body stringlengths 25 86.7k | comments list | answers list | meta_data dict | question_id stringlengths 1 6 |
|---|---|---|---|---|
<p>The task is to compress a string.</p>
<p>eg. "abcbcdabcbcd"</p>
<p>Here as you can see some characters are repeated, so it can be compressed.</p>
<p>"abcbcdabcbcd" -> "(a(bc2)d2)$"</p>
<p>'$' denotes end of string.</p>
<p>My code:</p>
<pre><code>import java.util.*;
class compress
{
public static void main... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-19T19:09:18.037",
"Id": "62728",
"Score": "2",
"body": "Is the double-indent of the first 2 lines of `void main` a paste glitch? FWIW I'm not buying `catch(Exception e){}`."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationD... | [
{
"body": "<p>Your naming is awful. Even <code>void main(String[] args)</code> has been <em>butchered</em> to <code>void main(String[] ar)</code>... and the only identifier that's more than 2 letters in this code, is called <code>found</code> - which implies a <em>search</em>, but the method is called <code>com... | {
"AcceptedAnswerId": "37816",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-19T19:03:40.040",
"Id": "37769",
"Score": "-3",
"Tags": [
"java",
"strings"
],
"Title": "Compressing a string"
} | 37769 |
<p>I'm trying to improve the following code for testability.</p>
<pre><code>public function can_apply_extension()
{
$search_dates = [
Carbon::createFromTimestamp(strtotime($this->billing_verified_to))->subMonth(1),
$this->billing_verified_to
];
$record = ORM::factory('a model')
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T15:55:28.653",
"Id": "62901",
"Score": "1",
"body": "Get rid of all the static calls, because an `ORM::factory` implies a static property that holds a reference to an object. Testing classes with static properties is hard... really ... | [
{
"body": "<p>(I've not coded in PHP recently, my examples are Java or Java-like pseudocode.)</p>\n\n<p>In his <em>Working Effectively with Legacy Code</em> book <em>Michael C. Feathers</em> describes a lot of techniques which help making any code testable. Another good resource is the following article: <a hre... | {
"AcceptedAnswerId": "43246",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-19T20:00:19.603",
"Id": "37776",
"Score": "5",
"Tags": [
"php",
"unit-testing"
],
"Title": "Testable code with ORM factory"
} | 37776 |
<p>On the attached fiddle is what I hope will the be future UI for navigation on my own personal portfolio site. I was hoping you guys could critique the JavaScript I wrote to accomplish the most compatibility with the most browsers. I've tested as far back as IE 7 with this code and it works. Whereas the CSS solution ... | [] | [
{
"body": "<p>For beginner code, that's reasonably good.</p>\n\n<ul>\n<li>Instead of calling <strong>setTimeout()</strong> yourself, why not let jQuery handle the animation for you with <a href=\"http://api.jquery.com/animate/\" rel=\"nofollow\"><code>.animate()</code></a>?</li>\n<li><p>Your <strong>indentation... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-19T21:18:35.123",
"Id": "37782",
"Score": "7",
"Tags": [
"javascript",
"jquery",
"beginner"
],
"Title": "jQuery-animated navigation menu"
} | 37782 |
<p>My needs outpace my abilities. This code (mostly) works, but it is really ugly, doesn't always add correctly, and is in desperate need of some help refactoring. I can't wrap my head around what needs done with it.</p>
<p>I have a SQLite table <code>WorkLog</code> which contains rows of <code>int</code>, <code>lon... | [] | [
{
"body": "<p>Your code is a bit too messy to understand what you are doing - or why you are doing it, but here are some pointers that can get you started:</p>\n\n<ul>\n<li><p>Your method is way too long. Break it up into a couple of sub-methods.</p></li>\n<li><p>Using a <code>List<long[]></code> and usin... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-19T23:30:11.600",
"Id": "37787",
"Score": "3",
"Tags": [
"java",
"android",
"datetime",
"sqlite"
],
"Title": "Searching database, filtering results, adding longs"
} | 37787 |
<p>I have this code that shows date pickers when the browser doesn't support <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local" rel="nofollow noreferrer"><code><input type="datetime-local"></code></a>.</p>
<p>Any tips on optimizing <a href="http://jsfiddle.net/LkpPJ... | [] | [
{
"body": "<p>Yes there is a fair amount of repeated code - e.g. the options:</p>\n<blockquote>\n<pre><code> dateFormat: "yy-mm-dd",\n timeFormat: "hh:mm TT",\n minuteGrid: 10,\n addSliderAccess: true,\n sliderAccessArgs: {\n touchonly: false\n ... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2013-12-20T02:40:57.103",
"Id": "37794",
"Score": "1",
"Tags": [
"javascript",
"performance",
"jquery",
"datetime",
"event-handling"
],
"Title": "Date/Time picker for browsers that d... | 37794 |
<p>Check out the fiddle <a href="http://jsfiddle.net/Hh5jg/1" rel="nofollow">here</a>. This JavaScript will take the row that a user clicks on and make an object with the key coming from the <code>thead</code> element in the table and the value coming from the data in the text in the table cell value. I'm looking for... | [] | [
{
"body": "<p>The selector <code>$('thead > tr th')</code> is not specific enough, if you have multiple tables in the page. You want the headings of the same table that was clicked: <code>$(this).closest('table').find('thead > tr th')</code>.</p>\n\n<p><code>var array</code> is an unsatisfying name. I c... | {
"AcceptedAnswerId": "37798",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T02:50:56.293",
"Id": "37795",
"Score": "2",
"Tags": [
"javascript",
"jquery"
],
"Title": "Get jQuery object from table row click"
} | 37795 |
The manipulation of individual bits. Operators used may include bit-wise and/or (&/|), left-shift (<<), and right-shift (>>). | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T02:51:20.047",
"Id": "37797",
"Score": "0",
"Tags": null,
"Title": null
} | 37797 |
<p>I'm writing a helper for asynchronous operations.
By default, winjs does not provide a way to wait x seconds before the execution of another function. So I decided to write a helper.</p>
<pre><code>(function asyncOperation() {
"use strict";
// --------------------------------------------------------------... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T13:56:07.383",
"Id": "62880",
"Score": "0",
"body": "What ( kind of ) async process are you waiting for ? Can you give us a specific sample ?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T14:02:10.7... | [
{
"body": "<p>I think WinJS already provides this:</p>\n\n<p><code>WinJS.Promise.timeout(timeout)</code> creates a promise that is completed asynchronously after the specified timeout, essentially wrapping a call to setTimeout within a promise. </p>\n\n<p>See also <a href=\"http://msdn.microsoft.com/en-us/libr... | {
"AcceptedAnswerId": "37804",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T10:32:26.723",
"Id": "37802",
"Score": "1",
"Tags": [
"javascript"
],
"Title": "Safer way to wait amount of time"
} | 37802 |
<p>I'm trying to make a program that calculates your k/d ratio (kill/death, which is used in FPS games to make people believe that it's skill), how many kills you need without dying once to reach a goalKD. It also has a part that calculates how many battles you need if you give the program your average battle kills and... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T01:36:06.013",
"Id": "62888",
"Score": "3",
"body": "There is nothing that changes in the `while` loop that affects its condition, so you would get stuck there."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "20... | [
{
"body": "<p>For the kills needed part, you are trying to solve this equation:</p>\n\n<pre><code>k{current} + n\n-------------- = r\n d{current}\n</code></pre>\n\n<p>Where <code>r</code> is the target rate and <code>n</code> is the number you're looking for. Some basic algebra:</p>\n\n<pre><code>n = rd - k\n... | {
"AcceptedAnswerId": "37807",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-19T22:21:49.063",
"Id": "37806",
"Score": "1",
"Tags": [
"performance",
"homework",
"basic-lang"
],
"Title": "Calculating kills and deaths in a game"
} | 37806 |
<p>I have a function - <code>TriggerNotifications</code> - that accepts a <code>NotificationType</code>. The Type determines which settings I should pull from the <code>User</code>. </p>
<p>The code looks like this: </p>
<pre><code>public void TriggerNotification(DbContext db, User user, NotificationType type, stri... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T00:57:30.810",
"Id": "63035",
"Score": "0",
"body": "It's good to be aware what is slow, but unless you actually have a good reason to worry about the performance of this code, don't base your decisions on it."
},
{
"Content... | [
{
"body": "<p>The redundancy is hard to remove and constructions like these make it hard to extend the options later. It would require updates to both data contracts and all classes implementing them.</p>\n\n<p>You could use a delegate instead of a switch/case to improve extensibility, it would not completely r... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T16:31:09.593",
"Id": "37809",
"Score": "4",
"Tags": [
"c#"
],
"Title": "Are redundancy and reflection my only options here?"
} | 37809 |
<p>In computer science, type conversion, type casting, and type coercion are different ways of changing an entity of one data type into another. An example would be the conversion of an integer value into a floating point value or its textual representation as a string, and vice versa. Type conversions can take advanta... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T16:31:10.273",
"Id": "37810",
"Score": "0",
"Tags": null,
"Title": null
} | 37810 |
Converting involves changing data from one data type or format to another. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T16:31:10.273",
"Id": "37811",
"Score": "0",
"Tags": null,
"Title": null
} | 37811 |
<p>Context: I've been learning Python for a few months and I'm able to write codes which do work, but they normally look very ugly and contain a lot of unnecessary code. But I normally struggle to find better ways to do things because of my limited knowledge.</p>
<p>I would like some advice on what I can improve on th... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T18:43:51.657",
"Id": "62933",
"Score": "2",
"body": "What is the API you're working with? Or to put it another way, what does activeDataConnections contain?\n\nMost database modules (eg sqllite) include query functionality which wou... | [
{
"body": "<p>This is what I would do.</p>\n\n<p>First, rename <code>coordinates</code> to <code>coord_list</code> so you can eliminate <code>mylist</code> which is kind of useless since you only use immediately assign it to <code>coordinates</code>. To make things slightly simpler I assigned <code>count</code>... | {
"AcceptedAnswerId": "37824",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T16:46:30.270",
"Id": "37813",
"Score": "4",
"Tags": [
"python"
],
"Title": "Removing redundant lines from script"
} | 37813 |
<p>Here's the current code: </p>
<pre><code> static string GetResources(string header, string filter, string resourceTemplate)
{
string themeName;
if (!TryGetHeaderValue(header, "theme", out themeName)) return "";
var resources = "";
var path = Path.Combine(HtmlPreview.BaseDirec... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T19:18:11.403",
"Id": "62949",
"Score": "5",
"body": "This question appears to be off-topic because it is about understanding the fundamentals of the framework, not a code review."
}
] | [
{
"body": "<p>Strings in C# are immutable which means that this:</p>\n\n<pre><code> resouces += string.Format(...);\n</code></pre>\n\n<p>will create 2 strings: one from <code>string.Format</code> and then the new string created by appending it to the existing string.</p>\n\n<p>A <code>StringBuilder</code> will ... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T17:02:47.660",
"Id": "37815",
"Score": "3",
"Tags": [
"c#",
".net",
"strings"
],
"Title": "Should I create an empty string and append through a foreach loop or should I use String... | 37815 |
<p>I have to protect really sensitive information and I have to do it both ways: encryption and decryption. How safe is it?</p>
<pre><code>function encrypt($mprhase) {
$MASTERKEY = "KEY PHRASE!";
$td = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MC... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T18:24:40.167",
"Id": "62922",
"Score": "2",
"body": "What kind of data are you encrypting? User passwords? Top secret documents? Your e-mail address?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T18... | [
{
"body": "<p>In all reality the safety of the Data can be affected by any part of the transportation process, So just seeing how you encrypt and decrypt the information doesn't really help us help you in determining the safety of the data.</p>\n\n<hr>\n\n<h1>Nothing to do with the Security of the Functions</h1... | {
"AcceptedAnswerId": "37828",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T18:21:37.140",
"Id": "37821",
"Score": "2",
"Tags": [
"php",
"security",
"cryptography"
],
"Title": "Encrypt/decrypt PHP function"
} | 37821 |
<p>I'm pretty new to ASP/MVC but have had some prior programming experience.</p>
<p>I am trying to retrieve statistics about URL clicks - total clicks and unique clicks by IP address. I started with:</p>
<pre><code>ViewBag.ClicksToday = context.EmailLinkClicks
.Where(c => c.CreatedOn == DateTime.Today).Count(... | [] | [
{
"body": "<p>Here's the first thing I came up with. Wrote it in Notepad, so it might not compile exactly as is. </p>\n\n<pre><code>private static int GetClicks(AppContext context, Period period, bool unique)\n{\n int Clicks = 0;\n switch (period)\n {\n var query = context.EmailLinkClicks.AsQuer... | {
"AcceptedAnswerId": "37826",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T18:47:54.747",
"Id": "37823",
"Score": "3",
"Tags": [
"c#",
"asp.net",
"beginner",
"entity-framework",
"asp.net-mvc-4"
],
"Title": "Retrieving statistics about URL clic... | 37823 |
<p>Problem statement is at <a href="http://www.codechef.com/DEC13/problems/MARBLEGF" rel="nofollow">http://www.codechef.com/DEC13/problems/MARBLEGF</a></p>
<blockquote>
<p>Lira is given array A, which contains elements between 1000 and 2000.
Three types of queries can be performed on this array: add a given value ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T19:05:54.970",
"Id": "62943",
"Score": "0",
"body": "How are you timing it? What input values are you using? Also please add a short description of the problem itself *within* the question. Also please describe your approach a littl... | [
{
"body": "<p>Given the constraints, the maximum sum, <em>N</em> * max(<em>A</em>), would be 2000000000, which fits within a Java <code>int</code>. You don't need a <code>long</code>.</p>\n\n<p>Your code is a straightforward implementation of the challenge; there's nothing to micro-optimize. Your only hope is... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T18:54:23.950",
"Id": "37825",
"Score": "5",
"Tags": [
"java",
"performance",
"array",
"mathematics"
],
"Title": "Optimising Funny Marbles"
} | 37825 |
Programming associated with creating and managing networks as well as adding network connectivity to a (set of) programs. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T20:39:40.463",
"Id": "37832",
"Score": "0",
"Tags": null,
"Title": null
} | 37832 |
<p>A structure can be a:</p>
<ul>
<li>A <strong>data structure</strong>: a particular way of storing and organizing data in a computer so that it can be used efficiently.</li>
<li>A <strong>struct</strong> (short for "structure") is a computer science term for a record that is used to store more than one value.</li>
<... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T20:45:14.403",
"Id": "37833",
"Score": "0",
"Tags": null,
"Title": null
} | 37833 |
A structure is a fundamental, tangible or intangible notion referring to the recognition, observation, nature, and permanence of patterns and relationships of entities. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T20:45:14.403",
"Id": "37834",
"Score": "0",
"Tags": null,
"Title": null
} | 37834 |
A block of arbitrary information, or resource for storing information, accessible by the string-based name or path. Files are available to computer programs and are usually based on some kind of persistent storage. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T20:49:49.183",
"Id": "37836",
"Score": "0",
"Tags": null,
"Title": null
} | 37836 |
A generator is a generalization of a subroutine, primarily used to simplify the writing of iterators. The yield statement in a generator does not specify a co-routine to jump to, but rather passes a value back to a parent routine. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T20:52:23.083",
"Id": "37838",
"Score": "0",
"Tags": null,
"Title": null
} | 37838 |
<p><a href="https://en.wikipedia.org/wiki/Syntax_%28programming_languages%29" rel="nofollow">From Wikipedia</a>:</p>
<blockquote>
<p>In computer science, the <strong>syntax</strong> of a computer language is the set of
rules that defines the combinations of symbols that are considered to
be a correctly structure... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T21:00:40.817",
"Id": "37839",
"Score": "0",
"Tags": null,
"Title": null
} | 37839 |
In computer science, the syntax of a programming language is the set of rules that define the combinations of symbols that are considered to be correctly structured programs in that language. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T21:00:40.817",
"Id": "37840",
"Score": "0",
"Tags": null,
"Title": null
} | 37840 |
Microsoft Access, also known as Microsoft Office Access, is a database management system from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software-development tools. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T21:19:39.460",
"Id": "37842",
"Score": "0",
"Tags": null,
"Title": null
} | 37842 |
Portable code can be run with little to no modification in multiple environments. Portable applications can be run from, for example, a USB drive without modifying a computer's environment. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T21:21:38.630",
"Id": "37844",
"Score": "0",
"Tags": null,
"Title": null
} | 37844 |
A formal grammar is a set of production rules that describe how to form strings of valid syntax. Formal grammars are most often used to specify the syntax of a programming language. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T21:26:15.093",
"Id": "37847",
"Score": "0",
"Tags": null,
"Title": null
} | 37847 |
<p>I'm trying to make my code easier to understand by making it more correct and maintainable.</p>
<p>Here's the code I'm trying to simplify:</p>
<pre><code> $(document).ready(function(){
$('.opretbruger').on('click', function(){
if (opretbruger() === true){
}
});
});
var opretbruger = function(){... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T22:06:20.983",
"Id": "62975",
"Score": "0",
"body": "What does `overskulig` mean?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T22:07:37.753",
"Id": "62976",
"Score": "0",
"body": "@Nobo... | [
{
"body": "<p>Let me make sure I understand the problem. You have a number of fields on the page where a value is required; when the user submits the page, and any of the fields are blank, you'd like the page to display a Javascript alert instead of submitting the form. Yes?</p>\n\n<p>I'd suggest you use an u... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T21:58:22.313",
"Id": "37852",
"Score": "1",
"Tags": [
"javascript",
"jquery",
"validation"
],
"Title": "Displaying alerts for blank fields"
} | 37852 |
<p>The question is explained well by examples in the comments below. Also I request verifying complexity: O( n * n!), where n is the number of words in the subsets. Review my code for optimizations, best practices etc.</p>
<pre><code>/**
* Question is better explained by examples:
* 1. given
* i/p subsets - ["... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T11:55:55.570",
"Id": "63012",
"Score": "1",
"body": "I don't get it. What is your algorithm supposed to do?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T15:12:13.943",
"Id": "63080",
"Score... | [
{
"body": "<p>Your <code>getPermutations()</code> fails to generate all permutations. Consider…</p>\n\n<pre><code>public static void main(String[] args) {\n List<String> list = Arrays.asList(args);\n for (String s : getPermutations(list)) {\n System.out.println(s);\n }\n}\n</code></pre>\n... | {
"AcceptedAnswerId": "37894",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T02:57:49.800",
"Id": "37860",
"Score": "2",
"Tags": [
"java",
"algorithm",
"strings",
"combinatorics"
],
"Title": "Determine if a word can be constructed from list of subse... | 37860 |
<p>I'm doing a website in CodeIgniter and I'm loading the content page via jQuery, but I don't know if this is a good practice or not. Could I improve it?</p>
<p><strong>jQuery:</strong> </p>
<pre><code>// Another question here: how can I group the repeated code in a function:
$(function() {
var control = '../Indoa... | [] | [
{
"body": "<p>You might already know this but you can add a library class called 'template' it allows you to make a kind of a masterpage where you can load all different php files, for example your header - content - footer or anything else, seperately into one page.</p>\n\n<p>Your controller will look like thi... | {
"AcceptedAnswerId": "37862",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-20T22:12:46.807",
"Id": "37861",
"Score": "3",
"Tags": [
"javascript",
"php",
"jquery",
"controller",
"codeigniter"
],
"Title": "Loading content in page via jQuery"
} | 37861 |
<p>I'm trying to write a neural network that only requires the user to specify the dimensionality of the network. Concretely, the user might define a network like this:</p>
<pre><code>nn = NN([2, 10, 20, 15, 2]) # 2 input, 2 output, 10 in hidden 1, 20 in hidden 2...
</code></pre>
<p>To do this, I'm trying to adapt so... | [] | [
{
"body": "<p>Here are a bunch of relatively minor comments:</p>\n\n<ul>\n<li>put your imports on separate lines.</li>\n<li>call <code>random.seed</code> in an <code>if __name__ == '__main__':</code> section, not in the global section.</li>\n<li><code>r_matrix</code> is not a very obvious name; <code>random_mat... | {
"AcceptedAnswerId": "37881",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T05:33:40.050",
"Id": "37864",
"Score": "8",
"Tags": [
"python",
"ai",
"machine-learning",
"neural-network"
],
"Title": "Python neural network: arbitrary number of hidden no... | 37864 |
<p><a href="https://codereview.meta.stackexchange.com/a/1281/23788">This week's challenge</a> is essentially about fetching Json data from the Web, and deserializing it into objects. I don't have much time to devote to this one, so what I have is very basic: it displays the names of all pokemons in a WPF ListView:</p>
... | [] | [
{
"body": "<p>If a class such as <code>ResourceReference</code> makes sense as far as wrapping the API is concerned, from a UI standpoint, it's like using POCO's in the UI layer: If the data came from a database through Entity Framework, this code would be displaying the entities. This is a basic implementation... | {
"AcceptedAnswerId": "37886",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T06:34:37.260",
"Id": "37866",
"Score": "15",
"Tags": [
"c#",
"json",
"community-challenge",
"pokemon"
],
"Title": "Gotta catch 'em all!"
} | 37866 |
<p>I have written this InsertSort program in F#. It works, but I am not very happy with it.</p>
<pre><code>let rec SubArrayBegin list n =
list |> Seq.ofList |> Seq.take n |> List.ofSeq
let SubArrayEnd list n =
List.rev (SubArrayBegin (List.rev list) ((List.length list) - n - 1))
let InsertSort... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T11:50:05.087",
"Id": "63011",
"Score": "0",
"body": "What's wrong with `@` and `if`?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T01:55:46.257",
"Id": "63040",
"Score": "0",
"body": "@ ... | [
{
"body": "<ol>\n<li>Function names in F# are usually written in <code>camelCase</code>. (Though members that are not private should use <code>PascalCase</code>, to adhere to general .Net naming conventions.)</li>\n<li><code>SubArrayBegin</code> is not recursive, so it doesn't need to be <code>rec</code>.</li>\... | {
"AcceptedAnswerId": "37883",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T07:05:13.863",
"Id": "37868",
"Score": "4",
"Tags": [
"sorting",
"f#"
],
"Title": "InsertSort F# program"
} | 37868 |
<p>This is my .cs part code where I am calling <code>storeprocedure</code> in LINQ to SQL:</p>
<pre><code>var rr_j_cat = db.allcategories().ToList();//its store procedure calling thousands of rows
if (rr_j_cat.Count() != 0)
{
DataTable dt = new DataTable();//making dynamic datatable
dt.Columns.Add("sub_id"); ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T09:15:22.187",
"Id": "63003",
"Score": "1",
"body": "Can you not have one stored procedure return you the results rather than having to call two?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T03:01:... | [
{
"body": "<p>You asked two things, </p>\n\n<ol>\n<li>Clearer code</li>\n<li>Better performance</li>\n</ol>\n\n<p>I'll try to cover both.</p>\n\n<p>First of all it's unnecessary to convert <code>rr_j_cat</code> and <code>rr_sel_cat</code> to list again!\nSo <code>rr_j</code> and <code>rr_list</code> variables a... | {
"AcceptedAnswerId": "37873",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T07:08:10.347",
"Id": "37869",
"Score": "2",
"Tags": [
"c#",
"asp.net",
"sql-server",
"linq-to-sql"
],
"Title": "How to make my code faster and easier?"
} | 37869 |
<p>I would like to ask you for a code review of my c++11 Thread Pool implementation. Your constructive criticism is welcome! Could you give me some ideas how to extend it?</p>
<p>The main idea is to synchronise access to tasks with condition variable.</p>
<h2>ThreadPoolExecutor.cpp</h2>
<pre><code>#include "ThreadPo... | [] | [
{
"body": "<h1>ThreadManager.h</h1>\n\n<p>What is Task.h? Why are you including it? I see no names that aren't covered by the standard headers you include.</p>\n\n<p>There's no apparent order to your private members. You mix methods and data members; it looks like the members are added in the order they were wr... | {
"AcceptedAnswerId": "37888",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T12:17:22.623",
"Id": "37878",
"Score": "4",
"Tags": [
"c++",
"multithreading",
"c++11",
"thread-safety",
"asynchronous"
],
"Title": "simple ThreadPool implementations"
... | 37878 |
<p>I'm looking for code review of part of my replacement of timeout() project. Namely, feedback on SleeperNotifier class:
<a href="https://github.com/ledestin/frugal_timeout/blob/master/lib/frugal_timeout.rb#L125" rel="nofollow">https://github.com/ledestin/frugal_timeout/blob/master/lib/frugal_timeout.rb#L125</a></p>
... | [] | [
{
"body": "<p>How do you cancel a sleep once it starts? I would expect that calling <code>.expireAt(nil)</code> might accomplish that. However, if <code>@expireAt</code> is nil, <code>calcTimeLeft()</code> crashes.</p>\n\n<p>Alternatively, one might try to call <code>.onExpiry(nil)</code>, but you don't handl... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T13:08:37.990",
"Id": "37879",
"Score": "2",
"Tags": [
"ruby",
"multithreading"
],
"Title": "Sleep and background wakeup system"
} | 37879 |
<p>I believe any data structure can be converted to RDF, and I wrote the
subroutine below which sort of does this, at least for arbitrarily
complex hashes. </p>
<p>However, I'm unhappy with it because: </p>
<ul>
<li><p><code>$hash2rdf_count</code> should not be global. I don't see an easy fix for this. </p></li>
<l... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T23:52:41.787",
"Id": "63032",
"Score": "0",
"body": "Could you provide an example of usage and expected output?"
}
] | [
{
"body": "<p>I'm not sure what you're trying to do, so I'll just review the code itself, not what you're trying to do.</p>\n\n<p>I looked into the whole script on GitHub and was <em>shocked</em> to see that you didn't <code>use strict; use warnings</code>. This would usually abort any review, but let's continu... | {
"AcceptedAnswerId": "37903",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T16:10:16.620",
"Id": "37882",
"Score": "4",
"Tags": [
"recursion",
"perl"
],
"Title": "Data structure to RDF"
} | 37882 |
<p>Request for optimization, good practices, recommendations.</p>
<pre><code>class NodeMaxDepth {
private final NodeMaxDepth parent;
public NodeMaxDepth (NodeMaxDepth parent) {
this.parent = parent;
}
public NodeMaxDepth getParent() {
return parent;
}
}
/**
* Given a l... | [] | [
{
"body": "<ol>\n<li><p>You shouldn't name your classes which form the data structure you operate on according to the problem you are trying to solve. The classes should be named according to their function in the data structure. Thus <code>NodeMaxDepth</code> should be simply <code>Node</code>. This also remov... | {
"AcceptedAnswerId": "37910",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T21:04:53.437",
"Id": "37890",
"Score": "1",
"Tags": [
"java",
"algorithm",
"tree",
"hash-map"
],
"Title": "Max depth of tree when all parent pointers are provided"
} | 37890 |
<p>I'm currently trying to improve my coding skills, so I'm trying to code a <em>Tic Tac Toe</em> game. At one point a "win check" is needed.<p>I'm using this code to check:</p>
<pre><code>public void CheckWin(States state)
{
if(fieldA1.GetState == state && fieldA2.GetState == state && fieldA3.G... | [] | [
{
"body": "<p>There should only be eight ways to win; you have nine <code>ReportWin()</code>s. This one got listed twice:</p>\n\n<pre><code>fieldA2.GetState == state && fieldB2.GetState == state && fieldC2.GetState == state\n</code></pre>\n\n<p>Considering that you've named your squares as inde... | {
"AcceptedAnswerId": "37892",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T21:09:28.430",
"Id": "37891",
"Score": "5",
"Tags": [
"c#",
"game"
],
"Title": "Simplifying `if` statements in Tic Tac Toe function"
} | 37891 |
<p>I've just completed my first Ruby game. It's a modified BlackJack type game, called Hot 18.
I've used all methods for this Ruby game. It's a one-player game, but you can play with 1, 2, or 3 hands.</p>
<p>I would like to make it shorter and more efficient. I know it's kinda long, so I'm not asking you to go over ev... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T04:53:38.280",
"Id": "63047",
"Score": "1",
"body": "*where should I go from here? How can I make it visual? What program should I use? How to start that next step?* These requests are off-topic, but the other review requests can st... | [
{
"body": "<p>There is some awkward recursion and mutual recursion being used for flow control:</p>\n\n<ul>\n<li><code>getnumberofhands()</code> calls itself if the input fails validation.</li>\n<li><code>hitorstay()</code> calls itself if the input fails validation.</li>\n<li><code>newround()</code> calls <cod... | {
"AcceptedAnswerId": "37900",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-21T23:54:10.187",
"Id": "37895",
"Score": "8",
"Tags": [
"optimization",
"ruby",
"beginner",
"game",
"playing-cards"
],
"Title": "Hot 18 game (modified Blackjack)"
} | 37895 |
<p>In a question I answered I posted the following code:</p>
<pre><code>#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
int main()
{
fstream iFile("names.txt", ios::in);
// This does not work so replacing with code that does
// iFile >> file;
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T10:00:42.273",
"Id": "63060",
"Score": "0",
"body": "Is the code all inside `main()`? You can't have free-floating code like that in C++."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T21:42:00.323",... | [
{
"body": "<p>Instead of constructing an <code>fstream</code>, reading it all into a <code>string</code> (which is misleadingly named <code>file</code>, by the way), and creating an <code>istringstream</code> from that, why not just create an <code>ifstream</code> and call <code>getline</code> on it directly?</... | {
"AcceptedAnswerId": "37919",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T07:52:49.990",
"Id": "37901",
"Score": "3",
"Tags": [
"c++",
"strings",
"c++11",
"csv",
"io"
],
"Title": "Reading in a file and performing string manipulation"
} | 37901 |
<p>I have written this code for BubbleSort in F#. Can you review and let me know how I can do this in most functional way.</p>
<pre><code>let rec getHighest list =
match list with
| [x] -> x
| [x; y] when x > y -> x
| [x; y] -> y
| hd1 :: hd2 :: tl when hd1 > hd2 -> getHighest (... | [] | [
{
"body": "<p>The first part could be rewritten as</p>\n\n<pre><code>match list with\n| hd1 :: hd2 :: tl when hd1 > hd2 -> getHighest (hd1 :: tl)\n| hd1 :: hd2 :: tl -> getHighest (hd2::t1)\n| hd1 :: [] -> hd1\n| _ -> failwith \"unknown pattern\"\n</code></pre>\n\n<p>which is significantly simple... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T08:08:57.023",
"Id": "37902",
"Score": "1",
"Tags": [
"functional-programming",
"sorting",
"f#"
],
"Title": "Review my F# BubbleSort Program"
} | 37902 |
<p>I have written the following program to implement merge sort in F#.</p>
<p>Can you please review this and let me know how can I write this in the most functional way (also most efficient and concise)?</p>
<p>In my recursion call, <code>mergeSort</code> is called again twice. I think it will be great if these two c... | [] | [
{
"body": "<p>A good start if you want to see a functional approach to a problem would be looking up a Haskell implementation. Poor guys are doomed to do things the functional way, so we might just as well use that - <a href=\"http://en.literateprograms.org/Merge_sort_%28Haskell%29\" rel=\"nofollow\">here's</a>... | {
"AcceptedAnswerId": "38228",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T08:53:53.757",
"Id": "37904",
"Score": "1",
"Tags": [
"recursion",
"functional-programming",
"sorting",
"f#",
"mergesort"
],
"Title": "Merge Sort Program"
} | 37904 |
<p>I have been working on a javascript heavy project. There are sales, purchases, reports etc. What I've done is created a separate module for each i.e. a separate module for each i.e. a separate one for sale, one for purchase and so on. I am posting one of my modules, all the others have same structure. Can anyone ple... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T09:29:30.940",
"Id": "63057",
"Score": "0",
"body": "Do you intend for each module to use it's own global namespace object, rather than just have one master namespace object that each module could plug its own object into?"
},
{... | [
{
"body": "<p>In short,</p>\n\n<p>your code looks good until <code>$.ajax</code> where far to many things happen, more specifically too many things happen in <code>success</code>.</p>\n\n<p>The funny thing there is that it would look already a lot better if you took a generic approach to deal with the grouping.... | {
"AcceptedAnswerId": "38006",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T09:19:15.100",
"Id": "37906",
"Score": "2",
"Tags": [
"javascript",
"jquery",
"design-patterns",
"modules"
],
"Title": "Javascript code pattern"
} | 37906 |
<p>OK... last sort of the day and probably the most fun. F# is really awesome.</p>
<pre><code>let rec quickSort list =
match list with
| [] -> []
| [x] -> [x]
| hd :: _ ->
quickSort (List.filter (fun x -> x < hd) list) @ hd :: quickSort (List.filter (fun x -> x > hd) list... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T10:41:51.133",
"Id": "63062",
"Score": "1",
"body": "This will probably drop any duplicate elements as `x !< hd` and `x !> hd`"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T18:20:19.227",
"Id": ... | [
{
"body": "<p>I'd:</p>\n\n<ul>\n<li>exclude unnecessary duplication (<code>List.filter</code> etc.)</li>\n<li>drop separate match rule for the list of one element</li>\n<li>rely on type inference</li>\n<li>use more succinct form of pattern matching</li>\n</ul>\n\n<p>Something like this:</p>\n\n<pre><code>let re... | {
"AcceptedAnswerId": "37989",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T09:58:24.340",
"Id": "37907",
"Score": "1",
"Tags": [
"functional-programming",
"sorting",
"f#",
"quick-sort"
],
"Title": "Review my F# QuickSort Program"
} | 37907 |
<p>I am new to JavaScript, HTML and CSS, although not to programming.</p>
<p>I wanted to style 'select' dropdowns, so I wrote this:</p>
<p>What noob mistakes am I making? Is this a good or evil use of JS?</p>
<pre><code><head>
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.cs... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T12:30:12.117",
"Id": "63260",
"Score": "0",
"body": "Do I conclude that no-one knows if this is good or evil, or that it was so evil (or good) that it left everyone speechless?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"Cr... | [
{
"body": "<h1>Tip for your code:</h1>\n\n<ul>\n<li>Use <code>$name</code> for var names that represent a jQuery selection, nor for a member (it is the convention).</li>\n<li>Since you use jQuery, consider writing a plugin extending <code>jQuery.fn</code> instead of prototyping</li>\n</ul>\n",
"comments": [... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T10:02:14.717",
"Id": "37908",
"Score": "4",
"Tags": [
"javascript",
"jquery",
"beginner"
],
"Title": "Styling <select> dropdowns with jQuery"
} | 37908 |
<p>I'm looking for feedback (both general Java, and Twitter specific) on how I'm getting the Twitter handles of everyone who retweeted me over the last 200 Tweets. Comments welcome. </p>
<pre><code>package twitone;
import java.util.ArrayList;
import twitone.structure.BaseTwitterClass;
import twitone.structure.TwitAp... | [] | [
{
"body": "<p>GOing through some general style issues first:</p>\n\n<ul>\n<li><code>getmyretweeters</code> is a class, and should have Camel-Case capitalization -> <code>GetMyRetweeters</code>. I would prefer <code>MyRetweeters</code> with a method <code>get()</code>.</li>\n<li>Your class should not have the st... | {
"AcceptedAnswerId": "37913",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T12:17:40.010",
"Id": "37911",
"Score": "2",
"Tags": [
"java",
"twitter"
],
"Title": "Getting the list of people who RT'd a particular Twitter account (using Twitter4J)"
} | 37911 |
<p>I'm making a Hangman game and it seems that my code doesn't provide me much freedom with using layouts. I added an image to my <code>JFrame</code> then I added a <code>JPanel</code> to my image which I'm using for all the <code>JLabel</code>s and <code>JTextField</code>s but it seems to me that it's inefficient beca... | [] | [
{
"body": "<p>You will need to do two things:</p>\n\n<ol>\n<li>Split your image into multiple pieces that will be loaded into different panels.</li>\n<li>Use appropriate layout managers when adding components so that you can control how components are arranged. <a href=\"http://docs.oracle.com/javase/tutorial/... | {
"AcceptedAnswerId": "37918",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T18:49:00.440",
"Id": "37916",
"Score": "3",
"Tags": [
"java",
"performance",
"functional-programming",
"homework",
"hangman"
],
"Title": "Hangman game background image ... | 37916 |
<p>In C++11, it is en vogue to use small lambda expressions to produce ad-hoc predicates. However, sometimes it's fun to create predicates in a functional, "point-free" way. That way, no function bodies need to be inspected, the code is mildly self-documenting, and it's a great icebreaker at parties.</p>
<p>Suppose I ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T17:53:30.420",
"Id": "63168",
"Score": "0",
"body": "Note: `bind` also doesn't work: `std::not1(std::bind(&std::vector<int>::empty, std::placeholders::_1))`"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-1... | [
{
"body": "<p>I think your way works, but there are other solutions:</p>\n\n<p>In C++98, there is actually an <code>std::mem_fun_ref</code> function.<br>\nIn C++11, there is the <code>std::ref</code> and <code>std::cref</code> functions. </p>\n\n<pre><code>// VS2012 doesn't have uniform initialization, so this... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T19:00:47.007",
"Id": "37917",
"Score": "8",
"Tags": [
"c++",
"c++11",
"template-meta-programming",
"higher-order-functions"
],
"Title": "Functional composition of member funct... | 37917 |
<p>Given an array, find any three numbers which sum to zero. </p>
<p>This problem is a continuation of a code kata in <a href="https://codereview.stackexchange.com/questions/23996/given-an-array-find-any-three-numbers-which-sum-to-zero">Python</a> . I'm learning Scala and would like feedback on more efficient, clean... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-29T17:44:53.123",
"Id": "63707",
"Score": "0",
"body": "Thanks for the feedback. I was not able to package functions outside an object or class. I also ended up playing around with Scala traits and pattern matching to test out multip... | [
{
"body": "<p>If you only want to return the first such combination what about doing something like this instead of the for loop?</p>\n\n<pre><code>def process(arr: Array[Int], size: Int = 3): Array[Int] = {\n arr.combinations(size).find(_.sum == 0).getOrElse(throw new SumToZeroNotFound)\n}\n</code></pre>\n\n<... | {
"AcceptedAnswerId": "38208",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T21:58:56.217",
"Id": "37922",
"Score": "3",
"Tags": [
"algorithm",
"scala"
],
"Title": "Given an array, find any three numbers which sum to zero"
} | 37922 |
<p>I had a somewhat interesting issue. I had to take an array and turn it into a string with a set of delimiters; then later on take that string and turn it back into an array, splitting at the same delimiters. The twist was the string could be contain anything (including the delimiters).</p>
<p>I feel like I over-e... | [] | [
{
"body": "<p>Not bad. I just have a few nitpicks.</p>\n\n<p>You can iterate over characters of a string directly without splitting it into an array first:</p>\n\n<pre><code>for ($i = 0; $i < strlen($string); $i++) {\n $char = $string[$i];\n ...\n}\n</code></pre>\n\n<p>I believe that the PHP interpret... | {
"AcceptedAnswerId": "37928",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T23:00:36.340",
"Id": "37923",
"Score": "3",
"Tags": [
"php",
"strings"
],
"Title": "Escaped explode/implode function"
} | 37923 |
Programming questions involving digitally-represented playing cards. This includes representing cards and decks in data structures, user interfaces for manipulating cards in a virtual fashion, and implementing correct algorithmic shuffling. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T23:05:25.667",
"Id": "37925",
"Score": "0",
"Tags": null,
"Title": null
} | 37925 |
The Fibonacci sequence is the sequence defined by F(0) = 0, F(1) = 1, F(n + 2) = F(n) + F(n + 1). The first few terms are 0, 1, 1, 2, 3, 5, 8. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T23:06:19.247",
"Id": "37927",
"Score": "0",
"Tags": null,
"Title": null
} | 37927 |
<p>I have reworked my code as suggested from my previous question: <a href="https://codereview.stackexchange.com/questions/37860/determine-if-a-word-can-be-constructed-from-list-of-subsets/37894#37894">Determine if a word can be constructed from list of subsets</a>.</p>
<p>Please instruct me on the complexity along wi... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T02:37:13.207",
"Id": "63125",
"Score": "1",
"body": "I believe you haven't thought this through. According to my interpretation, I would expect `targetFromSubSets(…, \"endul\")` to be `true`, but it would print `false`."
},
{
... | [
{
"body": "<ol>\n<li><p>After pressing <kbd>Ctrl</kbd>+<kbd>F</kbd> (code format) in Eclipse the javadoc will be this:</p>\n\n<pre><code>/**\n * Question is better explained by examples: 1. given i/p subsets - [\"un\", \"xy\",\n * \"te\", \"i\", \"d\"] and i/p string is : united should result in true. and i/p\n... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T23:42:04.730",
"Id": "37930",
"Score": "3",
"Tags": [
"java",
"algorithm",
"strings",
"combinatorics"
],
"Title": "Determine if a word can be constructed from list of subsets ... | 37930 |
<p>I wrote a python model for the game "snake" that I'm not really satisfied with.</p>
<p>My intention was to separate the game logic from the drawing and input handling (which worked quite well) but I've got several points which I don't know how to solve better.</p>
<ol>
<li><p>To use this model one needs to initial... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T00:18:20.527",
"Id": "63116",
"Score": "0",
"body": "You might be interested in [this question](http://codereview.stackexchange.com/q/24267/11728) and its answer."
}
] | [
{
"body": "<h3>1. Answers to your questions</h3>\n\n<ol>\n<li><p><strong>Callbacks</strong>. Why not use a <em>return value</em> intead?</p>\n\n<pre><code>def step(self):\n \"\"\"Advance the game one step.\n Return a pair of Booleans (game over, ate food).\n\n \"\"\"\n game_over = self.head in self.... | {
"AcceptedAnswerId": "37981",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-22T23:58:18.287",
"Id": "37931",
"Score": "6",
"Tags": [
"python",
"game",
"interface",
"callback"
],
"Title": "Python model for a \"snake\"-like game"
} | 37931 |
<p>I am trying to solve a bioinformatics problems from a <a href="https://beta.stepic.org/Bioinformatics-Algorithms-2/An-Explosion-of-Hidden-Messages-4/#step-4" rel="nofollow">Stepic course</a>.</p>
<p><strong>The problem posed</strong>: find clumps of the same pattern within a longer genome.</p>
<p><strong>Motivatio... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T03:26:53.373",
"Id": "63128",
"Score": "1",
"body": "Your `patternOccurances` function won't work properly: it doesn't check patterns beginning at the first character. And for the rest, you may want to take a look at [`Counter` from... | [
{
"body": "<p>\"Occurrances\" should be spelled as \"occurrences\".</p>\n\n<p>The core of your strategy is this loop from <code>frequentPatterns()</code>:</p>\n\n<pre><code>for i in range(len(text)-k + 1): #iterate over the valid length of the string\n a = text[i:i+k]\n if a in words:\n words[a] = words[a]... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T00:54:57.180",
"Id": "37932",
"Score": "7",
"Tags": [
"python",
"performance",
"bioinformatics"
],
"Title": "Genome string clump finding problem"
} | 37932 |
<p>Which one of these two is better?</p>
<p>This one:</p>
<pre><code>middleware.response_redirect = function(){
return function (req, res, next){
var redirect = function(){
if(req.form.redirect) return url.parse(req.form.redirect);
return {
protocol: "http",
... | [] | [
{
"body": "<p>How about a ternary operator?</p>\n\n<pre><code>var redirect = req.from.redirect\n ? url.parse(req.from.redirect)\n : {\n protocol: 'http',\n hostname: config.domain,\n pathname: 'thanks'\n };\n</code></pre>\n\n<p>Looks cleaner in my opinion.</p>\n",
"comments": [],
"meta_data"... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T04:02:10.047",
"Id": "37933",
"Score": "4",
"Tags": [
"javascript",
"node.js",
"comparative-review",
"express.js"
],
"Title": "I'm torn between conditionals and abrupt return ... | 37933 |
<p>Follow-up posted -> <a href="https://codereview.stackexchange.com/q/38016/18427">Follow up to Pay Rate Calculator</a></p>
<hr>
<p>This little bit of code is just some code that I wrote from a flowchart at the beginning of a programming and logic book that I have added some to. I tried to create it as an object.</p... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T10:03:30.090",
"Id": "63142",
"Score": "1",
"body": "`payCheck = PayRateCalculator` should be enough to raise an eyebrow."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T14:16:28.603",
"Id": "6315... | [
{
"body": "<ol>\n<li><p>The standard naming convention for properties is <code>PascalCase</code> in C#.</p></li>\n<li><p>I try and give default \"magic constants\" a name. In this case I admit it's fairly obvious however you never really know what your code will turn into. It is also good to form habits so you ... | {
"AcceptedAnswerId": "37964",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T06:53:52.293",
"Id": "37939",
"Score": "8",
"Tags": [
"c#",
"beginner",
"console"
],
"Title": "Simple pay rate calculator"
} | 37939 |
<p>I want to combine elements in different lists.
For example, here are 3 lists.</p>
<pre><code>list_a : [ 1,2,3 ]
list_b : [ 4,5,6 ]
list_c : [ 7,8 ]
</code></pre>
<p>Selecting elements from <code>list_b</code> and <code>list_c</code> is mutually exclusive. When including an element from <code>list_b</code>, I'd li... | [] | [
{
"body": "<p>The <code>itertools</code> library has a function called <a href=\"http://docs.python.org/3/library/itertools.html#itertools.product\" rel=\"nofollow\"><code>product</code></a>. You can rewrite your snippet as:</p>\n\n<pre><code>global sum_list=itertools.product(list_a, list_b, list_bb) + itertool... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T07:36:31.170",
"Id": "37941",
"Score": "2",
"Tags": [
"python",
"combinatorics",
"python-2.x"
],
"Title": "Produce product of lists"
} | 37941 |
<p>I am constructing a binary tree. Let me know if this is a right way to do it. If not please tell me how to?? I could not find a proper link where constructing a general binary tree has been coded. Everywhere BST is coded.</p>
<pre><code> 3
/ \
1 4
/ \
2 5
</code></pre>
<p>This is the binary tree which i... | [] | [
{
"body": "<p>Your code does represent the tree that you drew. However, the code doesn't implement the logic for determining <em>where</em> to place nodes within a binary search tree; instead, you hard-coded that logic in your <code>main()</code> function. A useful implementation of <code>Binarytreenode</code... | {
"AcceptedAnswerId": "37948",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T08:29:08.277",
"Id": "37944",
"Score": "3",
"Tags": [
"java",
"object-oriented",
"tree"
],
"Title": "Constructing a binary tree in java"
} | 37944 |
<p>Single Instruction, Multiple Data describes CPU instructions that process many operands in parallel. Examples of SIMD instruction sets include AltiVec on PowerPC, SSE and MMX on Intel x86, and 3DNow! on AMD.</p>
<p>Related tag: <a href="/questions/tagged/gpgpu" class="post-tag" title="show questions tagged 'gp... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T10:02:44.490",
"Id": "37950",
"Score": "0",
"Tags": null,
"Title": null
} | 37950 |
Single Instruction, Multiple Data describes CPU instructions that process many operands in parallel. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T10:02:44.490",
"Id": "37951",
"Score": "0",
"Tags": null,
"Title": null
} | 37951 |
<p>Given the test code:</p>
<pre><code>import struct
buf = bytearray(b'\xef\xf8\t\xf2')
number = struct.unpack("<I", buf)[0]
</code></pre>
<p>How do I cleanly make it work both under Python 2.6 and Python 3.3? The problem is that struct.unpack in Python 2.6 seems to expect a str object (not unicode), so the only w... | [] | [
{
"body": "<p>Why not just call <code>bytes</code>?</p>\n\n<pre><code>number = struct.unpack('<I', bytes(buf))[0]\n</code></pre>\n\n<p>In Python 2.6:</p>\n\n<pre><code>Python 2.6.8 (unknown, Aug 13 2012, 22:19:05) \n...\n>>> import struct\n>>> struct.unpack('<I', bytes(bytearray(b'ABCD')... | {
"AcceptedAnswerId": "37961",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T15:17:40.143",
"Id": "37959",
"Score": "4",
"Tags": [
"python",
"python-3.x"
],
"Title": "struct.unpack on a bytearray that works under Python 2.6.6, 2.7 and 3.3?"
} | 37959 |
<p>I've been writing a simple code just for fun:</p>
<p>This is a simple WinForms application with which you can measure your typing speed. There are three controls on it, doing the following:</p>
<ul>
<li><code>rtbResults</code> - The one where you need to be as quick as possible.</li>
<li><code>textBox1</code> - Th... | [] | [
{
"body": "<p>Your code seems to me to be as efficient as reasonable for the application you are writing...</p>\n\n<p>... but what you want/intend to do with it is unreasonable.... but first:</p>\n\n<ul>\n<li><p>The method resetting the time is not very practical</p>\n\n<pre><code>private void textBox1_TextChan... | {
"AcceptedAnswerId": "37963",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T15:22:16.997",
"Id": "37960",
"Score": "8",
"Tags": [
"c#",
"performance",
"game"
],
"Title": "WinForms typing speed game"
} | 37960 |
<p>As a student of C# right now, I am trying my best to get a grasp on many of the systems being taught. I just completed Week 1 of a C# 102 class and the class was assigned a bit of homework. I am curious, from a beginners point of view, how you might restructure this code to make it more readable and understandable.<... | [] | [
{
"body": "<p>A huge amount of that code is 'garbage', afraid to say.</p>\n\n<p>You already have all the basic pet data stored in the <code>Pet</code> class... so there is no need to duplicate it all in each pet type class (Dog/Cat, etc.).</p>\n\n<p>For example, your <code>Cat</code> class should remove all the... | {
"AcceptedAnswerId": "37991",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T15:26:27.663",
"Id": "37962",
"Score": "8",
"Tags": [
"c#",
"design-patterns",
"beginner",
"classes"
],
"Title": "Abstract Pet class"
} | 37962 |
<p>I am writing up a class to handle various templates to be used in a web application. Each template contains various placeholders which will need to be replaced at the time of the build. I am wondering if the method I am using is the best solution, or if I should consider something else. At the moment I have two sepa... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T18:51:12.627",
"Id": "63175",
"Score": "2",
"body": "Your solution sounds fine. By the way, \"duplicitous\" means \"treacherous\" and has nothing to do with duplicates :)"
}
] | [
{
"body": "<p>To answer just the question in the title;\nYour solution seems fine to me; <code>addMultiplePlaceholders()</code> is a utility method that acts as a wrapper for <code>addPlaceholder()</code></p>\n\n<p><strong>Note</strong> there's a bug in your code; <code>addMultiplePlaceholders()</code> calls <c... | {
"AcceptedAnswerId": "38139",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T16:05:17.987",
"Id": "37966",
"Score": "1",
"Tags": [
"php"
],
"Title": "Handling templates for a web application"
} | 37966 |
<p>Basically, this code takes a keyword and an array of strings, then sorts them based on two things: the number of characters shared with the key, and the distance between them.(As a side note, would this properly be called a sort, not a search?)</p>
<pre><code>def search(key, list)
# Format for everything pushed t... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T19:40:04.490",
"Id": "63182",
"Score": "1",
"body": "You appear to be trying to do fuzzy text matching. Consider using an [existing solution](https://github.com/seamusabshere/fuzzy_match), [another existing solution](https://github... | [
{
"body": "<ul>\n<li>Blocks longer than one line are conventionally written using <code>do</code>…<code>end</code> rather than braces.</li>\n<li><p>Code of the form</p>\n\n<pre><code>out = []\nlist.each { |l| ... out.push(something) }\n</code></pre>\n\n<p>… would be better expressed as</p>\n\n<pre><code>out = l... | {
"AcceptedAnswerId": "37980",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T17:36:55.487",
"Id": "37971",
"Score": "4",
"Tags": [
"algorithm",
"ruby",
"beginner",
"search",
"edit-distance"
],
"Title": "Simple fuzzy text search algorithm"
} | 37971 |
<p>I created a weather widget in JavaScript that requests the current weather from Yahoo. The weather request returns a code which corresponds with a current weather image. I don't like Yahoo's images, so I use my own CSS classes that correspond with my own images. Consequently, the following code returns the correct C... | [] | [
{
"body": "<p>This sort of thing, with a finite set of coditions, is typically done using an array:</p>\n\n<pre><code>var codeIcons=[\n [\"basecloud\", \"wind\"],\n [\"basecloud\", \"rain\"],\n [\"basecloud\", \"rain\"],\n [\"basecloud\", \"thunder\"],\n [\"basecloud\", \"thunder\"],\n ... | {
"AcceptedAnswerId": "37990",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2013-12-23T17:55:58.667",
"Id": "37974",
"Score": "15",
"Tags": [
"javascript"
],
"Title": "Mapping Yahoo weather codes to CSS classes"
} | 37974 |
<p>I am/have been building a game for a long time now. The game is a web browser based system, and data is stored using <code>JSON</code> stored in <code>RavenDB</code>.</p>
<p>One thing I am very constantly running into as a problem is the notion of <code>Requirements</code>. Anyone who has played a game, particularl... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T20:00:40.783",
"Id": "63191",
"Score": "1",
"body": "Have you seen [Specification Pattern](http://en.wikipedia.org/wiki/Specification_pattern)?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T00:02:57... | [
{
"body": "<p>I have never written code against a RavenDB, and very seldom use Json (actually, \"never\" is almost accurate). The way I see it, the classes that end up Json-serialized and persisted to the database, are analoguous to <em>Entities</em> (Entity Framework), or <em>POCO</em>'s.</p>\n\n<p>They are pa... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T19:29:02.590",
"Id": "37982",
"Score": "8",
"Tags": [
"c#",
"json"
],
"Title": "\"Game\" Engine Requirements System"
} | 37982 |
<p>I feel like I don't understand how polymorphism works in Python. Here is something I put together.</p>
<pre><code>class _Tag(object):
def __init__(self):
#DisjointedTag and JoinedTag will bypass __init__.
#Also, self will not be defined within this class.
#Bottom line, this class is just... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T21:34:39.203",
"Id": "63194",
"Score": "0",
"body": "I get `SyntaxError: invalid syntax` when I try to run your code. At Code Review we review *working* code."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013... | [
{
"body": "<p>I'm a bear of very little brain, so I don't really understand what you are trying to achieve, or why you think polymorphism will help you achieve it.</p>\n\n<p>But I did notice some problems with your code:</p>\n\n<ol>\n<li><p>There's no documentation.</p></li>\n<li><p>There are no test cases.</p>... | {
"AcceptedAnswerId": "37997",
"CommentCount": "10",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T20:10:25.510",
"Id": "37987",
"Score": "0",
"Tags": [
"python",
"polymorphism"
],
"Title": "Understanding polymorphism in Python"
} | 37987 |
<p>I have attached two scripts which calculate the most popular songs according to zipf's law from the following standard input:</p>
<pre><code>6 3
100 one
50 two
10 three
30 four
5 five
10 six
</code></pre>
<p>The first line details the number of songs to be input followed by the number of songs to return. Each line... | [] | [
{
"body": "<p>I must confess that I do not understand what you're trying to achieve and how Zipf's law come into play !\nBut I've some suggestions about the code itself :</p>\n\n<ul>\n<li>Use meaningful variable names.</li>\n<li>Concatenating strings only to split the result afterward is terribly costly, for no... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T00:17:34.330",
"Id": "38001",
"Score": "1",
"Tags": [
"python",
"algorithm",
"performance"
],
"Title": "Optimizing/Cleaning up Python Script for Zipf's Law"
} | 38001 |
<p>Any suggestions on how to shorten this would be greatly appreciated. This code takes three parameters through the URL and displays a page with targeted ads. I especially need help on how to cut down the three sections where I replace <code>%20</code> with spaces. Also, here is the URL with sample parameters - <a hre... | [] | [
{
"body": "<p>Your getParam code has a bug and cannot possibly work..</p>\n\n<pre><code>function getParam(paramName){ //Look for parameters\n var prmstr = window.location.search.substr(1);\n var prmarr = prmstr.split (\"?\"); //This has to be ampersand!!\n var params = {};\n\n for ( var i = 0... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T00:19:37.233",
"Id": "38002",
"Score": "4",
"Tags": [
"javascript",
"optimization",
"html",
"url"
],
"Title": "Ad page optimization?"
} | 38002 |
<p>I have below Java code to compare two list values with some condition:</p>
<pre><code> public boolean compareLists(List<SortData> prevList, List<SortData> modelList) {
if (prevList != null && modelList != null && prevList.size() == modelList.size()) {
boolean indicato... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T06:32:13.127",
"Id": "63238",
"Score": "1",
"body": "If you could, please state more concretely what this method is intended to do. Rather than just restating your program logic with words, explain what its purpose is. Right now it ... | [
{
"body": "<p>Some comments:</p>\n\n<pre><code>&& modelList.size() > 1\n</code></pre>\n\n<p>this check is redundant, in fact</p>\n\n<pre><code>if (prevList.size() > 1 && modelList.size() > 1 && prevList.size() == modelList.size()) {\n</code></pre>\n\n<p>this whole check doesn't ... | {
"AcceptedAnswerId": "38141",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T04:56:19.553",
"Id": "38007",
"Score": "5",
"Tags": [
"java",
"optimization"
],
"Title": "Optimize list comparison method?"
} | 38007 |
<blockquote>
<p>Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. <em>More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42.</em> All
numbers at input are integers of one or two digits.</p... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T05:45:41.790",
"Id": "63230",
"Score": "3",
"body": "Try adding a newline after each echo'd integer. I suspect that SPOJ is like most judges and likes line breaks between outputs."
},
{
"ContentLicense": "CC BY-SA 3.0",
... | [
{
"body": "<p><strong>Disclaimer:</strong> I'm not sure if this code will be the solution for <a href=\"http://www.spoj.com/\" rel=\"nofollow\">SPOJ</a>.</p>\n\n<p>You don't check if the input number is an <code>int</code>.</p>\n\n<pre><code>if (scanf(\"%d\", &i) == 1)\n{\n printf(\"OK\\n\");\n} \nelse\n... | {
"AcceptedAnswerId": "38012",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T04:58:14.280",
"Id": "38008",
"Score": "5",
"Tags": [
"c",
"io"
],
"Title": "Life, the Universe, and Everything"
} | 38008 |
<p>I've run my code through Valgrind and managed to not get any memory leaks based on the test code in main. I'm looking for things that I may not have thought to check for, and ways to improve my code in general.</p>
<p><strong>Header file:</strong></p>
<pre><code>#ifndef DLL_H
#define DLL_H
struct node{
voi... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T05:50:42.953",
"Id": "63232",
"Score": "3",
"body": "Hmm, that's a lot of code. Sounds like a job for tomorrow :P"
}
] | [
{
"body": "<p><code>typedef</code> means you no longer have to write <code>struct</code> all over the place. That not only saves keystrokes, it also can make the code cleaner since it provides a smidgen more abstraction. There are some places I wouldn't use it in your code, but the <code>struct</code>s in your... | {
"AcceptedAnswerId": "38081",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T05:28:23.780",
"Id": "38010",
"Score": "12",
"Tags": [
"c",
"linked-list",
"memory-management"
],
"Title": "Doubly linked list with no apparent memory leaks"
} | 38010 |
<p>Below is the python code to compress js and css files.</p>
<pre><code>import sys
import os
import glob
import shutil
import fnmatch
import os.path
import re
import argparse
import time
#Store the time the script starts
start_time = time.time()
total_files_compressed = 0
total_js_files_compressed = 0
total_css_file... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T14:20:22.787",
"Id": "63265",
"Score": "0",
"body": "I removed the javascript tag, that tag is meant for the language of the code."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T14:55:06.280",
"I... | [
{
"body": "<pre><code> if not os.path.exists(jsMinPath + \"/log\"):\n os.makedirs(jsMinPath + \"/log\")\n else:\n shutil.rmtree(jsMinPath + \"/log\")\n os.makedirs(jsMinPath + \"/log\")\n</code></pre>\n\n<p>could be</p>\n\n<pre><code> if os.path.exists(jsMinPath + \"/lo... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T05:55:59.757",
"Id": "38011",
"Score": "3",
"Tags": [
"javascript",
"python",
"performance",
"css"
],
"Title": "Python code to minify JS and CSS on the fly"
} | 38011 |
<p>I wrote some code for linked lists and would like to know what things could/should be done differently.</p>
<p>I'm using an index to keep track of the most important information and have 2 sets of functions, one to use the list just to point to data and the other to store the data in the list.</p>
<p>Here's the co... | [] | [
{
"body": "<ol>\n<li><p>You use <code>root</code> as parameter name when you pass the list around but I think a better name would just be <code>list</code>. <code>root</code> implies that you pass the first node of the list around rather than the container.</p></li>\n<li><p><code>++root->node_count</code> is... | {
"AcceptedAnswerId": "38027",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T06:32:13.567",
"Id": "38013",
"Score": "7",
"Tags": [
"c",
"linked-list"
],
"Title": "Linked list implementation"
} | 38013 |
<p>Request for review, optimization, best practice recommendations etc.</p>
<pre><code>/**
* Find the smallest positive number whose individual digits adds to the input number.
* eg: consider the input 14,
* The smallest number whose digit add to the given number is 59 ie 5 + 9 = 14.
*
* Complexity: O(n), where... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T07:20:52.793",
"Id": "63239",
"Score": "1",
"body": "`getVal(50)` returns 149, which is wrong."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T08:33:03.370",
"Id": "63253",
"Score": "2",
"... | [
{
"body": "<p>I am struggling to understand your algorithm. I don't fathom why you have to go through all that work of adding digits to values when the math behind this problem is so much simpler.</p>\n\n<p>The smallest value will always be a digit followed by nines. The number of nines is the number of whole t... | {
"AcceptedAnswerId": "38029",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T06:35:51.277",
"Id": "38014",
"Score": "2",
"Tags": [
"java",
"mathematics"
],
"Title": "Find the smallest number whose sum of digits add to a number"
} | 38014 |
<p>This is a Follow-up to <a href="https://codereview.stackexchange.com/q/37939/18427">Simple pay rate calculator</a></p>
<hr>
<p>Here is what I came up with. Hopefully if I have missed something that was said in answers on the previous question, we can still get those things pointed out. I am hoping that I made th... | [] | [
{
"body": "<p>Some enhancements I'd make is making employee a separate class with name, payrate, and a list of another class,workday that holds days and hours worked in the current pay period. If you make the PayRate class static and have only methods that take an object of class employee you simplify the clas... | {
"AcceptedAnswerId": "38138",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T06:50:20.523",
"Id": "38016",
"Score": "7",
"Tags": [
"c#",
"beginner"
],
"Title": "Follow up to Pay Rate Calculator"
} | 38016 |
<p>I wanted to consolidate solutions to disparate problems into a single program. I am worried that there is a interface, command pattern, or dictionary solution to what will become a massive switch statement here. However, the main in this program is essentially a meta-program which would switch between the miniature... | [] | [
{
"body": "<p>Instead of making one big program to solve all the problems, I would just make one program per problem. There is no logical connection between the Euler problems, so it's best to keep the solutions separate, too.</p>\n",
"comments": [],
"meta_data": {
"CommentCount": "0",
"Cont... | {
"AcceptedAnswerId": "38024",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T07:34:13.990",
"Id": "38019",
"Score": "5",
"Tags": [
"c#",
"beginner",
"programming-challenge"
],
"Title": "Solving Project Euler challenge"
} | 38019 |
<p>Review this code for code quality.</p>
<pre><code><!DOCTYPE html>
<title>Email obfuscator</title>
<style>.email { unicode-bidi: bidi-override; direction: rtl; }</style>
<h1>Email obfuscator</h1>
<p>A kick-ass email obfuscator, inspired by <a href="http://mathiasbyn... | [] | [
{
"body": "<p>Your code has room for improvement,</p>\n\n<p>in top-bottom order:</p>\n\n<ul>\n<li>Your code is littered with DOM queries, I would suggest to group them all on top, they reduce comprehension speed</li>\n<li>Access elements through the form is considered old skool, always use getElementByID</li>\n... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T07:36:32.830",
"Id": "38020",
"Score": "4",
"Tags": [
"javascript",
"email"
],
"Title": "Email obfuscator"
} | 38020 |
<p>Below is my first attempt at programming a Celsius to Fahrenheit converter in C# winforms. I'm looking for tips and advice on improving my style and what I can do to make the code more efficent/proper, or is it good as is? I apologize ahead of time if i've forgotten any details and would be happy to provide more upo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T09:57:54.860",
"Id": "63256",
"Score": "3",
"body": "In this piece of code it does not really matter because it it so short, but if it were longer you should start avoiding one letter variables and given them proper names like `celc... | [
{
"body": "<p>The main change is separation of logic and User Interface. Firstly the calculation methods should ideally not reside in UI methods like event handlers.</p>\n\n<p>Secondly the calculations should really be in it's own class, (but this application is just small enough that it is not ENTIRELY necessa... | {
"AcceptedAnswerId": "38023",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T08:03:19.393",
"Id": "38022",
"Score": "16",
"Tags": [
"c#",
"winforms",
"converting"
],
"Title": "Simple temperature converter"
} | 38022 |
<p>I have started learning about SOLID principles yesterday. I've got a detailed explanation of SOLID principles <a href="http://cre8ivethought.com/blog/2011/08/23/software-development-is-not-a-jenga-game" rel="nofollow noreferrer">here</a>. After reading it, and a few other articles, I have tried to apply these princi... | [] | [
{
"body": "<p>When you say <em>I have a form that initiates import process on a button's click event</em>, you've coupled your UI with some \"business logic\". Let's look at that <code>Click</code> handler:</p>\n\n<blockquote>\n<pre><code>private void btnStart_Click(object sender, EventArgs e)\n {\n IRe... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2013-12-24T16:10:11.300",
"Id": "38035",
"Score": "5",
"Tags": [
"c#",
"design-patterns",
"asp.net"
],
"Title": "Implementing SOLID Principles with C# Asp.net"
} | 38035 |
<p>As a challenge to myself, I wrote a solution to <a href="https://stackoverflow.com/questions/20763678/convert-list-of-list-tree-to-dict">this Stack Overflow question</a>. For completeness, the bulk of the question is as follows:</p>
<h2>Problem</h2>
<p>Input:</p>
<pre><code>[
['key1', 'value1'],
['key2',
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T18:40:45.667",
"Id": "63289",
"Score": "2",
"body": "Argh! All the `\\ ` you are using when defining the input are *useless*. Also you should **never** us `\\ ` to continue a line since you can wrap whatever expression you are writi... | [
{
"body": "<p>You could simplify your function:</p>\n\n<pre><code>def nested_pairs2dict(pairs):\n d = {}\n for k, v in pairs:\n if isinstance(v, list): # assumes v is also list of pairs\n v = nested_pairs2dict(v)\n d[k] = v\n return d\n</code></pre>\n\n<p><a href=\"http://ideone... | {
"AcceptedAnswerId": "38043",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T18:06:40.863",
"Id": "38038",
"Score": "4",
"Tags": [
"python",
"recursion",
"hash-map"
],
"Title": "Recursively convert a list of lists into a dict of dicts"
} | 38038 |
<p>I don't like to post programming contest code in here, but I really like the question and want to share it with you all.</p>
<blockquote>
<p>It has been years since Superman started his enmity with the
super-genius Lex Luthor. After years of intense battle, Luthor finally
decides to end it all by going into t... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T21:39:24.907",
"Id": "63304",
"Score": "0",
"body": "One thing I found out : `median` should be `meridiem` or `period`."
}
] | [
{
"body": "<p>For writing all of that in under an hour you should feel pretty good about yourself (with partial documentation to boot!). Here are some things I found though:</p>\n\n<hr>\n\n<p>You currently <a href=\"https://stackoverflow.com/a/2125337/1937270\">aren't following Java package naming standards</a... | {
"AcceptedAnswerId": "38103",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T21:25:20.680",
"Id": "38044",
"Score": "10",
"Tags": [
"java",
"datetime",
"programming-challenge"
],
"Title": "PUT (Parallel Universe Time) generator"
} | 38044 |
<p>I was inspired with this question <a href="https://stackoverflow.com/q/20597649/937125">How I can detect when other control changes it bounds?</a> and @Remy Lebeau's answer and decided to write my own control (based on ideas from <code>ExtCtrls.TLabeledEdit</code>).</p>
<p>Now I have a few concept problems: </p>
... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T22:07:41.523",
"Id": "38047",
"Score": "3",
"Tags": [
"delphi"
],
"Title": "TStickyLabel control anyone?"
} | 38047 |
<p>I would like some help refactoring this code. This is to improve some of the nonfunctional attributes of the software to</p>
<ol>
<li>improve code readability</li>
<li>reduce complexity to improve the maintainability of the source code.</li>
</ol>
<p></p>
<pre><code>package Game;
import java.awt.*;
import java.a... | [] | [
{
"body": "<p>Some comments:</p>\n\n<ul>\n<li><p>Make sure you have a consistent indentation style. It makes it difficult to follow the code flow, if there are multiple lines with different indentation.</p></li>\n<li><p>You should separate the view and the game logic. Having both the Swing design setup and the ... | {
"AcceptedAnswerId": "38052",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-24T22:18:51.853",
"Id": "38048",
"Score": "6",
"Tags": [
"java",
"optimization",
"performance",
"game",
"hangman"
],
"Title": "Hangman game code refactoring"
} | 38048 |
<p>I'm in the process of learning python and programmed this exercise in decrypting the <a href="http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher" rel="nofollow">Vigenere square cypher</a> as practice.</p>
<p>Please comment on best practices, efficiency, or more pythonic ways to do things.</p>
<pre><code>#!/usr/bin/... | [] | [
{
"body": "<p>Overall this is well documented, well written code. There are a number of things I may have written differently, but they are primarily manners of personal style. But I still found some things I want to call out that might be somewhat problematic, or at least worth examining:</p>\n\n<ol>\n<li><cod... | {
"AcceptedAnswerId": "38075",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T01:07:49.217",
"Id": "38055",
"Score": "3",
"Tags": [
"python",
"vigenere-cipher"
],
"Title": "Vigenere square cypher decryption"
} | 38055 |
<p>This is for an app built with Express. One of my concerns is the routes ending with <code>/</code> which I did because our previous site was an ASP app. So they named the folders that way for SEO purposes, then the page would be <code>index.aspx</code> .But in my case I just did, for example </p>
<p><code>science.j... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-31T06:15:32.153",
"Id": "63873",
"Score": "0",
"body": "Looks alright to me, the only thing i would suggest is to brake this file up. What exactly concerns you though?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate":... | [
{
"body": "<p>From a once over of the code and the comments:</p>\n\n<ul>\n<li>This code is fine, especially if you have only a dozen routes, I would not advise you to build your own route building infrastructure for such a small amount of routes</li>\n<li>Dont worry about the <code>/</code></li>\n<li>Consider h... | {
"AcceptedAnswerId": null,
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T01:57:35.147",
"Id": "38056",
"Score": "3",
"Tags": [
"javascript",
"node.js"
],
"Title": "How well or poorly structured are my routes in this NodeJS app?"
} | 38056 |
<p>I've just completed my first JavaScript game. I strongly welcome any advice/opinions/insults on how crappy or good my game is.</p>
<p>Do you notice anything that is poorly done? </p>
<p>Is there anything that I can write better/shorter?</p>
<p>Here is a link where you can change the code/test the game/etc. <a hre... | [] | [
{
"body": "<p>My <a href=\"https://codereview.stackexchange.com/a/37900/9357\">remarks about the Ruby version of your code</a> also apply to your JavaScript port.</p>\n\n<p>For example <code>hitOrStay()</code> should not recurse, because you're just using it as a <code>goto</code>.</p>\n\n<p>The players' hands ... | {
"AcceptedAnswerId": "38061",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T02:14:18.417",
"Id": "38057",
"Score": "2",
"Tags": [
"javascript",
"beginner",
"game",
"playing-cards"
],
"Title": "Hot 18 game (modified Blackjack) in JavaScript"
} | 38057 |
<p>I have built a partial human brain model and the following is an example of how I use all the classes. I was wondering if anyone could critique my implementation strategies because I feel like the following setup is very clumsy. You can view all the code at:
<a href="https://github.com/quinnliu/WalnutiQ" rel="nofoll... | [] | [
{
"body": "<p>Well, nobody said that modelling the brain would be easy.</p>\n\n<p>However, it you find that it takes a lot of code to set up the nervous system model, it's probably a sign that your library is underdeveloped. Maybe the library should include some kind of <code>NervousSystemFactory</code> for co... | {
"AcceptedAnswerId": "38065",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T06:31:40.927",
"Id": "38060",
"Score": "4",
"Tags": [
"java",
"object-oriented",
"unit-testing",
"junit"
],
"Title": "Review of java interface for constructing brain model"... | 38060 |
<p>I have solved the question, and in turn felt the need to get it reviewed. Any suggestions for clean up and optimization would help. Also please verify my complexity: \$O(V + E)\$.</p>
<p><code>GraphCycleDetection</code> should be named to <code>Graph</code>, but it was named on purpose to avoid conflict in Eclipse ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T12:41:21.197",
"Id": "63356",
"Score": "2",
"body": "You use a *weighted* directed graph, while you only need a directed graph. Why the [Premature Generalization](http://c2.com/cgi/wiki?PrematureGeneralization)? YAGNI."
}
] | [
{
"body": "<p>Just something minor:</p>\n\n<p>I'm not sure why you keep on insisting to name data structures after specific algorithms (you seem to do that in most of your code you post).</p>\n\n<ol>\n<li><p><code>GraphCycleDetection</code> is a graph and should therefore be named <code>Graph</code>. It can be ... | {
"AcceptedAnswerId": "38067",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T10:06:21.870",
"Id": "38063",
"Score": "8",
"Tags": [
"java",
"graph"
],
"Title": "Check if directed graph contains a cycle"
} | 38063 |
<p>I have such a problem:</p>
<p>I'm parsing a lot of HTML files with Simple HTML DOM Parser, that's why I need to use three <code>foreach</code>s to parse the necessary information from it -> I am getting a lot of information and now I have three arrays which keep it. I think that it's dumb to keep the code like that... | [] | [
{
"body": "<p>Please provide some more information, like the example contents of <code>$infos</code>. It is hard to find any other solution if we are not able to understand your current solution in the first place.</p>\n\n<p>However, there already are some issues with your code:</p>\n\n<ul>\n<li>avoid using var... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T11:10:42.247",
"Id": "38064",
"Score": "0",
"Tags": [
"php",
"array",
"classes"
],
"Title": "How to put a lot of information in the class?"
} | 38064 |
<p><a href="http://projecteuler.net/problem=12" rel="nofollow">Project Euler Problem 12</a> asks (paraphrased):</p>
<blockquote>
<p>The <em>n</em><sup>th</sup> triangular number <em>T</em><sub><em>n</em></sub> = 1 + 2 + … + <em>n</em>. <em>T</em><sub>7</sub> = 28 has 6 divisors (1, 2, 4, 7, 14, 28). What is the fi... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-26T17:02:10.873",
"Id": "63428",
"Score": "1",
"body": "[Optimization hints](http://stackoverflow.com/a/571526/4279) (Implementation in Python takes around 50ms)"
}
] | [
{
"body": "<ul>\n<li><p>This:</p>\n\n<pre><code>int i = 2;\nwhile (overall_factors(i) < 500)\n{\n std::cout << overall_factors(i) << std::endl;\n ++i;\n}\n</code></pre>\n\n<p>can just be a <code>for</code>-loop:</p>\n\n<pre><code>for (int i = 2; overall_factors(i) < 500; ++i)\n{\n std... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T14:17:29.113",
"Id": "38069",
"Score": "3",
"Tags": [
"c++",
"c++11",
"project-euler",
"primes"
],
"Title": "Project Euler #12 in C++ - highly divisible triangular number"
} | 38069 |
<p>I'm coding an algorithm to remove a parameter (let's call it <code>foo</code>) from URL strings.</p>
<p>Of course, after the <code>foo</code> parameter removal, the query string should remain valid (with a leading <code>?</code> and remaining parameters separated by <code>&</code>).</p>
<p>I'd also like to rem... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-26T09:59:13.527",
"Id": "63411",
"Score": "0",
"body": "dear lord, I'm sorry to say this but: Gloves... yes [gloves](http://thedailywtf.com/Articles/The_Complicator_0x27_s_Gloves.aspx) exist, that's why the market for electrically heat... | [
{
"body": "<p>URL's are a nightmare to process. Even though, in your case, it appears that you can use regex to isolate your specific problem, I would still recommend that you avoid regex for URL manipulation.</p>\n\n<p>PHP has native URL parsing methods (much better tested and controlled than your code), and y... | {
"AcceptedAnswerId": "38076",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T14:27:29.297",
"Id": "38070",
"Score": "6",
"Tags": [
"php",
"regex",
"url"
],
"Title": "Remove a parameter and its value from URL's query string"
} | 38070 |
<p>I have an application for transferring files from clients to a server. A client opens, transfers a file to the server and closes. The server is open and may receive multiple files. Also, when transferring a file, a loader bar is created on both server (the server must have some way to display multiple loaders simult... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T19:40:29.993",
"Id": "63393",
"Score": "0",
"body": "I know that and I specified the parts that I am interested in, but I tought it will be nice if I show the whole thing, maybe I will get a superficial remark at least."
}
] | [
{
"body": "<p>Nice code in general. Many of my comments are a bit on the\nnit-picking level, so apologies in advance.</p>\n\n<p>Your method of error handling seems to be just to exit, so the return\nvalues from various functions should probably be <code>void</code>. This method\nof error handling is certainly... | {
"AcceptedAnswerId": "38115",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T14:55:05.137",
"Id": "38071",
"Score": "7",
"Tags": [
"c",
"multithreading",
"file",
"server"
],
"Title": "Client server application for file transfer"
} | 38071 |
<p>I know there are countless questions on SO, and several articles on the web regarding this subject, but after looking at all the options, I was moved to write my own code to address my own requirements. However, this has raised a couple of questions for me that I would appreciate your valued input on.</p>
<p>First,... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T21:30:15.387",
"Id": "63362",
"Score": "1",
"body": "Could you possibly make use of mysqldump instead of trying to format the data yourself? You could use PHP's exec() command to capture the command's output and funnel it to the br... | [
{
"body": "<p>The following will make use of mysql dump executable to dump the database to a file of your choice. The mysqldump command takes care of adding quotes and scaping characters. In PHP the following should work:</p>\n\n<pre><code><?php\n\necho exec('mysqldump –-user [user name] –-password=[password... | {
"AcceptedAnswerId": "38074",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-23T21:25:57.510",
"Id": "38072",
"Score": "2",
"Tags": [
"php",
"mysql",
"pdo"
],
"Title": "Dumping a MySQL database to a file using a PHP script"
} | 38072 |
<p>I am writing an "Enter key pressed" event-handler, so when user presses the "enter" key in the input of type text, this code is called:</p>
<pre><code> var email = "";
var subscriberInput = $("input[name='subscriber_email']")
// Subscribe RSS
subscriberInput.keyup(function(e){
if(e.which == 1... | [] | [
{
"body": "<p>A few things to note before I explain improvements</p>\n\n<ul>\n<li><p>Never forget <code>var</code> when declaring variables. I saw this in the code.</p>\n\n<pre><code>email = subscriberInput.val();\n</code></pre>\n\n<p>Now, best case scenario is that you declared <code>email</code> somewhere in ... | {
"AcceptedAnswerId": "38087",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T17:57:46.503",
"Id": "38082",
"Score": "2",
"Tags": [
"javascript",
"jquery",
"event-handling"
],
"Title": "\"Enter key pressed\" event-handler"
} | 38082 |
<p>Review this code for code quality.</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Data URI encoder</title>
<style>
#dropbox {
padding: 18.5px 0;
max-width: 499px;
border: 2px dashed #bbb;
border-radius: 5px;
color: #bbb;
text-align: c... | [] | [
{
"body": "<p>There isn't much here, just a few comments though:</p>\n\n<ul>\n<li><p>Most developers I come across use <code>var</code> per variable rather than comma separated. It's down to personal preference and code habits though, so you could ignore this one.</p>\n\n<p>An advantage I see is that it makes v... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T18:03:26.537",
"Id": "38083",
"Score": "3",
"Tags": [
"javascript"
],
"Title": "Data URI encoder"
} | 38083 |
<p>Here is a solution for <a href="http://projecteuler.net/problem=7">Project Euler Problem #7</a>.</p>
<blockquote>
<p>By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can
see that the 6th prime is 13. What is the 10,001st prime number?</p>
</blockquote>
<p>I've used the pseudo code from the <a... | [] | [
{
"body": "<p>Well since you didn't mention what kind of improvement you are looking for, I will share some short(LOC) and precise way to find X<sup>th</sup> prime number.</p>\n\n<pre><code>public static BigInteger getXthPrime(final int x) {\n BigInteger prime = new BigInteger(\"2\"); // first prime number\n... | {
"AcceptedAnswerId": "38095",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2013-12-25T18:46:54.100",
"Id": "38084",
"Score": "12",
"Tags": [
"java",
"project-euler",
"primes"
],
"Title": "Suggestions for improvement on Project Euler #7"
} | 38084 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.