body stringlengths 25 86.7k | comments list | answers list | meta_data dict | question_id stringlengths 1 6 |
|---|---|---|---|---|
<p>As part of my Java learning, I tried solving Part I of problem description <a href="http://www.cs.berkeley.edu/~jrs/61bf06/hw/pj1/readme" rel="nofollow">here</a>. The only issue that I see now is that I could not close the button of <code>Frame</code>. </p>
<p>Please review and provide your comments on coding style... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T07:45:34.513",
"Id": "75164",
"Score": "1",
"body": "This is the same simulation they used in AP Computer Science courses over eight years ago..."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T08:27:... | [
{
"body": "<p>Just a quick comment: Your <code>Ocean</code> class knows/does too many things.</p>\n\n<p>I'd be expecting a <code>Fish</code> class and a <code>Shark</code> class. Creating an ocean requires a <code>starveTime</code> constructor parameter? That's a sign you've broken the <strong>single responsibi... | {
"AcceptedAnswerId": null,
"CommentCount": "8",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T01:39:07.920",
"Id": "43476",
"Score": "9",
"Tags": [
"java",
"simulation"
],
"Title": "Simulation of an ocean containing sharks and fish"
} | 43476 |
<p>I'm using this JS to sticky website footers at the bottom and I would like to know if is there anything to be optimised?</p>
<pre><code>(function($, window, document){
//Screen_height = Header_height + Main_Content_height + Footer_height + alltoplvlContainersMarginTop_Bottom + alltoplvlContainersPaddingTop_Bott... | [] | [
{
"body": "<p>From a once over,</p>\n\n<ul>\n<li>I strongly suggest lowerCamelCase: <code>sticky_footer</code> -> <code>stickyFooter</code>, <code>screen_height</code> -> <code>screenHeight</code> etc. etc.</li>\n<li><p>You should compare to <code>undefined</code> with <code>===</code> or use a falsey compariso... | {
"AcceptedAnswerId": "43513",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T05:18:16.877",
"Id": "43484",
"Score": "1",
"Tags": [
"javascript",
"jquery",
"dom"
],
"Title": "JavaScript Sticky Footer"
} | 43484 |
<p>I've tried to write my <code>Property Container</code> design-pattern implementation.</p>
<p>Could anybody, please, tell me, if this code is really <strong>what I intended</strong> to write (follows the <code>Property Container</code> design-pattern rules)? Is there anything that can be improved?</p>
<pre><code>&l... | [] | [
{
"body": "<p>Yes, you are using this patter correctly here. Its use in PHP (especially as a generic implementation) is greatly reduced though. As the answers in your <a href=\"https://softwareengineering.stackexchange.com/questions/231274/property-container-design-pattern-in-depth-definition\">programmers.stac... | {
"AcceptedAnswerId": "43558",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T05:18:27.767",
"Id": "43485",
"Score": "2",
"Tags": [
"php",
"design-patterns",
"classes",
"php5",
"properties"
],
"Title": "\"Property Container\" design-pattern"
} | 43485 |
<pre><code>import java.math.BigInteger;
import java.util.Random;
public class Primetest {
private static int size=15;
private static Random r=new Random();
private static BigInteger two=new BigInteger("2");
private static BigInteger three=new BigInteger("3");
public static void main(String[] args) ... | [] | [
{
"body": "<p>This is Code Review, so I will not try to find where it doesn't support 2048 bit BigIntegers, but I will tell you what I see in your code:</p>\n\n<p><strong>Naming Conventions</strong></p>\n\n<p>You should choose your names according to your language's <a href=\"http://www.oracle.com/technetwork/j... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T08:25:18.453",
"Id": "43490",
"Score": "5",
"Tags": [
"java",
"primes",
"random"
],
"Title": "BigInteger prime testing"
} | 43490 |
<p>I am using knockout in my project. I have some models like <code>EmployeeModel</code>, <code>ServiceModel</code> etc which user can update. On UI I give the user a <code>Cancel</code> control button by which he can revert the changes. On cancel I have to revert the model change back to its original state. For this I... | [] | [
{
"body": "<p>From a <a href=\"http://en.wikipedia.org/wiki/KISS_principle\" rel=\"nofollow\">KISS</a> perspective, I would simply load the model again, then you would not need any of this code.</p>\n\n<p>Other than that the code is clean and maintainable, some nitpicking though:</p>\n\n<ul>\n<li>You declare <c... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T08:45:03.627",
"Id": "43492",
"Score": "3",
"Tags": [
"javascript",
"jquery",
"knockout.js"
],
"Title": "Revert knockout model original state back on update cancel?"
} | 43492 |
<p>I'm hoping this is the correct place for this, I'm struggling a little for wording as i'm not sure what you would call this.</p>
<p>Basically, i have a system in place where my datagrid marks cells that have changed with a new background colour, to do this i have a method in the object that contains these propertie... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T11:34:38.847",
"Id": "75193",
"Score": "1",
"body": "That doesn't really change much from the points I mentioned below although as Vogel612 said , you shouldn't use exceptions in expected areas. you should return the Pink value if t... | [
{
"body": "<p>Well it seems to me you have a key and a chunk of code that returns a colour based on some boolean check. </p>\n\n<p>I would probably suggest a Function collection.</p>\n\n<p>e.g</p>\n\n<pre><code>Dictionary<string,Func<Color>> Actions;\n\nvoid InitActions()\n{\n Actions = new Diction... | {
"AcceptedAnswerId": null,
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T09:50:03.603",
"Id": "43495",
"Score": "4",
"Tags": [
"c#",
"wpf"
],
"Title": "Better method for my property Checking, replacement of switch statement"
} | 43495 |
<p>I tried to make a weighted search function in JavaScript. I've been improving my JS lately but still not sure about some best practices, wondering if there's any improvements I could make, or if I've ended up doing it completely wrong.</p>
<p>The intention is to keep it quite flexible so it can take an array of fil... | [] | [
{
"body": "<p>I like it, from a once over:</p>\n\n<ul>\n<li><code>map</code>, <code>filter</code>, <code>reduce</code> etc. are not the most efficient functions, they make for readable code, not for speedy sorting/searching. See this : <a href=\"http://jsperf.com/arraymap\" rel=\"nofollow\">http://jsperf.com/ar... | {
"AcceptedAnswerId": "43549",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T10:55:19.227",
"Id": "43500",
"Score": "5",
"Tags": [
"javascript",
"algorithm",
"search"
],
"Title": "My attempt at a weighted search in JavaScript"
} | 43500 |
<p>I have a jQuery script and I should explain it line by line. I already do that and I want to make sure that is correct. If someone has any remarks, I will be very appreciative.</p>
<pre><code>//Here we use the jQuery selector ($) to select the servers_id which is located into
//the delivers_id and we attaches a... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T12:13:11.877",
"Id": "75202",
"Score": "2",
"body": "Your indentation is damn confusing"
}
] | [
{
"body": "<p>Curious,</p>\n\n<ul>\n<li><code>$(\"#delivers #servers\")</code> does not do what you think it does, <code>$(\"#delivers, #servers\")</code> might, UPDATE: unless you mean to look for <code>#servers</code> under <code>#delivers</code> in which case you should strive to only have one tag with the ... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T12:06:05.023",
"Id": "43504",
"Score": "1",
"Tags": [
"javascript",
"jquery",
"ajax"
],
"Title": "Script for managing server IDs"
} | 43504 |
<p>I use the <a href="https://www.sencha.com/learn/how-to-use-src-sencha-io/" rel="nofollow">src.sencha.io service</a> to resize images on the fly according to device width, saving lots of bandwidth on mobiles etc.</p>
<p>Sometimes the service fails randomly with a 503 error, so a fallback is needed. I've written this... | [] | [
{
"body": "<p>I like the idea, from a once over:</p>\n\n<ul>\n<li>Since you use an IIFE I would declare <code>sencha_path_identifier</code> and <code>sencha_path_regex</code> outside of the constructor, then you can access them without specifying <code>this.</code></li>\n<li>I would do either <code>function Sen... | {
"AcceptedAnswerId": "43547",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T13:21:07.060",
"Id": "43507",
"Score": "4",
"Tags": [
"javascript",
"jquery",
"web-services",
"prototypal-class-design"
],
"Title": "Graceful JavaScript fallback for extern... | 43507 |
<p>The <code>results</code> variable is coming from an API that have a arrays in arrays, etc.</p>
<p>I have made a <code>foreach</code> with <code>for</code> loops inside, which looks like this:</p>
<pre><code>foreach (var s in results)
{
var dataRowsCollection = s.ResultRows;
for (int g = 0; g <= dataRow... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T14:09:38.187",
"Id": "75229",
"Score": "4",
"body": "What are you trying to do with these values? This code doesn't do anything with the values it creates in the inner most for loop."
},
{
"ContentLicense": "CC BY-SA 3.0",
... | [
{
"body": "<p>Before you ask yourself \"<em>can I do this with LINQ?</em>\", you need to look at the body of your loop:</p>\n\n<blockquote>\n<pre><code>var dataRows = dataRowsCollection[i].ItemArray;\nvar Title = dataRows[0].ToString();\nvar Url = dataRows[4].ToString();\nvar TemplateId = dataRows[6].ToString()... | {
"AcceptedAnswerId": "43538",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T14:00:19.423",
"Id": "43512",
"Score": "-2",
"Tags": [
"c#",
"linq"
],
"Title": "Is this correct way to use loops or should it be in LINQ?"
} | 43512 |
<p>I'm attempting to apply a long set of conditions and operations onto a pandas dataframe (see the dataframe below with VTI, upper, lower, etc). I attempted to use apply, but I was having a lot of trouble doing so. My current solution (which works perfectly) relies on a <code>for</code> loop iterating through the data... | [] | [
{
"body": "<p>Pandas allows you to filter dataframes efficiently using boolean formulas.</p>\n\n<p>Instead of using a <code>for</code> loop and conditional branching, use the following syntax:</p>\n\n<pre><code>df = portfolio[(portfolio['sell'] == True) & (portfolio['Tok'] < maxtokens)]\n</code></pre>\n\... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T15:07:40.277",
"Id": "43517",
"Score": "3",
"Tags": [
"python",
"pandas"
],
"Title": "Working with pandas dataframes for stock backtesting exercise"
} | 43517 |
<p>I wrote some compare-functions that I pass to other methods in javascript:</p>
<pre><code>function equal(a, b) {
if (a instanceof Date) return a.getTime() == b.getTime();
return a == b;
}
function lessThan(a, b) {
if (a instanceof Date) return a.getTime() < b.getTime();
return a < b;
}
funct... | [] | [
{
"body": "<p>No need to check if the variables are <code>instanceof Date</code>. <strong>A dates value is its time</strong> so when you make (less than/greater than) comparisons with a Date instance (<code>x</code>) you're essentially comparing it to <code>+x</code> or <code>x.valueOf()</code> which will be th... | {
"AcceptedAnswerId": "43519",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T15:17:21.503",
"Id": "43518",
"Score": "5",
"Tags": [
"javascript"
],
"Title": "remove redundance in compare-functions"
} | 43518 |
<p>This code currently works, but I'm new to Objective-C from a Python/PHP background. How can I improve it/make it more Objective-Cesque?</p>
<p><strong>Header File/Interface</strong></p>
<pre><code>#import <Foundation/Foundation.h>
@interface Monster : NSObject
@property NSString* name;
@property NSNumber*... | [] | [
{
"body": "<p>First and foremost, the best way to make this "more Objective-Cesque" would be to develop a UI for it. Whether OSX or iOS, the tools available for develop UI are really quite good... but let me look at the rest of your code... ;)</p>\n<hr />\n<p>I can't see any good reason for your <cod... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T15:43:37.727",
"Id": "43523",
"Score": "5",
"Tags": [
"beginner",
"game",
"objective-c",
"console"
],
"Title": "Console monster battle game"
} | 43523 |
<p>I am relatively new to JavaScript/jQuery, and cobbled together a script. Essentially, the script sets individual timers on specific DOM elements, and then recursively applies timed functions to them. The functions actually apply a "flip" effect to a div, showing a front and back, and then do different things on each... | [] | [
{
"body": "<p>This might not be an improvement per se, but you can change this:</p>\n\n<pre><code>$(document).ready( function() {\n $('.flipper').each(function(e) {\n var flipper = new myFlipper($(this));\n })\n});\n</code></pre>\n\n<p>To this:</p>\n\n<pre><code>$(function() {\n $('.flipper').ea... | {
"AcceptedAnswerId": "43527",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T16:06:21.603",
"Id": "43526",
"Score": "6",
"Tags": [
"javascript",
"jquery",
"beginner"
],
"Title": "Applying timed functions recursively"
} | 43526 |
<p>I have a small little function in a VB6 codebase:</p>
<pre><code>Public Function GetEquivalentCode(Optional ByVal code As String) As String
If IsMissing(code) Or code = vbNullString Then code = m_GlobalCode
Dim result As String
If StringStartsWith("ABC", code) Then
result = "ABC2013"
Else... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T17:52:14.230",
"Id": "75291",
"Score": "1",
"body": "I would make a single test case for every comportement you have! In my opinion it show that there is different rules (or a complex one)."
}
] | [
{
"body": "<p>The only thing that I can see at first glance to show what the business rule is, is to do something like this</p>\n\n<pre><code>m_GlobalCode = \"ABC\"\nresult = GetEquivalentCode\nDebug.Assert result = \"ABC2013\"\n</code></pre>\n\n<p>probably at the beginning. </p>\n\n<p>I think this is exactly ... | {
"AcceptedAnswerId": "43535",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T17:41:52.697",
"Id": "43531",
"Score": "10",
"Tags": [
"unit-testing",
"vb6",
"assertions"
],
"Title": "Testing code with Debug.Assert"
} | 43531 |
<p>Based on the true condition, I am making some operations. But I want to simplify the below HTML code in a better way.</p>
<pre class="lang-html prettyprint-override"><code>@{
bool savingHtml = (Request.QueryString["savehtml"] == "1");
string activeTab = Request.QueryString["from"];
}
@if (savingHtml)
{
... | [] | [
{
"body": "<p>Most of your code is duplicated, what I did is extract the logic to the first code block, and left only the placeholders in the HTML.</p>\n\n<pre><code>@{\n bool savingHtml = (Request.QueryString[\"savehtml\"] == \"1\");\n string activeTab = Request.QueryString[\"from\"];\n string tabCont... | {
"AcceptedAnswerId": "43543",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T18:07:11.867",
"Id": "43536",
"Score": "3",
"Tags": [
"html",
"mvc",
"asp.net-mvc-4"
],
"Title": "Avoiding redundant code in MVC view page"
} | 43536 |
<p>I recently posted a question about modeling a system that contains elements that can perform actions (<a href="https://codereview.stackexchange.com/questions/42332/model-simulation-using-java-annotations">here</a>). The model runs in cycles and parts perform their action every cycle. The model should have some kind ... | [] | [
{
"body": "<p>It looks quite good, some, mostly minor notes:</p>\n\n<ol>\n<li><blockquote>\n<pre><code>class Controller implements ActionListener {\n</code></pre>\n</blockquote>\n\n<p>Having an <code>actionPerformed</code> method in the controller <a href=\"https://en.wikipedia.org/wiki/Code_smell\" rel=\"nofol... | {
"AcceptedAnswerId": "43732",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T19:19:17.950",
"Id": "43540",
"Score": "3",
"Tags": [
"java",
"design-patterns",
"mvc"
],
"Title": "Java MVC pattern"
} | 43540 |
<p>I'm creating a game that implements a finite automaton and I don't know if I'm doing it right. Any advice?</p>
<p><strong>Game class</strong></p>
<pre><code>import java.awt.Canvas;
import java.awt.event.KeyListener;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.aw... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T11:11:52.707",
"Id": "75393",
"Score": "0",
"body": "In the future, it would help if you make life easier for reviewers and explain a bit about [what your code does](http://meta.codereview.stackexchange.com/questions/1226/code-shoul... | [
{
"body": "<p>There are a number of things to comment on here.</p>\n<h2>Code-Style</h2>\n<p>Java coding style puts <a href=\"http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-142311.html#15395\" rel=\"noreferrer\">the <code>{</code> opening brace at the end of the line</a> containing t... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T19:55:45.220",
"Id": "43544",
"Score": "6",
"Tags": [
"java",
"game",
"homework"
],
"Title": "Finite Automaton for a Typing Game"
} | 43544 |
<p>I am populating a drop down list from my SQL database. List should be able to be displayed with active only, inactive only or both at the same time.</p>
<p>OfficeRepository.cs:</p>
<pre><code> public static List<OfficeRollups> ListOfficeRollups(bool active, bool inactive)
{
List<DataRow>... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T21:29:35.003",
"Id": "75344",
"Score": "3",
"body": "There's a typo in your Hungarian notation for `strQry`... ;)"
}
] | [
{
"body": "<p>Here's a simplification of the <code>OfficeRepository</code> methods. Note the other <code>IDisposable</code> types in <code>using</code> blocks:</p>\n\n<pre><code> public static IEnumerable<OfficeRollups> ListOfficeRollups(bool active, bool inactive)\n {\n var whereClause = act... | {
"AcceptedAnswerId": "43551",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T20:07:24.680",
"Id": "43545",
"Score": "3",
"Tags": [
"c#",
"sql-server",
"entity-framework",
"asp.net-mvc-4"
],
"Title": "Populate Drop Down List from SQL Database"
} | 43545 |
<p>I'm adding additional functionality to an existing MVC .net application, and to help prevent or at least reduce repeated reads to the dB I'm dumping a few custom entities in session. I'm limiting what can be stored in session to say a max of 5 objects for now. </p>
<p>Given below is the code and it seems generic en... | [] | [
{
"body": "<p>There are 4 places where you have code like,</p>\n\n<pre><code>if (session != null)\n{\n List<KeyValuePair<string, T>> questionModelStore;\n\n if (session[\"QuestionModelStore\"] == null)\n {\n questionModelStore = (List<KeyValuePair<string, T>>)session[\"Qu... | {
"AcceptedAnswerId": "43570",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T20:18:16.643",
"Id": "43546",
"Score": "3",
"Tags": [
"c#",
".net",
"mvc",
"generics",
"session"
],
"Title": "Session state wrapper, extending an existing application"
... | 43546 |
<p>I implemented a fixed-size matrix class which supports basic matrix operations (cannot use C++11). What do you think, and how could it be improved?</p>
<pre><code>#ifndef FIXED_SIZE_MATRIX_H__
#define FIXED_SIZE_MATRIX_H__
#include <iostream>
#include <cstdlib>
template <typename Ty, int N, int M =... | [] | [
{
"body": "<p>Looks good over all, but I have a few thoughts. A few are stylistic, some are technical, and some are just trade offs I want to make sure you're aware of.</p>\n\n<hr>\n\n<p>I would use the <code>value_type</code> typedef for method return types, temporary types, etc. It should make for a bit prett... | {
"AcceptedAnswerId": "43553",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T20:47:36.543",
"Id": "43548",
"Score": "5",
"Tags": [
"c++",
"matrix",
"c++03"
],
"Title": "Fixed size matrix implementation"
} | 43548 |
<p>How could I make this code more effective? I'm just experimenting and learning the different ways of how Python runs.</p>
<pre><code>list=[]
original=mkPoint3D(x,y)
z1=mkPoint3D(x-d,y)
z2=mkPoint3D(x+d,y)
z3=mkPoint3D(x,y-d)
z4=mkPoint3D(x,y+d)
list.append(original)
list.append(z1)
list.append(z2)
list.append(z3)
... | [] | [
{
"body": "<p>Don't use \"list\" as a variable name, since it is a python function.\nDon't initialize it a list and append to it, if you can\njust create it and populate it with one line.\nDon't call a function more than once, if you don't need to.\nUse a loop with a break statement, instead of all the elif sta... | {
"AcceptedAnswerId": "43556",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T21:38:26.133",
"Id": "43554",
"Score": "3",
"Tags": [
"python",
"performance"
],
"Title": "Determine local maximum from given points"
} | 43554 |
<p>Is this orthogonal?</p>
<pre><code>#ifndef TOKENIZER_H
#define TOKENIZER_H
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
class StringTokenizer
{
private:
std::vector<std::string> tokens;
unsigned int index;
public:
StringTokenizer(std... | [] | [
{
"body": "<p>Your constructor is nigh-identical to <a href=\"https://stackoverflow.com/a/236803/49942\">this up-voted answer</a> for splitting a string.</p>\n\n<p>The rest of the class doesn't add much value: IMO the vector provides the same API as your class and more besides; so a user might prefer to have th... | {
"AcceptedAnswerId": "43566",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-05T23:00:59.447",
"Id": "43561",
"Score": "7",
"Tags": [
"c++",
"design-patterns",
"strings"
],
"Title": "Simple string tokenizer wrapper"
} | 43561 |
<p>We have a geocoding samples <a href="https://github.com/agrc/GeocodingSample">github repository</a>. The snippet below came through in an email and I am not very familiar with PHP. I'd like to add this as the PHP example in the samples repository but would like someone to review it first. The idea is that some other... | [] | [
{
"body": "<p>There are a number of concerns - from code styling to error handling (echoing out an error is not good. Use Exceptions or a custom Error handler). </p>\n\n<pre><code><?\n\n/**\n * Access API from http://api.mapserv.utah.gov\n * \n * @require cURL\n * @internal Create your api key at https://dev... | {
"AcceptedAnswerId": "43623",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T00:08:07.430",
"Id": "43567",
"Score": "6",
"Tags": [
"php",
"http"
],
"Title": "Geocode an address"
} | 43567 |
<p>I'm writing an algorithm to take in a sample list of sequences of events, calculate 1-step transitional probabilities from the sequences, forward or in reverse, then calculate the joint probability of n events occurring from those conditional probabilities.</p>
<p>Eg. if the sample list of sequences is:</p>
<block... | [] | [
{
"body": "<p>Counting in Python is best done using <a href=\"http://docs.python.org/3/library/collections.html#collections.Counter\" rel=\"nofollow\"><code>collections.Counter</code></a>.</p>\n\n<p>The problem you have described sounds like a Markov chain, and the probabilities would best be represented as a <... | {
"AcceptedAnswerId": "45049",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T00:27:49.587",
"Id": "43568",
"Score": "11",
"Tags": [
"python",
"algorithm",
"numpy",
"bioinformatics"
],
"Title": "Calculating the joint probability of n events from a sa... | 43568 |
<p>For this problem, I came up with this ugly solution of appending the characters to the output and in case there is adjacent duplicate deleting from the output. Considering <code>StringBuilder.deleteCharAt(i)</code> is O(N), performance is O(N) + O(N) = O(N).</p>
<p>Please critique this, if this is a right way.</p>
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T00:31:46.990",
"Id": "75358",
"Score": "6",
"body": "Why does it have to be recursive? ... and if it has to be recursive, why is your code ***not*** recursive?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "201... | [
{
"body": "<h2>General</h2>\n<p>Your code formatting is all over the place. You should use consistent and structured indentation. See the <a href=\"http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html\" rel=\"nofollow noreferrer\">Java Code-Style guide for, well, guidance</a>.</p>... | {
"AcceptedAnswerId": "43578",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T00:28:58.540",
"Id": "43569",
"Score": "2",
"Tags": [
"java",
"algorithm",
"performance"
],
"Title": "Remove all adjacent duplicates"
} | 43569 |
<p>Here is the question: find the largest palindrome from a string.</p>
<p>Ex:</p>
<pre><code>ABCBAHELLOHOWRACECARAREYOUILOVEUEVOLIIAMAIDOINGGOOD
</code></pre>
<p>Result:</p>
<pre><code>ILOVEUEVOLI
</code></pre>
<p>I am not sure of the efficiency of the algorithm.</p>
<pre><code>static void Main(string[] args)
{
... | [] | [
{
"body": "<p>Your basic algorithm seems pretty efficient, but building a list then sorting it just to find the longest one isn't very efficient. It would be much more efficient to just keep track of the longest palindrome:</p>\n\n<pre><code> private static string GetLongestPalindrome(string input)\n {\n... | {
"AcceptedAnswerId": "43574",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T00:49:39.007",
"Id": "43571",
"Score": "17",
"Tags": [
"c#",
"algorithm",
"palindrome"
],
"Title": "Return the largest palindrome from the string"
} | 43571 |
<p>I'm comparing two distinct instances and if they are not the same I save to the dB, so I've given snippet of code below of the way I am comparing these instances, I realize I could use reflection and generalize but short of using reflections is there any other way I could optimize the code or make it neater? </p... | [] | [
{
"body": "<ol>\n<li><p>Property names like <code>IsCheckedRadioButton1</code> are completely useless as they in no way indicate the purpose of it's intended usage or what it represents. Given that it's probably bound to a radio button it means it's very likely some sort of option to chose from. My guess you co... | {
"AcceptedAnswerId": "43582",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T05:18:00.810",
"Id": "43577",
"Score": "4",
"Tags": [
"c#",
"algorithm",
".net",
"reflection"
],
"Title": "comparing objects; optimize code short of using reflection"
} | 43577 |
<blockquote>
<p>Regex parser which follows the following rule</p>
<ol>
<li><code>.</code> (dot) means a any single character match</li>
<li><code>*</code> (star) means 0 or more character match</li>
<li><code>?</code> (question) means previous char is an option i.e <code>colou?r</code> matches <code>color<... | [] | [
{
"body": "<p>Your code is rather nice, but the algorithm is fundamentally flawed. Consider these test cases, which you currently fail:</p>\n\n<pre><code>// The empty string is a substring of any string\nAssert.assertTrue(Regex.matches(\"\", \"abc\"));\n\n// Because you check for direct character equivalence be... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T06:25:53.770",
"Id": "43579",
"Score": "5",
"Tags": [
"java",
"regex",
"reinventing-the-wheel"
],
"Title": "Regex parser implementing dot, star and question mark"
} | 43579 |
<p>I'm trying to tidy the following fragment of code:</p>
<pre><code> if (this.Details.Recipients.Count > 0)
this.Recipient = this.Details.Recipients[0];
else
{
this.Recipient = new Contact();
this.Details.Recipients.Add(this.Recipient);
}
i... | [] | [
{
"body": "<p>So I think the error you is getting is hopefully obvious. You can't pass a property by ref. There is quite a few answers if you google this. Here's a quick one I found on <a href=\"https://stackoverflow.com/questions/1402803/passing-properties-by-reference-in-c-sharp\">stack overflow</a></p>\n\... | {
"AcceptedAnswerId": "43581",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T07:39:01.087",
"Id": "43580",
"Score": "4",
"Tags": [
"c#"
],
"Title": "Managing contacts"
} | 43580 |
<p>I had three multi-select boxes from <a href="http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/#basic" rel="nofollow">this page</a>. I want to customize each box so I simply repeat the code three times with different options: <strong><a href="http://jsfiddle.net/akhyp/1004/" rel="nofollow">Check t... | [] | [
{
"body": "<p>Because you have different options for each one, there isn't really an efficient way to combine them into a common selector. And, with only three items, other options aren't really that likely to be more compact. Here's a pure table driven mode that would be more advantageous if you had many mor... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T09:10:12.430",
"Id": "43584",
"Score": "3",
"Tags": [
"javascript",
"jquery",
"jquery-ui"
],
"Title": "Do I need to trim this jQuery code?"
} | 43584 |
<p>I appreciate any feedback on where I might alter or improve my code for this project. This is an old attempt at implementing a Hierarchical State Machine in F#. I'm from a C#/OO background mostly.</p>
<pre><code>module FSharp.HSM
open Option
open System.Collections.Generic
exception NoTransition
exception NotI... | [] | [
{
"body": "<pre><code>let rec getParents results state =\n let currentConfig = stateList |> List.find (fun x -> x.State = state)\n if isSome currentConfig.SuperState then \n let super = get currentConfig.SuperState\n getParents (super::results) super\n else results |> List.rev\n</code></pre>\n... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T09:25:06.500",
"Id": "43587",
"Score": "9",
"Tags": [
"f#",
"state-machine"
],
"Title": "Hierarchical State Machine in F#"
} | 43587 |
<p><a href="http://pandas.pydata.org/" rel="nofollow">Pandas</a> is a Python data analysis library.</p>
| [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T09:30:16.107",
"Id": "43588",
"Score": "0",
"Tags": null,
"Title": null
} | 43588 |
Pandas is a Python data analysis library. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T09:30:16.107",
"Id": "43589",
"Score": "0",
"Tags": null,
"Title": null
} | 43589 |
<p>I am trying to solve <a href="http://www.spoj.com/problems/PRIMEZUK/" rel="nofollow">this SPOJ question</a>.</p>
<pre><code> #include<iostream>
#include<cstdio>
#include<math.h>
#define l long long
using namespace std;
l chk(l a)
{
for(int i=2;i<=sqrt(a);++i)
{
if(a%i==0)
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T10:09:59.970",
"Id": "75386",
"Score": "5",
"body": "Welcome to Code Review! Unfortunately, this question appears to be off-topic because it is about solving a problem rather than asking for a Code Review. We improve code cleaniness... | [
{
"body": "<p>I cannot help you with your issue before commenting and fixing on the formating of your code :</p>\n\n<ol>\n<li>Remove whatever you want to remove before going through code reviews.</li>\n<li>Give your function relevant names and add some documentation and unit tests.</li>\n<li>Indent your code pr... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T09:41:43.470",
"Id": "43591",
"Score": "0",
"Tags": [
"c++",
"primes"
],
"Title": "Prime conjecture"
} | 43591 |
<p>I have been working on a linked list for some while now and started out with <a href="https://stackoverflow.com/questions/22141477/simple-linked-list-c">this</a>.</p>
<p>Is my code clean? Or is there some way to make it better and more readable? </p>
<p>The reason for this question is for me to be a better program... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T16:57:43.107",
"Id": "75444",
"Score": "0",
"body": "If you use a `Sentinal` it makes the creation of a linked list a lot easier to write and the code a lot cleaner. http://codereview.stackexchange.com/a/9399/507"
}
] | [
{
"body": "<p>Here's some feedback (not an exhaustive list).</p>\n\n<pre><code>using namespace std;\n</code></pre>\n\n<p>Please stop doing this. when you add <code>using namespace</code> directives in header files, any file including that header will have potential namespace clashes (which is the problem namesp... | {
"AcceptedAnswerId": "43597",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T12:44:27.877",
"Id": "43595",
"Score": "4",
"Tags": [
"c++",
"linked-list"
],
"Title": "Make LinkedList in C++ more clean"
} | 43595 |
<p>I'd like to get some input on whether or not to DRY up this code. And if so how to implement it correctly. How do I know when it's worth refactoring?</p>
<pre><code>public class Win32OperatingSystem
{
public Win32OperatingSystem() { }
/// <summary>
/// Number, in megabytes, of physical memory cu... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T13:33:00.523",
"Id": "75399",
"Score": "0",
"body": "Hi! I have removed the extra closing brace at the end; you could add a bit more context to the question, describing what the code is doing - comments are part of your code and can... | [
{
"body": "<p>Your PropertyGetter.Dispose method does nothing and has nothing to do, so there's no point in PropertyGetter being disposable.</p>\n\n<p>Instead its methods could be static, for example:</p>\n\n<pre><code>public static ulong GetUlong(string propertyName, string Win32Class) { ... }\n</code></pre>\n... | {
"AcceptedAnswerId": "43602",
"CommentCount": "11",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T13:22:39.240",
"Id": "43598",
"Score": "5",
"Tags": [
"c#"
],
"Title": "Should I refactor for DRY?"
} | 43598 |
<p>I'm writing a simple table-oriented storage for objects. The schema of a table is stored in the <code>columns</code>-array and the data in the <code>rows</code>-array.</p>
<pre><code>// example: table "employees"
var columns = ["id", "name"]
var rows = [[1, "Alice"], [2, "Bob"]];
</code></pre>
<p>I wrote a functio... | [] | [
{
"body": "<p>You could make it smaller by turning your function into a constructor:</p>\n\n<pre><code>function RowObject(row) {\n for (var i = 0; i < columns.length; i++) \n this[columns[i]] = row[i];\n}\n</code></pre>\n\n<p>You would have to call this function with <code>new</code> then. I would av... | {
"AcceptedAnswerId": "43613",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T14:12:40.873",
"Id": "43603",
"Score": "2",
"Tags": [
"javascript",
"array",
"properties"
],
"Title": "Create object-properties from an array"
} | 43603 |
<p>I've been suggested to put the following snippet of code up for review, hence I will do so, review of everything is appreciated, also posting as much relevant code as possible:</p>
<pre><code>abstract public class Primitive {
protected List<VertexData> vertexData;
public List<VertexData> getVer... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2015-03-01T13:23:06.537",
"Id": "149067",
"Score": "2",
"body": "Instead of looping and doing `vdSet.add(vd);` you can in Java 7 do `vdSet.addAll(primitive.getVertexData());`"
}
] | [
{
"body": "<h2>long vs. int</h2>\n\n<p>In your map you are keyed off the long value of the index. The long is simply related to the size of the map as you accumulate things.</p>\n\n<p>A Map can never have more than Integer.MAX_INT members, thus you can never accumulate more than that number of key values.... th... | {
"AcceptedAnswerId": "44444",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T14:20:16.980",
"Id": "43607",
"Score": "7",
"Tags": [
"java",
"stream"
],
"Title": "Java 8 stream collector for numbering vertices"
} | 43607 |
<p>I want to factor out the <code>AsyncTask</code> to a <code>Manager</code>. I thought to make it a singleton, but then I cannot use generics as the object to serialize to JSON and send (e.g. <code>PostManager<T></code>).</p>
<p>How can this be refactored?</p>
<pre><code>public class RestPostActivity extends B... | [] | [
{
"body": "<p>First thing I would do is separate the two concerns you have in the POST method.</p>\n\n<p>The POST method should have a different name (since <code>POST</code> does not match Java conventions), and the signature should be something like:</p>\n\n<pre><code>public static String httpPost(String url,... | {
"AcceptedAnswerId": "43632",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T14:55:19.567",
"Id": "43611",
"Score": "2",
"Tags": [
"java",
"android",
"database"
],
"Title": "Factoring out REST-POST activity to a manager"
} | 43611 |
<p>I have a lot of functions in this class to implement a login client. How do I modularize it ?</p>
<pre><code>from PyQt4 import QtGui, QtCore
from xml.dom.minidom import parseString
from datetime import datetime
import urllib2, urllib
import sys
import time
import base64
import fcntl
class Cyberoam(QtGui.QWidget):
... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T14:56:06.937",
"Id": "43612",
"Score": "1",
"Tags": [
"python",
"authentication",
"pyqt"
],
"Title": "Implementing a login client"
} | 43612 |
<p>I have a program that processes Microsoft Office documents (and other kinds, but primarily Office). I am replacing one purchased product that performs this processing with a new one. This new product consists of a library which is linked in to my code and a Windows service, which performs the actual work. For the mo... | [] | [
{
"body": "<p>There's one thing that annoys me about your class and it's the order of the code. You should follow this order: </p>\n\n<ol>\n<li>Private members </li>\n<li>Constructors</li>\n<li>Properties</li>\n<li>Methods</li>\n</ol>\n\n<p>Your code looks fine, but you could pull the delegates out of your clas... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T15:27:43.420",
"Id": "43615",
"Score": "6",
"Tags": [
"c#",
"multithreading"
],
"Title": "Safely resetting an outside service that handles requests from multiple threads"
} | 43615 |
<p>A lookup (table) is an array that replaces run time computation with a simpler array indexing operation. The savings in terms of processing time can be significant, since retrieving a value from memory is often faster than undergoing an 'expensive' computation or input/output operation.</p>
<p>Over time the definit... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T15:30:18.883",
"Id": "43616",
"Score": "0",
"Tags": null,
"Title": null
} | 43616 |
A lookup (table) is an array that replaces run-time computation with a simpler array indexing operation. The savings in terms of processing time can be significant, since retrieving a value from memory is often faster than undergoing an 'expensive' computation or input/output operation.
Over time the definition has ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T15:30:18.883",
"Id": "43617",
"Score": "0",
"Tags": null,
"Title": null
} | 43617 |
<p>I just want to checking if this kind of routing is good or bad?</p>
<p>I implement the routing of my web appl to something like this.</p>
<p>All page will be pointing to the index.php</p>
<p>in index.php I have this code</p>
<pre><code>$url = array_values(array_filter( explode( '/', strtolower($_SERVER["REQUEST_... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T15:38:44.887",
"Id": "75416",
"Score": "0",
"body": "I would separate the logic and the site specific functionality."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T18:13:15.020",
"Id": "75463",
... | [
{
"body": "<p>Separate your logic and site specific functionality like this:</p>\n\n<pre><code>function Router{\n $url = array_values(array_filter(explode('/', strtolower($_SERVER[\"REQUEST_URI\"]))));\n switch($url[0]){\n case \"admin\": $this->Admin($url);\n break;\n case \"a... | {
"AcceptedAnswerId": "43710",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T15:36:12.207",
"Id": "43618",
"Score": "1",
"Tags": [
"php"
],
"Title": "Is my routing good or bad? in PHP"
} | 43618 |
<p>This question specifically relates to the use of the class constants ABOVE and BELOW in the sample code below.</p>
<p>I have a few different classes that look like this:</p>
<pre><code>class MyClass(object):
ABOVE = 1
BELOW = 0
def __init__(self):
self.my_numbers = [1,2,3,4,5]
def find_th... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T17:25:45.517",
"Id": "75458",
"Score": "0",
"body": "Updated the code to be working python in response to off-topic flags"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T18:54:42.853",
"Id": "7546... | [
{
"body": "<p>I think the answer depends on the scope of your constants. </p>\n\n<p>If you're trying to keep the constants the same across your handful of classes, i.e., you have many class definitions and they all use ABOVE and BELOW, and ABOVE and BELOW always have the same value, then you should pull them o... | {
"AcceptedAnswerId": "43648",
"CommentCount": "8",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T15:38:15.263",
"Id": "43619",
"Score": "19",
"Tags": [
"python",
"classes",
"constants"
],
"Title": "Proper use of class constants"
} | 43619 |
<p>I am building a PHP framework and would like to get some feedback on a few different sections of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about completing these different tasks in an efficient and or correct way. </p>
<p>I am currently working on a session ma... | [] | [
{
"body": "<p>First off the code is hard to make sense of, because I only see part of it. Most importantly I don't have the source for SessionsStruction class, which you are extending, and the name \"Struction\" doesn't make any sense to me (is it even in dictionary?).</p>\n\n<p>It would also help to have a cod... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T15:45:25.130",
"Id": "43620",
"Score": "6",
"Tags": [
"php",
"design-patterns"
],
"Title": "PHP framework building: Sessions Managment Class"
} | 43620 |
<p>I am writing a Sudoku solver in C, but am having problems with how long it takes to run. It can solve easier puzzles but once I put in one a little more difficult it runs and runs and never stops.</p>
<pre><code>int solver (int x, int y)
{
int a;
int b;
int i;
int j;
printf("Depth: %d\n", counter);
fo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-28T20:03:43.380",
"Id": "75431",
"Score": "0",
"body": "maybe threads help."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-28T20:04:35.250",
"Id": "75432",
"Score": "1",
"body": "What is `check... | [
{
"body": "<p>There are a number of things that could be improved in this code.</p>\n\n<h2>Post complete code</h2>\n\n<p>I understand that this code was migrated from Stack Overflow where the rules are a little different, but here on Code Review, we want to see not just one small piece but the whole code. I ca... | {
"AcceptedAnswerId": null,
"CommentCount": "9",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-28T20:01:05.103",
"Id": "43624",
"Score": "3",
"Tags": [
"c",
"performance",
"sudoku"
],
"Title": "Faster Sudoku solver in C"
} | 43624 |
<p>I want a thread safe list with a max item count, will the following implementation correctly provide this?</p>
<pre><code>public class ConcurrentThrottledList<T>
{
private readonly List<T> items = new List<T>();
private readonly int maxItems;
private object _lock = new object();
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T16:54:52.853",
"Id": "75443",
"Score": "0",
"body": "I really can't see anything to improve."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T09:22:31.570",
"Id": "75566",
"Score": "0",
"bo... | [
{
"body": "<blockquote>\n <p>will the following implementation correctly provide this?</p>\n</blockquote>\n\n<p>Yes, it would appear so.</p>\n\n<p>Minor comments:</p>\n\n<ul>\n<li>TryRemove could be called Remove (because List.Remove is called Remove).</li>\n<li>IsFull may not be useful (because it may be obso... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T16:44:47.190",
"Id": "43627",
"Score": "8",
"Tags": [
"c#",
"thread-safety"
],
"Title": "ConcurrentThrottledList - Will this implementation be thread safe?"
} | 43627 |
<p>I need to take data from a MySQL database and message it into a format expected by the front end of an application - I can not change the front end as other services provide it data in this same format.</p>
<p>The database is structured as follows:</p>
<pre><code>id type value label optgroup
1 ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T20:17:54.917",
"Id": "75495",
"Score": "1",
"body": "slow just means it could be faster; for the current dataset it runs for about .75 seconds but it runs on EVERY page load. Currently I'm caching the results for 30 seconds but hone... | [
{
"body": "<p><strong>Non-optimizing suggestions</strong></p>\n\n<p>Your SQL is not very clear. What kind of object is acceptable for the <code>type</code> column, and how do you manage to put items into that column? How specific or general should the terms be in that column? What is the <code>value</code> colu... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T18:41:22.217",
"Id": "43635",
"Score": "5",
"Tags": [
"php",
"optimization"
],
"Title": "How can I optimize this database to array structure code?"
} | 43635 |
<p>After reading @JavaDeveloper's <a href="https://codereview.stackexchange.com/q/43579/489">recent question</a>, I was inspired<sup>1</sup> to try my hand at writing code to accomplish the same task.</p>
<p>The "rules" for this code (i.e., its intent) is to match a subset of regular expressions, defined as follows:</... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T00:47:44.697",
"Id": "75520",
"Score": "0",
"body": "This is actually a complete wildcards grammar, I think."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T00:55:40.197",
"Id": "75521",
"Scor... | [
{
"body": "<p>The regex flavour is non-standard, as you noted. Just to be clear, <code>?</code> acts as a zero-or-one-of-the-previous-character modifier, while <code>*</code> acts more like a shell glob.</p>\n\n<p>You have an access-past-the-end-of-string error when testing for glob matches in a test such as t... | {
"AcceptedAnswerId": "43647",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T18:54:01.197",
"Id": "43637",
"Score": "6",
"Tags": [
"c++",
"c",
"regex"
],
"Title": "Another regex subset matcher"
} | 43637 |
<p>This is my first attempt to create an STL-compliant container. I'd like to know whether it meets STL concepts & requirements, so feel free to critique.</p>
<p><a href="https://www.mediafire.com/?0c5zb05izkinjnu" rel="nofollow"><strong>list.h</strong></a></p>
<pre><code>#include <cstdint>
#include &... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T19:28:04.867",
"Id": "75477",
"Score": "5",
"body": "Point #1: at least as it shows up here, the formatting renders the code excessively difficult to read."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03... | [
{
"body": "<p>Why return a value:</p>\n\n<pre><code>value_type operator * () const {return *(this->m_pT->m_pT);}\n</code></pre>\n\n<p>I would return a const reference</p>\n\n<pre><code> const_reference operator * () const {return *(this->m_pT->m_pT);}\n</code></pre>\n\n<p>Iterator does not seem to s... | {
"AcceptedAnswerId": "43730",
"CommentCount": "10",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T19:18:57.247",
"Id": "43639",
"Score": "6",
"Tags": [
"c++",
"c++11",
"linked-list",
"stl"
],
"Title": "STL-compliant list class"
} | 43639 |
<p>Today, I tried to create a really simple <code>sparse_array</code> container adapter. I did not provide all the STL-like functions, only the elementary ones as a proof of concept. I also trimmed the class from its copy constructor and all the unecessary things for this review actually. Here is the code:</p>
<pre><c... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2019-12-11T19:42:42.597",
"Id": "457297",
"Score": "0",
"body": "A possible API is to see your data structure more as a map, i.e. iteration returns key,value pairs, where key is the index and value is a non default value"
}
] | [
{
"body": "<p>The primary question I have is one of usage. By the name <code>sparse_array</code>, it sounds like you want to expose an interface that is similar to an array. Perhaps it needs dynamic sizing, or perhaps not, but in particular I expect to be able to iterate over its elements with code like this:</... | {
"AcceptedAnswerId": "43865",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T19:29:50.507",
"Id": "43643",
"Score": "8",
"Tags": [
"c++",
"array",
"c++11",
"container"
],
"Title": "Simple sparse array"
} | 43643 |
<p>In an example game engine server, the game world could be represented by a World object. The game might have multiple game worlds and a player who is in a world only needs to receive position data of units in that world.</p>
<pre><code>class World
{
public List<Unit> Units { get; set; }
}
</code></pre>
<... | [] | [
{
"body": "<p>The best way to accomplish this is to have each <code>World</code>, <code>Structure</code>, and anywhere else a unit can move to inherit an interface <code>IEnterable</code>, which looks like</p>\n\n<pre><code>public interface IEnterable\n{\n void Enter(Unit unit);\n void Leave(Unit unit);\n... | {
"AcceptedAnswerId": "43649",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T19:38:54.027",
"Id": "43644",
"Score": "7",
"Tags": [
"c#",
"game"
],
"Title": "Automatically update one-to-many bi-directional relationship"
} | 43644 |
<p><strong>Task:</strong> </p>
<blockquote>
<p>Draw a grid with a given number of rows and columns. Each cell can be
any color. The same grid should also be updated at a predetermined
time interval. The grid should cover the entire visible portion of the page in the
browser. Add a context menu with which yo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T23:11:18.857",
"Id": "75512",
"Score": "3",
"body": "Please leave the formatting alone. We are trying to make the question more readable for people who want to answer can understand the question."
},
{
"ContentLicense": "CC... | [
{
"body": "<p>Just a couple of things that I really feel strongly about (didn't work line for line through your code though).</p>\n\n<h1>Seperation of logic and presentation</h1>\n\n<p>Yes, there is a <code>.style</code> object, however this does <em>not</em> mean you should use it as the primary way to style y... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T22:42:24.430",
"Id": "43655",
"Score": "5",
"Tags": [
"javascript",
"object-oriented",
"html",
"dom"
],
"Title": "Updating Grid on Webpage"
} | 43655 |
<p>I am trying to upload an image (screenshot from desktop) to an SQL database as fast as possible. I would like to optimize my current procedure in terms of speed:</p>
<pre><code>bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height,
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T16:58:43.150",
"Id": "75642",
"Score": "0",
"body": "Have you profiled your code? Which part takes the most time?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T20:38:50.647",
"Id": "75678",
... | [
{
"body": "<p>For graphic part :</p>\n\n<p>I think Gdi++ of .NET framework is very slow.\nMainly the Bitmap() construtor and Save() method.</p>\n\n<p>If it's possible for screenshot, I recommend to use :\nEither directly gdi32.dll or (maybe, im not sure that is good idea) direct2d (benefits on hardware accelera... | {
"AcceptedAnswerId": null,
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-06T23:55:34.723",
"Id": "43658",
"Score": "8",
"Tags": [
"c#",
"sql",
"sql-server",
"winforms",
"image"
],
"Title": "Fastest image upload into SQL database"
} | 43658 |
ECMAScript is the scripting language standardized by Ecma International in the ECMA-262 specification and ISO/IEC 16262. The language is widely used for client-side scripting on the web, in the form of several well-known implementations such as JavaScript, JScript and ActionScript. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T00:29:33.727",
"Id": "43661",
"Score": "0",
"Tags": null,
"Title": null
} | 43661 |
<p>Please give me some feedback to my <code>malloc</code> implementation. I implemented this design to understand the basic concept.</p>
<pre><code>#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#define HEAP_MEM_SIZE 150
#define MEMORY_AVAILABLE 1
#define MEMORY_USED 0
struct chunk_... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-09T17:10:13.843",
"Id": "75906",
"Score": "1",
"body": "When you find an answer that is satisfactory to you, you should upvote and [accept it](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). :)"
}
] | [
{
"body": "<h1>Things you did well:</h1>\n\n<ul>\n<li><p>Some use of comments.</p></li>\n<li><p>Use of <code>typedef</code>.</p></li>\n</ul>\n\n<h1>Things you could improve:</h1>\n\n<h3>Syntax/Styling:</h3>\n\n<ul>\n<li><p><a href=\"https://stackoverflow.com/q/46586/1937270\"><strong>Never</strong> use <code>go... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T01:19:17.357",
"Id": "43663",
"Score": "11",
"Tags": [
"optimization",
"c",
"memory-management"
],
"Title": "malloc implementation"
} | 43663 |
<p>I put together this implementation after playing around with various partitioning- and pivot-strategies, and it runs fine. I wrote this off a version which seemed a bit different from the majority of implementations, so I'm curious on what you guys think. It works and handles duplicates.</p>
<pre><code>def quicksor... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-09T10:23:02.697",
"Id": "75876",
"Score": "0",
"body": "It's amusing just how terse Quicksort can be in Ruby. For a functional (that is, not in-place) version of Quicksort that is just a few lines, see [this page on Ward's wiki](http:... | [
{
"body": "<p>You code looks nice, my main problem with it is <strong>naming</strong>:</p>\n\n<p>Don't use single letters as member names, unless they are trivial. I couldn't figure out what <code>l</code> and <code>r</code> stand for until I read your code a couple of times (length? range?).</p>\n\n<p>Even mor... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T02:22:54.020",
"Id": "43667",
"Score": "8",
"Tags": [
"algorithm",
"ruby",
"sorting",
"quick-sort"
],
"Title": "Quicksort implementation"
} | 43667 |
<p>I have been trying to create a class that would list prime numbers forever. I know it has already been done but I think I learned some valuable principles during my trials.</p>
<p>This project helped me understand (to a better extent) return values, arguments for methods, simple math arithmetic and what I personall... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T17:53:18.927",
"Id": "75652",
"Score": "0",
"body": "I never programmed in Java, but when I did it in C, I used an Int64. Is there a reason to use a double here?"
}
] | [
{
"body": "<p>The major problem here is using imprecise floating point values. Not only does it slow the entire process (minor quibble), but it will produce incorrect results once the values pass the integral cutoff of the field width. If you truly want to allow calculations approaching infinity (or what? 24 bi... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T04:12:54.130",
"Id": "43668",
"Score": "15",
"Tags": [
"java",
"primes"
],
"Title": "Prime number generator exercise"
} | 43668 |
<p>Please review the code.</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>RGB to HEX (and vice versa) converter</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.0/normalize.min.css">
<styl... | [] | [
{
"body": "<p>Two things jump out at me.</p>\n\n<ol>\n<li><p>Decouple from the HTML elements.</p>\n\n<pre><code>var inputRgb = document.getElementById(\"rgb\"),\n inputHex = document.getElementById(\"hex\"),\n</code></pre>\n\n<p>I would do something like:</p>\n\n<pre><code>function RGB2Hex (inputRgb, inputHe... | {
"AcceptedAnswerId": "43672",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T04:49:40.633",
"Id": "43670",
"Score": "6",
"Tags": [
"javascript",
"converting"
],
"Title": "RGB to HEX (and vice versa) converter"
} | 43670 |
<p>Is there a better (functional or more idiomatic) way to get the first positive number that is not included in a set?</p>
<pre><code>val set = Set(4, 1, 2, 0, 5)
var x = 0
while(set(x)) x += 1
println(x) // Should print 3
</code></pre>
| [] | [
{
"body": "<p>Your solution could hardly be more simple which is good.</p>\n\n<p>Also, it will loop at most <code>n</code> times (worst case when integers from the set start at 0 and are consecutive). Each loop should take a constant time on average (property of a set). Worst case complexity is <code>O(n)</code... | {
"AcceptedAnswerId": "43682",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T06:14:40.183",
"Id": "43673",
"Score": "1",
"Tags": [
"scala"
],
"Title": "Get lowest integer that is not in set"
} | 43673 |
<p>I have a server application using <code>TcpListener</code> in <code>BackgroundWorker</code>, where my application is doing some work, and in the background listening to a IP:PORT.</p>
<p>The <code>DoWork</code> of the <code>BackgroundWorker</code>:</p>
<pre><code>private void m_oWorker_DoWork(object sender, DoWork... | [] | [
{
"body": "<p>Your code looks OK, though I think there is some redundant code - <code>e.Result = clientSocket;</code> is never used, since work is never completed...</p>\n\n<p>You might also want to consider a different approach to <code>BackgroundWorker</code> - <code>TcpListener.AcceptTcpClientAsync</code>. I... | {
"AcceptedAnswerId": "43685",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T07:34:05.093",
"Id": "43679",
"Score": "3",
"Tags": [
"c#",
"tcp"
],
"Title": "Is this the right way to use TcpListener in the background?"
} | 43679 |
<p>Could you suggest ways of writing this code better?</p>
<pre><code>bool success = true;
if(x == 0)
{
if(do_up)
run_do_up();
else if(do_a)
run_do_a();
else if(do_n)
run_do_n();
else
success = false;
}
else if(x == 1)
{
if(do_n)
run_do_n();
else if(do_a... | [] | [
{
"body": "<p>You could try anything like this:</p>\n\n<pre><code>bool success = true;\n\nif(x == 1)\n{\n if(do_n)\n run_do_n();\n else if(do_a)\n run_do_a();\n else\n success = false;\n}\nelse//x == 2 || x == 0\n{\n if(do_up && x == 0)\n run_do_up();\n else if... | {
"AcceptedAnswerId": "43690",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T09:16:10.503",
"Id": "43683",
"Score": "6",
"Tags": [
"c++",
"game"
],
"Title": "Movement code from a game"
} | 43683 |
<p>Given a mongodb collection that stores trees as nodes with parent references this methods returns a deep nested tree where every child nodes are stored in a property childs[Seq]</p>
<pre><code> def getTree(rootId: BSONObjectID): Future[CategoryTreeNode] = {
def collect(parent: CategoryTreeNode): Future[Catego... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T11:50:59.010",
"Id": "75581",
"Score": "0",
"body": "What are your concerns about the code? Or do you simply want general comments about your implementation?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-... | [
{
"body": "<ul>\n<li><p><code>flatMap (x => x)</code> would probably better be written as <code>flatten</code>.</p></li>\n<li><p><code>map (x => x)</code> is essentially a no-op, and could be removed.</p></li>\n<li><p><code>map ( ... ) flatten</code> is equivalent to <code>flatMap (...)</code></p></li>\n<... | {
"AcceptedAnswerId": "43699",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T11:28:00.867",
"Id": "43692",
"Score": "1",
"Tags": [
"scala",
"tree",
"mongodb"
],
"Title": "Transform a MongoDb parent reference tree into a deep nested tree"
} | 43692 |
<p>In my latest project I am using fullscreen background images for each page. I decided to write some code to fetch the different thumbnail sizes and then use it as a background for the appropriate viewport size using media queries. I also made sure that in the case of big screens the smallest image loads first so tha... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T15:53:15.680",
"Id": "75630",
"Score": "0",
"body": "Your \"how do I do this\" questions will have to be answered on SO, Code Review is just for reviewing working code."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDa... | [
{
"body": "<p>I'm not familiar with Wordpress, so it's just a minor note about duplication. You could extract out some duplication to a method:</p>\n\n<pre><code>function get_attachment_image($attachment, $type) {\n $img_array = wp_get_attachment_image_src($attachment->ID, $type);\n return $img_array[0... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T11:37:06.543",
"Id": "43693",
"Score": "2",
"Tags": [
"php",
"css",
"wordpress"
],
"Title": "How do I refactor this responsive background images code?"
} | 43693 |
<p>I need to know whether I am doing the best way of binding click event through elements in jQuery. I need to avoid duplicate code in my function (since lot of duplicate code is repeated in all functions).</p>
<p>How can I clean this up and do it in a better way?</p>
<pre><code> $(".nna-icon-excel").click(function (... | [] | [
{
"body": "<p>You are right, the code could be tigher</p>\n\n<ul>\n<li><p>This</p>\n\n<pre><code>var action = \"\";\nif {\n action = \"expand\";\n}\nelse {\n action = \"expandheatmap\";\n}\n</code></pre>\n\n<p>could be reduced with a ternary operation to:</p>\n\n<pre><code>var action = (activeTab.toLower... | {
"AcceptedAnswerId": "43705",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T12:08:35.527",
"Id": "43695",
"Score": "4",
"Tags": [
"javascript",
"jquery",
"url"
],
"Title": "Binding click event through elements"
} | 43695 |
<p>The code below will split environment variables from a command line (always appear at the end of the command line). Environment variables are represented by '-E key=value'. I've achieved this like so, but I'm wondering if there's a more elegant way</p>
<pre><code>public class TestSplit {
public static void main(... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T12:27:01.040",
"Id": "75584",
"Score": "0",
"body": "Have you taken a conscious decision not to use the JVM's -D option, or were you unaware of it?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T12:2... | [
{
"body": "<ol>\n<li><p>Currently it prints something like this:</p>\n\n<blockquote>\n<pre><code> opInstallDir /home/paul \n opWD /home/paul/remake \n</code></pre>\n</blockquote>\n\n<p>Note that there is a space before the key. You might want to trim that.</p></li>\n<li><p>I guess the parameters comes from a us... | {
"AcceptedAnswerId": "43701",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T12:21:45.033",
"Id": "43697",
"Score": "6",
"Tags": [
"java",
"child-process"
],
"Title": "Splitting a command line into key/value pairs"
} | 43697 |
<p>I am trying to make a thread test in which 4 threads are all trying to set a <code>bool</code>. Only one should be allowed to set it. After the first thread has set the <code>bool</code> (<code>m_isRunning</code>) to <code>true</code>, no other threads should set it to <code>true</code> because of the check <code>is... | [] | [
{
"body": "<p>In this case, you really just need an atomic variable, and you can do a <code>compare_exchange_strong</code> to set the value once:</p>\n\n<pre><code>#include <thread>\n#include <iostream>\n\nstd::atomic_bool m_running;\nbool wrote[4];\n\nvoid func1(int num) {\n bool f{ false };\n ... | {
"AcceptedAnswerId": "43717",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T14:26:11.840",
"Id": "43708",
"Score": "6",
"Tags": [
"c++",
"optimization",
"beginner",
"multithreading",
"c++11"
],
"Title": "Thread test mutex implementation"
} | 43708 |
<p>I have recently written the program for the <a href="https://www.hackerrank.com/contests/sep13/challenges/sherlock-and-the-beast">Sherlock and The Beast' HackerRank challenge</a>. That's working fine, but the problem is that it takes too much time if a big number is given as a input. I would like you to help me out... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T15:04:00.790",
"Id": "75612",
"Score": "0",
"body": "Can't you just people answer it rather than editing? :P nevamind."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T15:15:19.093",
"Id": "75617",... | [
{
"body": "<p>Your approach seems all wrong, throw all that code away <- that's the code review.</p>\n\n<p>You have to think about combinations, this is not like finding prime numbers.</p>\n\n<p>n:1 -> Because you can only build numbers with <code>33333</code> and <code>555</code> you cannot find anything</p... | {
"AcceptedAnswerId": "43718",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T14:52:56.737",
"Id": "43709",
"Score": "7",
"Tags": [
"python",
"optimization",
"algorithm",
"python-3.x",
"programming-challenge"
],
"Title": "Sherlock and The Beast"
... | 43709 |
<p>Challenges offer good insights into combinations, permutations, prime number generation, look-up tables, matching, regular expressions, etc. A well reviewed programming-challenge can be very educational.</p>
<h2>Challenge Providers</h2>
<p>Programming challenges can be found on sites such as:</p>
<ul>
<li><a href="h... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2014-03-07T15:29:15.540",
"Id": "43713",
"Score": "0",
"Tags": null,
"Title": null
} | 43713 |
Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T15:29:15.540",
"Id": "43714",
"Score": "0",
"Tags": null,
"Title": null
} | 43714 |
<p>HTML form field names must be equal to SQL table field names.</p>
<p>Changing only table name and allowed fields can be used in many other update pages.</p>
<p>How can I improve this?</p>
<pre><code>$allowed = array("name","surname","email","rank");
$items = '';
foreach($_POST as $key => $value) {
if (in_... | [] | [
{
"body": "<p>As it stands right now, you are wide open to sql injection injection attacks because you are copying posted data directly into your sql update statement. All kinds of nasty things could be injected.</p>\n\n<p>I started to rewrite it but it became a pain since mysqli requires you to bind each para... | {
"AcceptedAnswerId": "43736",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T15:51:20.750",
"Id": "43716",
"Score": "3",
"Tags": [
"php",
"mysqli"
],
"Title": "UPDATE SQL with prepared stmt using only 1 variable"
} | 43716 |
<p>I'd like some additional assistance on refactoring. This is my latest update for this iteration.</p>
<pre><code>#region WMI Classes
/// <summary>
/// The Win32_OperatingSystem WMI class represents a Windows-based OS installed on a computer. Any OS that can be
/// installed on a computer that can run a Windo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T16:09:41.760",
"Id": "75632",
"Score": "1",
"body": "I feel like this needs generics and enums rather badly."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:56:29.053",
"Id": "75690",
"Scor... | [
{
"body": "<ol>\n<li><p>What is the point of empty <code>public</code> constructors? If there's no logic in them, remove them.</p></li>\n<li><p>The <code>PropertyGetter</code> class member in multiple classes is never assigned to after it is initialized. Mark them <code>readonly</code>. Same goes for <code>_win... | {
"AcceptedAnswerId": "43735",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T16:03:32.650",
"Id": "43719",
"Score": "6",
"Tags": [
"c#"
],
"Title": "Next Instance of DRY Refactoring"
} | 43719 |
<p>I have an Olympics database from each Olympic year and I want to find the person that has won the most medals. The main problem is that I'm basically querying the same sub-query twice in <code>SUBSET1</code> and <code>SUBSET2</code>. How would I go about making this more efficient?</p>
<pre><code>Select athlete F... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T16:41:45.593",
"Id": "75637",
"Score": "0",
"body": "Can you add which database you are actually using (vendor/version)... SQLServer, DB2, MySQL, Oracle, etc."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014... | [
{
"body": "<p>In PostgreSQL, you can use the <code>rank()</code> mechanism to help.</p>\n\n<p>It still requires a subselect, but consider the following query:</p>\n\n<pre><code>Select o.athlete,\n sum(o.total_medals) as sumtotal_medals\nfrom Olympics o,\n ( select r.athlete as toprank,\n ... | {
"AcceptedAnswerId": null,
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T16:29:58.230",
"Id": "43721",
"Score": "15",
"Tags": [
"optimization",
"sql",
"postgresql"
],
"Title": "Finding person with most medals in Olympics database"
} | 43721 |
<p>I have long been looking for an elegant, one-line solution to map <code>enum</code> to strings automatically, for use with the <code><<</code> and <code>>></code> stream operators.</p>
<p>I know that a lot of macros have been proposed to achieve that, but I never found a really simple scheme, with only ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T19:10:01.373",
"Id": "75666",
"Score": "0",
"body": "Shouldn't `Essai` just be a `struct` since its only member is `public`?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T02:07:51.753",
"Id": "7... | [
{
"body": "<p>I agree with the comments: macros are a mess. Avoid them when possible.</p>\n\n<p>If you're willing to make certain sacrifices (a little repetition), it's possible to avoid macros here. Doing so will also avoid some of the arbitrary limitations in your macro implementation, such as the 10 or so ca... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T16:53:57.417",
"Id": "43725",
"Score": "3",
"Tags": [
"c++",
"enum"
],
"Title": "Automatic C++ enum to string mapping macro"
} | 43725 |
<p><strong>The original question where the general concept of this implementation was discussed:</strong> <a href="https://codereview.stackexchange.com/questions/41989/using-ids-with-a-scope-like-hierarchy">Using ID's with a "scope" -like hierarchy</a></p>
<p>I have designed a resource manager as part of... | [] | [
{
"body": "<p>I can't answer all your questions, but here are some things you can improve or some guidelines you can follow:</p>\n\n<ul>\n<li><a href=\"https://stackoverflow.com/a/2502454/1364752\">Always pass <code>std::shared_ptr</code> by const reference</a>. There are several reasons for this, some of them ... | {
"AcceptedAnswerId": "43830",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T19:07:27.927",
"Id": "43733",
"Score": "6",
"Tags": [
"c++",
"game",
"c++11"
],
"Title": "Resource manager implementation, with resources being organized in a scope-like hierar... | 43733 |
<p>I keep seeing <code>/subsite/../global/css/file.css</code> when I look at my website's source code, and today I decided that I want to get rid of the unnecessary traversal in the path itself, so it becomes <code>/global/css/file.css</code>. I made myself a function which I now use for all paths. Here is the base of ... | [] | [
{
"body": "<ol>\n<li><pre><code>djpth('/parent/subsite/../../global/css/file.css')\n</code></pre>\n\n<p>returns</p>\n\n<pre><code>/parent/../file.css \n</code></pre>\n\n<p>I guess that is not what you want.</p></li>\n<li><p>If the file exists I'd use the built-in <a href=\"http://php.net/realpath\" rel=\"nof... | {
"AcceptedAnswerId": "43738",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T19:32:19.287",
"Id": "43734",
"Score": "4",
"Tags": [
"php"
],
"Title": "Resolving directory traversal"
} | 43734 |
<p>I've built a web site that uses AJAX to update a div. Most of the data displayed in the div is drawn from a MySQL database. All the pages are PHP. </p>
<p>I've tried to follow best practices. I put all the query strings into stored procedures in the database. The PHP files call the stored procedures with parameters... | [] | [
{
"body": "<p>First lets define MVC design and break apart your question:</p>\n\n<p>M: Model (datastructure or business logic)</p>\n\n<p>V: View (the display of your information)</p>\n\n<p>C: Controller (the one that connects the M to the V)</p>\n\n<ol>\n<li><p><strong>Have I made an example of MVC design?</str... | {
"AcceptedAnswerId": "44313",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T20:11:03.013",
"Id": "43737",
"Score": "3",
"Tags": [
"php",
"sql",
"ajax"
],
"Title": "Website for updating a div"
} | 43737 |
<p>I've decided to go with OOP style and prepared statements, and so far I like it a lot more than the procedural style. It's much more understandable in my opinion.</p>
<p>For this code review, I've just included my PHP code that interacts with my MySQL database. Everything is working how it should, but I'd like to ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T16:21:33.813",
"Id": "75774",
"Score": "0",
"body": "It looks like you are using prepared statements correctly. However, I'd suggest rewriting using PDO prepared statements with named parameters. All of those binding statements ca... | [
{
"body": "<p>With PDO, you could have:</p>\n\n<pre><code>$getStuff = $pdo->prepare('SELECT `question`, `answer` FROM `Quizzes` WHERE `questionNumber`< :questionNumber ORDER BY `questionNumber` ASC');\n\n$getStuff->execute(array('questionNumber' => 21));\n\n$rows = $getStuff->fetchAll();\n\nforea... | {
"AcceptedAnswerId": "44120",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T20:29:20.337",
"Id": "43740",
"Score": "17",
"Tags": [
"php",
"beginner",
"security",
"mysqli"
],
"Title": "Prepared statements from security viewpoint"
} | 43740 |
<p>I guess I'm a little late with my entry to <a href="https://codereview.meta.stackexchange.com/questions/1201/cr-weekend-challenge">this code challenge mentioned here</a>, but I decided the world must need yet another RPSLS implementation to critique.</p>
<pre><code>#include <vector>
#include <string>
#i... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:20:51.360",
"Id": "75683",
"Score": "0",
"body": "Safe to assume you're not using C++11?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:24:20.717",
"Id": "75684",
"Score": "0",
"bod... | [
{
"body": "<p>Not sure I like the use of <code>operator<</code> to test for a winner.</p>\n\n<pre><code>bool operator<(gesture const &other) const\n</code></pre>\n\n<p>Here</p>\n\n<pre><code> if (user < computer) \n ++scores[0]; \n else if (computer < user) \n ++scores... | {
"AcceptedAnswerId": "43775",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:08:25.447",
"Id": "43743",
"Score": "10",
"Tags": [
"c++",
"game",
"community-challenge",
"rock-paper-scissors"
],
"Title": "RPSLS yet again"
} | 43743 |
<p>My code works, but the aesthetic of the code seems to need some real work. The logic is simple enough: </p>
<ul>
<li>Create three lists of words that will be used throughout the conversion</li>
<li>Create three functions:
<ul>
<li>One for sub-1000 conversion</li>
<li>Another for 1000-and-up conversion</li>
<li>Ano... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-04-04T14:06:53.493",
"Id": "80773",
"Score": "0",
"body": "I recently tried the same task, but took a different approach. I wonder how you think it compares. Yours looks more sophisticated, ive not quite got to grips with the logic yet, b... | [
{
"body": "<p>A couple of thoughts:</p>\n\n<ul>\n<li>You only want to output <code>zero</code> in the special case when the number is 0. It would be easiest to handle that special case at the outermost level.</li>\n<li>Use <code>\" and \".join</code> and <code>\", \".join</code> to construct strings from parts.... | {
"AcceptedAnswerId": "43763",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:12:47.463",
"Id": "43744",
"Score": "9",
"Tags": [
"python",
"converting",
"numbers-to-words"
],
"Title": "Number-to-word converter"
} | 43744 |
<p>I've got the following Elixir code:</p>
<pre><code>defmodule Envvar do
def exists?(env) do :os.getenv(env) != false end
def get(env) do
if exists?(env) do
{env, :os.getenv(env)}
else
{env, nil}
end
end
end
</code></pre>
<p>Two things:</p>
<ol>
<li>Am... | [] | [
{
"body": "<p>Using the ? for a boolean predicate is fine. At least it is what I would do in\nRuby and Elixir.</p>\n\n<p>You won't be able to call exists?(env) in a guard clause so pattern matching does not win you much here.</p>\n\n<p>You are calling :os.getenv() twice unneccessarily. \nI'm not sure why you ju... | {
"AcceptedAnswerId": "43753",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:20:42.523",
"Id": "43747",
"Score": "5",
"Tags": [
"functional-programming",
"error-handling",
"elixir"
],
"Title": "Fetching environment variables — can I use pattern match... | 43747 |
<p>Here's an attempt I've made of implementing the <a href="http://en.wikipedia.org/wiki/Barnes-Hut_simulation" rel="nofollow">Barnes-Hut</a> <a href="http://en.wikipedia.org/wiki/N-body_simulation" rel="nofollow">n-body</a> algorithm, or its initial stage - The quadtree. That there're lots of lengthy doc strings might... | [] | [
{
"body": "<p>You may well have a good reason for using Python 2.x. If you don't, I'd suggest that using the latest version is more Pythonic. In particular, as you describe yourself as a beginner, it may be easier to use the latest version now rather than having to unlearn certain quirks of 2.x at some point in... | {
"AcceptedAnswerId": "44222",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:25:14.733",
"Id": "43749",
"Score": "8",
"Tags": [
"python",
"tree",
"python-2.x"
],
"Title": "Barnes-Hut n-body quadtree"
} | 43749 |
<p>Previous version:</p>
<p><a href="https://codereview.stackexchange.com/questions/43655/updating-grid-on-webpage">Updating Grid on Webpage</a></p>
<p><strong>Task:</strong></p>
<blockquote>
<p>Draw a grid with a given number of rows and columns. Each cell can be
any color. The same grid should also be updated ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T23:11:43.087",
"Id": "75698",
"Score": "0",
"body": "Indent that CSS code properly! The JavaScript code looks so much better now, I will definitely get back to this."
}
] | [
{
"body": "<p>Overall it looks pretty clean,</p>\n\n<ol>\n<li>I'd like to see some comments on the functions so I know what they do without having to read the code, you could use <a href=\"http://usejsdoc.org\">JSDoc</a> for this.</li>\n<li>I'd recommend explicitly using <a href=\"http://en.wikipedia.org/wiki/D... | {
"AcceptedAnswerId": "46335",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:36:31.923",
"Id": "43751",
"Score": "11",
"Tags": [
"javascript",
"object-oriented",
"html",
"dom"
],
"Title": "Updating Grid on Webpage (new version)"
} | 43751 |
<p>I'd like some advice about any better or cleaner way to implement this class, if there's any. </p>
<p>I made it using <a href="https://stackoverflow.com/questions/5204578/is-it-possible-to-implement-events-in-c/5204594#5204594">this answer</a>, posted on Stack Overflow, as reference. A lot of problems arose when I ... | [] | [
{
"body": "<p>Before looking at the code, and just having a quick read-through, the first thing that sticks out to me are the comments:</p>\n\n<pre><code>private: // Private variables\n\nDelegate (const Func& func) : functionPtr(new Func(func))\n{\n /* NOP */\n}\n\n#include <memory> // std::aut... | {
"AcceptedAnswerId": "43766",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:36:41.927",
"Id": "43752",
"Score": "6",
"Tags": [
"c++",
"optimization",
"c++11",
"event-handling"
],
"Title": "Generic event class - am I over-complicating it?"
} | 43752 |
<p>From Coderbyte:</p>
<blockquote>
<p>Have the function StringReduction(str) take the str parameter being
passed and return the smallest number you can get through the
following reduction method. The method is: Only the letters a, b, and
c will be given in str and you must take two different adjacent
charac... | [] | [
{
"body": "<p>A few minor notes:</p>\n\n<ol>\n<li><blockquote>\n <blockquote>\n <p>Have the function StringReduction(str)</p>\n </blockquote>\n</blockquote>\n\n<p>strictly speaking, the parameter name is different:</p>\n\n<blockquote>\n<pre><code>function StringReduction(s) \n</code></pre>\n</blockquote>\n... | {
"AcceptedAnswerId": "43776",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T21:43:55.853",
"Id": "43754",
"Score": "6",
"Tags": [
"javascript",
"strings"
],
"Title": "Coderbyte: String Reduction"
} | 43754 |
<p>I have a function that returns the index of the first alphabet letter found in a string, or -1 if no letter is found. It seems like there should be a way to do this with extension methods instead of looping, but I can't think of one:</p>
<pre><code>int findFirstLetter(string str)
{
for(int ctr=0;ctr<str.Length... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T23:56:12.707",
"Id": "75699",
"Score": "3",
"body": "return str.ToList().FindIndex(c => Char.IsLetter(c));"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T23:57:57.503",
"Id": "75700",
"Score"... | [
{
"body": "<p>I have no issue with the loop. It is about as fast as it can be. I would recommend renaming the method to match the other IndexOf methods.... something like <code>IndexOfAlphaChar</code>.</p>\n\n<p>There is no reason to worry about this code. Move on to bigger problems.</p>\n",
"comments": [
... | {
"AcceptedAnswerId": "43757",
"CommentCount": "11",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-07T23:46:09.717",
"Id": "43756",
"Score": "9",
"Tags": [
"c#"
],
"Title": "Is there an easier way to find the index of the first letter in a string?"
} | 43756 |
<p>I am SURE this is somehow easy but reading the docs isn't bringing it to light.</p>
<p><strong>The problem:</strong> I am trying to setup a JMS message listener and what I need is for the first client to have exclusive message processing rights.</p>
<p>That is: Until a single client acknowledges the message the se... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-09T00:09:54.130",
"Id": "75854",
"Score": "1",
"body": "Sorry for pointing back to Stack Overflow, but I guess asking there about how `Session.CLIENT_ACKNOWLEDGE` and `@Transactional` work together will get you (better) answers."
},
... | [
{
"body": "<p>The code looks fine although I'm not familiar with JMS, so I can't say anything about it's correctness. Just three minor notes:</p>\n\n<ol>\n<li><p><code>userMessage</code> could be declared inside the <code>try</code> block:</p>\n\n<pre><code>try {\n byte[] in = new byte[(int) jmsMessage.getBo... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T00:29:19.843",
"Id": "43758",
"Score": "5",
"Tags": [
"java",
"spring",
"jms"
],
"Title": "JMS configuration -- client exclusive messages"
} | 43758 |
<p>I wrote this bit of python intending it to become some module to replace excel mapping programs like <a href="http://www.altova.com/mapforce.html">MapForce</a>. Right now it only does columns to columns. So the number of rows in always equals the number of rows out.</p>
<p>To declare a map, use a python <code>defa... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-08-06T15:06:15.583",
"Id": "106703",
"Score": "0",
"body": "I have a solution for it using a custom dictionary shown [on code review](https://codereview.stackexchange.com/questions/51247/python-dictionary-black-magic) and [on github](http... | [
{
"body": "<p>Generally camelCase is used for both locals and functions.\nBoth PEP 8 and Google style guide recommend underscore lower_caps for both.\ncamelCase isn't <em>wrong</em> in python, it's just sticking with global standards in more right.</p>\n\n<p>Also some names could be more descriptive.\n<code>rBo... | {
"AcceptedAnswerId": "59522",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T00:53:41.170",
"Id": "43759",
"Score": "8",
"Tags": [
"python",
"excel"
],
"Title": "Excel Mapping Module"
} | 43759 |
<p>I'm working on a <a href="https://github.com/SublimeText/CTags" rel="nofollow">CTags plugin for Sublime Text</a>. One of the <a href="https://github.com/SublimeText/CTags/issues/145" rel="nofollow">open issues</a> revolves around the fact that an in-memory sort of a tag file can cause some form of memory or buffer o... | [] | [
{
"body": "<ul>\n<li>It is not necessary to decode and encode UTF-8, as <code>split('\\t')</code> and <code>lstrip('.\\\\')</code> work fine on UTF-8-encoded strings. </li>\n<li>The programs keeps an unlimited number of temporary files open simultaneously and will fail after exceeding the platform's maximum for... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T01:18:43.400",
"Id": "43760",
"Score": "5",
"Tags": [
"python",
"algorithm",
"sorting"
],
"Title": "External \"bucket\" sort"
} | 43760 |
<p>I am designing a new application to track sports statistics with code-first migration. I have the bare minimum POCO setup. The problem is that I am not happy with the design specifically how the players, teams and tournaments are relating to each other. </p>
<p>I appreciate any comments and suggestions.</p>
<p><st... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-07-12T16:36:43.447",
"Id": "101291",
"Score": "1",
"body": "It's been a while since I've used EF but I don't recall having to create my own model for a N-N relationship. I'll take a look into it tonight after my Civ 5 game but I believe y... | [
{
"body": "<p>Don't use underscores in identifiers. <s>If that's how the database has them, use a <code>ColumnAttribute</code> to specify the column name</s> <em>scratch that, you're going code-first</em>. This:</p>\n\n<pre><code>public int Tournament_Id { get; set; }\n\npublic int Match_Id { get; set; }\npubli... | {
"AcceptedAnswerId": "56846",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T02:03:58.670",
"Id": "43762",
"Score": "12",
"Tags": [
"c#",
"asp.net",
"entity-framework",
"asp.net-mvc-4",
"poco"
],
"Title": "Tracking sports statistics"
} | 43762 |
<p>In my Java code I have these three classes. Basically I have a User class, and also a GUI class that holds <code>TextView</code>s and other things (GUI related) for the properties that show on the screen.</p>
<p>The <code>SearchUser</code> is just a object that has the GUI properties. One of these per user object.
... | [] | [
{
"body": "<p>Designing is art we learn from experience. Object oriented paradigm is \"natural\" way to explain things.</p>\n\n<p>SearchUser extending BaseUser is wrong naturally, isn't it ? (because SearchUser is not special type of user so can't be subclass) You can have has-a-relation ship there (i.e. Search... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T04:21:12.507",
"Id": "43767",
"Score": "7",
"Tags": [
"java",
"classes",
"android"
],
"Title": "User search implementation"
} | 43767 |
<p>I've written some code to brute-force enumerate the solution space of <a href="http://en.wikipedia.org/wiki/Nonograms" rel="noreferrer">nonogram puzzles</a> up to a certain size. It does a good job up to the first ~4 billion puzzles, but I run out of disk space to store any bigger collection of the solution space se... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T15:03:55.470",
"Id": "75768",
"Score": "0",
"body": "Are you deliberately trying to generate and store every solution, or just solve the puzzle?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-09T03:27:1... | [
{
"body": "<ol>\n<li><p>There are no docstrings. What do these functions do? Lack of docstrings make the code hard to review, because we don't know what the functions are supposed to do.</p></li>\n<li><p>The call <code>indices(n)</code> generates the Cartesian product of <code>range(n)</code> × <code>range(n)</... | {
"AcceptedAnswerId": "91819",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T05:04:33.427",
"Id": "43770",
"Score": "14",
"Tags": [
"python",
"combinatorics",
"complexity"
],
"Title": "Nonogram puzzle solution space"
} | 43770 |
<p>This should be the last iteration for this code.</p>
<ol>
<li><p>Does this approach make sense or am I heading down the wrong path?</p></li>
<li><p>The only thing I can see to make this better is to genericize the <code>GetType</code> methods at the end so that I could eliminate the goofy <code>if</code> statement ... | [] | [
{
"body": "<p>First:</p>\n\n<pre><code> if (pair.Key.ToLower() == \"datetime\")\n { return GetDateTimeFromDmtf(pair.Value); }\n if (pair.Key.ToLower() == \"string\")\n { return GetString(pair.Value); }\n if (pair.Key.ToLower() == \"ulong\")\n { return GetUnsignedInt64(p... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T08:24:03.607",
"Id": "43777",
"Score": "4",
"Tags": [
"c#",
"generics",
"hash-map",
"enum"
],
"Title": "Genericizing PropertyValues"
} | 43777 |
<p>Is this class perfect for databases? All I want to know is what I should change to make it perfect.</p>
<pre><code>error_reporting(E_ALL);
class RESPETO{
private $_server = 'mysql';
private $_host = '';
private $_database = '';
private $db_username = '';
private $db_password = '';
private $... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T14:20:14.433",
"Id": "75761",
"Score": "0",
"body": "As the local said \"If I was going there I wouldn't start from here\". \"Swiss Army\" functions are pointless."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": ... | [
{
"body": "<p>Due to the fact that a lot of the comments should have been answers - I will attempt to say what they are probably thinking.</p>\n\n<p>A jack-of-all-trade function is poor programming. It defeats the <strong>SOLID</strong> principles and doesn't enable you flexibility.</p>\n\n<p>I will give you a ... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T09:12:30.637",
"Id": "43780",
"Score": "3",
"Tags": [
"php",
"classes",
"pdo"
],
"Title": "Is this a complete PDO prepared class?"
} | 43780 |
<p>The linked code below is meant to be used in a user space file-system (fuse). Given that multiple processes may have multiple files opened on the file-system, the files on the specific user space file-system will map each of these open files to an (encrypted) file on a regular file-system, attempting to keep all map... | [] | [
{
"body": "<p>From a once-over:</p>\n\n<p><strong>Naming</strong></p>\n\n<ul>\n<li><p>You seem to use all kinds of conventions, all lowercase, sometimes you use an underscore, sometimes you use lowerCamelCase. Perhaps you should stick to the underscore_style.</p></li>\n<li><p>The name <code>mOpperQue</code> is ... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T09:48:44.683",
"Id": "43782",
"Score": "10",
"Tags": [
"c++",
"c++11",
"cache",
"file-system",
"container"
],
"Title": "Allowing user space file-system to (kind-of) keep m... | 43782 |
<p>How to shorten up this code? I know there's a way that this kind of code could be shortened, but I don't know how by myself yet. Who can help me?</p>
<pre><code> //CHOOSE LEVEL: FROZEN
case 1213:
sendOption5("Level 1 " + (c.achievedFloor <= 1 ? "@gre@(Achieved)" : "@red@(Not achieved)") + "",
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T11:36:56.173",
"Id": "75744",
"Score": "4",
"body": "Welcome to Code Review! Can you explain a bit about the context of the code? What is it used for? What is it doing? Providing some context will likely give you better reviews."
... | [
{
"body": "<p>There's a good talk about it by a Google's employee (<a href=\"https://www.youtube.com/watch?v=4F72VULWFvc\" rel=\"nofollow\">https://www.youtube.com/watch?v=4F72VULWFvc</a>).\nIn fact these kind of conditions can be avoided using inheritance.\nYou could create 3 different implementations of an ab... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T10:18:55.410",
"Id": "43783",
"Score": "4",
"Tags": [
"java"
],
"Title": "How to shorten this code or make it more efficient?"
} | 43783 |
<p>I am having this problem with my code. I have variables <code>firstnumber</code> and <code>secondnumber</code>, as well as <code>operand</code> and <code>result</code>. Then I am using the <code>string.Split</code> to know whether it's an operator or a number.</p>
<p>After that I have used a <code>while</code> loo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T12:53:13.577",
"Id": "75747",
"Score": "0",
"body": "Welcome to Code Review! I have written an answer that should help you clean up your code. Unfortunately, you shouldn't expect any answers to extend the functionality of your code.... | [
{
"body": "<h1>Using <code>goto</code> is not a good practice!!</h1>\n<p>Instead of using <code>goto</code>, use a do-while or a <code>while</code> loop. You want to do something as long as the answer to "Do you want to continue" is "Yes". This is perfect for a do-while loop.</p>\n<p>You sho... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T11:58:17.450",
"Id": "43789",
"Score": "4",
"Tags": [
"c#",
"console",
"calculator"
],
"Title": "Calculator for more than two numbers"
} | 43789 |
<p>I have a C# function like below, and in the <code>else</code> block, the function must return something. I don't know whether returning null is a good practice or not.</p>
<pre><code>public Nullable<Point> GetSprite(int x, int y)
{
if (x <= xCount && y <= yCount)
{
return new Poi... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T17:59:31.600",
"Id": "75789",
"Score": "6",
"body": "How is the `GetSprite` method **used**? And what is it **used for?**"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T18:37:24.513",
"Id": "7579... | [
{
"body": "<p>Yes, you could just write:</p>\n\n<pre><code>public Point GetSprite(int x, int y)\n{\n if (x <= xCount && y <= xCount)\n {\n return new Point(x * spriteHeight, y * spriteWidth);\n }\n\n return null;\n}\n</code></pre>\n\n<p>And write in the documentation it could re... | {
"AcceptedAnswerId": "43799",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-03-08T17:25:06.027",
"Id": "43798",
"Score": "12",
"Tags": [
"c#",
"null"
],
"Title": "Returning null or what?"
} | 43798 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.