body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>I just want to know if this is reasonably good implementation of including local/remote JavaScript files. </p> <p>The function takes a dictionary with (string) <code>.src</code> whitespace-separated list of urls to include/execute in global context, and (func) <code>.done/.error/.load</code> callbacks to run in cor...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-08T19:19:36.837", "Id": "75810", "Score": "0", "body": "There are many script loader libraries out there, some extremely small and simple. What new functionality are you offering over all these other offerings. Or put another way, wh...
[ { "body": "<p>Your code is interesting,</p>\n\n<p>you are clearly smart and know JavaScript, but this is a maintenance nightmare. I am assuming you will not take my advice to heart but here goes:</p>\n\n<ul>\n<li>Do not abbreviate: <code>isfn</code> -> <code>isFunction</code>, <code>isstr</code> -> <code>isStri...
{ "AcceptedAnswerId": "43939", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-08T18:52:40.770", "Id": "43803", "Score": "5", "Tags": [ "javascript", "reinventing-the-wheel" ], "Title": "Am I including these JavaScript files correctly?" }
43803
<p>I want to divide the screen in two halves. The layout is locked on portrait mode. The top half will have one button and the bottom half will have many buttons. That's why I choose this division, since the top half can be potentially scrollable. </p> <p>This is my layout xml:</p> <pre><code>&lt;LinearLayout xmlns:a...
[]
[ { "body": "<p>Your layout looks very good. <code>android:layout_weight</code> is the correct way to solve this.</p>\n<h3>A couple of other notes regarding your XML layout:</h3>\n<ul>\n<li><p>As your outermost LinearLayout has match_parent for both width and height, there is no need for <code>android:gravity=&qu...
{ "AcceptedAnswerId": "43807", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-08T19:19:40.253", "Id": "43806", "Score": "6", "Tags": [ "android", "xml", "layout" ], "Title": "Dividing the screen in two halves using LinearLayout" }
43806
<p>This one review will be a little bit tricky: I was trying to implement a template <code>Vector</code> struct in C11. Of course, templates don't really exist in C11, so I used <em>a few</em> macros to get the desired interface. Here is the implementation of the core features, trying to mimick those of the c++ <code>s...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-14T06:31:24.977", "Id": "76874", "Score": "0", "body": "Interesting, however the implementation is by force of nature of cpp not so appealing as it should. I think somebody should develop more powerful and elegant macro/templating lang...
[ { "body": "<p>There is a rather large amount of code here and a lot of macro trickery, so I shall refrain from attempting to comment on it all.</p>\n\n<p>There are, however, a few things that immediately jumped out at me.</p>\n\n<hr>\n\n<p>Don't use <code>new</code> as your allocating macro. That's extremely co...
{ "AcceptedAnswerId": "45805", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-08T20:10:14.730", "Id": "43809", "Score": "16", "Tags": [ "c", "template", "vectors", "macros", "c11" ], "Title": "Template vector struct in C11" }
43809
<p>As usual, please be <em>brutally</em> honest with your opinion of my code, and how you would judge it if I were to code this at a top-tier tech company for an interview(think Google, MSFT, Facebook, etc). My algorithm is has a worst time complexity of O(n).</p> <p>Question: Given an unsorted integer array, find the...
[]
[ { "body": "<p>I guess it's quite good in 22 minutes.</p>\n\n<ol>\n<li><blockquote>\n<pre><code>Hashtable&lt;Integer, Integer&gt; myTable = new Hashtable&lt;Integer, Integer&gt;();\n</code></pre>\n</blockquote>\n\n<p>Instead of the <code>Hashtable</code> use <code>HashMap</code>, but you use it like a <code>Set<...
{ "AcceptedAnswerId": "43819", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-08T21:09:53.513", "Id": "43813", "Score": "7", "Tags": [ "java", "algorithm", "interview-questions" ], "Title": "First missing positive" }
43813
<p>I'm trying to implement a <code>TaskScheduler</code> that runs all tasks in the order they are submitted, on a single dedicated thread. Here's my implementation, using a <code>BlockingCollection</code>:</p> <pre><code>class SequentialScheduler : TaskScheduler, IDisposable { readonly BlockingCollection&lt;Task&g...
[]
[ { "body": "<p><code>TryExecuteTaskInline</code> is used in what is called \"task inlining\": basically, when you call <code>Wait()</code> on a <code>Task</code> that didn't start executing yet, it might be executed on the current thread. A simple way to test that is:</p>\n\n<pre><code>var factory = new TaskFact...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2014-03-08T21:11:26.753", "Id": "43814", "Score": "10", "Tags": [ "c#", "task-parallel-library", "concurrency" ], "Title": "TaskScheduler that uses a dedicated thread" }
43814
<p>As soon as I saw the <a href="https://codereview.stackexchange.com/questions/43813/first-missing-positive">First missing positive</a> question, I decided to write my own method for this before writing my review on the question.</p> <p>Judge me by the same standards as bazang wants to be judged, i.e. As if this was ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-08T21:41:18.677", "Id": "75826", "Score": "2", "body": "You should use `import static ` for all your asserts. So you could do `assertEquals(3, missingInt(new int[]{ 1, 2, 0 }));`." }, { "ContentLicense": "CC BY-SA 3.0", "Cr...
[ { "body": "<p>That solution is the algorithm I would have chosen.</p>\n\n<p>I like the data you chose for your list of test cases; you could have added at least one more test case, i.e. an input array with zero elements.</p>\n\n<p>In fact IMO your code will fail when the input is a zero-length array.</p>\n\n<p>...
{ "AcceptedAnswerId": "43822", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-08T21:38:44.930", "Id": "43818", "Score": "11", "Tags": [ "java", "algorithm" ], "Title": "First missing positive with only primitives" }
43818
<p>After spending a few ages writing out every combination of triggers, bindings and storyboards, I finally managed to get my program working. First time working with WPF, so I made a big mess. Now it's time to put on my refactoring hat and make the code neat and proper again!</p> <p>That is, if I knew how. Could anyo...
[]
[ { "body": "<p>Your markup is inlining the styles, which has the effect of producing extremely redundant markup - as you've noticed.</p>\n\n<p>You can define the resources of a window in its <code>Resources</code> property - step one would be to extract your inline styles into the <code>Window</code> tag:</p>\n\...
{ "AcceptedAnswerId": "43828", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-08T22:56:18.807", "Id": "43821", "Score": "11", "Tags": [ "c#", "wpf", "xaml" ], "Title": "Lots of Storyboards in XAML, huge file" }
43821
<p>I've done a library that can parse strings to different java types and to <code>List&lt;...&gt;</code>, <code>Set&lt;...&gt;</code>, <code>Map&lt;...&gt;</code> and <code>arrays</code> of such types. Below are some usage examples, to get a better understanding where to start reviewing:</p> <pre><code>StringToTypePa...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T13:33:16.357", "Id": "76002", "Score": "0", "body": "There is a fair amount to go through here... it is on my radar.... but will probably be a day before I get to it." } ]
[ { "body": "<p>There is a lot of detail in your code, and there is no way to just scan it, and look for problems/patterns, etc.</p>\n<p>Still, here are some observations for the moment, and, depending on time availablility, I may come back with some additional comments (maybe posted as a different answer, we wil...
{ "AcceptedAnswerId": "44020", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-08T23:21:47.787", "Id": "43823", "Score": "4", "Tags": [ "java", "parsing", "generics", "library" ], "Title": "Library for parsing strings to java types, generic types and col...
43823
<p>I'm a F# newbie, and would like to share my implementation of the <a href="http://codingdojo.org/cgi-bin/index.pl?KataPokerHands">Poker Hands Kata problem</a> to get some feedback.</p> <pre><code>module PokerHands open System.Text.RegularExpressions type Figure = | Two | Three | Four | Five | Six | S...
[]
[ { "body": "<p>I like this! Your use of discriminated unions and active patterns is quite elegant, I think. (Although exploiting that <code>compare</code> on discriminated unions does what it does seems a bit of a hack–although I have a hard time justifying that sentiment.)</p>\n\n<p>As to your concerns:</p>\n\n...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T00:42:54.550", "Id": "43831", "Score": "13", "Tags": [ "beginner", "game", "f#", "playing-cards" ], "Title": "Poker Hands Kata in F#" }
43831
<p>I really do not have access to anyone, outside of professors, that is highly knowledgeable about Java so I figured I would post my stuff here to further my knowledge and improve my coding. This is homework for my Operating Systems class and it works. Here are some of my main concerns. </p> <ol> <li>Is this a goo...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T04:17:17.440", "Id": "75868", "Score": "3", "body": "Sorting 20 elements using multiple threads seems overkill. Doing it in a single thread should occupy the processor for microseconds. Starting the threads probably takes longer the...
[ { "body": "<p>I agree with <em>@Loki Astari</em> that this is overkill but as a homework for a course is fine. Some notes about the current code:</p>\n\n<ol>\n<li><blockquote>\n <p>Is this a good use of the static inner class? </p>\n</blockquote>\n\n<p>It's OK but I prefer putting them to separate files. I've ...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T02:07:14.810", "Id": "43834", "Score": "4", "Tags": [ "java", "multithreading", "classes", "homework", "thread-safety" ], "Title": "Using threads to find max in array" }
43834
<p>I have some code that I'd written using this pattern with <a href="https://github.com/creationix/step" rel="nofollow noreferrer">Step.js</a>. In this case, talking to MongoDB in Node:</p> <pre><code>Step( function connectToDatabaseWithAuthorization() { mongodb.connect(mongoConnectURI, this); }, ...
[]
[ { "body": "<p>Interesting that you're getting <code>.finally()</code> after your first method rather than at the end. Should I read that to mean that your code executed as: connect-->finally-->[DONE] or did control flow somewhere else in the promise chain subsequent to <code>finally</code>?</p>\n\n<p>Regarding ...
{ "AcceptedAnswerId": "43864", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T03:13:12.047", "Id": "43837", "Score": "2", "Tags": [ "javascript", "node.js", "mongodb", "promise" ], "Title": "Thoughts on this conversion of code from Step.js to Q promi...
43837
<blockquote> <p>Given an input string, reverse the string word by word.</p> <p>For example: Given <code>s = &quot;the sky is blue&quot;</code>, return <code>&quot;blue is sky the&quot;</code>.</p> <p><strong>What constitutes a word?</strong></p> <ul> <li>A sequence of non-space characters constitutes a word.</li> </ul>...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T12:36:20.977", "Id": "75883", "Score": "1", "body": "There's a (little known) class in the Java class libraries that's meant for these problems. BreakIterator: http://docs.oracle.com/javase/7/docs/api/java/text/BreakIterator.html ...
[ { "body": "<ol>\n<li><p><code>Stack</code> seems more or less deprecated. <a href=\"http://docs.oracle.com/javase/7/docs/api/java/util/Stack.html\">Javadoc says the following</a>:</p>\n\n<blockquote>\n <p>A more complete and consistent set of LIFO stack \n operations is provided by the Deque interface and its...
{ "AcceptedAnswerId": "43840", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T04:39:00.777", "Id": "43838", "Score": "22", "Tags": [ "java", "algorithm", "strings", "interview-questions" ], "Title": "Reverse a string word by word" }
43838
<p>I have the following two vectors in C++11:</p> <pre><code>vector&lt;unsigned char&gt; left = { 1, 2, 3, 4, 5, 6 }; // it is meant to represent the number: 123456 vector&lt;unsigned char&gt; right = { 1, 2, 3, 4 }; // meant to be number: 1234 </code></pre> <p>After a function processes them, they become:</p> <pre>...
[]
[ { "body": "<p>Firstly, given that you're using <code>vector</code> without namespace qualification (that is, not as <code>std::vector</code>), I assume you have a <code>using namespace std;</code> in this code. This is generally a bad idea, but especially so in this case. You use <code>vector&lt;unsigned char&g...
{ "AcceptedAnswerId": "43884", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T09:42:22.407", "Id": "43844", "Score": "7", "Tags": [ "c++", "c++11" ], "Title": "Better size aligning?" }
43844
<p>Please review this code:</p> <pre><code>function toggleFullScreen() { if (!document.fullscreenElement &amp;&amp; !document.mozFullScreenElement &amp;&amp; !document.webkitFullscreenElement &amp;&amp; !document.msFullscreenElement) { var elem = document.documentElement; if (elem.requestFullscreen) { ...
[]
[ { "body": "<p>Right now you have a lot of duplicate-ish code because of the prefix checking. You can improve this by using a helper function to handle the prefix checking for you (untested, but should work):</p>\n\n<pre><code>function prefixed(name, scope) {\n var prefixes = ['', 'moz', 'webkit', 'o', 'ms'];...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T14:08:09.080", "Id": "43856", "Score": "6", "Tags": [ "javascript", "cross-browser" ], "Title": "Toggling Fullscreen" }
43856
<p>I solved this problem in about 11 minutes (with all 50+ test cases passed).</p> <p>I think most of you already know me by now, and I truly appreciate your advice, but please be brutal and judge me as if I was being interviewed by you.</p> <p>Question:</p> <blockquote> <p>Given a m x n matrix, if an element is 0...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T16:06:31.657", "Id": "75896", "Score": "3", "body": "I see that you have been writing a lot of code involving primitives to implement some algorithms. How about writing your own more object-oriented classes? I think you could learn ...
[ { "body": "<p>At first when I took a look at your question I was thinking: Why do you first set values in a boolean matrix to true? I quickly realized, \"Oh. That's why.\"</p>\n\n<p>Overall, well done. I like your code. I would have solved it in the same way. Your coding style is consistent, which makes it easy...
{ "AcceptedAnswerId": "43866", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T15:32:32.020", "Id": "43861", "Score": "13", "Tags": [ "java", "algorithm", "interview-questions", "matrix" ], "Title": "Set matrix zeros" }
43861
<p>This is a simple hello world sample project used for instruction. I'm just looking for general comments on the approach and design.</p> <p><strong>AdvancedHelloWorldTest.java</strong></p> <pre><code> /** * AdvancedHelloWorldTest.java * 2014 GetGnosis.com */ package com.getgnosis.tutorials.tutorial01001; impor...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T17:36:05.487", "Id": "75907", "Score": "1", "body": "Personally I'd find this a little difficult to give much of a review on. My first reaction is that your tests a bit brittle because they depend on the exact format of the output, ...
[ { "body": "<p>Having tests is great (I'd love to see more questions with tests), keep it up! Other parts I would keep simpler.</p>\n\n<ol>\n<li><p>You <em>might</em> want this as a tag in your <a href=\"https://en.wikipedia.org/wiki/Revision_control\" rel=\"nofollow noreferrer\">revision control system</a> inst...
{ "AcceptedAnswerId": "43873", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T16:58:10.613", "Id": "43868", "Score": "10", "Tags": [ "java", "unit-testing", "junit" ], "Title": "Simple Hello World with unit tests" }
43868
<p><a href="https://github.com/syb0rg/parcel">I've created a JSON parsing library in C</a>, and would like some feedback on it (feel free to submit a pull request on GitHub). Any and all suggestions are acceptable, but I would prefer if reviews were focused on making this more efficient.</p> <p>My header file:</p> <...
[]
[ { "body": "<p>I think the code looks pretty tidy. Not sure if you can get a huge speed up - you are effectively tokenizing a string by storing the meta data of the tokens (start/end positions and type). This alleviates the pain of having to copy the data and dealing with the associated memory allocation issue.<...
{ "AcceptedAnswerId": "43915", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T18:11:23.287", "Id": "43872", "Score": "23", "Tags": [ "performance", "c", "parsing", "json", "library" ], "Title": "parcel: a JSON parsing library in C" }
43872
<p>Sparkling is a new, lightweight, dynamic extension language. It combines elements from C, Lua, Python and JavaScript. The reference implementation is hosted on GitHub, at <a href="https://github.com/H2CO3/Sparkling" rel="nofollow">H2CO3/Sparkling</a>.</p>
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T18:15:51.123", "Id": "43874", "Score": "0", "Tags": null, "Title": null }
43874
Sparkling is a lightweight, dynamic extension language.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T18:15:51.123", "Id": "43875", "Score": "0", "Tags": null, "Title": null }
43875
<p>After reading <a href="https://codereview.stackexchange.com/questions/43893/first-real-world-f-application-how-good-idiomatic-is-it-long?stw=2">this question</a>, I've realized that I can do a lot to improve the quality of my question, so I've edited this question quite a bit.</p> <p>I've been teaching myself F# in...
[]
[ { "body": "<p>Overall, this code looks very good. Just two nitpicks here:</p>\n\n<ol>\n<li>Give your function definitions lines to themselves:</li>\n</ol>\n\n<blockquote>\n<pre><code>let openChannelOn (connection:IConnection) = connection.CreateModel()\n</code></pre>\n</blockquote>\n\n<ol start=\"2\">\n<li>Use...
{ "AcceptedAnswerId": "151354", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T19:03:14.130", "Id": "43880", "Score": "8", "Tags": [ "beginner", "f#" ], "Title": "Simple RabbitMQ client wrapper" }
43880
<pre><code>/* * LinkedList.h * * Created on: Mar 9, 2014 * Author: steven */ #ifndef LINKEDLIST_H_ #define LINKEDLIST_H_ #include &lt;iostream&gt; using std::cout; using std::endl; template&lt;class T&gt; class LinkedList { template&lt;class E&gt; struct Node { Node&lt;E&gt; *rightNode; ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T22:30:21.733", "Id": "75939", "Score": "1", "body": "One quick thing I've noticed: `getSize()` should be `const`. I also see that this wasn't corrected from your previous question. You should ideally be showing some improvement wi...
[ { "body": "<h3>Bugs</h3>\n\n<p>For a header-only library, <code>using std::cout</code> and <code>using std::endl</code> are unacceptable side effects.</p>\n\n<p>The <code>LinkedList&lt;T&gt;::Node&lt;E&gt;</code> class should just be <code>LinkedList&lt;T&gt;::Node</code>, and it should be private.</p>\n\n<p><c...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T22:17:04.390", "Id": "43889", "Score": "6", "Tags": [ "c++", "linked-list" ], "Title": "Is this a proper singly linked list?" }
43889
<p>Every time I write a new PHP page, I usually need to include this at the top:</p> <pre><code>&lt;?php require_once(__DIR__ . '/../libraries/global.lib.php'); function load_classes($class) { // appears to get all the names of the classes that are needed in this script... $file_name = './classes/' ....
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T01:07:42.557", "Id": "75955", "Score": "0", "body": "Moving this to an include would work. You will have to be careful about paths like `__DIR__` since they apply directly to the file they are contained in." } ]
[ { "body": "<p>Yes, you could put that into a separate file and <code>include_once('header_file.php');</code>.</p>\n\n<p>You try something such as:</p>\n\n<pre><code>function loadFile($name, $isInterface = false) {\n $type = ($isInterface == true) ? 'interface' : 'class'\n $path = sprintf('./classes/%s.%s....
{ "AcceptedAnswerId": "43892", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T22:59:05.067", "Id": "43891", "Score": "7", "Tags": [ "php" ], "Title": "Autoloader functions" }
43891
<p>After reading/watching various introductions and blog posts and some code here and there, doing a bit of the Try F# tutorial and starting to read "Real World Functional Programming", I felt I should be able to write a first small real-world application in F#.</p> <p>In order to be able to concentrate on getting to ...
[]
[ { "body": "<p>Overall I think it's fine.</p>\n\n<p>A couple of suggestions that leap out, based on a quick scan.</p>\n\n<p>CAVEAT: This code was written in the browser and not compiled -- sorry for any errors, but you should get the idea.</p>\n\n<h3>1) The operation in <code>SetClassificationIdentificationValue...
{ "AcceptedAnswerId": "43896", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-09T23:59:07.000", "Id": "43893", "Score": "25", "Tags": [ "beginner", "f#" ], "Title": "First real-world F# application - how \"good\"/idiomatic is it? (long!)" }
43893
<p>I am not sure what I am doing is right or not and am looking for experienced opinions.</p> <p><img src="https://i.stack.imgur.com/t980u.jpg" alt="Soluton Explorer window"></p> <p><strong>Entity Example</strong></p> <pre><code>namespace Entities.Shop { public class Shop { public virtual int ShopId ...
[]
[ { "body": "<p>Browsing over the code one issue which jumped at me is the fact you have a tight coupling between your business layer and data access layer. Your BL is calling straight into the DAL by calling <code>DAL.Entity.CRUD.Whatever()</code>. This means that if you want to unit test your BL all of a sudden...
{ "AcceptedAnswerId": "43909", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T02:09:40.640", "Id": "43898", "Score": "5", "Tags": [ "c#" ], "Title": "Online food ordering application structure" }
43898
<p>One of the main problems I have with <code>JList</code> is that no component is actually <em>added</em> to it. This means that things like <code>ActionListener</code>s don't work, and you can't really have a list of interactive components. To solve this, I've tried to quickly implement an alternative.</p> <p>I have...
[]
[ { "body": "<p>This is a huge step to take to solve a problem which I am not sure actually exists.</p>\n\n<p>Why do you need to reimplement the way the entire component is rendered just to add the ActionListeners in a different way? I think you have missed something here.</p>\n\n<p>You can override the ListModel...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T03:03:28.203", "Id": "43899", "Score": "10", "Tags": [ "java", "performance", "swing" ], "Title": "Component-oriented implementation of JList" }
43899
<p>As I was coding this algorithm I found that some variables that are meant to be global behave as they are intended to behave, but others do not. Specifically, my boolean arrays, e.g. <code>processed</code> and <code>discovered</code>, can be modified within any method without the need to declare them. </p> <p>On ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T06:07:01.340", "Id": "75975", "Score": "1", "body": "Some minor points to consider\n\ntime is a stdlib module - that makes it a bad candidate for a global variable name! But as the code is written each new call to dfs() needs it. W...
[ { "body": "<blockquote>\n <p>Can someone, in a clear way that makes sense, explain the why time needs to be declared Global and the other global variables do not? What is the difference between time and the other variables?</p>\n</blockquote>\n\n<p>The <code>time</code> variable is an integer and the boolean a...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T04:56:36.680", "Id": "43902", "Score": "1", "Tags": [ "python", "python-2.x", "depth-first-search" ], "Title": "Depth first search, use of global variables, and correctness of tim...
43902
<p><a href="http://stackoverflow.com/tags/jms/info">Stack Overflow JMS tag wiki</a></p>
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T06:37:22.453", "Id": "43905", "Score": "0", "Tags": null, "Title": null }
43905
The Java Message Service (JMS) API is a Java Message Oriented Middleware (MOM) API for sending messages between two or more clients. JMS is a part of the Java Platform, Enterprise Edition, and is defined by a specification developed under the Java Community Process.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T06:37:22.453", "Id": "43906", "Score": "0", "Tags": null, "Title": null }
43906
<p>I wrote this code to send any binary file from <strong>server</strong> to <strong>client</strong> (in our example, I am sending sample_file.txt); the client should recreate the file locally. Code works fine (I tested with one or two files). Data is sent in chunks of 256 bytes.</p> <p>I would appreciate remarks and ...
[]
[ { "body": "<p>I am not an expert in network so I will comment on the part that doesn't interest you that much. On top of that, your code is pretty clean, well documented and seemed to work properly when I tried it locally so there is not too much to say.</p>\n\n<p>You should try to avoid magic numbers to keep t...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T08:39:27.893", "Id": "43914", "Score": "16", "Tags": [ "c", "networking", "socket" ], "Title": "Client/server implementation in C (sending data/files)" }
43914
<p>I'm trying to write a Minecraft server in Ruby as an educational project and I've hit the point now where I need to decide on how I am going to structure the in-game objects (entities). In my mind, an Entity is an in-game thing such as a block, or a player, or a skeleton.</p> <p>The reason this is code review, and ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T14:59:22.033", "Id": "76029", "Score": "0", "body": "Forget my previous comment -- I didn't read the question carefuly and thought you wanted to build the map in OOP, that would be nonsense." }, { "ContentLicense": "CC BY-SA...
[ { "body": "<p>I would prefer your second plan, with inheritence and mixin modules. I'll restate their different uses, which I am sure you know:</p>\n\n<ul>\n<li>Use inheritance to model relationships between objects (B <em>is a</em> A).</li>\n<li>Use mixins to model behavior (C <em>logs</em>, D <em>remembers i...
{ "AcceptedAnswerId": "43931", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T09:38:26.400", "Id": "43917", "Score": "6", "Tags": [ "ruby", "minecraft" ], "Title": "Game object structure for Minecraft server" }
43917
<p>At the innermost loop of my software is a lookup of a function value from a piecewise defined function with interpolation between the sample points.</p> <p>Illustration:</p> <pre><code>* * * * * * |--|------|------|----...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T16:25:13.527", "Id": "76048", "Score": "0", "body": "Would be nice, if you post, if and how much you have improved the speed with witch attempt. maybe there are also some possible improvements in your *interpolation between the samp...
[ { "body": "<p>Why do you need a <strong>linear search [O(n)]</strong>? </p>\n\n<p>You can determine in which interval the value belongs by a <strong>binary search [O(log n)]</strong> (do not implement is with a recursion! use a loop or hard-code it))). </p>\n\n<p>Average number of comparisons for linear sea...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T10:29:30.293", "Id": "43920", "Score": "6", "Tags": [ "c++", "optimization", "performance", "lookup" ], "Title": "How to speed up interval lookup for a piecewise defined funct...
43920
<p>After suggestions given in this <a href="https://codereview.stackexchange.com/questions/43476/simulation-of-an-ocean-containing-sharks-and-fish">question</a>, modifications to the code has been done.</p> <p>Only thing I could not do is to decide, where to place the <code>starveTime</code> property (in <code>Shark</...
[]
[ { "body": "<p>Just one quick observation: There seems to be no point in the <code>Point</code> class (pun not intended). Its fields are private, so you can't ever read anything from it, and you don't actually use it anyway, except for the <code>Critter</code>s location property of which the getter <code>getLoca...
{ "AcceptedAnswerId": "44242", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T10:29:43.163", "Id": "43921", "Score": "14", "Tags": [ "java", "game-of-life", "simulation" ], "Title": "Suggestions needed after modification of Simulation of an Ocean" }
43921
<p>I am working on angularjs, and I have created some directives with bunch of HTML elements within its templates. I have assigned a controller for those directives. Below is my code snippet: </p> <pre><code>directives.directive('ngLd',function() { return { restrict : "AE", templateUrl:'partials/...
[]
[ { "body": "<p>I think you did the right thing, if you used <code>ngClick</code> you would loose tooling: syntax highlighting, debugging, linting.</p>\n\n<p>Other than that your code looks good, some minor nitpickings:</p>\n\n<ul>\n<li><p>a single comma separate <code>var</code> statement is considered better:<b...
{ "AcceptedAnswerId": "43930", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T10:32:26.020", "Id": "43922", "Score": "3", "Tags": [ "javascript", "angular.js", "event-handling" ], "Title": "Bootstrap/bind click event over ngClick" }
43922
<p>Is there a more efficient/direct way to find an arbitrary perpendicular vector of another vector?</p> <pre><code>def perpendicular_vector(v): r""" Finds an arbitrary perpendicular vector to *v*. """ a, b = random.random(), random.random() if not iszero(v.z): x, y, z = v.x, v.y, v.z elif not...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2019-11-12T12:17:42.797", "Id": "453411", "Score": "1", "body": "You better not use random. Arbitrary does not mean differrent on each call. Better use size that comes out of your algorithm. Either it be same size as input vector or 1 could be...
[ { "body": "<p>Hmm. The lack of comments make it slightly non-obvious what is happening. The inverted conditions <code>not iszero(…)</code> don't make it any easier to understand. The same set of these conditions occurs two times, which is a bit confusing. I also don't know where the <code>iszero(…)</code> funct...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T12:00:17.233", "Id": "43928", "Score": "7", "Tags": [ "python", "algorithm", "mathematics", "computational-geometry" ], "Title": "Algorithm to get an arbitrary perpendicular v...
43928
<p>I haven't thought of a nice way to remove <code>#, fuzzy</code> from the files. I think <code>process_babel_file</code> might possibly become its own module, but on the other hand, having all methods in one script is quite nice for the mean time. I expect there to be bugs, although it works for the languages I've tr...
[]
[ { "body": "<p>Nice script! Found it very helpful to get started and test flask babel and see first translations.</p>\n\n<p>A few \"bugs\" I discovered for your consideration</p>\n\n<ul>\n<li>Any string with a ' will cause problems</li>\n<li>Same with other special characters, e.g. ()</li>\n</ul>\n\n<p>The resul...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T12:14:28.570", "Id": "43929", "Score": "1", "Tags": [ "python", "i18n" ], "Title": "Script for initialising i18n for a Flask site using pybabel and goslate" }
43929
<p>I see that there are quite some words that are appearing double or more times in my code.</p> <p>I'm thinking there might be a more efficient way of writing this code, only I don't have the knowledge to do so.</p> <pre><code>function transitionData(data) { if($("div#facebook div#notice").is(":visible")) { ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T13:08:44.663", "Id": "75993", "Score": "1", "body": "you can store and use for example $(\"div#facebook\") in a variable" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T13:11:22.770", "Id": "75994...
[ { "body": "<p>From a once over,</p>\n\n<ul>\n<li><p>You have far more than a <code>few words</code> that are copy pasted, you could extract all the common statements into a common function:</p>\n\n<pre><code>function transitionDataDone( data ){\n $(\"div#facebook div.wrapper &gt; img:first-child\").attr(\"sr...
{ "AcceptedAnswerId": "43961", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T12:42:44.750", "Id": "43933", "Score": "2", "Tags": [ "javascript", "jquery", "dom", "query-selector" ], "Title": "Showing/hiding a box containing a Facebook profile" }
43933
<p>My software has multiple devices connected before starting. I must be sure these devices are working and are well connected. every device has different error ID code so we can see every component that is not working.</p> <p>When the software will have completly test connection for every devices, we would like to sh...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T13:18:23.540", "Id": "75998", "Score": "0", "body": "Why do you want to show the error code? Why not directly tell the user which devices failed?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T13:42:...
[ { "body": "<p>I think your enum is taking naming conventions, making a little paper ball out of it, and throwing it out the window.</p>\n\n<p>An enum is a type. As such, its name should be <code>PascalCase</code>. Enum members are, well, public members of a type. As such, their names should be <code>PascalCase<...
{ "AcceptedAnswerId": "43950", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T12:45:14.173", "Id": "43934", "Score": "4", "Tags": [ "c#", "error-handling" ], "Title": "How to properly detect multiple devices failure?" }
43934
<p>I have a simple sorting algorithm that I was told is possibly unstable. I'm wondering what in the sort is unstable. I have test cases written to test all fields with no issues.</p> <p>A secondary problem is that jQuery is not appending the rows for some reason (works fine in local and server environments).</p> <p>...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T17:14:19.663", "Id": "76064", "Score": "0", "body": "I'm sorry but it's off-topic to ask to fix a bug or something like that (Read the FAQ for more details http://codereview.stackexchange.com/help/on-topic). The rest of the question...
[ { "body": "<p>You are using the built-in <code>sort</code> of <code>Array</code>, which is not guaranteed to be stable per the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\" rel=\"nofollow\">documentation</a>. You will have to write your own sort algorith...
{ "AcceptedAnswerId": "43949", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T14:37:31.913", "Id": "43942", "Score": "3", "Tags": [ "javascript", "jquery", "sorting" ], "Title": "Sorting possibly unstable and general jsfiddle/jquery problem" }
43942
<p>I have a function that iterates through a list of file updates, and for each file, if updates are needed, download the file from the server, make the updates, and upload the updated version. Each update gets marked with a string identifying the result of the update operation.</p> <p>There are several steps in the ...
[]
[ { "body": "<p>You can use <code>continue</code> instead:</p>\n\n<pre><code>public void updateAllFiles()\n{\n foreach (string fileName in updateList.fileNameList())\n {\n updatesForFile = updateList.updatesForFile(fileName);\n hyperlinkEntry = hyperlinkList.getHyperlinkEntry(fileName);\n ...
{ "AcceptedAnswerId": "43962", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T17:57:41.240", "Id": "43960", "Score": "5", "Tags": [ "c#", "exception-handling" ], "Title": "Should this be written with exception handling instead of nested if-thens?" }
43960
<p>I have isolated a little bit of code that was causing a small debate between myself and another user. I have taken some of the things that he said and meshed it with the code that was being reviewed in the first place <a href="https://codereview.stackexchange.com/q/36482/18427">here</a>.</p> <p><strong>Original Co...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T13:24:03.877", "Id": "76259", "Score": "1", "body": "You initialize `playerChoice` to `-1`, but that value is never used." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T13:33:07.543", "Id": "7626...
[ { "body": "<p>It would be best for the sake of modularity, and re-usability for this whole chunk of code to be placed in a separate method. If you are going to need more user input besides just what gesture they want to use you could also make it more generic to be re-used through the rest of your program for v...
{ "AcceptedAnswerId": "43989", "CommentCount": "9", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T18:27:51.700", "Id": "43965", "Score": "36", "Tags": [ "c#", "validation", "console", "comparative-review" ], "Title": "Ensuring user input is an integer in a range" }
43965
<p>To avoid <code>switch</code> statements at multiple places, I wrote the following code. This was based on articles found in the Google search. <em>The object names are not real in the sample below. So please ignore that</em>.</p> <pre><code> //somewhere in the code foreach (IEmailAlertDt alert in EmailAlertFactory....
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T19:26:17.833", "Id": "76105", "Score": "0", "body": "Could you explain why are you trying to avoid `switch`?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T19:30:44.977", "Id": "76108", "Scor...
[ { "body": "<ol>\n<li><p>I really like your use of a <code>Dictionary</code> with <code>Functions</code>, that is one of my favorite things to do in C# for some reason. </p></li>\n<li><p>Your methods that look like this</p>\n\n<pre><code>public bool CheckEmailAlertDt(PatWaitListStatReason reason)\n{\n if (rea...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T18:41:18.687", "Id": "43968", "Score": "6", "Tags": [ "c#", "optimization", ".net", "email" ], "Title": "Optimizing email alert code" }
43968
<p>I have this piece of code that is running too slow. I was wondering if anyone can help me optimize it as I can't seem to find any more shortcuts. I'm not sure if using <code>List&lt;&gt;</code> is going to help me but I need complex operation such as Union and Overlap. </p> <p>Also, <code>List</code> is desirable b...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T19:35:43.733", "Id": "76114", "Score": "0", "body": "I personally get rather annoyed when I see `List.Add()` in a loop inside an `if`, because to me that means its just begging for an `.AddRange()` and a `.Where()`, but the fact tha...
[ { "body": "<p>First of, I'm gonna give you a basic idea...</p>\n\n<p>Instead of doing 2 loops over two different arrays, check their sizes first. Create a loop for the smaller of both array sizes. In that loop you will process that Array, and then create another loop for the remainder of unprocessed data.</p>\n...
{ "AcceptedAnswerId": "44004", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T18:55:45.487", "Id": "43969", "Score": "3", "Tags": [ "c#", "performance", "image" ], "Title": "Loop optimization for image processing" }
43969
<p>I have decided to make a basic C++ implementation of the <code>std::map</code> class, and I was checking that it is fine, as I am not sure if the <code>operator[]</code> is done correctly: should I be using the <code>has_key</code> function? e.t.c</p> <pre><code>template &lt; typename _Key, typename _Ty, typename _...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T19:58:36.987", "Id": "76568", "Score": "4", "body": "I am downvoting this for your use of reserved identifiers. You have been advised not to do this in all of your previous STL exercise that you put up here for review. Please STOP A...
[ { "body": "<p>You are searching two times the entire arrays to find your key,pair value. This is highly inefficient. Instead you could extend your has type to take two arguments and in the second argument it could store the value. This way you only iterate once. </p>\n\n<p>Otherwise yes, reusing your code is a ...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T19:23:14.267", "Id": "43972", "Score": "6", "Tags": [ "c++", "reinventing-the-wheel" ], "Title": "Implementation of std::map" }
43972
<p>I have currently been working on a program for a few days now, and I am just about done. The goal of my program is to ask the user for the amount they still owe on their credit card, and assign an appropriate monthly interest rate. I have commented the code to make it a bit easier to understand, and I believe it i...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-02-27T18:28:34.670", "Id": "76122", "Score": "0", "body": "Could you fix your formatting, and only include the code that's related to your issue? (Removing user input and output is a good start.) I'm also not sure what you mean by \"calli...
[ { "body": "<p><strong>Watch your scope</strong> - in your class you keep your data in two places - local variables, and static members. I cannot see any thought behind choosing where to put them - you pass some around in your method signatures, but then you use the others in the same methods... The most acute c...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-02-27T18:25:51.020", "Id": "43978", "Score": "3", "Tags": [ "java", "finance" ], "Title": "Assign monthly interest rate based on credit card input" }
43978
<p>This is a similar question to <a href="https://stackoverflow.com/questions/492716/reversing-a-regular-expression-in-python">this</a>, but I am looking for the set of <strong>all possible values</strong> that will match a regular expression pattern.</p> <p>To avoid an infinite set of possible values, I am willing to...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T18:08:15.107", "Id": "76129", "Score": "1", "body": "Are you looking to exhaustively test all possible inputs to this regex? That could get quickly out of hand, and some regex's could literally have an infinite number of possible in...
[ { "body": "<p>A major inefficiency in your solution is that you try every <code>fill_in</code> character as a replacement for any character class in the pattern. Instead, you could use the character class to select matching characters from <code>fill_in</code> and only loop over those. </p>\n\n<pre><code>&gt;&g...
{ "AcceptedAnswerId": null, "CommentCount": "8", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T17:32:16.360", "Id": "43981", "Score": "3", "Tags": [ "python", "performance", "regex" ], "Title": "All possible values that will match a regular expression" }
43981
<p>I was wondering if anyone had some general clean up advice on my code. I believe that more helper functions would be my case but I could be wrong. 30 lines maximum per method is my rule. I can't seem to figure out how to clean this up more, though. </p> <p><strong>Sample Input:</strong></p> <p>(1/3) (1/5) - (40/...
[]
[ { "body": "<p>Reverse Polish Notation does not need parentheses, so that should actually be invalid input and should not be checked.</p>\n\n<p>To determine if something is an operand you should be able to use <code>stdin.hasNextInt()</code>. If that is false, then you should be able to use <code>stdin.next()</c...
{ "AcceptedAnswerId": "43998", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T20:37:54.453", "Id": "43984", "Score": "7", "Tags": [ "java", "beginner", "math-expression-eval", "rational-numbers" ], "Title": "Cleaning up Reverse Polish Notation evalua...
43984
<p>It might be easier to read the explanation of what I was trying to do, and implement it a completely different way, rather than go through the code. But the code does what I want it to do, just nowhere near any measurable efficiency.</p> <p>This started off as an assignment that I got finished, but I know there ha...
[]
[ { "body": "<p>Use the power of data structures...</p>\n<p><img src=\"https://i.stack.imgur.com/NS5oG.png\" alt=\"Data Structure Power\" /></p>\n<h3>Step one</h3>\n<p>You create a two different data structures consisting of pure indexes of your original matrix. On the first you create Objects that contain &quot;...
{ "AcceptedAnswerId": "44022", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T20:44:43.077", "Id": "43987", "Score": "5", "Tags": [ "java", "matrix", "image" ], "Title": "Image-grouping using bit matrices" }
43987
<p>What troubles me are the empty <code>/**/</code> brackets. Is there a cleaner way of handling this logic?</p> <pre><code>if (opcode == OP_0) { /* continue */} else if (opcode == OP_1NEGATE) { /* continue */} else if (opcode &gt;= OP_1 &amp;&amp; opcode &lt;= OP_16) { /* continue */} else { throw new Exc...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T11:37:55.270", "Id": "76444", "Score": "7", "body": "I see that most answers copy the indentation from the question. I would expect the `else if` chain to align with the initial `if`. When I see an indented `else` I tend to start ...
[ { "body": "<p>I don't like the empty blocks after the <code>if</code> statements. Its very confusing, and clutters up your code.</p>\n\n<p>I also don't like that you are throwing a general <code>Exception</code>. Create one and throw that exception instead.</p>\n\n<pre><code>public class InvalidOpCodeExceptio...
{ "AcceptedAnswerId": "43997", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T21:12:42.973", "Id": "43991", "Score": "24", "Tags": [ "c#" ], "Title": "Checking opcode values" }
43991
<p>I made an <code>isSorted</code> function in Scala and Java as well and when I measured the time of functions' run I saw that the Scala version was very slow. It ran about 3.2 sec for 10000 Int but java version just ran about 10 ms!</p> <p>How can I make faster my Scala version?</p> <p><strong>Scala:</strong></p> ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T21:28:38.623", "Id": "76146", "Score": "1", "body": "Java 8, which will release in a week, will support Lambdas, so you can use some of the syntaxic sugar. Keep in mind though that Scala is much less verbose than Java is." }, { ...
[ { "body": "<p>The problem is simply that your two solutions are not equivalent. For example, you would probably not use <code>Array</code>, but barring that, a direct translation of the Java code to Scala would be:</p>\n\n<pre><code>def isSorted[A](items: Array[A], cond: (A, A) =&gt; Boolean): Boolean = {\n ...
{ "AcceptedAnswerId": "44002", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T21:16:36.040", "Id": "43992", "Score": "5", "Tags": [ "java", "performance", "scala", "sorting" ], "Title": "How can I make my isSorted function faster?" }
43992
<p>I'm somewhat new to network programming. I have a server that uses Ubuntu, which needs to send data quickly to about 50 clients.</p> <p>As of now, I have about 50 concurrent connections (of course), and it needs to be scalable up to 500.</p> <p>I've created a JSON-based protocol to handle the streams and binary. ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T21:32:39.367", "Id": "76147", "Score": "0", "body": "Off-topic, but what's wrong with big headers?" } ]
[ { "body": "<p>There is a <em>lot</em> of ground to cover here...</p>\n<h1>General</h1>\n<h2>ToString</h2>\n<p>You do not have a <code>toString()</code> on your JSONClient code. These are invaluable for debugging, etc.</p>\n<h2>Configuration</h2>\n<p>There are a lot of values which are hard-coded in your program...
{ "AcceptedAnswerId": "44003", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T21:20:38.717", "Id": "43995", "Score": "8", "Tags": [ "java", "socket", "server", "client" ], "Title": "Multi-threaded server socket" }
43995
<p>I am trying to find the users who have the highest "Following vs. Friends" ratio in my Twitter timeline. </p> <p>I have a SQLite database of the users in my Twitter timeline and each column contains data found in the <code>user</code> section of the tweet JSON.</p> <p>Is there a better way that I could write this...
[]
[ { "body": "<p>Your code is not working well, and the SQL statement is not formatted nicely either.</p>\n\n<p>Reformatting your code in to logical sections produces.</p>\n\n<pre><code>SELECT CAST(followers_count AS DECIMAL)/ CAST(friends_count AS DECIMAL),\n screen_name\nFROM following\nORDER BY CAST(CAST(...
{ "AcceptedAnswerId": "44010", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T22:10:13.950", "Id": "44000", "Score": "3", "Tags": [ "sql", "sqlite" ], "Title": "Finding users with the highest Following vs. Friends ratio" }
44000
<p>This code uses a <code>ReaderWriterLockSlim</code> to store data (on a disk or wherever), so that only one thread can write and many threads can read.</p> <p>All writers should be finished before reading, and the write should not block the caller.</p> <p>Basically my solution would work, but it doesn't look and fe...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T11:18:48.063", "Id": "76442", "Score": "0", "body": "and the question is? BTW: you start the writer thread in constructor but when does that thread end and when does `Take` return null? You seem to always \"append\" to the persisten...
[ { "body": "<ol>\n<li><p>For this:</p>\n\n<blockquote>\n<pre><code>try\n{\n readerWriterLock.EnterWriteLock();\n //do stream stuff here\n}\nfinally\n{\n readerWriterLock.ExitWriteLock(); \n}\n</code></pre>\n</blockquote>\n\n<p><code>EnterWriteLock</code> should be before the <code>try</code> statement.<...
{ "AcceptedAnswerId": "44540", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T22:18:53.720", "Id": "44001", "Score": "6", "Tags": [ "c#", "multithreading" ], "Title": "ReaderWriter Synchronization" }
44001
<p>I have started making a <strong><em>very basic</em></strong> networking library in C++. It is built on UDP, with both reliable and unreliable delivery options. So far, I have made the base messaging class, so I will show the header, and the code behind a few functions.</p> <p>Things to note:</p> <ul> <li>While thi...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T23:09:30.833", "Id": "76169", "Score": "0", "body": "From the looks of things, I'd give serious consideration to just using the standard RTP packet format, with a few parts (e.g., `contributing sources`) just zeroed." }, { "...
[ { "body": "<p>Don't use your own spin lock (it is ah huge waste of resources).</p>\n\n<pre><code>while (m_locked.test_and_set(memory_order_seq_cst))\n ;\n</code></pre>\n\n<p>Use a condition variable.<br>\nAlso empty blocks are hard to spot and understand if you are going to use them then put a comment that it...
{ "AcceptedAnswerId": "44081", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T22:41:26.260", "Id": "44005", "Score": "0", "Tags": [ "c++", "thread-safety", "library", "networking" ], "Title": "Threadsafe network message" }
44005
<p>I'm not particularly Python savy and <a href="https://github.com/megawac/iris/commit/fed82b8a6a4c9168fda4ee12a657fde5bddfc337" rel="nofollow noreferrer">recently wrote</a> a <code>LocalizationEngine</code> for <code>Twisted</code>.</p> <p>The strategy I implemented was to make a dictionary from <code>base.json</cod...
[]
[ { "body": "<p>I haven't worked with Twisted, \nand also cannot recommend existing internationalization implementations,\nbut I can code review in terms of Python in general.</p>\n\n<p>You are not following <a href=\"http://www.python.org/dev/peps/pep-0008/\" rel=\"nofollow\">PEP8</a>,\nthe official coding style...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T22:44:30.783", "Id": "44006", "Score": "5", "Tags": [ "python", "i18n", "twisted" ], "Title": "Twisted Internationalization" }
44006
Event-driven networking engine written in Python.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T22:52:26.580", "Id": "44009", "Score": "0", "Tags": null, "Title": null }
44009
<p>Cross-browser refers to the ability of a website, web application, HTML construct or client-side script to function in environments that provide its required features and to bow out or degrade gracefully when features are absent or lacking.</p>
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T23:21:49.600", "Id": "44011", "Score": "0", "Tags": null, "Title": null }
44011
Cross-browser refers to the ability of a website, web application, HTML construct or client-side script to function in environments that provide its required features and to bow out or degrade gracefully when features are absent or lacking.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-10T23:21:49.600", "Id": "44012", "Score": "0", "Tags": null, "Title": null }
44012
<p>I have the following method which basically converts an input audio file to a monophonic FLAC file.</p> <p>Now I am getting <em>Member has cyclomatic complexity of 21 (105%)</em> message in Visual Studio, while I've taken care of improving it as in the beginning it was longer, now there's not much I can remove from...
[]
[ { "body": "<p>I think your code would become much simpler and more readable if you encapsulated all the BASS-related functionality from into separate types.</p>\n\n<p>Something like:</p>\n\n<pre><code>class Stream\n{\n private readonly int handle;\n\n // add overload that supports setting offset and lengh...
{ "AcceptedAnswerId": "44016", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T00:35:59.373", "Id": "44014", "Score": "2", "Tags": [ "c#", "audio", "cyclomatic-complexity" ], "Title": "Converting an input audio file to a monophonic FLAC file" }
44014
<p>I have written this code to search for a string in a <code>.txt</code> file. Is it possible to optimize the code so that it searches for the string in fastest manner possible? Assuming the text file would be a large one (500MB-1GB)</p> <p>I don't want to use regex.</p> <pre><code>import java.io.BufferedReader; imp...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T17:06:23.200", "Id": "76308", "Score": "1", "body": "Have you done any research on what algorithms to use? When searching for a fixed string (i.e., no wildcards), [Knuth-Morris-Pratt](https://en.wikipedia.org/wiki/Knuth%E2%80%93Morr...
[ { "body": "<p>Fast comes at a price.... code complexity and perhaps readability.</p>\n\n<p>Assuming that your code produces the right results now.... and it is a big assumption because:</p>\n\n<ul>\n<li>it expects the word to be at the beginning/end of the line, or surrounded by spaces (not commas, punctuation,...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T02:46:50.807", "Id": "44021", "Score": "26", "Tags": [ "java", "algorithm", "strings", "search", "file" ], "Title": "Fast way of searching for a string in a text file" }
44021
<p>Is there any way to take this chunk of an else if and make it its own method? I would need the values of valid and throwLine() to be done in the method containing this if else statement, but I'm around 45 lines in my method which is 15 more than I'm allowed to have for simplicity. </p> <pre><code> else if(isOpera...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T03:17:52.087", "Id": "76189", "Score": "1", "body": "This question would benefit from a little more context. Don't include the full enclosing function (or do as it will suffice), but include at least the method's signature and final...
[ { "body": "<p>As @DavidHarkness points out, you didn't provide enough context for this question to make sense. However, I see that this code comes from a <code>doTypeCheck()</code> method, which is at the heart of your <a href=\"https://codereview.stackexchange.com/q/43984/9357\">RPN calculator implementation<...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T03:01:47.380", "Id": "44023", "Score": "4", "Tags": [ "java", "beginner" ], "Title": "Executing an operator in an RPN evaluator" }
44023
<h1>Specification</h1> <p>A simple PHP script resizes images on-the-fly. The script is called by the web server's 404 handler to return a scaled version of the original. For example, if the original image is at:</p> <pre><code>http://localhost/images/filename.jpg </code></pre> <p>Then valid requests for scaled versi...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T06:59:36.253", "Id": "76203", "Score": "0", "body": "Comments such as `Locate the position of the last hyphen in the filename.` don't tell us anything new, and your code might be cleared up without those comments" }, { "Cont...
[ { "body": "<p>This code does not do what the comment says:</p>\n\n<pre><code>// Locate the position of the last hyphen in the filename.\n$index = strpos( $filename, \"-\" );\n</code></pre>\n\n<hr>\n\n<p>Consider parsing the path using a regular expression.</p>\n\n<p>For security, I've explicitly listed the allo...
{ "AcceptedAnswerId": "44095", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T03:29:44.510", "Id": "44025", "Score": "4", "Tags": [ "php", "security", "file-system", "image" ], "Title": "Security: Scale and cache images" }
44025
<p>I've created a regular expression (regex) parsing library in C, and would like some feedback on it. Speed is really important to me, but any and all suggestions are acceptable.</p> <pre><code>#include &lt;ctype.h&gt; static int regex_matchHere(const char *regex, char *s, int *len); static int regex_matchGroup(int...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T14:50:03.887", "Id": "76281", "Score": "2", "body": "Although it *can* be divined from the code, it wouldn't hurt to explicitly state the exact sort of regular expressions this is intended to parse/match." } ]
[ { "body": "<h3>What you did well</h3>\n\n<p>The code seems clean and logically organized. I like your 0x100-bit hack to indicate special characters. You could make that convention more obvious in the comments, though.</p>\n\n<h3>What you could improve on</h3>\n\n<ol>\n<li><p>The return value of <code>regex_ma...
{ "AcceptedAnswerId": "44033", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T03:47:55.470", "Id": "44027", "Score": "12", "Tags": [ "performance", "c", "parsing", "regex", "library" ], "Title": "A regular expression parsing library in C" }
44027
<p>Here is what I'm trying:</p> <p>Please review the code:</p> <pre><code>function quicklyChangePageTitle() { var currentTitle = document.title; // remember original title document.title = "temp title"; // change to the temporary title setTimeout(function() { // revert back to original title document.title...
[]
[ { "body": "<p>That seems like a very fragile thing to do. If it works at all, you would still only succeed on browsers where the keyboard shortcut is <kbd>Control</kbd><kbd>D</kbd>. It probably won't work on a Mac or on a mobile device. It will probably break if the user interface is in a non-English locale ...
{ "AcceptedAnswerId": "44030", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T04:15:14.980", "Id": "44029", "Score": "2", "Tags": [ "javascript", "timer", "event-handling" ], "Title": "Auto change page title while bookmarking a page" }
44029
<p>I'm wondering if it's bad practice to couple my DTO to my domain object like this and pass the object itself into <code>Create()</code>. Is it better to just give the parameters needed to perform the creation?</p> <pre><code>public static Playlist Create(PlaylistDto playlistDto, IUserManager userManager, IPlaylistM...
[]
[ { "body": "<p>If the Playlist is an external dependency then it might make sense to use an extension method like:</p>\n\n<pre><code>public static Playlist Create(this PlaylistDto playlistDto, IUserManager userManager, IPlaylistManager playlistManager)\n{\n Playlist playlist = new Playlist\n {\n ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T05:16:35.763", "Id": "44031", "Score": "2", "Tags": [ "c#", "dto" ], "Title": "Passing a DTO into a static domain 'Create' method" }
44031
<p>This is a follow up to the following questions:</p> <p><a href="https://codereview.stackexchange.com/q/36482/18427">RPSLS Game in C#</a></p> <p><a href="https://codereview.stackexchange.com/q/43965/18427">Ensuring user input is an integer in a range</a></p> <p>I haven't made my way to <code>DecideWinner()</code> ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T08:29:32.143", "Id": "76213", "Score": "1", "body": "have you seen the update from BenVlodgi on your old question? http://codereview.stackexchange.com/a/43654/37660" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate":...
[ { "body": "<p>I like the <code>while</code> loop. It states the exit condition from the start, so you know right away what you're getting yourself into.</p>\n\n<p>However I don't like the multi-screen <code>if</code> block.</p>\n\n<p>What if you had a method to handle each of the player's possible moves? Say yo...
{ "AcceptedAnswerId": "44088", "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T06:04:57.877", "Id": "44034", "Score": "12", "Tags": [ "c#", "beginner", "game", "community-challenge", "rock-paper-scissors" ], "Title": "RPSLS is less messy now, but ...
44034
<p>While trying to learn some more C, I decided to implement a linked list and perform a few operations on it.</p> <p>The first thing I wanted to do was read from a .csv of numbers (ex: 1,2,3,...) and store the numbers in a Linked List. </p> <p>Once I have the linked list, I want to reverse the linked list and then I...
[]
[ { "body": "<p>I have 5 Suggestions.</p>\n\n<ul>\n<li>No need to pass the <strong>reverseHead</strong> in <code>LList* reverse(LList * head,LList * reverseHead)</code> method</li>\n</ul>\n\n<p>Change that to:</p>\n\n<pre><code>LList* reverse(LList * head)\n</code></pre>\n\n<ul>\n<li>There is <strong>memory leaks...
{ "AcceptedAnswerId": "44037", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T06:05:36.407", "Id": "44035", "Score": "5", "Tags": [ "c", "linked-list", "memory-management" ], "Title": "Linked List implementation and manipulations in C" }
44035
<pre><code>def uniop_nested(func,o_list): def inner(i_list): if isinstance(i_list[0],np.ndarray): return map(func, i_list) else: return map(inner, i_list) return inner(o_list) def binop_nested(func, o1, o2): if not isinstance(o1,np.ndarray): return [binop_n...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T09:02:49.790", "Id": "76215", "Score": "1", "body": "If you're mostly interested in lists of ndarrays, why not replace recursion with a simple loop without all the 'isinstance' stuff?" }, { "ContentLicense": "CC BY-SA 3.0", ...
[ { "body": "<p>For recursion, you can try adding an @memoize decorator to it, to speed it up. </p>\n\n<pre><code>import functools\n\ndef memoize(f):\n cache= {}\n @functools.wraps(f)\n def memf(*x):\n if x not in cache:\n cache[x] = f(*x)\n return cache[x]\n return memf\n</co...
{ "AcceptedAnswerId": null, "CommentCount": "10", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T08:21:51.973", "Id": "44039", "Score": "4", "Tags": [ "python", "optimization", "recursion", "numpy", "cython" ], "Title": "Recursive function, high performance critical"...
44039
<p>I have a WPF/MVVM form that contains sections for managing Recipient Contacts, CC Contacts and BCC Contacts.</p> <p>Each of the three sections has buttons/ICommands for 'Add', 'Clear', 'Previous' and 'Next' that move through the collection of objects.</p> <p>I'm trying to work out how I can remove the repeated cod...
[]
[ { "body": "<p>If I understand correctly what you're doing, I think what you need is a <code>UserControl</code> that encapsulates some <code>AddressBookCommand</code>, <code>ClearCommand</code>, <code>NextCommand</code> and <code>PreviousCommand</code> commands.</p>\n\n<p>Your main <em>view</em> would have 3 ins...
{ "AcceptedAnswerId": "44154", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T08:25:42.923", "Id": "44040", "Score": "5", "Tags": [ "c#", "wpf", "email" ], "Title": "Managing Contact Collections" }
44040
<p>I created a very basic "image projector" that shows the current one and shows the next on clicking into the image.</p> <p>And yeah, it works, but I don't think that's a very elegant way to do it. Any advice please?</p> <p>Bear in mind I'm just starting my JavaScript classes and that's my third assignment, but the ...
[]
[ { "body": "<pre><code>window.onload = function loadFirst() {\n var n = 0; //Initial counter \n var images = document.getElementById(\"list\").children; //get length of images carousel\n images[n].style.display = \"block\"; //set first image visible\n document.getElementById(\"btn\").onclick = functi...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T08:56:11.017", "Id": "44044", "Score": "0", "Tags": [ "javascript", "dom", "image" ], "Title": "Image Carousel in JavaScript" }
44044
<p>Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix:</p> <blockquote> <p><strong>'100' is a magic number.</strong></p> </blockquote> <p>Consider this code:</p> <pre><code>public double getPercent(double rate) { return rate * 100; } public double getRate(double percent)...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T09:24:28.643", "Id": "76219", "Score": "17", "body": "I've written a [rant on stupid linters](http://programmers.stackexchange.com/a/223625/60357) over on programmers. Adding a named constant for the `100` here would just be obfusca...
[ { "body": "<p>Speaking as a human programmer (i.e. I am not Lint software), your use of \"100\" there looks fine to me.</p>\n\n<p>Wikipedia has an article (without citations) titled <a href=\"http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Accepted_limited_use_of_magic_numbers\">Accepted limited use...
{ "AcceptedAnswerId": "44051", "CommentCount": "13", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T09:06:46.817", "Id": "44047", "Score": "99", "Tags": [ "java", "constants" ], "Title": "'100' is a magic number" }
44047
<p>This is a very basic script. If the screen width is larger than say a tablet, and a portfolio link is hovered over, it will fade out the original text and replace it with the text held in the 'data-portfolio' attribute. I'm fairly new to jQuery so any improvements will be welcomed.</p> <p>You can see it working <a ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T10:06:11.150", "Id": "76225", "Score": "0", "body": "By the looks of it you have a bunch of implicit global variables, `width`, `prev` and `data`. Are those really meant to be global? Are we missing some code?" }, { "Content...
[ { "body": "<p>First off, you should clean up the indention. Currently the wrong indention makes the code hard to read.</p>\n\n<p>The next problem is that your variables <code>width</code>, <code>prev</code> and <code>data</code> are lacking the <code>var</code> keyword making them global und thus making the sur...
{ "AcceptedAnswerId": "44052", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T09:58:37.960", "Id": "44049", "Score": "6", "Tags": [ "javascript", "jquery", "beginner", "html5" ], "Title": "Data attribute text() swap on hover" }
44049
<p>I've written a query to compare the clients in our database with the people in a list that I've received. It needs to check if anyone from the list is one of our clients. I've created a temporary table which has been filled with the names and the query below makes a cross-join with the two tables. That query works v...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T22:27:14.663", "Id": "76378", "Score": "0", "body": "Rolled back the change you made in Rev 3. (Please don't edit questions in a way that invalidates answers.)" } ]
[ { "body": "<p>Fundamentally, at some point, you have to do a cross-join to calculate your results. Performance will be a problem... but there are things that can be done.</p>\n\n<p>First though, why the ugly SQL? Formatting SQL to make it readable is not hard to do:</p>\n\n<pre><code>select C.NUMCLI,\n C....
{ "AcceptedAnswerId": "44162", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T11:07:32.083", "Id": "44054", "Score": "11", "Tags": [ "optimization", "performance", "sql", "oracle", "edit-distance" ], "Title": "Comparing client lists with Cross Jo...
44054
<p>Is there a way I can write this function with less code?</p> <p><strong>jQuery</strong></p> <pre><code>function displayError(display, string, xhr) { var args = arguments; var $error = $("div#error"); var visible = $error.is(":visible"); if(args.length == 1 &amp;&amp; typeof display === "boolean" &...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T12:52:05.613", "Id": "76253", "Score": "0", "body": "You should remove the `b` element and its hard-coded color and move the styling to the CSS." } ]
[ { "body": "<p>I don't use Javascript, but i could write it in this way:</p>\n\n<pre><code>function displayError(display, string, xhr) \n{\n var args = arguments;\n var $error = $(\"div#error\");\n var visible = $error.is(\":visible\");\n\n if (!display)\n {\n $error.slideUp();\n }\n ...
{ "AcceptedAnswerId": "44060", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T11:28:30.513", "Id": "44057", "Score": "5", "Tags": [ "javascript", "jquery", "html" ], "Title": "Shorter way of writing my displayError() function?" }
44057
<p>I want to optimize a Perl function which is frequently used in my application. The function creates a special datastructure from the results of <code>DBI::fetchall_arrayref</code> which looks like:</p> <pre><code>$columns = ['COLNAME_1','COLNAME_2','COLNAME_3'] $rows = [ ['row_1_col_1', 'row_1_col_2', 'row_1_col...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T12:12:11.327", "Id": "76245", "Score": "0", "body": "Just a note: It seems (`$self`) you are using the subroutine as a method. You can remove the prototypes `($$)` as they are ignored in method calls anyway." } ]
[ { "body": "<p>The following code is about 35% faster (measured with <a href=\"http://p3rl.org/Benchmark\" rel=\"nofollow\">Benchmark</a>). The tricks:</p>\n\n<ul>\n<li><p>no anonymous array created for <code>$tmp</code>.</p></li>\n<li><p>explicit <code>return</code> removed.</p></li>\n<li><p>variables created i...
{ "AcceptedAnswerId": "44061", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T11:55:05.273", "Id": "44059", "Score": "3", "Tags": [ "performance", "perl" ], "Title": "Performance optimization in function for datastructure mapping" }
44059
<p>I have a strongly typed enum and <code>std::vector</code> of this type.</p> <pre><code>enum class Colors { red, green, blue }; std::vector v = { Colors::blue, Colors::red }; </code></pre> <p>I trying to output <code>v</code> to standard output via <code>std::copy</code>.</p> <pre><code>std::copy(v.begin(), v.end(...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T13:08:58.390", "Id": "76257", "Score": "0", "body": "Why do you want to avoid defining an `operator<<` or using a range-based for loop?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T13:29:33.480", ...
[ { "body": "<p>It seems to me that if you want to insert an object into a stream, the \"right\" way to do it is normally to define an <code>operator&lt;&lt;</code> for that type. That goes for strongly typed enums just as much as it does for class/struct objects.</p>\n\n<pre><code>#include &lt;iostream&gt;\n#inc...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T12:53:52.373", "Id": "44063", "Score": "9", "Tags": [ "c++", "c++11", "enum", "boost", "container" ], "Title": "Converting data when output std container via ostream_itera...
44063
<p>I am writing an application that uses <code>ASP.NET MVC</code> for its front end, and for the back end, it uses <code>RavenDB</code> to store data. This has so far worked out great, but I am hitting a huge wall with the use of <code>enum</code> in selecting things.</p> <p>The problem comes with front end interactio...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T14:43:21.660", "Id": "76280", "Score": "0", "body": "I'm confused, why where you using an enum for a user defined drop down list? because that's what it sounds like you're describing but an enum is not user defined." } ]
[ { "body": "<p>It seems like you've gone to more trouble to avoid using <code>enum</code> than you would have had just using them. <code>enums</code> are just numbers with a mask, converting to an int to an <code>enum</code> and vica versa is quite simple in C#, they also have a <code>ToString</code> which makes...
{ "AcceptedAnswerId": "44072", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T13:24:08.230", "Id": "44066", "Score": "6", "Tags": [ "c#", "json", "enum", "asp.net-mvc" ], "Title": "Concerned with Enums, JSON, and ASP.NET MVC" }
44066
<p>The following code is used to find the usual_gp(General Practitioner) from <code>gpCollection</code> variable of type <code>TreeMap&lt;Long(Date)</code>, <code>SummableMap&lt;String(GPId)</code>, <code>Integer(GPCount)&gt;&gt;</code> and store result (usual GP) along with date on <code>usualGPCollection</code> Map.<...
[]
[ { "body": "<p>When you have cascading conditions like you have, it can become 'messy'. At some point the design-pattern <a href=\"http://en.wikipedia.org/wiki/Chain_of_responsibility_pattern\">'Chain of responsibility'</a> becomes useful....</p>\n\n<p>Consider an interface:</p>\n\n<pre><code>public interface GP...
{ "AcceptedAnswerId": "44075", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T13:35:32.370", "Id": "44069", "Score": "5", "Tags": [ "java", "optimization" ], "Title": "General practitioner collection" }
44069
<p>I always see comments about how a Unit Test should only be testing one piece of functionality. For the most part, I definitely agree with that assessment. However, I'm working on testing a method right now that has me pondering if being laxer on this ideal would be a better thing, so I'm curious to everyone's opinio...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T14:33:28.223", "Id": "76278", "Score": "0", "body": "Possibly Programmers? I can imagine this question working here though, if you include the tests." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T14...
[ { "body": "<p>In this case, what you're really trying to do is validate three <code>MessageDay</code>s, as the return values of one method. As you are only testing one thing (the successful return of a method), you need not worry about testing too many things. I would, however, reduce the amount of asserts to t...
{ "AcceptedAnswerId": "44079", "CommentCount": "9", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T13:45:06.373", "Id": "44071", "Score": "6", "Tags": [ "c#", "unit-testing", "assertions" ], "Title": "How should I structure my Unit tests for minimal Asserts?" }
44071
<p>Is this the good way to create a portfolio article in HTML5 or do you have any suggestions?</p> <p>Not sure about the section but I need it as overlay over the image. Is it better to use a DIV instead?</p> <pre><code>&lt;article class="three columns remove-all project"&gt; &lt;section class="project-information...
[]
[ { "body": "<p>A good reference for element semantics would be <a href=\"http://html5doctor.com/\" rel=\"nofollow noreferrer\">HTML5 Doctor</a>. You can read all about the tags and their intended purposes. From their overview for <a href=\"http://html5doctor.com/element-index/#section\" rel=\"nofollow noreferrer...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T14:03:10.327", "Id": "44073", "Score": "7", "Tags": [ "html", "html5" ], "Title": "Is this a good way to create an article in HTML5?" }
44073
<p>I'm in the middle of a project that was built around Microsoft's Message Queue service. During development all of our machines are on a domain and we were able to create a public queue accessible from the server and client.</p> <p>When moving this to our test server, I discovered that both the test server and produ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-02-05T16:57:55.960", "Id": "76285", "Score": "2", "body": "Just use private queues, they are still accessable remotely. See http://technet.microsoft.com/en-us/library/cc778392(v=ws.10).aspx. Public queues are a pain anyways, so this would...
[ { "body": "<p>What you have here is, IMHO, excellent.</p>\n\n<p>Couple nitpicks: </p>\n\n<ul>\n<li>I don't get why <code>RemoveAll</code> is returning the original content instead of <code>void</code> - also I'm expecting an exception to be thrown in <code>GetQueue</code> if the specified <code>key</code> doesn...
{ "AcceptedAnswerId": "47161", "CommentCount": "9", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-02-05T16:44:53.567", "Id": "44077", "Score": "3", "Tags": [ "c#", "memory-management", "queue" ], "Title": "MemoryCache as a message broker?" }
44077
A function is said to be idempotent when it can be called multiple times without changing the result.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T17:27:09.563", "Id": "44084", "Score": "0", "Tags": null, "Title": null }
44084
<p>My task was to create a menu that displays three items <code>(A,B,C)</code>, and has two nav buttons <code>&lt;-</code> and <code>-&gt;</code>. So for example, a menu of <code>(A, B, C, D, E)</code> starts off showing <code>A,B,C</code> and can press <code>-&gt;</code> twice to display <code>C,D,E</code>.</p> <p>My...
[]
[ { "body": "<p>I guess my first thought is that I'm not sure why JavaScript is being used to generate the HTML, when the information, or view model, so to speak, is hard coded. It seems the HTML markup could all be written directly on the page. </p>\n\n<p>If it is dynamic in nature, I think I would use an object...
{ "AcceptedAnswerId": "44117", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T17:28:57.840", "Id": "44085", "Score": "3", "Tags": [ "javascript", "jquery", "html", "dom" ], "Title": "Horizontal menu for 3 items" }
44085
<p>This is a user login (some session wrapper I managed to put together after a lot of web searching).</p> <p>It's for a simple CMS I'm trying to build. It only needs one user and there is no need for multiple user log in at the same time. It works, the problem being I think it has safety issues.</p> <p>It works li...
[]
[ { "body": "<h1>MVC</h1>\n<p>If you're trying to make a CMS, then there's a possibility that this CMS will become bigger than you first though. More pages, more modules, more code. You might want to consider doing an <a href=\"http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter\" rel=\"noreferrer\"...
{ "AcceptedAnswerId": "44091", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T17:47:13.457", "Id": "44087", "Score": "5", "Tags": [ "php", "beginner", "session", "authentication" ], "Title": "Safety issues in PHP log-in system" }
44087
<p>I'm trying to login into a webapi2 site from a desktop application. After a lot of googling, I cobbled together a working prototype. Since we are talking about security I wanted to do a peer review. I'm just starting with security design and I'm not exactly sure about my design.</p> <p>The WebAPI site that is targ...
[]
[ { "body": "<p>I don't like that the password is hard coded here</p>\n\n<pre><code>HttpContent requestContent = new StringContent(\"grant_type=password&amp;username=\" + Username + \"&amp;password=\" + Password, Encoding.UTF8, \"application/x-www-form-urlencoded\");\n</code></pre>\n\n<p>I am sure that you could ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T20:07:09.907", "Id": "44097", "Score": "11", "Tags": [ "c#", "security", "api" ], "Title": "Logging into WebAPI 2 site from c# desktop application" }
44097
<p>I created my own <code>indexOf</code> function. I was wondering if anyone could help me come up with a way to make it more efficient. I am practicing for interviews so the catch is that I cannot use any <code>String</code> methods. I believe the runtime of this method is O(n<sup>2</sup>) with space of O(n). Correct ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T00:24:15.933", "Id": "76389", "Score": "6", "body": "Wikipedia has a list of string substring searching algorithms with their time and space complexity. The faster it goes, the more complicated (and cool and innovative!) it is, but ...
[ { "body": "<p>Other answers are already covering what maybe matters more to you: space, time complexity, safety, correctness. I think you can do further steps in order to improve the code readability: if it was a production code it would be hard to maintain. Consider the following suggestions:</p>\n\n<ul>\n<li>...
{ "AcceptedAnswerId": "44107", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-11T20:33:38.930", "Id": "44100", "Score": "29", "Tags": [ "java", "performance", "algorithm", "strings", "search" ], "Title": "Custom indexOf() without String methods" }
44100
<p>I thought I would try and write a solution to the Wolf, Goat and Cabbage problem in Java 8 to try and get to grips with lambdas.</p> <p>I am looking for any feedback you might provide. The feedback I am looking for is mainly on code structure and where I could make more, or more simple, use of new Java 8 features.<...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T01:39:45.980", "Id": "76394", "Score": "2", "body": "That project lombok link is noisy (literally) and irritating. Makes a very, very bad first impression." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03...
[ { "body": "<h2>Commentry</h2>\n<blockquote>\n<p>So, this is not working code. I don't consider code to be working if\nneeds pre-processing, and the pre-processor is not shipped as part of\nthe standard toolchain.</p>\n<p>This code is nearly useless to anyone unless they have lambok.</p>\n<p>If I pull the code i...
{ "AcceptedAnswerId": null, "CommentCount": "8", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T01:20:22.280", "Id": "44115", "Score": "15", "Tags": [ "java" ], "Title": "Wolves, Goats and Cabbages in Java" }
44115
<p>This is a partial code of my JavaScript app.</p> <p>The <code>openDoc</code> function's task is: call <code>newDoc</code> if use uploads a file through <code>fileInput</code>. Or, when user drag and drop a file in the <code>document</code>.</p> <p>I want to review my logic and code.</p> <pre><code> function ...
[]
[ { "body": "<p>There is a not a lot to review, from a once over:</p>\n\n<ul>\n<li>Indenting is not good for <code>stopDefault</code>, but I guess that's from copy pasting</li>\n<li>There is no sense in calling <code>addEventListener</code> if <code>file</code> is not set, it should be part of your <code>if</code...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T06:05:59.547", "Id": "44124", "Score": "2", "Tags": [ "javascript", "html", "html5", "api" ], "Title": "Drag and normal upload code" }
44124
<p>This is my code for running a background thread. I believe it is very poor in naming and code structure.</p> <pre><code>package com.ocs.socialshare.bloggershare; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; imp...
[]
[ { "body": "<p>The first thing I would say is to use an <code>AsyncTask</code> here instead of normal Thread/Runnable. <code>AsyncTask</code> helps you to work better with the thread and UI thread better.</p>\n\n<p>It's a login system, so disable login buttons while the application is login to avoid the user to...
{ "AcceptedAnswerId": "44126", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T06:15:14.010", "Id": "44125", "Score": "7", "Tags": [ "java", "beginner", "android" ], "Title": "Android Thread and Runnable" }
44125
<p>While trying to learn more about linked lists, I thought I should try the exercise of reading two BigInts from an input file and then adding them up. My strategy was to store the two numbers in two different linked lists and then add the entries of the linked lists while traversing through them. I have my implementa...
[]
[ { "body": "<p>Just two things:</p>\n\n<ol>\n<li><p>In <code>convertToList()</code> you don't really use the first argument at all. You can code that function with receiving only the (read-only) input string.</p>\n\n<pre><code>LList *convertToList(const char *line) {\n /* ... */\n return temp;\n}\n</code><...
{ "AcceptedAnswerId": "44136", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T07:27:40.237", "Id": "44128", "Score": "5", "Tags": [ "c", "linked-list", "memory-management" ], "Title": "Adding two BigInts using linked lists in C" }
44128
<p>I've seen others use &amp;&amp; for conditionally continuing execution in bash, and found it effective but rather ugly. (I'm not sure if there's a better name for this technique.)</p> <pre><code>do_something &amp;&amp; something_else &amp;&amp; the_next_thing </code></pre> <p>Then I found out that you can simply w...
[]
[ { "body": "<p><strong>Firstly</strong>, this will most likely do a wrong thing if the first argument is empty:</p>\n\n<pre><code>if [ \"$1\" = \"--help\" ] || [ -z $1 ] || [ \"$2\" ];\n</code></pre>\n\n<p>You should probably use something like this instead (note added quotes):</p>\n\n<pre><code>if [ \"$1\" = \"...
{ "AcceptedAnswerId": "44133", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T08:28:31.867", "Id": "44131", "Score": "2", "Tags": [ "bash", "error-handling" ], "Title": "Is this an appropriate approach and layout for conditionally continuing execution in bas...
44131
<p>I want to refactor the following code because I don't feel comfortable about using assignment inside comparison operator. It looks like pretty idiomatic C, but do you think this is a good practice in Java?</p> <pre><code>private void demoA(BufferedReader reader) throws IOException { String line = null; whil...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T09:32:43.847", "Id": "76428", "Score": "0", "body": "You are mainly asking for a based-opinion answer, in my case the first approach has proven to be more clear when I need to choose between both, but it is just my case." }, { ...
[ { "body": "<p>Assignment inside a condition is ok in this case, as the assignment is surrounded by an extra pair of parentheses – the comparison is obviously <code>!= null</code>, there is no chance that we wanted to type <code>line == reader.readLine()</code>.</p>\n\n<p>However, a <code>for</code> loop might a...
{ "AcceptedAnswerId": "44137", "CommentCount": "7", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T09:24:30.523", "Id": "44135", "Score": "54", "Tags": [ "java", "stream" ], "Title": "Is it OK to use while ((line = r.readLine()) != null) construct?" }
44135
<p>I suppose this is a two-part question. The first part is just a simple implementation of a Binary Tree (<code>BTree</code>), with pre-order, post-order, and in-order searches implemented by default. The second is the <code>AmorphousBTreeCreator</code>(amorphous because the trees sit in a sort of limbo until they are...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T13:10:26.783", "Id": "76462", "Score": "0", "body": "What is the purpose of BTree? This is not a heap, search is O(N), so it not better than a list." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T13:...
[ { "body": "<p>Review for <code>Node</code> and <code>BTree</code> classes. Stay tuned for more.</p>\n\n<p>I know that this is a religious question, but Java people really like OTBS.</p>\n\n<pre><code>class BTree&lt;T&gt;\n{\n private Node&lt;T&gt; head;\n\n public BTree(T head)\n {\n this.head = new Node&...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T10:41:07.003", "Id": "44139", "Score": "10", "Tags": [ "java", "optimization", "tree" ], "Title": "Binary Tree/ Amorphous Binary Tree Creator" }
44139
<p>I've made a function that takes an array of amounts owed by each user_id and works out the best way to square everyone up. The input array would look something like this, but may consist of 1 or more "users" who all owe (or are owed) money between each other:</p> <pre><code>//the owings should sum to 0. $owings = a...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T12:00:48.520", "Id": "76449", "Score": "0", "body": "When you say the best way do you mean the least number of payments?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T12:06:50.427", "Id": "76452...
[ { "body": "<p>Well if you want to split hairs, you could do a couple of minor changes (commented below)</p>\n\n<p>Honestly, I can't see any advantage in making it recursive, it works fine as it is</p>\n\n<pre><code>function settleUp($owings){\n $reimbursments = array();\n\n// $i is never used\n // $payment...
{ "AcceptedAnswerId": "44143", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T10:52:23.103", "Id": "44140", "Score": "3", "Tags": [ "php" ], "Title": "Can this PHP code to settle up payments be improved?" }
44140
<p>I have a program that gets 5 random dice throws from <a href="http://random.org/" rel="nofollow">random.org</a> over and over. In order to avoid doing <code>getaddrinfo()</code> over and over with the exact same data, I moved some of the code to an initialization function (and an unused finalization function).</p> ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T11:59:30.830", "Id": "76447", "Score": "0", "body": "If what you want is to get random numbers, there should be an easiest way ;-)" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T12:00:36.340", "I...
[ { "body": "<h1>Things you could improve:</h1>\n\n<h3>Dependencies:</h3>\n\n<ul>\n<li><p>You are <strong><em>way</em></strong> overdoing this problem. By a lot. You can generate pseudo-random on your computer just fine. There is no reason to create a dependency on the internet for that. What if you don't hav...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T11:57:17.707", "Id": "44145", "Score": "6", "Tags": [ "c", "networking", "socket", "http" ], "Title": "Checking web-page repeatedly" }
44145
<p>I am new to threading and I am a junior developer, so I guess there are many mistakes. My scenario is this:</p> <ul> <li>look into the database</li> <li>if there are data which should be sent <ul> <li>add the data to the queue</li> </ul></li> <li>if queue is not empty <ul> <li>send the next message and remove it fr...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-07-30T08:34:16.890", "Id": "104984", "Score": "0", "body": "You may opt for tasks, instead of threads. To me your code look like a self rolled message bus on a db , you may consider msmq for the same purpose if possible." } ]
[ { "body": "<p>This looks pretty good to me. I am not that good at threads myself, so I won't comment on the thread safety, but these are a few things I noticed.</p>\n\n<p>This is fine as it is, but you might want to consider making this a ternary:</p>\n\n<pre><code>if (Services.Count != 0)\n{\n SetNextSerAn...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T11:59:40.213", "Id": "44146", "Score": "4", "Tags": [ "c#", "multithreading", "thread-safety" ], "Title": "Database threading design" }
44146
<p>The Rapheal script seems to be too long. Is there any option to make it shorter ?</p> <p>I think <code>loop</code> can make this script smaller. Does anyone have good suggestions or advice?</p> <p><a href="http://jsfiddle.net/sweetmaanu/Ta8mR/5/" rel="nofollow">http://jsfiddle.net/sweetmaanu/Ta8mR/5/</a></p> <p...
[]
[ { "body": "<p>A naming scheme like <code>foo3_2</code> suggests that you want a two-dimensional array instead:</p>\n\n<pre><code>var safetyBar1_1 = { width:30, height:150, x:60,y:50};\nvar safetyBar1_2 = { width:30, height:130, x:90,y:70};\nvar safetyBar2_1 = { width:30, height:165, x:140, y:35};\nvar safetyBar...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T12:26:10.187", "Id": "44148", "Score": "2", "Tags": [ "javascript", "jquery", "raphael.js" ], "Title": "How to shorten the JavaScript in Raphaël?" }
44148
<p>I get a <code>map</code> from <code>DB</code> called <code>doc1</code> and I also have the <code>arrayList</code> called <code>someWord</code>. I will find the subscription of <code>doc1</code> and <code>someWord</code> and store it in <code>doc2</code>. I will also add the intersecting words with zero index in <c...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T13:03:32.620", "Id": "76460", "Score": "0", "body": "Could post all the code? What is Neighbor class? What is dbDocMeta?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T13:33:05.087", "Id": "76471...
[ { "body": "<p>You should declare variables in the smallest possible scope. E.g. instead of</p>\n\n<pre><code>String family;\nfor (...) {\n family = ...;\n ...\n}\n</code></pre>\n\n<p>we could do</p>\n\n<pre><code>for (...) {\n String family = ...;\n ...\n}\n</code></pre>\n\n<p>The same applies to <...
{ "AcceptedAnswerId": "44160", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T12:47:54.777", "Id": "44150", "Score": "3", "Tags": [ "java", "optimization", "iteration" ], "Title": "Intersection of words" }
44150
<p>I created an <code>enum</code> for a class and in the constructor I inserted all the <code>enum</code> values into a set. I am wondering if there is a better way anyone can recommend. I feel like there should be, but have been unable to think of one or find one online. I wrote the code in C++ and am using the Boo...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-13T02:17:33.247", "Id": "76633", "Score": "0", "body": "Like the fellow asking http://codereview.stackexchange.com/q/35208/32004 it sounds like you might be looking for [n3815](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3...
[ { "body": "<p>You can iterate over the <code>enum</code> and insert each one individually.</p>\n\n<pre><code>for ( int i = FIXED_VOLTAGE1; i != FIXED_VOLTAGE4; i++ )\n{\n m_modules.insert(CreateAndUseIniFile::static_cast&lt;iniFileValues&gt;(i));\n}\n</code></pre>\n\n<p><strong>Note</strong>: This will work ...
{ "AcceptedAnswerId": "44163", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T14:28:26.260", "Id": "44158", "Score": "7", "Tags": [ "c++", "enum", "set" ], "Title": "Is there a better way to insert an enum into a set without macros?" }
44158
<p>Description of my code:</p> <p>I am trying to maximize the number of nodes that could be reachable in a graph. Please do not consider my main algorithm, I want it to be like that. The only parts that I need to be boosted are the way of using data structures and reachability. I don't want to change my main algorithm...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T14:50:11.770", "Id": "76479", "Score": "1", "body": "Have you profiled your code?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T14:51:34.743", "Id": "76480", "Score": "0", "body": "What ...
[ { "body": "<p>Lots to think about, this is not a comprehensive evaluation</p>\n\n<h2>Use Java7</h2>\n\n<p>your code style indicates you are using Java6 (you are not using the <a href=\"http://www.javaworld.com/article/2074080/core-java/jdk-7--the-diamond-operator.html\" rel=\"nofollow\">diamond operator <code>&...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T14:43:59.717", "Id": "44159", "Score": "4", "Tags": [ "java", "performance", "graph" ], "Title": "Maximize the number of nodes that could be reachable in a graph" }
44159
<p>I have a working script that selects image fields in all tables and empty their values if the physical file doesnt exist.</p> <pre><code> $query1 = "SELECT table_name,column_name FROM information_schema.columns WHERE table_schema='schemaname' AND column_name like '%image%' or column_name='v...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T15:38:12.120", "Id": "76496", "Score": "2", "body": "For the sake of ease (of writing, reading and thus maintaining) I would recommend using PDO instead of using the MySQL drivers like that. It's more secure too once you start worki...
[ { "body": "<p>The <a href=\"http://www.php.net/manual/en/intro.mysql.php\" rel=\"nofollow noreferrer\"><code>mysql_*</code> functions are deprecated</a>. Use <code>mysqli</code> or PDO instead.</p>\n\n<p>Each query that you issue has a rather large overhead: you have to communicate the query to the server; the...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2014-03-12T14:44:36.997", "Id": "44161", "Score": "7", "Tags": [ "php", "optimization", "mysql", "sql" ], "Title": "Removing image records if no physical file exists" }
44161