instruction stringlengths 71 71.9k |
|---|
Some coworkers and I sometimes want to delete folders, only to get the very informative: "Permission Denied" message. I had discovered Handle.exe and Process Explorer to help with this, but the method was still too manual and cumbersome.
Thus, I decided to write this Python CLI script to release locks on a given file. ... |
I've just started a self-learning "course" on Python practical programming for beginners. I found this book online, and decided to go through the chapters.
The book had a half-complete implementation of a Tic-Tac-Toe game, and I was supposed to finish it as an exercise. This is my code so far:
theBoard = {'top-L': ' ... |
I am using a foreach loop to sort an associative array alphabetically. I would like to know if there is a more proper and/or efficient way of doing it.
The array:
Array
(
[gr_c] => Array
(
[f] => 'value...'
[a] => 'value...'
[d] => 'value...'
[m] => 'value...'... |
Is there anything wrong with the following implementation of an in-memory top-ten bought products tracker?
public class Main {
private static List<Integer> topTenItems = Collections.synchronizedList(new ArrayList<Integer>(Collections.nCopies(10, 0)));
private static List<Integer> topTenScores = Collections.syn... |
Perfect Hash Families (PHFs) are a widely studied combinatorial object. Essentially, they are 4-tuples (N; t, k, v), where the PHF is an N by k array of v symbols. For any t columns chosen, there is at least one row of those chosen columns that has no symbol duplicated in that row.
I want to be able to count how many "... |
For a little toy project of mine I need to have data available in a certain format in order to be able to feed into a Recurrent Neural Network (Long short term memory), it uses HearthStone card data that is available in JSON format.
Example input:
{
"id":"EX1_306",
"name":"Succubus",
"type":"Minion",
"f... |
I did not implement a priority queue in Dijkstra. I'm not sure if a trivial priority queue is the best choice, since, after each iteration, several elements change their value. Maybe it is better to just "bubble" modified elements to their new places.
Tests are implemented very roughly, but it is not the point here.
im... |
This Java Swing code consists of 2 JLists and a delete button. When I select an item from locationList, it will also delete items from branchList. This is achieved by using the equals method to compare object between the two lists.
Is there any better solution/data structure that I can implement where when I delete an ... |
Implementing the July 2015 Community Challenge seemed relevant considering it is election time.
I decided to go with the strategy pattern as this can be implemented in many different ways. I did my own implementation of this first, and then later also added a "PascalElection" strategy, as that code was translated and a... |
public struct DateRange : IEquatable<DateRange>, IComparable<DateRange>
{
private readonly DateTime _min;
private readonly DateTime _max;
public DateRange(DateTime min, DateTime max)
{
if (min.CompareTo(max) > 0)
throw new ArgumentOutOfRangeException("max", "Cannot be less than min.... |
This is simple code that recursively downloads articles from the public WordPress API:
import requests
from pymongo import MongoClient
client = MongoClient()
db = client.wp
payload = {
'number': 100
}
url = 'https://public-api.wordpress.com/rest/v1.1/sites/{site_id}/posts'
response = requests.get(url, params=pay... |
I've thrown together this simple chat program, and while it works. I think it could certainly use some improvement. Here's how it works.
Obtain user input by removing all punctuation from the input string, splitting it on whitespace, and converting it into a set.
Loop through a list of possible input sets, and check t... |
I have to show a select control of students with event information
where Monday, Tuesday, Wednesday, Thursday and Friday are Events. (Independent buttons). The second columns are Events too, but you can add these Events using the "Add" button.
Data flows in like this:
I have to maintain the state the state of every st... |
I have a superclass with several subclasses. Each subclass overrides the "solve" method with some a different algorithm for estimating the solution to a particular problem. I'd like to efficiently create an instance of each subclass, store those instances in a list, and then take the sum (or average) of the estimates t... |
I am building an Android application and there are five Activity classes or if you're familiar with the MVC pattern they would usually be the Controller classes.
Specifically a User will enter one of these 5 Activity classes (by navigating throughout the app) and sometimes they might upload a photo. Now the code for u... |
This is a follow-up question to original Prorated Refund Calculator. Here is the summary of the changes I made since last, thanks to the good answers and some study of my own.
Did away with bleeding-edge ECMAScript 6 code that was causing compatibility issues with some browsers.
Added more input validation.
Added a u... |
I have a website for my car enthusiast club ("example.org") whose content can be divided into three main sections: Startseite (the "front page" of the site), Mitglieder (membership directory), and Vereinsinfos ("about us"). For each section, the content is handled by a corresponding PHP script: /home.php, /mitglieder.... |
The idea behind the encryption is that it stores the key within the final encrypted password. When the user inputs a password for the first time, they also have to pick an element from a list of elements, and that determines where in the final, encrypted password the key is stored.
This is crucial for decryption.
The ... |
I've recently started using PHP OOP, and I'm now working on an application where different company representatives can create job offers that candidates can look at.
I have a variety of objects for most entities such as Company, Candidate, Offer.
The problem that I have is that these objects all need to be stored in a... |
The opening sentence of an answer I received in my previous post snowballed, and led to completely ditching the previous approach. Mocking my IDE with a MockFactory worked ok, ...for some values of "ok" - the more components needed to be involved, the messier the setup code was getting.
So instead of manufacturing mock... |
Is this a practical algorithm for pattern matching in a text? Assume text can be very large, is there anything I can do to speed up the performance?
public static int match(String pattern, String text) {
int i = 0;
int M = pattern.length();
int N = text.length();
int ret = -1;
while (i < N) {
... |
Problem 4
As per the given link, this exercise is part of recursion lab.
Printer A prints a random x copies 50 ≤ x ≤ 60, and Printer B prints a random y copies 130 ≤ y ≤ 140. Can the two printers be used in a way that guarantees that the number of copies is between some lower and upper bound?
Hint: Try using a helper... |
Here is the source of the question:
GitHub
Given a singly linked list, swap the list items in pairs (reconnect
the pointers, not simply swap the values). For example:
Before: A->B->C->D
After: B->A->D->C
See the method reversePairs.
Node
class Node {
private Node next;
private int data;
public Node... |
I have the following configuration:
$('document').ready(function () {
var what0 = [
["http://validator.w3.org/unicorn/", "Unicorn"],
["http://validator.w3.org/", "W3C Validation Service"],
["http://jigsaw.w3.org/css-validator/", "W3c CSS Validator"],
["http://text-compare.com/", "T... |
In essence, what I'm looking to do is split a string into one-word and two-word segments, and train classifiers against them. First it lowercasifies the string, then strips all non-alphanumeric characters.
Then, it splits the strings into a list of one-word entries. Afterward, it creates a new *[]string which it fills... |
I'm currently taking a look at Snap with Haskell. I'm pretty new to Haskell and functional programming in general and am working out the best way to handle errors. Currently I have something like this
createReport :: Handler b Api ()
createReport = do
report <- readRequestBody 65536
modifyResponse $ setHeader "Content-... |
I have created what was a rather simple piece of code to calculate the factorial of a number, although I wanted to ensure that my program could calculate the factorial of any given number. To do this, the only data type I thought was relevant was BigInteger. The problem I had with this was that my code quickly became q... |
I have two jQuery Ajax callbacks in succession, to fetch two sets of data from two different URLs, before combining them.
$.ajax({
type: "GET",
url: numeratorUrl,
error: function(request, status, error) {
_this.showErrorMessage(request.status, error);
},
success: function(data)... |
I'm using Cordova with jQuery and jQuery Mobile to develop a hybrid app. In this app I need to save data that I get from a server.
The data is a JSON. I chose this SQLite plugin for Cordova to save the content in tables for easy access.
I make an AJAX-GET call to get the data I need and call the function below with the... |
I have the following spaghetti update method and I would like to improve its coding style.
This takes an incoming PUT query for a survey object and updates it accordingly.
update: function(req, res) {
var slug = req.body.slug
, errors = {}
, surveyDiff = req.body.diff;
surveyDiff.slug = slug;
// Certain... |
Given a Map<K, Object>, I'm returning Map<K, String> or throwing an Exception for at least one non-String value.
private static <K> Map<K, String> validate(final Map<K, Object> map)
throws NonStringValueException {
final List<Object> invalidValues = new ArrayList<Object>();
final ... |
I'm trying to implement a HashSet that it's accessed from different thread for querying, adding or deleting elements. It doesn't make sense to use a Dictionary for I got several search keys so I won't get benefited much for the speed provided on querying.
My real problem is when trying to remove several items matching ... |
I'm trying to create a function for a dynamic dropdown. I have done it this way and it works, but I want to make my code cleaner.
function renderRowCounter() {
var rowCount = [25, 50, 100];
var first = rowCount[0];
var items = '';
$.each(rowCount, function(i,v) {
items += "<li><a href=\"#\">"... |
This is an iterative review request of this other question I posted.
As a follow up to that previous question, I changed the pattern completely and I went to an events-based approach, which might be more relevant.
Pre-text and background story
To address some of the points in that question (to hopefully avoid repeats)... |
How would you rewrite this code which I have now:
uint32_t Utils::stringToInt(unsigned char const* buffer, int len)
{
uint32_t result = buffer[0] - '0';
for (int i = 1; i < len; i++) {
result *= 10;
result += buffer[i] - '0';
}
return result;
}
I need the lowest possible latency. It's v... |
This is a followup post to Particle Swarm Optimization.
I wrote a script in Python for particle swarm optimization and I posted it here to get comments on the design. I was told that encapsulating the list used to hold the particles in a class would be a good idea, but it seemed like putting the Particle class I alread... |
I'm still investigating the problem with decimal to word conversion. I understood the basics, but now my goal is to learn how to add in base-26 (the English alphabet) or base-52 ([a-zA-Z]) or base-62 ([a-zA-Z0-9]), etc.
I've written the following code and it works, but I think it could be written better and run faster... |
I would like to create a wrapper for a Boost conditional variable:
class Cond_wrap
{
private:
boost::condition_variable cond;
boost::mutex mutex;
bool work_to_do;
public:
Cond_wrap()
{
work_to_do = false;
}
void notify_all()
{
boost::mutex::scoped_lock lock(... |
For my current project I need to validate responses. The requests will be send from multiple different shell scripts and should be controlled from another script. I'd never targeted a .sh with a .sh before, so let's try some FizzBuzz first.
Fizz.sh
#!/bin/bash
if [ $# -eq 0 ]
then
echo "This FizzBuzz is interactiv... |
In my app, the user can upvote a cycling track if they want to ride on it.
Note: I do understand I can use a boolean column to check if a user has voted or not, but, I am just testing at the moment.
My logic works the following way:
First, it needs to determine what user is accessing the program, which is done by se... |
I had a test before and had to do this task:
Create classes: Cat, Dog and Petshop. Types Cat and Dog have fields Name and Breed and method Introduce() which prints text "I'm (Name) of (Breed). I'm a cat (or dog)".
The class Petshop collects different pets in its container.
We may add new pet to container using metho... |
I've put together another simple query that allows you to search post/comments with specific keywords. At the moment, only post bodies are checked.
DECLARE @search_keywords NVARCHAR(MAX) = ##SearchKeywords:string##;
DECLARE @search_type_id NVARCHAR(MAX) = ##SearchTypeId:string##;
IF (LOWER(@search_type_id) = 'post')
B... |
I am writing a unit test to be sure the code can connect to aws via boto, since I will be putting the credentials in place via some other process than code deployment. So far, I've only figured out how to check if I have a valid connection by looking at an S3 bucket, but am hoping someone has a more direct way to chec... |
I was thinking the other day how could I get the icon from a website and make it show and update when it is updated on the site so I made this code:
URL url2 = null;
boolean updateIcon = true;
try {
url2 = new URL("https://dl.dropboxusercontent.com/s/70rhm66myw8ay2v/Perception%20Logo.png");
} catch (MalformedU... |
For my website, I use the opengraph to send the right data to the crawler.
On the top of all pages on my website, I include the opengraph-script, like this:
if (preg_match("/facebookexternalhit/is", $_SERVER['HTTP_USER_AGENT'])) {
include("./facebook-crawler.php");
exit();
}
facebook-crawler.php:
## I... |
I have a piece of code that checks if two strings are anagrams. I would like this to be as pythonic as possible.
def are_two_string_anagram(string1, string2):
if len(string1) != len(string2):
return False
def char_count(string):
char_count = {}
for s in string:
char_count[s]... |
I built a small store site for learning purposes. I loaded my 'products' from the db into a Products class. I used a method from this class to display the products in HTML. Of course, the HTML contains 'Add to Cart' buttons which POST the product ID and quantity when a button is clicked. The result is that the POSTe... |
I have a homework question that asks me to get 2 integers from the user, put them in shared memory, fork a child, have the child add them and put the result in shared memory, and then the child will end and the parent will print out the sum. The program must also loop until the user does CTRL+C, at which point it shou... |
I was posed a question as follows:
Given a sentence like "John is a bad man", lets say all the formatting disappears and you are left with one string "johnisabadman". Given a dictionary of words, design an algorithm to find the optimal way of "unconcatenating" the sequence of words. The optimality stems from the parsi... |
I am new to C++ and programming in general. After reading through my first book, I decided to take on some programming exercises and test what I learned. The exercise is phrased as follows:
Find Cost of Tile to Cover W x H Floor - Calculate the total cost of tile it would take to cover a floor plan of width and heigh... |
I have implemented Dijkstra's Algorithm in C, using arrays instead of any structs.
Here is my implementation:
#include <stdio.h>
#include <stdlib.h>
int G[20][20], distance[20], inSet[20], q[20], parent[20];
void print(int V)
{
int i ;
for (i = 0; i < V; i++)
{
printf("i = %d parent = %d distanc... |
I have a piece of code that searches for XMLs in given folders, delete the ones older than X, zip the ones older than Y and delete zips older than X. It works perfectly but I have a terrible feeling that this is very inefficient code.
A little more information: It reads a config file for the times to delete/zip using ... |
I am currently learning javascript and I attempted to make a Person class (note - this was part of a practice exercise, so some of the design decisions may have been due to the requirements).
Specifically, I am looking for feedback on:
Usage of prototypes (i.e. from my understanding, prototype should be used when th... |
This is my first program in Python and first time I'm writing in dynamically typed language. I have substituted real detectPeaks function with a simple placeholer. I'm aware of several problems with this program.
I still don't quite know how to 'live with' Python scoping, hence the qFixfunction. I didn't bother to find... |
The script is intended to return an array with texts containing specific words in English and the equivalent texts in Polish from EUR-Lex - a website with EU documents.
The script downloads the page which address is specified by the passed variable. Then this page is parsed using regular expressions for the document co... |
I have written this code for a two input calculator. Is there anything I can do to make this code more efficient?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CalcGui extends JFrame {
private JButton buttonZero;
private JButton buttonOne;
private JButton buttonTwo;
p... |
I have recently started researching some computer vision, and in the process of discovering some interesting things I have been compiling some functions that allow me to manipulate images at a low level. I am not interested in replacing any of these functions with already existing, built-in functionality of canvas (but... |
This code is used for displaying only certain content of the form instead of displaying all the form content. I am using it to stop the users from filling all the form fields if those are irrelevant to the user.
var checkbox = document.getElementById('checkbox');
var checkbox1 = document.getElementById('checkbox1');
... |
A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted S1, opens every locker. Then the second student, S2, begins with the second locker, denoted L2, and closes every other locker. Student S3 begins with the third locker and chan... |
I would appreciate some help with camera movement and zoom. Is there any easier way with cleaner code, or simply how can I improve it?
Window size: 800x600
Image size: 1200x900
This is my code so far (you can move with the camera only around the image and use zoom):
package game.engine.gui;
import game.engine.Engine... |
Recently, I implemented an RenderBatch class, which renders any objects, using a specific shader (with its configuration). I'd like to improve on the way my render process works.
RenderBatch.h:
#pragma once
#include "alpha/Shader.h"
#include "alpha/RenderComponent.h"
#include <glm/glm.hpp>
#include "alpha/Mesh.h"
#inc... |
I was asked to create a function that return first UNIQUE integer from given array of integers. In a case of success the function return the unique number in a case of failure return -1. The complexity should be \$O(n \log(n))\$. How can this be improved?
function solution(A) {
var returnNumber = -1;
var tempA... |
I wrote some code to translate numbers ( for now just positive, up to the 32bit limit ) into English words.
Everything works and I'm happy. I searched through the site looking for a comparison code but I couldn't find a C++ version that goes above 999 to use as example
I had a few assumptions:
No need for and, just sp... |
I've built a simple decorator that wraps a function in a general Pygame game loop. It also allows for the programmer to set the tick rate.
import pygame
import sys
pygame.init()
def game_loop(tick_rate=60):
"""
This simple decorator wraps functions
with a pygame game loop. Here's an
example of usage... |
I'm creating a JavaScript app for a esoteric language, Marbelous. One of the features of this language are the devices. Each cell has a device, and each device has certain properties.
In order to represent this, I've created a massive object (or in my mind: HashMap) to store all of this data. This object stores stat... |
I don't like how transforming the data requires a bunch of nested functions. It's not very readable. Is there a more readable way to do the same transformations in Lodash?
var templates = {
"fullRenderV80": {
"stuff": "stuff",
"screenshots": [
{
"device": "iPhone 6",
"position": 1
... |
This code allows me to compare two complex objects, which are stored in a relational database, to see what has been removed from the objects. These objects have a unique integer primary key. They are also composed of other objects hierarchically.
The Difference method is used within a database application (code not ... |
I am currently trying to learn Lambdas and following the book Java SE8 for the really Impatient and just finished Chapter 1 of it. This is the question, I am trying to get done with:
Didn’t you always hate it that you had to deal with checked exceptions
in a Runnable? Write a method uncheck that catches all checked
... |
I wrote this program where you can input x amount of words that of length x that checks if the grid formed is the same words vertically as they are horizontally:
F I L E
I C E D
L E A D
E D D Y
The words can be entered in any order and the letters must stay in the same order. i.e. F I L E can't be F E L I
The permut... |
I am currently preparing for my exam and I am trying to implement some abstract data types with linked lists as preparation for the exam. I found an older exam from my prof. and he wants us to implement an ADT stack with an inner class ListElement.
He has given us the interface, so it doesn't need to be implemented. He... |
I'm having to dabble with caching and multithreading (thread per request), and I am an absolute beginner in that area, so any help would be appreciated.
My project requirements are:
Cache one single large object that has ether interval refresh or refresh from user
Because retrieving object data is very time consuming ... |
void chrrem (char arr[], size_t len, size_t pos)
{
memmove(arr + pos, arr + (pos + 1), (len - pos) + 1);
}
It is supposed to be just fast.
Erases the character pointed by pos (starting from 0)
Note that this function works with a statically allocated array like so:
char arr [256] = "Mystring";
// >>
chrrem (arr... |
This is a small object that allows you to pass an obj and a property name using its helper functions to create a typed var that won't save a value to the property if it isn't the right type.
This was just for fun, and I am interested on getting some feedback on what I could have done better/cleaner.
/* JSTypes is the... |
I'm implementing several data structures in an attempt to learn C++. Below is a binary search tree that I've implemented to learn about pointers, dangling pointers, and memory leaks. I was hoping someone could critique my code, point out any problems that they may find, or any inconsistencies. Please, be as harsh you f... |
I call these text updates "Feeds". A Feed object has some basic attributes like its content string, how many lives it has and its priority in the queue. I haven't made a unittest for this one, but below I have added a small test function for the purpose of posting this question. I use this to update statusbar in GUI ap... |
Please ignore row "B. and C." as it works in the environment where it was implemented and is missing the JavaScript reference. The rows highlighted in light blue are the issue. I injected row "A." to calculate (addition) the input of the rows above it. I am appealing to experts who know how to better recognize loops... |
I have a Controller which uses an application service to accomplish its tasks. The service class is starting to grow big and developing multiple dependencies. So I am thinking of replacing the single big service class with multiple command handlers, each handling a single responsibility. This is how the old and the new... |
I created 3 different implementations (which produce the same results) using the count_if function from STL. I wish to check the number of elements in the vector which are strictly less than 6.
These are:
C++ lambda function
Global function (no functor)
Using class and creating my own functor
These implementations ... |
The purpose of this script is to enforce some rules for validating a keyboard shortcuts definition. In my case I want to reject duplicates keys improperly added in the combo properties. This code rejects key combinations like CtrlAltPPwhich are not valid.
I would like to know what are the best practices regarding varia... |
I have a function that breaks up a source file and checks each token against a keyword list to determine whether its a particular file type. How can I improve this function? Tokenization is a class that contains a function to break up the source code.
public static boolean validationTypeOfSQL(String sourceFile, Tokeniz... |
I'm learning regex with sed to extract the last field from file named "test". The method I'm trying gives desired output.
Please suggest if this method Im trying is effective way of doing it. Also when should we use "-e" option with sed (please give an example — I couldn't find examples)
~# ] cat test
example.com. ... |
This is a Python library for efficiently tracking span information while parsing source code, and generating errors on those spans.
I intend to use it in my rewrite of mypy's Python parser to add column tracking and better diagnostics, but this code could be used by any parser.
I am using PEP 484 type hinting (which ca... |
I tried to answer the question "How to print a hash in Perl, such that 3 key value pairs are printed on each line?" like this.
As I got an uncommented downvote, I'd like to ask: What's wrong with/How to improve:
use Modern::Perl;
my %h = ();
for (0..7) {
$h{$_} = chr(65 + $_);
}
print %h, "\n";
my $cols = +$ARGV[0... |
I have a Swing vector-program similar to Dia targeting RAD. There are some plug-ins that let you
create structures like Rectangle, Text and Circle but also complex types like Table-Columns.
generate files like Spring-Roo-Script, grails-script, SQL-Files and svg-Files.
In the Center you have the Drawing-Panel (DrawPa... |
I'm learning JavaScript and I've made a very simple little document-modifying script that prints a message as if it was someone typing into a console. It practices recursion and in my opinion, I feel a bit iffy about the number of if-cases in the code. My main concern is the JavaScript though I know there's still a lot... |
I'm working on an upload file program in PHP in OOP style. I need some feedback about code.
index.php
<?php
require_once('./lib/upload.php');
?>
<?php
if(isset($_FILES['file'])){
$fileupload = new upload();
if(!$fileupload -> sizeck()){
if($fileupload -> extens()){
if($fileupload -> upload... |
I wrote this code to De- and serialise structures afap using IL generation (comments describes C# analogue). What can be improved here?
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
namespace StructInterop
{
public static class StructInterOp
{
... |
I implemented a D-ary max heap backed by a vector for resizing. I would like to know any possible improvements in performance, design, and in the code in general.
#pragma once
#include <vector>
#include <iostream>
#include "Comparators.h"
template<typename T>
class DHeap
{
public:
DHeap();
DHeap(unsigned);
... |
The purpose of this file is to make an Ajax call to a certain endpoint, and update a certain fields on the HTML page, auto populate the dropdown-menu, table, and piechart.
My script will turn this:
to this:
I'm not sure whether or not I should do all my logic within my Ajax success. Should I separate it? This is what... |
My logic is as follow:
Convert actual time to minutes.
Extract seconds from minutes (30:04 -> 4 seconds).
Subtract seconds value from minutes (step1-step2) to get time only in seconds.
Convert time in minutes (step 3 output/60) to hours.
Now suppose i got time as 5404 which corresponds to 1:30:04. When I divide 5404... |
I am working on an algorithm, which should group connected Arcs. The situation is described via code examples below.
I have Arcs:
public class Arc
{
public Point StartPoint { get; set; }
public Point EndPoint { get; set; }
public bool Visited { get; set; }
public Arc Successor { get; set; }
public A... |
My problem statement is:
Write a function to indicate if a given Sudoku board is legal. This function takes a Sudoku board (which you may assume is a N2xN2 2d list of integers, where N is an integer), and returns True if the board is legal, as described above.
And here's my solution:
import time, random
def solve_al... |
I wanted to render the textures that comprise a bitmap font glyph onto the screen directly as an Image in libGDX. When you make a bitmap font using a program (such as Hiero), it generates a text readable .fnt file along with a .png file that is the sprite sheet for the font. The only thing missing is a matching .atlas... |
I have a button dropdown that you can select different currencies from. When you select one, it replaces the button value with that currency type, and displays the currency symbol in a span in front of an input.
I have done some refactoring where I now have just one function getCurrency() that accepts parameters and i... |
I create blog posts as blog1.php...blog20.php...blog500.php etc and redirect users from blog.php (code below) to the most recent blog post as determined by the blog post with the highest number in the filename.
Here's how I'm doing it, but I have the sense this could be much cleaner and more elegant:
$directory = "/va... |
I am writing a piece of code in c# that mimics the behaviour of following SQL function STR in the following case:
declare @number numeric(19,15) = 219.37345462345234235
SELECT str(@number,9,9) -- 219.37345
declare @number numeric(19,15) = 19.37345462345234235
SELECT str(@number,9,9) -- 19.373455
Following is an... |
I never took an application in a Model-View-Controller architecture and have some difficulties in front-end. The following code works fine, but what can I do to make "layers" of better code and even the application directories?
This is a single file located in /resources/js/controller.js.
Controller.js
var app = angul... |
Quite a little while ago, I wrote a VBA macro to generate fiscal calendar date records. That macro did the job all this time, but I needed to be able to generate fiscal years from an ETL overnight process, so I rewrote it in a small C# console application.
I went with full-on dependency injection and IoC, wrote dozens ... |
I have come up with a solution to the equilibrium index problem with help from the answers off here:
val in = Stream(-7, 1, 5, 2, -4, 3, 0)
val sum = in.scan(0)(_ + _)
val hash = (in zip sum) map { case (e, lsum) => 2*lsum + e }
val target = sum.last
hash.zipWithIndex.collect { case (e, i) if e == target => i }
It's u... |
I've made about 2 forms that have a server side action using PHP. For the first one, I made a variable for every form field and mapped it to $_POST["name"]. For small amount of fields, it's not a problem, but it's tiring for large amounts.
For my second form, I used the scripts below. The problem I had with it was how... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.