instruction
stringlengths
71
95.1k
I am interested in seeing how people would refactor this code to make it more readable, remove local variables, etc. The code checks a string against a number of arrays. The first (0) field of each array is the root word and the rest of the words are its synonyms. The idea is to replace any word in the user-provided st...
The aim of this code is to return an object which contains all of the movies. Where attributes are not found, they need to return None rather than be undefined and raise an exception. attrs is a list of all possible properties for that class. Each class loops through and tries to get the attribute. If the attribute is ...
I am using class "active" to keep track on which child to fade in and fade out in my gallery. Are there any other, better options for doing this? <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/...
Previous question: Java application for finding permutations efficiently> I have changed quite a bit of code, and need some more reviews. class Permutations { static long factorial(int num){ long factorial = num; for (int forBlockvar = num; forBlockvar > 1; forBlockvar--) { factorial = ...
Please have a look at the following 2 snippets: var query = _ctx.Notes.Where(...); var searchLower = searchTerms.ToLower(); query = query.Where(a => a.Comment.ToLower().Contains(searchLower)) vs var query = _ctx.Notes.Where(...); query = query.Where(a => a.Comment.ToLower().Contains(searchTerms.ToLower()))...
My query is this: UPDATE `phrases` SET `phrases`.`count`=(SELECT COUNT(*) FROM `strings` WHERE `string` LIKE CONCAT('%', `phrases`.`phrase`, '%')) My tables look like this: CREATE TABLE `phrases` ( `hash` varchar(32) NOT NULL, `count` int DEFAULT 0, `phrase` text NOT NULL, PRIMARY KEY (`hash`), K...
I have made a simple scorecard form which uses jQuery to automatically calculate the score of submissions depending on field values. Some fields are "critical" which means if they are a fail they automatically fail. You can see a jsFiddle example to get a better understanding. I have tried to make the code as efficien...
This is a view as part of a RESTful image handler module, written for Flask, I am sure there is a better/more pythonic way of doing parts of this, maybe using List Comprehensions or Generator Functions. But I am a bit of a Python newbie and cannot spot it. Can any experienced pythonistas take a look? @__mod__.route('/'...
I'm working through an introduction to computer science book, this is not homework for me but me trying to learn in my spare time, I'm not asking for homework help! The output is below, and this is all ok, but I'm just certain there is a more efficient way of doing this. I have been trying for many hours now and this i...
Is there a better way to do this without using if or case statements? var val = ui.value, $box = $('#message'); switch(true) { case (val > 50): $box.hide(); animations.animateBox($box.html('you have chosen XN')); break; case (val < 50): $box.hide().delay(300); animations....
Any suggestions on how I could improve it? jsFiddle (function($){ $.extend({ notify: function(options, duration) { var // Default options object defaults = { inline: false, href: '', html: '', onStart: funct...
Requirements: When the page (or in the case of the example Frame) expands, the only column to expand with the table should be 'unfrozen' columns (without the 'freeze' class). here is the live demo The jQuery is there to show dynamic content, it is not the code under review What I really don't like is that is seems to ...
I just rewrote this: if (budgetRemaining != 0 || totalOpenInvoices != 0) { } Like this: if (new[] { budgetRemaining, totalOpenInvoices }.Any(c => c != 0)) { } If I had seen that before I ramped up on Linq, it would have confused me. Now that I've been learning functional programming and using Linq, it seems natural,...
I wrote a query to run the same query across multiple databases and combine the results. While it seems plenty quick I was wondering if there is a better way to do this. create table #serverlist( ID smallint IDENTITY(1,1), dbName varchar(50) ) create table #browsercounts( ID smallint IDENTITY(...
Here is my attempt at a floaty Bar module, used in a mobile application. There are several "bars", which stick to the top of the browser window once they are passed. When the next bar is reached, it takes over that sticky position... Based on: http://googlecode.blogspot.com/2009/09/gmail-for-mobile-html5-series-css.htm...
I'm somewhat new to SQL (using it in the past but only being exposed to it heavily in my current role). Unfortunately nobody at my current company has really given me any advice on formatting. How can I format this better / what should I avoid doing that I may have done below? Any feedback on re-factoring would be grea...
I'm building a web application in Java. I'm new to Java, so before I get too far into this... I'm hoping to take advantage of all the experience here and learn the problems with this setup. My Servlet package cms.content; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotati...
I have a TreeView called myTreeView. I want to be able to write a single statement after which myTreeView.SelectedNode is null, but TreeView.SelectedNode doesn't have a setter. I've looked at the decompiled source of TreeView, and there is a SetSelectedNode method (that can accept null), but it's internal. So I made th...
I am writing a script that takes one CSV file searches for a value in another CSV file then writes an output depending on the result it finds. I have been using Python's CSV Distreader and writer. I have it working, but it is very inefficient because it is looping through the 2 sets of data until it finds a result. Th...
I am learning Scala, coming from Java background. Here I have written a small prototype proof of concept program that is a part of concept base for a simple upcoming tutorial game. There are two game objects: a Cell and a Breed of cells (a 1d row). The operations are simple. One can create a breed with a number of cell...
I had to do a small application using a menu system and Turtle. I have finished it and worked perfect. Just to make sure, can you please check it if it has done properly? #!/usr/bin/python ## draw_shape.py import turtle as t def how_many(): while True: print " How many of then do you want to draw?" ...
I'm trying to print the top 5 most queried strings from a text file. I can't use other third-party libraries to make it easier w.r.t hashmap implementations. I need to improve on these if possible: cyclomatic complexity Memory usage Execution time Page faults import java.io.File; import java.io.FileNotFoundExceptio...
Below is a simple "class" for displaying messages. It stores the output html div and then displays messages to it as needed. It works fine. For readability, and encapsulation purposes, I'd like the componenets of the "class" in a contianer of sorts or a javascript object? What is the simplest way to to do this. Or...
I have a C# WinForms app containing a ListBox control, which I populate with objects of type BukkitServer. When an object is added or removed from the list, I want to write them to an XML file. I have a static method in a helper class that takes an ICollection argument and achieves this. However, since the ListBox.Ob...
I'm new to template meta-programming and wrote some code to determine if a number is a perfect square. For example, in my program, SQUARE<1>::value and SQUARE<4>::value evaluate to true while SQUARE<5>::value is false. I'm open to any suggestions on how I could implement this better, cleaner, or make use of standard ...
I have been reading about ZF2 EventManager for some time now and I wonder what you'd think about this approach. class Model_Member extends App_Model_Model { protected $_data = array( 'ID' => null, 'UserName' => null, 'Password' => null, 'EmailAddress' => null, 'CreatedOn' => ...
I have a small program where I have a background thread that plays sound, so it needs to run really fast, but it also needs to do a small amount of memory management. I didn't want to use normal new and delete in a time critical area, so I threw this together, but set it up so I could reuse it elsewhere. template <typ...
How do I make my Python program faster? I have 3 suspects right now for it being so slow: Maybe my computer is just slow Maybe my Internet is too slow (sometimes my program has to download the html of web pages and then it searches through the html for a specific piece of text) My code is slow (too many loops maybe? s...
This is my first attempt at a hash map and I feel it is a great start. Although it does have a certain naive feel that I'm having trouble with. public class HashMap<TKey, TValue> { const int BlockSize = 100000; const int NumberOfBlocks = 42950; readonly Entry[][] _blocks = new Entry[NumberOfBlocks][]; ...
File manipulation code, I've noticed, has two salient properties: It's everywhere, and vitally important to functional software It has lots of exceptions. Please give me some pointers on how I can better improve the usability of this rough draft I wrote yesterday. It assumes some very basic things, and was scraped to...
The goal is displaying the date and time of an article in a humanized and localized way: Yesterday 13:21 or if the Swedish language parameter is set it will display: Igår 13:21 And if the date wasn't yesterday or today, it will print the date and 24-hour time. I think I succeeded with everything except handling ...
var newObject = keyValuePair.Key; var originalObject = keyValuePair.Value; List<ChargeBITValue> bitValues = new List<ChargeBITValue>(); foreach (var item in originalObject.ChargeBITValues) { ChargeBITValue bitValue = new ChargeBITValue() { ChargeTypeEnumID = item.ChargeTypeEnumID, DataValue = it...
I have the following: public interface IBehaviour { event EventHandler Completed; void Execute(); } public interface IBehaviourA : IBehaviour { // Some specific stuff here object A { get; set; } } public interface IBehaviourB : IBehaviour { // Some specific stuff here object B {get;set;} } pu...
I'm extremely new to Java, and I had a bit of an attempt at making something that you could call lotto. I've still got a lot more to go on it, but things are becoming tedious, and I am sure there is a simpler way to do what I am doing. How can this code be changed to have less repetitive code/optimized? import java.ut...
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: int IsPrime(unsigned int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if (num...
I am trying to remove duplicates from a string without using additional buffers. This seems to work correct, I think. Can this be improved? Should I be doing it differently? private static String removeDuplicates(char[] chars) { if(chars == null) return null; int len = chars.length; ...
Based on the standard implementation of Array.sort in JavaScript, would the following be a reasonable way of shuffling the contents of an array? Is it moderately efficient and will it produce a fairly even spread of results? Array.prototype.shuffle = function () { return this.sort(function(){ return Math.random() -...
I posted the following Matlab script in response to a question on Signal Processing. Here is the questions with my answer. I am looking for comments on how to make this code more instructive for the questioner. Any other code review comments are also welcomed. fs = 2^10; %sample frequency in Hz T = 1/fs; ...
I've written a quick "local document crawler" that fetches the title tag and an expandable amount of metatag information from files on a webserver. I develop in .NET for a living and don't have a clue what I'm doing, but the site I'm helping with only has PHP hosting. The goal is to gather metadata from files on a serv...
Inspired by another question here: Sum of Prime numbers under 2 million, I decided to try and implement Eratosthenes' Sieve from scratch using the algorithm described in the article. unsigned int CalculateSumOfPrimes(const unsigned int number) { if(number <= 1) return 0; if(number == 2) return 2; std::vecto...
I have a module, that fetches some object. Then other modules can use this object. Here is a little example of this task: var Structure = (function(){ var tree = null, df = $.ajax({ 'url' : '/some/path', 'type' : 'POST', 'data' : { some : 'data' }, ...
I have two tables table_inventory List item inventory_rack_key(primarykey) node_key rack_id inventory_item_key in_coming_qty,locked_qty quantity table_item inventory_item_key(primary key) item_id,product_zone The table example are provided here DB TABLES I need query to find out t...
Here are some examples: [1, 2, 3, 4, 5] => [1, 2, 3, 4, 5] [10, 15, 10, 15, 30] => [10, 15] [1, 2, 3, 4, 1, 5, 6, 7] => [1, 2, 3, 4] Here's my best (and deeply ugly) non-recursive, side-effect-free solution so far: x.scanLeft(List[Int]())((B, Term) => Term :: B).drop(1).takeWhile(i => !(i.tail contains i.head)).last.r...
This is the proof-of-concept code with drafts for widgets for my current project that uses Google Maps. As a result the code produces 3 buttons in the top right corner: Any advice on how I may improve it? (personally I'm specifically server-side developer and don't use JavaScript extensively, so expect a lot of no-no'...
I have a set of components that each need to both publish and receive messages using a multicast channel. In production, any one machine could host two or more of these components with 12 or more machines communicating with each other. My question is... given that components on the same machine and components on separ...
I know I've already asked a similar question, but this feels quite different to me. The main goal is to wait for a file to be accessible (read: waiting until the file lock releases), since it seems like there's no way to do this built into the .NET framework I've written a quick and dirty function to do this. The requi...
This code basically finds duplicate strings within a file. An example: DUPLICATE_LENGTH set to 6, file contains: process hash michael honeycomb interrupt system call deadlock scheduling michael The output will be michael, as its a duplicate with a length of 6 or higher The following code shows my approach to solv...
In our embedded application, we have to replace ::operator new and ::operator delete to call a special malloc(), to ensure that the memory is allocated correctly. The code, written with this guide in mind, looks like this: #include <new> #include <stdexcept> // Regular scalar new void* operator new(std::size_t n) thro...
If I have a long string: // 10MB string $string=''; for($run=0; $run<1000000; $run++) $string.='012345689'; Then I perform many substr, cutting off small portions from the beginning. for($run=0; $run<100000; $run++) { $temp=substr($string,0,10); DoSomething($temp); $string=substr($string,10); } It is VERY slow (20 se...
I am trying to implement a TCP/UDP server so all I have to do is something like this: var server = new Server(Type.UDP, "127.0.0.1", 8888); server.OnDataRecieved += Datahandler; server.Start(); I have tried to make it perform as fast as possible by using Asynchronous calls where possible. I basically would like to kn...
I have a subsystem in a web application that essentially allows users to build views of certain lists of objects. They can specify which columns to display, how to sort and group the list, and what filters they want to assign to the results set. These views of certain objects are fundamentally similar, but due to limit...
I've got an MVC site, using FormsAuthentication and custom service classes for Authentication, Authorization, Roles/Membership, etc. Authentication There are three ways to sign-on: Email + Alias OpenID Username + Password All three get the user an auth cookie and start a session. The first two are used by visitors (s...
I'm not a css expert so please help me figuring this out. Would you consider this as good css code? Please point any issues if you believe this is not what you would exactly consider as good code. html { -webkit-text-size-adjust: 70%; } body { margin:0px; padding:0px;font-family:Ar...
This is a rot-n (rotate n times) encrypt/decrypt algorithm, where n can be any integer (+/-). It's written to encrypt/decrypt all the alphabets (upper/lower case) and leaving behind all non-alphas. rot-n where n is the key, is given in the first line of input file. Everything is working fine. I just need help in optim...
It is known a Revealing Module Pattern in javascript, and here it is a little example. var Module = (function(){ var a = 3, init = function(a_user){ a = a_user; }, update = function(){}, get = function(){return a}, set = function(a_user){ a = a_user; }; return { i...
I am creating a Minecraft-like terrain engine in XNA to learn HLSL and more XNA. The problem is my lighting algorithm. Whenever a block which emits light is placed, it takes about half a second to calculate it. I have implemented the lighting in a recursive way. public void DoLight(int x, int y, int z, float light) { ...
Please point out every problem you see with this code. Any fundamental flaws, naming conventions, design decisions, you name it. #include <iostream> #include <algorithm> #include <vector> class SieveHelper { public: SieveHelper() : cur(2) {} bool operator()(unsigned int i) { return i != cur && i % cur...
Struggling to write a simple tool to quickly sum up the last reported versions in a bunch of files. I'm using a named pipe to get the count out the loop for the final value, but the $version isn't populated which I don't understand. mkfifo mypipe for i in stats/* do tail -1 $i done | sort -n > mypipe & while read ...
Is it possible to shorten this, or to improve the code in any way? I know it's just a simple if-statement, but it's always fun to learn a shorter way of doing things. if self.citizenship == 'ES' @identification_type = IDENTIFICATION_TYPES[0] elsif self.country == 'ES' @identification_type = IDENTIFICATION_TYPES[1] ...
For digital electronic circuit simulation, i wanted to implement Three states. i.e High, Low and Undefined in C++. I saw Boost::tribool, and they implement it using enum Now for conserving some memory i have implemented it using 1 Byte Int #ifdef _WINDOWS typedef __int8 State; #elif typedef int8_t State; #endif const ...
I have the following code that loops through a collection of objects and dumps different properties out to Excel. The whole j++ on every other line doesn't seem very elegant. Is there a more elegant way to have this functionality where I loop through objects in a collection and dump out properties? int rowIndex = 2; ...
This is based on Alexey Drobyshevsky's excellent article, "Problems with Iteration". With Alexey's suggestion, I implemented his solution using a ReaderWriterLockSlim. Then I fleshed out a ThreadSafeList<T> : IList<T> implementation. The idea here is to have a collection that multiple threads can iterate over, execute...
Puzzle: For two strings A and B, we define the similarity of the strings to be the length of the longest prefix common to both strings. For example, the similarity of strings "abc" and "abd" is 2, while the similarity of strings "aaa" and "aaab" is 3. Calculate the sum of similarities of a string S with each o...
I'm writing a (nearly-)single-page app using Ruby on Rails 3.1 and Backbone.js. Thus, most of my controllers return rootless JSON, courtesy this setting as per the Backbone.js docs: ActiveRecord::Base.include_root_in_json = false So the returned JSON for an account, say, looks like this: { "created_at":"2011-12-27T...
Is this implementation of AES for Android safe? Is it 128 bit encryption? How can I strengthen this implementation? Please help me, all suggestions are welcome :) import java.security.NoSuchAlgorithmException; import javax.crypto.Cipher; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.IvParameterSp...
I have an MD5 hash string: _hash = '743a0e0c5c657d3295d347a1f0a66109' I want to write function that splits passed string to path in nginx cache format: print hash2path(_hash, [1, 2, 3]) # outputs '7/43/a0e/743a0e0c5c657d3295d347a1f0a66109' This is my variant: def hash2path(_hash, levels): hash_copy = _hash pa...
I have an increasing table which already has records of 50,000+. So in a combo box I have to load it, so that it shows which one is selected and its a main record which need to be selected and based on that it spread other relational records. But when I load it the whole web browser freeze. How do you handle it? My co...
I want to build a small newsletter like tool which sends mails in pre-defined timespans. First after registration, second 14 days later, third 7 days later etc. I came across for two database designs and those two queries: Create a separate table (dispatch) and put the next mails into it (can be done by cronjob): SELE...
I was searching for a way to get all active log4net logfiles (if any) at runtime without adding a reference to the project. This is the solution I came up with: private static IEnumerable<AbstractReportInformation> GetLog4NetLogfiles() { var type = Type.GetType("log4net.LogManager,log4net"); if(null == type) ...
I'm working on a game for iOS devices and this is the function we use to create server-loaded buildings. The server loading is in another function and everything works just fine, but I was wondering if this function could be prettier? This function runs every 60 seconds as we reload the whole base (with the buildings i...
In one of our project with 3 tier architecture (tightly coupled), there's a bad code smell and it doesn't follow the DRY principle. I want to refactor it with design possible design pattern. I don't want to write this project from scratch. Here's one of the class in BLL: namespace BAL { public class NotificationSett...
I have a unit test that needs to compare two arrays but it shouldn't care about the order of the arrays. I didn't see anything in the Test:Unit docs that provided this so I wrote my own. I really don't want to use this code if I don't have to (want to avoid Not Invented Here syndrome). If you can give me some feedback...
I decided to build my own fade-in fade-out function, since that is all I need on my page. Please comment on things I can make better. <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> </head> <body> <div> <span id="fade_in">Fade In</span> | <span id="fade_out">Fade Out</sp...
Puzzle Description Given \$N\$ numbers, \$N <= 10^5\$, count the total pairs of numbers \$(N_i, N_j)\$ that have a difference of \$K = N_i - N_j\$ where \$0 < K < 10^9\$. Input Format: 1st line contains \$N\$ and \$K\$ (integers). 2nd line contains \$N\$ numbers of the set. All the \$N\$ numbers are assured to be dis...
This started as a hacked-together tool to remove annoyances I was facing with experimenting with code on live remote servers, then getting that code into my development environment after experimenting. I thought others might be able to benefit from the tool, so I cleaned it up and released it as open source on GitHub. ...
I am optimizing the variable parser for my programming language, and also trying to make it more readable and concise (precedence: readable and concise > efficient). What is the best way to improve this code and make the best out of each line, and make it easier to understand for contributors? namespace pro_compiler { ...
I have a model with a number of complex/simple properties that has a corresponding strongly typed view, that calls EditorFor to a custom editor template view for the model. One of the form's requirements is to auto fill the form based on a choose of values from a database. Previously, I had the selectors on the selecti...
Puzzle Description: You are given 'n' strings w1, w2, ......, wn. Let Si denote the set of strings formed by considering all unique substrings of the string wi. A substring is defined as a contiguous sequence of one or more characters in the string. More information on substrings can be found here. Let 'S' = {S1 U S2 ...
This is for a page where it displays some social media information for that user. I would like to improve the following code that I posted below. It does the job perfectly, but I just feel like it could definitely be improved. I could easily leave it the way it is but I am trying to learn and that's why I would like ...
Edit - decl smokes dojo.declare - http://jsperf.com/dojo-declare-vs-decl The code has been updated a bit. decl now accepts object literals as well, although I still like "declaration functions" better. I'm looking for some feedback on an approach I've been taking to provide simple inheritance for my javascript code. ...
I have the following Student class: class Student { public $user_id; public $name; public function __construct($user_id) { $info = $this->studentInfo($user_id); $this->name = $info['name']; $this->is_instructor = $info['is_instructor']; $this->user_id = $info['id']; } ...
Background: I'm a member of my high school's robotics club (and in charge of the programming team). The robot is going to be written in C++, but I'm mostly a Python coder and want to make sure I don't have any fundamental gaps in my knowledge. In preparation for the start of the competition in just a few days, I've...
Some code im working with for a stock system , i have two ways to do this, looking for review on if any of them are correct and if so which one is better OO than the other public interface Order { public void processed(AllocationResponse response); } the two solutions i have in my head are public class Warehouse {...
I have applied some optimizations like storing only odd values and starting to mark off from square of the number. Can it be optimized further? bool * isPrime = new bool [n/2]; for (int i=0; i < n/2; ++i) isPrime [i] = true; cout<< 2 << "\n"; for (int i = 3; i < n; i += 2) { if (isPrime [i / 2]) { ...
Being new to Node.js, I'd like to know of a better way of implementing this: server = http.createServer( function(req, res) { if (req.url === '/') { fs.readFile('index.html', function(err, page) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write(page); res.end(); ...
This code performs 301 redirects based on the taxonomy terms associated with the node, as 301 redirects can adversely effect page load time. How could this be best optimized? <?php /** * Implementation of hook_init(). *calling this hook causes the code below to execute before the page is loaded */ ...
Below is a set of extensions that I use in unit tests. The basic idea is that when creating or modifying some sort of user output type of string, I want to eyeball the output to see that it makes sense, even though it might be 'correct' in a unit test sense. But when doing almost any other tests and certainly when reg...
I know that Facebook has an algorithm to filter out posts that may be irreverent, but I'm building a very simple yet functional algorithm to improve on it. It's getting complicated to maintain, and I want to know how to organize the code in one specific way, have patterns, use shortcuts etc... Please don't hesitate to ...
What is the best way to considerably decrease the size of the following code without sacrificing functionality, and to make it more readable, and well, make it look professional? class Compiler { public string Compile(TextReader src) { string rtn = SourceTemplate.Top; var preprocessor =...
I have a keyup function that expands an input field as text is added. There are a lot of fields where this code will be applied, what is the best way to write this for best performance? Here is a working demo: http://jsfiddle.net/J9Ner/ $('input.name','#bakery').live('keyup', function() { var el = $(this); var ...
I wrote a Hangman game to try out some of the new features in C++11. I'm pretty new to C++, and I would like some good advice on how I can improve this code (in terms of conventions, bad/good practices, ...): #include <iostream> #include <fstream> #include <vector> #include <string> #include <stdexcept> #include <rando...
I am attempting to optimize a piece of C code which aims to multiply a series of pairs of unsigned shorts and add the result. I am only concerned about the high 16 bits of the result, and I can guarantee that the sum of the multiples will fit in a 32-bit value. I initially coded this in C, and then rewrote it to use SS...
I was experimenting with lists, sets, and finally maps when I spotted a pattern in my code to make it recursive. Now I haven't used recursion much in the past or at work and I was very excited to have something that does recursion. I have this recursive method that takes in an Integer and returns a string representatio...
I decided to put together a quick project using jquery, the Kendo UI HTML 5 framework and JavaScript. I don't do much JavaScript development and I'd like some input on how to make this look less like a complete spaghetti hack, walking up and down DOM elements, trying to find the right event handler to hook onto. $(win...
I'm learning java, although because of work I didn't had much time to go to classes. We had a final work to do but since I'm more familiarised with python I'm not sure if I'm doing java correctly... I'm also a bit confused about attributes and constructors, I don't really understand the use of it. For this work we have...
I'm kinda worried that the way I did my animation intro is a bit too heavy and is not optimized. Please review and let me know your thoughts. $(document).ready(function() { introIconFirst(); function introIconFirst() { $('h2.ribbon').css({ 'marginTop': '+30px', 'opacity': '0' ...
On ASP.NET MVC, I try to write an async Controller action with the old asynchronous programming model (actually, it is the current one, new one is still a CTP). Here, I am trying to run 4 operations in parallel and it worked great. Here is the complete code: public class SampleController : AsyncController { publi...
First number indicates the number of points, followed by N points (x,y). Then the next number indicates Q num_queries, followed by Q queries: Reflect all points between point i and j both including along the X axis. This query is represented as "X i j" Reflect all points between point i and j both including alo...
I'm calling this function from my html (and in some cases from another function in my JavaScript). These type of switch statements are starting to litter my code. Is there a more elegant solution to these if statements? I wish I could pass a reference to the variables I want to modify. I'm finally asking the questi...
I would like to simplify to following function as much as possible: public string[] GetPowerSet(string input) { IEnumerable<IEnumerable<string>> seed = new List<IEnumerable<string>>() { Enumerable.Empty<string>() }; return input.Split(',').ToList().Aggregate(seed, (a, b) => a.Concat(a.Sel...