body stringlengths 25 86.7k | comments list | answers list | meta_data dict | question_id stringlengths 1 6 |
|---|---|---|---|---|
<p>I am learning Nimrod and needed a few functions from <code>libsndfile</code>. I deviated slightly from <code>libsndfile</code> to use namespace and stronger types that is available in Nimrod.</p>
<pre><code>when defined(windows):
const soname = "libsndfile.dll"
elif defined(macosx):
const soname = "libsndf... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T18:28:44.640",
"Id": "57600",
"Score": "2",
"Tags": [
"nim"
],
"Title": "Wrapper for Nimrod"
} | 57600 |
<p>This query currently takes approximately 250 seconds to run and I'd like to reduce it by as much as I can. I have tried using left joins instead of subqueries and it increases run time.</p>
<pre><code>SELECT `items`.`id`,
ifnull((SELECT sum(`history`.`quantity`) FROM `history` where `history`.`itemID` = `items`.`i... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T20:46:18.193",
"Id": "103092",
"Score": "0",
"body": "What is the documented/expected result of this sub-select: `SELECT round(\\`supply\\`) FROM \\`supply\\` WHERE \\`itemID\\` = \\`items\\`.\\`id\\` AND \\`date\\` > date_sub(now()... | [
{
"body": "<p><strong>Formatting</strong></p>\n\n<p>First, the way you wrote this makes it difficult to understand what you are trying to do. Here are a few points to improve it:</p>\n\n<ul>\n<li>Use indentation and line breaks that illustrates your nesting. I provided an example below.</li>\n<li>Use all caps f... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T18:37:31.130",
"Id": "57602",
"Score": "4",
"Tags": [
"performance",
"sql",
"mysql"
],
"Title": "Multiple dependent subqueries"
} | 57602 |
<p>I am using C# to get the user's input of how many buttons to change the color of. The buttons are in rows that have 1-10 button in each. If the user enters 11, then the entire first row will be filled out and the first button on the second row will change color. I have figured out how to accommodate for different... | [] | [
{
"body": "<p>This one's pretty straightforward. If you have rows of length <code>rowLength</code>, then the row is <code>j / rowLength</code> (note that with integer arithmetic this automatically rounds down to the nearest integer) and the column is <code>j % rowLength</code>.</p>\n\n<hr>\n\n<p>Altough there w... | {
"AcceptedAnswerId": "57604",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T18:42:18.590",
"Id": "57603",
"Score": "8",
"Tags": [
"c#"
],
"Title": "Changing button colors based on user input"
} | 57603 |
<p>I've written an interpreter for a simple assembly-like language and it's performing slower than I would like.</p>
<p>It's split into 3 files: the Parser that converts the source to a vector of ints, the VM that actually runs the bytecode, and Tests that has a bubble sort written in the language.</p>
<p>It sorts 10... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T05:25:10.860",
"Id": "103140",
"Score": "0",
"body": "I don't see anything obviously bad, except that you're benchmarking ghci's interpreter. It's not designed to be efficient. Try compiling with optimizations."
},
{
"Conten... | [
{
"body": "<p>Based on my investigations, I'm going to say that your problem is exactly what I said in the comments: performance testing with ghci.</p>\n\n<p>I modified VM.hs a bit, to get it to build:</p>\n\n<pre><code>{-# LANGUAGE BangPatterns #-}\n\nmodule VM where\n\nimport Parser (ByteCode, OpCode(..), ari... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T19:02:29.727",
"Id": "57605",
"Score": "7",
"Tags": [
"performance",
"haskell",
"interpreter"
],
"Title": "Primitive stack-based code interpreter"
} | 57605 |
<p>Edit: This was an absolute ignorance on my part which leads to hierarchical locks and can be implemented much cleaner (in fact the right way, in a mutable world) using a pipe-line of messages or Agents. Please consider studying other actor models in .NET (like the one in F#).</p>
<p>What are drawbacks/benefits of t... | [] | [
{
"body": "<p>I don't like the way you're (ab)using LINQ. Instead I would use syntax like:</p>\n\n<pre><code>globalIdServer.Run(x => x.Generate())\n</code></pre>\n\n<p>This is shorter than your approach and I think it makes it clearer what's going on.</p>\n\n<p>EDIT: Actually, your <code>Send()</code> alread... | {
"AcceptedAnswerId": "57696",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T19:39:55.257",
"Id": "57611",
"Score": "2",
"Tags": [
"c#",
"actor"
],
"Title": "Light Weight Actors"
} | 57611 |
<p>The use case is to convert an array of objects into a hash map where one property is the key and the other property is the value. Common case of using this is converting a "link" object in a hypermedia response into a hash map of links.</p>
<p><a href="http://jsfiddle.net/MrRampage/d4sXq/"><strong>jsfiddle</strong>... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2016-11-17T23:10:58.557",
"Id": "276937",
"Score": "0",
"body": "I've compiled the most common ways to turn an object into an array in [this lodash feature request](https://github.com/lodash/lodash/issues/2718) _(which currently needs upvotes!... | [
{
"body": "<p>I think you are looking for <code>_.keyBy</code> (or <code>_.indexBy</code> in older versions)</p>\n\n<pre><code>_.keyBy(data, 'rel');\n</code></pre>\n",
"comments": [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2015-02-17T15:53:44.147",
"Id": "147112",
... | {
"AcceptedAnswerId": "57615",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T20:01:42.227",
"Id": "57614",
"Score": "88",
"Tags": [
"javascript",
"beginner",
"lodash.js"
],
"Title": "Convert object array to hash map using lodash"
} | 57614 |
<p>I looked at a bunch of AngularJS directives checking for uniqueness of a username and decided to try for the simplest implementation. It does what I want but may not really be 'idiomatic' Angular.</p>
<p>Here is the form element:</p>
<pre><code><input type="text"
name="username"
ng-model="form.username"... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-08-03T05:10:07.897",
"Id": "105893",
"Score": "0",
"body": "I would avoid naming `thisform...`, too easy to confuse with `this.form...`"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2015-03-09T15:00:46.710",
"Id... | [
{
"body": "<p>Here's my two cents. These are the changes that I would make:</p>\n\n<ul>\n<li>Separate the API calls into a service.</li>\n<li>Separate the event triggers using the model-options in the view.</li>\n<li>Handle the monitoring using a watch. (Expensive, but it seems to be the \"angular\" way.)</li>\... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T21:01:19.740",
"Id": "57619",
"Score": "4",
"Tags": [
"javascript",
"angular.js"
],
"Title": "Angular directive for unique username"
} | 57619 |
<p>I've been working on this module with the assistance of codereview, and based on the responses and my own research, this is my project so far. The goal behind the code is that it starts with a .NET bitmap object, extracts the byte array of image data from the bitmap, then transforms it into an array of arrays or mat... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T22:53:33.587",
"Id": "103106",
"Score": "0",
"body": "*a square \"jagged\" array* <-- does not make much sense to me.... just saying."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T22:54:06.280",
... | [
{
"body": "<p>By convention, F# function names are <code>camelCase</code>, for example <code>transform2D</code> instead of <code>Transform2D</code>.</p>\n\n<hr>\n\n<p><a href=\"http://en.wikipedia.org/wiki/Hungarian_notation\" rel=\"nofollow\">Hungarian notation</a> is dead and buried. For example, use <code>bi... | {
"AcceptedAnswerId": "57632",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T22:31:40.330",
"Id": "57625",
"Score": "4",
"Tags": [
"image",
"f#"
],
"Title": "Transform Bitmap object into jagged array of RGB tuple values"
} | 57625 |
<p>For a small project I'm working on, I've been looking for an iterable <code>enum</code>-like class in C++, since neither C-style nor scoped <code>enum</code>s seem to support iteration in a way that isn't hack-y. I stumbled across <a href="http://www.drdobbs.com/when-enum-just-isnt-enough-enumeration-c/184403955" re... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T00:14:25.787",
"Id": "103114",
"Score": "0",
"body": "http://codereview.stackexchange.com/questions/14309/conversion-between-enum-and-string-in-c-class-header?rq=1"
}
] | [
{
"body": "<p>You are no longer using the enum properties.</p>\n<pre><code>const Color Color::blue(0);\nconst Color Color::green(1);\nconst Color Color::red(2);\nconst Color Color::white(3);\nconst Color Color::yellow(4);\nconst Color Color::multicolor(5);\nconst Color Color::hidden(6);\n</code></pre>\n<p>But r... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-21T23:30:10.120",
"Id": "57626",
"Score": "9",
"Tags": [
"c++",
"c++11",
"enum"
],
"Title": "Iterable enum class in C++11"
} | 57626 |
<p>I have a chunk of code that get's all of the <code>ICollection</code> properties of the passed in object and then takes all of their values and adds them to another <code>ICollection</code>. </p>
<blockquote>
<p>End goal is to see which properties have child objects in them and
thus finding out how many depende... | [] | [
{
"body": "<p>First up, let's clean up the formatting a bit.</p>\n\n<pre><code>public class DependencyValidator<TEntity> :\n IDependencyValidator<TEntity>\n where TEntity : class\n{\n private readonly Type IEnumerableType = typeof(IEnumerable);\n private readonly Type StringType = typeof... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2014-07-22T00:29:19.180",
"Id": "57628",
"Score": "7",
"Tags": [
"c#",
"reflection"
],
"Title": "Find all collection properties of an object and get their values"
} | 57628 |
<p>Wow, this one is definitely going to need some improvement. </p>
<p>So, just for fun, I decided to make a program where the player moves across a 2-dimensional ASCII-art map. If the player types something such as <code>down</code>, the on screen representation moves down and "loads" a bit more of the map.</p>
<pre... | [] | [
{
"body": "<p>A few comments:</p>\n\n<ul>\n<li><p>You already did a good job with PEP8. The only error I get back is that it expects two blank lines between functions</p></li>\n<li><p>Regarding PEP257, please add some docstrings and comments to make clear what's the code goal to the potential reader</p></li>\n<... | {
"AcceptedAnswerId": "57651",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T00:50:12.687",
"Id": "57630",
"Score": "5",
"Tags": [
"python",
"game",
"python-2.x"
],
"Title": "Moving the player across an ASCII art \"world\""
} | 57630 |
<p>Official website: <a href="http://nimrod-lang.org/" rel="nofollow">http://nimrod-lang.org/</a></p>
| [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T04:15:29.607",
"Id": "57641",
"Score": "0",
"Tags": null,
"Title": null
} | 57641 |
Nimrod is a statically typed, imperative programming language that combines pascal semantics with a python-like syntax and extensive support for meta-programming. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T04:15:29.607",
"Id": "57642",
"Score": "0",
"Tags": null,
"Title": null
} | 57642 |
<p>I have taken over maintenance of some code, and have restructured it after reading some documents about PSR-2:</p>
<pre><code><?php
function calc_p()
{
list($arg1, $arg2, $arg3) = func_get_args();
switch($arg1) {
case 'ebook':
$bp = 5;
$tax = .08;
break;
... | [] | [
{
"body": "<p>I've been waiting for this question to be reopened because the formatting issues here are quite extraordinary! I think I'll keep this post to a clean code/code styling post exclusively, that way others can touch on purpose and implementations.</p>\n\n<p>I think what's required here is a bullet poi... | {
"AcceptedAnswerId": "58000",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T04:24:45.447",
"Id": "57643",
"Score": "2",
"Tags": [
"php",
"finance"
],
"Title": "Calculating the price of digital media"
} | 57643 |
<p>A while ago I posted <a href="https://codereview.stackexchange.com/questions/49602/worker-ai-and-job-queue-management-for-simulation-game">this question</a> about worker AI and Job Queues for a strategy game. I have posted other questions about the Job Queue, and now I would like to post this revised question about... | [] | [
{
"body": "<pre><code>-(void) tryToChooseAJobWhileIdle\n</code></pre>\n\n<p>You don't need to say \"try\". I think this method name is fine as \"chooseJobWhileIdle\" or maybe even \"lookForJob\", \"findJob\", or maybe \"idleJobSearch\" perhaps. The current method name is verbose, yes, and we like that in Obje... | {
"AcceptedAnswerId": "57668",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T05:23:55.940",
"Id": "57645",
"Score": "3",
"Tags": [
"object-oriented",
"game",
"objective-c",
"simulation",
"ai"
],
"Title": "Revised worker movement AI for strategy ... | 57645 |
<p>I have written the following code using a dynamic programming technique. Can I use <code>ArrayList</code> here? Please let me know if I can improve this code.</p>
<pre><code>package com.java.fib;
import java.math.BigInteger;
import java.util.HashMap;
public class Fibonaci {
public static void main(String[]... | [] | [
{
"body": "<p>A few things:</p>\n\n<h1>Naming:</h1>\n\n<p>It's neither <code>Fibonaci</code>, nor <code>febonani</code>, nor <code>fibonanci</code> it's <code>fibonacci</code>. Please get your names to reflect what you're actually talking about and not some disfigured mutation of it :(</p>\n\n<p><code>memoized<... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T05:27:28.653",
"Id": "57646",
"Score": "12",
"Tags": [
"java",
"optimization",
"fibonacci-sequence",
"dynamic-programming",
"memoization"
],
"Title": "Dynamic programming ... | 57646 |
<p>I have a class that always has 14 instances. I'm just wondering if there is a better or more effective way of doing this. In this class I also have an array that is filled by calling 4 functions multiple times. Because this class is instanced 14 times, the array is duplicated a lot. What would be a better way to d... | [] | [
{
"body": "<p>This code can indeed use some Refractoring. Different approaches could be used here: </p>\n\n<blockquote>\n <p>a __toString method can not be used here as Elias pointed out in the comments</p>\n</blockquote>\n\n<h1>Implement a toArray() method on the Machine Object:</h1>\n\n<pre><code>public func... | {
"AcceptedAnswerId": "57688",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T07:57:44.510",
"Id": "57649",
"Score": "5",
"Tags": [
"php",
"array",
"classes"
],
"Title": "Initiating class objects and arrays"
} | 57649 |
<p>Given a Perfect Binary Tree, reverse the alternate level nodes of the binary tree. </p>
<blockquote>
<p>Given tree: </p>
<pre><code> a
/ \
b c
/ \ / \
d e f g
/ \ / \ / \ / \
h i j k l m n o
</code></pre>
<p>Modified tree:</p>
<pre><code> ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T09:35:01.320",
"Id": "103161",
"Score": "0",
"body": "Is your omission of a generic type in `new TreeNode<>` intentional?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T19:33:40.940",
"Id": "1033... | [
{
"body": "<p>A minor bug: You get an <code>IndexOutOfBoundsException</code> for an empty list in <code>SwapTreeLevelsValues.create(List<T> items)</code>. You don't have a comment stating you need to input a list containing at least something. Consider returning <code>IllegalArgumentException</code> and a... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T08:47:44.803",
"Id": "57652",
"Score": "3",
"Tags": [
"java",
"algorithm",
"tree"
],
"Title": "Reverse values of alternate nodes of the tree"
} | 57652 |
<p>I have a vector of <code>uint16_t</code> and I want to check if there is a bit which is only set in one vector. I then get its position within the vector as well as from the bit.</p>
<p>Let's say we have:</p>
<pre><code>v[0] = 0100
v[1] = 0110
v[2] = 1001
</code></pre>
<p>I would like to know that <code>ind = 1<... | [] | [
{
"body": "<p>Let me start by pointing out problems in your code:</p>\n\n<h2>Wrong type</h2>\n\n<p>The type of your global constant <code>N</code> is <code>uint16_t</code>. There are several problems with this:</p>\n\n<ul>\n<li>as you are using <code>cstdint</code> the type should be <code>std::uint16_t</code> ... | {
"AcceptedAnswerId": "57679",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T09:41:49.197",
"Id": "57655",
"Score": "8",
"Tags": [
"c++",
"c++11",
"bitwise"
],
"Title": "Check if bit is only set once in a vector of int"
} | 57655 |
<p>I decided to re-write my code responsible for WCF calls, as all of my methods had <code>try</code>-<code>catch</code>-<code>finally</code> blocks. I read that it is bad idea to use a <code>using()</code> statement as it does not close the WCF connection. After digging around, I found a solution based on delegates. Y... | [] | [
{
"body": "<p>You don't want to use <code>Task.Run</code> from WebAPI (or other service frameworks) because that interferes with the ASP.NET thread pool heuristics.</p>\n\n<p>Instead, use the naturally-asynchronous methods that are available in your WCF client proxy. (Side note: if the proxy is from a very old ... | {
"AcceptedAnswerId": "57820",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T10:03:14.847",
"Id": "57656",
"Score": "5",
"Tags": [
"c#",
"asynchronous",
"delegates",
"wcf",
"asp.net-web-api"
],
"Title": ".NET WCF Activator for sync and async cal... | 57656 |
<p>I wrote this to consume valid IPv4 addresses in dotted-quad decimal form:</p>
<pre><code>def dotted_ip_to_num ip
strings = ip.split('.').reverse
strings.each_with_index.inject(0) do |sum, pair|
str, i = pair
sum + str.to_i * (2 ** (i * 8))
end
end
</code></pre>
<p>But my chain of <code>each_with_inde... | [] | [
{
"body": "<p>Some notes:</p>\n\n<ul>\n<li><p>As you say in your answer, you can unpack block arguments with the syntax <code>|arg1, (arg2, arg3)|</code>.</p></li>\n<li><p>I'd always write parentheses in the method definition, it looks more clear (subjective, of course).</p></li>\n<li><p>Instead of doing two th... | {
"AcceptedAnswerId": "57663",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T10:05:28.840",
"Id": "57657",
"Score": "3",
"Tags": [
"ruby",
"parsing",
"functional-programming",
"collections",
"ip-address"
],
"Title": "Evaluating a dotted quad IP ... | 57657 |
<p>I developing an algorithm to read a row from a table (specifically, I'm reading from an Excel file).</p>
<p>I have three conditions about when to terminate the Read operation:</p>
<ul>
<li>When an empty cell is found (recognized by an <code>ElementNotFoundException</code></li>
<li>When a cell with errors is found ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T12:53:22.483",
"Id": "103190",
"Score": "1",
"body": "Please see this meta post. [For an iterative review, is it ok to include revised code?](http://meta.codereview.stackexchange.com/questions/1763/for-an-iterative-review-is-it-okay... | [
{
"body": "<ul>\n<li>You always terminate the reading of the row if the element isn't found. This means you can have just one Try-Catch block that wraps your If statement. </li>\n<li>Instead of checking for <code>&&</code> in your first statement, use <code>||</code> (or instead of and). You don't reall... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T10:17:51.180",
"Id": "57658",
"Score": "5",
"Tags": [
"c#",
"excel"
],
"Title": "Read table row with multiple options"
} | 57658 |
<p>I have the following scenario - i have a grid on web page that is populated with data. User can check a check-boxes in grid and data is saved to DB on navigating to next page. If they then navigate back to the page and remove a selection the data is deleted from the DB and also if the original selection is still c... | [] | [
{
"body": "<p>To clean up your controller I came up with this:</p>\n\n<ul>\n<li>entire logic is moved to your <code>CarService</code></li>\n<li>method <code>CarModelsToRemoveFromDb</code> is also moved to <code>CarService</code></li>\n<li><code>CarService</code>has two overloads for method <code>Update</code></... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T10:28:01.120",
"Id": "57659",
"Score": "3",
"Tags": [
"c#",
".net"
],
"Title": "Reduce logic in Web API controller"
} | 57659 |
<p>I have a data table and have to validate every field in it. I have refactor this code to this below, but the complexity is 15(!!) Should I make something like dictionary with <code>type</code> as Key and <code>Func</code> as Value? </p>
<pre><code>private bool CheckField(DataRow dataRow, ValidationField validation... | [] | [
{
"body": "<p>Just a small note about this:</p>\n\n<pre><code>public bool Requiered { get; set; }\n</code></pre>\n\n<p>I can't tell if it's supposed to be <code>Required</code> or <code>Requeried</code>. Either way, it's a typo that needs to be corrected. </p>\n",
"comments": [],
"meta_data": {
"... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T10:49:41.080",
"Id": "57660",
"Score": "7",
"Tags": [
"c#",
"validation"
],
"Title": "Refactor a selection validator"
} | 57660 |
<p>As part of a C# class <code>CsvConverter</code> that converts various file types to CSV, I am designing a private class <code>CsvConversionResult</code>. My current design choice is to return a <code>null</code> value of <code>CsvConversionResult</code> if processing is successful.</p>
<p>What can I add to or remov... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T11:01:13.837",
"Id": "103169",
"Score": "3",
"body": "\"Returning primitive data types is out of the question since I want to return more than one thing.\" Could you expand on this? What would a consumer who can handle both success ... | [
{
"body": "<p>As one of the commenters pointed out, adding a boolean flag to your result is one of the better ways to go about returning a successful result, especially when compared to returning null. In fact, I have a wrapper around a search result object where I do exactly this in the code for my current pro... | {
"AcceptedAnswerId": "57700",
"CommentCount": "12",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T10:57:36.877",
"Id": "57662",
"Score": "1",
"Tags": [
"c#",
"object-oriented",
".net",
"converting",
"csv"
],
"Title": "Returning information about the result of a fil... | 57662 |
<p>This is so ugly code. There must be better way to write it, but I'm noob to AS3.</p>
<p>The goal is to make a square move at even speed counter-clockwise around the edge and on call <code>reverseDirection();</code>, <code>changeColor();</code>, or <code>spin();</code>.</p>
<p>I'm trying to understand Tweenlite var... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T14:58:00.607",
"Id": "103234",
"Score": "0",
"body": "**There's a bug in your code!** I've edited my answer to mention this."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T13:39:33.313",
"Id": "1... | [
{
"body": "<p><strong>After looking thoroughly at your code, I found a bug. Please be sure this is intended behavior, and if not, fix it.</strong></p>\n\n<p>In <code>reverseDirection</code>, you have this:</p>\n\n<pre><code>switch (tweeningDirection){\n case \"down\":\n stoppedDown();\n break;\... | {
"AcceptedAnswerId": "57675",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T11:36:16.523",
"Id": "57665",
"Score": "10",
"Tags": [
"animation",
"actionscript-3"
],
"Title": "Making a square move counter-clockwise around the edge"
} | 57665 |
<p>I'm still learning about domain driven design, and I have created my first entity class <code>User</code>.</p>
<p>Is this fully compliant with the DDD principles? Particularly my setters because I have business rules in them. Any other suggestions would be highly appreciated as well.</p>
<pre><code>namespace Mod... | [] | [
{
"body": "<p>Your class can absolutely be considered like a DDD domain entity.\nHowever, I would suggest some improvements:</p>\n\n<ul>\n<li>DDD likes to use an ObjectValue for the unique identifiers, you could use one instead of a simple integer.</li>\n<li>You could separate the validation logic from the enti... | {
"AcceptedAnswerId": "57759",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T11:46:35.933",
"Id": "57669",
"Score": "13",
"Tags": [
"php",
"object-oriented",
"ddd"
],
"Title": "First domain-driven User entity class"
} | 57669 |
<p>I have written a function that returns me the duplicates of a list:</p>
<pre><code>static List<SomeClass> findDuplicateElements(List<SomeClass> myObjects) {
List<SomeClass> duplicates = myObjects
.groupBy { it.someAttribute }
.findAll { it.value.size() > 1 }
.collect { it.value ... | [] | [
{
"body": "<p>You can use <a href=\"http://groovy.codehaus.org/groovy-jdk/java/lang/Object.html#with(groovy.lang.Closure)\" rel=\"nofollow\"><code>with</code></a> to do things inline without declaring another variable:</p>\n\n<pre><code>List list = [\n [first: \"foo\", last: \"bar\"],\n [first: \"baz\", last:... | {
"AcceptedAnswerId": "57874",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T12:58:26.577",
"Id": "57676",
"Score": "5",
"Tags": [
"groovy",
"assertions"
],
"Title": "Better way to assert correct return values in Groovy"
} | 57676 |
<p>This is an app made by me to display a web page on blackberry and to add some more features like checking network connectivity while opening app, loading some URL in browser rather than app, making a splash screen and loading animation.</p>
<p>The problem with the code is that when I run this app on blackberry devi... | [] | [
{
"body": "<p>You should fix your indentation. I want to review the code, but a lack of indentation makes it really hard to read it.</p>\n<p>You use Eclipse, so use this to format your code:</p>\n<blockquote>\n<p><kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>F</kbd></p>\n<p>Or, in the main menu > Source > For... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T13:15:14.780",
"Id": "57678",
"Score": "5",
"Tags": [
"java",
"mobile"
],
"Title": "Making a lightweight app in BlackBerry Browserfield"
} | 57678 |
<p>I have a nested loop which creates a drop down with 3 levels. Works fine on modern browsers but on IE8 it hangs and takes several seconds when there's even a moderate volume of data.</p>
<p>It creates a list of publishers, when I click a publisher I get that publishers authors, click an author I get the years they... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T13:52:03.230",
"Id": "103211",
"Score": "0",
"body": "Welcome to Code Review! This is a good question! Do know that reviewer can still review other aspect of your code (style, formatting, algorithm and etc)!"
},
{
"ContentLi... | [
{
"body": "<p>There are a few things you can do to improve your JavaScript code.</p>\n\n<p>For example, you can save the element you are using in each loop:</p>\n\n<pre><code>var currentPuiblisher = data.genres[i].publishers[j]\n</code></pre>\n\n<p>Every time you use a object like <code>data.genres[i].publisher... | {
"AcceptedAnswerId": "57686",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T13:41:38.160",
"Id": "57680",
"Score": "7",
"Tags": [
"javascript",
"jquery"
],
"Title": "Improving nested for loops for sub menu creation"
} | 57680 |
<p>I've written a function that takes a number and returns a value depending on where that number lies on a pre-defined scale. That's probably a little confusing so I've put the code below and added a <a href="http://jsfiddle.net/4QqDz/" rel="nofollow">JSFiddle</a> (although you might be better off in the dev console).... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T20:21:45.580",
"Id": "103333",
"Score": "2",
"body": "I would not trust `for in` to be always properly sorted."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T20:24:23.287",
"Id": "103337",
"S... | [
{
"body": "<ul>\n<li>Your <code>for..in</code> construct should have an <code>Object.hasOwnProperty</code> check in the extremely unlikely event that somebody decides to abuse prototypes (and on <code>Object</code>, no less!).</li>\n<li>Your indentation is a little inconsistent.</li>\n<li>You assign to the <cod... | {
"AcceptedAnswerId": "57694",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T15:12:21.960",
"Id": "57689",
"Score": "12",
"Tags": [
"javascript"
],
"Title": "Categorising a number in JavaScript"
} | 57689 |
<p>I'm writing a program and I have a server that needs to be able to handle multiple client connections at once doing many different things.</p>
<p>I'm using the Qt library, so I handle new connections like this:</p>
<p>In the server constructor:</p>
<pre><code>Server::Server(QObject* parent): QObject(parent)
{
c... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T17:31:37.217",
"Id": "103284",
"Score": "1",
"body": "This question appears to be off-topic because it is about asking for advice on usage of qt. This would be better resolved on stackoverflow.com"
},
{
"ContentLicense": "CC... | [
{
"body": "<p>I was not able to find this question on SO, so let me try to give an answer here:</p>\n\n<p><strong>A general idea:</strong></p>\n\n<p>Depending on the nature of the data your are synchronizing, it might be better that the server sends out a <em>synchronization signal</em> and the clients synchron... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T16:14:23.800",
"Id": "57698",
"Score": "3",
"Tags": [
"c++",
"server",
"qt",
"client"
],
"Title": "Multi-user server connection handling"
} | 57698 |
<p>How can the following program execution time improved? I have used dynamic programming in both "recursive" as well as "prime" function, but I'm not getting the efficient execution time.</p>
<blockquote>
<p>There is a wall of size 4xN in the victim's house where. The victim
also has an infinite supply of bricks... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T17:04:09.583",
"Id": "103276",
"Score": "1",
"body": "I think `import ...*` is *very bad* ™. Clean out your imports. Your `b` array uses a magic number for its length. Also, your code isn't what I would traditionally consider DP..."... | [
{
"body": "<p>First off, <strong>fix your indentation near single line if statements that have else statements</strong>. They're making your code hard to read and I even made a mistake interpretting the bottom most function (I thought it would return after a single iteration, went to go to great lengths to expl... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T16:48:09.863",
"Id": "57701",
"Score": "2",
"Tags": [
"java",
"optimization",
"algorithm",
"programming-challenge",
"dynamic-programming"
],
"Title": "Calculating the numb... | 57701 |
<p>I'm saving string values in an array one at a time so I cannot initialize the array with the values all at once. After I'm done with the array I need to pass it to another class that is expected a <code>String</code> array.</p>
<p>Normally I would use a <code>List</code> but the end result is expecting an Array so ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T16:57:37.613",
"Id": "103268",
"Score": "0",
"body": "You should add more context to your question, show some of the code that calls `addArgument(...)`"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T... | [
{
"body": "<p>Use a list for building your array, then convert your list into an array before you return it from your function. =)</p>\n",
"comments": [],
"meta_data": {
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T16:56:37.060",
"Id": "57704... | {
"AcceptedAnswerId": "57706",
"CommentCount": "8",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T16:50:43.550",
"Id": "57703",
"Score": "7",
"Tags": [
"java",
"array"
],
"Title": "Use a Java Array like a List"
} | 57703 |
<p>I've been working on development for an Android game, and this is the game loop I have so far:</p>
<pre><code>private static final int MAX_UPDATES_PER_DRAW = 10;
private long timeAccumulator = 0;
private long lastTime = System.nanoTime();
@Override
public void onDrawFrame(GL10 unused)
{
// Use this structu... | [] | [
{
"body": "<p>I don't see where <code>dt</code> is coming from and when it gets updated. You don't modify it within your function, and if its value doesn't change, then there's no need to evaluate this division in every iteration of the <code>while</code> loop:</p>\n\n<blockquote>\n<pre><code>game.update((doubl... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T17:29:11.430",
"Id": "57708",
"Score": "7",
"Tags": [
"java",
"performance",
"android",
"opengl"
],
"Title": "Perfect game loop"
} | 57708 |
<p>I wrote a program that reads a pcap file and parses the HTTP traffic in the pcap to generate a dictionary that contains HTTP headers for each request and response in this pcap.</p>
<p>My code does the following:</p>
<ol>
<li>Uses tcpflow to reassemble the tcp segments</li>
<li>Read the files generated by tcpflow a... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T18:34:43.400",
"Id": "103299",
"Score": "0",
"body": "Welcome to Code Review! This is a good question, thank you for taking the time to form it so that we can help show you the proper coding styles and techniques. We all look forwar... | [
{
"body": "<p>New Lines and indentations help the interpreter know where the code terminates and blocks end, you have to be super careful with them </p>\n\n<p>Like in your if condition, you can't have a newline in between the conditions.</p>\n\n<pre><code>if header.find(\" \")==0 or \n header.find(\"\\t\")=... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T18:26:02.543",
"Id": "57715",
"Score": "10",
"Tags": [
"python",
"http"
],
"Title": "Parse HTTP header using Python and tcpflow"
} | 57715 |
<p>Problem details from Codility:</p>
<blockquote>
<p>A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D.
Count the minimal number of jumps that the small fro... | [] | [
{
"body": "<p>Method 1 sometimes gives wrong solution because it has a bug:</p>\n\n<blockquote>\n<pre><code>def solution(X, Y, D):\n if (X == Y):\n jumps = 0\n elif Y-X % D == 0:\n jumps = (Y-X)/D\n else:\n jumps = ((Y-X)/D) + 1\n return jumps\n</code></pre>\n</blockquote>\n\n<p... | {
"AcceptedAnswerId": "57720",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T18:31:34.513",
"Id": "57716",
"Score": "6",
"Tags": [
"python",
"programming-challenge",
"comparative-review"
],
"Title": "Codility Frog Jump solutions"
} | 57716 |
<blockquote>
<p><img src="https://i.stack.imgur.com/gsbhY.png" alt="enter image description here"> </p>
<p>Given such a structure the output should be</p>
<blockquote>
<pre><code>10->5->12->7->11->4->20->13->17->6->2->16->9->8->3->19->15.
</code></pre>
</bl... | [] | [
{
"body": "<p>What you have here is a right-only in order traversal of your \"tree\". This means you will have to FIFO-Queue the discovered down nodes to continue from, when you can't traverse right anymore.</p>\n\n<p>Your code nicely reflects this, but I have some comments, especially concerning style and nami... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T19:37:48.293",
"Id": "57723",
"Score": "6",
"Tags": [
"java",
"algorithm",
"linked-list"
],
"Title": "Flatten a multilevel linked list"
} | 57723 |
<p>Using jQuery I'm trying to find an efficient way to iterate through an array <code>excludeMe</code> and check if elements from another array <code>needsExclusions</code> are contained in the <code>excludeMe</code> array. Not sure if this is the most efficient, but it works. Fiddle here: <a href="http://jsfiddle.net/... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T20:23:17.727",
"Id": "103335",
"Score": "0",
"body": "Sounds like your looking for an [`intersection`](http://underscorejs.org/#intersection) algorithm"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T... | [
{
"body": "<p>Your particular example gets 10 times faster by just removing the jQuery and using a <code>for</code> loop and <code>.indexOf()</code> instead of the jQuery versions. It's also worth stopping the iteration when you find an excluded value since you don't need to look any more once the flag is alre... | {
"AcceptedAnswerId": "57730",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T19:42:18.707",
"Id": "57726",
"Score": "2",
"Tags": [
"javascript",
"jquery",
"array"
],
"Title": "Efficient way to iterate over elements of array for matching contents of anot... | 57726 |
<p>Designed for OpenCart, vQmod places or replaces bits of code based on <code>XML</code> files.</p>
<p>The following three versions of the code achieve the same goal, which is to replace nearly ALL of a specific page.</p>
<p>The <code>offset</code> parameter tells the vqmod how many lines of code to remove, includin... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T20:44:55.763",
"Id": "57732",
"Score": "3",
"Tags": [
"php",
"xml"
],
"Title": "Use of die() in flow control - proper and sensible?"
} | 57732 |
<p>In the following:</p>
<pre><code>import Data.Bits (popCount, shiftL, (.|.))
import Data.Char (chr, ord)
import Data.Word (Word8)
import qualified Data.ByteString as B
data MByteSequence = MByteSequence [Word8] -- a sequence of map bytes (len 0-15)
data Atom = TerminationAtom |
NonOffsetAtom { nonOffse... | [] | [
{
"body": "<blockquote>\n <p>To me, serialize especially seems pretty ugly; the use of the where clauses and the similarity of the latter two pattern match cases all seems bad to me, yet I'm unsure what should be done instead.</p>\n</blockquote>\n\n<p>You can rewrite the <code>serialize</code> function using <... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T21:07:09.770",
"Id": "57733",
"Score": "3",
"Tags": [
"haskell",
"serialization"
],
"Title": "Separation of code into functions and use of patern matching in Haskell"
} | 57733 |
<p>I need to build a little UI to allow easy maintenance of some data stored in a MySQL database, and the end user wants to do that in Excel (I know, I know).</p>
<p>The code I came up with comes pretty close to what I'd call Model-View-Presenter (MVP).</p>
<p>I can get my form shown like this:</p>
<pre><code>set x ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T22:02:27.173",
"Id": "103368",
"Score": "0",
"body": "Nevermind the `View()` function, I forgot to remove it... it's just a relic from a previous approach / dead code now."
},
{
"ContentLicense": "CC BY-SA 3.0",
"Creatio... | [
{
"body": "<h3>TL;DR</h3>\n\n<p>I wasn't going to review this, but I couldn't stop reading it again and again. So, here I am reviewing it. I'm going to go down line by line, but first let me address your question. Would creating a data service class be overkill? Right now, I think it would be. Overall this is a... | {
"AcceptedAnswerId": "57772",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-22T21:17:05.470",
"Id": "57734",
"Score": "13",
"Tags": [
"sql",
"mysql",
"vba",
"mvp"
],
"Title": "Abusing Excel VBA... to maintain data stored in a database"
} | 57734 |
<p>There have been many FizzBuzz questions lately, and here is one more! Granted, <a href="https://codereview.stackexchange.com/questions/56875/fizzbuzz-in-sql-no-loops">it is pretty straightforward to do FizzBuzz with SQL using calculations</a>.</p>
<p>So instead, I'm going to do a FizzBuzz which will not only be fun... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T01:45:23.577",
"Id": "103383",
"Score": "13",
"body": "About time... +1 for the pure effort"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T06:37:37.023",
"Id": "103408",
"Score": "6",
"bo... | [
{
"body": "<p>I think your scripts could use a bit more vertical whitespace; maybe it's the uppercasing, but I find this:</p>\n\n<blockquote>\n<pre><code>BEGIN\nSET SEARCH_PATH = PhrancisFizzBuzz;\n-- call populate function with input parameters\nPERFORM fncPopulateFizzBuzz(\n prmMaxNumber,\n prmFizz,\n ... | {
"AcceptedAnswerId": "57796",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T00:00:31.400",
"Id": "57737",
"Score": "46",
"Tags": [
"sql",
"fizzbuzz",
"postgresql",
"stored-procedure"
],
"Title": "Tired of FizzBuzz yet?"
} | 57737 |
<p>I have this code to check a couple conditions before allowing a <kbd>play</kbd> button to become visible. Is there anything to do to consolidate this code?</p>
<pre><code>var isNodeWebkit = (typeof process == "object"); // check if using node app
var downloadURL = 'https://www.microsoft.com/getsilverlight/get-start... | [] | [
{
"body": "<h2>Ok first of all.. Silverlight Rant.</h2>\n\n<p>Silverlight was <s>a flop</s> far less successful than Microsoft expected it to be. HTML5 + WebGL, on the other hand, is the future of handling anything that anyone ever thought Silverlight might do. If you want to maintain highly supported, future-p... | {
"AcceptedAnswerId": "57753",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T01:38:44.993",
"Id": "57739",
"Score": "12",
"Tags": [
"javascript",
"jquery"
],
"Title": "Checking conditions before allowing a play button to become visible"
} | 57739 |
<p>I am fairly new to Javascript. I have written a website that works as designed. However, I have a strong feeling that my code could be heavily refactored. Can anyone see anything, besides line spacing, that I could do to clean up my code?</p>
<pre><code>var i1 = document.createElement("img");
var i2 = document.crea... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T02:19:48.387",
"Id": "103384",
"Score": "1",
"body": "Could you provide some context on this code, since it's a lot?"
}
] | [
{
"body": "<p>I'm not so experienced in javascript, so beware syntax errors, but looking at it from what I can read...</p>\n\n<p>This...</p>\n\n<pre><code>var i1 = document.createElement(\"img\");\nvar i2 = document.createElement(\"img\");\nvar i3 = document.createElement(\"img\");\nvar i4 = document.createElem... | {
"AcceptedAnswerId": "57761",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T02:01:23.850",
"Id": "57741",
"Score": "4",
"Tags": [
"javascript"
],
"Title": "Advice needed in refactoring/cleaning up my javascript code"
} | 57741 |
<p>Given a Binary Tree, find the deepest leaf node that is left child of its parent. This question is attributed to GeeksForGeeks. Looking for code-review, optimizations and best practices. </p>
<pre><code>public class DeepestLeftLeaf<T> {
private TreeNode<T> root;
/**
* Constructs a binary... | [] | [
{
"body": "<p>Bug:</p>\n\n<p><code>IndexOutOfBoundsException</code> on empty list in <code>DeepestLeftLeaf.create(List<T> items)</code>. You don't have a comment stating you need to input a list containing at least something. Consider returning <code>IllegalArgumentException</code> and adding a comment.</... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T02:16:58.700",
"Id": "57742",
"Score": "3",
"Tags": [
"java",
"algorithm",
"tree"
],
"Title": "Deepest left leaf node in a binary tree"
} | 57742 |
<p>Just wanted to see what you all thought about my program, I basically have two different classes that I designed to allow for automated wrapping of text in a circular pattern. This is my first bit of useful and reusable code. Let me know what can be improved or added.</p>
<p>Here are some screenshots I took of the ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T04:29:30.880",
"Id": "103393",
"Score": "0",
"body": "By the way, the first class relies on the user setting the font's size and the second one attempts to calculate it for the user. The original had a bug which seemed to cause the ... | [
{
"body": "<p>from the book Clean Code</p>\n\n<blockquote>\n <p>Long lists of imports are daunting to the reader. We don’t want to\n clutter up the tops of our modules with 80 lines of imports.</p>\n</blockquote>\n\n<p>I find this to be lot of imports too. But It's still somewhat OK,</p>\n\n<pre><code>import ... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T04:20:31.570",
"Id": "57749",
"Score": "7",
"Tags": [
"java",
"java-8",
"javafx"
],
"Title": "Rotating Text in Circular Pattern Using JavaFX"
} | 57749 |
<p>I am trying to send SMS using Twilio with Scala 2.10 in Playframework 2.2, but this code is looking odd to me, maybe due to lots of conditions. I'm sure it needs some important reviews.</p>
<pre><code>val invalidEX = List(21211, 21614, 21608, 30006, 30005, 21604, 21601, 14101)
val reachEX = List(21612, 30004)
def... | [] | [
{
"body": "<p>As I'm new to scala, I don't feel I could generate the appropriate code, but I wanted to make a couple points.</p>\n<p>First, your method is doing way to much. I see validation, I see messing with a request object, I see sending the SMS, I see response generation. From my point of view, when loo... | {
"AcceptedAnswerId": "57784",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T05:52:35.303",
"Id": "57751",
"Score": "10",
"Tags": [
"mvc",
"scala",
"thread-safety"
],
"Title": "Sending SMS through twilio from play framework"
} | 57751 |
<p>This question is about <a href="https://codegolf.stackexchange.com/questions/34851/slime-the-territory-war/34910#34910">my answer</a> to <a href="https://codegolf.stackexchange.com/questions/34851/slime-the-territory-war">this king-of-the-hill challenge on Code Golf</a>. In short, the purpose of the challenge is to ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T09:07:19.310",
"Id": "103427",
"Score": "1",
"body": "Did you read up on commonly used algorithms like [alpha-beta pruning](http://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning) that help to reduce the search space?"
},
{
... | [
{
"body": "<p>Well, this is quite a bit of code so just some generic remarks and advise for now:</p>\n\n<ol>\n<li><p>Your code is a prime example of what I would call spaghetti code. It's unmaintainable and if you come back to it in 6 months time you'll have a hard time understanding what all of it is doing.</p... | {
"AcceptedAnswerId": "57754",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T06:33:31.103",
"Id": "57752",
"Score": "10",
"Tags": [
"java",
"performance",
"beginner",
"game",
"tree"
],
"Title": "Good performance when predicting future game state... | 57752 |
<p>I have base abstract <code>GenericDAO</code> class that executes CRUD operations with different kind of objects. <code>Customer</code> and <code>Employee</code> POJO classes are used in specific <code>DAO</code> classes that extends GenericDAO class. From <a href="https://codereview.stackexchange.com/questions/57407... | [] | [
{
"body": "<ul>\n<li>How to realize immutable objects in GenericDAOImpl?</li>\n</ul>\n\n<p>By creating copies of the objects you get in, rather than keeping references to the objects. With generics this is may be tricky but if T extends Cloneable you could at least call clone() on it to create a field for field... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T07:09:00.830",
"Id": "57755",
"Score": "6",
"Tags": [
"java"
],
"Title": "Base generic DAO optimizations"
} | 57755 |
<p>I'm writing code for an embedded device - specifically, a camera. The idea is different camera manufacturers can implement the code so it properly works with their camera.</p>
<p>Here, I'm encapsulating the request/response library we're using, because it's complicated to deal with, and we want to use ease of imple... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T09:53:04.723",
"Id": "103707",
"Score": "0",
"body": "There was a bug in this code, by the way. I'm accidentally writing to a `readBuffer`... whoops."
}
] | [
{
"body": "<h2>ANSI C</h2>\n\n<p><a href=\"https://stackoverflow.com/a/8284962/760746\">Don't use <code>//</code> comments but <code>/**/</code>.</a></p>\n\n<h2>Design away invalid states</h2>\n\n<p>It probably will never happen and is only in your mockup code but your design allows for the state</p>\n\n<pre><c... | {
"AcceptedAnswerId": "57770",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T10:34:53.433",
"Id": "57765",
"Score": "11",
"Tags": [
"c"
],
"Title": "Mapping enum to function - request / response library encapsulation"
} | 57765 |
<p>I have the following code to select an image using Selenium, only now I have added an <code>errorRecovery</code>. Is there is a better way to right the code in the <code>catch</code>?</p>
<pre><code> public static void selectHeader() {
try {
WebDriverWait wait = new WebDriverWait(driver, 20);
... | [] | [
{
"body": "<p>Judging by the overall structure it looks quite good, I would change a few things though with respect to formatting:</p>\n\n<ol>\n<li>Your <code>public static void selectHeader() {</code> line seems to be off, might've been due to putting the code here, you should remove 4 blanks.</li>\n<li><p>Tak... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T10:43:31.893",
"Id": "57766",
"Score": "3",
"Tags": [
"java",
"exception-handling",
"selenium"
],
"Title": "Selenium Java: errorRecovery"
} | 57766 |
<h3>Goals:</h3>
<p>So the plan was simple: Provide a factory to instantiate implementations of a certain interface (<code>ModelConverter<T></code>), depending on what model-class you want to convert.</p>
<p>The approach is relatively straightforward:</p>
<pre class="lang-none prettyprint-override"><code>static... | [] | [
{
"body": "<p>Quick answer:</p>\n\n<pre><code>Log.doLogError(e.toString());\ne.printStackTrace();\n</code></pre>\n\n<p>Duplication!\nMake a method <code>logAndPrintException</code>. You could even put the whole <code>throw new BrokenCodeException</code> section in there... provided you are planning to only thro... | {
"AcceptedAnswerId": "57826",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T10:58:47.390",
"Id": "57768",
"Score": "15",
"Tags": [
"java",
"design-patterns",
"interface"
],
"Title": "More German overengineering™ - Class mappings and factories"
} | 57768 |
<p>I have been learning Python and was trying to make a chat system which can be run by commands. This is my first attempt to write the code. Does this make sense or is it wrong usage of classes?</p>
<p>There is a <code>User</code> class which will contain the user of the chat.
The <code>Message</code> class is used t... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T12:39:19.473",
"Id": "103490",
"Score": "0",
"body": "Which version of Python, and is there some test to run it with?"
}
] | [
{
"body": "<p>A few comments regarding style (mainly based on <a href=\"http://legacy.python.org/dev/peps/pep-0008/\" rel=\"nofollow\">PEP8</a>):</p>\n\n<ul>\n<li>Use for spaces for each level of indentation</li>\n<li>Use a space around binary operators like <code>=</code></li>\n<li>Use a space after a <code>,<... | {
"AcceptedAnswerId": "57798",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T11:04:01.373",
"Id": "57769",
"Score": "7",
"Tags": [
"python",
"beginner"
],
"Title": "Chat using commands"
} | 57769 |
<p>This is my first C# console application. This program asks for an input of a number, and finds the highest prime factor of that number. Please review my code. </p>
<ul>
<li>Have I used things right? </li>
<li>Is my code efficient? </li>
<li>Is there a better way to achieve this?</li>
</ul>
<p></p>
<pre><code>usin... | [] | [
{
"body": "<pre><code>using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace Problems\n{\n</code></pre>\n\n<p>You can make this class static since it doesn't make sense to make instances of it.</p>\n\n<pre><code> static class Progr... | {
"AcceptedAnswerId": "57774",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T11:07:58.903",
"Id": "57771",
"Score": "12",
"Tags": [
"c#",
"beginner",
"primes",
"console"
],
"Title": "Finding largest prime factor from inputted number"
} | 57771 |
<p>I've come across the following piece of code in a Razor view</p>
<pre><code><table class="key-left">
<tr>
<td>Company</td>
@foreach (Customer c in Model.SelectedInstallers)
{
<td>@c.Name</td>
}
</tr>
<tr class="even... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T12:19:07.960",
"Id": "103487",
"Score": "0",
"body": "First, it depends what your understanding of \"better\" is? Better in readability, performance, maintainability?\nAs for performance, it really comes down to the list size. If th... | [
{
"body": "<p>Stay with the first solution:</p>\n\n<ol>\n<li><p>It is easier to read.</p>\n\n<p>Using such a template is the least-obfuscated method to generate the output HTML, as the structure of the template directly corresponds to the structure of the output.</p>\n\n<p>Another important aspect is that when ... | {
"AcceptedAnswerId": "57794",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T11:20:45.200",
"Id": "57773",
"Score": "3",
"Tags": [
"c#",
"optimization",
"asp.net-mvc-4"
],
"Title": "Multiple loops versus multiple stringbuilders"
} | 57773 |
<p>I wrote a program to display data in memory as binary and it worked. (It gave me immense sense of satisfaction and joy to see this work. I guess this happens to newbies who are just testing the waters). I know this isn't some terribly smart code, and I'm sure there must be surely lots of better ways to do this. Any ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T16:30:20.037",
"Id": "103554",
"Score": "0",
"body": "*I guess this happens to newbies who are just testing the waters* - I can assure you I'm still proud when what I just code is working. It's a feeling I don't want to lose since i... | [
{
"body": "<p>You may use the shift operation;</p>\n\n<pre><code>char mask = 0x01; //define initial mask\n\nif (mask&mychar) printf(\"1\"); // check that spesific bit\n\nmask<<=1; //shift left\n</code></pre>\n\n<p>of course if you want to start checking from right hand then shift right you can do :</p... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-06-05T07:28:32.407",
"Id": "57776",
"Score": "1",
"Tags": [
"beginner",
"c",
"bitwise"
],
"Title": "Displaying data as binary in C with bitmasks"
} | 57776 |
<p>I want to find the first and second highest number in an array. I could come up with one solution, but I want to know the optimum solution to do the same. Can someone help me with some alternative solution to this?</p>
<pre><code>int main()
{
int arr[10] = {0,1,2,13,4,5,9,8,11,6};
int first = arr[0];
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-06-06T05:53:26.343",
"Id": "103451",
"Score": "0",
"body": "check this link it might help http://stackoverflow.com/questions/3628718/find-the-2nd-largest-element-in-an-array-with-minimum-of-comparisom"
},
{
"ContentLicense": "CC B... | [
{
"body": "<p>You can use any sorting algorithm and can get first and second highest element in array.<br>\nUsing bubble sort.</p>\n\n<pre><code>int temp=0;\nint n=10;\n for(i=1;i<n;i++)\n {\n for(j=0;j< n-1;j++)\n if(arr[j]>arr[j+1])\n {\n temp=arr[j];\... | {
"AcceptedAnswerId": "57781",
"CommentCount": "14",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-06-06T05:51:07.243",
"Id": "57779",
"Score": "4",
"Tags": [
"c"
],
"Title": "Find out the second highest in array"
} | 57779 |
<p>I wrote an R code that basically performs 2 operations:</p>
<ol>
<li><p>For each segment in file A, find all segments in file B that lie in that segment.</p></li>
<li><p>Find the percentage of overlap for each case in previous point.</p></li>
</ol>
<p>The code that I have written works fine but given I have 74 fil... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-06-10T11:14:46.867",
"Id": "103474",
"Score": "0",
"body": "Have you tried using [bedtools](http://bedtools.readthedocs.org/en/latest/) instead of R?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-06-10T11:18:10... | [
{
"body": "<p>I read the data in</p>\n\n<pre><code>a <- read.delim(textConnection(\"Chromosome\\tStart\\tEnd\n1\\t0\\t2420037\n1\\t2420037\\t2522634\n1\\t2522634\\t10794763\n1\\t10794763\\t10925915\n1\\t10925915\\t11280057\"))\n\nb <- read.delim(textConnection(\"chr\\tstart\\tend\\tvariantaccession\\tvari... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-06-10T10:06:33.650",
"Id": "57785",
"Score": "3",
"Tags": [
"r",
"performance",
"bioinformatics"
],
"Title": "Calculating overlap of segments in chromosome data"
} | 57785 |
<p>I have an API with the following code</p>
<pre><code> class API::V1::ReceptionController < API::V1::APIController
before_filter :ensure_document_exists
def produto
jid = ProdutoWorker.perform_async params[:document]
render json: {jid: jid}, :status => 200
end
def c... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T12:01:37.747",
"Id": "103484",
"Score": "0",
"body": "Can you show what `ProdutoWorker` means? As your code is currently missing context."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T12:05:08.400",... | [
{
"body": "<p>I'm not familiar with Ruby, so I will write a no-code answer here, discussing what you could change.</p>\n\n<p>I am assuming that <code>ProdutoWorker</code>, etc. all extend a <code>Worker</code> class, where extending is an OOP-definition here.</p>\n\n<p>Then you should make a method that takes t... | {
"AcceptedAnswerId": "57797",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T11:52:43.640",
"Id": "57788",
"Score": "5",
"Tags": [
"ruby",
"ruby-on-rails"
],
"Title": "Repetitive controller with all methods nearly identical"
} | 57788 |
<p>I got a PHP developer interview test to solve for a company. I didn't get the job but I would like to know where I was wrong. Did I understand the test completely?</p>
<pre><code>/**
* Create an Animal Choir simulator
*
* The task constraints are:
*
* There must be 3 different choir member animals
* (i.e. do... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T19:25:34.587",
"Id": "103577",
"Score": "0",
"body": "I would also ask the company what they think you can do to improve."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-11-12T14:20:25.410",
"Id": "1271... | [
{
"body": "<p>Let's start with class hierarchy. The choir is made up of the animals.</p>\n\n<p>The <code>Choir</code> class should have a list of its <code>Animal</code> members:</p>\n\n<pre><code>$felix = new Cat();\n$rex = new Dog();\n$choir = new Choir(array($felix, $rex, $bernand));\n</code></pre>\n\n<p>The... | {
"AcceptedAnswerId": "57799",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T11:53:52.087",
"Id": "57789",
"Score": "10",
"Tags": [
"php",
"object-oriented",
"interview-questions"
],
"Title": "Animal choir simulator"
} | 57789 |
<p>For a project, I need to validate a VAT number against the correct algorithm. I found a library for this <a href="http://www.braemoor.co.uk/software/vat.shtml" rel="nofollow">here</a> (freeware, so I should be able to reuse it) that I'm grateful exists. However, I feel like it could be improved upon in a few ways, b... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T14:22:15.240",
"Id": "103504",
"Score": "0",
"body": "You didn't give us a bunch of variables... First whats `vatNumber`, `defCode`, etc"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T14:54:33.477",
... | [
{
"body": "<p>First of all, I don't think you should worry too much about the loop in particular. It may seem a little bit naïve, but it's easy to understand and easy to add new patterns if need be. </p>\n\n<p>Your refactoring cleans it up a lot (like, really a lot! Kudos), but the suspect part (IMO) are the ma... | {
"AcceptedAnswerId": "57807",
"CommentCount": "8",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T12:00:35.603",
"Id": "57791",
"Score": "2",
"Tags": [
"javascript",
"regex",
"validation"
],
"Title": "Validate multiple regexes without a for loop in JavaScript"
} | 57791 |
<p>I have a <code>DiningHall</code> class that has the 3 properties: <code>openingTime</code>, <code>closingTime</code>, and <code>nextMealOpeningTime</code>, and I need to set these <code>NSDate</code> properties from the data from this <a href="https://secure5.ha.ucla.edu/restauranthours/dining-hall-hours-by-day.cfm?... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T22:27:09.560",
"Id": "103908",
"Score": "0",
"body": "Have you tried using `NSXMLParser`?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-25T01:44:00.070",
"Id": "103939",
"Score": "0",
"body... | [
{
"body": "<p>For now, I will avoid commenting too much on <code>- (NSArray*) getHourDataForRow:(TFHppleElement*)row Meal:(NSString*)meal</code> as I think the real answer here is to look into <code>NSXMLParser</code> and see if that will work for you. Other than that, for now I'll simply comment that your spa... | {
"AcceptedAnswerId": "59338",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T12:29:54.270",
"Id": "57795",
"Score": "5",
"Tags": [
"optimization",
"parsing",
"objective-c"
],
"Title": "Parsing Websites and transferring Data between Objects"
} | 57795 |
<p>I wonder, what might be the best (most pythonic) way of implementing multiple observerables in Python. There are multiple objects, which should be able to register themselves at one or multiple observables.</p>
<p>Shall I simply submit the update methods, like this:</p>
<pre><code>class MethodObservable():
de... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-08-15T11:04:34.653",
"Id": "108690",
"Score": "1",
"body": "You've presented three full working implementations of `Observable`s, which should be enough to meet Code Review's working-code requirement. The placeholder methods in the `Obser... | [
{
"body": "<p>First thing, you should use new-style classes, inheriting from <code>object</code>. (<a href=\"https://stackoverflow.com/questions/1238606/is-it-necessary-or-useful-to-inherit-from-pythons-object-in-python-3-x\">Not necessary if you are in Python3</a>, but convenient for backwards compatibility).<... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-02T08:16:24.177",
"Id": "57804",
"Score": "3",
"Tags": [
"python",
"callback",
"comparative-review"
],
"Title": "Three implementations of observable objects"
} | 57804 |
<p>I've coded a calculator in C# with WPF as the UI.</p>
<p>I wish to know mainly about these points:</p>
<ul>
<li>Ways of optimizing</li>
<li>Better techniques, tactics and ways of coding this</li>
<li>All flaws on the surface as well as deep</li>
<li>Simpler logic</li>
</ul>
<p><strong>MainWindow.xaml.cs</strong><... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T14:46:54.917",
"Id": "103512",
"Score": "2",
"body": "If you changed from using events to using commands, you could include a specific parameter, which means they could all share the same method. That alone might clean things up a l... | [
{
"body": "<p><strong>Duplication</strong></p>\n\n<pre><code>if (totalled == true)\n{\n Display.Content = \"\";\n totalled = false;\n}\nDisplay.Content += \"1\";\nstorageVariable += \"1\";\n\nif (totalled == true)\n{\n Display.Content = \"\";\n totalled = false;\n}\nDisplay.Content += \"2\";\nstorag... | {
"AcceptedAnswerId": "57808",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T14:38:39.383",
"Id": "57806",
"Score": "3",
"Tags": [
"c#",
"wpf",
"calculator"
],
"Title": "WPF Calculator Code"
} | 57806 |
<p>I have a purpose for an application to run a daemon in my web application. </p>
<p>The application is running with Struts1 on a tomcat7 server using Java7.</p>
<p>This is what it does:</p>
<ul>
<li>Launch itself when the application is loaded</li>
<li>every minutes does a task (the sysout in the code)</li>
<li>wh... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T09:15:40.037",
"Id": "103696",
"Score": "1",
"body": "Just a quick idea: I would use `shutdown()` instead of the *first* `shutdownNow()`."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T12:00:18.613",... | [
{
"body": "<ol>\n<li><p>Using a <code>ServletContextListener</code> is a good solution, I would use the same.</p></li>\n<li><p>I would consider using a <a href=\"http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html\" rel=\"nofollow noreferrer\"><code>ScheduledExecutorServi... | {
"AcceptedAnswerId": "57828",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T15:01:12.163",
"Id": "57809",
"Score": "8",
"Tags": [
"java"
],
"Title": "Best way to create a daemon in a JavaWeb application"
} | 57809 |
<p>The purpose of the program is to add 2 sides of an array starting from the bottom and top of both ends and to find the lowest difference at equal decrements of iteration. The program functions but it's slow.</p>
<pre><code>int solution(vector<int> &A) {
int n = A.size();
int i, j, rsum, lsum, diff... | [] | [
{
"body": "<p>Your code is \\$O(n^2)\\$. You can improve it to \\$O(n)\\$ by precomputing a sum array.</p>\n\n<pre><code>int solution(vector<int> &A) {\n int n = A.size();\n int i, j, rsum, lsum, difference;\n int currentmindifference = 1000;\n\n std::vector<int> pre(n);\n pre[0] ... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T15:51:52.450",
"Id": "57813",
"Score": "10",
"Tags": [
"c++",
"optimization",
"performance",
"algorithm"
],
"Title": "Adding two sides of an array"
} | 57813 |
<p>I am writing an application that either mirrors a file/directory into another location or creates a zip file "snap shot" of a file or directory and stores it in another location. The user is able to create "rules" where they define the source file/directory, the destination file/directory and if they are archiving ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T17:46:29.830",
"Id": "103563",
"Score": "0",
"body": "I failed to mention I am using `System.IO.Packaging` instead of `System.IO.Compression` because this is being developed on .NET 4.0 instead of .NET 4.5"
},
{
"ContentLice... | [
{
"body": "<p>As rule has been passed to ArchiveAction class , you dont need to check type inside ArchiveRule class. Move all processing related code to the process method like ZipTempFile ,MoveArchiveToDestinations</p>\n\n<pre>\n <code>\n //inside FileActionService \n public void ArchiveRule(Back... | {
"AcceptedAnswerId": "58135",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T17:16:31.600",
"Id": "57821",
"Score": "1",
"Tags": [
"c#",
"winforms",
"file-system"
],
"Title": "Service class for Archiving and Mirroring Files and Directories"
} | 57821 |
<p>I just want to know whether I've done transaction handling well. Also what about the other types of transactions available in .NET with regard to this code snippet?</p>
<p>Also are there any redundant things in this code?</p>
<pre><code> public void InsertAttendance(BindingList<IAttendance> attendanceList... | [] | [
{
"body": "<p>First and foremost, <em>I would strongly suggest using an ORM (e.g., <a href=\"http://msdn.microsoft.com/en-us/data/ee712907\" rel=\"nofollow\">Entity Framework</a> or nHibernate) rather than doing all this manual work to update the database.</em> ORMs take most of the drudge work away and genera... | {
"AcceptedAnswerId": "57825",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T17:31:59.103",
"Id": "57822",
"Score": "4",
"Tags": [
"c#",
"sql",
".net",
"transactions"
],
"Title": "Data Access Layer method with transaction handling"
} | 57822 |
<p>I want recommendations on how to improve this code.</p>
<p><a href="http://jsfiddle.net/8Gx7X/" rel="nofollow">JSFiddle for you to play in</a> (It's laggy, so it would be better if you download the images and try it in your own PC).</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<m... | [] | [
{
"body": "<p>Here are some quick comments on your HTML and CSS.</p>\n\n<p>I will leave the JS for someone else.</p>\n\n<h1>Move CSS/JS to their own files</h1>\n\n<p>You should split your CSS to a css file, and your JavaScript to a JS file.</p>\n\n<pre><code><script src=\"tictactoe.js\"></script>\n&... | {
"AcceptedAnswerId": "57838",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T17:38:37.843",
"Id": "57823",
"Score": "4",
"Tags": [
"javascript",
"jquery",
"html",
"game",
"tic-tac-toe"
],
"Title": "Tic-Tac-Toe Game"
} | 57823 |
<p>I am rewriting an old VB.NET app in C#. I will not subject you to the old VB.NET code that I am writing (the original method that I have already refactored was over 700 lines long).</p>
<p>The following is what we call On Demand Reports. There is a stored procedure that these objects fill in for us. I don't have a ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T20:02:23.820",
"Id": "103588",
"Score": "0",
"body": "Is `parameter` guaranteed to be `'@' + method name`?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T20:08:30.283",
"Id": "103589",
"Score... | [
{
"body": "<pre><code>var inputs = new List<MyObject>();\ninputs.Add(AssembleMyObject(key, \"@BeginTime\", MyObjectPropertyConstants.BeginTime()));\ninputs.Add(AssembleMyObject(key, \"@EndTime\", MyObjectPropertyConstants.EndTime()));\n\nreturn inputs;\n</code></pre>\n\n<p>You could rewrite this to make i... | {
"AcceptedAnswerId": "57844",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T18:43:49.367",
"Id": "57827",
"Score": "3",
"Tags": [
"c#"
],
"Title": "Return a List<MyObject> based on very similar data"
} | 57827 |
<p>I have the following method for opening a file:</p>
<pre><code>void TankFile::OpenForReading(const std::string & filename)
{
assert(!filename.empty());
errno = 0;
file.exceptions(0); // Don't throw
file.open(filename, (std::fstream::in | std::fstream::binary));
if (!file.is_open() || !file... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T19:00:47.623",
"Id": "103837",
"Score": "7",
"body": "+1 This is a great question. I also noticed that the error messages returned by `std::ios::failure` are pretty useless."
}
] | [
{
"body": "<p>I currently don't see any seamless alternative to using errno and ::strerror;. </p>\n\n<pre><code>#include <stdexcept>\n#include <system_error>\n#include <string>\n#include <iostream>\n\n#include <cstring> // strerror\n\n#include <fstream>\n\n#if defined(_LIBCPP... | {
"AcceptedAnswerId": "58112",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T18:55:14.570",
"Id": "57829",
"Score": "14",
"Tags": [
"c++",
"c++11",
"io",
"error-handling"
],
"Title": "Better option than \"errno\" for file IO error handling"
} | 57829 |
<p>I am creating a Blackjack simulator in Java in order to better understand the language. I have written the basic strategy section for a player and it is terribly long.</p>
<p>Is there a better way to do this other than <code>if</code>/<code>else</code> statements? I know a switch might work but that wouldn't make... | [] | [
{
"body": "<p>Two words.</p>\n\n<p><strong>Lookup tables.</strong></p>\n\n<p>Here's one I randomly found on the internet:</p>\n\n<p><img src=\"https://i.stack.imgur.com/os0IP.png\" alt=\"from www.blackjack-strategycard.com/blackjack-strategy-rules-multi-deck.htm\"></p>\n\n<p>All you gotta do is make a 2D array,... | {
"AcceptedAnswerId": "57840",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T19:09:06.243",
"Id": "57832",
"Score": "19",
"Tags": [
"java",
"beginner",
"game",
"playing-cards"
],
"Title": "Blackjack Strategy"
} | 57832 |
<p>I found a connected components algorithm posted <a href="https://stackoverflow.com/a/13837045">here on SO</a> and modified it for my own purposes. It runs well for small input sets, but doesn't scale as well as I would like. </p>
<p>The largest set I've been able to handle with it has just under 10,000 nodes and to... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T20:00:13.683",
"Id": "103587",
"Score": "0",
"body": "Hi, welcome to code review.SE ! Maybe you could check how many times adjacent is called as the input set gets bigger. If the number of calls grows faster than the size of the set... | [
{
"body": "<p>In algorithm implementation there are usually subtleties that are difficult to spot in a code review. In these cases, I always recommend to have a look at the implementation in other libraries in which smarter people have already spent time to get a good performance.</p>\n\n<p>In this case, I thin... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T19:09:33.850",
"Id": "57833",
"Score": "5",
"Tags": [
"python",
"optimization",
"python-2.x"
],
"Title": "Connected components algorithm does not scale past 10,000 nodes"
} | 57833 |
<p>I'm working on this Objective C programming assignment I found online. I'm not sure if I have met all the requirements, especially part C. Any help or suggestion will be appreciated.</p>
<blockquote>
<p>Part 6</p>
<p>a) Implement class <code>A</code> with properties <code>a1</code>, <code>a2</code>, and <co... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T11:44:31.023",
"Id": "103719",
"Score": "0",
"body": "You are missing part C. I will come back this evening and show you how to implement it."
}
] | [
{
"body": "<p>This is my first review so bear that in mind when you are reading it.</p>\n\n<p>The first thing I see is that in the initialization, you should not use the automatic setters and getters for properties. The reason for this is that the object may not be completely initialized, and thus may fail. S... | {
"AcceptedAnswerId": "57915",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T19:20:53.927",
"Id": "57834",
"Score": "3",
"Tags": [
"classes",
"objective-c",
"inheritance"
],
"Title": "Working with Classes (inheriting), @ properties and Initialization"
} | 57834 |
<h2>Aim</h2>
<p>In C#, the following method will cause a <code>StackOverFlowException</code> if called with parameter <code>0</code>:</p>
<pre><code>int Recurse(int i)
{
return i<100000 ? Recurse(i+1) : i;
}
</code></pre>
<p>However, this method actually uses tail-call recursion, meaning that if it ever perfo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T22:25:47.667",
"Id": "103614",
"Score": "0",
"body": "“the following method will cause a `StackOverFlowException`” For me, that happens only in Debug mode."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07... | [
{
"body": "<blockquote>\n <p>The logic feels like it's overly complex. I'm especially unhappy with the need for three booleans.</p>\n</blockquote>\n\n<p>Yeah, I agree that especially the logic around <code>_invokeNext</code> is messy, but I think that's required due to the way <code>Proceed()</code> behaves (t... | {
"AcceptedAnswerId": "58575",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T19:57:04.903",
"Id": "57839",
"Score": "12",
"Tags": [
"c#",
"recursion",
"aspect-oriented",
"trampoline"
],
"Title": "Trampoline Interceptor"
} | 57839 |
<p>The function below takes a datestring in the form d-mmm-yyyy and converts it to ISO date format (yyyy-mm-dd). Delimiters may be hyphen, space or <code>/</code>, and Dutch or English month abbreviations may be used. </p>
<p>Now, I know there is <code>dateutil</code>, but it returns <code>unknown string format</cod... | [] | [
{
"body": "<p>Neat stuff. </p>\n\n<p>Suggestions:</p>\n\n<p>Changing <code>shortmonths</code> to a dictionary. This will allow for a pair between numerical months and alphabetical months. No need to repeat 'jan' for example, as you have it now.</p>\n\n<p>Pythonic: unpack <code>month, year, day</code> in a one... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T20:06:56.037",
"Id": "57841",
"Score": "3",
"Tags": [
"python",
"datetime",
"i18n"
],
"Title": "Convert international datestring to ISO-format"
} | 57841 |
<p>I wrote a function that inserts or updates a <code>Map key value</code> depending on whether the <code>key</code> is already in the <code>map</code>. If it is, then the <code>value</code> gets added to the already existing <code>map</code>'s value.</p>
<pre><code>import Data.Map as Map
updateMap :: (Ord k, Num v) ... | [] | [
{
"body": "<pre><code>updateMapPF :: (Ord k, Num a) => k -> a -> Map k a -> Map k a\nupdateMapPF = Map.insertWith (+)\n\nλ> updateMapPF 1 1 $ Map.singleton 1 100\nfromList [(1,101)]\nλ> updateMapPF 2 1 $ Map.singleton 1 100\nfromList [(1,100),(2,1)]\nλ> updateMapPF 1 33 $ Map.singleton 1 10... | {
"AcceptedAnswerId": "57850",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T20:17:56.837",
"Id": "57843",
"Score": "8",
"Tags": [
"haskell"
],
"Title": "Update Map in Haskell"
} | 57843 |
<p>Today I decided to learn some basic Haskell, and for starters I made a program for calculating the checksum of a Swedish personal identification number. It uses the Luhn-algorithm, aka. <code>IBM MOD-10</code>.</p>
<p>Explanation of this code can be found on <a href="https://translate.google.com/translate?sl=auto&a... | [] | [
{
"body": "<p>This is a good start! I'll do two passes over your code, one to address issues of style, and another to leverage functions from the Haskell Prelude to decrease code length and bring it more in line with typical Haskell usage and idioms.</p>\n\n<p><strong>Style</strong></p>\n\n<p>Your <code>sumOfCh... | {
"AcceptedAnswerId": "57864",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T20:22:49.513",
"Id": "57846",
"Score": "23",
"Tags": [
"beginner",
"haskell",
"checksum"
],
"Title": "Calculating Luhn-algorithm checksum digit"
} | 57846 |
<p>Somewhere in this code seems to be a memory leak. A couple of users were exceeding 512Mb and I'm not sure how.</p>
<p>Adapted the following <a href="https://stackoverflow.com/questions/19973037/benchmark-memory-usage-in-php">SO code</a> to try and test memory usage of each function on the (OpenCart extension) page:... | [] | [
{
"body": "<p>PHP is a way to high-level programming language to fully, and comprehensively manage the memory. Memory leaks are really relatively common. They are, however, not as problematic as you seem to think.</p>\n\n<p>PHP is, essentially, stateless. After the script has been executed, all resources associ... | {
"AcceptedAnswerId": "57917",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T20:38:33.620",
"Id": "57847",
"Score": "1",
"Tags": [
"php",
"memory-management"
],
"Title": "Testing memory usage of each function on the OpenCart extension page"
} | 57847 |
<p>A <a href="https://codereview.stackexchange.com/questions/57555/git-commit-msg-url-shortener">recent question</a> inspired me to write a script for this task:</p>
<ul>
<li>Shorten URLs in specified text files using googleapis.com</li>
<li>Handle multiple URLs, whether on the same line or multiple lines</li>
</ul>
... | [] | [
{
"body": "<p>Overall, LGTM.</p>\n\n<p>Suggestions:</p>\n\n<ul>\n<li><p><code>try ... except</code> would look better than <code>os.path.isfile()</code>. Even if <code>isfile</code> returns <code>True</code>, you still may encounter an exception trying to open it (say, insufficient privileges), so you should be... | {
"AcceptedAnswerId": "58015",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T20:43:47.167",
"Id": "57848",
"Score": "6",
"Tags": [
"python",
"url"
],
"Title": "Simple python script to shorten URLs in specified text files"
} | 57848 |
<p>To try out the concepts and tools I've been learning, I decided to write a Blackjack game. I wrote it entirely with functions, so it hasn't helped me at all with the concept I really lack understanding in: classes. Could someone point me in the right direction as to how I could rewrite this program utilizing class... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T21:59:36.123",
"Id": "103611",
"Score": "0",
"body": "Your second question is basically *\"what's the point of OOP?\"*, which is a long way off-topic here. Maybe look at [Programmers](http://programmers.stackexchange.com/help/on-top... | [
{
"body": "<p>In this case, adding classes is really easy.</p>\n\n<ol>\n<li>Create a Card class, which has a value (1, 2 ... 10) and a name (2, ... K, A)</li>\n<li>Create a Deck class, which is a list/tuple or other collection of Card with a shuffle function and a draw_card function.</li>\n<li>Create a Hand cla... | {
"AcceptedAnswerId": "57854",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T20:55:13.307",
"Id": "57849",
"Score": "6",
"Tags": [
"python",
"beginner",
"game",
"classes",
"playing-cards"
],
"Title": "Blackjack game with classes instead of funct... | 57849 |
<p>I basically have 3 processes which I loop through.</p>
<p>The first process is encoding Video. It's actually 2 processes but they are connected, so I don't need to worry about how it handles the other one.</p>
<p>The second and third are connected by me, however. One reads and the other writes, so I have to manua... | [] | [
{
"body": "<h3>Naming. It's hard.</h3>\n\n<p>I'll focus on that so a better programmer than I may focus more important things when they review this.</p>\n\n<ul>\n<li><code>QU</code> is completely meaningless to Mr. Maintainer. </li>\n<li><code>cmdCommands</code> is a bit repetitive. <code>commands</code> would ... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T22:21:22.257",
"Id": "57860",
"Score": "4",
"Tags": [
"c#",
"performance"
],
"Title": "Processes and Handling (Piping)"
} | 57860 |
<p>I have a pretty big file (3 million lines) with each line being a person-to-event relationship. Ultimate, I want to project this bipartite network onto a single-mode, weighted, network, and write it to a CSV file. I'm using NetworkX, and I've tested my code on smaller sample datasets, and it works as it should. Howe... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T22:34:49.837",
"Id": "57862",
"Score": "2",
"Tags": [
"python",
"performance",
"graph",
"pandas"
],
"Title": "Speed up projection of a bipartitie network for a big file using ... | 57862 |
<p>I am trying to learn PHP in depth by creating this personal CMS. I try to utilize OOP concepts and do best I can...</p>
<p>The way I am trying to design this CMS is to keep including 'modules' within a page to minimize code. I am using extensively POST and GET variables to decide which module will be reached. The I... | [] | [
{
"body": "<p><strong>Developement</strong></p>\n\n<p><a href=\"/questions/tagged/oop\" class=\"post-tag\" title=\"show questions tagged 'oop'\" rel=\"tag\">oop</a> & <a href=\"/questions/tagged/design-patterns\" class=\"post-tag\" title=\"show questions tagged 'design-patterns'\" rel=\"tag\... | {
"AcceptedAnswerId": "57872",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T22:36:58.350",
"Id": "57863",
"Score": "27",
"Tags": [
"php",
"object-oriented",
"design-patterns",
"security"
],
"Title": "How is my CMS design? Any security, design, or o... | 57863 |
<p>Consider:</p>
<pre><code> let mutable m' = m
while m' % i = 0L do
m' <- m' / i
</code></pre>
<p>I've refactored it into:</p>
<pre><code> let m' =
let rec exhaust m =
if m % i = 0L then exhaust (m/i)
else m
exhaust m
</cod... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T09:52:00.570",
"Id": "103706",
"Score": "0",
"body": "It only looks clearer to the non-functional eye. The second version looks cleaner to me :-)"
}
] | [
{
"body": "<p>I would write it this way</p>\n\n<pre><code>let rec exhaust m i =\n match m % i with\n | 0L -> exhaust (m / i) i\n | _ -> m\n</code></pre>\n\n<p>Not a huge improvement, but I think it's idiomatic. Now let's look at <code>primeFactors</code>:</p>\n\n<pre><code>let primeFactors x =\n ... | {
"AcceptedAnswerId": "57868",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-23T23:01:42.040",
"Id": "57865",
"Score": "2",
"Tags": [
"recursion",
"primes",
"f#",
"immutability"
],
"Title": "Replacing an F# loop over a mutable variable by an immutable ... | 57865 |
<p><a href="http://jsfiddle.net/rishulmatta/PGtWJ/" rel="nofollow">This fiddle</a> has an <kbd>ADD</kbd> button when you click it a Chat window is added. When there are more than 1 windows the message from one window is reflected across all the windows.</p>
<p>Say you have templates (in above case "Chat Window") whic... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T12:10:22.163",
"Id": "103730",
"Score": "2",
"body": "Welcome to Code Review! After having received answers, please do not add revised versions of your code to your question or modify your previous code in such a way that it invalid... | [
{
"body": "<h2>Formatting Improvements</h2>\n\n<p>I don't have time for a full review, but I will help with some of these formatting issues.</p>\n\n<p>Quoted sources: <a href=\"http://javascript.crockford.com/code.html\" rel=\"nofollow\">Douglas Crockford</a></p>\n\n<hr>\n\n<p><strong>1...</strong> You've got s... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T00:59:27.040",
"Id": "57871",
"Score": "3",
"Tags": [
"javascript",
"dom",
"event-handling"
],
"Title": "Recognizing elements and doing event handling for repeating templates"
} | 57871 |
<p>Below is my code that was written for the following task (based on an <a href="https://stackoverflow.com/q/24923216/2055998">SO question</a>):</p>
<blockquote>
<p>Given a Java <code>Collection</code> (of <strong>N</strong> elements) create an <code>ArrayList</code>, containing <strong>N</strong>
collections of ... | [] | [
{
"body": "<p>Two parts to this review:</p>\n\n<ol>\n<li>the 1-liner for the newInstance()</li>\n<li>the general mechanism of the method</li>\n</ol>\n\n<h2>newInstance()</h2>\n\n<p>This code will work, but only for a subset of Collections. For example, there are many Collection implementations that do not have ... | {
"AcceptedAnswerId": "57876",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T02:06:09.353",
"Id": "57873",
"Score": "12",
"Tags": [
"java",
"generics",
"interface"
],
"Title": "Instantiating a run-time implementation of an interface"
} | 57873 |
<p>How can I optimize this code?</p>
<pre><code>for(var i = 0; i<people_to_save_parse.length;i++)
{
if($(".ID-"+people[i].tdid).is(':checked')==true)
{
people_to_save_parse[i].id = $(".ID-text-"+people[i].tdid).text();
}else{
pe... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T02:53:43.497",
"Id": "103639",
"Score": "1",
"body": "What does this code do?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T02:54:46.637",
"Id": "103640",
"Score": "0",
"body": "Check if... | [
{
"body": "<p>With a function:</p>\n\n<pre><code>var checkedValue = function (tdid, field) {\n if ($(\".\" + field + \"-\" + tdid).is(':checked')) {\n return $(\".\" + field + \"-text-\" + tdid).text();\n }\n return \"\";\n}\n</code></pre>\n\n<p>and you could then simply call that with:</p>\n\n<... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T02:52:19.453",
"Id": "57877",
"Score": "2",
"Tags": [
"javascript",
"jquery"
],
"Title": "Checking if switch is checked and doing something with the data"
} | 57877 |
<p>Here is a short and simple Ajax method that returns <code>"True"</code> or <code>"False"</code> if an entity exists in a database via a stored procedure that returns just <code>"Y"</code> or <code>"N"</code> (the details of this entity and database are not relevant to my question though). </p>
<p>This is the first... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-25T01:39:54.870",
"Id": "103937",
"Score": "0",
"body": "Thanks for the helpful and informative responses, ckuhn203 and Carlos, and thank you for fixing the formatting, Jamal!"
}
] | [
{
"body": "<ul>\n<li>I may be pointing out the obvious here, but the <code>ValidateEntity</code> Method returns a string. I would expect it to return a Boolean. </li>\n<li>There are a number of one and two letter variable names. We've not been restricted in the size of names for many years now. It would be good... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T02:53:41.210",
"Id": "57878",
"Score": "3",
"Tags": [
"c#",
"ajax",
"validation",
"stored-procedure"
],
"Title": "Determining if an entity exists in a database via a stored pr... | 57878 |
<p>This is my firstish (heavily rewritten) go at the completed project that I've been working on with CodeReview assistance, so further advice is appreciated! See <a href="https://codereview.stackexchange.com/questions/57167/load-bitmap-object-data-into-array-of-byte-values">here</a>, <a href="https://codereview.stacke... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T19:33:04.447",
"Id": "103854",
"Score": "0",
"body": "Note: if somebody can show me how to change my while-do loop to be more F#-ish/functional, I will happily put a bounty on this question. =)"
},
{
"ContentLicense": "CC BY... | [
{
"body": "<p><code>try ... with | _ -> false</code> is bad. Like, <strong>very bad</strong>. The equivalent in C# is</p>\n\n<pre><code>try\n{\n ...\n}\ncatch (Exception)\n{\n return false;\n}\n</code></pre>\n\n<p>See <a href=\"https://stackoverflow.com/a/7152374\">this answer</a> on SO for good advice... | {
"AcceptedAnswerId": "58452",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T04:34:22.337",
"Id": "57882",
"Score": "3",
"Tags": [
"array",
"image",
"f#"
],
"Title": "Locating a bitmap inside another (larger) bitmap with F#"
} | 57882 |
<p>I'm quite new to Laravel, and I'm not sure what am I doing is the best practice.</p>
<p>I'd like to return JSON if the request is Ajax, or return a view otherwise. This is the way I made it, and it works fine, but I'm not sure if this is the best way(it seems long winded). I'd really like to hear your suggestions.<... | [] | [
{
"body": "<p>The only problem with this approach is that as you add more methods, you are going to end up with an awful lot of repeated <code>if (Request::ajax()) ...</code> blocks all over your code.</p>\n\n<p>Here's what I do for my sites:</p>\n\n<pre><code><?php\nclass ApiController extends Controller {\... | {
"AcceptedAnswerId": "57884",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T04:54:35.987",
"Id": "57883",
"Score": "4",
"Tags": [
"php",
"laravel"
],
"Title": "Controller method - Ajax request"
} | 57883 |
<p>I'm currently working on a tool that needs to decode, modify data, then re-encode that data using the Yaz0 format. Everything has been in a working state, but after running some code analysis on my program it turns out it is spending an obscene amount of time on the encoding portion (Over 95%). However, I cannot thi... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T12:00:52.583",
"Id": "103726",
"Score": "0",
"body": "Please see [this meta post on how to have a successful iterative code review](http://meta.codereview.stackexchange.com/questions/41/iterative-code-reviews-how-can-they-happen-suc... | [
{
"body": "<p>Just looking at the logic of the code, it looks to me that you could do the same thing by assigning j to numBytes after the j loop exits and moving the matchpos assignment outside the j loop since it is assigned the value of i and doesn't need to be assigned on every iteration of the j loop:</p>\n... | {
"AcceptedAnswerId": "57946",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T05:52:55.993",
"Id": "57888",
"Score": "6",
"Tags": [
"c++",
"optimization",
"performance"
],
"Title": "Optimizing nested loop in run length encoding function"
} | 57888 |
<p>Following-up on <a href="https://codereview.stackexchange.com/q/57734/23788">this post</a>, I wanted to be able to put a copy of that Excel workbook on a USB key and take it home to keep working on the code a bit (there's more than just one or two tables to maintain, so I'll have about a dozen forms when I'm done)..... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T16:37:11.943",
"Id": "103808",
"Score": "0",
"body": "Did you have any particular concerns about the code?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T16:39:22.277",
"Id": "103810",
"Score... | [
{
"body": "<p>I think this is pretty much done. You have great naming. No glaring bugs as far as I can tell. It's clear and concise. Very OOP, which is impressive given the language. Even the high level design seems pretty darn tight. (I know very little about dependency injection though. I could have missed so... | {
"AcceptedAnswerId": "57953",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T06:23:46.420",
"Id": "57889",
"Score": "14",
"Tags": [
"object-oriented",
"design-patterns",
"vba",
"dependency-injection",
"repository"
],
"Title": "YARPI: Yet Another... | 57889 |
<p><img src="https://i.stack.imgur.com/v7Yd1.png" alt="Play! Framework logo"></p>
<p>The <strong><a href="http://www.playframework.com/" rel="nofollow noreferrer">Play! Framework</a></strong> is a modern Java (and Scala) web application open-source framework that provides a clean alternative to bloated Enterprise Java... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T07:10:53.087",
"Id": "57891",
"Score": "0",
"Tags": null,
"Title": null
} | 57891 |
The Play! Framework is a modern Java and Scala web application open-source framework that provides a clean alternative to bloated Enterprise Java stacks. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T07:10:53.087",
"Id": "57892",
"Score": "0",
"Tags": null,
"Title": null
} | 57892 |
<p>I tested the play framework the last days and had mixed feelings about it. In the end, I don't use play for my new REST project. I use <a href="http://www.sparkjava.com" rel="nofollow">http://www.sparkjava.com</a> as minimal server setup.</p>
<p>But I really like the server session less idea from play and want them... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T08:02:22.953",
"Id": "103675",
"Score": "0",
"body": "Hello there and welcome to [codereview.se]! I took the liberty to edit your question a little, the reasons are outlined in the edit-summary. If you disagree with my edit, feel fr... | [
{
"body": "<p>First of all, this code is not thread safe. If different threads find the privateKey as null, each of them will generate a different value into it. You should use \"static constructor\" or have to use <a href=\"http://blog.crazybob.org/2007/01/lazy-loading-singletons.html\" rel=\"nofollow\">Double... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T07:25:53.100",
"Id": "57897",
"Score": "6",
"Tags": [
"java",
"security",
"mvc",
"rest"
],
"Title": "Java secured cookie - security issues?"
} | 57897 |
<p>I have two functions that are similar. The only differences is that they're using two different models. How can I change them into one function?</p>
<pre><code> ITagRepository tagRepo = new TagRepository();
ICategoryRepository catRepo = new CategoryRepository();
public void AddTagsDontExist(string tags)
{
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T08:15:37.670",
"Id": "103681",
"Score": "2",
"body": "Why do you use `ToArray` in one, but not the other?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T08:17:46.160",
"Id": "103682",
"Score"... | [
{
"body": "<p>You need to think about the underlying model. Have a think about isA/hasA. Depending on what you conclude...</p>\n\n<ul>\n<li>Are the types defining similar interfaces? You may find that the date info is like a label that both object types have attached to them. (It looks that way.) Define an inte... | {
"AcceptedAnswerId": "57902",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T07:56:36.193",
"Id": "57899",
"Score": "3",
"Tags": [
"c#",
"linq"
],
"Title": "Changing these two functions into one function"
} | 57899 |
<p>I have <a href="https://github.com/alvations/pywsd" rel="nofollow">a library</a> for simple Word Sense Disambiguation (WSD).</p>
<p>I have a function for WSD based on the sum of maximum similarity score for every word. But it's slow because it iterates through all words in the input sentence and then finds the max ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T08:35:02.640",
"Id": "103686",
"Score": "0",
"body": "Probably not worth an answer but you can replace : `return max(wn.path_similarity(sense1,sense2), wn.path_similarity(sense1,sense2))` with `return wn.path_similarity(sense1,sense... | [
{
"body": "<p>To improve performance, remove stop words from context sentence. </p>\n\n<pre><code>from nltk.corpus import stopwords\n\ndef is_stopword(x): return x not in stopwords.words('english')\n\nwords = filter(is_stopword, word_tokenize(context_sentence))\nresult[i] = sum(max([sim(i,k,option) for k in wn... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T08:30:55.983",
"Id": "57903",
"Score": "3",
"Tags": [
"python",
"performance"
],
"Title": "Optimizing max similarity for WSD in Python"
} | 57903 |
<p>I want to create an XML format in which I will define data objects for a game I am currently working on.</p>
<p>The base idea is that I will have <code>Elements</code> which can be combined in other <code>Elements</code>, <code>Items</code> or <code>Spells</code>. </p>
<p>A <code>primal element</code> is an elemen... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T11:22:32.467",
"Id": "103714",
"Score": "0",
"body": "It would be really interesting to see the code for your actual game another time. How you format your XML will likely depend a lot on that code."
},
{
"ContentLicense": "... | [
{
"body": "<p>I'd wrap the <code><Component>s</code> in a <code><Components></code> tag. Maybe you want to add more attributes to spells later. In fact, I'd probably make <code><ItemComponents></code> and <code><SpellComponents></code>.</p>\n\n<p>I'm also thinking you might be better off... | {
"AcceptedAnswerId": "57913",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-24T08:45:38.347",
"Id": "57905",
"Score": "12",
"Tags": [
"game",
"xml"
],
"Title": "XML format for game data"
} | 57905 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.