body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>I have the following function defined in a program that implements the 2048 game. I tried condensing the repeating part of the code into one loop containing +1 offset variables for the indices, which are either set to 0 or 1 depending on the direction passed into the function, but the outer and inner loop variables ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T14:30:55.083", "Id": "79606", "Score": "0", "body": "Shouldn't your `if` be more indented?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T15:00:04.500", "Id": "79616", "Score": "0", "body...
[ { "body": "<p>Iterating more smartly can simplify your loops.</p>\n\n<p>To start with, run this standalone example and see that the <code>izip(…)</code> expression produces useful pairs of coordinates:</p>\n\n<pre><code>from itertools import product, izip\nnRows, nColumns = 3, 5\nfor dest, src in izip(product(r...
{ "AcceptedAnswerId": "45621", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T14:23:52.777", "Id": "45613", "Score": "11", "Tags": [ "python", "game", "matrix" ], "Title": "Repetitive For Loops in 2048 Game" }
45613
<p>I've been working on a game prototype for a couple days and I think that code review would be really helpful. The basic idea of the game is that you are controlling some dwarves, and you dig up resources underground in order to build a tower above ground.</p> <p>I'm doing this in Sprite Kit, and initially I wanted...
[]
[ { "body": "<p>First thing I notice here is the lack of the proper <code>init</code> pattern:</p>\n<pre><code>-(id) initWithSize:(CGSize)size {\n self = [super init];\n if (self) {\n self.worldSize = size;\n [self createDwarves];\n [self createGameTower];\n }\n return self;\n}\n<...
{ "AcceptedAnswerId": "45657", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T14:31:18.433", "Id": "45615", "Score": "2", "Tags": [ "game", "objective-c", "ios" ], "Title": "Separating Game Logic from Rendering - Sprite Kit" }
45615
<p>I have created my first ping-pong game with JavaScript and Canvas. I will be glad if anybody can tell me how to optimize the code and functionality.</p> <p><a href="https://github.com/nikitalarionov/js-pong" rel="nofollow">https://github.com/nikitalarionov/js-pong</a></p> <p>First collision detection:</p> <pre><c...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T15:08:30.940", "Id": "79620", "Score": "1", "body": "I posted some code with problems, but it works, but not good :) It seems i have two problem (Collision Detection, Lazy Moving of left paddle)." }, { "ContentLicense": "CC ...
[ { "body": "<p>From a once-over,</p>\n\n<ul>\n<li>Short 1 letter variables are terrible ( except for <code>x</code> and <code>y</code> ), <code>b</code>, <code>p</code> and <code>W</code> are just terrible</li>\n<li>Also please spellcheck your variables: <code>padles</code> -> <code>paddles</code></li>\n<li><p>Y...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T14:42:45.023", "Id": "45618", "Score": "5", "Tags": [ "javascript", "performance", "game", "collision", "canvas" ], "Title": "Ping-pong game with JavaScript and Canvas" }
45618
<p>Like many ASP.NET developers, I use the Newtonsoft library to convert C# objects into JSON. Is this use of <code>Newtonsoft.Json.JsonConvert.SerializeObject</code> secure?</p> <p>Here is how I use it in a Razor view:</p> <pre><code>&lt;script type="text/javascript"&gt; var json = @Html.Raw(Newtonsoft.Json.Json...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T16:00:00.693", "Id": "79648", "Score": "0", "body": "I'm new here, brand new actually, and may not yet get the purpose of this Stack Exchange site. Would the person who down voted the question or someone in the know give me a clue a...
[ { "body": "<p>An opinion question, my answer is; sure ( if you can trust Newtonsoft to escape properly all data, since JSON is such a simple format, it should not be a problem ).</p>\n\n<p>Regardless,</p>\n\n<ul>\n<li><p><code>var json</code> &lt;- unfortunate name, the name should describe what data there is, ...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T15:37:29.660", "Id": "45623", "Score": "1", "Tags": [ "javascript", "asp.net", "security", "json" ], "Title": "Newtonsoft.Json.JsonConvert.SerializeObject" }
45623
<p>I have written a code for an application/website that I wanted to be structured similarly to MVC design pattern (but I think it's rather MVP based on comparison I read). This functions as a kind of intranet where users can log in, see some news, short info about them - all on one page (some of the content is static ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-02T15:32:33.770", "Id": "80369", "Score": "0", "body": "question, there are a lot of frameworks that does MVC - is there a reason why you are re-inventing the wheel so that we know more into how we could look at your code in a critical...
[ { "body": "<p>For now, here is what I have noticed. I'll come back when I get some time to take a better look.</p>\n\n<p>I'm seeing some repetition in that initial try statement too. It looks as though you can take</p>\n\n<pre><code>$method = filter_input(INPUT_POST, 'method', FILTER_SANITIZE_STRING);\n$class =...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T15:38:02.020", "Id": "45624", "Score": "2", "Tags": [ "php", "mvc" ], "Title": "Is this right structure for MVC / MVP application?" }
45624
<p>I know that there may be better ways of writing this do you think that this code is written well enough to be used in a real world application?</p> <pre><code> var pow = function ( base, power ) { var result = 1; if ( power &lt; 0 ) { return ( 1 / pow( base, -(power)) ); } for ( var i = 1...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T16:07:32.563", "Id": "79649", "Score": "3", "body": "[Math.pow()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) - it's built in (and roughly 5 times faster)" } ]
[ { "body": "<p>The code in the OP won't return a correct result for non-integer values of <code>power</code>: for example, <code>0.5</code> should return the square root of the number.</p>\n\n<p>Sometimes you want to use the <a href=\"http://en.wikipedia.org/wiki/Floating-point_unit\" rel=\"nofollow\">Floating P...
{ "AcceptedAnswerId": "45636", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T15:58:00.733", "Id": "45630", "Score": "5", "Tags": [ "javascript", "reinventing-the-wheel" ], "Title": "Power function in JavaScript" }
45630
<p>I am looking to speed up the exchange from vba to IE. The sendkeys works, but I was curious if there were a better way to do this?</p> <p>The site that it routes to is a form, but there is no submit button. The only way to pull the data is to tab to the next box or click somewhere on the screen. I was hoping, howev...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-04T23:01:39.100", "Id": "80924", "Score": "0", "body": "Hi, I've rolled back your edit. [Please avoid editing your question to include suggested changes from answers](http://meta.codereview.stackexchange.com/a/1483/23788)." } ]
[ { "body": "<p>Just reviewing what you've got here...</p>\n\n<h3>Indentation</h3>\n\n<p>The code would read much better with proper indentation:</p>\n\n<pre><code>Function FillInternetForm()\n Dim HWNDSrc As Long\n Dim ie As Object\n\n Set ie = CreateObject(\"InternetExplorer.Application\")\n HWNDSrc...
{ "AcceptedAnswerId": "46095", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T16:33:46.730", "Id": "45635", "Score": "8", "Tags": [ "vba" ], "Title": "Speed up processing between VBA and IE" }
45635
<p>I was asked this recently, and I couldn't figure out the best way. We are trying to replicate Google's search results where the search terms are bolded (using a b tag) in the results. </p> <pre><code>Input Terms Output The search is cool {sea} The &lt;b&gt;...
[]
[ { "body": "<p>I would go with Regex for this, with greedy matches so that nested results like your example above would only match the outer string.</p>\n\n<p>So with your example here:</p>\n\n<pre><code>Input Terms Output\nThe search is cool {sea, search} The &...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T16:56:27.667", "Id": "45638", "Score": "5", "Tags": [ "java", "strings" ], "Title": "Find and replace String with a substring result" }
45638
<p>This is a baseline tagger coed I have written. How can I optimize this code?</p> <pre><code>public class Tagger { private ArrayList&lt;List&gt; copyTagsList = new ArrayList&lt;List&gt;(); public Tagger(WordChecker tagsList){ for(int i =0; i&lt;tagsList.getCheckedTags().size();i++){ copyTagsList.add(i,tag...
[]
[ { "body": "<pre><code>private ArrayList&lt;List&gt; copyTagsList = new ArrayList&lt;List&gt;();\n</code></pre>\n\n<p>You should always use generic version (use raw type only if you have a good reason!)</p>\n\n<p>Same inside <code>extractTag</code> using generic version you will not need anymore <code>String</co...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T17:28:26.063", "Id": "45640", "Score": "4", "Tags": [ "java", "optimization" ], "Title": "Baseline tagger" }
45640
<p>I'm creating an app where the user will be able to create HTTP request matchers. So the <code>RequestMatchers</code> will match HTTP method, path, query parameters, etc., for incoming requests. </p> <p>Can someone look over this gist to see if you think I'm on the right track for making it very extensible? Currentl...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T18:51:29.497", "Id": "45644", "Score": "2", "Tags": [ "php", "http", "url" ], "Title": "Persistable specifications in symfony" }
45644
<p>For a school project I am tasked to decrypt DES passwords. I have sample code provided below and I want to know if this is the best method. Also should I code in error handling for the dictionary file or does the <code>while</code> condition take care of this?</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;c...
[]
[ { "body": "<p>You're keeping us in suspense — I'm dying to know which password matched!</p>\n\n<p>Many password crackers also test for common character substitutions, e.g. o → 0, i → 1, s → $.</p>\n\n<p>Other than that, the general technique seems sound.</p>\n\n<p>I do have a few general remarks, though.</p>\n\...
{ "AcceptedAnswerId": "45677", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T20:44:46.890", "Id": "45650", "Score": "7", "Tags": [ "c", "homework", "cryptography" ], "Title": "Dictionary brute force on DES encrypted passwords" }
45650
<p>Expected behavior of the code below:</p> <ul> <li>There will be one static <code>SessionManager</code> accessed by many threads.</li> <li>Multiple calls to <code>SessionManager.UseTheSession</code> for a given session ID must be processed on a first come first serve basis (similarly, calling <code>EndSession</code>...
[]
[ { "body": "<p>In <a href=\"https://codereview.stackexchange.com/a/44490/23788\">this answer</a> I explain in details why <em>one should not throw System.Exception</em>. You should be throwing <code>InvalidOperationException</code> in the case of the <em>astronomically unlikely situation</em>, and probably an <c...
{ "AcceptedAnswerId": "45662", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T21:55:06.357", "Id": "45655", "Score": "11", "Tags": [ "c#", "multithreading", "thread-safety", "locking", "concurrency" ], "Title": "Thread-safe session manager" }
45655
<p>Unfortunately I get 3 warnings at jslint. Could someone please help?</p> <p>I already tried a lot, but didn't get it yet.</p> <p>Here's a jsfiddle: <a href="http://jsfiddle.net/KYjF9/21/" rel="nofollow">http://jsfiddle.net/KYjF9/21/</a></p> <p>JSlint options:</p> <pre><code>/*jslint browser: true indent: 2 */ /*...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T22:50:51.780", "Id": "79707", "Score": "0", "body": "The code works! It's just not perfectly valid in jslint." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T22:51:13.167", "Id": "79708", "Sco...
[ { "body": "<p>I suppose you're talking about these 3 JSLint warnings:</p>\n<pre><code>Combine this with the previous 'var' statement.\n var interval = 300 - Math.random() * 100;\n\nCombine this with the previous 'var' statement.\n var interval = 3000;\n\nDo not use 'new' for side effects.\n new Typing(th...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T22:43:29.830", "Id": "45659", "Score": "4", "Tags": [ "javascript", "jquery" ], "Title": "jquery script for inserting and deleting text" }
45659
<p>In the code below, I take the number of square the user wants, then calculate the size of each square (so that they all fit in the container.)</p> <p>I then define <code>var square</code> as in the 3rd line of code. I find this string pasting technique very hard to read and error-prone. The general question is thus...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T00:33:46.690", "Id": "79718", "Score": "0", "body": "Where does `num_square` come in?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T00:39:50.177", "Id": "79719", "Score": "0", "body": "n...
[ { "body": "<p>As you have already stated passing an HTML string is not the best way to create a new DOM element. You can create a new one using plain Javascript, like this:</p>\n\n<pre><code>var newDiv = document.createElement('div');\n</code></pre>\n\n<p>and together with few changes to your code, function cou...
{ "AcceptedAnswerId": "45670", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-28T23:43:58.313", "Id": "45663", "Score": "1", "Tags": [ "javascript" ], "Title": "Javascript to change element property based on user input" }
45663
<p>In order to implement my own <code>Dictionary&lt;TKey, TValue&gt;</code> in VB6, I've implemented a <code>KeyValuePair</code> class, which can accomodate any type as its key, or value.</p> <p>This <code>KeyValuePair</code> class implements the <code>IComparable</code> and <code>IEquatable</code> interfaces which I'm...
[]
[ { "body": "<p>That has been said before in previous reviews, there's not really a gain in having a <code>Private Type</code> that lets you define a <code>Private this As tKeyValuePair</code>, which forces you to use <code>this.</code> to access what would otherwise be private fields.</p>\n\n<p>Actually there <e...
{ "AcceptedAnswerId": "46127", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T00:00:19.543", "Id": "45664", "Score": "4", "Tags": [ "vba", "vb6" ], "Title": "KeyValuePair implementation" }
45664
<p>This class encapsulates a <code>List&lt;KeyValuePair&gt;</code> (see <code>List&lt;T&gt;</code> implementation <a href="https://codereview.stackexchange.com/questions/32618/listt-implementation-for-vb6-vba">here</a>, and <code>KeyValuePair</code> implementation <a href="https://codereview.stackexchange.com/questions...
[]
[ { "body": "<p>Although <code>CallByName</code> doesn't seem to have a return value (from the parameter tooltip), it does. This means if <code>IsSafeKeyXxxxxx</code> methods were <code>Public</code> you could use <code>CallByName</code> instead of the <code>Select..Case</code> block.</p>\n\n<p>However exposing a...
{ "AcceptedAnswerId": "46134", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T00:18:56.587", "Id": "45666", "Score": "8", "Tags": [ "hash-map", "vb6" ], "Title": "Dictionary<TKey, TValue> Implementation" }
45666
<p>I need to split up a sequence into equal segments of a given size (yes, the last one may be shorter), and I'm trying to find an efficient and idiomatic way to do it.</p> <p>I have two versions of the function; <code>segment</code> is the F# version of an awkward and probably quite inefficient old C# extension metho...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T01:48:27.807", "Id": "79729", "Score": "1", "body": "link from SO for the same problem: https://stackoverflow.com/questions/3999584/f-split-sequence-into-sub-lists-on-every-nth-element (The accepted answer is from a MS F# dev)" } ...
[ { "body": "<p>Functional-first style tends to prefer immutability over mutability, so the fact that you're using <code>ref</code> can sometimes signify that the code could be more idiomatic.</p>\n\n<p><strong>Recursive Solution</strong></p>\n\n<p>But how do you keep track of the state of your program without mu...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T00:26:18.620", "Id": "45668", "Score": "7", "Tags": [ "f#" ], "Title": "Splitting a sequence into equal segments" }
45668
<p>I'm writing a jQuery plugin.</p> <p>I'm allowing the user to pass options (optionally-- argument 2 to extend) but I also require some defaults (argument 1), and some things user is not allowed to modify (argument 3). </p> <p>I follow the global override pattern recommended by most jQuery plugins. But I'm running...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T20:58:05.587", "Id": "79800", "Score": "1", "body": "Could you provide a little more context? From the above it's hard to tell if there are improvements to be made or not" }, { "ContentLicense": "CC BY-SA 3.0", "Creation...
[ { "body": "<p>Not a lot ( of context ) to review;</p>\n\n<ul>\n<li><p><code>this.options = $.extend(true, $.fn.myPlugin.Defaults, options);</code> &lt;- This will modify the defaults of the plugin, if you did not want that, then you should do</p>\n\n<pre><code>this.options = $.extend(true, {}, $.fn.myPlugin.Def...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T05:35:50.167", "Id": "45674", "Score": "3", "Tags": [ "javascript", "jquery", "plugin" ], "Title": "JavaScript jQuery plugin options. Defaults, User Options, and immutable setting...
45674
<p>I've tried to make a portable way of ensuring endian-specific code gets generated at compile time using C++11, however I only have a computer with Windows on it to test at the moment. Because of this, I'm a bit limited in the amount of places where I can test my code. Also, would anyone be able to offer some best-pr...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T17:56:11.433", "Id": "79783", "Score": "0", "body": "Or `#include <boost/predef/detail/endian_compat.h>` and then test for `BOOST_LITTLE_ENDIAN` or `BOOST_BIG_ENDIAN` or `BOOST_PDP_ENDIAN`" }, { "ContentLicense": "CC BY-SA ...
[ { "body": "<p>Just a couple points:</p>\n\n<ol>\n<li><p>Endian-ness is not generally based on the Operating System but on the processor. For example, Intel x86 processors are little-endian regardless of it running Windows or Linux.</p></li>\n<li><p>Your code will always return <code>HL_LITTLE_ENDIAN</code>. Wh...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T06:34:30.500", "Id": "45675", "Score": "4", "Tags": [ "c++", "c++11", "integer", "portability" ], "Title": "Checking endianness at compile-time" }
45675
<p>Given a directed connected graphs, find all paths from source to destination.</p> <p>Looking for code review, optimizations and best practices. Also need help figuring out complexity, which in my best attempt is O(E!), where E is the number of edges. </p> <pre><code>class GraphFindAllPaths&lt;T&gt; implements Iter...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T15:46:19.507", "Id": "79777", "Score": "2", "body": "You should probably specify if it is assumed that there are no cycles. It is not a small detail." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T1...
[ { "body": "<p>This is really an interesting problem. First of all I want to mention that IMHO there is no polynomial solution to this task, because it is not an optimization problem. The required result is not max/min of something but an enumeration of all possible paths. I think that all possible paths may res...
{ "AcceptedAnswerId": "45690", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T08:03:01.657", "Id": "45678", "Score": "22", "Tags": [ "java", "algorithm", "graph", "complexity" ], "Title": "Find all paths from source to destination" }
45678
<p>With a positive outlook, I posted <a href="https://codegolf.stackexchange.com/questions/24904/how-many-squares-can-you-see">this challenge</a> at <a href="https://codegolf.stackexchange.com/">Programming Puzzles &amp; Code Golf</a>. I tried to come up with my own solution to the challenge which is as follows:</p> ...
[]
[ { "body": "<ol>\n<li><p>A great comment from <a href=\"https://codereview.stackexchange.com/a/19459/7076\"><em>@tb-</em>'s answer</a>:</p>\n\n<blockquote>\n <p>Do not extend <code>JPanel</code>, instead have a private <code>JPanel</code> \n attribute and deal with it (Encapsulation). \n There is no need to g...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T08:35:34.323", "Id": "45681", "Score": "4", "Tags": [ "java", "multithreading", "swing" ], "Title": "How many squares can you see?" }
45681
<p>I have tried to implement a Least Recently Used cache with only C++ STL containers. The main thing that I keep asking my self the static variable called <code>garbage_val</code>. Is it a good practice to have such a <code>static</code> variable just for garbage values? </p> <pre><code>template&lt;typename Key, type...
[]
[ { "body": "<blockquote>\n <p>Is it a good practice to have such a static variable just for garbage values?</p>\n</blockquote>\n\n<p>Maybe not:</p>\n\n<ul>\n<li><code>garbage_val</code> is a <code>Value</code>, so if you return it, then the caller doesn't know whether the <code>get</code> succeeded.</li>\n<li>I...
{ "AcceptedAnswerId": "45703", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T09:19:22.720", "Id": "45682", "Score": "2", "Tags": [ "c++", "c++11", "cache", "stl" ], "Title": "LRU Cache with a static variable for garbage value" }
45682
<p>Functionality that overwrite standard error message with trace to user friendly message with error number stored in DB.</p> <p>Not yet completed some stuff with trx...</p> <p>Please review this.</p> <p><strong>DB table:</strong></p> <pre><code>CREATE TABLE stored_error_msg ( id number PRIMARY KEY ,msg VARCHAR2...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T10:13:01.477", "Id": "79745", "Score": "5", "body": "Welcome to Code Review! To make life easier for reviewers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of d...
[ { "body": "<p><strong>Proprietary indentation convention</strong><br>\nFor some reason the first line in every method in your code is blank. This might be consistent, but since I haven't seen it anywhere else, I find it breaks the read flow, and makes your code less readable.</p>\n\n<p><strong>Use of deprecated...
{ "AcceptedAnswerId": "45687", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T09:59:52.233", "Id": "45685", "Score": "5", "Tags": [ "java", "exception-handling", "logging" ], "Title": "StoredErrorWriter" }
45685
<p>Below is a full working code example of code which is used to compute stats on two class vectors (partitions). </p> <p>There are two functions:</p> <ul> <li><code>pairwise_indication</code> and </li> <li><code>to_clust_set</code>. </li> </ul> <p>The first one is the function in question and the second is just for...
[]
[ { "body": "<p>If I understood what you want to do, this would be a more direct way to compute the same result. At least for the test cases provided, the result is indeed the same.</p>\n\n<pre><code>def pairwise_indication(part1, part2):\n if len(part1) != len(part2):\n raise ValueError('Partition shap...
{ "AcceptedAnswerId": "45708", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T10:17:23.133", "Id": "45686", "Score": "8", "Tags": [ "python", "algorithm", "performance", "combinatorics" ], "Title": "Compute stats on two class vectors" }
45686
<p>I implemented an unordered_set like container for storing small sets of unsigned integers. It uses a trivial hash table for lookups and an unordered array for quickly iterating over small sets.</p> <p>I'm looking for suggestions on best practices and correctness.</p> <pre><code>#pragma once #include &lt;array&gt; ...
[]
[ { "body": "<p>You should learn about <a href=\"http://en.cppreference.com/w/cpp/utility/bitset\" rel=\"nofollow\"><code>std::bitset</code></a>.</p>\n\n<p>It has almost everything you wants already with far less data storage. Encapsulate it inside your class to keep track of <code>min</code>, <code>max</code> an...
{ "AcceptedAnswerId": "45813", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T11:49:34.533", "Id": "45689", "Score": "7", "Tags": [ "c++", "c++11", "set" ], "Title": "Container for Sets of Integers" }
45689
<p>I looked at a search filter code code and edited it to catered to my functional needs. I understood most of the JavaScript except the <strong>extend</strong> method bit. Can someone explain that? Also, is this the best way to create such a filter? Please let me know of any ways to improve the code.</p> <pre><code...
[]
[ { "body": "<p>The <a href=\"http://api.jquery.com/jquery.extend/\" rel=\"nofollow\">extend</a> method is being applied to <code>jQuery.expr</code> which is the set of selectors <code>jQuery</code> will apply when selecting elements (<a href=\"http://james.padolsey.com/javascript/extending-jquerys-selector-capab...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T14:07:04.537", "Id": "45693", "Score": "3", "Tags": [ "javascript", "jquery", "search" ], "Title": "Search filter list using jQuery" }
45693
<p>The options for the 'cat' command are as follows:</p> <blockquote> <pre class="lang-none prettyprint-override"><code> -b Number the non-blank output lines, starting at 1. -e Display non-printing characters (see the -v option), and display a dollar sign (`$') at the end of each line. -n ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T15:45:48.003", "Id": "79776", "Score": "2", "body": "You seem to be missing some code in `main()`, as well as a level of indentation." } ]
[ { "body": "<p>You're initializing but not using local variables like <code>bflag</code>.</p>\n\n<p>Is the user allowed to specify more than one option? <a href=\"http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob_plain;f=src/cat.c;hb=HEAD\" rel=\"nofollow\">Source code for GNU's cat found here</a> says ...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T15:20:45.797", "Id": "45696", "Score": "5", "Tags": [ "c", "unix" ], "Title": "Implementing the 'cat' command" }
45696
<p>I have a link (avatar)<code>#qam-account-toggle</code> and <code>div.qam-account-items</code>, the div containing user account links. I am toggling div on avatar click as well as click anywhere but <code>div.qam-account-items</code></p> <p>Here is my code. How can I optimize this better?</p> <pre><code>$('#qam-acc...
[]
[ { "body": "<p>I'd suggest wrapping the code in a function, so it's all in one place and can share variables. Then there's no need to find and re-find the same elements in each event handler.</p>\n\n<p>Also, you're doing some extra filtering by class name and such which is unnecessary. E.g. <code>.hide()</code> ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T16:59:09.020", "Id": "45698", "Score": "6", "Tags": [ "javascript", "jquery" ], "Title": "Optimizing an avatar toggle" }
45698
<p>Got this question in a test.</p> <blockquote> <p>Display the following number pattern using Java.</p> <p>User inputs number of rows. For example 3</p> <pre><code>1112 3222 3334 </code></pre> <p>For 5</p> <pre><code>111112 322222 333334 544444 555556 </code></pre> <p>and so on.</p> </blockquote> ...
[]
[ { "body": "<p>Since all you've been asked is to display output, a single simple nesting of two for loops without arrays should work just fine. Note that in all cases, you know in advance prior to performing a loop how many times the loop will iterate, and in this situation a for loop is cleaner than a while loo...
{ "AcceptedAnswerId": "45712", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T18:16:09.247", "Id": "45701", "Score": "7", "Tags": [ "java" ], "Title": "Number pattern problem using Java" }
45701
<p>I would like to display this data, callable at any time, but I'm not sure if this is the best practice to do so. </p> <pre><code>countries = [ dict(Name = "China", Population = "1,363,560,000"), dict(Name = "India", Population = "1,242,070,000"), dict(Name = "United States", Population = "317,768,000"), ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-29T21:41:46.943", "Id": "85220", "Score": "0", "body": "And what, exactly, does this question have to do with code review? **Nothing!** Is our new policy that anything goes as long as it is easy to answer and tangentially includes the ...
[ { "body": "<p>To format the data nicely for printing you can use the <code>ljust</code> method:</p>\n\n<pre><code>print \"Country\".ljust(15),\"Population\"\nfor country in countries:\n print country[\"Name\"].ljust(15), country[\"Population\"]\n</code></pre>\n", "comments": [ { "ContentLic...
{ "AcceptedAnswerId": "45721", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T19:30:38.460", "Id": "45705", "Score": "5", "Tags": [ "python", "beginner", "python-2.x", "formatting" ], "Title": "Best way to display big data" }
45705
<blockquote> <p><strong>Question</strong>: </p> <p>One of Scotland Yard’s most wanted criminal (Mister X) is on the run and needs to reach a certain destination safely. There are three modes of transport available for him - By air, by train or by cab. With air travel, he can go from station i to station i...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T19:48:55.100", "Id": "79798", "Score": "1", "body": "You should only change an edit for improvement of formatting only if any meaning in your question was lost. In this case, there wasn't any information lost, so I rolled back the ...
[ { "body": "<p>Although this is not related to optimization, it looks like you could improve some of the ways you use loops. If you're using a counter, chances are you should use a <code>for</code> loop:</p>\n\n<pre><code>for (int i = number; i &gt; 0; i--) { /*...*/ }\n</code></pre>\n\n<p>This works best if th...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T19:34:41.253", "Id": "45706", "Score": "6", "Tags": [ "java", "optimization", "complexity" ], "Title": "Determine total number of ways of reaching a destination" }
45706
<p>I'm not much of a jQuery coder (more of a PHP coder), except to call a few get values out of class and id and Ajax calls. However, I need to make a checkout system work and one thing I would like to do is to put a loading wait while I send a form through Ajax. When it's finished, it would redirect the user.</p> <...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T03:09:12.647", "Id": "79828", "Score": "0", "body": "Does this code actually work? As far as I can tell, you hide (fade out) the `body` element, which hides _everything_. It doesn't matter that you call `.show()` on something later:...
[ { "body": "<p>Let's go through it one section at a time.</p>\n\n<pre><code>jQuery.fn.center = function () {\n this.css(\"position\",\"absolute\");\n this.css(\"top\", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + \"px\");\n this.css(\"left\", ( $(window).wid...
{ "AcceptedAnswerId": "45725", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T00:17:53.120", "Id": "45717", "Score": "4", "Tags": [ "javascript", "jquery", "html", "css" ], "Title": "Fading and Loader jQuery Improvement" }
45717
<p>I'm doing my homework and it says to write a test program that prompts the user to enter ten double values, invokes this method, and displays the average value.</p> <p>I was able to get this program working with an overloaded method... but I'm curious to hear your feedback on where I can improve and what I'm not un...
[]
[ { "body": "<p>You wrote the <code>average</code> method but you're not calling it.</p>\n\n<p>The <code>average</code> method need not be overloaded because the problem doesn't ask for a version of it which works with <code>int</code> arrays (so you can delete the version which works with <code>int</code> arrays...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T06:35:33.707", "Id": "45718", "Score": "6", "Tags": [ "java", "beginner", "homework" ], "Title": "Pass an array of numbers into a method that's overloaded" }
45718
<p>The code here will be directly pasted from <a href="https://github.com/fge/largetext" rel="nofollow noreferrer">this project</a>. Quick summary: it is related to a <a href="https://stackoverflow.com/q/22017480/1093528">Stack Overflow question</a>.</p> <p>So, basically, all the code below aims to implement <code>Cha...
[]
[ { "body": "<ol>\n<li><p><code>TextRandge</code> could be declared inside the loop and could be <code>final</code>: </p>\n\n<blockquote>\n<pre><code>TextRange range;\n\nwhile (byteOffset &lt; fileSize) {\n</code></pre>\n</blockquote>\n\n<p>The same is true for <code>waiter</code> here:</p>\n\n<blockquote>\n<pre>...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T02:32:22.197", "Id": "45724", "Score": "2", "Tags": [ "java", "thread-safety", "concurrency", "guava" ], "Title": "Decoding big text input: potential concurrency bugs?" }
45724
<p>Solved the ford-fulkerson algorithm, which is too vast to explain it comprehensively here. Check <a href="http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm">Wikipedia for Ford-Fulkerson</a> and <a href="https://www.youtube.com/watch?v=_yOSku77w0o">Princeton lecture on Ford-Fulkerson</a>.</p> <p>Looking...
[]
[ { "body": "<p>Some small remarks:</p>\n\n<ul>\n<li>I would change the <code>NullPointerException</code> to <code>IllegalArgumentException</code> when you check for <code>null</code> in the arguments of the method.</li>\n<li>I would add an <code>addNodes(T ...)</code> convenience method.</li>\n<li>addNode(T node...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T06:08:12.347", "Id": "45729", "Score": "6", "Tags": [ "java", "algorithm", "graph" ], "Title": "Ford-Fulkerson algorithm" }
45729
<p>I have a function <code>initialize_path_statistics()</code>. I have used openMP to make it parallel. I am not sure where certain lines such as</p> <pre><code>float length_enclosed = Nodes::get_length_enclosed(i); </code></pre> <p>need additional <code>pragma</code> like <code>#pragma omp atomic</code>. </p> <pre>...
[]
[ { "body": "<p>The code seems thread-safe to me. All operations are either done with local variables or with data addressed via the loop index, so data races are seemingly absent. Thus, no additional protection like <code>#pragma omp atomic</code> is necessary.</p>\n\n<p>I do not think you can make it \"more par...
{ "AcceptedAnswerId": "45758", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T06:40:33.880", "Id": "45731", "Score": "4", "Tags": [ "c++", "beginner", "thread-safety", "vectors", "openmp" ], "Title": "OpenMP loop parallel for loop with function c...
45731
<p>Task:</p> <blockquote> <p>Given a dictionary of words, and a set of characters, judge if all the characters can form the words from the dictionary, without any characters left. For example, given the dictionary {hello, world, is, my, first, program}, if the characters set is "iiifrssst", you should retur...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T07:06:52.557", "Id": "79851", "Score": "1", "body": "My initial impression is that this sounds like a [Set Cover](http://en.wikipedia.org/wiki/Set_cover_problem) problem, which would be NP-complete." } ]
[ { "body": "<h3>Replace <code>prune_words</code> with a <a href=\"http://docs.python.org/2.7/library/functions.html#filter\" rel=\"nofollow\">filter</a>.</h3>\n\n<ul>\n<li>Replace <code>words = prune_words(words)</code> with <code>words = filter(valid_word, words)</code>.</li>\n<li>You can now remove <code>prune...
{ "AcceptedAnswerId": "45855", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T06:45:54.247", "Id": "45733", "Score": "9", "Tags": [ "python", "interview-questions", "python-2.x" ], "Title": "Use up all characters to form words" }
45733
<p>I've been trying to create a calculator to find mass using any and all known equations. The program will also return the steps used to find mass so the user can 'check their work' on physics assignments.</p> <p>My biggest problem so far (and was solved by much copy-pasta) is the equations themselves. I'd like to b...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T08:01:56.627", "Id": "79852", "Score": "2", "body": "I don't think you can blindly apply Physics formulas like that. The appropriate formula to choose depends entirely on context. For example, there are [many processes](http://en.wi...
[ { "body": "<p>I’m not going to have a go at the big problem of “equation variable” (which might be better suited to Stack Overflow), but I do have some comments on your existing code:</p>\n\n<ul>\n<li><p>Python uses the operator <code>**</code> for powers; i.e., <code>a ** b</code> means “a to the power b”. You...
{ "AcceptedAnswerId": "45742", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T07:15:04.903", "Id": "45734", "Score": "2", "Tags": [ "python", "python-3.x", "physics" ], "Title": "Calculator for finding mass" }
45734
<p><a href="http://www.open-mpi.org/" rel="nofollow">Open MPI</a> is a BSD-licensed Message Passing Interface library for building distributed applications to run on clusters. It is the result of merging MPI implementations FT-MPI, LA-MPI, and LAM/MPI with contributions from PACX-MPI.</p> <p>Not to be confused with <...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T07:23:14.967", "Id": "45735", "Score": "0", "Tags": null, "Title": null }
45735
Open MPI is a Message Passing Interface library for building distributed applications to run on clusters. (Not to be confused with OpenMP.)
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T07:23:14.967", "Id": "45736", "Score": "0", "Tags": null, "Title": null }
45736
<p><a href="http://en.wikipedia.org/wiki/Message_Passing_Interface" rel="nofollow">Message Passing Interface</a> is a standardized and portable system for building distributed applications to run on parallel computing systems. It consists of a communications protocol and multiple independent libraries that implement s...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T07:34:56.667", "Id": "45737", "Score": "0", "Tags": null, "Title": null }
45737
Message Passing Interface (MPI) is a standardized and portable system for building distributed applications to run on parallel computing systems.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T07:34:56.667", "Id": "45738", "Score": "0", "Tags": null, "Title": null }
45738
<p><a href="http://en.wikipedia.org/wiki/OpenMP" rel="nofollow">OpenMP</a> is an API that supports multi-platform shared memory multiprocessing programming in <a href="/questions/tagged/c" class="post-tag" title="show questions tagged &#39;c&#39;" rel="tag">c</a>, <a href="/questions/tagged/c%2b%2b" class="post-tag" ti...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T07:43:16.793", "Id": "45739", "Score": "0", "Tags": null, "Title": null }
45739
OpenMP is an API that supports shared memory multiprocessing in C, C++, and Fortran.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T07:43:16.793", "Id": "45740", "Score": "0", "Tags": null, "Title": null }
45740
<p>I am not sure about the place where flush should be used (if it is used at all here).</p> <pre><code>int Window_Shift :: get_window_shift() { int window_shift = INFINITE; #pragma omp parallel for for(unsigned int node_id = 0;node_id&lt; no_of_valid_nodes ;node_id++) { //for all the nod...
[]
[ { "body": "<ul>\n<li><p>With just one function provided and some return information, it's hard to tell everything about it. Since this is a member function with \"get\" in its name (meaning it's an accessor), and only local variables are being modified (no data members), then this should likely be a <code>cons...
{ "AcceptedAnswerId": "49592", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T09:10:09.757", "Id": "45743", "Score": "6", "Tags": [ "c++", "beginner", "thread-safety", "openmp" ], "Title": "OpenMP parallel for critical section and use of flush" }
45743
<p>How can I test this C program for "efficiency"? The most interesting usage is that it returns negative output for large enough input, otherwise the behavior is about expected. Will you suggest how to improve the code, both the ui used in main that should be both efficient and preferably platform-indepedent and not u...
[]
[ { "body": "<h1>Things you could improve</h1>\n\n<h3>Efficiency</h3>\n\n<ul>\n<li><p>As @rolfl stated, you want to use a <a href=\"https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes\" rel=\"nofollow noreferrer\">Sieve of Eratosthenes</a> (+1 to that answer).</p>\n\n<p><img src=\"https://i.stack.imgur.com/uMQ5O....
{ "AcceptedAnswerId": "45749", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T09:11:44.080", "Id": "45744", "Score": "23", "Tags": [ "optimization", "c", "performance", "beginner", "primes" ], "Title": "First prime number larger than given intege...
45744
<p>This is self-explaining example with usage in doctests (it's not that fast as implementation with dict key-lookups, but it's a lot more readable, and don't require callables and lambdas):</p> <pre><code>class Switch(object): """ Switch, simple implementation of switch statement for Python, eg: &gt;&gt;...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-03T05:05:49.230", "Id": "80488", "Score": "0", "body": "If you want to preserve the `case/break` syntax of C, here is an interesting implementation: http://code.activestate.com/recipes/410692/." } ]
[ { "body": "<p>I like your trick to create this syntactic sugar. The implementation is also pretty good, as are the doctests.</p>\n\n<h3>Feature suggestions</h3>\n\n<p>I think it would be nice if a <code>case()</code> could test for multiple values. A <code>case('jack', 'queen', 'king')</code> should match if...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T12:46:24.850", "Id": "45747", "Score": "7", "Tags": [ "python" ], "Title": "Switch like context manager in Python" }
45747
<p>I am just starting out in my Clojure journey and I wonder if anybody can point out my beginners mistakes in my function below that simply reverses a list. I know that there is already a reverse function so this is purely for learning.</p> <pre><code>(defn rev ([l] (if (= (count l) 1) l (rev '() l))) ([l ori...
[]
[ { "body": "<p>Sometimes using arity overloading like you've done is the best way to write a function. </p>\n\n<p>I tried to rewrite your function using destructuring, like this:</p>\n\n<pre><code>(defn rev [[x &amp; more]]\n (if more\n ...\n</code></pre>\n\n<p>however, it doesn't really work because you nee...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T13:09:13.733", "Id": "45748", "Score": "3", "Tags": [ "beginner", "clojure" ], "Title": "Basic reverse function" }
45748
<p>I had written a solution for <a href="http://projecteuler.net/problem=18" rel="nofollow">Project Euler problem 18</a> in Python 3. It is good in its efficiency but the problem is the readability and I think reuse. </p> <p>The algorithm used is that at every iteration the maximum for all numbers in a row is calculat...
[]
[ { "body": "<p>The purpose of your program was unclear to me before reading the problem description. I could understand the logic flow, but I had no idea what answer it was seeking.</p>\n\n<ul>\n<li><p>The name <code>matrix</code> implies a rectangle. While <code>triangle</code> or <code>pyramid</code> are more ...
{ "AcceptedAnswerId": "45767", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T13:59:44.023", "Id": "45750", "Score": "5", "Tags": [ "python", "programming-challenge", "python-3.x" ], "Title": "Increasing readability of maximum path sum algorithm" }
45750
<p>I created a singleton class for managing sound effects on Android. This class will only be instanced and loaded once at the beginning, and each activity will use the loaded songs.</p> <p>I don't know either if this is the good approach for Singleton, nor if this is the good way to play sounds in Android. This is wo...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T21:17:31.530", "Id": "80066", "Score": "0", "body": "Here is the corrected version : https://gist.github.com/FR073N/9902559" } ]
[ { "body": "<p>Let me start by saying I have very limited Android experience. That said, I did look into the <code>SoundPool</code> class a bit and have some questions/comments about your implementation:</p>\n\n<ol>\n<li>If you aren't already aware of some of the reasons why people consider Singletons an anti-pa...
{ "AcceptedAnswerId": "45774", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T14:31:28.543", "Id": "45751", "Score": "10", "Tags": [ "java", "android", "singleton", "audio" ], "Title": "Sound manager for Android" }
45751
<p>I am going on with refactoring my code base while migrating from Python 2 to Python 3. I am using generators to make reusable components this time as I am more comfortable with them this time then last time. But there are times when I am stuck at their use. Like below example. These two are essentially same with one...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T15:27:46.297", "Id": "79874", "Score": "0", "body": "I don't use Python much, but why wouldn't an optional argument work here? Pseudocode: `while(!optionalArgumentExists || optionalArgumentCondition)`." }, { "ContentLicense"...
[ { "body": "<p>Something like this should work:</p>\n\n<pre><code>def sequence(start, end = None):\n loopIndefinitely = end is None \n\n curr = start \n while loopIndefinitely or curr &lt;= end:\n yield curr\n curr += 1\n\n## Prints: 1 2 3 4 5 6 7 8 9 10\nfor i in sequence(1, 10):\n ...
{ "AcceptedAnswerId": "45765", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T14:55:04.677", "Id": "45752", "Score": "8", "Tags": [ "python", "python-3.x", "generator" ], "Title": "Wrapping my head around generators" }
45752
<p>I implemented the <code>atoi()</code> function! Here is my code: </p> <pre><code>int my_atoi(char* pointer) { int result = 0; char* pointer1; multiplier = 1; char sign = 1; if(*pointer == '-') sign =- 1; pointer1 = pointer; while(*pointer != '\0') { if(*pointer &gt;=...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T15:59:04.487", "Id": "79877", "Score": "0", "body": "how is the problem \"string to int: 232-19\" connected with the code at hand?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T16:08:05.327", "I...
[ { "body": "<h1>Things you could improve</h1>\n\n<h3>Variables/Initialization</h3>\n\n<ul>\n<li><p>Where do you declare <code>multiplier</code>? I assume that since it is not declared within the method, it is declared as a global variable. Try to avoid global variables.</p>\n\n<p>The problem with global variab...
{ "AcceptedAnswerId": "45769", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T15:25:02.740", "Id": "45755", "Score": "12", "Tags": [ "c", "parsing", "reinventing-the-wheel", "integer" ], "Title": "Implementation of atoi()" }
45755
<blockquote> <p>Find the element the occurs more than \$\dfrac{n}{2}\$ times in an input array, where \$n\$ is input array length.</p> </blockquote> <p>I'm looking for code review, optimizations and best practices.</p> <pre><code> public final class VotingAlgorithm { // non-instantiable. private VotingAlg...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T17:42:41.000", "Id": "79889", "Score": "0", "body": "Use the test input `int[] a9 = {1, 2, 2, 1, 3, 3, 1, 4, 4, 1, 5, 5, 5};` ... what's the result?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T18:...
[ { "body": "<p>The JavaDoc and the method names do not agree.</p>\n\n<p>The method name <code>maxElement</code> implies the method will get either:</p>\n\n<ol>\n<li><em>the element that occurs most frequenly</em></li>\n<li><em>the element with the largest value</em></li>\n</ol>\n\n<p>This function may, or may no...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T17:27:57.990", "Id": "45766", "Score": "5", "Tags": [ "java", "algorithm", "array" ], "Title": "Voting Algorithm" }
45766
<p>Is this the right way? Any comments on the hash functions? If asked a question like this in an interview, do I need to follow all OOP concepts(because I am using Java)? Like encapsulating the variables by writing getter and setter functions? </p> <pre><code>import java.lang.reflect.Array; import java.util.ArrayList...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T10:07:22.900", "Id": "79950", "Score": "1", "body": "@Ocelot20 Whitespace is subject to review, just like any other aspect of the code, so it should not be edited in the question. I've rolled back to Rev 1." } ]
[ { "body": "<p>No, this is not the correct way to implement a hash map in Java, and especially not to implement the <code>java.util.Map</code> interface.</p>\n\n<ul>\n<li><p>You aren't even explicitly implementing the <code>Map</code> interface.</p></li>\n<li><p>What is <code>(Map[]) Array.newInstance(Map.class,...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T19:27:07.553", "Id": "45770", "Score": "10", "Tags": [ "java", "hash-map" ], "Title": "Is this the right way to implement a hashmap?" }
45770
<p>I put together this Ruby script (1.9.3) to load data into MySQL from many .xlsx files that contain data entered by people. These files typically have many illegal characters and it has been difficult to handle the different errors. I have tried multiple rescue and character escaping approaches but now this method is...
[]
[ { "body": "<p>For starters, I'd break the script up into many more methods. If nothing else it'll avoid the \"pyramid code\" (all that nested indentation) you've got going on. But it should also make the code easier to understand, maintain and extend.</p>\n\n<p>I'd also, as an overall approach, favor writing a ...
{ "AcceptedAnswerId": "45778", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T20:24:54.100", "Id": "45773", "Score": "5", "Tags": [ "ruby", "mysql", "file", "excel" ], "Title": "Ruby script to load .xlsx files into a MySQL database" }
45773
<p>My goal is to make File_Path_Handler constructor the only thing a user can access. Oh, is it too coupled? but the main question is: <strong>is File_Path_Handler the only accessible part of this package?</strong></p> <p>The handler: </p> <pre><code>package file_path_handler; //| File_Path_Handler //| - a compon...
[]
[ { "body": "<pre><code>package file_path_handler;\n</code></pre>\n\n<p>Package names should be in the format <code>tld.organization.application.package</code>. For example like this:</p>\n\n<pre><code>package com.company.application.package;\npackage com.github.username.application;\npackage com.gmail.username.a...
{ "AcceptedAnswerId": "45905", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T21:58:48.057", "Id": "45777", "Score": "4", "Tags": [ "java", "swing" ], "Title": "Did I properly encapsulate this package?" }
45777
<blockquote> <p><strong>Task:</strong></p> <p>Given <code>comma_separated.txt</code> file with string:</p> <blockquote> <pre><code>1,2,3,4,5,6,7,8,9,10,11,12...,n </code></pre> </blockquote> <p>Calculate the average value.</p> <p><strong>For example:</strong> 1,2,3 should be equal 2 (float) as r...
[]
[ { "body": "<h1>Things you can improve</h1>\n\n<h3>Variables/Initialization</h3>\n\n<ul>\n<li><p>Floating-point math is challenging in surprising places. It's easy to write down a reasonable algorithm that introduces 0.01% error on every step, which over 1,000 iteration turns the results into complete slop. Yo...
{ "AcceptedAnswerId": "45791", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T22:15:22.657", "Id": "45779", "Score": "11", "Tags": [ "beginner", "c", "csv" ], "Title": "Averaging numbers from a file, obeying Single Responsibility Principle" }
45779
<p>System I'm building has Users and Articles. Users can upvote/downvote Articles and cancel their votes if they want to. Each vote changes article's score. Score equals to sum of all vote values together.</p> <p>So I created three models: User, Article, ArticleVote. Even though the most natural way for me would be to...
[]
[ { "body": "<p>Rails just isn't taking chances, so when you call <code>vote.article</code> it's performing a new DB query, and thus creating a new instance rather than grabbing a cache. And that's a good thing! You might run into trouble otherwise, since you call <code>save</code>. If it was the same <code>Artic...
{ "AcceptedAnswerId": "45794", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T22:37:04.223", "Id": "45781", "Score": "5", "Tags": [ "ruby", "ruby-on-rails" ], "Title": "Article voting schema" }
45781
<p>If I was at an interview, and wrote this code, what would you think? Please be brutal.</p> <p>Time it took to wrote it: 13 minutes</p> <p>Problem:</p> <blockquote> <p>Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:</p> <p>Integers in ea...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T01:55:23.310", "Id": "79914", "Score": "1", "body": "A better way to do this is to treat it like a single dimension sorted array, and perform your binary search on _that_, using modulo and division to extract your values from the 2d...
[ { "body": "<p>Your algorithm is not efficient (thats the brutal part of the answer).</p>\n\n<p>Searching in a list of t values is a task that can be accomplished using O(log(t)) comparisons. Here we have t=m*n values so it should be accomplished using O(log(m*n)) = O(log(m))+O(log(n)) comparisons. I suspect yo...
{ "AcceptedAnswerId": "45809", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T22:48:12.753", "Id": "45783", "Score": "7", "Tags": [ "java", "interview-questions", "search", "matrix", "binary-search" ], "Title": "Searching in a sorted 2D matrix" }
45783
<p>I am doing a project for school and had to create a function to check if 2 time ranges overlap. I searched the net a bit but failed to find a simple function to do that. I played around a bit with my code and I think I created a working one.</p> <p>Note: it works for 24 hour times only &amp; don't forget the 0 in f...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T01:24:56.463", "Id": "79912", "Score": "1", "body": "I'm not sure why you've created the `$timeCheck` variable. You can just write `return true` or `return false` instead of using that variable. That saves you a few lines of excess ...
[ { "body": "<ul>\n<li>As <a href=\"https://codereview.stackexchange.com/users/39766/s3rius\">s3rius</a> pointed out, you don't need the <code>$timeCheck</code> variable. You can just use <code>return true;</code> or <code>return false;</code>.</li>\n<li>To parse a time use the <a href=\"http://us2.php.net/manual...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-30T23:20:33.777", "Id": "45784", "Score": "4", "Tags": [ "php", "interval" ], "Title": "Test 2 time ranges to see if they overlap" }
45784
<p>I wrote a package manager in clojure that does 5 things:</p> <ol> <li><p>depend a b //creates a and b (if they don't exist) and adds dependency on a</p></li> <li><p>install a //installs a and its dependencies</p></li> <li><p>list //prints out the install packages</p></li> <li><p>sys //prints out all packages</p></...
[]
[ { "body": "<p>You can use clojure sets to group like outcomes in a condp.</p>\n\n<pre class=\"lang-lisp prettyprint-override\"><code>(condp get (lower-case command)\n #{DEPEND} (apply add-sys-package args)\n #{LIST} (print-installed)\n #{INSTALL} (install (first args) true)\n #{INFO} (println (get-package (...
{ "AcceptedAnswerId": "45878", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T00:29:23.067", "Id": "45788", "Score": "8", "Tags": [ "functional-programming", "clojure" ], "Title": "Package manager in Clojure" }
45788
<p>This is all in one methods but I would like to see it in individual separate methods. The code works fine but all of the code is in the <code>canvasApp()</code> methods and I would like to see it all in individual methods so that I could call them as below.</p> <p>Question: How to make all of the code into separate...
[]
[ { "body": "<p>From a Code Review perspective, what you are asking for, is worse.</p>\n\n<p>Currently, you only need to call <code>canvasApp()</code> and that function does all the work. Inside you have <code>drawScreen</code> which is periodically called, starting in <code>gameLoop</code>.</p>\n\n<p>Still,</p>\...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T01:51:53.520", "Id": "45790", "Score": "3", "Tags": [ "javascript" ], "Title": "Splitting canvas app into separate functions" }
45790
<p>Solution to bounded knapsack 01 problem. Once again comprehensive description is difficult in this space, refer <a href="http://en.wikipedia.org/wiki/Knapsack_problem#0.2F1_Knapsack_Problem" rel="nofollow">here</a>. Looking for code review. optimizations and best practices.</p> <pre><code>final class Item { pri...
[]
[ { "body": "<p>Just a few comments :</p>\n\n<hr>\n\n<p>Your <code>if (value == 0)</code> and <code>if (weight == 0)</code> should probably be <code>if (value &lt;= 0)</code> and <code>if (weight &lt;= 0)</code>.</p>\n\n<hr>\n\n<p><a href=\"http://en.wikipedia.org/wiki/KISS_principle\" rel=\"nofollow\">Keep It Si...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T02:05:58.233", "Id": "45793", "Score": "1", "Tags": [ "java", "algorithm", "dynamic-programming", "knapsack-problem" ], "Title": "Knapsack 01 solution" }
45793
<p>Counterfactual Regret Minimization is an algorithm that can be used to find the Nash Equilibrium for games of incomplete information. I have tried to adapt the exercise from <a href="http://cs.gettysburg.edu/~tneller/modelai/2013/cfr/index.html" rel="nofollow">here</a> to Clojure. You can see the original RPSTrain...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T03:16:47.090", "Id": "45796", "Score": "6", "Tags": [ "performance", "algorithm", "clojure" ], "Title": "Translating CFRM algorithm from Java to Clojure and improving performance"...
45796
<p>I have a modal window that needs to be closed, obviously. I've created this piece of code that works okay. But is there a way to optimize it?</p> <pre><code>// close the modal window $('.modal-close').click(function(e) { $('#modal').hide(); $('#modal-overlay').hide(); e.preventDefault(); }); $...
[]
[ { "body": "<p>You can combine a couple of things: The close functionality can be function, and jQuery can operate on several elements at once:</p>\n\n<pre><code>function closeModal(event) { // passing in an event obj is optional\n $(\"#modal, #modal-overlay\").hide();\n if(event) {\n event.preventDefault()...
{ "AcceptedAnswerId": "45799", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T03:39:20.177", "Id": "45797", "Score": "2", "Tags": [ "javascript", "optimization", "jquery" ], "Title": "Am I optimally closing this modal window?" }
45797
<p>I am trying to solve this <a href="http://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/" rel="nofollow">Binary tree lever order traversal</a>:</p> <blockquote> <pre class="lang-none prettyprint-override"><code>Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7 return its...
[]
[ { "body": "<p>Depending on number of nodes in your tree, recursive post-order traversal of the tree, might let you run into problems on the stack. If the number of nodes is huge, you might need to consider a non-recursive post-order traversal.</p>\n\n<p>Have a look at <a href=\"http://leetcode.com/2010/10/binar...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T03:46:20.817", "Id": "45798", "Score": "5", "Tags": [ "java", "programming-challenge", "tree", "breadth-first-search", "time-limit-exceeded" ], "Title": "Binary tree level...
45798
<p>I have datalayer code as below which is implementing an interface as: <strong>Note:</strong> I have hand written this code on Notepad so it may contain some typo errors, which you can gracefully ignore. I am searching for an approach here.</p> <pre><code>public interface ISimpleInterface{ void DosSomething(lon...
[]
[ { "body": "<p>I think this ID should be generated at database level (autoincrement). But let's ignore this, for testing you have to make sure your methods do not have a dependency on eachother. </p>\n\n<p>It would be better if you write it like this</p>\n\n<pre><code>public void DoSomething(long someValue, long...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T04:13:47.203", "Id": "45800", "Score": "0", "Tags": [ "c#", "unit-testing" ], "Title": "Unit Testing Datalayer written in ADO.net" }
45800
<p>Could someone help me on how to eliminate some nested blocks or improve this code? I am concerned this will slow down my site dramatically.</p> <pre><code>function dispalyEvent($weekNr, $week, $year){ echo "&lt;p&gt;"; $gendate = new DateTime(); $gendate-&gt;setISODate($year,$week,$weekNr); $event...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T08:24:15.523", "Id": "79943", "Score": "0", "body": "Explain the purpose of this function. Is it called for each day on the calendar to render events for that day?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": ...
[ { "body": "<p>Here are a few quick tips:</p>\n\n<ul>\n<li><p>Your indentation seems mostly consistent, but there are a few lines off by a space. Most editors have a format feature if you find it too tedious to maintain it manually.</p></li>\n<li><p>Other whitespace is inconsistent as well. Compare these two lin...
{ "AcceptedAnswerId": "45814", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T05:17:57.210", "Id": "45801", "Score": "4", "Tags": [ "php", "beginner" ], "Title": "I have a huge function filled with nested blocks" }
45801
<p>I am using using the following code to choose the transport layer security protocol while issuing a request to server. Could someone please review it. This is in reference to the following question: <a href="https://stackoverflow.com/questions/22657498/i-want-to-choose-the-transport-layer-security-protocol-in-urllib...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T09:09:42.397", "Id": "45812", "Score": "4", "Tags": [ "python", "https" ], "Title": "Choose the Transport Layer Security protocol - requests python" }
45812
<p>In an effort to teach myself some python and programming in general I made a Sudoku Solver (as many others have done before me from what I can tell). The one thing that bugs me a little is my use of deepcopy which I think I can avoid by implementing __eq__ in my classes.</p> <p>My questions:</p> <ol> <li>Is this u...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T12:18:50.317", "Id": "79961", "Score": "2", "body": "New style classes should be derived from `object`. i.e. `class SudokuGrid:` should be `class SudokuGrid(object):`" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate...
[ { "body": "<p>in your class SudokuCell()</p>\n\n<p>add a function that sets all the values to a boolean, e.g. ...</p>\n\n<pre><code>def reset_all_values(self, new_value):\n self.values = {}\n for i in range(1, 10):\n self.values[i] = new_value\n</code></pre>\n\n<p>Then, <strong>init</strong> can ca...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T12:14:46.377", "Id": "45817", "Score": "12", "Tags": [ "python", "unit-testing", "sudoku" ], "Title": "Deepcopy usage in a Sudoku solver" }
45817
<p>I have implemented a HTML table sorting. I actually implemented a sort first using jQuery and then modified it based on the answer to <a href="https://codereview.stackexchange.com/questions/37632/how-should-i-sort-an-html-table-with-javascript-in-a-more-efficient-manner?newreg=4b372a7633204fa09a28b55a6443b687">this ...
[]
[ { "body": "<p>From a once over;</p>\n\n<ul>\n<li>The easiest way to be sure that you sort algorithm is stable, is to write you own sort algorithm.</li>\n<li>The second easiest way to be sure is to pass in each array entry object it's position in the array ( you could set this after your <code>arr[i][j]</code> a...
{ "AcceptedAnswerId": "45829", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T12:21:14.353", "Id": "45818", "Score": "5", "Tags": [ "javascript", "jquery", "performance", "sorting" ], "Title": "How to verify if HTML table sort is stable or not?" }
45818
<p>This snippet from a downloader callable handles HTTP status codes. I need critique on both the style (<code>for</code> or <code>do-while</code> loop better here?) and functionality. Should I manage the delay differently? Do I need to handle <code>InterruptedException</code> specifically?</p> <pre><code>HttpURLConne...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2016-11-19T16:35:54.430", "Id": "277235", "Score": "1", "body": "You got labels? Goto style?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2019-08-01T15:05:21.573", "Id": "437555", "Score": "0", "body": "@fnc...
[ { "body": "<h2>Readability</h2>\n<p>Let's reformat your code quickly:</p>\n<blockquote>\n<pre><code> HttpURLConnection connection = null;\n boolean connected = false;\n outer: for (int retry = 0; retry &lt;= RETRIES &amp;&amp; !connected; retry++) {\n if (retry &gt; 0) {\n log.warning...
{ "AcceptedAnswerId": "45820", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T12:22:46.883", "Id": "45819", "Score": "8", "Tags": [ "java", "error-handling", "http" ], "Title": "HttpURLConnection response code handling" }
45819
<p>I have a class used to return a single integer, but think there is room for improvement. The class should only return a single row every time and if no row is found it might be a good idea to throw an error from the class rather than from the calling code which will break when the integer comes back as zero.</p> <p...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T14:31:03.637", "Id": "79975", "Score": "0", "body": "I don't quite understand your question. Are you looking to add a new implementation to the code ? What it this code suppose to do, retrieve an id or something ? And where is the e...
[ { "body": "<p>I see a number of things wrong with this implementation:</p>\n\n<p>First, You already have a <code>CommuteData</code> entity. Why are you using it to go back to the database to retrieve a property that's already on it (ie: <code>commuteData.CommuteDataId</code>)? This makes me very suspicious of a...
{ "AcceptedAnswerId": "45832", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T13:59:14.370", "Id": "45826", "Score": "1", "Tags": [ "c#", "entity-framework", "asp.net-mvc-4" ], "Title": "Class to Return Single Integer" }
45826
<p>I wrote a BFS implementation that walks a tile-based field. It takes a function that should return true for walkable tiles and false for walls. It also takes the start and end points. It currently takes about 5 seconds to find the shortest path from (0, 0) to (1000, 1000) which isn't bad, but it really isn't great.<...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-23T20:47:17.810", "Id": "84233", "Score": "0", "body": "it seems you accidentally swapped `then` and `else` parts of the condition" } ]
[ { "body": "<p>I managed to make it five times faster but my solution uses some ad-hoc hacks.</p>\n\n<p>First, I replaced queue with a set. This makes checking for solution faster and allows to update <code>visited</code> with single set-union operation.</p>\n\n<pre><code>bfs field start end = minSteps H.empty (...
{ "AcceptedAnswerId": "48013", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T14:06:07.977", "Id": "45828", "Score": "5", "Tags": [ "optimization", "haskell", "breadth-first-search" ], "Title": "BFS implementation that walks a tile-based field" }
45828
<p>We have an entity data model (database first) for a legacy product we are migrating to .Net from Delphi. We recently deployed to a server where some of the tables had been modified and columns deleted. The results were catastrophic. I'm working on a way of validating the EDM schema against the live SQL server databa...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T17:32:15.127", "Id": "80179", "Score": "0", "body": "I think question 2 is probably best asked on StackOveflow. Also, Dapper would only work if you don't have any non-conventional mappings or implicit many to manys" }, { "Co...
[ { "body": "<blockquote>\n <p>Is there a better way?<br>\n Does Entity Framework already provide a mechanism for achieving this?</p>\n</blockquote>\n\n<p>In fact this is one question. If EF would provide a mechanism, undoubtedly that would be better, because you'd know for sure it yields something that EF is h...
{ "AcceptedAnswerId": "46278", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T14:20:49.823", "Id": "45831", "Score": "10", "Tags": [ "c#", "entity-framework" ], "Title": "Verifying the Entity Data Model schema against a production database" }
45831
<p>I'm writing a program that will perform a long-running computation, gradually improving a solution. On top of that, there's a simple UI that basically allows the user to stop the computation (letting the worker finish a step it's working on) and shows the best solution. Here's a simplified version of what I have, I'...
[]
[ { "body": "<h3>Task-based Asynchronous Pattern (<a href=\"http://msdn.microsoft.com/en-us/library/hh873175.aspx\" rel=\"nofollow noreferrer\">MSDN</a>)</h3>\n<blockquote>\n<pre><code>public async Task&lt;IProblemSolution&gt; Search(CancellationTokenSource cts)\n</code></pre>\n</blockquote>\n<p>As I explain in <...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T14:54:17.367", "Id": "45838", "Score": "3", "Tags": [ "c#", "async-await" ], "Title": "Stopping a long-running asynchronous computation" }
45838
<p>How can I make the following code shorter or efficient (maybe with other loops or other nice ideas), and keep the current functionality?</p> <pre><code>my $examine = shift; my $detect = 0; foreach my $ProteinDB (@DB) { my $Set = $ProteinDB-&gt;{'ID'}; if($Set =~ /$examine/) { $detect = 1; m...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T14:46:24.770", "Id": "79987", "Score": "0", "body": "the Code is fast enough but its too long thats my problem i am trying to use another things(loops, regex,.. to make it shorter, but have the same functionality" } ]
[ { "body": "<p>This is nice, well-formatted code. Let's see what we can improve:</p>\n\n<ul>\n<li><p>Only use one statement per line:</p>\n\n<pre><code>my $examine = shift;\nmy $detect = 0;\n</code></pre></li>\n<li><p>I assume this code is from the body of a subroutine. I'd recommend not using <code>shift</code>...
{ "AcceptedAnswerId": "45861", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T14:39:32.337", "Id": "45839", "Score": "6", "Tags": [ "perl", "bioinformatics" ], "Title": "Foreach-loop for and print commands" }
45839
<p>To solve a polynomial equation I have written following program, is there any way to optimize this program.</p> <p>Following code is working code:</p> <p>Program takes input n,x where n is the deg of polynomial and x is the point at which the polynomial is to be evaluated.</p> <pre><code> #include&lt;stdio.h&gt...
[]
[ { "body": "<p>By following <a href=\"http://en.wikipedia.org/wiki/Horner%27s_method\" rel=\"nofollow\">Horner's Method</a> only n multiplications are needed.</p>\n\n<pre><code>#include &lt;stdio.h&gt;\n\nint main()\n{\n // n is the deg of polynomial\n // x is the value of polynomial for which it is to be ev...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-29T15:05:23.360", "Id": "45841", "Score": "3", "Tags": [ "c" ], "Title": "Evaluating a polynomial at a given value of x and n" }
45841
<p>I am trying to step to the next level from student to amateur web developer, and I would like to make sure I am not making any web-development no-no's, that's all. What caused me to want to ask SO this question is that I had to make some tweaks to make my responsive design work.</p> <p>For instance, I had to make a...
[]
[ { "body": "<p>From a once over:</p>\n\n<ul>\n<li><code>$(document).ready(function () {</code> &lt;- old skool, you should use <a href=\"http://api.jquery.com/ready/\" rel=\"nofollow\"><code>$( handler )</code></a></li>\n<li>Indenting, you are not doing it consistently</li>\n<li><code>$('.assignmentsDown').click...
{ "AcceptedAnswerId": "45849", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T15:27:22.843", "Id": "45846", "Score": "5", "Tags": [ "javascript", "jquery", "html", "css", "html5" ], "Title": "Expandable navigation menu" }
45846
<blockquote> <p><strong>Problem Statement</strong></p> <p>Generate as many distinct primes P such that reverse (P) is also prime and is not equal to P.</p> <p>Output:<br> Print per line one integer( ≤ 10<sup>15</sup> ). Don't print more than 10<sup>6</sup> integers in all.</p> <p>Scoring:<br> L...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T17:04:44.113", "Id": "80020", "Score": "0", "body": "For generating primes, see [Sieve of Eratosthenes - Python](http://codereview.stackexchange.com/q/42420/10916)" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": ...
[ { "body": "<p>There are a few things you could optimize:</p>\n\n<ul>\n<li>If you (or the grading server?) are running this on Python 2.x, you should definitely use <code>xrange</code> instead of <code>range</code> (about 2 seconds on my system)</li>\n<li>In your prime sieve, you have to check the multiples only...
{ "AcceptedAnswerId": "45869", "CommentCount": "8", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T16:05:44.043", "Id": "45857", "Score": "25", "Tags": [ "python", "performance", "primes", "programming-challenge", "palindrome" ], "Title": "Count distinct primes, disc...
45857
<p>I used a standard calculator design from Java. I wanted to expand it so I created a class to create buttons for different operations, like <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>. The original program didn't do this, they just made them individually without a template method. Do you think I ...
[]
[ { "body": "<h1>Bug!</h1>\n<p>In your program, it's impossible to use any operator besides addition. As Code Review is not meant to be a code-bug-fixing site, I think you should try to fix this yourself. <em>Hint: The bug is in your <code>addActionButton</code> method</em></p>\n<h2>Now, about your question</h2>\...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T16:56:16.280", "Id": "45864", "Score": "12", "Tags": [ "java", "swing", "calculator" ], "Title": "Basic Calculator in Java with Swing" }
45864
<pre><code>if($row['best']){ $id = $row['best']; } elseif($row['average']){ $id = $row['average']; } elseif($row['bad']){ $id = $row['bad']; } </code></pre> <p>If <code>row['best']</code> is <code>null</code>, I need <code>$id</code> to equal the 2nd best. If 2nd best is null, <code>$id</code> is equal t...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T17:10:36.790", "Id": "80022", "Score": "10", "body": "Can you add a bit of the surrounding context to your question? Where does the `$row` variable come from? I can imagine that there might be a possible solution where the problem c...
[ { "body": "<p>There are some different approaches possible here, one of them is to use an array:</p>\n\n<pre><code>$arr = array($row['best'], $row['average'], $row['bad']);\nfor ($arr as $value) {\n if ($value) {\n $id = $value;\n break;\n }\n}\n</code></pre>\n\n<p>If you consider this as a be...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T17:00:50.950", "Id": "45865", "Score": "7", "Tags": [ "php" ], "Title": "Shorter way to write multiple if-then-else-if" }
45865
<p>This is my function returning matrices from Matlab. This code run very slowly. I was trying to use <code>Parallel.For</code> in-order to run it in parallel threads but I got different results than running it on one thread. </p> <p>Am I iterating the matrix in a wrong order? Row, col vs col, row? Can you please re...
[]
[ { "body": "<p>As usual with performance problems the only way of knowing for sure is to use a profiler and check which piece of code is taking the longest time. However looking at the code you are copying the matrix element by element which is typically the slowest way to go. Often there is a method which can d...
{ "AcceptedAnswerId": "45890", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T18:39:53.317", "Id": "45875", "Score": "2", "Tags": [ "c#", "performance", ".net", "matrix", "matlab" ], "Title": "Parsing MWNumericArray to C# code optimization" }
45875
<p>I recently added a feature to my application to serve arbitrary markdown documents from a directory. This is designed to allow authors to populate a folder full of help documents, and be able to view them without any code changes. However, because this is an MVC application, I needed a few extra features. Straight t...
[]
[ { "body": "<p>A few minor nit-picks:</p>\n\n<ol>\n<li><p>I'd change the id checking code around a bit to avoid some redundant checks by first sanitizing the input:</p>\n\n<pre><code>id = string.IsNullOrEmpty(id) ? DefaultDocPage : id;\nViewBag.HomeLinkPage = id == DefaultDocPage ? string.Empty : DefaultDocPage;...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T19:01:44.900", "Id": "45877", "Score": "5", "Tags": [ "c#", "strings", "url-routing", "markdown" ], "Title": "Preprocessing Markdown Documents for Keywords" }
45877
<p>I need to create variable-length strings of dots/periods/full-stops to add to some text content, in a way that is similar to a formatted table-of-contents:</p> <pre><code>Chapter 1 .................................... 1 Section 1.1 ................................ 1 Subsection 1.1.2 .......................... 1...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T22:01:55.503", "Id": "80069", "Score": "0", "body": "Shouldn't you have some sort of helper method like `DotPadding.getPaddedString(String left, String right)`? Or is that what the last code block is about?" }, { "ContentLic...
[ { "body": "<ol>\n<li><p>Naive approach: use <a href=\"http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#repeat%28char,%20int%29\" rel=\"nofollow noreferrer\"><code>StringUtils.repeat</code></a> (<a href=\"http://commons.apache.org/proper/commons-lang/apidocs/src-htm...
{ "AcceptedAnswerId": "45908", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T21:54:40.943", "Id": "45885", "Score": "10", "Tags": [ "java", "strings", "concurrency" ], "Title": "Poke-a-Dot (Provider)" }
45885
<p>I'm looking for some feedback on my implementation of the algorithm. How can I improve it? I ran into problems when calculating the larger prime numbers > 46349 due to integer overflow, but fixed that by using <code>sqrt</code> instead of <code>pow</code>.</p> <pre><code>#include&lt;iostream&gt; #include&lt;math.h&...
[]
[ { "body": "<ul>\n<li><p><code>&lt;math.h&gt;</code> is a C header. Use the C++ header <code>&lt;cmath&gt;</code>.</p></li>\n<li><p>If you have a dynamically-allocated array with <code>new</code>, you <em>must</em> use <code>delete</code> at some point afterwards, otherwise you'll get a memory leak:</p>\n\n<pre...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T22:02:28.193", "Id": "45886", "Score": "14", "Tags": [ "c++", "primes", "sieve-of-eratosthenes" ], "Title": "Sieve of Eratosthenes in C++" }
45886
<p>I have been using this code for a while for a project at work. Actually I got it from a friends who got it from a book. But either way it worked for my demonstration.</p> <p>But the other night I decided to sit down and see if I could make it into all functions and then to see about moving the variables up to the t...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T23:41:28.460", "Id": "80081", "Score": "0", "body": "Duplicate of http://codereview.stackexchange.com/questions/45790/splitting-canvas-app-into-separate-functions ?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate":...
[ { "body": "<p>I don't see any problem when I move the two lines you mentioned to an earlier position (directly after the check for canvas support).</p>\n\n<ul>\n<li><p>You need to clean up the indention.</p></li>\n<li><p>Use one <code>var</code> statement with the variables separater with commas instead of mult...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T23:32:39.070", "Id": "45892", "Score": "5", "Tags": [ "javascript", "canvas", "animation" ], "Title": "Bouncing ball in JavaScript" }
45892
<p>Please let me know your thoughts on the code below, please be brutal. Here is the question I solved:</p> <p>Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).</p> <p>For example: Given binary tree...
[]
[ { "body": "<p>Just the first few steps of refactoring:</p>\n\n<ol>\n<li><p><code>ArrayList&lt;...&gt;</code> reference types should be simply <code>List&lt;...&gt;</code>:</p>\n\n<pre><code>List&lt;List&lt;Integer&gt;&gt; res = new ArrayList&lt;&gt;();\n</code></pre>\n\n<p>See: <em>Effective Java, 2nd edition</...
{ "AcceptedAnswerId": "45965", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-31T23:36:24.450", "Id": "45893", "Score": "3", "Tags": [ "java", "algorithm", "interview-questions" ], "Title": "ZigZag order of a tree traversal" }
45893
<p>A brief background:</p> <p>I'm working on a game prototype for a simple strategy game. After I created a number of possible jobs I wanted to create something to manage them. This is the first time I've attempted something like this so code review would be helpful. </p> <p>I created a set of methods that adds Jobs...
[]
[ { "body": "<p>Let's make your relevant enum more relevant:</p>\n<pre><code>typedef NS_ENUM(NSInteger, JobType) {\n MiningJob = 0,\n LadderJob,\n BottomBuildJob,\n WallBuildJob,\n RoomBuildJob\n};\n</code></pre>\n<p>Now let's change the argument type of all the methods where we want to send a job ...
{ "AcceptedAnswerId": "45935", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T00:48:17.747", "Id": "45897", "Score": "2", "Tags": [ "game", "objective-c", "queue" ], "Title": "Job queue that performs actions" }
45897
<p>This question is a follow-up to a <a href="https://codereview.stackexchange.com/q/40119/31982">previous version</a> of this program, which I wrote because I found it annoying that <a href="https://www.videolan.org/vlc/index.html" rel="nofollow noreferrer">VLC Media Player</a> (which I love) prevents the screensaver ...
[]
[ { "body": "<p>Define your variable in the smallest possible scope as it make things easier to understand.</p>\n\n<hr>\n\n<p>Avoid hardcoded strings and magic numbers in your code. In you do need them, make sure you define them in a single place ( <a href=\"http://en.wikipedia.org/wiki/Don%27t_repeat_yourself\">...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T01:10:17.517", "Id": "45900", "Score": "5", "Tags": [ "c", "linux", "portability" ], "Title": "VLC media player watchdog daemon v6" }
45900
<p>When a user presses a key in my game, their avatar can move down, left, right or up. By move, I mean their avatar animates while various other things move around them on the screen. This is accomplished by raising an event from the <code>InputHandler</code> class.</p> <pre><code>public class InputHandler { publ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T06:14:57.927", "Id": "80106", "Score": "0", "body": "Are you asking how to fix this issues in your current design or how to implement a better design?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T1...
[ { "body": "<p>Looks pretty neat overall, I merely glanced at your code (favorited, I want to look at this more deeply, as I'm [<em>playing with</em> | <em>learning</em>] XNA myself, your XNA posts are very useful!).</p>\n\n<p>One thing I've noticed, I don't think you need this <code>switch</code> block:</p>\n\n...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T01:17:32.537", "Id": "45901", "Score": "17", "Tags": [ "c#", "game", "animation", "xna" ], "Title": "Sprite animation handler" }
45901
<p>This is my code for a server using EAP (Sockets).</p> <p>Is <code>AsyncOperation.Post</code> the right way to raise thread safe events?</p> <p><code>AsyncOperation.Post</code> states: </p> <blockquote> <p>Invokes a delegate on the thread or context appropriate for the application model.</p> </blockquote> <p>Is...
[]
[ { "body": "<blockquote>\n<pre><code>public EndPoint LocalEndPoing { get; private set; } \n</code></pre>\n</blockquote>\n\n<p>should be <code>LocalEndPoint</code>. </p>\n\n<hr>\n\n<blockquote>\n<pre><code>public void Start()\n{\n try\n {\n if (Listening)\n return; \n</code></pre>\n</bl...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T03:05:19.160", "Id": "45907", "Score": "3", "Tags": [ "c#", "asynchronous", "event-handling" ], "Title": "Thread Safe Events while utilizing EAP" }
45907
<p>I'm trying to write a JavaScript library to allow inheritance with knockout.</p> <p>The fundamental problem when implementing inheritance in Knockout is that each Knockout observable is its own instance, thus if you try this:</p> <pre><code> x = function () {}; x.prototype.m = ko.observable(); y = function () {}...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T23:32:47.743", "Id": "80247", "Score": "0", "body": "I am most curious, what would you be modeling that requires a long inheritance chain ? I have yet to find something that requires more than 3 levels." }, { "ContentLicense...
[ { "body": "<p>Interesting question,</p>\n\n<ul>\n<li><p><em>Are there any performance hits ?</em> I don't see problems, it would not be slower then building the objects in an old skool manner</p></li>\n<li><p><em>Does this make for clear code?</em> Your sample code would not run, you need to provide a sample th...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T04:01:58.097", "Id": "45909", "Score": "5", "Tags": [ "javascript", "inheritance", "prototypal-class-design", "knockout.js" ], "Title": "Prototype inheritance with Knockout ob...
45909
<p>I am working on a project involving the unique partitioning of integers. I.e. I am looking to have all of the partitions of n = x<sub>1</sub> + x<sub>2</sub> + x<sub>3</sub> + ... + x<sub>k</sub>, where x<sub>i</sub> = x<sub>j</sub> implies i = j.</p> <p>For example, if I give my code input of 10, I want to have as...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T05:09:44.927", "Id": "80102", "Score": "1", "body": "The MarkDown interpreter on this site gets confused by tabs; I've replaced them with spaces." } ]
[ { "body": "<p>Yes, it is unreasonable to expect this approach to be &quot;fast&quot;.</p>\n<p>This answer will focus on... <em>drumroll, please!</em></p>\n<h1>Why your current approach is slow</h1>\n<p>The reason for why it is unreasonable to expect this approach to be fast can be shown simply by adding a <code...
{ "AcceptedAnswerId": "45915", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T04:16:34.463", "Id": "45910", "Score": "6", "Tags": [ "java", "optimization", "algorithm", "combinatorics", "integer" ], "Title": "Optimizing unique partitions of integ...
45910
<blockquote> <p>Given an expression string exp, write a program to examine whether the pairs and the orders of</p> <pre><code>"{","}","(",")","[","]" </code></pre> <p>are correct in exp.</p> <p>For example, the program should print true for</p> <pre><code>exp = "[()]{}{[()()]()}" </code></pre> <p>a...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T07:20:30.690", "Id": "80108", "Score": "1", "body": "Best practices: 1) Use Snobol (in which most of the program reduces to `BAL x`, where `x` is the string to check for balance)." }, { "ContentLicense": "CC BY-SA 3.0", ...
[ { "body": "<p>I just wanted to write that the code looks completely fine to me, until...</p>\n<pre><code>assertEquals(false, isBalanced(&quot;[[&quot;));\n</code></pre>\n<p>I''m sure you'll find the error :-)</p>\n<p>Otherwise two small remarks:</p>\n<ul>\n<li><p>Personally I'd have the function return <code>tr...
{ "AcceptedAnswerId": "45926", "CommentCount": "6", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T06:55:06.123", "Id": "45916", "Score": "32", "Tags": [ "java", "algorithm", "strings", "stack" ], "Title": "Check for balanced parentheses" }
45916
<p>As suggested in <a href="http://chat.stackexchange.com/transcript/message/14590911#14590911">The 2nd Monitor</a>, I'd like a review of this in-place reversal of a singly linked-list:</p> <pre><code>#include &lt;iostream&gt; struct node { int data; node *next; }; node *reverse(node *list) { node *pre...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T20:35:37.733", "Id": "80224", "Score": "2", "body": "I would use the term one pass reversal rather than in-pace." } ]
[ { "body": "<p>Code this valuable shouldn't be limited solely to <code>int</code> data.</p>\n\n<pre><code>template&lt;typename T&gt;\nstruct node { \n T data;\n node *next;\n};\n</code></pre>\n", "comments": [], "meta_data": { "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", ...
{ "AcceptedAnswerId": "45978", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T07:03:55.267", "Id": "45918", "Score": "13", "Tags": [ "c++", "linked-list" ], "Title": "In-place reversal of a singly linked list" }
45918
<p>I've created a linked list class in Python, but I'm not sure how to enforce only passing <code>Node</code> objects into the <code>insert</code> routine.</p> <pre><code># linked list in Python class Node: """linked list node""" def __init__(self, data): self.next = None self.data = data ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T08:36:05.393", "Id": "80112", "Score": "0", "body": "Use Python 3.4 `@singledispatch`." } ]
[ { "body": "<p>You could delegate the construction of nodes to the <code>insert</code> function :</p>\n\n<pre><code>#!/usr/bin/python\n\n# linked list in Python\n\nclass Node:\n \"\"\"linked list node\"\"\"\n def __init__(self, data):\n self.next = None\n self.data = data\n def insert(self...
{ "AcceptedAnswerId": "45930", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T08:32:16.557", "Id": "45923", "Score": "5", "Tags": [ "python", "linked-list" ], "Title": "Passing Node objects into insert routine of linked list" }
45923
<p>This tag is reserved for <a href="/questions/tagged/linked-list" class="post-tag" title="show questions tagged &#39;linked-list&#39;" rel="tag">linked-list</a> implementations in <a href="/questions/tagged/c" class="post-tag" title="show questions tagged &#39;c&#39;" rel="tag">c</a> / <a href="/questions/tagged/c%2b...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T08:35:22.773", "Id": "45924", "Score": "0", "Tags": null, "Title": null }
45924
Special tag reserved for the countless implementations of linked lists in C and C-derived languages.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T08:35:22.773", "Id": "45925", "Score": "0", "Tags": null, "Title": null }
45925
<p>first let me explain what I am trying to achieve here :</p> <p>I am supposed to compute some results, using data from several tables, filtered by a run_id. One of these tables has about 500.000 rows per run_id, and 60 columns. All other tables have only a few thousand rows per run_id. I also have to write about 500...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T13:23:23.370", "Id": "80138", "Score": "0", "body": "You could probably benefit from threading the application or using something like map/reduce. Sorry this isn't much help, but your data set is large enough that I would say it co...
[ { "body": "<p><strong>Naming, naming, naming...</strong><br>\nYour code is <em>very</em> hard to read - <code>ntt</code>, <code>epe</code>, <code>lgd</code>, <code>SPECIAL = \"207\"</code>(?!?). I understand (hope?) that some of these names are part of your business nomenclature, but, especially when asking str...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-04-01T11:04:36.383", "Id": "45933", "Score": "3", "Tags": [ "java", "performance", "sql", "hibernate" ], "Title": "Loading, computation and writing 500.000 rows in database" }
45933