body stringlengths 25 86.7k | comments list | answers list | meta_data dict | question_id stringlengths 1 6 |
|---|---|---|---|---|
<p>I have a page with a list of items. Items have several actions assigned to them. (see screenshot).</p>
<p>One may choose to directly click on an icon next to each row or check a checkbox on the left hand side and click action above the list.</p>
<p>The issue is that after clicking an item OR checking a checkbox of... | [] | [
{
"body": "<p>So pretty much everything will make a insignificant effect apart from the section where you are looping through each of the checkboxes. See my modifications and notes below.</p>\n\n<pre><code>$(\"a.action:not(.remove)\").click(function (e) { // .remove => do not execute on download tasks page\n... | {
"AcceptedAnswerId": "23525",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T08:01:45.350",
"Id": "23524",
"Score": "3",
"Tags": [
"javascript",
"jquery"
],
"Title": "How can I improve performance of my selecting code"
} | 23524 |
<p>Exercise:</p>
<blockquote>
<p>Define three new classes, called <strong>Song</strong>, <strong>Playlist</strong>, and
<strong>MusicCollection</strong>. A Song object will contain information about a particular song, such as its title, artist, album, and playing time.
A Playlist object will contain the name... | [] | [
{
"body": "<p>As I already wrote on <a href=\"https://codereview.stackexchange.com/questions/21688/creating-shapes-program-with-multiple-classes-different-files-in-objective-c\">another of your questions</a>:</p>\n\n<pre><code>-(void) setSong:(NSString *)theSongName andArtist:(NSString *)theArtist andAlbum:(NSS... | {
"AcceptedAnswerId": "23530",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T09:43:33.737",
"Id": "23527",
"Score": "2",
"Tags": [
"objective-c"
],
"Title": "Creating a Playlist program"
} | 23527 |
<p>My context is a very simple filter-like program that streams lines from an input file into an output file, filtering out lines the user (well, me) doesn't want. The filter is rather easy, simply requiring a particular value for some 'column' in the input file. Options are easily expressed with <code>argparse</code>:... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T13:59:23.147",
"Id": "36310",
"Score": "0",
"body": "`int()` skips leading and trailing whitespace and leading zeros. So, a string comparison is not quite the same. Which do you need?"
},
{
"ContentLicense": "CC BY-SA 3.0",
... | [
{
"body": "<h3>1. Possible bugs</h3>\n\n<p>I can't be certain that these are bugs, but they look dodgy to me:</p>\n\n<ol>\n<li><p>You can't filter on the number 0, because if <code>args.c1</code> is 0, then it will test false and so you'll never compare it to <code>c1</code>. Is this a problem? If it is, you ou... | {
"AcceptedAnswerId": "23560",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T12:24:18.877",
"Id": "23531",
"Score": "3",
"Tags": [
"python",
"type-safety"
],
"Title": "Pythonic type coercion from input"
} | 23531 |
<p>I'm learning C and today I wrote a program that displays info about my hardware on ubuntu. </p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch, file_name[25] = "/proc/scsi/scsi";
FILE *fp;
fp = fopen(file_name,"r"); // read mode
if( fp == NULL )
{
perror("E... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-01-14T04:59:56.987",
"Id": "65624",
"Score": "1",
"body": "It may be better to ask a new question when you have an updated version of the code, instead of editing it into an existing question. That way it will get a more attention and a ... | [
{
"body": "<p>It can run on BSD since you wrote a cross-platform code and /proc/scsi/scsi is present on BSD as well.\nYes, you can list the installed hardware using ioctl calls, see <a href=\"https://stackoverflow.com/questions/2698465/how-to-find-out-if-scsi-device-say-etc-sda-is-a-disk-or-not-via-ioctl-calls-... | {
"AcceptedAnswerId": "23535",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T13:46:10.137",
"Id": "23534",
"Score": "-1",
"Tags": [
"c",
"linux"
],
"Title": "Possible improvements for this small C program?"
} | 23534 |
<p>I'm writing a small Win32 console app that manipulates the contents of binary files. It accepts the filename as a command line parameter and writes to a file named filename.scramble</p>
<p>This is the first time I'm dynamically allocating memory for C strings (which I'm using since the <code>fstream</code> function... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T02:52:05.823",
"Id": "36449",
"Score": "0",
"body": "I'd suggest creating the output file name using something like `std::string name(argv[1] + std::string(\".scramble\"));`"
}
] | [
{
"body": "<p>There is no need for manual dynamic memory allocation.</p>\n\n<p>Don't use this:</p>\n\n<pre><code>using namespace std;\n</code></pre>\n\n<p>It causes lots of problems in anything but a small application. So get into the habbit of not using it. If you muse be lazy specifically import the things yo... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T14:09:52.563",
"Id": "23536",
"Score": "3",
"Tags": [
"c++",
"strings",
"memory-management",
"console"
],
"Title": "Dynamically allocated C strings in C++, concatenation, poin... | 23536 |
<p>How can I optimize this?</p>
<pre><code><cfftp connection = "myConnection"
username = "#username#"
password = "#password#"
server = "#server#"
action = "open"
timeout = "500"
stopOnError = "Yes">
<cfloop index="i" from="1" to="#ArrayLen(ImagesArray)#">
<... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T15:02:25.410",
"Id": "36315",
"Score": "1",
"body": "Could you give us more details on what you're trying to optimize? How many images are being FTP'd? What operating system are you using?"
},
{
"ContentLicense": "CC BY-SA 3... | [
{
"body": "<p>In my experience, FTP can use up a lot of network packets and CPU time just negotiating the starting and finishing of a single file. If there exists the option of having an archive uncompressed at the destination, I would suggest zipping the images into a single file for transport.</p>\n\n<p>To g... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T14:53:19.740",
"Id": "23539",
"Score": "2",
"Tags": [
"performance",
"coldfusion",
"cfml"
],
"Title": "Image transfer script"
} | 23539 |
<p>Most of my slow queries on my server are due to a single "find" query. I have a collection that represents website pages. I want to be able to look up a page in the collection by URL. The caveat is that a website might have URLs that redirect to it.</p>
<p>I've modeled my schema (with Node.js/Mongoose) like this:</... | [] | [
{
"body": "<p>I haven't used MongoDB, but I have a few suggestions based on experiences with optimization and other databases.</p>\n\n<ol>\n<li><p>Index hashes of the URLs and search for those instead. Using a simple MD5 hash would probably speed up searching with the cost of dealing with false positives (unlik... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T15:49:42.807",
"Id": "23542",
"Score": "3",
"Tags": [
"javascript",
"node.js",
"mongodb"
],
"Title": "Query for finding collection entries matching an arbitrary set of URLs"
} | 23542 |
<p>Would you be kind to make me a code review? It would be nice to have some comments, whether you would have done something differently and so on. I am not sure about the way I handle the exception. Is there a better way?</p>
<pre><code>@Transactional
public classServiceImpl implements Service {
private static... | [] | [
{
"body": "<p>Few points:</p>\n\n<ul>\n<li>Try to avoid long or nested if/else </li>\n<li>Sub-divide tasks in smaller functions(clean and more readable code + easier unit testing)</li>\n<li>Minimize variable scope(try to declare variables in the scope where you really need them)</li>\n<li>Think about Exception ... | {
"AcceptedAnswerId": "23658",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T17:47:37.383",
"Id": "23546",
"Score": "2",
"Tags": [
"java"
],
"Title": "Review of document registrar"
} | 23546 |
<p>The following code works, but I'd like to re-write, so that a single index is returned, rather than a sequence of indexes visited.</p>
<p>Here are the defs and function.</p>
<pre><code>(def usage-vec-len 13)
(def read-levels [9999 3000 2000 1000 100 90 80 70 60 50 40 30 10])
(defn sel-adj-idx
"Finds the correct po... | [] | [
{
"body": "<ul>\n<li><p>Why not use just what you posted? Like this:</p>\n\n<pre><code>;use better names\n(defn sel-adj-idx-fixed [reading] (first (reverse (sel-adj-idx reading))))\n</code></pre></li>\n<li><p><code>for</code> is used to generate sequences. Try <a href=\"http://clojuredocs.org/clojure_core/cloju... | {
"AcceptedAnswerId": "23562",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T17:51:14.777",
"Id": "23547",
"Score": "4",
"Tags": [
"clojure"
],
"Title": "Is there a better way to extract a single value instead of a sequence?"
} | 23547 |
<p>This code takes 8 divs and races them across the screen depending on which time value the div was assigned. How can I have coded this better so my code doesn't look so amateurish?</p>
<p>I know I should have used something other than a hard coded 8 in my <code>for</code>-loop, but <code>timeArray.length</code> is u... | [] | [
{
"body": "<p><em>Note: As I type \"pony\" and \"ponies\" in my code, I can't help but wonder what the hell I'm doing with my time. Never thought I'd be writing words like that in javascript...</em></p>\n\n<p>Anyway! My first suggestion would be to make everything more flexible bynot relying on element IDs, and... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T18:39:50.307",
"Id": "23548",
"Score": "4",
"Tags": [
"javascript",
"jquery"
],
"Title": "Reading 8 divs across the screen depending on assignment time"
} | 23548 |
<p>I have recently just started learning Perl, so I decided to program the classic 'Guess my Number' game. I was wondering if anyone can spot any areas for improvement. As it's my first program, I expect there to be some unoptimized areas.</p>
<pre><code>#!\usr\bin\perl
print"Welcome to guess my number!\n";
$co... | [] | [
{
"body": "<p>You could ask the user for a range between the random number should be choosen.\nAlso, you check is the user is right after he has tried 6 times, but what if he has right in less than 6 tries ? You better should write something like</p>\n\n<pre><code>boolean won = false\nint tries = 0\n\nwhile (tr... | {
"AcceptedAnswerId": "23556",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-06T20:41:02.857",
"Id": "23550",
"Score": "5",
"Tags": [
"game",
"perl",
"number-guessing-game"
],
"Title": "\"Guess my Number\" game"
} | 23550 |
<p>These functions are selected by the same index. I understand the index logic of what to do but I don't know how to do it well enough.</p>
<pre><code>// those are buttons that will trigger different functions according by an index
button_up = jQuery('#videos_tabs-up-0' );
button_down = jQuery('#videos_tabs-down-0' ... | [] | [
{
"body": "<p>You can compact this code a lot by generalising the click listener.</p>\n\n<p>In the html assign a class to each video_tab, but keep the ids as they are. For instance I assigned each video tab a video_button class.</p>\n\n<pre><code><div id=\"videos_tabs-up-0\" class=\"video_button\">\n But... | {
"AcceptedAnswerId": "23561",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T05:24:35.367",
"Id": "23558",
"Score": "1",
"Tags": [
"javascript",
"jquery"
],
"Title": "Multiple and similar numbered functions"
} | 23558 |
<p>I want to know whether this thing I wrote in C# is a correct implementation of the state monad.</p>
<p>I've used it in code and it does what I expect it to do, but I'm still not quite sure if I'm doing this right, or if I just pulled something out of my ear and called it a state monad.</p>
<p>I would have made an ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T18:28:15.943",
"Id": "36354",
"Score": "0",
"body": "Could you add an example of how would you use it?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-28T06:49:26.557",
"Id": "37735",
"Score": "1... | [
{
"body": "<p>Mutable <code>struct</code>s in C#/.NET are evil for many reasons you can Google. Rewrite as such:</p>\n\n<pre><code>// State a\ninternal class State<TResult>\n{\n // State a t\n public struct StateData<TState>\n {\n private readonly TResult result;\n\n private r... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T05:38:53.807",
"Id": "23559",
"Score": "5",
"Tags": [
"c#",
"haskell",
"monads"
],
"Title": "C# state monad implementation"
} | 23559 |
<p>I'm using the boost::units library (<a href="http://www.boost.org/doc/libs/1_53_0/doc/html/boost_units.html" rel="nofollow" title="boost::units">boost::units</a>) and trying to make use of auto and decltype to deal with all the complicated types it produces.</p>
<p>I have a templated function to integrate a mathema... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T12:51:36.173",
"Id": "36342",
"Score": "0",
"body": "You could re-use `minWavelength` instead of introducing `fakeLength`. Since there could be multiple `pmt_radiant_sensitivity` and `plancklaw` with different return types, I'm not ... | [
{
"body": "<p>I'm not sure why you need the typedef in the first place. Is there anything wrong with <code>auto spectral_differential_current = ...</code>?</p>\n\n<p>On a similar note, why do you want to require that <code>f</code> is an <code>std::function</code>, disallowing reasonable calls like <code>integr... | {
"AcceptedAnswerId": "23612",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T12:39:20.747",
"Id": "23563",
"Score": "2",
"Tags": [
"c++",
"c++11",
"functional-programming"
],
"Title": "Determining function return types for std::function"
} | 23563 |
<p>Racket is a general purpose, multi-paradigm programming language in the Lisp/Scheme family. One of its design goals is to serve as a platform for language creation, design, and implementation. The language is used in a variety of contexts such as scripting, general-purpose programming, computer science education, an... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T14:26:25.130",
"Id": "23566",
"Score": "0",
"Tags": null,
"Title": null
} | 23566 |
Racket is an extensible general programming language in the Lisp family. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T14:26:25.130",
"Id": "23567",
"Score": "0",
"Tags": null,
"Title": null
} | 23567 |
<p>I am trying to track relationships among people. I came up with my own solution, but I'm wondering if there might be another way or better way of doing this. To keep it simplified, I'll post just the bare bones.</p>
<p>Let's say I have created the tables: <code>person</code>, <code>person_relation</code>, and <code... | [] | [
{
"body": "<p>It seems fine for me for generic cases. Later you might need some denormalization or caching if it's too slow but it really depends on the usage. (If you have any special requirement you should share it, edit the question, please.)</p>\n\n<p>Four things to consider:</p>\n\n<ol>\n<li><p><code>varch... | {
"AcceptedAnswerId": "23569",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T15:42:51.590",
"Id": "23568",
"Score": "2",
"Tags": [
"sql",
"mysql"
],
"Title": "Keeping track of people's relationships using a people relation table"
} | 23568 |
<p>I need to run over a log file with plenty of entries (25+GB) in Python to extract some log times. </p>
<p>The snippet below works. On my test file, I'm ending up with roughly <code>9:30min</code> (Python) and <code>4:30min</code> (PyPy) on 28 million records (small log).</p>
<pre><code>import datetime
import time... | [] | [
{
"body": "<pre><code>import datetime\nimport time\nimport json\nimport re\n\nformat_path= re.compile( \n r\"^\\S+\\s-\\s\" \n r\"(?P<user>\\S*)\\s\"\n r\"\\[(?P<time>.*?)\\]\" \n)\n</code></pre>\n\n<p>Python convention is ALL_CAPS for global constants. But as far as I can tell, you don't a... | {
"AcceptedAnswerId": "23589",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T16:33:24.563",
"Id": "23570",
"Score": "5",
"Tags": [
"python",
"performance",
"logging"
],
"Title": "Running over a log file to extract log times"
} | 23570 |
<pre><code>class ControllerFactory {
public function createController($controller)
{
if (file_exists($path = __DIR__ . 'app/controllers/' . $controller . '.php')) {
require_once $path;
return true;
}
}
}
</code></pre>
<p>It seems a bit overkill to have a class to do ... | [] | [
{
"body": "<p>I indeed suggest to make it static, so you can call <code>ControllerFactory::createController</code>. I think factories are the only things that are allowed to use static methods.</p>\n\n<p>But I think this is not something you do in a factory. It looks like it is some autoloading function. Factor... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T17:07:35.233",
"Id": "23573",
"Score": "1",
"Tags": [
"php"
],
"Title": "Small factory class"
} | 23573 |
<p>I'm running into page performace issues and I believe this block is causing the biggest slowdown:</p>
<pre><code> // Section menu on mouseover, hide menu on mouseout
// Can be more concise using .toggleClass?
$('section').live('mouseenter', function() {
if ($(window).width() > 1278) {
$(this).find... | [] | [
{
"body": "<p>Just a simple case of css hierarchy and not covering my bases with undoing twitter bootstrap's <code>.hidden</code> class. This does the trick:</p>\n\n<pre><code>@media(min-width: 1279px) {\n section:hover {\n menu.hidden {\n display: block;\n visibility: visible;\n }\n .sectio... | {
"AcceptedAnswerId": "23579",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T17:17:16.940",
"Id": "23575",
"Score": "2",
"Tags": [
"javascript",
"jquery",
"css"
],
"Title": "Convert JavaScript to CSS media query"
} | 23575 |
<p>I've managed to position the link boxes as I wanted and to apply a background to them, but I'm not sure I've done it in the most elegant or efficient way. </p>
<p>Is there a better way to position the elements without mixing positioning and floats? And is there a way to remove the background between the link boxes... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T16:39:22.993",
"Id": "36423",
"Score": "0",
"body": "Your background images in your fiddle don't load because you have to update the links to a public URL."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03... | [
{
"body": "<p>I edited your fiddle <a href=\"http://jsfiddle.net/SSANp/3/\" rel=\"nofollow\">jsFIddle</a>. Basically what I have done is removed <code>position:relative</code> and added <code>float:left</code> and then added some margin to the elements. Then with the last-child selector I removed margin from th... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T17:54:18.083",
"Id": "23577",
"Score": "3",
"Tags": [
"html",
"css"
],
"Title": "Positioning link boxes & managing backgrounds"
} | 23577 |
<p>Given a sorted array, remove the duplicates in place such that each element appear at most twice and return the new length.</p>
<p>Do not allocate extra space for another array, you must do this in place with constant memory.</p>
<p>For example,
Given sorted array A = [1,1,1,2,2,3],</p>
<p>Your function should re... | [] | [
{
"body": "<h3>Opps one bug:</h3>\n<pre><code> if(A[pos]==A[pos-1])\n</code></pre>\n<p>If <code>pos == 0</code> (if there is only one first element) it will fail (undefined behavior).</p>\n<h3>Two Recommendation:</h3>\n<p>This:</p>\n<pre><code> int i=0;\n while(i<n)\n {\n // Stuff\n i = pos+1;\n }\n<... | {
"AcceptedAnswerId": "23594",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T19:46:16.943",
"Id": "23582",
"Score": "3",
"Tags": [
"c",
"algorithm",
"interview-questions"
],
"Title": "remove duplicates in a sorted array if duplicates are allowed at most... | 23582 |
<p>Does the following code look okay? Want to see if anyone can spot any mistakes I may have made. This will be pulling from a pre-formatted Excel document - I have already specified all needed Cell locations.</p>
<p>Things I want clarified:</p>
<ul>
<li><p>How many times can you invoke SetInfo and did I use it more ... | [] | [
{
"body": "<h1>Naming: <em>Hungarian Notation</em> is the DEVIL.</h1>\n<h3>It makes the reader want to see your code burn in eternal flames.</h3>\n<blockquote>\n<p><img src=\"https://simpsonswiki.com/w/images/7/7c/Devil_Flanders.png\" alt=\"enter image description here\" /></p>\n<p><a href=\"https://simpsonswik... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T19:49:58.280",
"Id": "23583",
"Score": "4",
"Tags": [
"vbscript"
],
"Title": "VBScript for AD account creation"
} | 23583 |
<p>I wrote an infinite scrolling scrolling plugin for an app I'm developing. When requesting the second 'page' from the server, I loop through each image, and give it a very basic <code>onload</code> function.</p>
<pre><code>// I will have the result in a variable called data
// Fetch each image from result
$images = ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T00:26:32.150",
"Id": "36380",
"Score": "0",
"body": "Why do you think it can be sped up? Because as far as I can tell, the js can't be made much faster. If it seems slow, it's probably the actual image fetching that's taking time"
... | [
{
"body": "<p>Not really about performance, but this is more about clarity of the code.</p>\n\n<ul>\n<li><p>Attach <code>onload</code> handlers first, for readability. Appending the <code>src</code> starts the loading process. If you saw code that loaded something, expect to do something, but haven't found the ... | {
"AcceptedAnswerId": "23618",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T20:34:45.400",
"Id": "23587",
"Score": "3",
"Tags": [
"javascript",
"performance",
"jquery",
"image",
"ajax"
],
"Title": "JavaScript Image Preloading Script"
} | 23587 |
<p>I have an sql table with multiple fields and 4 of them are enums. I wrote a script that runs thought the table and retrieve the enums and put them in a 2 dimension array.</p>
<p>Unfortunately this script is extreamly slow and I can't fix it. </p>
<pre><code><?php
require_once('mySQL_Connect.php');
$con = Conn... | [] | [
{
"body": "<p>You can use describe queries in mysql to find column types</p>\n\n<p>for example <code>DESCRIBE courses</code> returns the table information including column type</p>\n",
"comments": [],
"meta_data": {
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate":... | {
"AcceptedAnswerId": "24021",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T21:34:25.810",
"Id": "23592",
"Score": "0",
"Tags": [
"php",
"performance",
"mysql",
"sql"
],
"Title": "php script to retrieve enum values from sql table"
} | 23592 |
<p>I've just started programming with JavaScript and I am currently working on this hobby website project of mine. The site is supposed to display pages filled with product images than can be "panned" to either the left or right. Each "page" containing about 24 medium sized pictures, one page almost completely fills ou... | [] | [
{
"body": "<p>Well I can only guess without seeing the code where the DOM is actually accessed but one thing that looks big to me is that you appear to be manipulating each individual element in seperate frames. If you did the calcs in one function for all elements that would be (I believe) one set of reflow ca... | {
"AcceptedAnswerId": "23596",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-07T23:14:47.900",
"Id": "23595",
"Score": "1",
"Tags": [
"javascript",
"image",
"animation",
"dom",
"google-chrome"
],
"Title": "Website with images that pan to different ... | 23595 |
<p>This question is about improving my C++ coding skills. I was asked to implement a simple static integer stack in C++ as an assignment. I've come up with the following code:</p>
<pre><code>class myStaticIntStack
{
int stackSize;
int storedElements;
int *elements;
public:
myStaticIntStack();
my... | [] | [
{
"body": "<p><code>this</code> is not always needed in member functions, you can remove all the </p>\n\n<pre><code>this->\n</code></pre>\n\n<p>The compiler knows this from the context.</p>\n\n<p>And move brackets, e.g.:</p>\n\n<pre><code>int myStaticIntStack::peek() {\n if( 0 == storedElements ){\n ... | {
"AcceptedAnswerId": "23602",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T00:22:01.747",
"Id": "23597",
"Score": "5",
"Tags": [
"c++",
"homework",
"stack"
],
"Title": "Simple static integer stack"
} | 23597 |
<p>Any idea how to write this code better."the html is nested tabs"
Two selectors and two similar events, in a function would be better or a pattern to reduce lines. <a href="http://jsbin.com/utaxot/3/edit" rel="nofollow">eg .jsbin</a></p>
<pre><code>$(function() {
var $items = $('#vtab>ul>li'),
$items2... | [] | [
{
"body": "<p>Give those <code>#vtab</code>s a class and it should be simple:</p>\n\n<pre><code>$(function() {\n $('.vtab > ul > li').mouseover(function() {\n var $this = $(this);\n\n $this.addClass('selected').siblings().removeClass('selected');\n $this.closest('.vtab').find('div'... | {
"AcceptedAnswerId": "23604",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T01:21:31.550",
"Id": "23600",
"Score": "1",
"Tags": [
"javascript",
"jquery",
"design-patterns"
],
"Title": "Reduce JavaScript code. Double event, selector into one"
} | 23600 |
<p>I'm pretty new to programming in general. I work with MySQL at my job but my knowledge of scripting language is rudimentary at best. I've been learning JavaScript via Codecademy but I got bored and set out on my own. I made this Tic Tac Toe game, which is purely text-based and predictably boring. I was just wond... | [] | [
{
"body": "<p>Your code's pretty good actually. I don't see any of the typical beginner's syntactical pitfalls. Kudos! (Though I would prefer <code>gameOver</code>, given its name, to be <em>false</em> while the game's running).</p>\n\n<p>Structurally, there are many ways to build it. I'd probably split things ... | {
"AcceptedAnswerId": "23613",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T06:02:20.717",
"Id": "23606",
"Score": "4",
"Tags": [
"javascript",
"beginner",
"game",
"tic-tac-toe"
],
"Title": "First JavaScript game: Tic Tac Toe"
} | 23606 |
<p>I have a situation where I have a fixed point number that I want to convert to and from a floating point number. Specifically it is the <code>SANE_Fixed</code> type from the <a href="http://www.sane-project.org/html/doc011.html#s4.2" rel="nofollow">SANE API</a>. Here is the what the documentation says (I grabbed t... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T09:17:41.357",
"Id": "36396",
"Score": "0",
"body": "Have you tried it? Does it seem to work?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T10:13:26.390",
"Id": "36401",
"Score": "0",
"b... | [
{
"body": "<p>If the <code>SANE_Fixed</code> type has a constantly fixed precision of 1/65536, that means it always stores the fractional part of the number as a 16 bit (two-byte) unsigned integer (hence the <code>SANE_FIXED_SCALE_SHIFT</code> of 16 bits). Since the whole number portion of the value can range ... | {
"AcceptedAnswerId": "23621",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T07:03:52.667",
"Id": "23608",
"Score": "2",
"Tags": [
"c#",
".net"
],
"Title": "Will this converstion to/from fixed point cause me to lose precision?"
} | 23608 |
<p>Please review my following code for DAO layer.</p>
<pre><code>public List<Channel> getListOfChannels() throws DataAccessException {
// will have the channel in form of List
// to hold the channels list
List<Channel> listChannels = null;
Connection conn = null;
Sta... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T11:12:01.733",
"Id": "36404",
"Score": "1",
"body": "Even if this code was perfect, what is your plan for avoiding repeating it?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T14:47:54.327",
"Id"... | [
{
"body": "<p>There are a couple of improvements that can be made here:</p>\n\n<ul>\n<li>a) your QUERY_STRING is magic string. Move it to a different place,\nbecause it make your code difficult to maintain </li>\n<li>user linked list\ninstead of array list. It has O(1) on insertion in worst case,\nwhereas array... | {
"AcceptedAnswerId": null,
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T07:09:35.577",
"Id": "23609",
"Score": "3",
"Tags": [
"java",
"database"
],
"Title": "DAO Layer Code Review"
} | 23609 |
<p>This is my first Java multi-threading code. It is part of an Android application that is a client to a webpage that serves books. Each page of the book is in a separate PDF, and the Book class represents the entire book, and has functions to download and render individual pages. This class is supposed to make things... | [] | [
{
"body": "<p>Here are a few comments:</p>\n\n<ul>\n<li><a href=\"https://stackoverflow.com/questions/5623285/java-why-not-to-start-a-thread-in-the-constructor-how-to-terminate\">you should not start a thread from the constructor</a> - for example, the thread could see <code>mPagesStatus</code> as null and thro... | {
"AcceptedAnswerId": "23725",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T08:28:03.157",
"Id": "23610",
"Score": "4",
"Tags": [
"java",
"multithreading",
"android",
"thread-safety",
"cache"
],
"Title": "Java thread safety and caching techniqu... | 23610 |
<p>After some 'digging' into the dark corners of legacy code I've found class, which handles INI files. It does reading and writing to the file, but I haven't found any exception handling logic. What kind of potential problems, if any, can you detect and what is your suggestion/advise for improving the code, based on t... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T15:05:13.680",
"Id": "36413",
"Score": "1",
"body": "If it is not broken then don't try and fix it. But feel free to add unit tests."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T16:16:32.750",
... | [
{
"body": "<p>This was posted just a short while ago on StackOverflow.com</p>\n\n<p>Firstly, if this is legacy code that has existed in production for a long time, then even if you can make it semantically better, you have to really weigh up the gains against the losses. Changing code is a cost, can introduce b... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T11:01:33.923",
"Id": "23615",
"Score": "3",
"Tags": [
"c++",
"c++03"
],
"Title": "legacy code and exception handling"
} | 23615 |
<p>Well, i'm starting a function to 'mess' with a image gallery, i made an <a href="http://jsfiddle.net/yVnTR/17/" rel="nofollow"><strong>example</strong></a></p>
<p>i wanna know if the way i'm doing is realy the BEST way, the function work perfect, but i fill that can be better, something more dynamic, like never flo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T13:13:22.027",
"Id": "36409",
"Score": "0",
"body": "Example was not working, updated right now"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T15:35:01.193",
"Id": "36417",
"Score": "0",
... | [
{
"body": "<p>I think your code is good and more importantly it works. The main thing I would change is that huge if else statement. You repeat yourself a lot there. Here's another way you could do it:</p>\n\n<p>Also here's your edited <strong><a href=\"http://jsfiddle.net/yVnTR/18/\" rel=\"nofollow\">fiddle</a... | {
"AcceptedAnswerId": "23624",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T13:07:01.557",
"Id": "23619",
"Score": "3",
"Tags": [
"javascript",
"jquery"
],
"Title": "Dynamically mess images inside a container"
} | 23619 |
<p>Can someone help in making this clock code more modular so I will be able to use it in other bigger projects for example: turn into a c function. Here is the code: </p>
<pre><code>#include <stdio.h>
#include <time.h>
#include <windows.h>
COORD coord = {0, 0};
void gotoxy (int x, int y)
{
coord... | [] | [
{
"body": "<p>General comments</p>\n\n<p>You should read the manual pages on <code>time()</code>, which gives you the time in seconds since 1970, library functions such as <code>localtime</code>, <code>strftime</code> and <code>ctime</code> that can be used to present time values and the <code>sleep()</code> fu... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T13:46:41.087",
"Id": "23620",
"Score": "3",
"Tags": [
"c",
"windows"
],
"Title": "Aid in making a clock code more modular"
} | 23620 |
<pre><code>#!/usr/bin/env python
import os, sys
variable = sys.argv
def enVar(variable):
"""
This function returns all the environment variable set on the machine or in active project.
if environment variable name is passed to the enVar function it returns its values.
"""
nVa... | [] | [
{
"body": "<p>Some notes:</p>\n\n<ul>\n<li>Indent with 4 spaces (<a href=\"http://www.python.org/dev/peps/pep-0008/\" rel=\"nofollow\">PEP8</a>)</li>\n<li>Use <code>underscore_names</code> for function and variables.</li>\n<li>Use meaningful names for functions (specially) and variables.</li>\n<li>Be concise in... | {
"AcceptedAnswerId": "23628",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T15:29:46.960",
"Id": "23623",
"Score": "6",
"Tags": [
"python"
],
"Title": "this code returns environment varibles or passed enverionment variable with values"
} | 23623 |
<p>I'd like to know if I'm doing profile configuration in the wrong place or in the wrong way.</p>
<p>I'm following the Onion Architecture, so that restricts the direction of my dependencies towards the center.</p>
<p><img src="https://i.stack.imgur.com/ECZcG.png" alt="Onion Architecture"></p>
<h2>Core</h2>
<p>My d... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-10-29T19:22:13.913",
"Id": "53606",
"Score": "0",
"body": "I assume that this code works the way you intended it to work. and it sounds like you want to create a session variable to hold your Mapper, is that what you are asking there abo... | [
{
"body": "<p>What is the purpose of the <code>IMapper</code> interface and <code>Mapper</code> class? It looks to me that they are just wrapping the <code>IMappingEngine</code> interface and <code>MappingEngine</code> class. While this is a good method when you have a third party class that doesn't have an i... | {
"AcceptedAnswerId": "43453",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T16:42:37.220",
"Id": "23625",
"Score": "20",
"Tags": [
"c#",
"dependency-injection",
"asp.net-mvc-4"
],
"Title": "Injecting AutoMapper profiles"
} | 23625 |
<pre><code>(defn merge [pred left right]
(loop [v [] l left r right] ; v is a vector, so conj will append to the end
(if (and (seq l) (seq r)) ; if both left and right are not empty
(if (pred (first l) (first r))
(recur (conj v (first l)) (rest l) r)
(recur (con... | [] | [
{
"body": "<p>A few points, though I'm not a Clojure expert:</p>\n\n<ul>\n<li><p>Indentation. You use four-space indentation, but two-space indentation is more common for Lisp in general and also generally preferred for Clojure. (there seems to be a Clojure <a href=\"https://github.com/bbatsov/clojure-style-gui... | {
"AcceptedAnswerId": "23698",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T18:44:10.040",
"Id": "23627",
"Score": "3",
"Tags": [
"clojure",
"sorting",
"mergesort"
],
"Title": "Mergesort implementation in Clojure"
} | 23627 |
<p>I'm trying to make a card game, using OOP style. I decided to make suit a class rather than an <code>enum</code> as I would first have done. How am I doing so far? Am I over-complicating things by making it a class?</p>
<pre><code>namespace Cards
{
class Suit
{
public:
Suit();
~Suit();
std::string GetN... | [] | [
{
"body": "<p>Yes I think you are over complicating things. In C++11 I would use a strongly typed enum:</p>\n\n<pre><code>enum class Suite {Hearts,\n Diamonds,\n Clubs,\n Spades};\n</code></pre>\n\n<p>I might also have considered a simple class hierarchy </p>\n... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T23:36:33.950",
"Id": "23636",
"Score": "2",
"Tags": [
"c++",
"object-oriented",
"playing-cards"
],
"Title": "Suit class for card game"
} | 23636 |
<p>I have a Ruby class into which I want to include both class and instance methods. Following the pattern described in "<a href="http://www.dan-manges.com/blog/27" rel="nofollow">Ruby Pattern: Extend through Include</a>", I'm currently using the following:</p>
<pre><code>class SomeObject
include SomeObject::Abilit... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T15:29:49.853",
"Id": "36473",
"Score": "1",
"body": "AFAIK `self.included` + `.extend(ClassMethods)` is pretty much the way to do it. If you're using Rails, you can use [ActiveSupport::Concern](http://api.rubyonrails.org/classes/Act... | [
{
"body": "<p>You're doing it right :) It's a very common idiom, and widely accepted as the preferred way to handle this.</p>\n\n<p>In case you're still in doubt, here are a few examples of the same pattern found in major projects out in the wild: <a href=\"https://github.com/mperham/sidekiq/blob/4e66339f653496... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-08T23:40:28.627",
"Id": "23637",
"Score": "1",
"Tags": [
"ruby",
"singleton",
"modules"
],
"Title": "Mixin both instance and class methods in Ruby"
} | 23637 |
<p>I have a class something like the following: </p>
<pre><code>class ItemManager {
List<Item> items;
public ItemManager() {
items = Database.retrieveItems();
}
}
</code></pre>
<p>An item has several attributes, so much so that I used a Builder class instead of a typical constructor(Lik... | [] | [
{
"body": "<p>You can generify your ItemManager</p>\n\n<pre><code>class ItemManager<T extends Item> {\n\n List<T> items;\n\n public ItemManager() {\n\n items = Database.retrieveItems();\n\n }\n}\n</code></pre>\n\n<p>The search method can be refactored with this help of <a href=\"http... | {
"AcceptedAnswerId": "23655",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T02:45:41.423",
"Id": "23640",
"Score": "2",
"Tags": [
"java",
"object-oriented"
],
"Title": "Merit of a \"Search\" class similar to a \"Builder\" class"
} | 23640 |
<p>Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.</p>
<p>If the last word does not exist, return 0.</p>
<p>Note: A word is defined as a character sequence consists of non-space characters only.</p>
<p>For example:</p>
<pre><code>... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T17:44:29.803",
"Id": "36487",
"Score": "0",
"body": "Not sure how this works: `\"b a \" 2`"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T17:59:02.620",
"Id": "36488",
"Score": "0",... | [
{
"body": "<p>(Just a quick note, I don't have too much time now.) Here is another approach:</p>\n\n<pre><code>int lengthOfLastWord2(const char* input)\n{ \n int result = 0;\n while (*input != '\\0') {\n if (*input != ' ') {\n result++;\n } else {\n re... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T03:26:02.340",
"Id": "23641",
"Score": "4",
"Tags": [
"c",
"strings",
"interview-questions"
],
"Title": "Length of last word"
} | 23641 |
<p>I recently started running but hate running both in the quiet and with music, so i've been listening to podcasts. Unfortunately, I've caught up with all my favorites and so I've started listening to some iTunesU courses, but unfortunately (again) very few of them have audio-only versions.</p>
<p>I wrote a shell sc... | [] | [
{
"body": "<h3>Function</h3>\n\n<p>The command</p>\n\n<pre><code>is_video_file $extension = 1\n</code></pre>\n\n<p>just passes the arguments <code>$extension</code> , <code>=</code> and <code>1</code> to the function <code>is_video_file</code>.</p>\n\n<p>To check if the return value of <code>is_video_file</code... | {
"AcceptedAnswerId": "23646",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T01:09:02.857",
"Id": "23645",
"Score": "3",
"Tags": [
"file-system",
"bash",
"osx"
],
"Title": "Shell script to copy video files to another folder"
} | 23645 |
<p>Is there a better way to write this in vs2010 C#?</p>
<pre><code>public bool IsAccept()
{
//check the status is accept
if (Status == null)
return false;
return Status.ToLower() == "accept";
}
public bool IsRefer()
{
//check the status is refer
if (Status == null)
return false;
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T21:14:48.793",
"Id": "36506",
"Score": "0",
"body": "not a real answer: just make it a ternary operator `public bool IsAccept() { return (Status == null) ? false : Status.ToLower() == \"accept\"; }`"
}
] | [
{
"body": "<h2>First wave</h2>\n\n<pre><code>public bool IsAccept\n{\n get { return Status != null && Status.ToLower() == \"accept\"; }\n}\n\npublic bool IsRefer\n{\n get { return Status != null && Status.ToLower() == \"refer\"; }\n}\n\npublic bool IsAnyReviewState\n{\n get { return IsA... | {
"AcceptedAnswerId": "23652",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T12:06:29.900",
"Id": "23649",
"Score": "1",
"Tags": [
"c#",
"asp.net"
],
"Title": "Simplify C# Code"
} | 23649 |
<p>I'm new to front-end development and now I'm learning JavaScript with jQuery.
I couldn't understand JavaScript's classes and objects and jQuery plugins, but after reading some articles and examples I wrote simple notifications system.</p>
<pre><code>(function ($) {
var notification = function (title, msg, durat... | [] | [
{
"body": "<p>First of, for someone learning jQuery and JavaScript, you've done a great job of avoiding the pitfalls of most new developers to JavaScript;</p>\n\n<ol>\n<li>You're not passing strings to <code>setTimeout</code>, which a lot of people do.</li>\n<li>You've got a good grasp on closures (no matter ho... | {
"AcceptedAnswerId": "23654",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T13:24:03.613",
"Id": "23653",
"Score": "2",
"Tags": [
"javascript",
"jquery"
],
"Title": "Simple JS/jQuery notification system"
} | 23653 |
<p>I am writing a specialized version of the cross correlation function as used in neuroscience. The function below is supposed to take a time series <code>data</code> and ask how many of its values fall in specified bins. My function <code>xcorr</code> works but is horrifically slow even. A test data set with 1000 poi... | [] | [
{
"body": "<p>Here's a crack at my own question that uses built-in functions from <code>NumPy</code> </p>\n\n<p><strong>Update</strong></p>\n\n<p>The function chain <code>bincount(digitize(data,bins))</code> is equivalent to <code>histogram</code>, which allows for a more succinct expression.</p>\n\n<pre><code>... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T14:43:36.820",
"Id": "23656",
"Score": "3",
"Tags": [
"python",
"performance",
"numpy",
"statistics"
],
"Title": "Specialized version of the cross correlation function"
} | 23656 |
<p>I made this simple game code. Can you please give me some advice on how I can improve it?</p>
<pre><code>#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include <time.h>
#include <windows.h>
void main ()
{
printf("\t\tWelcome to our gessing game\n\n\n");
printf("the co... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T17:14:27.857",
"Id": "36484",
"Score": "0",
"body": "Tabs don't translate well to the web. Please format your code so it is easy to read."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T17:23:33.813",... | [
{
"body": "<p>One variable per line please.</p>\n\n<pre><code>int gess,i=0,found=0, r = rand()%100;\n</code></pre>\n\n<p>This makes the code hard to read. There is also one corner case (with pointers) were this will not work as expected for beginners. As a result this is usually banned in most companies coding... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T14:57:08.420",
"Id": "23657",
"Score": "5",
"Tags": [
"c",
"windows",
"number-guessing-game"
],
"Title": "Simple random number guessing game"
} | 23657 |
<p><strong>Premise:</strong> Write a program that counts the frequencies of each word in a text, and
output each word with its count and line numbers where it appears. We
define a word as a contiguous sequence of non-white-space characters.
Different capitalizations of the same character sequence should be
consider... | [] | [
{
"body": "<p>You're right, the basic point to make this program faster is to store the line numbers in the first pass.</p>\n\n<p>The <code>for word in list</code> loop will run many times. The count depends on how many words you have. Every time it runs, it reopens and rereads the whole input file. This is awf... | {
"AcceptedAnswerId": "23681",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T16:00:50.760",
"Id": "23662",
"Score": "4",
"Tags": [
"python",
"optimization"
],
"Title": "Improve efficiency for finding word frequency in text"
} | 23662 |
<blockquote>
<p>Given a number represented as an array of digits, plus one to the
number.</p>
<pre><code>input expected
[8,9,9,9] [9,0,0,0]
[1,0,0,0,0] [1,0,0,0,1]
[9,8,7,6,5,4,3,2,1,0] [9,8,7,6,5,4,3,2,1,1]
</code></pre>
</blockquote>
<p>The followi... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T01:33:50.580",
"Id": "36660",
"Score": "0",
"body": "What should [9, 9, 9] do? Should it cause an error, or push anew element onto the vector to return [1, 0, 0, 0]?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate"... | [
{
"body": "<p>Since you are returning a result.<br>\nPass the parameter by const reference so that you don't accidentally modify it:</p>\n\n<pre><code>vector<int> plusOne(vector<int> const& digits)\n</code></pre>\n\n<p>The less than operator is not defined for iterators.<br>\nYou are just getti... | {
"AcceptedAnswerId": "23667",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T16:47:32.347",
"Id": "23666",
"Score": "5",
"Tags": [
"c++",
"interview-questions",
"vectors"
],
"Title": "Given a number represented as an array of digits, plus one to the num... | 23666 |
<blockquote>
<p>Given a sorted linked list, delete all duplicates such that each element appears only once.</p>
<p>For example:</p>
<ul>
<li>Given 1->1->2, return 1->2.</li>
<li>Given 1->1->2->3->3, return 1->2->3.</li>
</ul>
</blockquote>
<p>The following is my code:</p>
<pre><code>struct ListNode ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T18:48:36.860",
"Id": "36499",
"Score": "0",
"body": "Are the nodes dynamically allocated. If so you are leaking."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T19:40:54.323",
"Id": "36502",
"... | [
{
"body": "<p>You could browse all the elements of the linked list and store their value, address, and the number of time they appear in an array. After that you just have to remove (form the linked list) the address stored in the array which correspond to values that appears more than once.</p>\n\n<p>One advan... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T18:18:12.370",
"Id": "23670",
"Score": "3",
"Tags": [
"c++",
"linked-list"
],
"Title": "Remove duplicates from a linked list"
} | 23670 |
<p>I am trying to delete a large folders (with many levels of subfolders) over a network (i.e, on a remote machine). </p>
<p>I have the following code and it takes 10 minutes. Is there a way to improve this drastically?</p>
<pre><code>public static boolean deleteDirectory(File directory) {
File[] files = dir... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T22:24:04.773",
"Id": "36509",
"Score": "2",
"body": "Do you have command line access to the machines? Because it would probably be faster to have the OS do it with `rmdir`/`rm -rf` in a `Runtime.exec()` if so."
},
{
"Content... | [
{
"body": "<p>I decide to write my own function(using native process) to delete the files(tested on <strong>windows</strong>), no external dependencies on jars.</p>\n\n<p>Implementation details for windows:</p>\n\n<ul>\n<li><p>I am using <a href=\"http://en.wikipedia.org/wiki/Robocopy\" rel=\"nofollow\">robocop... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T18:46:17.150",
"Id": "23673",
"Score": "4",
"Tags": [
"java",
"optimization",
"performance"
],
"Title": "Deleting large folders on remote machines"
} | 23673 |
<p>I've designed the basics of an admin page I'd like to use for a small website. I'd like to know if I'm using the language properly. Please rip apart the code and tell me what I could do better.</p>
<p>Admin page code, file called "index.php" (just the file name in my "netbeans" folder):</p>
<pre><code><!DOCTY... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-24T16:03:34.253",
"Id": "37483",
"Score": "2",
"body": "At first glance, I don't see anything \"wrong\" with this. However, have you considered separating the logic from the view i.e. using the [MVC](http://en.wikipedia.org/wiki/Model%... | [
{
"body": "<h2>PHP Related Things</h2>\n\n<ul>\n<li>Try not to mix HTML and PHP. PHP logic should come on top of the document, HTML below it. Within the HTML, there are just some minor <code>echo</code> and <code>if</code> statements and some loops. If you go a little bit more advanced, you should use something... | {
"AcceptedAnswerId": "24310",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T20:17:09.757",
"Id": "23675",
"Score": "2",
"Tags": [
"php",
"html"
],
"Title": "Admin page for a small website"
} | 23675 |
<p>I created this version of Hangman in Python 3. Does anyone have any tips for optimization or improvement?</p>
<pre><code>import random
HANGMAN = (
'''
-------+''',
'''
+
|
|
|
|
|
-------+''',
'''
-----+
|
|
|
|
|
-------+''',
'''
---... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T13:22:45.947",
"Id": "36588",
"Score": "2",
"body": "Not an optimization, but you could load your words from a - possibly encrypted - text file instead of having them in your raw code :)"
}
] | [
{
"body": "<p>You can avoid repeating <code>guess = input('Guess a letter: ').lower()</code> by changing the inner while loop to:</p>\n\n<pre><code>while True:\n guess = input('Guess a letter: ').lower()\n if guess in lettersGuessed:\n print('You\\'ve already guessed that letter!')\n else:\n ... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T21:43:33.187",
"Id": "23678",
"Score": "6",
"Tags": [
"python",
"optimization",
"game",
"python-3.x",
"hangman"
],
"Title": "Hangman in Python"
} | 23678 |
<p><strong>Update:</strong> Great answers up to now, but I would still love to have a bit of review about possibility of variable caching and the filter I'm using for rows and page sets!</p>
<hr>
<p>After seeing a lot of Paginator plugin that never fit my needs, I've decided to create my own. I have followed the <a h... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2015-01-03T02:35:07.817",
"Id": "137459",
"Score": "0",
"body": "I'm closing this as the question is now harder to follow for future visitors and reviewers, and the updated answer prevents this question's update from being justifiably reversed... | [
{
"body": "<p>You do have a lot of code for review so here are some quite general suggestions:</p>\n\n<p>Code length shouldn't be a problem when you minify/gzip. Even though it is 300+ lines. If you can reduce more, power to you! I see you've used prototypes well and that should have already reduced quite a bit... | {
"AcceptedAnswerId": "23912",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T21:51:35.267",
"Id": "23679",
"Score": "3",
"Tags": [
"javascript",
"jquery",
"plugin"
],
"Title": "jQuery Object Oriented Plugin"
} | 23679 |
<p>I've realized a jQuery Plugin recently and made a basic default CSS for it.</p>
<p>As I'm mainly a server-side guy, I'm not too familiar with CSS and would like to have insight about what could be improved.</p>
<p>The main issues I've targeted are :</p>
<ul>
<li>Are the CSS selectors appropriate, knowing that thi... | [] | [
{
"body": "<p>You styles are pretty solid, it's mainly your selectors that have issues I feel. Here are some notes:</p>\n\n<ul>\n<li><p>It's normally best to not include the type of element if it has a class. This is for maintainability and extensibility purposes, you could switch in <code><ol></code> for... | {
"AcceptedAnswerId": "23687",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-09T22:11:15.613",
"Id": "23680",
"Score": "6",
"Tags": [
"css",
"plugin"
],
"Title": "CSS Good Practice on a JavaScript Plugin"
} | 23680 |
<p>Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.</p>
<p>For example,</p>
<pre><code>Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->1->1->2->3, return 2->3.
</code></pre>
<p>The following is m... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T02:43:06.650",
"Id": "36516",
"Score": "0",
"body": "This is the same question as your previous one. Why do that?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T04:29:36.160",
"Id": "36522",
... | [
{
"body": "<p>Iterate through the list and remember the pointer to the first element in the group node. Then check if the current element has the same value as the first element in the group. Remove the current element and set some flag to remember to remove the first element in this group. Then if you have a n... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T00:43:57.510",
"Id": "23683",
"Score": "1",
"Tags": [
"c++",
"interview-questions",
"linked-list"
],
"Title": "remove all nodes with same value in a linked list"
} | 23683 |
<p>I need to join source-specific multicast group and receive data. When I don't need to receive data anymore, I need to leave the group and disconnect the socket.</p>
<p>Am I doing everything right? In particular, is this order of actions in <code>Disconnect</code> correct and complete?</p>
<ol>
<li>Leave the group... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2019-11-10T15:17:02.690",
"Id": "453162",
"Score": "0",
"body": "Can you please supply test cases in code to show how these functions are used? Right now the question can be closed as off-topic due to Lack of Concrete Context."
}
] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T08:17:55.813",
"Id": "23688",
"Score": "2",
"Tags": [
"c++",
"socket"
],
"Title": "Join / leave source-specific multicast group and connect / disconnect corresponding socket"
} | 23688 |
<p>In my system I frequently require data by Ajax requests. For example, different lists, content of modal dialogs, etc. This data can't be changed after request, so I wrote cache mechanism which stores Ajax result and then before Ajax request checks is there stored data.
Here is example:</p>
<pre><code>YFeX.cache = {... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T11:32:20.377",
"Id": "36530",
"Score": "1",
"body": "Not much to improve in just the couple of lines, but why not use browser's default caching?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T11:43:1... | [
{
"body": "<p>From a once over;</p>\n\n<ul>\n<li>Unless <code>YFeX</code> is also a constructor, it should be <code>yFex</code></li>\n<li>lowerCamelCase is good for you: <code>account_modal</code> -> <code>accountModal</code></li>\n<li>I would store <code>YFeX.cache.account_modal</code> into a <code>var cachedA... | {
"AcceptedAnswerId": "43956",
"CommentCount": "8",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T10:00:04.230",
"Id": "23691",
"Score": "2",
"Tags": [
"javascript",
"jquery",
"ajax",
"cache"
],
"Title": "Simple cache mechanism?"
} | 23691 |
<p>I have a Edit/Details form which has 4 user related fields. On click of Save, I save the edited fields to local storage (if supported) and display the same values in the Details view.</p>
<p>Below is the code which does that;</p>
<pre><code> var UserDataObj = {
name:"John",
email:"john@example.com",
phone:"999999... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T11:53:43.330",
"Id": "36532",
"Score": "0",
"body": "Note that this has been crossposted to [Stack Overflow](http://stackoverflow.com/questions/15321636/check-javascript-coding-practice-and-overall-performance) (where it is closed) ... | [
{
"body": "<ul>\n<li><p>You can start with how you code. Have them <a href=\"http://jsbeautifier.org/\" rel=\"nofollow\">indented properly</a> and checked by a <a href=\"http://www.jshint.com/\" rel=\"nofollow\">quality-check tool</a>. Code-review doesn't only deal with optimization, but also maintainability of... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T11:30:51.510",
"Id": "23693",
"Score": "3",
"Tags": [
"javascript",
"jquery",
"html",
"html5"
],
"Title": "Edit/Details form in JavaScript"
} | 23693 |
<p>The required output is stated just before the <code>main()</code> function. Is there a better way to achieve it? I feel like I am repeating code unnecessarily but am unable to find a better way to get the result. Not squeezing the code too much, like one liners, but reasonably using better logic.</p>
<pre><code>#!/... | [] | [
{
"body": "<ol>\n<li>The pythonic way to do <code>count = count + 1</code> is <code>count += 1</code></li>\n<li><p>You don't need to repeat the 'guess again' part of the game twice:</p>\n\n<pre><code>if guess > val:\n print(\"Too high. Try again:\", guess) \nelif guess < val:\n print(\"Too low. Try... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T14:43:48.083",
"Id": "23694",
"Score": "12",
"Tags": [
"python",
"game"
],
"Title": "Guessing Game: computer generated number between 1 and 100 guessed by user"
} | 23694 |
<p>I've started to program a state machine on a PIC18F2550 microcontroller. In each state of my machine, there is a designated block of code that runs for a specific amount of real time, such as 20 or 30 seconds. To do this, I use a countdown timer that is decremented once every second. Depending on the state the machi... | [] | [
{
"body": "<h2>General</h2>\n\n<p>Difficult to read, don't you think? Code is normally a 'write-once,\n read-often' operation. Therefore it makes sense to make it easy to read,\n even if it takes longer to write.</p>\n\n<ul>\n<li><p><code>if</code>, <code>while</code> etc should be followed by a space and o... | {
"AcceptedAnswerId": "23712",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T19:32:50.307",
"Id": "23699",
"Score": "1",
"Tags": [
"optimization",
"c",
"synchronization"
],
"Title": "Timing/Synchronization issues with interrupt-reliant code"
} | 23699 |
<p>This is in continuation to a question I asked <a href="https://stackoverflow.com/questions/15256966/deriving-a-group-or-a-set-from-a-map">here</a>. Given the total number of nodes (employees) and the adjacency list (friendship amongst employees), I need to find all the connected components.</p>
<pre><code>public c... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-16T10:20:57.193",
"Id": "36974",
"Score": "0",
"body": "Use a profiler to profile the code and find out where you spent the time. It is hard to guess, because a lot is happening there."
},
{
"ContentLicense": "CC BY-SA 3.0",
... | [
{
"body": "<ol>\n<li><p>First of all, two things to read or search for: Cluster analysis (just a hint, I'm not an expert about that) and <a href=\"https://en.wikipedia.org/wiki/Linked:_The_New_Science_of_Networks\" rel=\"nofollow noreferrer\"><em>Linked: The New Science of Networks</em></a> by <em>Albert-László... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T19:53:39.013",
"Id": "23700",
"Score": "3",
"Tags": [
"java",
"performance",
"breadth-first-search",
"graph"
],
"Title": "BFS implementation to find connected components takin... | 23700 |
<p>Below is an implementation of Dijkstra's shortest path algorithm. It's input <code>graph</code> is represented as an association list of source nodes to assoc of target node and arc weight.</p>
<p>My question is about the following, am I missing a way of simplifying <code>min-path</code> function used in reduce? Ma... | [] | [
{
"body": "<p>First, <code>(not (null x))</code> is not very idiomatic; just use <code>x</code> instead.</p>\n\n<p>Next, you are not handling <em>all</em> the cased in your <code>cond</code> (and you obviously mean <code>(null arc-2)</code> and not <code>(null (arc-2))</code>). If fact, I would drop the <code>l... | {
"AcceptedAnswerId": "23703",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T20:09:36.720",
"Id": "23701",
"Score": "1",
"Tags": [
"lisp",
"common-lisp"
],
"Title": "Proper use of reduce, nested loops"
} | 23701 |
<p>I need to connect different <code>Task</code> with a double linked list and different <code>Dependencies</code> which affect a calculation for which I need the values of both <code>Task</code>:</p>
<pre><code>public class Task {
private List<Dependency> parents = new ArrayList<Dependency>();
pri... | [] | [
{
"body": "<p><code>Task</code> depends on <code>Dependency</code> (not very troubling in itself) :</p>\n\n<pre><code>public class Task {\n private List<Dependency> parents = new ArrayList<Dependency>();\n</code></pre>\n\n<p>Also <code>Dependency</code> depends on concrete class <code>Task</code>... | {
"AcceptedAnswerId": "23726",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T20:49:20.797",
"Id": "23702",
"Score": "1",
"Tags": [
"java",
"linked-list"
],
"Title": "Doubly linked list with different dependencies"
} | 23702 |
<p>I have 2 classes that should run a service when calling their <code>Start</code> method, but before it they should:</p>
<ol>
<li>Copy items to F folder</li>
<li>Open S service in remote server if it's not opened already</li>
<li>Run #SN service in remote server</li>
</ol>
<p>They differ in 1 & 3 steps:</p>
<o... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T23:41:10.850",
"Id": "36562",
"Score": "3",
"body": "This is a bit abstract; would you mind posting the code of those classes? My first guess would be that if it can't be solved purely by passing in different parameters, step 1 (and... | [
{
"body": "<p>This depends on the capabilities of your language.</p>\n\n<h3>Strategies, and higher order functions</h3>\n\n<p>If I were to design this, there would only be one class, with a <code>Start</code> method, and two properties <code>service</code> (which somehow specifies a service), and <code>selectIt... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T21:31:25.727",
"Id": "23704",
"Score": "-1",
"Tags": [
"c#",
"object-oriented",
"design-patterns",
"inheritance"
],
"Title": "Should I use inheritance in my case?"
} | 23704 |
<p>I'm brand new to JavaScript and jQuery and I feel like there's probably a better way to do this. It seems that the way I designed it may not be very optimal once you get a thousand entries in the list but I do like the fact that it's a live search. </p>
<p>Note: I tried changing the style of the <code><option>... | [] | [
{
"body": "<p>First thing I notice is that you're actually not using jQuery all that much. The point of jQuery is really its convenience compared to the native DOM. You're foregoing that convenience in some places, and relying on jQuery in others. You can of course do it all directly using the DOM and skip jQue... | {
"AcceptedAnswerId": "23708",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-10T23:03:58.883",
"Id": "23706",
"Score": "6",
"Tags": [
"javascript",
"beginner",
"jquery",
"html"
],
"Title": "Better way to filter select list"
} | 23706 |
<p>Had some free time this weekend and I hacked together a small Brainfuck interpreter, with the sole intention of explaining PHP's flavour of OO to a friend. This is a bit over-engineered on purpose, and performance wasn't really considered (or I wouldn't have written this in PHP in the first place). </p>
<p>Thoughts... | [] | [
{
"body": "<p>So for starters, make the operations lazy-loaded (yeah big surprise, Haskeller says make it lazy)</p>\n\n<p>As such:</p>\n\n<pre><code>class LoopOperation implements OperationInterface {\n\n private $master = false;\n private $operations = array();\n\n public function __construct(array $o... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T00:47:40.747",
"Id": "23707",
"Score": "21",
"Tags": [
"php",
"object-oriented",
"php5",
"brainfuck"
],
"Title": "Thoughts on my brain fart interpreter?"
} | 23707 |
<p><a href="http://en.wikipedia.org/wiki/Data_validation" rel="nofollow">Validation</a> is the process of checking data to make sure they meet the specifications which have been set for them. Typically, validation is used in checking user-input data, and in verifying data before storage.</p>
<p>Examples of this includ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T06:38:00.027",
"Id": "23714",
"Score": "0",
"Tags": null,
"Title": null
} | 23714 |
Validation is used to check data to make sure it fits whatever required specifications are set for it. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T06:38:00.027",
"Id": "23715",
"Score": "0",
"Tags": null,
"Title": null
} | 23715 |
Declaration is the part of the subprogram (procedure or function) which provides the protocol(header), but not the body of the subprogram. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T06:38:36.143",
"Id": "23717",
"Score": "0",
"Tags": null,
"Title": null
} | 23717 |
<p>The Tk toolkit is a GUI toolkit that is designed to be used from dynamic languages. It was developed originally by John Ousterhout for use with Tcl, but has subsequently been evolved to be supported with many other languages (notably Perl, Python and Ruby).</p>
<p>Tk is a native toolkit on Windows and Mac OS X. On ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T06:39:50.617",
"Id": "23718",
"Score": "0",
"Tags": null,
"Title": null
} | 23718 |
The Tk toolkit is a scripted GUI toolkit that is designed to be used from dynamic languages (initially Tcl, but also Perl and Python). | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T06:39:50.617",
"Id": "23719",
"Score": "0",
"Tags": null,
"Title": null
} | 23719 |
<p>A directory is a named collection of related files or other folders that can be retrieved, moved, and otherwise manipulated as one entity.</p>
<p>Directory is also an alias for the more popular term <code>folder</code>.</p>
<p>The folder term is chosen to be consistent with the metaphor that the user interface is ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T06:41:41.460",
"Id": "23720",
"Score": "0",
"Tags": null,
"Title": null
} | 23720 |
Directories is an alias for folders. Use this tag for questions about creating, managing, using, and deleting folders. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T06:41:41.460",
"Id": "23721",
"Score": "0",
"Tags": null,
"Title": null
} | 23721 |
<p><strong>In mathematics</strong>, a graph is an abstract representation of a set of objects where pairs of the objects can be connected by links. The interconnected objects are represented by mathematical abstractions called vertices, and the links that connect pairs of vertices are called edges. A graph is said <em>... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T07:08:24.780",
"Id": "23722",
"Score": "0",
"Tags": null,
"Title": null
} | 23722 |
A graph is an abstract representation of objects (vertices) connected by links (edges). For questions about plotting data graphically, use the [data-visualization] tag instead. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T07:08:24.780",
"Id": "23723",
"Score": "0",
"Tags": null,
"Title": null
} | 23723 |
<p>This piece of code I have written works, but I don't think its the best solution.</p>
<p>What I am doing is check if a certain radio is checked if it is show this div if else show this div if this radio is checked etc.</p>
<p>Can someone point me in the right direction on this one? I would love to know how to writ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T08:18:35.457",
"Id": "36580",
"Score": "0",
"body": "Why not use the value passed as an `id` for the form elements?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T08:29:31.963",
"Id": "36581",
... | [
{
"body": "<p>Though your conditions are fine, I'd suggest you for a radical change in the code.</p>\n\n<ol>\n<li>Change the <code>id</code>s as follows:\n<ul>\n<li><code>ContactFormOne</code> to <code>informed</code></li>\n<li><code>ContactFormTwo</code> to <code>release</code></li>\n<li><code>ContactFormThree... | {
"AcceptedAnswerId": "23727",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T08:08:29.507",
"Id": "23724",
"Score": "3",
"Tags": [
"javascript",
"jquery",
"form"
],
"Title": "Show one form that corresponds to the selected radio button"
} | 23724 |
<p>The output is a random sequence, and the input is the sum of the sequence.</p>
<p>My solution is generating a random number <em>rand_num</em> from (0, sum_seq) at first, then draw another number randomly from (0, sum_seq - rand_num). By the way, all random numbers are integers.</p>
<pre><code>import random
rand_l... | [] | [
{
"body": "<h1>Using a recursive approach -</h1>\n\n<hr>\n\n<pre><code>from random import randint\n\ndef sequence(n):\n\n a = []\n\n def f(n):\n m = randint(1, n)\n if n > m:\n a.append(str(m))\n return f(n - m)\n else:\n a.append(str(n))\n return n\n\n f(... | {
"AcceptedAnswerId": "23731",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T08:45:56.317",
"Id": "23728",
"Score": "7",
"Tags": [
"python",
"random"
],
"Title": "Generating random sequences while keeping sum fixed"
} | 23728 |
<p>I was playing with some of the wonderful new C++11 features and tried to reimplement a function <code>reversed</code> that would behave just like the one in Python to allow reverse iteration on bidirectional iterables.</p>
<p>And to clarify since I'm been told that I was unclear, that <code>reverse</code> function ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T16:28:48.880",
"Id": "36614",
"Score": "0",
"body": "Is an 'iterable' a container usually? Everywhere you use `iter` is tremendously confusing because that usually means *iterator* not *iterable* (container)"
},
{
"ContentLi... | [
{
"body": "<p>Overall I like this helper. Most potential complaints are due to evaluating how well it would handle something it wasn't intended to support. Here are some of my thoughts from examining its implementation.</p>\n\n<p>This code goes out of its way to define a lot of names for types that are not used... | {
"AcceptedAnswerId": "35539",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T14:09:20.377",
"Id": "23734",
"Score": "8",
"Tags": [
"python",
"c++",
"c++11",
"iterator",
"reinventing-the-wheel"
],
"Title": "Python reversed in C++11"
} | 23734 |
<p>I need to refactor this code, targeted to Google Chrome (current+) to make it manageable going forward.</p>
<p><a href="http://jsbin.com/unazig/1/" rel="nofollow">Here</a> is a working JSBin of the idea.</p>
<p>The messiness comes from determining the accurate number of lines of text, and the real heights of eleme... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T15:20:16.887",
"Id": "36600",
"Score": "0",
"body": "I think you'd be better off figuring out how to parse the HTML-layout into a big fat pre-blob of text, and running the scan on that, character-by-character. Each character is a si... | [
{
"body": "<p>There are only two things I can think of.</p>\n\n<h3>Sometimes it's best to pass objects when there are more than 4 parameters for a method call.</h3>\n\n<p>Instead of this</p>\n\n<pre><code>function scan_el(el_fin_callback, el, mask, sub_mask, real_height, real_width, push, lines, line) {\n</code... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T14:14:00.793",
"Id": "23735",
"Score": "5",
"Tags": [
"javascript",
"jquery",
"animation"
],
"Title": "Retrocomputing scanline function"
} | 23735 |
<p>This is the code:</p>
<pre><code>public DateTime GibSomeStartDate(IEnumerable<int> partnerNumbers, DateTime startTime)
{
return (from contract in this.databaseContext.Contract
where partnerNumbers.Contains(contract.Pnr) && contract.SomeDateTime >= startTime
select con... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T14:56:03.907",
"Id": "36597",
"Score": "0",
"body": "I wasnt sure whether this question for this site or fot http://programmers.stackexchange.com If I have post it on the false one - migrate it please. Thank you."
},
{
"Cont... | [
{
"body": "<p>I'd do it like this:</p>\n\n<pre><code>public DateTime GibSomeStartDate(IEnumerable<int> partnerNumbers, DateTime startTime)\n{\n return this.databaseContext.Contract\n .Where(c => c.SomeDateTime >= startTime && partnerNumbers.Contains(c.Pnr))\n ... | {
"AcceptedAnswerId": "23737",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T14:49:59.357",
"Id": "23736",
"Score": "3",
"Tags": [
"c#",
"linq"
],
"Title": "Rewrite from .. where .. select to more compact one"
} | 23736 |
<p>This method assigns the value of a specified column in a <code>DataRow</code> to specified property in an object. </p>
<p>I have 3 conditionals handling exceptions, and I want these conditions to throw exceptions. </p>
<p>The final condition just allows the use of a conversion method if it exists. Is there a bette... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T19:28:51.313",
"Id": "36643",
"Score": "0",
"body": "What do you not like about your approach?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T19:33:08.177",
"Id": "36644",
"Score": "0",
"... | [
{
"body": "<p>Your code is as simple as it can get... but if you are wanting to clean up the method then you could do something like this to make it look nicer. </p>\n\n<pre><code>public string ColumnName { get; private set; }\n public string PropertyName { get; private set; }\n private Func<colType, p... | {
"AcceptedAnswerId": "23830",
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T16:12:25.307",
"Id": "23742",
"Score": "4",
"Tags": [
"c#",
"exception-handling"
],
"Title": "Is there a better way to test for the exception conditions?"
} | 23742 |
<p>I am very new to GUI programming, and I'm pretty sure I'm doing it wrong. Please take a look at my code, and suggest some changes. I feel it's way too complicated for what it's actually doing. </p>
<p>For example, here is my main class:</p>
<pre><code>'''
Written by blacksheep
March 4, 2013
'''
#################
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T17:14:24.843",
"Id": "36620",
"Score": "2",
"body": "As per the FAQ, we require that you post code in the question. We understand that the code may be too long to do this, but you should then pick a particular portion of the code yo... | [
{
"body": "<h3>1. Suitability for inspection</h3>\n\n<p>Tom Gilb and Dorothy Graham (in their book <em>Software Inspection</em>) recommend that you inspect code in batches of about 250 lines. They observe that in practice, as the batch size increases, the quality of the inspection (in terms of number of defects... | {
"AcceptedAnswerId": "23782",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T16:38:52.723",
"Id": "23743",
"Score": "2",
"Tags": [
"python",
"tkinter",
"battleship"
],
"Title": "Battleship in Python TKinter"
} | 23743 |
<p>I have a class, which stores an <code>enum</code> to track if my object is modified, newly created, or no change. If the object is modified, I have additional booleans for each field that is modified.</p>
<p>For instance,</p>
<pre><code>public enum status
{
NoChange,
Created,
Modified
}
private bool? ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T17:42:48.210",
"Id": "36628",
"Score": "0",
"body": "Are you manually adding a new `bool?` each time you add a new property? Or are you using something to auto-generate your code? In the former case, this looks like very painful c... | [
{
"body": "<p>I would suggest that you use a Dictionary, with the property as the key and the bool as the value. e.g.</p>\n\n<pre><code>Dictionary<string, bool?> myProperties = new Dictionary<string, bool?>();\n</code></pre>\n\n<p>Use reflection to get all the properties from your object. Then you d... | {
"AcceptedAnswerId": "23804",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T16:45:36.030",
"Id": "23745",
"Score": "6",
"Tags": [
"c#"
],
"Title": "Better Alternative For Storing Multiple Booleans?"
} | 23745 |
<p>I've made my first simple game in HTML5. Unfortunately, it runs so slowly. But there are only few rectangles! On my PC, frame rate is between 20 and 25. I expected something like 60-70 but no 20! You can see this game here: <a href="http://mygames.jcom.pl/" rel="nofollow">http://mygames.jcom.pl/</a> (and you can see... | [] | [
{
"body": "<p>I believe your issue is related to the setInterval, you should at least try not to use it; instead use requestAnimationFrame.</p>\n\n<p>for example here is a link:\n<a href=\"http://paulirish.com/2011/requestanimationframe-for-smart-animating/\" rel=\"nofollow\">http://paulirish.com/2011/requestan... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T18:32:49.770",
"Id": "23747",
"Score": "2",
"Tags": [
"javascript",
"optimization",
"html5"
],
"Title": "Game runs very slowly - optimization"
} | 23747 |
<p>Is there a cleaner way to write:</p>
<pre><code>def b_fname
if mdes_version_is_after?(3.0)
result = c_fname
else
result = response_for("#{birth_baby_name_prefix}.BABY_FNAME")
end
if result.empty?
result = 'your baby'
end
result
end
</code></pre>
| [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2016-01-04T20:22:55.707",
"Id": "215080",
"Score": "0",
"body": "To explain the downvote: could please add more information about the purpose of your code?"
}
] | [
{
"body": "<p>The following version uses the ternary operator, which avoids one assignment:</p>\n\n<pre><code>def b_fname\n if mdes_version_is_after?(3.0)\n result = c_fname\n else\n result = response_for(\"#{birth_baby_name_prefix}.BABY_FNAME\")\n end\n\n result.empty? ? 'your baby' : result\nend\n</... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T20:39:01.967",
"Id": "23751",
"Score": "-1",
"Tags": [
"ruby"
],
"Title": "Getting a name, with fallback behavior"
} | 23751 |
<p>What I want to do is; without leaving the chain, execute some custom/external code (and continue) within the chain. Otherwise; in a deep chain, I will have to re-query for the DOM element to get back where I've left.</p>
<p>The method below allows to execute custom code inside a jQuery chain synchronously or asynch... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T00:28:09.997",
"Id": "36657",
"Score": "0",
"body": "I'm not sure about the necessity of `.queue()` here - why are you adding a function to the default `fx` queue (will be queued after animations when there are pending animations) i... | [
{
"body": "<p>I guess this plugin could be useful, however I think you can drop the async part since it's not any harder to call <code>queue</code> directly.</p>\n\n<p>Also, I am not a huge fan of error swallowing or ignoring invalid calls since it makes the code harder to debug. If there's a call to <code>do</... | {
"AcceptedAnswerId": null,
"CommentCount": "11",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T21:28:56.770",
"Id": "23752",
"Score": "2",
"Tags": [
"javascript",
"jquery"
],
"Title": "$.fn.do() method: Execute other code within a jQuery chain"
} | 23752 |
<p>The code already works, but I just want tips for improving.</p>
<pre><code>import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class Calculator
{
public static void main(String[] args)
{
double initialPrice = 0.00;
double commissionRate = 0;
double discountRate = 0... | [] | [
{
"body": "<p>Interesting, consider the following:</p>\n\n<ul>\n<li><p>For extra DRYness, you could have created a helper function to get a double</p>\n\n<pre><code>private double getDouble( String msg )\n</code></pre></li>\n<li><p><code>computeFinalPrice</code> should probably be private</p></li>\n<li>If you w... | {
"AcceptedAnswerId": "23757",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T23:07:22.777",
"Id": "23756",
"Score": "1",
"Tags": [
"java",
"finance"
],
"Title": "Calculating price after sales commission and discount"
} | 23756 |
<p>This is a method that calls a web service, it uploads an audio file and fetches metadata back.</p>
<p>While the advantage is that there is only one method to call there are a few concerns about it :</p>
<ul>
<li>There is some UI-related code (upload progress)</li>
<li>Some audio-related code (format detection)</li... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-02-10T08:19:36.373",
"Id": "504933",
"Score": "1",
"body": "The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to **simply sta... | [
{
"body": "<ul>\n<li>You <em>should</em> move <code>fileFormat</code> to parameters, this method is doing too much</li>\n<li>Use <a href=\"https://docs.microsoft.com/en-us/dotnet/api/system.iprogress-1?view=net-5.0\" rel=\"nofollow noreferrer\"><code>IProgress<T></code></a> instead of <code>handler</code>... | {
"AcceptedAnswerId": "23771",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-11T23:56:54.313",
"Id": "23758",
"Score": "1",
"Tags": [
"c#",
"design-patterns"
],
"Title": "Appropriate separation of concerns for this case?"
} | 23758 |
<p>I am trying to write a Python script that download an image from a webpage. On the webpage (I am using NASA's picture of the day page), a new picture is posted everyday, with different file names. After download, set the image as desktop. </p>
<p>My solutions was to parse the HTML using <code>HTMLParser</code>, lo... | [] | [
{
"body": "<pre><code># Save the file\nimg = urllib2.urlopen(imgurl)\nlocalFile = open('desktop.jpg', 'wb')\nlocalFile.write(img.read())\nlocalFile.close()\n</code></pre>\n\n<p>For opening file it's recommend to do:</p>\n\n<pre><code>with open('desktop.jpg','wb') as localFile:\n localFile.write(img.read())\... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T00:08:39.580",
"Id": "23759",
"Score": "4",
"Tags": [
"python",
"beginner",
"parsing",
"windows",
"web-scraping"
],
"Title": "Download an image from a webpage"
} | 23759 |
<h1>Background</h1>
<p>A subclass of <code>java.util.Properties</code> attempts to recursively resolve configured properties:</p>
<pre><code>prop_a=Prop A is ${prop_b}
prop_b=Prop B is ${prop_c}
prop_c=Prop C.
</code></pre>
<p>After reading the file, <code>prop_a</code> should be <code>Prop A is Prop B is Prop C</... | [] | [
{
"body": "<ul>\n<li><p>You say \"recursively resolve\", but in fact <code>resolve</code> is not recursive. It returns <code>Prop A is Prop B is ${prop_c}</code> instead of <code>Prop A is Prop B is Prop C</code>, if you call it with <code>Prop A is ${prop_b}</code>. If you call it with <code>prop_a</code>, as ... | {
"AcceptedAnswerId": "23775",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T02:11:40.270",
"Id": "23762",
"Score": "1",
"Tags": [
"java",
"recursion",
"properties"
],
"Title": "Recursive java.util.Properties references"
} | 23762 |
<p>I want to know the correct way to finish up this code at the bottom. I'm thinking there has to be a better way to grab content from one section of your site and displaying it somewhere else with animation attached to it. The Code below seems like it can do better. I post the entire code below, but you might be able ... | [] | [
{
"body": "<p>At first, you are requesting the element <code># + ValUe</code> 4 times. That means jQuery need to search to the entire DOM 4 times to get an element. Cache the value of this element and use that cache variable:</p>\n\n<pre><code>var elem = $('#' + ValUe);\n\nelem.html(...);\n\nelem.find(...);\n</... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T05:51:21.490",
"Id": "23766",
"Score": "1",
"Tags": [
"javascript",
"jquery",
"html",
"jquery-ui"
],
"Title": "Grab Text storing it in a var then adding html method and adding... | 23766 |
<p>I have the following SQL structure (simplified for brevity):</p>
<pre><code>TABLE [Posts]
[Id] INT NOT NULL IDENTITY PRIMARY KEY,
[ParentId] INT NULL,
[Type] INT NOT NULL,
FOREIGN KEY ( [ParentId] ) REFERENCES [Posts] ( [Id] )
FOREIGN KEY ( [Type] ) REFERENCES [PostTypes] ( [... | [] | [
{
"body": "<p>Your code is correct as long as you plan to validate business integrity using triggers.</p>\n\n<p>But I would question whether business validation in SQL Server is a right choice:</p>\n\n<ul>\n<li>You have no means (other than parsing return error string) to process errors on client side.</li>\n<l... | {
"AcceptedAnswerId": "23770",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T05:55:42.317",
"Id": "23767",
"Score": "3",
"Tags": [
"sql",
"sql-server"
],
"Title": "Request review of sql validation trigger"
} | 23767 |
<p>I'm using both Core Data and <code>NSFetchedResultsController</code>. Is there anything I can improve on?</p>
<pre><code>//
// RoutineTableViewController.m
// App
//
// Created by Me on 3/21/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "RoutineTableViewController.h"
#import <Qua... | [] | [
{
"body": "<p>Just briefly looking at your table view controller code, I'd <em>in general</em> suggest a more efficient way of configuring your cells. You have:</p>\n\n<pre><code>- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {\n cell.imageView.image = [UIImage imageNamed... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T06:32:48.330",
"Id": "23769",
"Score": "4",
"Tags": [
"objective-c",
"ios",
"cocoa-touch"
],
"Title": "NSFetchedResultsController implementation"
} | 23769 |
<p>Because we're passing object to Spring Framework in which Jackson classes convert them into JSON as a response, we chose to implement a simpler <code>Tweet</code> class rather than the Twitter4j-provided <code>Status</code> class, which includes numerous data that is irrelevant.</p>
<p>Status class provided by Twit... | [] | [
{
"body": "<p>If the interfaces <code>HashtagEntity</code>, <code>MediaEntity</code>, <code>URLEntity</code>, and <code>UserMentionEntity</code> were subinterfaces of a superinterface <code>Entity</code>, you could refactor the 4 loops into 4 calls to one function that would take <code>Entity[]</code> as one of... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T08:55:29.250",
"Id": "23776",
"Score": "4",
"Tags": [
"java",
"strings",
"twitter",
"hash-map"
],
"Title": "Insert tags around entities in body"
} | 23776 |
<p>This is my second attempt to create asynchronous version of AutoResetEvent.
<a href="https://codereview.stackexchange.com/questions/23522/autoreseteventasync-am-i-missing-something">At first</a> I tried to make it completely lock-less, but it turned out to be impossible.
This implementation contains a lock however ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-14T17:21:44.153",
"Id": "36843",
"Score": "0",
"body": "If it's an `AutoResetEvent`, shouldn't it allow only one continuation to proceed? Your documentation for `Set()` says otherwise."
}
] | [
{
"body": "<p>Your new code seems thread-safe to me. Though there are some small issues:</p>\n\n<pre><code>lock (handler)\n</code></pre>\n\n<p>I think that you should use braces after <code>lock</code>/<code>if</code>/<code>while</code> whenever the following statement is more than a single line, even if the la... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T11:34:01.193",
"Id": "23783",
"Score": "5",
"Tags": [
"c#",
".net",
"multithreading",
"asynchronous",
"async-await"
],
"Title": "Asynchronous version of AutoResetEvent"
} | 23783 |
<p>I wrote a two player Noughts and Crosses game in Python 3, and came here to ask how I can improve this code.</p>
<pre><code>import random
cell = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
board = '\n\t ' + cell[0] + ' | ' + cell[1] + ' | ' + cell[2] + '\n\t-----------\n\t ' + cell[3] + ' | ' + cell[4] + ' | ' + ... | [] | [
{
"body": "<p>Some notes:</p>\n\n<blockquote>\n <p>cell = ['1', '2', '3', '4', '5', '6', '7', '8', '9']</p>\n</blockquote>\n\n<p>Try to be less verbose: <code>cell = \"123456789\".split()</code> or <code>cell = [str(n) for n in range(1, 10)]</code>. Anyway, conceptually it's very dubious you initialize the boa... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T11:42:53.097",
"Id": "23784",
"Score": "9",
"Tags": [
"python",
"game"
],
"Title": "Noughts and Crosses game in Python"
} | 23784 |
<p>I have a card matching game with a model of:</p>
<ul>
<li><code>Card</code></li>
<li><code>Deck</code></li>
<li><code>PlayingCard</code></li>
<li><code>PlayingCardDeck</code></li>
</ul>
<p>And another model called <code>CardMatchingGame</code>.</p>
<p>Now, I had a task to add a button to the view for new game, wh... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T09:38:39.303",
"Id": "36672",
"Score": "0",
"body": "if not Code Review, try at Stackoverflow or GameDev.stackexchange.com"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T11:03:13.243",
"Id": "366... | [
{
"body": "<p>You certainly get points for using <code>IBOutletCollection(UIButton)</code>. But, it's unclear why you want to replace this array with a new one? If you're going to do that it should be this view controller that creates the new buttons and adds them as subviews. Also, if you're going to create th... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T08:52:02.640",
"Id": "23785",
"Score": "6",
"Tags": [
"beginner",
"objective-c",
"ios",
"playing-cards",
"cocoa-touch"
],
"Title": "Logic in a card matching game controlle... | 23785 |
<p>Im trying to solve two problems I see with JSF2 and Spring.</p>
<h1>First</h1>
<ul>
<li><code>@Autowired</code> in <code>@ManagedBean</code> does not work</li>
<li>Nor does <code>@ViewScoped</code> with <code>@Controller</code></li>
<li><code>@ManagedProperty</code> is not type safe and requires setter</li>
</ul>
<h... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-25T12:40:12.810",
"Id": "37535",
"Score": "1",
"body": "You might consider making the service reference transient. `transient SampleService ss;`"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-26T19:35:11.4... | [
{
"body": "<p>You might consider making the service reference transient. </p>\n\n<pre><code>transient SampleService ss;\n</code></pre>\n",
"comments": [],
"meta_data": {
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-26T20:18:34.080",
"Id": "42890... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T13:05:19.420",
"Id": "23790",
"Score": "7",
"Tags": [
"java",
"dependency-injection",
"spring",
"jsf-2",
"serialization"
],
"Title": "Spring autowiring in managed beans wi... | 23790 |
<p>There are some things that I know that need to be fixed, such as <code>mysql_*</code> needing to be converted to PDO, and using a better hash. I am working on building a social networking site, and I've been having issues with some of the <code>mysql</code> like <code>mysql_real_escape_string</code> and implementing... | [] | [
{
"body": "<p><strong>for your register script</strong></p>\n\n<pre><code>$ln = (!empty($_POST['lname'])) ? $_POST['lname'] : '';\n$un = (!empty($_POST['username'])) ? $_POST['username'] : '';\n$em = (!empty($_POST['email'])) ? $_POST['email'] : '';\n$em2 = (!empty($_POST['email2'])) ? $_POST['email2'] : '';\n$... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-03-12T14:58:30.500",
"Id": "23792",
"Score": "3",
"Tags": [
"php",
"pdo"
],
"Title": "Review my PHP login and register script, and profile page, and how to improve them"
} | 23792 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.