instruction
stringlengths
71
95.1k
Topic 1: Switching to another form from the project startup form I use the following code that calls an instance of my form for payment (frmPayment) from my startup form (frmMainMenu) using a click event: Private Sub btnPayment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPayment.Click, ...
The following is the producer-consumer algorithm for a piece of software that I'm upgrading to take advantage of multi-core processing. The intended platform is some flavor of Linux running on an EC2 HPC cc4x.large cluster, which feature 2 x Intel Xeon X5570, quad-core “Nehalem” architecture processors (2*4=8 cores). T...
I'm in the middle of writing my own little bullet shooter game much in the style of Touhou. Everything works fine so far but I'm disliking certain aspects of my code. Take this function for showing and unshowing the title screen: private function runIntro() : void { if (introFadeInTitle_ && aliceIntroTx...
Examples of where I've started migrating to short-circuit evaluation: PHP $id=0;//initialized in case of no result $r=mysql_query(SQL); if($r && mysql_num_rows($r)>0){ list($id)=mysql_fetch_row($r); } becomes $id=0; $r=mysql_query(SQL); $r && mysql_num_rows($r)>0 && list($id)=mysql_fetch_row($r); JavaScript var Req...
This is a function which produces the sum of primes beneath (not including) a certain number (using a variant on the sieve of Eratosthenes). erastosum = lambda x: sum([i for i in xrange(2, x) if i == 2 or i == 3 or reduce(lambda y,z: y*z, [i%j for j in xrange(2,int(i ** 0.5) + 1)])]) Excessive use of lambda? Perhaps....
I'm using this C# function to generate random coupons for a system. How can I improve it? public static string GenerateCoupon(int length) { string result = string.Empty; Random random = new Random((int)DateTime.Now.Ticks); List<string> characters = new List<string>() { }; for (int i = 48; i < 58; i++) ...
The index file: <?php require_once 'app/run.php'; $_action = (isset($_GET['cmd']) && ctype_alnum($_GET['cmd'])) ? $_GET['cmd'] : 'index'; switch ($_action) { case 'index': case 'default': case 'home': include $con_dir . '/index.php'; break; default: include $con_dir . '/404.php'; ...
I am maintaining a site with significant security concerns and I wrote a helper class for validating potential XSS attacks. The ValidateRequest method is meant to evaluate the HttpRequest for any potential issues, and if issues are found, redirect the user to the same page, but in a away that is not threatening to the...
I'm just playing with the concept of GroupBy inside Rx. So, I wondered how hard it would be to write a console application that continuously reads lines, groups them by similar words and just prints out the word among the current count of how often the word was written before. It really was a breeze to do that but I wo...
I was given a problem to find out all the prime numbers within a range. Just after I wrote the program I found numerous other codes to solve the problem. I am interested to know is my algorithm efficient? Is it like sieve filtration? (before writing this code I had no clear idea on sieve filtration method) or the algor...
I am a newbie at writing Android apps and using Java in general. I have went through most of the Android hello view tutorials but still seem to be lacking some understanding of the basics. Here is a snippet of code I wrote for an app. My goal was to have three edittext boxes for the user to input information. I want...
I am currently writing a disassembler for Don Knuth's MMIX. The module in this gist is a pretty-printer for single instructions that reads in instructions from an char* buffer and prints the resulting disassembly to stdout. It is quite long, the code below is an excerpt of the most important parts. I am quite new to C....
Here is a recursive function that I wrote to search a file-system to a child depth defined by $depth. Could it be optimized more? function stringSearch($working_dir,&$results_array,$depth) { global $search_string; global $dir_count; global $file_count; global $working_url; global $max_depth; if...
I would love to hear some comments on this small script, which (I hope) reduces repetitive tasks such as page refreshing, compilation and so on to minimum. # -*- coding: utf-8 -*- # Author: Jacek 'Sabr' Karolak (j.karolak@sabr.pl) # Watch [files] for change, and after every change run given [command] # # # Example watc...
I'm a systems programmer teaching myself javascript. Prototypal inheritance is completely new to me, so I could use some best practices advice here. I made a simple game (breakout) for my first practice project. Here is a simple example of a game object. function GameObject(sprite) { this.xVelocity = 0; thi...
Just started to clean up an old code base. I'm interested in your perspective and ways that you would change the following function. private void MarkSelectedRow() { Object obj = Bankkonto1.Value; if ((obj != null) && (myBankkonten.Contains(obj.ToString()))) { foreach (UltraG...
If the current page URL has an argument 'myid1' or 'myid2' in the querystring, for each link in my webpage with class 'rewrite', I want the link href's querystring to be replaced by the current page URL's querystring. I'm using the code given below. Since I'm new to javascript, I'm not sure if its optimized. I want it ...
For each of my various websites, I back up the web site files and the associated database for into a single dated compressed archive file (one zip file per website) and download that to my local Windows Vista machine. My websites are hosted on Unix machines accessible via ssh. I've decided to use Python Fabric as it ...
I have been working with AJAX and JSON for quite some years now, but to be honest I still do not know exactly what all the functionality are, and how to create optimized code for jQuery. So my first question: Does anyone know a good tutorial, or better even a cheatsheet where are the functionalities are explained. I ha...
I've written some code to read a column of data from a dataset called AltIds. The values are nullable. My code is written to find all the values in the column that are not null and write them to an array. Guid[] altIds = myDataSet.Tables[0].AsEnumerable() .Select(row => row.Field<Guid?>("AltId")) .Where(x => x.Ha...
I have a function that is being called in a tight loop. I've profiled my code and this is where my largest bottleneck is. The function is fairly simple: it checks if a point in (x,y) form is above a line in (slope, intercept) form. The problem is, it also has to deal with the case where the slope is positive infinity,...
What I'm doing Using the v3 of the Wufoo API to retrieve all entries and store in a single array ($all_results). This is necessary because of the limit 100 entries limit that Wufoo has when retrieving results from their api. Also store the results to file we don't get slow responses from the api. My question I'm wonde...
There are 28 check boxes that are given a common name and have different values: <input type="checkbox" name="Schedules" id="checkbox1" value="1"> In controller in post action: public ActionResult Create(SubscriptionPlanCreateViewModel subscriptionPlanCreateViewModel, FormCollection Form) { string[] AllStrings = F...
Any suggestions on how to make this code more efficient? import java.util.Scanner; public class RecursionLargestInArray { public static void main (String[] args) { int max = -999; Scanner scan = new Scanner (System.in); System.out.print("Enter the size of the array: "); int arraySize = scan.nextI...
The below code converts the window.location.search querystring into a JavaScript object. In particular, if a key occurs more than once the resulting value in the object will be an array. Please feel free to comment on both readability and speed of execution. Thanks! window.location.search.split(/[?&]/g).reduce(function...
I have some troubles to find the right loop to check if some values are contained in mysql DB. I'm making a software and I want to add license ID. Each user has x keys to use. Now when the user start the client, it invokes a PHP page that check if the Key sent in the POST method is stored in DB or not. If that key is...
I'm trying to write function, that replace digits at some positions in number. For example f 91521 [3,4] -> [91001,91111,91221,91331,91441,91551,91661,91771,91881,91991] It's behavior like 91**1 -> ..., so I named it as a 'whitemask'. Question 1: is "whitemask" a normal and adequately name for that function? After tha...
This program is supposed to calculate the determinants of the data entered. I believe it does. Within the guidelines of this exercise we were not to break this down to functions but all out of main. We will be breaking it down into functions in part a and b of this overall exercise. However, I don't know enough about m...
I wrote this PHP Login system and I would like to see if I have any errors/made any mistakes or if you think I can do something to improve it, like including tokenizing and improving security even more. This script allows "Remember Me" option which uses a cookie and a session table to authorize a user. It has basic fun...
I understand not to rely on user agent information for anything detrimental towards the site since it can be faked or hidden etc, it's more of just an extra feature for something. Is there anyway this can be made shorter perhaps? Also it will be running on a few pages, so I was wanting to know if it's performance is go...
The comment at the top was not followed because I printed the contents. I just want an opinion on coding style. /* * Write a function setbits(x,p,n,y) that returns x with the n bits * that begin at position p set to the rightmost n bits of y, leaving * the other bits unchanged in the least number of ...
I have a JavaScript/jQuery function that handles the drop-down menus for several different sites. I am a new to JavaScript and jQuery and would love any input on how to clean up my code. Essentially, I am asking how to make this script more efficient and less clunky, so I can improve performance and write better code. ...
EDIT: Function is returnted to JClass Text. Prototypes hold non instance members (statics). No privacy. Privacy requires self executing methods. var Text = function( form_name ) { this.text_array = document.forms[form_name].elements; }; Text.prototype.patterns = { prefix_url: /^http:\/\//, url: ...
I started playing with Raphaël and I'm wondering if somebody could do the code review of what I have so far and maybe give me some tips how to improve it. Basically what I'm trying to accomplish is the zoom-in/zoom-out effect on the element when mouseover event is being triggered on the element. The effect should paus...
I have something akin to object[] values = getValues(); string renderedValues = string.Join("-", Array.ConvertAll<object,string>(values, new Converter<object,string>(o2s) )); where o2s is public static string o2s(object o) { return o.ToString...
I always thought it would be handy to be able to write: const std::string s = (std::ostringstream() << "hi" << 0).str(); This doesn't work in C++ by default because operator<< returns the ostringstream as a ostream, which obviously doesn't have the str() member. I was pleasantly surprised though to discover that this ...
After having spent a month or two trying to learn JavaScript, especially functional programming, async, and closures, I finally get it. But I don't know if I'm writing elegant code... Specifically, I'm not sure if I'm creating too many closures, because I don't entirely grasp when contexts remain and when they're marke...
For a given Entity Framework data set, I have written several adapters to import data into my entity models. Rather than manually write mapping code for each entity model, I tried for a generalized approach using reflection. My requirements are: The updater must create the entity if it does not exist, or update the e...
I am periodically getting tweets, formatting them, and storing them into the database. Now the line of code I use for this is an awful lot. I was wondering if this could be improved. // This is the wordpress way of getting a json object // Wordpress will determine how the data is going to // be fetched looking at what...
I need to get some scripts from the different social networking site and cache them. I want the function to be asynchronous, and non-blocking. I have settled with a script, but I am not really sure if it is not overly complicated to do the job. I did replace a normal for loop, and this method is much faster. I do not...
I've been away from PHP for at least 5 years and I'm just starting to look into it again. I have a set of functions I created and used for database access and I'm wondering if they are still good to use. <?php // // A group of database function to hide any errors that may occur and // allow for some form of fallback. I...
Can someone look over this Sieve of Eratosthenes implementation? It seems almost too easy. Rather than maintaining a seperate bit[] to track prime/not prime, I'm just removing the noncandidates from the collection completely on each iteration. Pseudocode LIST = 2...n set M = 1 while M < sqrt(n) set M = next number ...
I need to write a class to batch Order objects from 3 calling components running on 3 separate threads. The 3 calling components will call the Batcher class at the same time (within a second of each other), but to handle clock issues and thread interleaving, the method should wait for a maximum of 5 seconds for the 3 c...
The Problem I found myself needing an instance of an IObjectContext interface that should never be null, but wanting to delay instantiation until after some required resources have been loaded. I decided to approach this with Lazy<T>, but quickly ran into an issue -- I also require an IObjectSet<TEntity> that is never ...
Could you suggest ways of making this more simple? /* * Next write a function invert(x,p,n) that returns x with the n bits * that begin at position p inverted, leaving the others unchange */ void printbits(unsigned x) { size_t size_of_int = sizeof(int) << 3; unsigned mask = 1; int i = 0; for(i = 1; ...
This is the first time I tried to write a back propagation ANN and I would like to know what more experienced people think of it. The code is meant to distinguish if text is written in English, French or Dutch. I know my training set isn't very diverse but I just got the data from about 30 different texts, each contain...
I have a user model. It basically forwards get/create/delete requests into my database client. The problem I have is the error handling, it screams not DRY to me, but I can't find an elegant way to clean it up. var UserModel = pd.make(Model, { get: function _get(id, cb) { // nano is a database client ...
Basically I'm writing a simple framework in php in order to learn more. This session class is extremely rudimentary. At this point I'm not even checking ip/user_agent to prevent session hijacking, it's just basic right now. Also, my _serialize() and _unserialize functions don't actually do anything special, but they mi...
I have a WebPostRequest class which looks like this: public class WebPostRequest { public const string Success = "OK"; private WebRequest _webRequest; private List<string> _paramsList; public WebPostRequest(string url) { try { _webRequest = WebRequest.Create(url); ...
I have the following code which is located within a case, in a switch statement. Its goal is to add a Pupil to a Subject using the Collections in the respective class. I've tried to make the code as readable as possible, but I'm sure there's a better approach. System.out.println("Adding a Pupil..."); String AddPu...
I have two functions, one to convert a datetime to a hex word, and one to convert a word to a datetime. I was just wondering if there was a more efficient way to convert back and forth. /// <summary> /// Converts a date time to a hexadecimal word /// </summary> /// <param name="date">the date time</param> /// <returns>...
For a project I'm working on, I need to compare version strings where: version strings are composed only of numbers and periods version strings are made up of an arbitrary number of segments (major.minor, manjor.minor.build, etc) 1.0 is equivalent to 1.0.0, etc. Please provide feedback on performance considerations o...
The last question I have been playing around with is a right rotate. I think it is also called a barrel roll. Please post if you have a better solution please post. I am still learning the art of bit flipping. /* * Next write a function rightrot(x,n) that returns the value of the * integer x rotated to the right by ...
I have a list of sales records sorted by sales date. I need to fill in the gaps (days without a sales record) in this list with 'inferred sales' records. The method in question calculates an average price for the inferred sales records from its closest valid neighbors that have the same SalesType. If there's only one ...
I am trying to find a good way of parsing SQL arguments, the way I am accomplishing it now seems like it can use a lot of improvement. I am trying to convert arguments that are split apart by ', & <= =>' from a string into SQL arguments like name = 'ABC' OR name ='John Doe'. So parseSQLOperators('dan,john&steven', 'us...
The problem I am trying to solve can be described as take binarysearch0 and rewrite it as binarysearch1 such that binarysearch1 uses a single test inside the loop instead of two. The code I used to do this is seen below. Please let me know if you think I accomplished the task, and what I can do better. #include <stdlib...
I want you to review my JavaScript project. var geocoder; var map; var infowindow = new google.maps.InfoWindow(); var marker; function initialize() { document.upload.lat.value = geoip_latitude(); document.upload.lng.value = geoip_longitude(); geocoder = new google.maps.Geocoder(); var latlng = new goog...
I'm trying to conform to the Zend Coding Standard as well. EDIT 2: <?php /** * Input : Query request * Output : A row or a list of rows * Notes : * * Provides escaping and binding via PDO library * Consolidates PDO to use a single calling mechanism * Consolidates all queries to an as...
I'm looking for any feedback on this code. If it is too much please pick a random method/group and give me feedback. This code passes www.jshint.com. I'm trying to shape this collection into a library. The regular expressions have a way to go. Any incremental constructive feedback welcome. Only the objects returned are...
if (isset($_POST['submit'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { $errors = array(); $error = 0; if (!preg_match('/^[A-Za-z](?=[A-Za-z0-9_.]{3,20}$)[a-zA-Z0-9_]*\.?[a-zA-Z0-9_]*$/i', $_POST['username'])) { $errors[] = 'Your username must st...
I'm trying to transpose the following data from: 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 to: 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 ...
Are there any security flaws in what I plan to do? I need to store the following in my DB: a random string to act as a salt for encrypting a password the encrypted password that used the salt in #1 Here's the PHP code I have to accomplish the above tasks: <?php function decrypt($string, $encryption_key = '') ...
Alright, well the title doesn't really explain anything, so I'll show a pared down version of my code: class Handler { Dictionary<object, Leaf> AllItems = new Dictionary<object, Leaf>(); //This list Leaf RootLeaf = new Leaf(); public void Add (object obj) { Leaf AddedTo = RootLeaf.Add(obj); //A...
I am working a project which uses a function to show a modal dialog. The dialog can be hidden by calling the hideModal() function. This function is triggered by: Pressing the ESC key Clicking on the modal background Clicking on the close button My current code is: $("#modal").click(function() { hideModal(); }); ...
I've learned MVVM for a week or so, and I've seen the Jason Dolinger video many times. Step by step, following the Jason Dolinger video, I've created my own application which is almost the same to the one presented by Jason Dolinger. I'm completely satisfied with my current application, however, because the recorded vi...
How can this solution be improved? #include <limits.h> void itoa(int n, char s[]) { int min_int = 0; int i, sign; if (INT_MIN == n) { min_int = 1; n++; } if ((sign = n) < 0) n = -n; i = 0; do { s[i++] = n % 10 + '0'; } while ((n /= 10) > 0); if (sig...
I'm somewhat curious on peoples opinion about such a method. I Actually didn't find anything similar in librarys I use on regular bases so far. This is my implementation: Object.map = function _map( obj, transform ) { if( typeof obj === 'object' && typeof transform === 'function' ) { Object.keys( obj ).forE...
/** * View_message * Object Model */ var View_message = function(div) { this.div = document.getElementById(div); }; View_message.prototype.messages = { empty: 'Please complete all fields', empty_bm: 'Please enter both a title and url', name: 'Only letters or dashes for the name field', ...
I used to use static or singleton for my DAL class. However, I read some articles saying that singleton is evil and should be avoided. Therefore I try to rewrite my code like this: public class CustomerBLL { private CustomerHelper helper = new CustomerHelper(); private CustomerDAL dal = new CustomerDAL(); ...
I'm combining 2 UISliders made from scratch -- one horizontal and one vertical -- to make a single slider that controls 2 parameters. They are set up so that the vertical slider is perpendicular to the horizontal one. (Like a cross) The thumb knob can move both horizontally and vertically, and if it's moved horizontal...
For the time being, I am not interested in any recursive solution. The code is not modularized; the whole body is inside the main function. #include<iostream.h> #include<stdlib.h> /*This code is written by NF between any time of 120711 and 210711;modified at 231211*/ int main() { int length=0,min_heapified=0,start...
I am trying to validate time entry. ArrTime is the time entered by the user from the UI. I am trying to make it so that when a user attempts to add a time, it must be between 8:45 and 17:30. Is there any thing wrong with my code? I am not very good at JavaScript so I have a feeling it is that, but if you can help me at...
Fiddle: http://jsfiddle.net/fhBd5/ So the above is working but I'm having trouble trying to come up with a clean and concise way to do some type of loop on the if or statements. Any help is very much appreciated! var checkPositionOnLoad = function (e) { var currentPos = 0; var listItem = document.getE...
I am a Scala newbie and attempting to improve my skills. I have decided to be playful about it and work to do a conversion of the spaceinvaders game supplied with the LWJGL. It consists of 10 Java classes of which I have loaded, compiled and successfully ran from Eclipse. My first Scala step is to replace the Sprite.ja...
I was hoping someone could provide some feedback with regards to this: import java.util.InputMismatchException; import java.util.Scanner; public class Bank { protected double myBalance = 10.40; protected double bankBalance = 1000000; protected double creditRating = 0.1; private static final int PIN =...
Should I be using this more, instead of slider? Am I making any serious no-no's here, and is there a better design I should implement? I'm up for any pointers :) slider = { selector : '#slider', init : function() { $('#slider').hover(function(e){ ...
I wrote a small class that demonstrates my problem: class Root { private Leaf RootLeaf; private Dictionary<object, Leaf> AllItems = new Dictionary<object, Leaf>(); //dictionary contains a reference to each item, and the leaf it is assigned to (its parent) public Root() { RootLeaf = new Leaf(); ...
This is a pattern in SQL queries that I've found myself repeating recently: SELECT w, x, y, (w + x) / y as z FROM (SELECT <some gigantic and complicated query> as w, a + b as x, a - b as y FROM basetable) somealias; The issue is: a select query that does some complex oper...
I have a class which updates an object. The class takes a String id in its constructor and returns the appropriate class based on the id. I think these two methods should be separated into their own classes as returning an object based on a String id will probably have uses elsewhere in the code base. I've considered a...
The exercise was to take a file such as this: You say yes I say no You say stop And I say go go go CHORUS: Oh no You say Goodbye And I say hello Hello hello I don't know why You say Goodbye I say hello #repeat 9 12 Why #repeat 11 13 I say high You say low You say why And I say I don't know #repeat 5 19 And parse the...
I'm working on a piece of code in my MVC3 application and I'm struggling to decide if what I plan to do is a bad idea or not. I have a snippet of JavaScript that calls an MVC action that in turn returns an HTML partial that I then insert into a div element on my page. Nothing complicated there. However, things have cha...
The below is a class designed to implement Rememember the Milk's task priorities. I'm using it partly as an exercise in "Pythonic" programming, so it's fairly simple already, but advice on how to make it simpler or more Pythonic would be particularly appreciated. I'm using Python 2.6.5 in case it makes any difference. ...
I came across this code in our project today. Where possible I'm trying to leave the code base in a better shape than I found it, as I go along, and this method jumped out at me for a number of reasons, mainly the sql string and the try/catch block. I feel there's a less expensive way to do it. Original Code: public ...
<?php include_once('../dbInfo.php'); function getReport($user_table) { $tables = array( "day" => "p_day", "month" => "p_month" ... etc. ..... ); $table = $tables[$user_table]; if(!$table) { die(json_encode(array("error" => "bad table name"))); } ...
First Implementation public enum ReviewFlowExample { Draft { @Override public ReviewFlowExample getNext() { return Review; } @Override public ReviewFlowExample getPrevious() { return null; } }, Review { @Override pub...
I wanted to try experimenting with fluent interface design in the C programming language. That's why I wanted to ask you, Dear Code Review users, comments on the way I have implement this simple employee record interface. Please note that for maximum simplicity I am resorting to as simple data structures as possible. #...
I have a piece of code that takes a couple of integers and check if performing an addition on the inputs would result in an overflow. I was wondering if this code is SOLID: public static boolean CanAdd(int me, int... args) { int total = me; for (int arg : args) { if (total >= 0) { if (java....
I wrote a quicksort program in C++. Is it okay to implement it this way? Am I using pointers correctly? Is my style okay? Any ideas to speed it up or save memory? void change(int *i, int *j) { int temp = *j; *j = *i; *i = temp; } int *toplace(int *start, int *end) { int *i = start+1, *j= end; while(i<=j...
I did not get the job after submitting this piece of work in an interview, but I have no feedback to know what "BAD" things are inside this block of code. The requirements are: Connect to the server on a known port and IP Asynchronously send a message to the server in your choice of format Calculate a...
I am just trying to use ASP.NET MVC using repository pattern. Am I doing something wrong here? Model - Contains the model public class Contact { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string EmailAddress { get; set; } } Repository ...
I have two small structs (might change to classes later) that get loaded into Generic lists. The loading of the lists is what I'm asking about. Can it be done better or more object-oriented? You'll notice I'm using MS Enterprise library for data access to a SqlCe database. I'm just looking for some opinions on this cod...
In his KnockoutJs 1.3 beta post, Steve Sanderson has an example of using Binding providers ("5. Binding providers (and hence external bindings)") where he makes a comment in the JSFiddle JavaScript tab that says "// This syntax would be way more succinct with CoffeeScript". How would this actually be accomplished? //...
I have been tasked with implementing a secure account login system for a website's content management system. I have built a solution around an access masterpage that handles all account access functions. Here is the Page_Load Protected Sub Page_Load() Handles Me.Load If Not Request.IsSecureConnection Then ...
I just made this sort method. It runs fine and the code looks okay in my eyes. Is is possible to optimize it so it runs faster? If it's \$O(n^3)\$ now, it would be interesting changing it to \$O(n^2)\$ or something like that. Side question: This is \$O(n^3)\$, right (I only like \$O(n^2)\$ and below)? List<Log> errors...
I would like some advice to shorten down this snippet, give it more efficient flow and look. Review should focus on keeping it as a compact single method (except the two public props). The DataType and MeasureStatus is an enum. Readability is of course more important than compactness. .... /// <summary> /// Helper that...
As part of our sprints, we do peer review each others code. Here is the code that I am reviewing. public void SendEmail() { string emailAddress = string.Empty; string managerEmailAddress = string.Empty; if (//condition) { //do something //Retrieve emailAddress and managerEmailAddress...
I'm currently looking at this Boost::CRC example code which I have also inserted below. I always try to look for suggestions for improving my own coding style when I encounter well-written and well-formatted code. This code definitely looks like good code, but two things puzzle me about this: is it good practice to co...
Here it is the best I can do (I am a noob using Haskell): map (\(y, z) -> y + z) (zip x (tail x)) I'm looking for a point-free solution.
After checking some incoming coding competitions, I feel I may want to develop a little bit more on my coding skills and style using some basic algorithms/data structures. The following two pieces of Java code are about some LinkedList operation. Can you take a quick look and give me some feedback about the accuracy, e...
I'm trying to convert from random bytes to integers within a range. Basically converting as such: byte[] GetRandomBytes(int count) -> int NextInteger(int min, int max) Another way to think about it would be: I have a RNGCryptoServiceProvider but would rather have the interface to Random. My current algorithm works out...