instruction
stringlengths
71
95.1k
I have a very large number (millions) of messages, each labeled with the unixtime it was sent in a SQLite database. Each message has its own userid, for the user that have sent it. I want to know what's the max number of messages that is sent within an 24hr timeslot for each user. The 24hr timeslot is defined as the ti...
I am building a form with multiple select option fields. I am trying to only show the next field if it exists as a combination in the CSV file I am reading in. It's working fine right now and I am using onchange for each select field to call the next function. Is there a way to reduce to the code and make it more e...
I'm porting some Obj-C code to Swift, and I've written the following code to allow me to deal with "static local variables" which do not exist in Swift. A static local variable has these requirements: it is shared between all instances that access it it has one assignment method which only sets the value when it is f...
Sometimes you want to add/remove items from a collection inside of a foreach loop. Since this isn't possible, a common pattern is to add the items to a separate collection, then add/remove those items to the original collection after the foreach is finished. I'm wondering if this can be automated. Here's one attempt. I...
I have a base and derived class since I need to have different kinds of concrete classes. I cannot use the getInstance() function in the base class since I cannot make it both static and virtual. class ITrafficEventsReturner { public: virtual ~ITrafficEventsReturner() {} ; protected: ITrafficEven...
I've done a script that will write things as images, which can then be read elsewhere (eg. you could share an mp3 through imgur). This is the first one I've done where I've been trying to improve my writing style and make stuff run as efficient as possible, so if there is anything you see here that I can improve it'd b...
I'm working on a JavaScript plugin that makes font-sizes flexible (for a responsive layout). The code works well so far, but I'm sure that it's capable of improvement (especially if you look at the global variable). (function () { var extend = function (obj, ext) { for (var key in ext) { if (ext...
Using parse.com's javascript API, I would like to get a variable number or images from img tags on a page and save those images in the currently logged in user's user object. To my knowledge, parse cannot store image files directly from a url so I am using ajax to send each url to a php page that converts it and return...
my url is like page.php?path=content/x/y/z/aaa.md. Is the following php code secure? include "Parsedown.php"; function path_purifier($path) { if(substr($path, 0, 8) !== "content/") return null; if (strpos($path,'..') !== false) return null; return "./" . $path; } $parsedown = new Parsedown(); $path = $_...
I have a piece code which retries 3 more times to open a file (see below). Are there potential problems or side effects with the way it is written? How can it be improved? Also, why would one use Thread.currentThread().sleep(x) instead of simply Thread.sleep(x)? Any other code smell exists here? import java.io.*; publi...
The challenge in CodeEval is to take a number of days and iterate over the gains and losses and determine which lengths will yield the highest possible profit. I'm wondering if I could write this any better? It seems like sort of clunky code to me. file = ARGV[0] File.open(file).each do |line| duration, days = ...
I am trying to find the longest repeated string in text with python, both quickly and space efficiently. I created an implementation of a suffix tree in order to make the processing fast, but the code fails on large files due to memory problems. I am purposely not using any advanced libraries for this particular code....
This code is intended to take input from a form and append it to a database table. The same data is sent to a separate function for subsequent mailing to the respondent. I'm self-taught and it works so overall I'm quite happy. It just starts to seem a little flabby around the binding and creation of the $mail_params. I...
I am re-inventing the wheel and would like to lay down a comprehensive filesizes function. The only issue is that I guess bit-wise operators are more efficient but I'll be darned if I can understand them. What would you do to optimize this function? function humanFileSize($bytes = 0, $f = 1024) { $f = (int)$f; ...
For setters that set a member collection, I write template functions so as to accept any collection type as input: class HasItems { public: template <typename C> void items(const C& items) { // Copy-and-swap omitted m_items.assign(std::begin(items), std::end(items)); } private: std::vec...
I'm trying to use Moq to mock a rather large set of interfaces in an object. I'm trying to capture the behavior of retaining a dirty flag when properties are set and I'm hoping there is a cleaner way to do this because I have many properties that need this setup. public static void SetupDirtyProperty<T, TProp>(this...
I created a simple program that allows you to create and play MIDI sounds. I've used the MVC approach and I’d like to know if there are any improvements to be made regarding the design and structure of the classes? Have I used a constants class correctly? I also feel that the checkBoxArrayin the Midi class should be in...
I was going through my Java book's exercise solutions and comparing and incorporating the author's techniques into my repertoire. Most of the time, my approach is identical to the author's. When it is different, it is painfully obvious that his code is better and so I learn from it and rewrite it. This is the first ins...
My current code is kinda atrocious to switch fragments and everything, but I don't know a better way to check to see if the fragment I'm trying to switch to. private void FragmentChange(Bundle Data) { SetActionBarButtons(new String[] { "SearchButtonOff", "SearchExtraButtonOff" }); String[] data = Data.getString...
I posted a question on Stack Overflow regarding this program. I ended up pretty much rewriting everything to get what is posted here. This turned into a two-day long project. I've been using Python for so long; I've been spoiled. Anyhow, here is a BrainF*** interpreter. It takes in a file or reads from stdin. I've test...
To practice writing code in the functional programming style, I wrote a program to plot two-dimensional lattice random walks. I'd appreciate any feedback about how to improve its "functionaliness". possibleSteps <- list(c(-1,0), c(0,-1), c(1,0), c(0,1)) step <- function(x) { return(unlist(sample(possibleSteps...
My problem is in writing a function reverse(s) that reverses the character string s, a line at a time. My code here works, I write the line and it reverses the line. Is it a good solution? #include <stdio.h> #include <stdlib.h> #define MAX 1000 void reverse(char cad[] ,char cadenita[],int i); int main() { int a ...
I have to solve this equation: \$ x + y + xy = n \$ #include <iostream> #include <cstring> using namespace std; long c; int main() { long x = 0; cin >> c; if(c == 0) { cout << 1 << endl; return 0; } for(long i = 1; i <= c / 2; i ++) { for(long j = 1; j <= c; j ++) ...
I am trying to learn OOP in PHP. My PHP knowledge is pretty good, but haven't tried OOP before. I'm currently building a formbuilder class. Can you take a look and tell me if this is the right way? <?php class Forms { protected $_inputs; private $_method, $_action; public function __construct($method,$act...
I am creating my first HTML5 game using JavaScript and Phaser framework. I have a class (or more accurately a prototype) called MajorPoint that represents the starting point and the end point of the game. I initially put those two together, as they only differed from each other by the visible frame. Now as the game is ...
I've been learning JavaFX and wanted to recreate Simple calculator implemented with lambdas. It's also my first time using CSS, whose capability has convinced me of the wonders and appeal of JavaFX over swing. Hitherto, I've only somewhat used swing and jumping into JavaFX this program is now my most complex, I like ho...
I have been playing with Async/parallel execution in entity framework for while. I'm not sure if I'm doing it right. I have two entity contexts: one for reading and one for writing. The reading context has more than 200000 rows in table Customer. It took 9 minutes on my PC (i7+8GB). let FindGender(skip : int, take : in...
I'm trying to wrap my head around OOP, and am fairly new to PHP in general, so please forgive me if the following makes you cringe. I've decided to try and create a basic database wrapper using PDO. Here's what I've done so far. class DB { protected $db_user = 'root'; protected $db_pass = ''; protected $db_...
I was interested in experimenting with some intrusive versions of common data structures, so I've written this simple chained hash-table using the approach: #ifndef INTRUSIVE_HASH_TABLE_HPP #define INTRUSIVE_HASH_TABLE_HPP #include <cassert> #include <cstddef> #include <functional> #include <type_traits> // Types tha...
I have a program which generates a number between 0 and 4 for both the player and the computer. If the number is positive the player wins, and if it is negative the computer wins. if dif == 1 or dif == 2 or dif == 3 or dif == 4: print 'Player wins!' elif dif == -1 or dif == -2 or dif == -3 or dif == -4: print ...
I have been reading this great book and I decided to do the Project in Chapter 5: Writing an Assembler for the Hack Assembly Language. You can find the specification for the Hack Machine Language and the Hack Assembly Language here. Here is my implementation: package biz.tugay.hack.assembler; /* User: koray.asm@tugay.b...
I have small class which interprets TV show filenames to extract the show title and episode number. Due to the nature of the filenames, I have chosen for a cleaning approach: I clean the filename first as much as possible and then extract the necessary data (instead of matching the data right away with regexp). I'm kin...
I'm trying to learn C++ (with experience in C and Java, inter alia). I wrote a program to output a waveform of multiple (superimposed) tones, each varying in pitch. To execute: Compilation: g++ -W -Wall -pedantic -std=c++11 main.cpp Tone.cpp Running: ./a.out Playing: aplay out -r 44100 -f S16_LE (or S16_BE if you're o...
is being first and unique. Challenge: Write a program which finds the first non-repeated character in a string. Specifications: The first argument is a path to a file. The file contains strings, one per line. Print out the first non-repeated character of each string. Solution: import java.io.File; import java.i...
This is my second iteration of a simple Java MIDI player. I've made several amendments and would like to see if the code is now correctly implemented and readable. This follows on from the first review. With regards to the GUI class, is it a good idea to have musicInfo = midi.musicInfo in the GUI constructor? Or should...
I wrote this code that's supposed to correct quizzes on a webpage, but it feels bloated and I'm sure there's tons of ways to improve it. Any thoughts? $ -> #When submit_quiz div is clicked, do the following $(document).on "click", "#submit_quiz", (e) -> #Gets the quiz id for later use qid = getQuestions(thi...
As my first Java homework, I wrote a class to handle fractions. This Fraction class implements basic operations for the fractions (addition, subtraction, multiplication and division) and follows this interface*: interface FractionInterface { public int getNumerator(); public int getDenominator(); public Fr...
I was bored this evening and decided to create a program which calculates all the solutions for a given scenario of the game "24". The goal of this game is that you try to be the first one to find the answer to a certain card. On the card are four numbers ranging from 1 to 9. The player is allowed to use subtract, add,...
I am building a web app in Ruby but without Rails. So far I just have a very basic web server. What improvements can I make to it? require 'socket' require 'uri' # Files will be served from this directory WEB_ROOT = './public' # Map extensions to their content type CONTENT_TYPE_MAPPING = { 'html' => 'text/html', ...
I want to sort "movie search results" to get most probable movie that match "search". Input example: CARS.2.2011.720P.AC3.mkv I have a NameMatcher class which extract "title" and "year" from file name. Search string: cars 2 Search year : 2011 Results come from many websites like TMDB, Rotten Tomatoes, ... and much...
I am writing some Java code and am coming across a try/catch block in which I decided to verify the value is not null before parsing it: String parsedValue = DEFAULT_VALUE; try { if (myValue != null) { parsedValue = parse(myValue); } } catch (ParseException e) { log(e); } Regarding the code above, my questio...
The goal here is to only save (to file) the most recent Objects created if Object::maxMemoryOfObjects is exceeded. #include <iostream> #include <list> #include <algorithm> #include <fstream> #include <map> struct Object { const int ID; Object() : ID(++lastObjectID) {} static const int maxMemoryOfObjects =...
I'm designing a Tokenizer / Parser / AST. I'm wondering if this basic idea of an expression is good and if this way of implementing Simplification is good, or should I use something like the Visitor pattern? Is implementing it in the class itself a good idea? public abstract class Expr { public Expr Left; publi...
I am a complete noob to C and I've shied away from using such a powerful language due to it's large learning curve and other complicated mechanisms. For my first minor project I plan to create a small HTTP client that requests for a webpage. Before I start, I need to create a function that can correctly parse a URL usi...
Suppose I want to find the index of the maximal value of a given sequence. In Matlab, this is: [value, index] = max(x) In Python, I would abstract the following pattern: def find_best_element_index(elements, is_better): best_so_far = elements[0] best_so_far_index = 0 for (index, element) in enumerate(eleme...
I have implemented a Mammal class hierarchy in Java. Is it an intelligent approach, with respect to decomposition, locality and procedural abstraction? package Hierarchies; public class Mammals { public Mammals(){ } public void giveMilk(){ //REQUIRES: nothing //MODIFIES: nothin...
Because the ambient transaction isn't supported with informix, I pass the transaction and the connection through my methods. I want to ask about three things: Is the following code written well? I mean, no redundant steps and no logical errors. Is calling this transaction method with many null parameters in a specific...
I wrote a program for this problem, but it stopped because it took too much time. Any tips? The Problem: Bubble sort is the simplest algorithm for elements sorting. At each iteration we sequentially compare values of subsequent elements and swap them if necessary. Your job is to write a program which finds a state of a...
I'm using HapiJS to create a little backend for my side-project. In grabbing RSS feeds, I want to loop through my list of website URLs, grab the correct RSS links in the <head>, then loop through the RSS feeds, pulling out the articles, to return an aggregated JSON response (via the reply() call in HapiJS), to have all...
The function remove_odd is to remove odd valued nodes (surprise!!) from the linked list head. The code is very long and cryptic but it seems to work. Please help me reduce the lines of code and are there any cases that I might have missed. void rem_odd(struct Node** head) { struct Node* curr=*head; struct Node*...
Following is a Python program I wrote to find the common ancestor in a binary tree (not BST) with no link to parent node. Please review. def common_ancestor(N1, N2, head): if not head: return [None, 0, 0] left_status = common_ancestor(N1, N2, head.left) if left_status[0]: return left_status...
This macro is made to randomly draw specific number of civilization choices for a specific number of Civ V players. It is based on a list of 43 possibilities and the for loop in the while loop checks for already picked civilizations. Constant cell references point to values obtained with scroll-bars in the worksheet. T...
I'm working on a screen where I sent a request and I get response in two types. One is success and contains the below format: { "searchNames": [ { "CustomerName": "John", "CustomerType": "Business", "Profession": "Businessman", "address": { "ad...
Challenge: Implement a stack interface. Specifications: The interface should have ‘push’ and ‘pop’ functions. Your task is to ‘push’ a series of integers and then ‘pop’ and print every alternate integer. Your program should accept a file as its first argument. The file contains a series of space delimited in...
I'm trying to do Project Euler Problem 12, which reads as: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first sev...
I have the follow code to change between different CSS theme files, I would like some reviews on it because I am sure it can be improved to be safer. <head> <?php $theme = $_GET['theme']; $choice = preg_replace('/[^A-Za-z0-9\-]/', '', $theme); if (empty($choice)){ echo '<link rel"stylesheet" type="text...
I have been solving the following problem: Input array: \$[7,4,2,5,1,9,6]\$ Output array: \$[1,4,6,9,7,5,2]\$ I tried to do it in the following way: Sort the array. So, Input array becomes \$[1,2,4,5,6,7,9]\$ run time \$O(n \log n)\$ Numbers in even indices are \$[1,4,6,9]\$ an in odd indices are \$[2,5,7]\$. Move al...
I've posted and gotten help to optimize my code before here and here. Now I have implemented the following changes, after very helpful advice: I have implemented a Dictionary instead of using list when looking into the extracted messages. I have implemented index on the userid and unixtime tables in my database. Bo...
I found a lot of working codes to include page in page on Internet but I could not find a safe code. So I decided to create one myself. The pages will be only stored in folder /pages/ and whitelist seems to be a good option. Is the follow code safe? <?php $unsafe = $_GET['pagename']; $page = preg_replace('/[^A-Za-z0-9\...
First program I've written in Rust (besides the demos in the tutorial site). I decided to start by converting my C++ command line tool to Rust. This is not necessarily a 1 to 1 conversion, but I've tried to maintain the overall structure the same: // Currently (rustc 1.0.0-nightly), these modules are all unstable // an...
I wrote the following code as part of a larger application. This code takes a string that defines a mathematical function on such as r,y x[0], x[1] etc. or any other variable that additionally can be subscripted (indicated by the x[0] notation) and returns valid python function that accepts the the arguments and comput...
I'm trying to write a fully generic Stack in C++. I'm not sure if this is the best way to do this. Right now I know that the Pop method needs improvement since if T is a value type, returning a nullptr will cause a compiler error. Also, I'm pretty sure that this can be optimized in a few ways, but I don't see any o...
I needed to find whether any image's width at or higher than a certain directory folder exceeds a limit. Is this code a good way of doing this, or is there a way in which it can be improved? I ran it over at least a couple hundred images and several hundred other files contained in the main directory (not C:\Users, b...
-ish because I removed the input functionality from the compiler. And, the compiler does not support nested loops I've been recently reading up on compilers and how they work. Although this doesn't use most of the things I've learned about (the lexical and parser things), I thought it would be fun to try create a brain...
Challenge: Write a program which determines the Mth to last element in a list. Specifications: The first argument is a path to a file. The file contains series of space delimited characters followed by an integer. The integer represents an index in the list (1-based), one per line. Print out the Mth element fr...
I've very new to C++ and have been working through a tutorial and got as far as std::rand(). I was immediately horrified and rushed out to see if I could implement this as a service. This is my (pretty basic) non-cryptographically-secure implementation in the style of .Net's System.Random. There are a number of things ...
There is this type of puzzle that can easily be solved with a depth-first backtracking solver. I wrote one in python 3.4 and like to get some feedback. I'm especially interested in the following points: deepcopy. The usage of deepcopy in DepthFirstBacktrackingSolver.findsolutions is somewhat ugly. As Python simply bi...
I recently have been working on a Trie in Java. I have looked at the related posts here on Code Review to try and enhance my code, but I do have some methods and constraints not present on other posts. Objective To efficiently implement a Trie data structure in Java that is fast, with low memory consumption. Constrain...
Given a method isSubstring, two strings s1 and s2, check whether s1 is a rotation of s2 using only one call to isSubstring. Any comments on the code below? I would like to check the complexities as well: For isSubstring: runtime: \$O(n^2)\$ memory: in place For isRotation: runtime: \$O(n^2)\$ memory: \$O(n)\$ i...
Most of my experience is with Objective-C, so I am relatively new to Java inheritance. I understand that there are concepts such as abstract classes and interfaces, but I am still not totally sure when to use them. I would really like feedback on the structure of my inheritance in the following code. I am most concer...
This is a very basic PHP class that I am working on which will allow me to provide an HTML template in the form of a string saved to a variable or into an actual template file. I can then pass into my PHP class an array where the array KEYS will be used to find and replace variables in the template HTML. The template ...
For the below given exercise: Exercise 7: Abstracting Rectangles Implement a representation for rectangles in a plane. (Hint: You may want to make use of your procedures from exercise 5). Then, in terms of your constructors and selectors, create procedures that compute the perimeter and the area of a given rectangle. ...
Here's my test question for C++ programmer job: Servers only static content, no cgi Single process, multithreaded 1000 concurrent request at least Valid http status codes and headers No external libraries, just STL, POSIX and glibc Here's my code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <s...
The following Julia code implements Terry Feagin's 10th order explicit Runge-Kutta method (a more accurate cousin of RK4). Though the structure of the code is quite simple (i.e. no cyclomatic complexity), it involves many high-precision coefficients and lengthy arithmetic expressions which bring its length to over 150 ...
I am designing a COM wrapper for a C++ library using ATL. Currently I am a little bit confused about enumerators that are based on ATL collections. I already wrote several enumerators based on STL collections, but since there is no ICollectionOnATL-interface (such as the ICollectionOnSTL-interface), I am a little bit c...
Consider the following function: func Listen(username string) (net.Listener, error) { path := filepath.Join(socketsDir, username) oldUmask := syscall.Umask(^0600) defer syscall.Umask(oldUmask) listener, err := net.Listen("unixpacket", path) if err != nil { return nil, err } passwd...
I am a newbie to native JavaScript and am pretty much coming to grips with the operators, etc. At the moment I am currently constructing a slide. "use strict"; var intSeconds = 3; function loadSlider(){ flickrImgsShown = 0; sliderImages = new Array(slides + 10); sliderImages[0] = document.querySelector(".img"); ...
I'm currently trying to improve my C understanding. Would you mind telling me if there are good/bad things that I did here? (I implemented a function to reverse a string in place). For example things I feel uncomfortable with: I forwarded pointers to a buffer so that I could loosen the coupling of different parts of t...
I wrote this code to delete an item from a linked list. I checked it and it works, but I want to know if the logic could be written simpler or clearer. typedef struct linked_list{ int value; struct linked_list * next; }linked; int deleteSpecificItem(linked ** head, int val) { if(!head || !(*head)) return -1; lin...
I have written a program that calculates the "cost" of transforming one string into another. I would like you to review it. public class EditDistance { public static void main(String[] args) { // TODO Auto-generated method stub String source="COTI",destination ="CAT"; System.out.println(get...
I have tried to tackle this question as follows: The program Calculates the next Working day, taking into account: - weekends (Saturdays and Sundays) - holidays happening in the middle of the week param name="OrderDate" the date on which the order is placed param name="workingDays" the number of workingday...
As far as I can tell, there is no network access happening at this stage in the code. I am accessing Reddit's API via the PRAW module. However, it is crawling, and I think it should be faster, considering I am hardly doing any work (unless Python heavily penalizes object access?). This is the entire short script: impor...
This is a follow-up on my previous question about a VBA macro for randomizing a draw from a table. It can be found here: Randomizing Civilization 5 team choice The code has been improved with the help I got earlier and I now seek even further improvements. Public Enum CivilizationTableColumns CivilizationName =...
Print all the ways of arranging eight queens on an 8x8 board. Rules: Queens should not share the same row, column, of any diagonal. Any comment on my solution? I didn't write unit tests but I checked visually the solutions. public class solution { public static void printMatrix(char[][] board) { // 8x8 board...
This code is intended to process commands in a CQRS+Messaging system. It will parallelize the message processing to the degree you specify by the msgToIdFn parameter. The function's intention is to extract the target ID from the command message. This will be used to correlate all messages with that ID to the same agent...
I was wondering if I could get some feedback on the library I created to persist data online. JitterPushDemo.java public class JitterPushDemo { public static void main(String[] args) { Jitter jitter = new Jitter("scores"); // create hash map to map scores to players HashMap<String, Stri...
I'd like to get the indices of elements of an array with particular element. Is it okay or, or how can I make it even better? //string Input = "Net Sales,COGS"; int[] numbers = { 0, 1, 2, 3, 4, 5 }; string[] Values = { "Net Sales", "COGS", "COGS%", "Gross Profit", "GP%", "Quantity" }; string[] selectedValues = Input....
I've built a wrapper for a LocalReport and I would like to hear your suggestions about it: public class ReportWrapper : IDisposable { private string _reportResource; private LocalReport _report = new LocalReport(); private int m_currentPageIndex; private IList<Stream> m_streams; public Dictionary<...
I have the following script, which filters duplicates and returns only unique values for an array. When passing false or nothing the "original" array is overwritten, when passing true a new array is created with unique values and returned instead. The script should work only with numbers and strings. I would like to kn...
My Google Maps Script v1 Using the Google Maps JavaScript API v3. Does my script have any room for improvement (naming, readability, oop, etc.)? I'm going to pair it with some live time functionality, so that whenever the map its location changes the time would be updated accordingly. I've added this script to my HTML...
We just finished working on a Database project in Java Netbeans. We added the feature Import which will import the database record of one user to a text file. String IMPORT_QUERY = "SELECT pe.entry_id ID, pe.entry_account ACCOUNT, pe.entry_username USERNAME, pe.entry_password PASSWORD, pe.entry_category CATEGORY F...
I'm a newbie at programming, just one month into C. Working with Stephen Kochan's programming in C. There is a question in chapter 6 to write a printing calculator where 's' tells the program to set the accumulator, 'e' tells that the execution must end. And the operators tell the operations to be performed on the accu...
My task is to compute average half spread in percentages on a stream of market. This is part of the coding assignment that I have received. namespace CodingAssignment { public interface IMarketDataFeed { string StockName { get; } event Action<MarketDataUpdate> Update; } public interface...
I've never did a real Project Euler in my life, so I figured it was about to do one. And what better Project Euler to start with than Problem 42? Project description from Project Euler: By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word val...
I have the following code in PHP that appends a file path with a timestamp of when it was last modified: function AssetTimestamp($filename) { if (file_exists($filename)) { return $filename . '?' . @filemtime($filename); } else { return $filename; } } I have written the equivalent in C# publ...
I decided to write a small script to make writing HTML interactive stories less tedious: import doctest import re import sys import tkinter import tkinter.filedialog HTML_START = """<!DOCTYPE html> <html lang="en"> <div align="center"> <head> <title>{}</title> <h1>{}</h1> </head> <body> """ HTML...
I have the following code: if (isMandatory) { x.MandatoryServices.ForEach(y => { if (!y.IsSelectedByUser) { containsRemovedSrvcs = true; return; } }); } else { x.OptionalServices.ForEach(y => { if (!y.IsSelectedByUse...
First let me address why I'm not using the built-in string interning. My code is used in a utility that needs to free all of its memory once it's closed. Strings that are interned are not likely to be freed until the CLR is restarted. I can't create that situation since my utility is used on servers that primarily run ...
I have written a function which generates combinations of string by replacing 1 or more characters by the symbol "*". The code is as follows: /** this following code is responsible to generate all possible combiantions of letters from a word with * for eg. word = "fin", wordSet --> {fi...
I've just "finished" my second attempt a core game loop, which is a heavily refactored version of my first attempt. My perceived benefits are: Using functors means that the actual loops themselves are independent from the actual systems them manage. You can wrap states up elsewhere, and the only assumption they need t...