instruction
stringlengths
71
71.9k
I am trying to write a parser from JSON data which I get from Google requesting coordinates of a city, which will create my specified object structure. For parsing, I've written a custom TypeAdapter. It is my first time working with Gson, so probably my parsing method can be improved. Any suggestions? JSON I receive: ...
I am doing some math - combining, reusing, extending different analyses methods over the same original data set. It would be reasonable to use C# extension methods in my case instead of defining everything in one class. The same time there are too much stuff to be constantly recalculated in this extension methods - I d...
The app is a todo list with a three-day calendar. Users can add and remove lists and it's all stored in local storage. My aim was to use vanilla JS but I did use jQuery for the date picker. I'm just looking for some feedback on my code. This is my first app I have coded and I'm looking for some constructive criticism o...
I wrote a simple quadratic function solver with unit tests. Can anyone check if this is okay? Quadratic function class public class QuadraticFunction { private Integer a,b,c; public QuadraticFunction(Integer a, Integer b, Integer c) { this.a = a; this.b = b; this.c = c; } publi...
This is how I achieved it: <script type="text/javascript"> // Get this monday var dif, d = new Date(); dif = (d.getDay() + 6) % 7; d = new Date(d.getTime() - dif * 24*60*60*1000); d.setHours(0,0,0); var thisMondayUnixtimestamp = Math.round((d.getTime() / 1000)); console.log('thisMondayUnixtimestamp', thisMondayUnixti...
This is my attempted solution to Question 1.3 from "Cracking the Code Interview", 6th ed. Question: Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters, and that you are given the true length of the string. #incl...
I've been working on a regex-based UK postcode validation and format correction tool - with the aim of creating a list of postcodes that can be readily geocoded. The variety of postcode formats is explained here. I have based my regex on a discussion here. My correction tool is designed to cope with a number of commonl...
The code works well and does what I intend for it to do. In essence, it opens a file referenced as 'resource'. This is a .csv file. I then searches for the keys in the dictionary and for each key that it encounters, it replaces it with the value - the dictionary being 'rep'. It then exports this to a new .csv file. The...
I'm developing a WordPress plugin using the singleton pattern with the following requirements: There should ever exist one instance of the plugin Another instance of the object should never be instantiated, created, cloned, copied etc in any way. The singular plugin object and its public methods and vars should be eas...
I have some XML that I am parsing in Python and I need to insert the data on the database. This is current implementation of my code that is working. Actual XML: <JobTechData xmlns="http://tempuri.org/JobTechData.xsd"> <TechDataParams> <ProcessType>IONMILL1</ProcessType> <RunNumber>125229</RunNumber> <R...
I am trying to learn to code using Dependency Injection and Inversion of Control in Go. Please consider the following code. I am basically creating an interface ListingManager and then an implementation of it. I am using the New() function as a means to initialise the implementation. While not show, I would probably ad...
This program creates an integer array with a random size of 5-50 elements (inclusive). It then fills the array with random numbers between 0 - 100 (inclusive). The interesting part comes when I then have to print the array as a table limited at 5 columns wide. Also, the array must be centered on an output screen 80 cha...
Here is my code. I simulated a stack rather than used some regular recursive algorithm because I needed to keep track of two variables: the path to the biggest file and its size. Besides I wrote a few tests. My solution on Github. DirectoryIterator.java import java.io.File; import java.util.ArrayDeque; import java.util...
What do you think about the following approach to CRUD? Here is the reading+pagination example. DTO types have Dto* prefix, EF Entity Types have E* prefix. DAL example: class UserQuery : PagingQuery { public int CompanyId { get; set; } } interface IUserReader { IPage<DtoUser> Read(UserQuery query); } class User...
For the first time ever I decided to write a bash script. It works fine, but I'm feeling that I didn't write the most efficient code in order for future extension of the script. I also don't really get a good feeling on the look of the code. Any suggestions on how to improve the script? Purpose of the script: To pull a...
I would like to create a collection of binaries with n set bits and total length should be between n and 31; also those set bits should be randomly positioned. For example if n = 3, then [1;0;1;0;1], [1;0;0;1;1;] and [1;1;1;0;0] should all be possible with equal chance. Below is my implementation and any feedback is we...
What is so bad about [Flags] enum? It does not support IEnumerable<T> anyhow, so to get one we need to use syntax like (see): new HashSet<WhatToInclude>(new []{ WhatToInclude.Cleaners, WhatToInclude.Managers} Here is the helper class Flag<T> to discuss. We can use it this way: class Color : Flag<Color> { ...
I forked this StackExchange Data Explorer (SEDE) query from another one, and made it a bit more complex. I'm looking for feedback on my style, as well as answers to other questions (see below). -- top users: NYC -- forked from Avinash Raj's query for Chennai select row_number() over(order by u.Reputation desc) as [...
This approach was born out of wanting to pass a logical expression (E.G. ">=10000") as a parameter to a function. So, I built an Enum and a function to use it to evaluate logical expressions. Is this a good, maintainable, scalable approach? Public Enum comparisonOperator '/ Used [[ ]] because the outer set escape t...
Basing my work on a JavaScript progress bar created by another person, I added an animated percentage count. This solution is really ugly but it works. I don't know how to avoid having to declare the percentage value twice in the HTML. I would also like to unify the parts of the code responsible for the progress bar ...
I programmed a web adaption of the game Simon for to improving my JavaScript skills. A live version of the results are here. I got two more ideas which I like to incorporate. Moreover, I'd like to improve the look. But before I go on I would like to make some improvements. I guess there are a few necessary. function ...
I use the code (provided below) to check for certain criteria in a row. In this case, if cell F in worksheet "Swivel" contains "After Dispute For SBU" then that row needs to be highlighted in yellow and the text changed to red, then the row needs to be copied to another sheet named "Disputed" that is within the same wo...
This is my first game made using Pygame of about 550 lines of code. Advice and suggestions are more than welcome. ## Game music Attribution ##Frozen Jam by tgfcoder <https://twitter.com/tgfcoder> licensed under CC-BY-3 <http://creativecommons.org/licenses/by/3.0/> from __future__ import division import pygame import r...
I'm trying to learn more algorithmic techniques and I came across an interesting application of recursive backtracking: solving a Sudoku puzzle. I'm looking for a review concerning code style, quality, algorithmic correctness, and maybe tips on how to extend the algorithm/program. #include <array> #include <stdexcept> ...
I am learning Python, and would like to learn how to make this code simpler and easier to read. Things I am hoping to learn: What variables might be appropriate? How can I make it simpler? Is there any way to make it more efficient? What can be put into functions without sacrificing readability? import random yn = ra...
A recent comment to an answer of mine here on Code Review brought up an interesting point. The comment was that one should use std::vector<char> over std::vector<bool> in most cases because the standard requires std::vector<bool> to actually pack bits. I replied that for small vector sizes, the speed wouldn't matter ...
All I am trying to achieve is better use of built-in ES functions. var arr = [0, 1, 2, 3, -1, -2, -3]; function countPositiv(p, c, i, a) { if(c > 0){ return p+1; } else { return p; } } var positiv = arr.reduce(countPositiv, 0); console.log(positiv);
I have two classes responsible for attributes validation: class NameValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) message = options.fetch(:message, I18n.t('errors.attributes.name.invalid')) record.errors[attribute] << message unless NameValidator.valid_name?(value) end ...
Long story short: I wanted some of the time-saving functionality of jQuery without the bulk of the entire library. So, I wrote a lightweight shorthand library inspired by jQuery I'm calling Mozart JS, and I'd like to see how I can further enhance it without major impact on load times. Thoughts? Full library on GitHub. ...
The problem is (source)... By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? This is my second attempt at the problem, and gets the correct answer in about a second. I wasn't too unhappy with that until I noticed a C# solution in the...
The soundex algorithm maps several spellings of a name to a 4 character term. (hopefully mapping all different transcriptions to the same term) The steps as described in Introduction to information retrieval are: Keep first Letter for the rest: Change any of 'A', 'E', 'I', 'O', 'U', 'H', 'W', 'Y' to zero Change all ...
I need to call different functions depending on which enum value is used as parameter. it's working as it should do, but I wanted to ask if there's a proper way to do this without lacking a good performance? public enum Comparator { Greater=1,Equal=0,Lower=-1 } public enum ComparableValues { R,G,B,Yellow,Violett...
This is a simple implementation of text prediction using a list of keywords and UITextChecker. This is working correctly, but I think I could have implemented better. My goal is to use a protocol oriented approach. protocol KeywordSuggester { func suggestion(word: String) -> String? func loadKeywords() -> Set...
What do you think about this approach to validate and analyze URLs? There are Url and Url<TResource> model types to represent generic and specific site URL respectively. Specific site URLs can be validated against specific schema and provide custom data extraction API. Let's imagine the following DTO and EF Entity Typ...
I have written Python code that generates a plot. In the code below, when I set maxtime = 0.1, the program takes ~50s and when I set maxtime = 1, it takes ~420s. I need to run it for maxtime = 1000. I am familiar with Python syntax and writing "Matlabic" code, but am lost in writing natively "Pythonic" code. As a resul...
I have an array for an English sentence (enSentence) and for a German sentence (deSentence). Each value represents one word. I want to print every possible phrase pair (enPhrase and dePhrase), where no phrase contains more than maxhPhraseLength words. A phrase can consist of a single word, all words of the sentence, an...
I have this small piece of code written in a class. I am looking for a nicer way to write this, preferably avoiding nested if statements like what I currently have: @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { TheatreListDataWrapper[] selectedOperations = getSelectedDatas(); boolean ...
Just started learning Java Strings. Tried to implement the Soundex algorithm. Package to hold the String related functions package com.java.strings; public class StringFunctions { /** * Removes all the spaces in a given String. * E.g: : "A B CDD" becomes "ABCDD" */ public static String ...
You have one form and you can register a user. It can be god or mortal, but it also requires all the information to let you save the user or the change. When you have all the registers that you want you can edit one or delete it. I'm new using Angular and I want tips to use it better. I also want to see other ways to d...
Using OCR, my program reads the current selection for each of these categories: format, invert color? and storage. The OCR result will always have inconsistent error here and there, which is why I need a Regex match and return the correct wording for each selection: //format private Regex bmp8 = new Regex(".bmp...
As a learning exercise, I decided to implement a BST and add functionality to it slowly. I'd appreciate any feedback. I should also point out that I borrowed the template from the here. tree.h header file typedef char treeElement; typedef struct TreeNodeTag{ treeElement element; struct TreeNodeTag *left, *right;...
The syntax for specifying multi-dimensional types in C++ is messy. For example, to specify a two-dimensional std::vector<int>, one has to write std::vector<std::vector<int>>. The syntax doesn't scale. So, I wrote a handy tool that provides easy syntax for this. Any kinds of comments are welcome ^_^ (original version of...
I made a UI picker tool, like a "rolling select" to pick vales (demo here). I made first a independent module with a ES6 Class, basically: class ComponentPicker { constructor(target, data){ // init stuff } deployHTML(target, data) {...} getValue(){...} setValue(val){...} onChange(callba...
I wanted to have a custom section in my app.config file in which any element could reference and reuse (or better said could inherit) any string value that is defined in it or above it in the element hierarchy. In other words, a child element could reuse any string value that it has or that its parents have. For exampl...
I am creating a drawing-app. I want to have a toolbar populated with tools. Each tool is defined in a separate js file. Right now i have defined each tool as an object that contains functions and variables that dictate it's behavior, for example i have 'setDragBehaviour()' and setDrawBehaviour()'. All these functions i...
I've built a class that handles all my connections to a MySql database. These are the function I use to create the connection(not really sure about the two dispose functions) : public class dbConnection : IDisposable { public MySqlConnection conn; public MySqlTransaction transaction; private static Logger...
This code gets the cell's colour regardless of whether it's set from conditional formatting or not. It currently works on 2010 and unsure about older versions of excel. My question is is there a way to make this code more efficient? Such as being able to highlight an area for the code to search rather than setting For...
The following is a (somewhat messy) implementation of the BouncyCastle cryptography library. I create a self-signed certificate (hopefully correctly), store it in a Java KeyStore, and use it to create an SSL (TLSv1.2) socket session. I am not concerned about efficiency, as this was mainly a proof of concept code to fam...
I'm working on a booking application and am in the process of porting some legacy code to a more SOLID and testable architecture. Right now I'm working on the process of canceling bookings. Over the years, we have changed the steps involved here. The core has been the same (update booking entity status, make the timesl...
I'm doing the Racket track on exercism.io and solved the grains exercise: Write a program that calculates the number of grains of wheat on a chessboard given that the number on each square doubles. (test cases etc on exercism) So I wrote a straightforward recursive solution: #lang racket (provide square total) (def...
One of my github issues is below. I am having some problems with my security, is there anything that I should or need to improve. Here is an example of code that I use, but throughout the script there are some problems. <?php session_start(); error_reporting(0); include '../config.php'; $pass = substr(sha1($_POST['pas...
Here is a shell script which installs and configure owncloud on a Debian server. It also installs apache2 and MySQL as dependencies and fail2ban with a specific rule for owncloud. Apache2 is also configured to use a self signed SSL certificate. The script seems to work properly (everything is installed and works fine) ...
I wrote this factory class in order to pass parameter to Singlton class, is it a good design in term of design for multithreading environment? public static class LoggingServiceFactory { private static string _connectionstring; private static readonly Lazy<LoggingService> _INSTANCE = new Lazy<LoggingService>(()...
From SICP Exercise 2.69: The following procedure takes as its argument a list of symbol-frequency pairs (where no symbol appears in more than one pair) and generates a Huffman encoding tree according to the Huffman algorithm. (define (generate-huffman-tree pairs) (successive-merge (make-leaf-set pairs))) ...
(See the next iteration.) I have rewritten a Fibonacci heap implementation from Java to C. fibonacci_heap.h: #ifndef FIBONACCI_HEAP_H #define FIBONACCI_HEAP_H #include <stdbool.h> #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif typedef struct fibonacci_heap_t fibonacci_heap_t; /*****************...
I did a project in WPF MVVM. Just a single Window with single Frame control and few Pages. My problem was communication between pages without not violating MVVM principles. I'd like to use all bestprogramming-practices. Can you check if this code agrees with the all best principles? My solution has two projects: WPF c...
Can this query be improved? Is there a way to eliminate the duplicate function call? -- a Special Group has many Items which have many Bookings create function f_BookingsForSpecialGroup(@specialGroupId varchar(99)) returns table as return select * from v_Booking where ITEM_CODE in (select ITEM_CODE from v_I...
I feel like I’m violating a lot of DRY rules here but can’t think of a better way to do this. I have two event methods (there are actually four total just showing two) that are doing a lot of similar actions but on different DOM elements. Is there a better way to re-factor this so I’m not repeating myself so much. ...
Now that we can move across the bridge, it's time to finally set up the problem so that it can be solved. A reminder of what the assignment is: Welcome to the Bridge Crossing Problem. Person Pn can cross the bridge in n minutes. Only one or two persons can cross at a time because it is dark, and the flashlight mu...
I recently added this ConfigLoader class to my project : it loads information (in this example for a window) from an XML config file, using boost. I would like to ask your advice if this is a good implementation of a ConfigLoader using type_traits, or if I could improve it; here is my code: ConfigLoader.h: #pragma once...
I used a Raspberry Pi and Adafruit LCD with buttons to build a small thermostat for my house. This is the hardware I used to you can imagine how the button and the code work: https://www.adafruit.com/products/1110 I know I need to build some kind of state machine but I don't know how to handle persistance in python tha...
I've built a class for an e-commerce Item, and the ShoppingCart class for checkout functions. The thing I'm most concerned about is my use of pointers. I think I've used them properly in this situation, but I could be wrong. Item.hpp #ifndef Item_hpp #define Item_hpp #include <iostream> using namespace std; class It...
My friend requested a navigation menu for his code that he has since he didn't really know how to do it, so I had created one for him. I just wanted to get it reviewed since I'm a beginner with C and want to see if there is any way to shorten or improve this. // // main.c // Oyster Top Up Menu // // Created by JStud...
As of reading the following input.txt file: 1 6 14 1 2 7 1 3 9 2 3 10 2 4 15 3 6 2 3 4 11 4 5 6 5 6 9 I wanted to make a list of lists containing each line as a list of integers [[1, 6, 14], [1, 2, 7], [1, 3, 9], ... [5, 6, 9]] I achieved that by doing the following with open('input.txt', 'r') as f: # gets l...
I'm new to Java and is trying to solve the beginners problem of finding out the number of vowels in a string. I was just wondering if there is any alternatives to any of the steps that can improve efficiency as well as simplicity. import java.util.Arrays; import java.util.Scanner; public class CountVowels{ publi...
Compile with: gcc -std=gnu11 -o "portknock" "portknock.c" -lpcap I did this as a learning experience, and it actually ended up being something useful. I made a port-knocking spawned reverse TTY with it, and it could easily be made into a port knocking firewall daemon. #include <stdio.h> #include <stdlib.h> #include <pc...
I am trying to figure out a more efficient way of converting money into change. The code below is what i have written so far. It works perfectly but i know the code can be improved. Is there a more efficient way of writing this code? public class Problem2 { public static int quarters(int total) { retur...
What do you think about this file system manipulation helper? There is an utility class Folder which I can use to define directory structure of my app: static class Folders { public static Folder Bin => new Folder(Assembly.GetExecutingAssembly()); public static Folder App => Bin.Up(); public static...
This was asked in the SQL Helpline room: I have a sql query concern. Could you help me? It goes like this. I have a table with the Records A B A C B A B C C A C B How do I get only the records that there aren't duplicated in both columns A B A C B C While it seemed simple at first, it was surprisingly difficult t...
I am a self-taught programmer and would like anyone to point out anything that is not the standard or professional way to do things. Any help/advice is greatly appreciated. I would love to post a lot of my code or perhaps make a youtube video explaining certain portions for feedback. Let me know in the comments what yo...
This set of code is very large, and I'm hoping if someone could show me a more efficient way of doing this. In particular, the JavaScript code, but HTML and CSS corrections are just as welcome. $(document).ready(function () { var item1 = "active"; var item2 = "unactive"; var item3 = "unactive"; var it...
Sonar/FxCop are telling us that we shouldn't use void async methods. That's ok. This is the current implementation: private async void InitMethod(ServiceControl serviceControl) { if (serviceControl != null) { await Task.Factory.StartNew(() => serviceControl.Execute()); } } // fire and forget ... c...
I have built real-time markdown editor in order to learn AngularJS by practice. I think what I'm trying to do can be done a better way. Any suggestions appreciated. Here's my code: var myApp = angular.module('myApp',[]); myApp.factory('Data',function ($window) { return {message: $window.localStorage['stuff']} }); ...
I am using PHP in order to create a custom wrapper for including files, for this I have written this class: <?php class Refrences { #region properties private $_basePath; #endregion #region public members public function __construct() { $this->_basePath = $this->cleanDirName(dirname(__FILE__)); } ...
I have written a windows service that I am currently not that happy with as I am facing design issues (first windows service). The aim of this service is to monitor CPU usage and send an alert when it reaches a threshold (coming from the DB). So the user has set a threshold of > 60% CPU usage for 10 Seconds. Then the c...
I have created a function that helps me generate pagination really easily but I am concerned about its performance mainly. The function accepts 2 parameters: A list of items (has meaning in the framework I'm using) which contains information about the state of pagination itself and state of the storage layer - more pr...
I receive daily files (filename_%m_%d_%Y.csv) from a client and I read those in pandas, process them, and store them in Postgres. Sometimes there are delays and we do not get the data for a few days. The problem is that I have everything on a scheduled task and I do not want to manually check if the files exist or not ...
Based on the feedback and suggestions I received in my previous post (Lightweight shorthand JS library), I've updated and optimized Mozart JS. Again, the goal is to have some jQuery-like functionality in a minimal size. Thoughts on this updated version? Full library on GitHub. Mozart JS Element Retrieval Shorthand fo...
public class Encrypt extends Activity { EditText Filename; EditText secretKey; EditText msgContent; Button save; Button cancel; public String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Encrypted Files"; @Override protected void onCreate(Bundle savedInstance...
I have a Windows forms application which we deployed in my firm for use on thin clients. The app lives locally on each user's machine, but pretty much all of the work the users do is over a Citrix session. One of the options (the main option) available to the user is the ability to restart their own session. I recently...
I just came across the Ackermann–Péter function a few weeks ago, found it to be very interesting, and decided to write a simple implementation of it in a favorite programming language of mine. def ackermann_peter_10(m, n): assert isinstance(m, int) and m >= 0, 'm is unacceptable' assert isinstance(n, int) and n...
Sometimes, we create a one-dimensional object, but want to access it in a multi-dimensional way. For example, you can access an int[8] array object in a 2x2x2 way. So, I made a multi_view class template to make this easy. Any comments are welcome~ Original code can be found here and documentation here. template <typena...
I am newbie in scala don't know how to refactor to make it better because currently it kinds of boring when read it. I have 2 classes BidWinPostData and BidEventPostData. They are kind similar the different between of 2 is in modifier when call getSelectorAndModifier. I am using it at bidEventRDD.foreach { line => ...
I know a module like this already exists on CPAN, but I wanted to write my own simplified version that accepts wildcards in the input. I don't write many Perl modules so I figured I would post the code here and see if anyone could give me advice on how to make this code more efficient or user friendly. I also included ...
I'm trying to optimize the main loop portion of this code, as well as learn any "best practices" insights I can for all of the code. This script currently reads in one large file full of tweets (50MB to 1GB). It uses pandas to play with the data, and matplotlib to generate 2D graphs. Currently, this does not scale well...
To complement this Java question on palindrome identification, I came up with this C++(14) version: #include <iterator> #include <algorithm> #include <functional> namespace detail { template <typename RandomIt, typename BinaryPredicate> bool is_palindrome(RandomIt first, RandomIt last, BinaryPredicate pred, ...
Adding another level to my previous question on 'normal' palindrome identification, in this one I'm interested in identifying genetic palindromes. Here's my attempt: #include <iterator> #include <algorithm> #include <array> namespace detail { static constexpr std::array<char, 128> complement_table { 4,...
I am trying to pull back records that include child records for the View I'm putting together. Right now I have a working Linq statement, but it's big, and I think I could make it cleaner. var reqMatsInc = (from rm in db.RequiredMaterial join p in db.Project on rm.ProjectTemplateId equals p.ProjectT...
I recently followed a tutorial on a JavaScript snake game. I tried to improve that game by adding bad fruit which will make your snakes tail incredibly long. //constants var COLS = 26, ROWS = 26; //IDs var EMPTY = 0, SNAKE = 1, FRUIT = 2, BADFRUIT = 3; //direction var LEFT = 0, UP = 1, RIGHT = 2, DOWN =...
I am considering <input type="checkbox" name="arConfig[3]" value="payout" <cfif ListFind(attributes.config[3], "payout") NEQ 0>checked="checked"</cfif> /> Payout<br /> <input type="checkbox" name="arConfig[3]" value="points" <cfif ListFind(attributes.config[3], "points") NEQ...
i have found this article on how to loop through multi-dimensional arrays quickly. http://nadeausoftware.com/articles/2012/06/c_c_tip_how_loop_through_multi_dimensional_arrays_quickly I am using Method 6: Nested loops with linear array and single incrementing index. It says Method 8: Single loop with linear array and ...
I have a script which can only be run by one specific user on a system. I need to let all users on the system have access to run that script and see the output. But there must never be more than one instance of the script running simultaneously. I came up with this program to be run as the specific user who can run the...
This code correctly returns a View_appointment. Is there a better way to accomplish this with using left joins and unions? I'm trying to learn Linq a little bit better. Components: PostgreSQL 9.3 (backend database) Telerik DataAccess (the entity framework) Overview: I am writing an appointment book for my office. Eac...
I was working on an assignment and I was hoping to know if the merge sort algorithm I wrote in Python was not making any unnecessary computations. def sort(some_list): if len(some_list) > 1: return merge(sort(some_list.__getslice__(0, len(some_list)/2)),\ sort(some_list.__getslice__(len(some_list)...
For some of those in The 2nd Monitor, you know that I was creating a new golfing language. For one or two (@Quill), you have heard from me how tough it is. A-Ray (that's what it's called) is a functional programming language. A sample program looks something like: T0~f"Fizz"~b"Buzz"f{?=%t+960{p`fp`b}{?=%t30{p`f} ?=%t50...
I made a dynamic CSV serializer as a learning challenge a while back, I'm hoping to get my code picked apart so I can learn what I can do better. This is a bit long, so I wouldn't expect anyone to take the time to pick apart the entire thing. If it helps, here is the github page for a download with some instructions. T...
While implementing things like repositories we often can see that reading and writing parts can be done totally independently. The same time client side will win from the single reference (who wants to inject two parameters instead of one in many places). What do you think about a little bit of IL magic? Let's say we h...
Given a class which is an event dispatcher whose underlying store is a dictionary of events whose key is the event type private readonly Dictionary<Type, Delegate> _applicationEventHandlers;, is this the correct way to remove all remaining delegates when the class needs to be disposed? private void RemoveAllListene...
I'm attempting to implement a basic hash table in Python using only lists. Any tips would be appreciated (including better hash functions). I intend this to handle collisions with separate chaining. Are there any features I didn't implement that are standard in hash tables? Are there any things I handled incorrectly ...
For one of my university assignments, we were asked to take an unsigned int, reverse its digits, find the absolute difference between the original and reversed, then reverse that, and you receive the "Magic Number". $$ R(\ \lvert R(A) - A\rvert\ )$$ where \$A\$ is a positive integer and \$R(n)\$ means reverse. We were ...