body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>I have a model object class like this</p> <pre><code>public class EventInterestsResponse { public string id { get; set; } public int sortOrder { get; set; } public string name { get; set; } public string categoryName { get; set; } public string categoryId { get; set; } } </code></pre> <p>And I am using i...
[]
[ { "body": "<p>I'm not sure if this is any better and it might depend on how many if statements or different categories you have whether it's worth it. But an alternative could be something like:</p>\n\n<pre><code>var categoryLabelValues = new Dictionary&lt;string, string&gt;()\n {\n {\"11\", \"Branch...
{ "AcceptedAnswerId": "40247", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T06:48:26.953", "Id": "40245", "Score": "5", "Tags": [ "c#", "asp.net", "linq", "razor" ], "Title": "Convert looping statement to linq mode" }
40245
<p>I'm looking for a code review, clever optimizations, and good coding practices. Unit testing has been a visual inspection and concluded expectations match. Also, is the space complexity of the extra variable used to swap \$O(1)\$? Typically, is \$O(1)\$ an acceptable space to use when code requires no extra memory?<...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T10:19:09.967", "Id": "67686", "Score": "0", "body": "this is indeed O(1) space needed (2 indexes and the swap var+ generic stack space) and yes O(1) is indeed what is understood with no extra memory" }, { "ContentLicense": "...
[ { "body": "<p>You ask many questions on CodeReview, which in itself is good, but you have to start helping the reviewers actually review your code. You have this habit of dumping code and expecting a review. It does not work that way (very well). For a start, let's review the ideal process for a 'real' review:<...
{ "AcceptedAnswerId": "40372", "CommentCount": "8", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T07:30:31.417", "Id": "40246", "Score": "6", "Tags": [ "java", "matrix" ], "Title": "Given N*N matrix, rotate it by 90 degree to left and right without extra memory" }
40246
<p>Stack Overflow tag wiki: <a href="http://stackoverflow.com/tags/codenameone/info">http://stackoverflow.com/tags/codenameone/info</a></p>
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T08:02:39.587", "Id": "40248", "Score": "0", "Tags": null, "Title": null }
40248
<p>I have an entity <code>RegistrationForm</code> which has a OneToMany-relationship with <code>SurveyAnswer</code>. </p> <p>An answer can either have a collection of <code>FormOptions</code> (when the answer is of type <code>MULTIPLE_CHOICE</code>) or a <code>content</code> represented by a string (type <code>TEXT-F...
[]
[ { "body": "<p>For now, one solution is to concatenate the options into a string while the answer is persisted. This is part of my <code>FormToArrayTransformer</code>:</p>\n\n<pre><code>switch ($_question-&gt;getFormField()-&gt;getType()) {\n case FormField::CHOICE:\n $content = '';\n\n foreach(...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T10:14:20.370", "Id": "40254", "Score": "4", "Tags": [ "php", "mysql" ], "Title": "Query optimization PHP for string concatination" }
40254
<p>I wrote the following program to calculate <em>n</em> digits of Pi (where <em>n</em> could be anything, like 10M) in order to benchmark the CPU and it works perfectly (without OpenMP):</p> <pre><code>/* * * Simple PI Benchmarking tool * Author: Suyash Srijan * Email: suyashsrijan@outlook.com * * This program calcul...
[]
[ { "body": "<p>For starters, don't use <code>__inline__</code>. It isn't portable. Instead, use the standard C <code>inline</code>.</p>\n\n<p>Next, use more whitespace. Complex calls and almost all conditionals should go into multiple lines, while operations should be spaced. Also, explain what you are doing:</p...
{ "AcceptedAnswerId": "42017", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T11:37:21.990", "Id": "40256", "Score": "11", "Tags": [ "performance", "c", "multithreading", "openmp", "openssl" ], "Title": "Pi Benchmarking in C" }
40256
<p>Have a look to the following example. Clearly it's very hard to understand the meaning of each parameter passed to the string.Format to be replaced to the numeric sequence of {0}, {1}, ...</p> <p>I want to improve the software quality: Maintainability\Code readability <a href="http://en.wikipedia.org/wiki/Software_...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T14:58:32.093", "Id": "67738", "Score": "2", "body": "You could simply wrap the string.Format in a method with a proper name and documentation that shows what the output will be like. The IDE will do the rest." }, { "ContentL...
[ { "body": "<p>Like @jesse said you can have a custom method, maybe pass a user object to that method.\nSomething like this:</p>\n\n<pre><code>class User\n{\n public int AutoLoginRequestTemplate { get; set; }\n public string username { get; set; }\n public string password { get; set; }\n public strin...
{ "AcceptedAnswerId": "40266", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T14:53:51.130", "Id": "40265", "Score": "2", "Tags": [ "c#", "template" ], "Title": "How to make string.Format template more readable?" }
40265
<p>I'm creating a small online multiplayer game in NodeJS and I'm wondering if I'm "doing it right". Here is a bit of my code: </p> <pre><code>// app.js // if I give an id as argument we assume it's an existing player. var Player = new player(); Player.on('playerLoaded', function (err, result) { if (result) {...
[]
[ { "body": "<p>Interesting question,</p>\n\n<p>I am assuming you know that usually, in essence, the setting of the name would be written like this:</p>\n\n<pre><code>Player.setName('somename' , function( err, result ) {\n console.log('Name changed'); \n});\n</code></pre>\n\n<p>and in essence <code>setName</c...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T15:28:28.963", "Id": "40267", "Score": "6", "Tags": [ "javascript", "node.js", "callback" ], "Title": "Is this the right way to work with callbacks and the EventEmitter?" }
40267
<p>I've written a small library for reading and writing PGM/PPM images. The format is described <a href="http://paulbourke.net/dataformats/ppm/" rel="nofollow">here</a>. I attach the library itself and a small utility to convert binary encoded images to ASCII encoding. Any type of comment will be appriciated. However, ...
[]
[ { "body": "<p>A few improvements I notice right off the bat</p>\n\n<p><strong>newtype vs. data</strong>\nreplace single field <code>data</code> declarations with <code>newtype</code>. <code>newtype</code> has no runtime overhead.</p>\n\n<pre><code>data GrayscalePixel = GrayscalePixel Int\n-- becomes\nnewtype Gr...
{ "AcceptedAnswerId": "40282", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T15:50:01.287", "Id": "40269", "Score": "10", "Tags": [ "performance", "haskell", "image" ], "Title": "PPM/PGM Image processing library in Haskell" }
40269
<p>I like to reuse code as much as possible and keeps things DRY. But I'm afraid that sometimes it creates too many layers of indirection. It then becomes a chore to find where code exists that is relevant to the problem at hand. I'll give a couple of examples.</p> <p>In the first example, I'm using inheritance on cla...
[]
[ { "body": "<p>These dependencies can't be fixed by naming. They are a symptom of some fundamental design problems. If you're having trouble finding methods, that's\na symptom of an overly coupled design. </p>\n\n<p>You have a class names that really sound like methods in a completely different class. </p>\n\n<p...
{ "AcceptedAnswerId": "40284", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T15:51:09.983", "Id": "40270", "Score": "2", "Tags": [ "ruby", "datetime" ], "Title": "Code reuse while keeping meaning clear and avoiding unforseen consequences" }
40270
<p>Is it possible to improve this bit?</p> <pre><code>def append_nones(length, list_): """ Appends Nones to list to get length of list equal to `length`. If list is too long raise AttributeError """ if len(list_) &lt; length: nones = length - len(list_) return list_ + [None] * nones...
[]
[ { "body": "<h3>1. Comments on your code</h3>\n\n<ol>\n<li><p>The documentation does not match the implementation. The docstring says \"append Nones to list\" but it does not append: if the list does not have the required length, it returns a newly allocated list.</p></li>\n<li><p>It seems wrong to return the or...
{ "AcceptedAnswerId": "40274", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T16:15:11.780", "Id": "40272", "Score": "7", "Tags": [ "python" ], "Title": "Append nones to list if is too short" }
40272
<p>The app I'm working on should allows it's users to create tables. I have a view in which users are able to create a table. They should be able to define here the table's columns. The columns that the user adds will be part from some predefined types of columns: BusinessFields, SourceKeys, SourceAttrs,...; At the sam...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T17:07:42.753", "Id": "67784", "Score": "5", "body": "Welcome to Code Review. This is a very well formatted question, good to see this in the first-post review queue." } ]
[ { "body": "<p>I would just add a <code>columnGroup</code> attribute to <code>Column</code> and then do a <code>groupBy</code>-type operation on that attribute. That would reduce your <code>Table</code> view-model to just a collection of <code>Row</code>s, which would be nice. Here's what I'm thinking for <code>...
{ "AcceptedAnswerId": "40377", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T16:45:47.750", "Id": "40276", "Score": "11", "Tags": [ "javascript", "knockout.js" ], "Title": "Knockout.js binding 2D table with rowspan" }
40276
<p>I have the following method which encrypts a english text, given the plain text and the desired key:</p> <pre><code>/// &lt;summary&gt; /// Encrypts english plain text using user defined key. Range for the key is from -25 to 25. /// &lt;/summary&gt; /// &lt;param name="plainText"&gt;&lt;/param&gt; /// &lt;param nam...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T17:21:56.560", "Id": "67789", "Score": "1", "body": "Often, when I see a `for-if` or a `foreach-if`, I assume there's a missing `Where`. When I see nested `for`s, I assume there's a missing `SelectMany`." } ]
[ { "body": "<p>You are correct in suspecting that the try/catch is not necessary. Generally speaking, Caesar ciphers are implemented using <a href=\"http://en.wikipedia.org/wiki/Modular_arithmetic\" rel=\"nofollow noreferrer\">modular arithmetic</a>. We can determine if a character is alphabetical by simply chec...
{ "AcceptedAnswerId": "40281", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T16:49:31.997", "Id": "40277", "Score": "12", "Tags": [ "c#", "caesar-cipher" ], "Title": "How can I improve this Caesar encryption?" }
40277
<p>How should I optimize my code for better performance? When I execute the code outside of MySQL stored proc, it is 500% faster. </p> <p>MySQL stored procedure</p> <pre><code>SELECT bs.business_id, adr.street, bs.`name`, bs.description, adr.latitude, adr.longitude FROM businesses bs INNER JOIN address adr ON bs.addr...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T19:18:59.480", "Id": "67817", "Score": "2", "body": "This question appears to be off-topic because it is not really asking for a code review. It is asking for and explanation why two pieces of code do not perform the same. I'm not...
[ { "body": "<p>After three days for research, I discovered that <code>CallableStatements</code> are much slower than prepared statements because there is overhead when setting up the stored procedure. That's why my stored proc takes 300ms+ vs the prepared statement.</p>\n\n<p><a href=\"http://oreilly.com/catalog...
{ "AcceptedAnswerId": "40540", "CommentCount": "7", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T18:38:59.217", "Id": "40285", "Score": "4", "Tags": [ "java", "performance", "mysql", "sql" ], "Title": "Optimize MySQL in a stored procedure" }
40285
<p>I am new to c#, and rather new to design-patterns. I want to create a simple and a most elegant solution for loading and validating a xml file and later on extracting its fields. I've started with a generic <code>IData</code> interface, that gets implemented by a <code>XmlFileData</code> class, but I feel that there...
[]
[ { "body": "<p>A few things:</p>\n<ol>\n<li><p><code>IData</code> is not a particularly good name for the interface as it represents a source of data rather than the data itself. Therefor <code>IDataSource</code> seems more appropriate.</p>\n</li>\n<li><p>The interface is a bit ambiguous - which method am I supp...
{ "AcceptedAnswerId": "40288", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T18:44:12.580", "Id": "40287", "Score": "11", "Tags": [ "c#", "design-patterns" ], "Title": "Simple specific classes design" }
40287
<p>I'm working with Codeigniter and I have a jQuery file to add some functionalities. But I think I'm doing it in a wrong way.</p> <pre><code>$(function() { var list = '../indoamericana/intranet/employeesList/'; var home = '../indoamericana/administrar/callHome/'; var profile = '../indoamericana/user/'; ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T20:14:51.400", "Id": "67828", "Score": "1", "body": "Why do you think it's the wrong way? It looks like a fairly ok jquery code to me. I'd prefer to use a more specific selector rather than `$(document)` for attaching the event hand...
[ { "body": "<ol>\n<li><p>Apart from the fact I can't find any use of <code>var loadPage</code> It doesn't need to be an expression.\nInstead try:</p>\n\n<pre><code>function loadPage(page) {\n}\n</code></pre>\n\n<p>It is still accessible only within your code here, it is cleaner and easier to debug.</p></li>\n<li...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T19:45:27.920", "Id": "40290", "Score": "5", "Tags": [ "javascript", "jquery", "codeigniter" ], "Title": "jQuery click handlers" }
40290
<p>Here is a method I have in my <code>ApplicationController</code>, but it's "ugly" and needs some cleanup. </p> <pre><code> def user_root_path return root_url unless user_signed_in? return admin_root_url if current_user.admin? return contributor_dashboard_url if current_user.athlete_contributor? &amp;&a...
[]
[ { "body": "<p>I would solve this with a combination of inheritance and duck typing. </p>\n\n<ul>\n<li>Use a base method on a <code>User</code> class <code>root_path</code> to be your entry point. </li>\n<li>Pull out that nasty \"signed out\" user concept to a <code>NullUser</code> object, it is safer than passi...
{ "AcceptedAnswerId": "40438", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T19:51:04.900", "Id": "40291", "Score": "1", "Tags": [ "ruby", "ruby-on-rails" ], "Title": "Refactoring method in ApplicationController for Rails App" }
40291
<pre><code>def getProxiesLstFromDB(): global g_proxies # insert to status page links table proxies_list = g_db["proxies_list"] proxies_list_records = proxies_list.find() print_to_log("get proxies list from db") for proxies_list_record in proxies_list_records: if proxies_list_record is no...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T00:21:00.193", "Id": "67862", "Score": "6", "body": "Could you give some explanation/background to this? Why it was written maybe. What times you are seeing for the amount of data you're processing. etc. etc." }, { "ContentL...
[ { "body": "<p>This is just one bit that jumped out at me:</p>\n\n<pre><code> page_text = page_html.decode(\"utf8\", \"ignore\")\n page_text = converter.handle(page_text)\n page_text = re.sub(\"[^a-zA-Z0-9_!]+[ ,.\\?!]\", \"\", page_text)\n</code></pre>\n\n<p>It seems you are converting as utf8, ignorin...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T20:41:48.720", "Id": "40296", "Score": "2", "Tags": [ "python", "performance", "http" ], "Title": "How to speed up Python web crawler?" }
40296
<p>Here is a method that takes two lists (<code>l1</code> and <code>l2</code>) and pairs up elements that "match". As you can see at the end of the code block these lists consist of matching elements but in different indexes. The method <code>pairUp</code> outputs matching elements paired up, and discards those without...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T21:49:23.237", "Id": "68174", "Score": "1", "body": "Simpler or faster, pick one. :)" } ]
[ { "body": "<p>A version that's probably no faster but slightly less verbose. I'm sure there's a much better way but it's a start:</p>\n\n<pre><code>case class A(serial: Int) {\n def matches(b: B): Boolean = this.serial == b.serial\n}\ncase class B(serial: Int)\n\ndef pairUp2(list1: List[A], list2: List[B]): Li...
{ "AcceptedAnswerId": "40300", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T20:52:59.633", "Id": "40297", "Score": "10", "Tags": [ "scala", "recursion" ], "Title": "Pair matching elements from two lists" }
40297
<p>When the user visits the web page and hovers over an album artwork, the title of the piece and the artist name appears. It leaves when the mouse leaves. I have achieved this with the following code: HTML:</p> <pre><code> &lt;img id="pic1" src=" "&gt; &lt;div class="info1"&gt; &lt;div class="name"&gt;artist&l...
[]
[ { "body": "<p>In your <code>hover</code> method you want to select the next two divs after the img. Assuming that the divs are located (in DOM) immediately after the img, then you can select them using the jQuery <a href=\"http://api.jquery.com/next/\">.next()</a> method, instead of selecting them by name.</p>\...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T22:00:07.010", "Id": "40301", "Score": "7", "Tags": [ "javascript", "jquery" ], "Title": "Can this code be cleaned? Multiple objects triggering different hover events" }
40301
<p>I am new to Java and wrote one small program. It works fine, but it looks like it doesn't meet OOP concepts. Could someone look and give me advice so that I can fine tune?</p> <pre><code>public class App { public static void main(String[] arg) { String str = new String( "]d0100361958...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T22:20:47.200", "Id": "67846", "Score": "0", "body": "\"but it's not like it should be\" - does this mean that it does not work as intended?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T22:25:10.167...
[ { "body": "<ul>\n<li><p>You consistently do <code>String foo = new String(\"some string\")</code>. This is useless, as <code>\"some string\"</code> already is a string. Simplify your code to <code>String foo = \"...\"</code>.</p></li>\n<li><p>You declare some variables far before you use them. Try to declare yo...
{ "AcceptedAnswerId": "40327", "CommentCount": "7", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T22:17:33.043", "Id": "40304", "Score": "8", "Tags": [ "java", "beginner", "strings" ], "Title": "Matching program in Java" }
40304
<p>I've got a conditional that sets a cookie based on whether a selector exists. There are other places in the code where I do something similar if the selector exists. If the selector exists I either add "nfl" or "nfl-" (notice the dash) to various attributes on the page. I'm trying to remove as much code as I can as ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T23:44:20.193", "Id": "67858", "Score": "0", "body": "<header> is an html5 element. Sorry the second conditional was suppose to be <footer>" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T23:47:48.503"...
[ { "body": "<p>Increase DRYness. Something like this:</p>\n\n<pre><code>var makeAnchor = function(prefix, suffix) {\n return \"#\" + prefix + suffix;\n}\n\nvar nflPrefix = \"nfl-\";\nif ($(\".userLocation\").length &gt; 0) { nflPrefix = \"nfl\"; }\n$('header').attr(\"href\", makeAnchor(nflPrefix, \"city\");\...
{ "AcceptedAnswerId": "40313", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T22:18:10.780", "Id": "40305", "Score": "3", "Tags": [ "javascript", "jquery" ], "Title": "Setting a cookie based on a selector" }
40305
<p>I am new to studying data structures although I have been programming in Java/Android since October. I feel it's time to advance, so I am starting data structures / algorithms this month. Since linked lists are a big topic in interviews and I knew nothing about them (I spent the past 3 days learning about it), hopef...
[]
[ { "body": "<p>This is a great first attempt with a consistent coding style and good variable names. Bravo!</p>\n\n<ul>\n<li><p>Consider implementing the <a href=\"http://docs.oracle.com/javase/7/docs/api/java/util/List.html\" rel=\"nofollow\"><code>java.util.List</code></a> interface so you could use it with ex...
{ "AcceptedAnswerId": "40328", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-28T23:38:34.000", "Id": "40311", "Score": "5", "Tags": [ "java", "linked-list" ], "Title": "Singly linked list implementation" }
40311
<p>My <code>Import</code> method takes some <code>data</code> and writes it to a stream. If the <code>CompressedStore</code> property is true, the contents of that stream should be compressed.</p> <p>This code works, however I just don't like it. For one, I call <code>serializer.Serialize()</code> twice. I feel thi...
[]
[ { "body": "<p>By default, <a href=\"http://msdn.microsoft.com/en-us/library/27ck2z1y\" rel=\"nofollow\"><code>GZipStream</code> owns the underlying stream, so it disposes it when it's disposed itself</a>. If you're okay with relying on that, then you could put the right <code>Stream</code> into a variable and t...
{ "AcceptedAnswerId": "40320", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T00:46:31.137", "Id": "40316", "Score": "4", "Tags": [ "c#", ".net" ], "Title": "Conditionally write to a compressed stream" }
40316
<p>This is a Python script I made to create a HTML page listing the source files in the current directory. The script creates a syntax highlighted preview of the files and lists some basic attributes.</p> <p>I would like to know if this is the best method to generate the HTML code? Is there a web development library ...
[]
[ { "body": "<p>There are a <a href=\"https://wiki.python.org/moin/Templating\" rel=\"nofollow\">ton of good template rendering libraries out there</a>, but I'd leave it to you to figure out if they are better suited to your needs than hand rolled code. </p>\n\n<p>Assuming you still want to write this yourself, I...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T00:56:07.217", "Id": "40317", "Score": "2", "Tags": [ "python", "html" ], "Title": "Create HTML listing of source code" }
40317
<p>This function is for multiplying two matrices together. It's kind of messed up because the result is actually supposed to overwrite the object that called it, or since it's <code>static</code>, it's supposed to overwrite the <code>left</code> object. Is there any way to make it faster or more readable? </p> <pre><c...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T03:47:47.460", "Id": "67885", "Score": "8", "body": "Is this code doing what it is supposed to be? It doesn't sound like it is..... in which case you should take this to [so], not here on CodeReview. See the [help/on-topic] for guid...
[ { "body": "<p>For improving readability, you could perhaps replace the for-loop variable names with more descriptive names, such as 'currentColumn' and 'currentRow.'</p>\n\n<p>For performance, you can replace 'x++' with '++x' in every loop. 'x++' actually creates a copy of x, increments x, and returns the copy....
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T01:10:59.887", "Id": "40318", "Score": "-1", "Tags": [ "java", "mathematics", "matrix" ], "Title": "Matrix multiplication of arbitrary sizes" }
40318
<p>I have created this piece of js purely for learning purposes and I was hoping you could code review to see any mistakes / improvements I can make.</p> <p>Basically I have a tree structure and I will use the depth variable to work out what level of the menu I will display.</p> <p>Here is the code example: <a href="...
[]
[ { "body": "<p>It would be much easier just to let the CSS selector engine select the elements to hide:</p>\n\n<pre><code>var hideDepth = function(root, depth) {\n root.find('ul').show(); // Make sure all sublists are visible \n var selector = Array(depth + 1).join(' &gt; li &gt; ul'); // Repeat string\n r...
{ "AcceptedAnswerId": "40368", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T05:16:49.913", "Id": "40330", "Score": "5", "Tags": [ "javascript", "jquery", "tree" ], "Title": "Hide the tree menu at a certain depth" }
40330
<p>I was trying to write a Java program to compare previous records while traversing. It returns true if element exists previously, else false.</p> <p>e.g.</p> <ul> <li>if elements are <code>{"Raj","Jas","Kam","Jas"}</code> then return <code>true</code> (since <code>Jas</code> element available previously)</li> <li>i...
[]
[ { "body": "<p>You can actually change the performance to <code>O(n)</code> by changing one line of code here (and adding a couple of imports):</p>\n\n<pre><code>import java.util.Set;\nimport java.util.HashSet;\n\n...\n\nprivate Set&lt;String&gt; listTempName = new HashSet&lt;&gt;();\n</code></pre>\n\n<p>Althoug...
{ "AcceptedAnswerId": "40334", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T06:21:20.457", "Id": "40333", "Score": "3", "Tags": [ "java", "performance", "iteration" ], "Title": "Improve performance while Traversing List" }
40333
<ol> <li>What is more readable? <code>value / 60 / 60</code>, <code>value / 3600</code>, or <code>Hours{static_cast&lt;Minutes&gt;(*this).value / 60}</code>? Should I use constants, i.e. <code>SECONDS_IN_HOURS</code>.</li> <li>Should I use the <code>explicit</code> keyword? Would it actually prevent stupid mistakes/sil...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T10:25:44.927", "Id": "67925", "Score": "1", "body": "[Josay's answer below](http://codereview.stackexchange.com/a/40343/34757) is similar to the answers given for a different but similar question, [Type system for different represen...
[ { "body": "<p>1) For readability, I'd go with explicitly using the single conversion constants instead of lumping them together: </p>\n\n<pre><code>const int uptimeHours = uptimeMSecs / 1000 / 60 / 60;\n</code></pre>\n\n<p>Possibly off-topic, but I would probably do away with all these structs and auto-convers...
{ "AcceptedAnswerId": "40343", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T07:09:20.883", "Id": "40336", "Score": "4", "Tags": [ "c++", "c++11", "datetime", "converting" ], "Title": "Mutual conversion operators" }
40336
<p>I have a nested JSON of multiple levels. The last level has the "series data" that is to be added to the highcharts options to render the chart data of interest.</p> <p>I am sniffing the JSON and populating the options in each level which is set as a watched model in the controller and modifying the chart data, whi...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T09:29:13.677", "Id": "68282", "Score": "0", "body": "btw, instead of `function() { return scope.chartData; }` as a watcher target, it is valid to just put the string \"chartData\", and of course easier to read." }, { "Conten...
[ { "body": "<p>It's difficult to tell from these snippets exactly what you're trying to achieve, but I think the questions you have to ask are; how do you anticipate reusing this code? If reusability is the feature, what are the use cases?</p>\n\n<p>If you anticipate needing multiple distinct controllers with a ...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T07:22:14.370", "Id": "40337", "Score": "3", "Tags": [ "javascript", "angular.js" ], "Title": "Structuring a reusable angular component with multiple communicating directives" }
40337
<p>Here is the <a href="http://jsfiddle.net/P7b9S/66/" rel="nofollow">link to fiddle</a>. This is my first app using Dojo. Any comments/feedback is highly appreciated.</p> <pre><code>dojoConfig = {parseOnLoad: true}; resetStopwatch(); require(["dijit/form/ToggleButton", "dijit/form/Button", "dojo/dom", "dojo/dom-att...
[]
[ { "body": "<p>I tinkered a bit with the fiddle, I have the following observations:</p>\n\n<ul>\n<li><p>If you were to place the colons in the HTML, then you would no longer need to concatenate the colons into the time fields:</p>\n\n<blockquote>\n<pre><code>&lt;div id=\"stopwatch\"&gt; \n &lt;span id=\"hours\"...
{ "AcceptedAnswerId": "40367", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T08:32:17.997", "Id": "40339", "Score": "5", "Tags": [ "javascript", "datetime", "dojo" ], "Title": "Stopwatch app using Dojo" }
40339
<p>Here is an API for using a warehouse:</p> <pre><code>public static class WarehouseClient { event Action&lt;IWarehouse&gt; WarehouseCreated; } public interface IWarehouse { event Action&lt;IWarehouseSession&gt; NextSession; IWarehouseSession Session { get; } WarehouseInfo Info { get; } } public i...
[]
[ { "body": "<ol>\n<li><p>You definitely want to document those interfaces.</p></li>\n<li><p><code>WarehouseClient</code> should probably not be a static class.</p></li>\n<li><p>The name of the <code>NextSession</code> event in <code>IWarehouse</code> doesn't really mean anything to me. Just from reading the inte...
{ "AcceptedAnswerId": "40346", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T08:54:51.997", "Id": "40340", "Score": "2", "Tags": [ "c#", "object-oriented", "api", "interface", "library-design" ], "Title": "Backend interface VS hard contract" }
40340
<p>I want to get the source of these files, but I don't know if I'm efficient.</p> <p>I get the source of the file, put the source in a <code>list</code>, so I put this in a <code>hashmap</code> with the key is the <code>version</code> of file and the <code>values</code> are the <code>list</code>.</p> <pre><code>priv...
[]
[ { "body": "<ol>\n<li><p>Instead of <code>Map&lt;String, List&lt;String&gt;&gt;</code> you could use Guava's <code>Multimap</code> (<a href=\"https://code.google.com/p/guava-libraries/wiki/NewCollectionTypesExplained#Multimap\" rel=\"nofollow noreferrer\">doc</a>, <a href=\"http://docs.guava-libraries.googlecode...
{ "AcceptedAnswerId": "40382", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T10:31:43.750", "Id": "40347", "Score": "6", "Tags": [ "java", "properties", "hash-map" ], "Title": "How to refactor this code to get a source from property files?" }
40347
<p>Here is a <a href="http://jsfiddle.net/N355H/1/" rel="nofollow">JSFiddle</a> of an accordion menu that i've done. I have used <code>:before</code> to add the icons.</p> <p>My question is, is there a better way to Add different icon to each <code>li</code> item?</p> <p>My code is as follows:</p> <p>HTML Structure:...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T10:42:53.190", "Id": "67927", "Score": "1", "body": "It is good that you linked to a *demo* of the code, but we can only review code that's inside the question itself. Please [edit] your question to include the relevant code." } ]
[ { "body": "<p>First things first: You have a navigation but refuse to use anchor tags. Why? This is potentially harmful. How are you going to <em>navigate</em> if you don't have links? The only possible way would be completely relying on JavaScript. All users with disabled JavaScript have a useless list of word...
{ "AcceptedAnswerId": "40354", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T10:35:05.640", "Id": "40349", "Score": "2", "Tags": [ "javascript", "optimization", "html", "css" ], "Title": "Better way to use pseudo elements" }
40349
<p>I'm using the <a href="https://github.com/chuyskywalker/rolling-curl" rel="nofollow">rolling curl</a> library to fire HTTP requests for content-length headers of images (we need to know their size to weed out placeholders and low res images). The image URLs are stored in a database so I need to loop over the data in...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T16:27:43.630", "Id": "68111", "Score": "0", "body": "Not to nitpick, but you have a very odd, if non-existent, coding style." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T16:44:18.550", "Id": "6...
[ { "body": "<p>Give this a try and post the results - it integrates PHPBenchTime laps and get_memory_usage() with your script.</p>\n\n<p>\n\n<pre><code>require('PHPBenchTime.php');\nuse PHPBenchTime\\Timer as Timer;\n\npublic function fire(){\n $Benchmark = new Timer;\n $Benchmark-&gt;Start();\n\n $dt =...
{ "AcceptedAnswerId": null, "CommentCount": "11", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T10:44:31.297", "Id": "40351", "Score": "7", "Tags": [ "php", "performance", "http", "networking", "concurrency" ], "Title": "Concurrent HTTP request loop" }
40351
<p>Obviously, you have to test mapping code somehow, even (or especially) if you use AutoMapper. Is there any way to make it less verbose?</p> <pre><code>[Test] public void Map_Always_SetsSimpleProperties() { var auctionPlace = fixture.Create&lt;string&gt;(); var submissionCloseDateTime = fixture.Create&lt;DateTim...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T11:34:35.757", "Id": "68300", "Score": "1", "body": "If you put one assertion per test it doesn't look that verbose." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2017-10-27T08:41:31.413", "Id": "339662", ...
[ { "body": "<p>Unfortunately, I don't think so.</p>\n\n<p>There is <a href=\"http://dozer.sourceforge.net/documentation/faq.html#dozer-unit-tests\" rel=\"nofollow\">a question about this topic on the website of Dozer</a> (which is a similar library for Java) which mentions a trick:</p>\n\n<blockquote>\n <p><str...
{ "AcceptedAnswerId": "40403", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T10:47:34.913", "Id": "40352", "Score": "7", "Tags": [ "c#", "unit-testing", "automapper" ], "Title": "Testing mapping code" }
40352
<p>If have the following code that via an SQL query retrieves data from a database in the form:</p> <pre class="lang-none prettyprint-override"><code>Id subschemaName locusName MLST MLST LMO0558 MLST MLST LMO0563 MLVST MLVST LMO1305 MLVST MLVST LMO1089 </code></pre...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T15:48:13.900", "Id": "67961", "Score": "0", "body": "You could certainly be using Linq-to-Sql rather than hard coding sql strings. The result could then be easily transformed into Linq-to-Xml objects, though I definitely don't under...
[ { "body": "<p>Since your data is already sorted you definitely don't need to use a dictionary. You can just accumulate <code>loci</code> and then whenever the <code>id</code> or <code>subschemaId</code> rolls over you write them all out. That wouldn't be a huge change from what you've got. But honestly, what yo...
{ "AcceptedAnswerId": "40486", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T11:06:35.520", "Id": "40353", "Score": "3", "Tags": [ "c#" ], "Title": "Refactor C# code for creating XML to not use intermediate dictionary" }
40353
<p>We have a table with calculated data that groups sales by product, year and month, to provide fast querying for statistics.</p> <p>My colleague argues that the year and month should be two separate fields, because a day is meaningless.</p> <p>I want it as a date field, because using two separate fields leads to aw...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T12:27:33.107", "Id": "67938", "Score": "0", "body": "Does the information come from a database or where does it come from? If it's a database, which kind of RDMS is it?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDa...
[ { "body": "<p>In general it really depends on the use cases of your data. If you need to perform queries using just year or just month then you reduce complexity in the code and queries by having separate fields.</p>\n\n<p>However, if you aren't bounding by just a year or just a month then you would want to us...
{ "AcceptedAnswerId": "40358", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T12:19:28.963", "Id": "40356", "Score": "8", "Tags": [ "c#", "linq", "sql-server", "entity-framework", "datetime" ], "Title": "Should a year and month be stored as separ...
40356
<p>In my program(C++), I'm going to use callback functions to process input from the keyboard and mouse and constantly draw a scene. How these functions process information will change depending on the state of the program; like I would have certain functionality assigned to several keys, say the arrow keys move the hi...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T13:21:58.550", "Id": "67947", "Score": "1", "body": "It's C++. I changed the tag and I'll add it in the body of the question." } ]
[ { "body": "<blockquote>\n <p>My question is: are there any performance issues with the conditional functions approach?</p>\n</blockquote>\n\n<p>In a word: no.</p>\n\n<p>The additional performance cost is an extra <code>select</code> statement, whose cost probably depends on the number of <code>switch</code> op...
{ "AcceptedAnswerId": "40363", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T13:17:00.670", "Id": "40362", "Score": "2", "Tags": [ "c++", "callback" ], "Title": "Conditional functions or multiple similar definitions?" }
40362
<p>I have learned the question of solving Angular app optimization for search engines, and was frustrated that the most recommended option is <strong>prerendering</strong> HTML.</p> <p>After some time spent, I suggested to create a directive that will load the bot after rendering templates or update <strong>scope</str...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-19T20:22:00.303", "Id": "77931", "Score": "0", "body": "Do you make the difference between the google bot and google analytics? The googlebot (search engine) is not executing the javascript (at least most of the time it is not...). Thi...
[ { "body": "<p>As you found yourself, this has to work.</p>\n\n<p>I only have 2 minor nitpickings:</p>\n\n<ul>\n<li>Do not use <code>console.log()</code> in production code..</li>\n<li>You are not using <code>element</code> and <code>attrs</code>, you might as well declare <code>function($scope)</code></li>\n</u...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T13:42:28.943", "Id": "40364", "Score": "7", "Tags": [ "javascript", "optimization", "angular.js", "web-scraping" ], "Title": "AngularJs and Google Bot experiment" }
40364
<p>I wanted to write a small but non-trivial function in OCaml to test my understanding. I have only a basic understanding of the libraries, and no idea at all of what is considered good style. The function computes all combinations of size <code>k</code> from a list, where <code>0 &lt;= k &lt;= length lst</code>.</p> ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-07-19T10:23:07.113", "Id": "102715", "Score": "0", "body": "Like many, I tend to align the rhs of match arrows, but this style is actually discouraged from the official guidelines: http://caml.inria.fr/resources/doc/guides/guidelines.en.h...
[ { "body": "<p>Your <code>tails</code> is very beatiful, your <code>is_empty</code> useless, and <code>combnk</code> a mess.</p>\n\n<p>In <code>combnk</code>, your indentation obfuscates the actual structure of the code. Here is a better indentation:</p>\n\n<pre><code>let rec combnk k lst =\n if k = 0 then\n ...
{ "AcceptedAnswerId": "40380", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T14:14:40.107", "Id": "40366", "Score": "8", "Tags": [ "recursion", "functional-programming", "ocaml" ], "Title": "Combinations of size k from a list in OCaml" }
40366
<p>The intent of this script is to hunt down all <code>"*/testResults/*.xml"</code> files and touch them, so that our build system doesn't issue errors that the files are too old (it's entirely intentional that tests are only re-run when the libraries they change have been modified)</p> <pre><code>import fnmatch impor...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T01:22:01.543", "Id": "68020", "Score": "0", "body": "I don't think recursion is a good solution for this problem at all. You're initial solution is better." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01...
[ { "body": "<p>Python seems like overkill here: this is surely a job for the shell? Depending on exactly which files you want to touch, then use this:</p>\n\n<pre class=\"lang-sh prettyprint-override\"><code>touch -- */testResults/*.xml\n</code></pre>\n\n<p>or this:</p>\n\n<pre class=\"lang-sh prettyprint-overri...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T15:35:51.947", "Id": "40370", "Score": "3", "Tags": [ "python", "recursion", "file-system", "windows" ], "Title": "Python script to touch files of a particular pattern in all ...
40370
<p>I'm relatively new to unit testing and having gone through quite a bit of pain I was starting to feel pretty good about my tests. The problem is, now I have a nice set of green ticks I'm also suffering from the nagging doubt that it's just giving me a false sense of security and is in fact just a waste of time. </p>...
[]
[ { "body": "<p>I agree with what you said, i.e.:</p>\n\n<blockquote>\n <ul>\n <li><p>The only thing which can break these tests is a change to this specific method and surely if anybody is changing this method they are\n doing so with good reason, and all I've done is given them an extra\n job of changing th...
{ "AcceptedAnswerId": "40375", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T15:40:07.143", "Id": "40371", "Score": "2", "Tags": [ "javascript", "unit-testing", "physics", "jasmine" ], "Title": "Calculate the physical centre" }
40371
<blockquote> <p>As written, getint treats a + or - not followed by a digit as a valid representation of zero. Fix it to push such a charachter back on the input.</p> </blockquote> <p>Before the <code>for</code> I check if the charachter after the + or - is a number. If it is, the function will store the representati...
[]
[ { "body": "<ol>\n<li><p>The method modifies the parameter while it is processing input. It should store the processing result locally and then assign it once it is finished.</p></li>\n<li><p>It is unclear what the return value of the method means just by reading the code. If it is supposed to indicate success (...
{ "AcceptedAnswerId": "40399", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T16:03:04.990", "Id": "40373", "Score": "2", "Tags": [ "c" ], "Title": "getint that properly handles + or - signs" }
40373
<p>I have the following method in Ruby that appears to be just one line too long according to Ruby style guides. (Specifically: Rubocop tells me that my method has too many lines.)</p> <p>Granted, I'm only one over the apparent allowed "limit" but in the interests of seeing if the style guides are realistic, I'm tryin...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T18:00:54.317", "Id": "67975", "Score": "0", "body": "What is `spec_repo` and `spec_type`? If they operate on something external, shouldn't they be parameters? Or are they methods on `self`?" }, { "ContentLicense": "CC BY-SA ...
[ { "body": "<p>Unless I'm misinterpreting your code, you should be able to get by with something like this:</p>\n\n<pre><code>def spec_context\n directories = spec_repo.select { |path| File.directory?(path) }\n files = directories.map do |dir|\n spec_type.map { |type| Dir[\"#{dir}/**/*.#{type}\"].sort }\n ...
{ "AcceptedAnswerId": "40392", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T16:25:35.313", "Id": "40376", "Score": "4", "Tags": [ "ruby", "file-system" ], "Title": "Shorten code that gathers files from directories" }
40376
<p>I have various types of EF entities, all of them have a navigation property called "Employee". When generating reports the user will have the option to filter the report according to the different employee properties (Cost Center, gender, etc.). </p> <p>Something like this:</p> <pre><code>var courses = context.Cou...
[]
[ { "body": "<p>I think you might run into some design ugliness with the in the future because you are now coupling the knowledge that an entity could be filtered by a certain property to each entity.</p>\n\n<p>Imagine a requirement comes in to filter by <code>Course</code> - what would that look like in your des...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T16:51:56.870", "Id": "40378", "Score": "4", "Tags": [ "c#", "linq", "entity-framework", "generics", "extension-methods" ], "Title": "A genric extension method to filter Li...
40378
<blockquote> <p>Write getfloat, the floating-point analog of getint. What types does getfloat return as its function value?</p> </blockquote> <p><code>gefloat</code> would also return an integer value. Here is my solution:</p> <pre><code>int getfloat(double *pf) { int c, sign; double power; while(isspa...
[]
[ { "body": "<ol>\n<li><p>It obviously does not handle <code>NAN</code> and <code>INF</code>. Maybe outside code's goals.</p></li>\n<li><p>Surprisingly does not handle exponential notation such as 1.23e+56.</p></li>\n<li><p><code>if(!isdigit(c) &amp;&amp; c != '.') {</code> returns a <code>0</code> implying \"no...
{ "AcceptedAnswerId": "41191", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T17:21:43.983", "Id": "40379", "Score": "7", "Tags": [ "c", "parsing", "floating-point" ], "Title": "getfloat, the floating point analog of getint" }
40379
<p>Is the following good design for doing entity framework code first? What am I missing for a production system? I haven't included all my code, just a snapshot...</p> <p>My application, doesn't update the database; it just reads it. </p> <pre><code>public class Document { [Key, ScaffoldColumn(false)] public...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T17:52:01.823", "Id": "67970", "Score": "0", "body": "What makes you think you're missing anything for a production system?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T17:54:21.460", "Id": "679...
[ { "body": "<p>If you chose the code-first approach, I presume you don't have to deal with the constraints of an existing database. If that assumption is correct, then I'd say you've done it the hard way.</p>\n\n<p><strong>Convention Over Configuration</strong></p>\n\n<p>Entity Framework can infer keys (primary ...
{ "AcceptedAnswerId": "40424", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T17:38:50.413", "Id": "40381", "Score": "4", "Tags": [ "c#", "sql-server", "entity-framework" ], "Title": "Code First Entity Framework" }
40381
<p>I'm designing a table cell based map design for a little game I'm building, and I was hoping I could get some cleanup pointers or design tips to "perfect" my engine's design. Basically, in the end result, you'll walk around the map one tile at a time. On any visible tile you can walk to it, but only the tile you're ...
[]
[ { "body": "<p>I'm afraid your code is very hard to understand. Part of the problem is your variable naming: I'm not sure what exactly <code>p_x</code> is and what distinguishes it from the <code>x</code> that's part of the <code>Map</code> object, for example. It also doesn't help that your comments mostly ju...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T18:10:45.780", "Id": "40385", "Score": "3", "Tags": [ "javascript", "game" ], "Title": "Table cell map engine" }
40385
<p>I wanted a hash which lets me reference Japanese syllables by their romanized names. In hindsight I could have searched for an existing one column table, but I wanted to improve my ruby by writing a function which serializes these multi-column tables I found on wikipedia:</p> <pre><code> katakana: v_eng: a i u e...
[]
[ { "body": "<p>Feedback:</p>\n\n<ul>\n<li>Instead of <code>||= lambda { ... }.call</code>, you can use <code>||= begin ... end</code></li>\n<li>Instead of <code>Hash[*arr]</code> you can use <code>arr.to_h</code> in Ruby 2.0+</li>\n<li>You don't need to convert everything to a hash if you just want to use it for...
{ "AcceptedAnswerId": "40617", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T19:16:47.470", "Id": "40389", "Score": "3", "Tags": [ "ruby", "iterator", "serialization" ], "Title": "Serializing tabular data in ruby -- is map, flatten, hash the correct app...
40389
<p>I've implemented CTR mode by myself (only decryption for now), using only AES built-in functions from pycrypto. It means that I'm not supposed to use mode=AES.MODE_CTR. However, I know that using AES.MODE_CTR would be more simple, but I'm doing this as a learning experience.</p> <p>Is it a safe AES CTR??</p> <p>(n...
[]
[ { "body": "<p>I couldn't spot any problems with your implementations, but caveat lector: I'm not a cryptography expert, so take that with an appropriate pinch of salt.</p>\n\n<p><s>I'm also concerned about the output:</p>\n\n<pre class=\"lang-none prettyprint-override\"><code>$ python reinvent.py\nmsg = CTR mod...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T20:38:51.593", "Id": "40393", "Score": "5", "Tags": [ "python", "reinventing-the-wheel", "cryptography", "aes" ], "Title": "AES CTR mode using pycrypto" }
40393
<p>It's possible to work out the number of moves required to move from (0, 0) to (A, B) for a knight on an infinite chess board in O(1) time.</p> <p>This is an attempt at a solution to do it in O(n) time, where n is the number of moves required.</p> <pre><code>#define ABS(a) ({ typeof (a) _a = (a); _a &gt; 0 ? _a : -...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T22:05:29.030", "Id": "68000", "Score": "0", "body": "We are only considering one knight on this infinite chessboard, right? That's what I'm assuming since collisions with other chess pieces wouldn't be legal." }, { "Content...
[ { "body": "<p>A few notes (with efficiency aside, as you said):</p>\n\n<ul>\n<li><p>Your defined <code>ABS</code> surrounded by parenthesis is <a href=\"https://stackoverflow.com/q/154136/1937270\">not the usual way that C programmers declare macros</a> so that they aren't problematic.</p>\n\n<pre><code>#define...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2014-01-29T21:14:56.200", "Id": "40394", "Score": "23", "Tags": [ "c", "pathfinding" ], "Title": "Calculate the number of moves requires for a knight chess piece" }
40394
<ul> <li>Official site: <a href="http://automapper.org/" rel="nofollow">http://automapper.org/</a></li> <li>Stack Overflow tag wiki: <a href="http://stackoverflow.com/tags/automapper/info">http://stackoverflow.com/tags/automapper/info</a></li> </ul>
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T22:02:32.840", "Id": "40400", "Score": "0", "Tags": null, "Title": null }
40400
A convention-based object-to-object mapper and transformer for .NET.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T22:02:32.840", "Id": "40401", "Score": "0", "Tags": null, "Title": null }
40401
<p>This is my solution for the <a href="http://projecteuler.net/problem=5" rel="nofollow">5th problem of Project Euler</a>, which asks for the least common multiples of the numbers from 1 to 20 (inclusive). Is there any way to improve the while loop conditional instead of using the sum?</p> <pre><code>table = range(1,...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T13:58:52.110", "Id": "68080", "Score": "0", "body": "are you interested in a functional solution without loops?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T16:53:48.740", "Id": "68123", "S...
[ { "body": "<p>Use a constant. It's easier to understand when you want to go back and try a different value too.</p>\n\n<p>Copying my answer from stack overflow, also changed things around since this is code review.</p>\n\n<pre><code>MAX_FACTOR = 20 #The largest divisor we want to be able to divide by\n\n#should...
{ "AcceptedAnswerId": "40445", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T22:21:45.123", "Id": "40402", "Score": "2", "Tags": [ "python", "optimization", "project-euler" ], "Title": "Optimizing Python code for Project Euler #5 (LCM of all numbers fro...
40402
<p>I'm curious to see what any of the more experienced programmers would do instead of methods I took as a learning tool. Any tips/tricks/fixes and reasoning is appreciated!!</p> <p><a href="http://www.jacobweyer.com" rel="nofollow">http://www.jacobweyer.com</a></p> <p>This is the result of the code so far:</p> <pre...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T23:53:18.470", "Id": "68015", "Score": "0", "body": "[I think your code looks fine.](http://meta.codereview.stackexchange.com/a/96/34757)" } ]
[ { "body": "<p>I see no problems with it. However, at the HTML section, try adding maybe 2 lines of blank space in between the all of the divs. An example lies below.</p>\n\n<pre><code>&lt;div id=\"pagecenter\"&gt;\n\n\n&lt;/div&gt;\n\n\n&lt;div id=\"footer\"&gt;\n\n\n&lt;div id=\"footercontent\"&gt;\n\n\n&lt;di...
{ "AcceptedAnswerId": "40410", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-29T22:41:12.147", "Id": "40407", "Score": "6", "Tags": [ "html", "css" ], "Title": "How would you better organize/code this basic HTML and CSS?" }
40407
<p>I'm building an installer package for our software using Inno Setup. As a part of this, I'm also building a few different DLL's in Delphi XE2 to accommodate for some of the common tasks required by the installer. One of those is querying and manipulating settings on these instances. I intend to support SQL versions ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-02-09T20:40:22.807", "Id": "70872", "Score": "0", "body": "<Review>Although registry are tasty piece of cake, I would strongly recommend you to use [`WMI`](http://msdn.microsoft.com/en-us/library/ms180499.aspx) for your task. That's many ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T00:48:55.767", "Id": "40413", "Score": "2", "Tags": [ "sql-server", "windows", "delphi" ], "Title": "Installer package using Inno Setup" }
40413
<p>I need help cleaning up this piece of code.</p> <pre><code>if is_complete == true #If there are time stamps get between time stamps if start_date &amp;&amp; end_date tasks = Task.find(:all, :include =&gt; [:task_observer, :job, :contact], :conditions =&gt; ["contact_id = ? and completed_date IS NOT NULL and...
[]
[ { "body": "<ol>\n<li>you can replace <code>if is_complete == true</code> with <code>if is_complete</code></li>\n<li>the only thing that changes is <code>:conditions</code>, <code>tasks = ...</code> should not be inside the if/else</li>\n<li>the 3rd case is invalid: <code>completed_date</code> can't be <code>NUL...
{ "AcceptedAnswerId": "40443", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T01:12:24.653", "Id": "40415", "Score": "2", "Tags": [ "ruby", "datetime", "ruby-on-rails", "active-record" ], "Title": "Task observer implementation" }
40415
<p>I'm writing a small guessing game. I'm writing a points calculation algorithm.</p> <p>I wrote the following, and it works. But I feel like I'm bringing over procedural background into Ruby, or not leveraging Ruby properly.</p> <p>How would an experienced Ruby programmer approach the problem? You can test the code ...
[]
[ { "body": "<p>Assuming your lists are already sorted by the ID and contain results/guesses for exactly the same ID you can do:</p>\n\n<pre><code>r.zip(g).each do |result, guess|\n score = {}\n #...\nend\n</code></pre>\n\n<p>This dramatically reduces runtime from quadratic to linear time. If they are not a...
{ "AcceptedAnswerId": "40441", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T01:13:21.307", "Id": "40416", "Score": "5", "Tags": [ "algorithm", "ruby", "game" ], "Title": "Small guessing game in Ruby" }
40416
<p>This takes a width specified by user and prints a diamond of that width. It uses only three <code>for</code> loops, but could I reduce that further? Is there a more elegant solution?</p> <pre><code>public class Diamond { static boolean cont = true; public static void main (String[] args) { Scanne...
[]
[ { "body": "<p>There are a few things that we can do to clean this up.</p>\n\n<ul>\n<li><p>This is something I would extract to its own method. Handle getting the user input in the <code>main()</code> method, and then pass that on to the <code>drawDiamond()</code> method.</p></li>\n<li><p>Your <code>for</code> ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T01:58:30.037", "Id": "40417", "Score": "31", "Tags": [ "java", "console" ], "Title": "Print an ASCII diamond" }
40417
<p>I need a review on this. This code will read a 2D matrix bar code, which I hard-coded as a string <code>str</code>. It has "]d" starting string, which is a GS1 International body Bar Code spec. after that. It has information about Item Number, Serial Number, Locator Information. This code will read the entire st...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T08:54:54.230", "Id": "68053", "Score": "3", "body": "I looked at [@amon's answer to your previous question](http://codereview.stackexchange.com/a/40308/20251). You haven't followed that advice nearly enough. And a new review to be t...
[ { "body": "<p>Either your interpretation of the specification is incorrect, or I'm looking at the wrong specs. <a href=\"http://www.gs1.org/barcodes/support/prefix_list\" rel=\"nofollow\">GS1 country codes</a> are three digits, not two. Indeed, you disregard the character after your \"two digit\" country code...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T02:52:30.957", "Id": "40421", "Score": "3", "Tags": [ "java", "strings", "parsing", "validation" ], "Title": "Reading and validating 2D matrix bar code" }
40421
<p>This is my tentative solution to:</p> <p><a href="https://codereview.meta.stackexchange.com/questions/1376/how-can-i-prepare-my-code-so-that-i-can-paste-it-formatted">How can I prepare my code so that I can paste it formatted?</a></p> <p>If you need to copy and paste code into the question or answer textarea when ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T15:41:13.247", "Id": "68095", "Score": "0", "body": "Hmm, your code is 20K+ characters, IE9 will only accept up to 5K." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T21:06:14.143", "Id": "68167",...
[ { "body": "<blockquote>\n <p>It was originally going to have a \"just turn the tabs into spaces\" mode, which is why you see it messing with tab/space alignment. Is this a feature that would be useful? It would take trivial effort to implement.</p>\n</blockquote>\n\n<p>That feature might be useful on this site...
{ "AcceptedAnswerId": null, "CommentCount": "9", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T03:44:48.880", "Id": "40422", "Score": "10", "Tags": [ "javascript", "jquery", "formatting", "stackexchange", "bookmarklet" ], "Title": "Tool for automatically correcting ...
40422
<p>Below is the method that I have written for reading from a text file. While reading, I need to match a line string to a given regex, and if it matches, I need to add the line string to a collection.</p> <pre><code>private static void GetOrigionalRGBColours(string txtFile) { string tempLineValue; Regex rege...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T13:15:43.557", "Id": "68072", "Score": "0", "body": "It might be useful to profile the difference between matching the Regex then calling split vs. matching a capturing Regex, and converting its capture groups." }, { "Conten...
[ { "body": "<p>First, a sample of the input data would be helpful for testing. That said:</p>\n\n<ul>\n<li>If you're using .NET 4 or greater you can use the\n<a href=\"http://msdn.microsoft.com/en-us/library/dd383503%28v=vs.110%29.aspx\">File.ReadLines()</a> method to read all the lines at once which may speed t...
{ "AcceptedAnswerId": "40452", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T03:45:24.383", "Id": "40423", "Score": "10", "Tags": [ "c#", "performance", ".net", "parsing", "regex" ], "Title": "Reading from text file with RegexMatch" }
40423
<p>Is this a correct method of Fibonacci with recursion?</p> <pre><code>function fibb($limit,$first_numer=0,$second_number=1){ echo $first_numer."\n"; echo $second_number."\n"; if($limit &gt; 0){ fibb($limit-2,$first_numer+$second_number,($first_numer+$second_number+$second_number))...
[]
[ { "body": "<p>I think that programmers can write code with their own logic. You should get the correct output (with less code, which is great).</p>\n\n<p>There are many ways to do the same, such as:</p>\n\n<pre><code>&lt;?php\nfunction fibonacci ($n)\n{\n if ($n == 0) {\n return 0;\n }\n else if ($n ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T04:30:14.347", "Id": "40426", "Score": "5", "Tags": [ "php", "fibonacci-sequence" ], "Title": "Is this Fibonacci function right?" }
40426
<p>This code will accept user input from the command line.</p> <p>The first user can enter the limit of series.</p> <p>e.g: user may enter 5</p> <p>After that, the user will be prompted for 5 numbers of a series.</p> <p>e.g:</p> <p>2 4 8 10 12</p> <p>Here in this series, 6 is missing, so I am going to find the mi...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T10:27:55.743", "Id": "68289", "Score": "0", "body": "is it possible for more than 1 values to be missing? are series of 1 allowed? Are you considering negatives/invalid input?" } ]
[ { "body": "<p>Right, I'd fill in the missing values like so:</p>\n\n<pre><code>//assume\n$series = array(2,4,8,10,12);\n$count = 5;\n//get step-size:\n$step = floor((max($series) - min($series))/$count);\n//then check/complete series:\n$complete = array($series[0]);//first element is valid\nfor($i=1, $j=count($...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T04:41:28.543", "Id": "40428", "Score": "5", "Tags": [ "php" ], "Title": "Finding missing number from series" }
40428
<p>My code snippet is like this:</p> <pre><code>public static string EventId { get { return HttpContext.Current.Request["eventId"]; } } </code></pre> <p>And I will call this property <code>EventId</code> whenever I need it. Is it a good practice?</p>
[]
[ { "body": "<p>Can you guarantee that <code>eventId</code> will never change? If so it might not be a bad idea, but this comes down to a few things</p>\n\n<ul>\n<li><code>eventId</code> never changes;</li>\n<li>how and where you're using it. It might be somewhat difficult for a new programmer in the project to l...
{ "AcceptedAnswerId": "40436", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T05:41:16.467", "Id": "40430", "Score": "2", "Tags": [ "c#", "asp.net" ], "Title": "Is it a good idea to keep Request querystring as a property?" }
40430
<p>The configuration file of my app is similar to,</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;Items&gt; &lt;Item Name="Coffee" Cost="10" Image="itemCoffee.png" /&gt; &lt;Item Name="Tea" Cost="10" Image="itemTea.png" /&gt; &lt;Item ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T01:46:41.463", "Id": "68223", "Score": "5", "body": "If that XML is really the *configuration file of your app*, I think you've missed an opportunity to leverage [*.net application settings*](http://msdn.microsoft.com/en-us/library/...
[ { "body": "<ol>\n<li><p>I would definitely wrap the FileStream object into a using clause like this:</p>\n\n<pre><code>using (Stream reader = new FileStream(filePath, FileMode.Open))\n{\n var serializer = new System.Xml.Serialization.XmlSerializer(typeof(T));\n return (T)serializer.Deserialize(reader);\n}\n</...
{ "AcceptedAnswerId": "40435", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T07:00:04.647", "Id": "40434", "Score": "5", "Tags": [ "c#", ".net" ], "Title": "Reading a configuration file in c#" }
40434
<p>I'm writing an application that will be managed by my team, it uses Mustache.php as template engine.</p> <p>I have a PHP file that makes an array of variables and functions that is passed to the Mustache parser to populate the template.</p> <p>I even provide a system to override partials of my template to edit the...
[]
[ { "body": "<p>I don't know anything about Mustache, so just a note about the code: <code>$_SERVER['BASE_DIR'] . '/customcontents/'. $username . '.php'</code> is duplicated, it could be extracted out to a local variable:</p>\n\n<pre><code>$userFile = $_SERVER['BASE_DIR'] . '/customcontents/' . $username . '.php'...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T08:39:34.207", "Id": "40439", "Score": "1", "Tags": [ "php", "mustache" ], "Title": "Allow users to add custom queries to Mustache variables" }
40439
<p>The full question description is found <a href="http://www.geeksforgeeks.org/a-linked-list-with-next-and-arbit-pointer/" rel="nofollow">http://www.geeksforgeeks.org/a-linked-list-with-next-and-arbit-pointer/</a>. Looking for code review, optimization, clean code etc.</p> <pre><code>public class CopyArbit&lt;T&gt; {...
[]
[ { "body": "<ol>\n<li><p>I'd move the <code>main</code> method to a separate class. (For example, <code>CopyArbitMain</code>.) It's usually a good idea to separate a class from its clients.</p></li>\n<li><p><code>Iterator.remove()</code> should throw <code>UnsupportedOperationException</code> if remove is not su...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T09:27:43.237", "Id": "40444", "Score": "2", "Tags": [ "java", "linked-list" ], "Title": "Copy a linkedlist with an arbitrary pointer" }
40444
<p>Is it right? any improvements? different approach...?</p> <pre><code>import java.util.Properties; import javax.ejb.EJBException; import javax.ejb.MessageDrivenBean; import javax.ejb.MessageDrivenContext; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.Que...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T18:05:35.097", "Id": "68135", "Score": "2", "body": "Tiny thing, but probably you should use whitespaces consistently: in some places, you have unnecessary indentations, and missing spaces (before and after \"=\" and \",\")." } ]
[ { "body": "<p>Some notes:</p>\n\n<ol>\n<li><p>The <code>get*</code> methods do not look too easy to understand. I bet that there is some library which could do the calculations for you (<a href=\"https://stackoverflow.com/q/3422673/843804\">here a question about it on Stack Overflow</a>), so using one would imp...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T11:31:57.023", "Id": "40453", "Score": "3", "Tags": [ "java", "calculator", "jms" ], "Title": "Calculator implemented in a MessageDrivenBean" }
40453
<p>I would like to connect this "JS" to Bugzilla (example: bugzilla.mozilla.org or landfill.bugzilla.org). </p> <p>I started to learn JS language today and I would like to ask you:</p> <ol> <li>How can I not do bad things in global scope? </li> <li>How should I use functions (in <code>var</code> or not)?</li> </ol> ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-02-04T01:29:51.113", "Id": "68850", "Score": "0", "body": "typo: `if (keyCode == nk.save && commit_top!==null){` should be `kn.save` not `nk.save`?" } ]
[ { "body": "<blockquote>\n <p>How can I not mess up the global scope?</p>\n</blockquote>\n\n<p>You can use an IIFE ( Immediately Invoked Function Expression ) to surround your code and then assign all your variables with <code>var</code> &lt;- Very important.</p>\n\n<pre><code>(function(){\n\n var quicksearch ...
{ "AcceptedAnswerId": "40464", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T14:35:02.183", "Id": "40462", "Score": "8", "Tags": [ "javascript", "scope" ], "Title": "Advice needed for scopes in JavaScript" }
40462
<p>I'm calling a view into a view. Am I doing correctly, or is this a bad practice?</p> <pre><code>&lt;div class="tab-pane" id="tab_1_2"&gt; &lt;div class="portlet "&gt; &lt;div class="portlet-title"&gt; &lt;div class="caption"&gt; &lt;i class="icon-reorder"&gt;&lt;/i&gt; Nuevo ...
[]
[ { "body": "<p>For your controller, a method like this would be best to call all your variables:</p>\n\n<pre><code>$data = array(\n \"add_user\" =&gt; $this-&gt;load-&gt;view('form_add_user'),\n \"username\" =&gt; $username,\n \"admin\" =&gt; $admin\n);\n</code></pre>\n\n<p>(Variables are made up jus...
{ "AcceptedAnswerId": "40469", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T15:17:22.290", "Id": "40465", "Score": "2", "Tags": [ "php", "html", "mvc", "codeigniter" ], "Title": "Codeigniter view within a view" }
40465
<p>I am writing a Tornado app in which a user can maintain his products wishlist. There are two collections, <code>users</code> and <code>products</code>. As the names imply, the <code>users</code> collections will contain users info and the <code>products</code> collections will contain the URLs. </p> <p>Typically a...
[]
[ { "body": "<p>You can try editing your BaseHandler like this</p>\n\n<pre><code>class BaseHandler(tornado.web.RequestHandler):\n def prepare(self):\n self.user_email = self.get_secure_cookie('trakr')\n self.user_db = self.application.db.users\n</code></pre>\n\n<p>and then call the following in ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T15:38:17.203", "Id": "40466", "Score": "3", "Tags": [ "python", "mongodb", "tornado" ], "Title": "Tornado PyMongo product wishlist" }
40466
<p>I've been building a system for inputting and monitoring shifts for casual staff, who work across multiple sites with the ability to generate accounting information.</p> <p>I've had some help from Stack Overflow in building this project, as I had no prior knowledge of PHP or MySQL, and each time I posted some of my...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T15:55:29.637", "Id": "68098", "Score": "1", "body": "You could add `$stmt->execute();` outside the `if` statement so it doesn't have to be there twice. Although that's just being extremely nitpicky." }, { "ContentLicense": "...
[ { "body": "<p>One thing to improve on (if your PHP version allows it), is to consider using PHP's built in <code>password_hash()</code> function. Coupled with <code>password_verify()</code>, it eliminates the need to salt and hash passwords manually. More information can be found <a href=\"http://us2.php.net/ma...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T15:51:19.020", "Id": "40467", "Score": "5", "Tags": [ "php", "mysql", "sql", "security" ], "Title": "System for inputting and monitoring worker shifts" }
40467
<p>I am creating a Monopoly board game using HTML, CSS, PHP, JS and jQuery. I am doing this to develop my web development skills. I have cut the project into sections, so this question will only deal with creating the board.</p> <p><a href="http://jsfiddle.net/eltonfrederik/XyL48/" rel="nofollow">JSFiddle</a></p> <p>...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T17:37:17.043", "Id": "68130", "Score": "4", "body": "Greetings and welcome to Code Review. Since there is no JavaScript or PHP in this question, I removed these tags. The only thing then to review is the HTML which we all know is no...
[ { "body": "<p>As mentioned in the comments the question that you are asking is actually off topic as you have not implemented it yet and there are many solutions (you could for example do everything as percentage or <a href=\"http://css-tricks.com/viewport-sized-typography/\">vh/vw units</a> rather than pixels)...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T15:53:24.703", "Id": "40468", "Score": "1", "Tags": [ "html", "game", "css" ], "Title": "Creating a Monopoly board" }
40468
<p>In my CodeIgniter project I have a Login controller that load this view:</p> <pre><code>&lt;ul class="sub-menu"&gt; &lt;li&gt; &lt;a href="javascript:;" class = "menu-item" data-target="../indoamericana/soporte/callSupport/"&gt; Mis solicitudes &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Th...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2019-03-02T06:08:08.723", "Id": "414963", "Score": "0", "body": "If you are lucky, you'll never have a help desk employee called `<script>alert(123)</script>`. I wouldn't count on that, though. Better protect your code against cross-site scrip...
[ { "body": "<h1>General comments</h1>\n<p>I don't see much wrong with the code. The biggest concern I might have is that PHP code is mixed in with the HTML - an alternative to this would be using a template system. CodeIgniter has the <a href=\"https://www.codeigniter.com/userguide3/libraries/parser.html\" rel=\...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2014-01-30T16:03:36.817", "Id": "40470", "Score": "3", "Tags": [ "javascript", "php", "jquery", "html", "codeigniter" ], "Title": "Correct MVC in CodeIgniter" }
40470
<p>I'm a novice programmer learning Objective-C in my spare time. I would greatly appreciate any help or advice with my code. I want to follow best practices whenever possible. I know that I am missing some foundational stuff with my code, so please point that out where you see it. Things like when to make variable...
[]
[ { "body": "<p>I must say that I'm not an expert in Objective-C. I have used it though so I will review what I can and hope that others will fill in for the rest.</p>\n\n<p>First of all, to address your questions about variables and properties. Here's how I think about it: </p>\n\n<ul>\n<li>If you need a variabl...
{ "AcceptedAnswerId": "40570", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T16:04:49.060", "Id": "40471", "Score": "10", "Tags": [ "beginner", "game", "objective-c", "ios" ], "Title": "Game with tile map - Sprite-Kit" }
40471
<p><em>Note: I have posted a <a href="https://codereview.stackexchange.com/questions/127552/portable-periodic-one-shot-timer-thread-improvements?lq=1">follow-up question</a> for a significantly updated version of this code.</em></p> <p>I have implemented a class that provides portable one-shot or periodic timers.</p> ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T21:27:18.643", "Id": "68171", "Score": "0", "body": "Apologies for rolling back your last edit, but it's this site's policy to not edit the original code in a way that would invalidate the previous/existing answers." }, { "C...
[ { "body": "<p>I think I'm being confused by your type names. So each timer is actually called <code>Timer::Instance</code> and <code>Timer</code> is something else? Hmm.</p>\n\n<p>In terms of English I can certainly see why \"Timer\" as a name for the <em>whole timing system</em> might make sense, even if it's ...
{ "AcceptedAnswerId": "40487", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T16:11:54.940", "Id": "40473", "Score": "18", "Tags": [ "c++", "multithreading", "c++11", "timer" ], "Title": "Portable periodic/one-shot timer implementation" }
40473
<p>The <em>code challenge</em> problem must be solvable with a relatively short solution that can be posted in anyone's favorite programming language.</p> <p>After the community <a href="http://meta.codereview.stackexchange.com/questions/1201/cr-weekend-challenge">has agreed on a problem for the code challenge</a>, en...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T16:34:48.143", "Id": "40476", "Score": "0", "Tags": null, "Title": null }
40476
Reviewing code is fun! Every now and then the community decides on a problem to solve; solutions are posted as questions to be peer reviewed. Use this tag to mark your question as a code-challenge entry. This tag replaces the [weekend-challenge] tag.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T16:34:48.143", "Id": "40477", "Score": "0", "Tags": null, "Title": null }
40477
<p>I am using kendo grid's <code>onDataBound</code> event to do something. Here's my jQuery code:</p> <pre><code>console.time('withoutnot'); jQuery(e.sender.dataSource._data).each(function (i, v) { if (v.IsReadonly) { e.sender.wrapper.find("tr[data-uid='" + v.uid + "'] .k-button") .each(...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T22:08:55.757", "Id": "68185", "Score": "0", "body": "Out of curiousity how were you writing the `:not` as I'd expect it to be even with your filter and more elegant" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate":...
[ { "body": "<p>I found out solution to my problem. so basically this is what I learnt </p>\n\n<ol>\n<li>use <a href=\"http://api.jquery.com/filter/\" rel=\"nofollow\">filter</a> to reduce the set of similar items instead of explicit if condition</li>\n<li>use cached variables i.e. <code>var $this = $(this);</cod...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T17:49:58.220", "Id": "40480", "Score": "4", "Tags": [ "javascript", "jquery" ], "Title": "How to write efficient javascript/jQuery code involving loops and string concat?" }
40480
<p>I have a set of links with background images on this <a href="http://codepen.io/JGallardo/pen/kcdHF" rel="noreferrer">CodePen</a>.</p> <p><img src="https://i.stack.imgur.com/Il5qa.png" alt="Result"></p> <p>I am seeking feedback to see if I did this the most optimal way. For example, I made a sprite so that I can j...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T21:57:28.353", "Id": "68177", "Score": "0", "body": "Would it be possible for you to use a CSS preprocessor like LESS or SASS? E.g. the templating features of Sass would remove the need for some of the hard-coded pixel offsets." }...
[ { "body": "<p>if you don't want to mess with all the headache of the HTML and CSS you could just create an Image map</p>\n\n<p>in other words you create the image </p>\n\n<p><img src=\"https://i.stack.imgur.com/YLQsX.png\" alt=\"Image you want\"></p>\n\n<p>and then you map out the separate squares using the HTM...
{ "AcceptedAnswerId": "40492", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T21:24:13.060", "Id": "40488", "Score": "10", "Tags": [ "html", "css" ], "Title": "Is my use of CSS inheritance clean enough for these sprites?" }
40488
<p>After testing my site against GTMetrix, I get warnings on not specifying image dimensions. I am working on a WordPress site. Here is my solution:</p> <p>My first solution was: </p> <pre><code> // Specify image dimensions $('img').each(function() { var findImgWidth = $(this).width(); var find...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T23:53:59.073", "Id": "68203", "Score": "5", "body": "Greetings, the reason GTMetrix complains is that the browser can render the page faster if it knows the size of the image. Setting the size *after* the browser has rendered is not...
[ { "body": "<p>The reason GTMetrix complains is that the browser can render the page faster if it knows the size of the image. </p>\n\n<p>Setting the size after the browser has rendered is not going to make your page faster, it will only make the warning go away and fractionally make your page load slower.</p>\n...
{ "AcceptedAnswerId": "40500", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T21:37:31.090", "Id": "40489", "Score": "12", "Tags": [ "javascript", "jquery", "image" ], "Title": "Assigning width and height to specify image dimension using jQuery" }
40489
<p>I've recently wrote a simple bingo game in Java to refresh myself in oop principals I have not touched in quite a while. I feel like I have accomplished this, but I would like to learn as much as possible from this exercise. Besides the oop principals, I tried to make the code very readable and reusable in case ther...
[]
[ { "body": "<ul>\n<li><p>Initialize variables inline where you can, to reduce boilerplate:\n<code>private String board[][] = new String[BOARD_DIM][BOARD_DIM];</code>, etc.</p></li>\n<li><p>Don't use default scoping unless you really mean to. Prefer public or private, as appropriate.</p></li>\n<li><p>Delegate fr...
{ "AcceptedAnswerId": "40501", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-30T23:51:10.197", "Id": "40497", "Score": "11", "Tags": [ "java", "object-oriented", "game" ], "Title": "Basic bingo game in Java" }
40497
<p>I've got this Collection in my Backbone application:</p> <pre><code>var AnswersCollection = Backbone.Collection.extend({ model: Answer, initialize: function() { console.log('Hello from new answers collection'); }, getCorrect: function() { return this.where({correct: true}); }, ...
[]
[ { "body": "<p>Reviewing code for <em>coolness</em> is a first ;)</p>\n\n<p>Some observations:</p>\n\n<ul>\n<li><p><code>initialize</code> : if really all you want to do there is <em>Hello World</em>, then you should take it out. <code>initialize</code> is meant for initializing your model with answers.</p></li>...
{ "AcceptedAnswerId": "40547", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T02:18:14.970", "Id": "40503", "Score": "5", "Tags": [ "javascript", "array", "backbone.js" ], "Title": "Backbone collection filter" }
40503
<p>Below is the code for what I've called a <code>partitioned_multitype_map</code>. This has two major facets:</p> <ul> <li>Allowing a lookup based on keys of multiple lengths and of multiple types. For example:</li> </ul> <p><code>typedef partitioned_multitype_map&lt;int32_t, std::string, int64_t, double&gt; map_t;<...
[]
[ { "body": "<p>I'd say that the biggest problem with it is the problem it is trying to solve. A collection of objects of unknown types is a very confusing and inefficient thing. Once retrieved, one must then ascertain the identity of the object before deciding what can be done with it. There are only three real ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T03:24:27.420", "Id": "40505", "Score": "11", "Tags": [ "c++", "c++11", "lookup", "boost", "hash-map" ], "Title": "Partitioned Multikey Map" }
40505
<p>I'm trying to write a bash function that will take a command such as <code>xcode-select -v</code> or <code>brew -v</code> that outputs a lot of extra text, and format it to my liking. Just to further the example, say I run <code>xcode-select -v</code>, it will output <code>xcode-select version 2333.</code>. I want...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T06:41:27.347", "Id": "68253", "Score": "0", "body": "The \"How do I do _X_\" aspect of the question is off-topic for Code Review (see [help/on-topic]), though @rolfl has kindly answered it for you. In the future, try http://unix.sta...
[ { "body": "<p>The trick for splitting up the version blurb for just the version number, is to pass the values you want in <strong>before</strong> the command, and then shift them off <code>$@</code>.</p>\n<p>you have done a relatively unfamiliar-to-me parsing mechanism with the resetting the field separators, e...
{ "AcceptedAnswerId": "40509", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T03:57:35.200", "Id": "40508", "Score": "4", "Tags": [ "parsing", "bash", "shell" ], "Title": "Mixing function parameters, commands and command arguments in Bash functions" }
40508
<p>I have refactored one of my old homework assignments (mainly to utilize <code>std::stack</code> and some C++11), and I'm still having trouble making it less repetitive.</p> <p>It reads in a text file, character by character, and determines whether all of the opening and closing brackets (<code>{}</code>, <code>()</...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T13:50:55.640", "Id": "68328", "Score": "5", "body": "Since this is covered by *\"All other characters are ignored\"* I just wanted to comment that it's not unusual for languages that match brackets to use them in scenarios that don'...
[ { "body": "<p>Let's answer the questions you have first:</p>\n\n<ol>\n<li><p>Using a stack is fine for this. You need to keep track of the ordering of the tokens you encounter, removing them in a LIFO manner - pretty much the definition of a stack. </p></li>\n<li><p><code>std::map</code> is overkill for 3 token...
{ "AcceptedAnswerId": "40532", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T06:11:31.080", "Id": "40515", "Score": "27", "Tags": [ "c++", "c++11", "parsing", "validation", "balanced-delimiters" ], "Title": "Validating opening and closing bracke...
40515
<p>I'm a newbie self-learned programmer, I've started poking around a bit at C# around two months ago, since I will be starting formal programming studies in about 7 months. I heard the best way to learn how to code is to code so I've written this trivia application and I would love some constructive feedback, what are...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T10:03:41.683", "Id": "68285", "Score": "2", "body": "Consider to ask for review of single class/method instead of asking to review whole application code. Reviewing whole application and writing feedback is *time-consuming* activity...
[ { "body": "<ol>\n<li><p>When using an auto-property like <code>public string Name { get; set; }</code> you don't add a backing field like you do in <code>Player</code>:</p>\n\n<pre><code>private string name;\npublic string Name { get; set; }\n</code></pre>\n\n<p>The point of an auto-property is to generate the ...
{ "AcceptedAnswerId": "40531", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T09:45:29.390", "Id": "40523", "Score": "11", "Tags": [ "c#" ], "Title": "Feedback requested on simple trivia" }
40523
<p>I was told to create a calculator design on AWT, which is also my first project on AWT. I wrote the program and submitted it. I was then told that my program contains around 70 lines of code, and I should try to write less code. How can I shorten this code?</p> <pre><code>import java.awt.*; class Demo{ Frame...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T10:24:37.383", "Id": "68288", "Score": "0", "body": "Even though the program seems far from complete, I think there are some things that we can review here. Thanks for coming here, you will most likely get an answer soon!" }, { ...
[ { "body": "<p>Write a helper method, e.g.</p>\n\n<pre><code>static Button createButton(Frame f, String label, int x0, int y0, int width, int height) {\n Button b = new Button(label);\n b.setBounds(x0, y0, width, height);\n f.add(b);\n return b;\n}\n</code></pre>\n\n<p>Then your code would simplify t...
{ "AcceptedAnswerId": "40527", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T10:18:36.260", "Id": "40526", "Score": "6", "Tags": [ "java", "awt", "calculator" ], "Title": "Shortening calculator project code" }
40526
<p>I wrote a simple thread pool, which works pretty well. I would like to see your review of it.</p> <p>One important feature that I needed in the pool is the ability to wait until all the tasks that I sent to the pool are complete (so that later I could send other tasks that are dependent on the result of the previou...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T17:37:54.323", "Id": "68370", "Score": "1", "body": "Yes its fun writing your own thread pool. But this has been done to death before. Use one of the available ones that has been thoroughly tested and de-bugged." }, { "Conte...
[ { "body": "<p>A few points:</p>\n\n<p>Your <code>EnterCriticalSection</code>/<code>LeaveCriticalSection</code> code should be placed into a scoped RAII object. This saves you from explicitly calling leave, makes your code smaller, and avoids a deadlock if the synchronized code throws.</p>\n\n<p>Do something sim...
{ "AcceptedAnswerId": "40553", "CommentCount": "6", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T11:57:02.297", "Id": "40536", "Score": "6", "Tags": [ "c++", "multithreading", "thread-safety", "synchronization", "windows" ], "Title": "Simple thread pool in C++" }
40536
<p>My script, which is a web scraping script, is very slow, I even needed to put set_time_limit(0);</p> <p>This is the whole <a href="http://phpfiddle.org/main/code/9qt-78n" rel="nofollow">http://phpfiddle.org/main/code/9qt-78n</a></p> <p>I think the problem is here:</p> <pre><code>foreach ($array_with_links as $url...
[]
[ { "body": "<p>It seems that every one of your <code>getCity()</code>, <code>getDepartment()</code> etc functions loads the same web page over and over. </p>\n\n<p>You should load each URL once with your <code>curl_get_contents()</code>, then pass its result into each <code>get*()</code> function to parse it.</p...
{ "AcceptedAnswerId": "40539", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T12:10:25.190", "Id": "40538", "Score": "3", "Tags": [ "php", "performance", "http", "scrapy" ], "Title": "Why is my web scraping script so slow?" }
40538
<p>I have an array of items on which I have to perform 2 tasks:</p> <ol> <li>Applying a function on the array item</li> <li>Checking if the value is true or false.</li> </ol> <p>The functional approach to solving this would be</p> <pre><code>var result = arr.map(function(item){return some_action(item);}).filter(fun...
[]
[ { "body": "<p>Your “functional” approach is overly complicated. Notice that this is completely equivalent:</p>\n\n<pre><code>var result = arr.map(some_action).filter(other_action);\n</code></pre>\n\n<p>I.e. If you're only delegating to another function, you can specify that function directly. Also, an <code>== ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T12:32:18.000", "Id": "40541", "Score": "3", "Tags": [ "javascript", "functional-programming" ], "Title": "Better way to write this code in functional manner using map and reduce?" }
40541
<p>I was assigned to make a Rational class to perform functions on fractions. After awhile I got it to work, but now I'm wondering how to simplify and clean up my code. Basically how to improve and use good Java practices so I can write better Java in the future.</p> <pre><code>public class Rational { private int...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T21:01:03.497", "Id": "68398", "Score": "4", "body": "Default constructor should be `0/1` or non-existent. All constructors should prohibit `0` as the denominator value. This ensures that `Rational` forms an [field](http://en.wikiped...
[ { "body": "<p>You can make all the other constructors call the 2-variable constructor. For example:</p>\n\n<pre><code>public Rational(int num, int den){\n numer = num;\n denom = den;\n reduce();\n}\npublic Rational(){this(1,2);}\npublic Rational(Rational r){this(r.numer,r.denom);} \n</code></pre>\n", "comme...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T14:38:00.307", "Id": "40554", "Score": "18", "Tags": [ "java", "classes" ], "Title": "Rational number arithmetic" }
40554
<p>I am using Java and COM4j to communicate with Word. The approach I used here is brute force. I have a password protected <code>.doc</code>, and I forgot its password.</p> <p>Complexity is (26)<sup>(<code>maxPassLength</code>)</sup>. [a-z characters only]</p> <p>Before I run this code and wait for 7-10 days here ar...
[]
[ { "body": "<blockquote>\n <p>Complexity is (26)<sup>(maxPassLength).</sup></p>\n</blockquote>\n\n<p>You know that the password is only lower-case alpha characters?</p>\n\n<blockquote>\n <p>Would you recommend threading to reduce the search space?</p>\n</blockquote>\n\n<p>It's possible that threads wouldn't he...
{ "AcceptedAnswerId": "40562", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T15:09:17.443", "Id": "40558", "Score": "2", "Tags": [ "java", "performance", "com" ], "Title": "Find password to a word document" }
40558
<p>I have a <code>Factory</code> class that gives out instances of <code>ResponseImpl</code> class. It accepts one <code>Destination</code> class and up to four <code>Source</code> classes. At least one of the four <code>Source</code> classes should be not <code>null</code>.</p> <p>So, instead of asking calling progra...
[]
[ { "body": "<p>It seems to me that you are not quite making good use of exceptions and as long as I believe it is possible that you are disrespecting some principles. First things first, you really should be using <code>IllegalArgumentException</code> because that is the java standard exception class for invalid...
{ "AcceptedAnswerId": "40566", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T15:13:01.043", "Id": "40559", "Score": "10", "Tags": [ "java", "design-patterns" ], "Title": "Handling null arguments in a factory class" }
40559
<p>I am writing C++ code to enumerate the whole HDD and drive listing. However, it takes more than 15 minutes to complete the disk enumeration of all drives (HDD capacity of 500GB) and compile the response in a binary file.</p> <p>However, I have a 3rd party executable which gives me the listing of the whole disk in ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T17:32:05.580", "Id": "68369", "Score": "3", "body": "The difference between your code and the 3rd party app is they are not recursively scanning the directory structure. They will basically be running threw the directory tables on t...
[ { "body": "<blockquote>\n <p><em>Can you please look into my code and suggest me some performance improvement techniques.</em></p>\n</blockquote>\n\n<p><strong>No -- it doesn't work like that.</strong> While there are some obvious things you may catch visually (like observing string comparisons at each iterati...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T15:24:22.757", "Id": "40560", "Score": "5", "Tags": [ "c++", "recursion", "file-system", "windows", "winapi" ], "Title": "Disk enumeration and file listing" }
40560
<p>I have been making my own scoreboard, and needed a custom spectate function for it, so I made this:</p> <pre><code> util.AddNetworkString( "spectatePlayer" ) local playerLocal local isSpectating = false net.Receive("spectatePlayer", function(length, client) if isSpectating then return end isSpect...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2015-07-02T23:21:59.770", "Id": "174524", "Score": "6", "body": "Please add in what the custom behavior is -- just saying that it's custom isn't very specific." } ]
[ { "body": "<p>There's a few things to comment on:</p>\n\n<hr>\n\n<p>I'm not a Gmod developer, so I'm not familiar with the spectating abilities built in, but, I'd assume that if any exist, they're probably better to use than re-inventing the wheel.</p>\n\n<hr>\n\n<p>There's only two states: not spectating, and ...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T16:44:35.177", "Id": "40563", "Score": "10", "Tags": [ "game", "lua" ], "Title": "Garry's Mod custom spectate player" }
40563
<p>I wrote Conway's Game of Life in Python with Pyglet. It works pretty well but is very slow when the number of cells gets high. Any easier speedups I can attain with this code?</p> <pre><code>import pyglet import numpy from itertools import cycle from pyglet.window import key, mouse window_width = 700 window_heig...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T17:58:20.143", "Id": "68377", "Score": "2", "body": "There are algorithmic speedups suggested on [Wikipedia](http://en.wikipedia.org/wiki/Conway's_Game_of_Life#Algorithms) and probably [on this site too](http://www.conwaylife.com/):...
[ { "body": "<p>Here's a couple of ways to shorten the code, which may or may not involve perf gains but may make it easier to work with. I tested this with plain lists-of-lists instead of numpy.arrays but I think it should work the same way. I used itertools.product to get rid of the nested loops and used sum(...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T17:36:02.393", "Id": "40567", "Score": "4", "Tags": [ "python", "performance", "game-of-life", "opengl", "pyglet" ], "Title": "Speedups for Conway's Game of Life" }
40567
<p>I'd like you to review my attempt at creating an authorization class and let me know if there is re-factoring to be done and/or how I can make the code cleaner and abide by the MVC structure. </p> <p><strong>UsersController.php</strong></p> <pre><code>&lt;?php class UsersController extends BaseController { ...
[]
[ { "body": "<p>I didn't used PHP in the last few years, so just some generic notes:</p>\n\n<ol>\n<li><p>The <code>$input</code> parameter of <code>insertUserIntoDatabase($input)</code> is unused. I guess you wanted to use the parameter instead of direct <code>Input::</code> calls inside the function.</p></li>\n<...
{ "AcceptedAnswerId": "45083", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T19:24:44.200", "Id": "40571", "Score": "4", "Tags": [ "php", "mvc", "laravel" ], "Title": "Laravel 4 clean code review of users controller and model, trying to maintain MVC str...
40571
<p>Okay, so just having a little fun I thought I'd see if I could write an algorithm to find all of the prime factors of a number. The solution I came up with is as follows:</p> <pre><code>class Program { static void Main(string[] args) { var subject = long.MaxValue; var factors = new List&lt;l...
[]
[ { "body": "<p><strong>Other algorithms</strong></p>\n\n<p>Wikipedia has an article which lists other <a href=\"http://en.wikipedia.org/wiki/Integer_factorization#Factoring_algorithms\">Factoring algorithms</a>.</p>\n\n<hr>\n\n<p><strong>Your algorithm</strong></p>\n\n<p>Re. your algorithm, I see you're checking...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-01-31T19:34:39.780", "Id": "40572", "Score": "9", "Tags": [ "c#", "algorithm", "primes" ], "Title": "Finding prime factors of a number?" }
40572