instruction stringlengths 71 71.9k |
|---|
This program is a simulation of an ant colony, inspired by SimAnt. It doesn't do it off the batch; there must be code that instructs the ants to follow scent tiles in particular and react to the food.
main.cpp
It's the main file that must be modified to put more/less ants, more/less food/ants (generators or not).
#incl... |
I've written a to-do list app in React, as I am a beginner and this is my first app, I feel it can be improved. Some assistance in improving it, and how or why improvements are better would be much appreciated.
Here is a working demo of it.
var ToDoContainer = React.createClass({
getInitialState: function(){
... |
Following dreams, I have started learning Java for Game Programing purposes and, during code I figured out that Iterators such as Queue, Lists, Arraylists and what not are very common. I have written this code to replace any array and iterators based useage into one place.
what do i expect from this code?
Boost perfor... |
I have written a set of functions to compute basic mathematical operations for my own Java-based programming language. First I tokenize input from the source code file and store it in a String array. For the mathematics, I simply read through the array looking for an operator (+, -, /, *) and if I find one I call a ope... |
In my Rails 4 app I have this event listener:
$('.remove-tag-button').on('click', function () {
$.ajax({
type: "POST",
data: {id: <%= @item.id %>, tag: $(this).data("tag-name")},
url: "/remove_tag"
});
});
in three places and I'm wondering if there's a way to refactor.
I have an items contr... |
I implemented basic string compression algorithm that uses the counts of repeated characters. For example: the string aabcccccaaa would become a2b1c5a3. What do you think about this, is there a better way to do this?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char* compressString(char* arr, int size);
in... |
I am solving a puzzle (Finding if there exists an input for a given automata for which no matter what the starting state is, final state would be same everytime) and have written following Python code. A few testcases are written in check method in the code. For these cases program is running fairly fast. However, for ... |
I want to find a word in the string and replace it with new one. If the first letter in the word is upper case, the function should replace it with upper case, for example if you mean to replace the word "Book" with the word "dog", it should be replaced as "Dog".
Is there a better solution than this:
function myReplac... |
I need to create an object based on some properties of another given object. In my example setRules, add properties to object status.
Considering that the cases to be handled will increase increase I would like to figure out how to enhance readability.
I would like to know:
Could a switch statement increase readabilit... |
The full description of the problem to solve can be found here. The code I have written works fine but seems extremely verbose for what it's doing, I'm not sure if list comprehensions are meant to be used in the way that I have (maybe some kind of other construct would be more suitable?). Would be great for there to be... |
I have written a script to reduce/lower the version number stored in opkg status file using small shell script, This will enable us to force the opkg to install same version of a Debian package again.
Versions stored in the opkg files are as follows,
Version: 00.03.00a002
Version: 2013.07.001
Version: 2013.07.001
Versi... |
I've a piece of code down below that I'm really unsure about. Basically an user can type the url (urlStr param of the method) he wants. From this url I need to :
get the data as Base64 so I can display it in an html img src tag.
Being able to crop the image afterward and save the image as a file
What I'm a bit unsure... |
I want users to wait 9 minutes after their last comment. I have written this code. It works but do you think this is practical? Is there a simpler solution?
$now = new DateTime( date( 'Y-m-d H:i:s' ) );
$lastPost = new DateTime( '2016-01-08 13:16:59' );
$diff = $lastPost->diff( $now );
if ( $diff->format( '%Y-%m-%d ... |
I was writing some JavaScript that depended on several global variables being present.
I read about the "guard pattern" from a StackOverflow answer but since I need to check for multiple objects it quickly becomes quite tedious to have lines like this everywhere:
if (foo && foo.bar && foo.bar.baz) {
// access foo.b... |
I'm using maps to represent a polynomial.
The key is the exponent and the value is the coefficient : Map(exp -> coef)
e.g. 2.5*x^5 + 3.0 is represented by : Map(5 -> 2.5, 0 -> 3.0)
I wrote 3 functions (in Scala) to add such polynomials. Which one is the most elegant ? Do you have another version that is preferable/bett... |
I am calculating the number of people within a given age range. This is my current approach.
Note:
The persons is a List<Person>
The getDiffYears() returns the number of years between now and DOB of the person. It includes the month and day as well.
The method will be returning a HashMap<String, Integer>() (Can be cha... |
Similar to this question, but in C++. Although my priority is performance (and correctness!) rather than readability.
#include <algorithm>
#include <iterator>
#include <cstddef>
template <typename Container>
size_t count_unique(const Container& elements)
{
size_t result {};
for (auto it = std::cbegin(elements... |
Currently designing a homepage and from some initial tests users are experiencing lag.
I'm using some Javascript to create a parallel effect as well as an animated "click to explore" loop. Not sure if this is the cause of the problem or if there are any alternative ways to achieve the same effect that wouldn't be so in... |
From SICP
Exercise 2.28: Write a procedure fringe that takes as argument a tree
(represented as a list) and returns a list whose elements are all the
leaves of the tree arranged in left-to-right order. For example,
(define x (list (list 1 2) (list 3 4)))
(fringe x)
(1 2 3 4)
(fringe (list x x))
(1 2 3 4 1 2 3 4... |
This is a solution for the Day 8 hackerrank.com challenge. The basic idea of the challenge is to create a mapping of names to phone numbers based on the the given input, and later look up the phone numbers for certain names. If the entry exists, print it and its number. If it doesn't, print out "Not found"
Here's my s... |
I have created a project which uploads data from my local storage to my Google Drive account using the Google Drive API.
You can read about how to run it on its Github repository.
The main script upload.py:
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import json
import subproce... |
After 8 years with the same Apache webserver, the .htaccess file seems to be a bit heterogeneous. I have taken some care about readability, but there are still some problems (such as pages with www. prefix not working). How would you improve this .htaccess?
RewriteEngine on
ErrorDocument 404 /404/
# RENAME MYWEB
Rewri... |
Flambe is a really neat tool, even though developer dissapeared around march, and the proper camera access is missing (I could move to openFL, but I'm way too deep at the moment). This is my take at creating hybrid camera recorder (webcam for JS and frontal camera for AIR). Note that's early development, missing error ... |
Problem description:
You are given a phone book that consists of your friend's names and
their phone number. After that you will be given your friend's name
as query. For each query, print the phone number of your friend.
The first line will have an integer N denoting the number of entries
in the phone book. Eac... |
var headerTD = $('.ColHead').closest('tr').find('td'),
omitTD = $('.ColHead').closest('tr').find('td:eq(0), td:eq(1)');
//.each() method works
//--------------------------------------------------
headerTD.each(function() {
$(this).not(omitTD).css("border", "solid 10px red");
});
//--------------------------------... |
I do a lot of copying excel vba code related to classic ADO from workbook to workbook, so I've decided to add the code to a Class Module in a single utility workbook and then in all other books just reference the utility book and use instances of the ADO wrapper class.
The class module is called clDataAccess
I would li... |
As a follow-up of my previous non-off-the-bat Ant Colony Simulator, we have this one that works off-the-bat... quite; the code for when the ants find and take the food isn't really done but it would be almost impossible to do it anyway, if someone wants to contribute directly to the code, please do it in GitHub.
scent.... |
"You have just been hired at a local home improvement store to help compute the proper costs of inventory. The current prices are out of date and wrong; you have to figure out which items need to be re-labeled with the correct price.
You will be first given a list of item-names and their current price. You will then... |
This is the original code I had for removing duplicates from a sheet:
Sub Remove_Duplicates()
'
Application.ScreenUpdating = False
ActiveSheet.Range("$A$1:$Z$2000").RemoveDuplicates Columns:=Array(5, 10, 11, 12, 13, 14, 15, 16), Header:=xlYes
Range("C" & Rows.Count).End(xlUp).Offset(1).Select
Application.ScreenU... |
Stack Exchange sites support hiding text as a spoiler with >!; for example:
This text will be hidden until you hover over it/tap the "show spoiler" button.
This gets a lot of use on the Sci-Fi & Fantasy stack, usually to cover up key plot elements of a particular work (like the recent Star Wars film).
That’s a good... |
I wrote this in the last hour because I was bored. I was hoping I could get some feedback on this. It is a function that returns the price of a bitcoin and whether you should buy or sell it. I am thinking of setting it up as a function within a chat bot to spice up the chat a little.
import urllib2
import random
impo... |
I am trying to full one dimensional array in two dimensional array in Java.I did it using this way, is there another way better than this? .
public double[][] getResult(double[] data, int rowSize) {
int columnSize = data.length;
double[][] result = new double[columnSize][rowSize];
for (int i = 0; i < columnSize; i++) {... |
I've just implemented a simulation of tower of hanoi in Java. Any suggestions are welcomed. Here's my code:
static class Node{
int data;
Node next;
public Node(int data){
this.data = data;
}
}
static class Stack{
Node top;
String stackName;
public Stack(String name){
stackNam... |
I'm creating many builders where I use inheritance.
My resources have many properties and are stored in a Repository.
In rare case I need to update them.
When I update, I need to keep the same objectId (I track update on the repository).
I use the same Builder/Updater as it's easier for my users (there are more than 10... |
(See the next iteration.) This snippet is about computing \$k\$ shortest paths in a directed graph using this algorithm.
I would like to hear about API design, naming/coding conventions, and so on.
My implementation follows:
DefaultKShortestPathFinder.java:
package net.coderodde.graph.kshortest.support;
import java.ut... |
I'm trying to compute de Bruijn sequences for alphabets which have a number of characters which is a power of two. So the sequence must contain every possible subsequence of length \$N\$ from \$0\$ to \$2^n\$ as a sequence of consecutive characters exactly once.
I need to use only 2 digits (0 and 1) with a length \$N \... |
This is a follow-up of this question regarding MVC application architecture fit for automatic testing.
I have rewritten the DI code based on the answer provided there and also created some tests to see if I can properly benefit from the newly refactored code. I will repeat here the application structure, so that the q... |
I am developing an ERP system, called 'TeleMart' as a practice at Campus. I have noticed that one of my JavaFX Controller's have become quite complex and large, and most importantly, quite confusing. I have to write really large variable names for page elements, etc. Although I have a quite large code base, I want only... |
My question is about code efficiency. I recently had to write a Powershell 3.0 script which had the following criteria:
It had to pull all enabled user objects from active directory
It had to pull specific properties about each user object
It had to display what it was doing on screen so it didn't look like it was han... |
Given a binary tree organised as in the diagram below (a static tree represented by an array of 15 nodes), I am writing code to compute the interval represented by a given node at index i, given the interval of the entire tree (node 0)? My motivation to do this is to get rid of the need to store the interval in a node... |
I have Frankensteined the crap out of this method and just wanted to make sure of two things.
I'd like to make sure that this is the best route to take. If it isn't, I would welcome with open arms an alternative.
I don't typically use SQL in the code behind. I always use it in the markup. So I just need to make sure t... |
I'm mostly concerned about edge cases, although I think I dealt with them all. Improvements on code quality would also be much appreciated.
/*
printRadian(90) -> π/2
printRadian(-90) -> -π/2
printRadian(180) -> π
printRadian(-180) -> -π
printRadian(270) -> 3π/2
*/
function printRadian(degrees) {
... |
Inspired by Mayur Kulkarni's question this morning, I decided to post some code for the classic Towers of Hanoi problem, but this time in C++. Since this is fairly "textbook" kind of task, all suggestions are welcome.
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
class Hanoi {
typedef... |
So I have written a very simple program using a cocoa pods library to calculate the distance between different cities. Here is what the UI looks like:
So I have a textfield on top for entry of starting location, and then four other textfields for destination city input.
I went with nested if statements which I am not ... |
I have a JS file that creates an object with notes from a music scale when given a key (aka tonic/ note). The code works and does what I want it to do. I need a critique on the way it's written, what could be made better, quality of code — even if it's indentation. please. I've never written code so I have no frame of ... |
Given an angle in degrees, output a pretty string representation of its value in radians as a fraction.
Where pretty means:
Simplified as much as possible.
With no unnecessary ones.
Using the Unicode character that represents pi: π
With a single minus in front if negative (a minus at the denominator is not allowed).
... |
Is this an efficient way of finding the minimum using binary search?
//Find the minimum in a sorted rotated list of numbers
function findmin(arr, low, high){
if(low==high)
return arr[low];
if(arr[low]<arr[high])
return arr[low];
if((high-low) == 1)
return Math.min(arr[high], arr[low]);
var mid = M... |
I'm trying to define a function which takes an array and prints it to a predefined total width in as many columns as needed. Think of the way ls prints files for example.
Here is the kind of output I am looking for:
$ ./print-columns.py
Files
/home/stephen/dev/src/cmake-browser/cmakeclient.cpp /home/stephen/... |
I am developing a 2048 program in Python. As a part of that project, I am working on merging method that merges the given integer entries.
I am interested in some suggestion to improve my code.
def creating_resulting_list(length_line):
"""
Function that create a resulting_list with equal number of \
zeros... |
I'm playing around with hypercubes. For this, I need to create its edge set. Specifically, the edge set is the set of all bit strings with Hamming distance 1. An important property is that I want to generate every such pair exactly once. I do this with the following piece of code (I'm also providing a small benchmark f... |
I read user input from stdin in plain C.
The problem is that I want a sane implementation that is robust to errors and restricts the user to a certain input and doesn't suck in terms of complexity.
The function get_strings() reads input char by char as long there is no new line (\n), no EOF and all chars are passing ... |
I have been going back and forth on one certain part of my code. It works, but it doesn't seem right for some reason, as I believe there must be an easier/cleaner way to implement the NSUserDefaults. All of which are dates. I apologize that the code is so long. A lot of it is repetitive, and I want to learn the correct... |
Skip lists are a probabilistic alternative to balanced trees, they are balanced by consulting a random number generator, that determines how many pointerscalled node level to successive elements a node will have.
Skip list is a simple data structure that allows fast search within an ordered sequence of elements. Fast s... |
I have two lists: L stores some values and P holds values that are indices in the first list that should be printed. Lists are sorted in ascending order. Error-checking can be ignored, and both lists are valid and values are valid.
Do I understand correctly, that since I always continue from the place I ended at, and s... |
I was (yet again!) inspired by a previous question to post some code to solve the same problem. In this case, the problem in question is the Anagram challenge on HackerRank. The basic idea is that you're given some number of lines of input. Each line of input represents two strings (with no delimiter between them), eac... |
Based on the previous question, I have implemented all suggestions. Also, I worked a bit in this project to improve it.
Summary of improvements:
split the code into multiple files as .hpp and .cpp
removed STL functions
used only one sf::RectangleShape for border instead of std::vector.
I would like to know how I can ... |
I have made a loading screen (splash screen) just like the old C64. I have used a series of picture boxes and just change the coloured image using a timer and a case statement.
namespace c64
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
... |
I came across this interesting question while reading 'Cracking the coding Interview' and came up with a simple implementation. Any suggestions are welcomed.
Imagine a (literal) stack of plates. If the stack gets too high, it might topple.
Therefore, in real life, we would likely start a new stack when the previous ... |
I have solved a CodingBat problem: Given two ints, each in the range 10..99, return true if there is a digit that appears in both numbers, such as the 2 in 12 and 23. (Note: division, e.g. n/10, gives the left digit while the % "mod" n%10 gives the right digit.)
shareDigit(12, 23) → true
shareDigit(12, 43) → false
shar... |
The Ford-Johnson algorithm, also known as merge-insertion sort (the name was probably given by Knuth) is an in-place sorting algorithm designed to perform as few comparisons as possible to sort a collection. Unfortunately, the algorithm needs some specific data structures to keep track of the order of the elements and ... |
This question is in response to the code review here: Simple lightweight object pool. Please visit the original question for background.
I have taken on board all the suggestions made and carefully amended the code in response. As the answer is in two parts: one being the code review and that other being suggestions, I... |
I think the content is too large and I am deeply think about how to refactor it. Does anyone have good advice on refactoring it?
List<AccountEntity> fillNameAccounts = agentDao.getAgentListByIds(accountIdList);
for (T bean : results)
{
for (AccountEntity entity : fillNameAccounts)
{
... |
I have attempted to implement a similar version of the STL Vector; several functions are missing but I'd like a few words of advice on whether I am indeed on the right track or whether I should change my approach.
My objective is to understand how the vector works from behind the scenes and not to replace or use it for... |
I wrote the following code which transforms a nested data structure
(def board [[{:mine true} {:warn 1 :explored true} {:explored true}]
[{:warn 1 :explored true} {:warn 1 :explored true} {} ]
[{} {} {:flag true } ]])
into ... |
While working on a small project, I tried to implement a super simple tree class in C++. It supports an arbitrary number of branches from each node.
In addition to general comments, my main concerns are:
Are there other common tree functions that should be implemented? (So far I know about traversal and search, but ... |
I got my game working for so far, however, I would like the game to run faster. It's running at approximately 26 FPS when most of the blocks come in; my FPS goal would be about 60 FPS.
import pygame, random, sys
from pygame.locals import *
TEXTCOLOR = (0, 0, 0)
FPS = 60
BADDIEMINSIZE = 10
BADDIEMAXSIZE = 75
BADDIEMIN... |
Previously, I had written this program in C++ and asked about it here on Code Review. After spending some time with C++, I desired to become more familiar with its namesake. This is my first C program.
The purpose of the program is to help with remembering complex bash commands. It's invoked with arguments describing t... |
I am working on a UserScript that displays total flag counts and other information on the Flag Summary page.
Example:
Everything is working correctly but this bit of code seems rather repetitive and I'm sure it could be improved upon.
The following code pulls the total count of each flag type from the flag summary pa... |
I have the following functions and accompanying script. The purpose of these is is to extract XML data from one CSV column (one XML document for each row), and then transform it into a dictionary (where the tags are the keys and the text are the values). Then I update the headers in the original CSV with the keys and t... |
I am attempting to build my own website, based off Google's Material Design principles, to better my design/UX skills.
I am currently working on effects for my navigation, I wondered what would be best to lower browser resource usage when viewing my web page.
Quick Example:
When scrolling, without wrapping certain p... |
With the recent craziness of the Powerball in the US, I got interested in building a little lotto simulator to see how frequently I could win with purchasing large amounts of tickets.
For those not familiar with the game and its odds and ways of winning, a Powerball ticket consists of 5 white balls between 1 and 69 and... |
Is there a more efficient way to run this? I am especially interested in a way which perhaps does not require a for loop...
shopt -s nullglob
file=
declare -a ARRAY1
ARRAY1=( ~lettus_*.sh )
for file in ${ARRAY1[@]}
do
##
## Get <name> from /some/path/lettus_name.sh
##
# remove .sh extension
file=$... |
I created a quick calculator in Javascript and I was wondering if there was a way to make the code look prettier or make it simpler. To me, it looks really cramped and messy and I'm not sure how change that.
function calc() {
var height = (document.getElementById('height').value) / 100;
var weight = document.ge... |
Which option is better?
In the first case, I use a universal repository that can work with any entities. The methods of this repository have many parameters, such as string queries, table names, entity mappers, etc. Another option is to use for each entity separate repository (which is probably a good practice).
Advan... |
We are given two list on integer arrays, and the objective is to retrieve another list which contains the duplicates in both lists.
The code developed is the following:
public List<int[]> GetDuplicates(List<int[]> pInputList1, List<int[]> pInputList2)
{
var outputList = new List<int[]>();
pInputList2.ForEach(x... |
I have written command line chess in Python 3.4.3 and the code is included here. The chessboard is printed to standard output as a 2-D array; for now I only have CLI and the output in the command line is as below:
['Rb' '0 ' 'Bb' 'Qb' 'Kb' 'Bb' 'Nb' 'Rb']
['Pb' 'Pb' 'Pb' 'Pb' '0 ' 'Pb' 'Pb' 'Pb']
['0 ' '0 ' 'Nb' '0 ' ... |
Do you have in mind a way to compute the following sum
$$R_{i,j,k} = \sum_{l=0}^{2} J_{i,j,l+3k} v_{i,j,l}$$
obviously in a vectorised fashion? This may sound like an equivalent of:
c = np.einsum('ij(l + 3k),ijl->ijk', j, v)
where of course the notation 'ij(l + 3k),ijl->ijk' is not accepted by einsum.
I tried with the... |
I have a single page application where the resources sit on the classpath. Any request for a resource that doesn't exist should redirect to the index.html page. Resources should be mapped to memory on first request and then all subsequent requests should load from memory.
Have I made any mistakes with how I should be u... |
This uses a linked list to store the data. I used a linked list as it's the only type of data structure that I know currently. Using chrono, I can get microseconds into my timer and <random> for a completely random scramble. A main goal of this program is to be fast in the sense of less keystrokes to get scramble and s... |
Here is my scenario:
Every user checks in every five minutes.
If some user doesn't check in after 5 minutes, I should be able to keep track of it.
If some user doesn't check in N number of times, an alert should be generated , like send email or SMS.
Here is what I have implemented so far:
var Report = function(atte... |
For test cases I need a unique way to set any structure to zero. For openCV I wrote this:
// Fill every basic structure of openCV with zero.
template < typename Tp >
void zero( cv::Point_<Tp>& p ) {
p.x = p.y = 0;
}
template < typename Tp >
void zero( cv::Point3_<Tp>& p ) {
p.x = p.y = p.z = 0;
}
... |
Scenario: Count the total number of times a char occurs in a word.
For instance, "aaabbcccdddaaaa" should print out "a7b2c3d3".
Can you please critique my code?
import java.util.HashMap;
import java.util.Map;
public class Demo {
public static void main(final String[] args) {
final Demo d = new Demo();
... |
I have a number of XML files containing data I would like to analyse. Each XML contains data in a format similar to this:
<?xml version='1.0' encoding='UTF-8'?>
<build>
<actions>
...
</actions>
<queueId>1276</queueId>
<timestamp>1447062398490</timestamp>
<startTime>1447062398538</startTime>
<result>ABOR... |
I am trying to get this code running as fast as possible when traversing through my stack of my DFS currently the input files are like so:
0 2
2 1
1 4
4 5
5 6
10 8
8 9
9 6
7 6
3 4
0 1
3 9
0 4
Where my Maze class will tie the numbers together and create a graph for me. After the graph is created my DFS class runs thr... |
I'm writing code to find the available ports on 127.0.0.1. I'd like it to be faster, but it's functional now.
def find_open_ports():
for port in xrange(1,8081):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
res = sock.connect_ex(('localhost', port))
if res == 0:
yield ... |
In the beginning of my methods that handle the calls from outside, I run this method to make sure that everything's OK, or let the caller know what's wrong:
private static void Validate(Guid userId, EntityState state, object data)
{
if (userId == Guid.Empty)
throw new Exception("Token unrecognized!");
if (state... |
This is a script that accesses the SE impromptu APIs to receive the fkey, a variable need for connection to chatrooms, and uses it to build a websockets connection which is handled by Node.js.
This is also available on GitHub.
It requires your username and password in the ws.js file and looks like this once executed:
... |
private void moveViewToScreenCenter(final ImageView img, int x) {
DisplayMetrics dm = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(dm);
img.animate()
.translationX(0)
.withEndAction(new Runnable() {
@Override
public vo... |
This program is meant to ease making mods for a game. A mod is made with XML. I used the lxml library to handle making the XML. I used PyQt for the GUI and this code is the functionality of the GUI. Most functions do just what their name says: open file opens a file, save saves, addFunction makes sure that button that ... |
I have implemented the "Find the N longest lines in a file" problem from CodeEval quoted below.
I got a full 100 score and 182ms execution time of their data set on the site so I consider the code to be working and effective. What I'm wondering is, is there something I can do to make this faster than it already is? Di... |
I need to read databases which contain 44-50 tables, with around 5 million entries in total (~ 100k entries per table).
The data consists of positional tracking data in sports (players, refs and the ball) and match-events (shots, plays, tackles, ...):
Match-events are negligible regarding performance.
Table: PlayerXYZ... |
I'm trying to refamiliarize myself with Java and working with it, so I've implemented my own version of a BitArray. Basically, it's an array of integers that maps 32 boolean values to each integer. This means an array of 32 boolean values only takes 4 bytes of space.
I was attempting to implement a Sieve of Eratosthene... |
I feel that I have done as much as my knowledge base allows me to on developing this tic tac toe program. I would love for anyone to critique it and tell me of any good/bad points.
Includes two players, optional AI, optional first turn and a scoring system.
The two things that I am unsure about are the 'GameLogic' cla... |
Question:
Is there a way to more efficiently or more readably write a loop that creates multiple types of controls?
Background
I've been trying to learn C# by converting some of my older VB.Net programs over. This is a method I use after the main form loads to populate a TableLayoutPanel with controls. Eventually looki... |
I have a "manager" class that returns objects when requested. The if the required object already exists in the object collection it is returned, else a new one is created, added to the collection, and returned. I also need to periodically remove the objects from the collection when they're no longer required. This is d... |
I have made the decision to move the storing of session data from the filesystem to the database. Our application is growing at pace and we are having issues with the load balancer breaking the sessions (even with sticky sessions on).
Whilst obviously the idea here is to have my code reviewed, I have a few questions/ar... |
I currently use a data structure like this:
(def sample-board
[[{:mine true} {:warn 2 } {:warn 1} { }]
[{:warn 2 } {:mine true} {:warn 1} { }]
[{:warn 1 } {:warn 1 } {:warn 2} {:warn 1 }]
[{ } { } {:warn 1} {:mine true}]])
Now I want to create a copy of the fi... |
I am creating a util module that I'm using to communicate with a MS-SQL database. I want each public method to return a promise. I started with a private function that executes a DB query and returns a promise. The function establishes a connection to the DB then it executes the query. My current code just lets all err... |
I am creating a simple program that will do three things: add up the prime numbers found within the range set by the user, print out the entire list of prime numbers, and print how many prime numbers were found.
# Starting number
lower = int(input("Enter lower range: "))
# Final number
upper = int(input("Enter upper r... |
I'm working with TCP Sockets and I've build a simple packet struct that turns it into a datagram protocol. I've created a class which returns "promise" Tasks for Packets. Packets are very simple, they consist of:
struct TCPPacket
{
unsigned short size; // contains size-1
// such that size r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.