body stringlengths 25 86.7k | comments list | answers list | meta_data dict | question_id stringlengths 1 6 |
|---|---|---|---|---|
<p>I'm learning F# and I've decided to solve <a href="http://projecteuler.net/problem=81" rel="nofollow">Project Euler's Problem #81</a> with Dijkstra's algorithm.</p>
<blockquote>
<p>In the 5 by 5 matrix below, the minimal path sum from the top left to
the bottom right, by only moving to the right and down, is in... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-16T04:13:07.293",
"Id": "20476",
"Score": "0",
"body": "\"Code Review - Stack Exchange is for sharing code from projects you are working on\" -> This is not a project I'm working on. It's a short piece of code I wrote in an hour."
},... | [
{
"body": "<p>Apparently there is a strong opinion that this is not a good question for SO, hence no good answer may be given. Nevertheless, I'll try to approach it from efficiency side.</p>\n\n<p>Regardless of quality of given implementation of Dijkstra's algorithm it may be not a good approach for solving <a ... | {
"AcceptedAnswerId": null,
"CommentCount": "9",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-16T03:26:03.603",
"Id": "12687",
"Score": "5",
"Tags": [
"algorithm",
"f#",
"matrix",
"programming-challenge",
"pathfinding"
],
"Title": "Path sum - Dijkstra's algorithm in F... | 12687 |
<p>This is a lock-free <code>Container</code> class. By <code>Container</code> I mean it will hold objects for iteration at a later time. To achieve \$O(1)\$ it returns a token from the <code>put</code> method which you can then use to remove the object. The token is actually the node in which the object has been place... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T13:38:42.760",
"Id": "20486",
"Score": "0",
"body": "The original post is [here](http://stackoverflow.com/a/11080869/823393)."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T16:26:41.240",
"Id": "... | [
{
"body": "<p>I thought about a comment, but too long, several things I can think of:</p>\n\n<ol>\n<li><p>This does not guarantee order, i.e. an item is entered into the next free slot, and if there is a fast producer, the order the consumer sees is not guaranteed. Is this intentional?</p></li>\n<li><p>There is... | {
"AcceptedAnswerId": "12885",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T13:36:53.167",
"Id": "12691",
"Score": "17",
"Tags": [
"java",
"collections",
"circular-list",
"lock-free",
"atomic"
],
"Title": "O(1) lock free container"
} | 12691 |
<p>I recently started learning jQuery and JavaScript and put this together for the site I work on <a href="http://wncba.co.uk/results" rel="nofollow">here</a>.</p>
<pre><code>/*
* Manages the error report popups
*
* written by Tom Jenkinson
*/
jQuery(document).ready(function($) {
var bottomTableReport = {
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T14:00:49.973",
"Id": "20488",
"Score": "1",
"body": "`[]` instead of `new Array()`"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T14:37:48.877",
"Id": "20498",
"Score": "0",
"body": "@Thi... | [
{
"body": "<h2><code>[]</code> instead of <code>new Array()</code></h2>\n\n<p>Initialize arrays with <code>[]</code> instead of <code>new Array()</code> - it looks better, and when creating a single-element array [5] works while new Array(5) would create an array containing 5 undefined elements;</p>\n\n<h2>Long... | {
"AcceptedAnswerId": "12727",
"CommentCount": "9",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T13:45:51.033",
"Id": "12693",
"Score": "1",
"Tags": [
"javascript",
"jquery",
"html",
"html5"
],
"Title": "Managing error report popups"
} | 12693 |
<p>Yet another interview question:</p>
<blockquote>
<p>Implement a function to check if a tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that no two leaf nodes differ in distance from the root by more than one.</p>
</blockquote>
<p>First off, did I understand the q... | [] | [
{
"body": "<p>First off, I would use something other than a LinkedList to hold the children of an n-ary tree. A LinkedList requires you to enumerate the list in order to get the reference to any child other than the leftmost, which is going to slow you down.</p>\n\n<p>Second, your code is basically returning fa... | {
"AcceptedAnswerId": "12710",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T13:46:55.283",
"Id": "12694",
"Score": "1",
"Tags": [
"java",
"interview-questions",
"tree"
],
"Title": "Implement a function to check if a tree is balanced"
} | 12694 |
<p>All models are in the model namespace and follow a naming convention. This makes it easy to consolidate control into <code>cType()</code> as shown below.</p>
<p>All control passes through <code>cTYpe()</code> which calls the correct model. It does this by way of the type parameter which is set by the call back fu... | [] | [
{
"body": "<p><strong>Disclaimer:</strong> I'm here at behest of the OP. I'm not all that proficient at JS, just enough to do some basic things, but I am fairly well versed in PHP. That being said, the knowledge should be fairly universal and I said I'd lend my point of view on the subject. Please feel free to ... | {
"AcceptedAnswerId": "12714",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T14:29:34.427",
"Id": "12695",
"Score": "7",
"Tags": [
"javascript",
"mvc"
],
"Title": "MVC - Control Module - Version 2"
} | 12695 |
<p>This is an function that downloads a single file from an FTP server and saves it to disk
This is my first time doing anything with FTP, please let me know if i have missed anything.</p>
<pre><code>public void DownloadFile(string fileloc, string saveLoc)
{
try
{
// Get the object used to communicate ... | [] | [
{
"body": "<p>When you rethrow an exception using <code>throw ex;</code> you refresh its stacktrace. (Frame?) This means the exception will seem to have been initially raised at your <code>throw ex;</code> line, and loses its previous stacktrace.</p>\n\n<p>You want to simply <code>throw;</code> - like this:</p>... | {
"AcceptedAnswerId": "12703",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T14:36:02.300",
"Id": "12697",
"Score": "3",
"Tags": [
"c#",
".net",
"networking",
"ftp"
],
"Title": "FTP Download Function"
} | 12697 |
<p>I have some code in Go that is attempting to compare two images and determine how different they are. The method is fairly crude, but it is fast enough. Basically it just compares both images pixel by pixel and for each pixel it determines how different they are by comparing the RGBA values separately and using the ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T15:30:34.550",
"Id": "20508",
"Score": "1",
"body": "I wouldn't use rgba for this kind of difference but a color model more natural, like HSL."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T15:46:50.... | [
{
"body": "<p>Though I didn't check the whole program and, according to you, performance is good enough, I do have one performance related suggestion:</p>\n\n<p>avoid <code>int64(math.Abs(float64(</code><strong>var1</strong><code>-</code><strong>var2</strong><code>)))</code>. Casting between int and float types... | {
"AcceptedAnswerId": null,
"CommentCount": "8",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T15:08:17.050",
"Id": "12700",
"Score": "2",
"Tags": [
"image",
"go"
],
"Title": "Comparing two images"
} | 12700 |
<p>I am new to Java, and I would like some tips from the 'pros'. I know of the Pascal naming system, and things like that, but how can I improve this code?</p>
<p><strong>Menu.java</strong></p>
<pre><code>package com.x12.addsubtract;
import java.util.Random;
import java.util.Scanner;
public class Subtract {
Ga... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T20:26:58.343",
"Id": "20572",
"Score": "0",
"body": "It appears you added subtract class twice instead of menu"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T21:16:05.183",
"Id": "20581",
"Sc... | [
{
"body": "<p>Welcome to java :), it is not hard to get into the OO mindset. But you might have to unlearn the procedural way of thinking.</p>\n\n<p>A few thoughts to help you along ,</p>\n\n<p>(The Menu.java is missing. So I couldn't look at it)</p>\n\n<ul>\n<li>You seem to be using Game.numberOfQuestions as a... | {
"AcceptedAnswerId": "12718",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T19:12:56.537",
"Id": "12713",
"Score": "1",
"Tags": [
"java",
"optimization",
"beginner",
"game"
],
"Title": "Add/subtract questions game"
} | 12713 |
<p>I have been trying to make this code go faster by trying to write it more efficiently and I don't know what else to do. I got it to 30 seconds but I have seen 23 and 24 and I have no idea on how to do it. </p>
<pre class="lang-java prettyprint-override"><code>public class Main {
public static void main(Stri... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T20:17:48.130",
"Id": "20577",
"Score": "2",
"body": "Where have you seen the other timings? On your computer? You just might want to buy a faster computer!"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06... | [
{
"body": "<p>A little bit of loop unrolling plus a time memory tradeoff yields this, which on my machine runs in just over 6s. Your original code took about 32s, so that's a speedup of over 500%. You will need to launch it manually, eclipse cannot run it at the default settings, it takes too much RAM (over 8... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T19:56:55.417",
"Id": "12715",
"Score": "5",
"Tags": [
"java",
"performance"
],
"Title": "Speeding up 3n+1 challenge"
} | 12715 |
<p>The client side version in JavaScript is <a href="https://codereview.stackexchange.com/questions/12695/mvc-control-module-architecture-design-structure-review-js">here</a></p>
<p>This is the server side version of my control module. How does the structure look. </p>
<p><strong>PostScript</strong></p>
<p>Because... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T00:18:05.823",
"Id": "20603",
"Score": "0",
"body": "Too lazy to write a full answer, but the first thing that jumps out at me is that it looks like your controller is actually a dispatcher and your models are actually controllers."... | [
{
"body": "<p>Would separate those includes a bit differently. I'd use a newline after each include then use a double new line when I wanted to section them off. All one line as you are doing, and not even spaces between them, could make someone think that you have only three includes. Speaking of includes. You... | {
"AcceptedAnswerId": "12733",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-18T23:15:19.757",
"Id": "12719",
"Score": "0",
"Tags": [
"php"
],
"Title": "MVC - Control Class - Architecture / Design - Structure Review - PHP"
} | 12719 |
<p>I'm in the alpha stages of development for my console RPG, and I need some input.</p>
<p>My main question is how should I handle attacks? (You'll see what I mean if you look through my world, item, and enemy classes code.)</p>
<p>Here are some code snippets and a link to my full code. Please note that my latest re... | [] | [
{
"body": "<p>Well I have a few comments on the code, specifically dealing with the <code>Player</code> class.</p>\n\n<ol>\n<li>I would break up the Do method into a few methods. You could add a static method to parse the action/verb string.</li>\n<li>You could consider changing the verb data into an enum and t... | {
"AcceptedAnswerId": "12957",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T01:12:46.160",
"Id": "12721",
"Score": "4",
"Tags": [
"c#"
],
"Title": "Can I get some constructive criticism on my C# console RPG?"
} | 12721 |
<p>I feel like I write this a lot in PHP:</p>
<pre><code> $val = isset($var['foo']) ? $var['foo'] : '';
</code></pre>
<p>Is there a shorter way to write this? I can't use the ternary operator because the conditional is an <code>isset</code> check, not the value of the function itself.</p>
| [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T13:42:58.697",
"Id": "20626",
"Score": "0",
"body": "I toyed around with using `filter_var()` but that isn't any shorter really. Never got around to doing speed test on it. Benjamin's answer is your best bet."
},
{
"ContentL... | [
{
"body": "<p>You could wrap it in a function (check the syntax, I don't actually know PHP):</p>\n\n<pre><code>function getDefault($array, $key, $default) {\n return isset($array[$key]) ? $array[$key] : $default;\n}\n</code></pre>\n",
"comments": [
{
"ContentLicense": "CC BY-SA 3.0",
... | {
"AcceptedAnswerId": "12723",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T05:22:42.480",
"Id": "12722",
"Score": "11",
"Tags": [
"php"
],
"Title": "Shorthand for isset($var['foo']) ? $var['foo'] : ''"
} | 12722 |
<p>I have a class that has 5 similar methods, they just relay input parameters and return a result - best practice would be to skip the class, but that's not what I'm asking about :) This is a method from the class:</p>
<pre><code>public String deleteItem(Integer itemId,String username, String kpNumber) {
try ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T13:07:25.313",
"Id": "20622",
"Score": "0",
"body": "In what way are those methods different?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T13:28:59.860",
"Id": "20624",
"Score": "0",
"b... | [
{
"body": "<p>One alternative, although I don't know if you think it's too complex, would be to apply a visitor pattern:</p>\n\n<pre><code>private interface Command {\n String apply(ItemServiceFacade facade) throws RemoteException, CoreException;\n}\n\npublic String deleteItem(final Integer itemId, final Str... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T12:51:47.573",
"Id": "12728",
"Score": "5",
"Tags": [
"java"
],
"Title": "What is the \"proper\" way to write this in Java?"
} | 12728 |
<p>I have following code for a library management system.</p>
<ol>
<li><p>Is the following code a proper implementation of the Repository Pattern?</p></li>
<li><p>How can I adapt this code to use generics?</p></li>
<li><p>Should I let <code>MyOracleReservationRepository</code> and <code>MyOracleBookRepository</code> b... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T18:31:23.623",
"Id": "20792",
"Score": "1",
"body": "This is more of an aside, not warranting a full answer, but it is good practice to have your public APIs expose as low-level objects as you can. For example, depending upon inten... | [
{
"body": "<p>That is a very good start. However, look into moving the loop to get all the books into the GetAllReservations() method in the concrete class that implements IReservationRepository. When I see the method name \"GetAllReservations\" in the interface IReservationRepository I would expect it would ... | {
"AcceptedAnswerId": "12832",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T13:22:09.013",
"Id": "12730",
"Score": "4",
"Tags": [
"c#",
"design-patterns",
"object-oriented",
"generics",
".net-2.0"
],
"Title": "Repository Pattern Review"
} | 12730 |
<p>I'm verifying South African IDs with jQuery, the code below works but Id like to know if it could be simplified in anyway or if there is a better way of doing things here?</p>
<p>South African IDs are verified as follows:</p>
<blockquote>
<pre><code>Using ID Number 8001015009087 as an example:
Add all the digits i... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T14:13:22.860",
"Id": "20629",
"Score": "0",
"body": "You can [beautify](http://jsbeautifier.org/) (better indenting and spacing) or uglify (compress) it, I don't see why make changes to a fully working code which is as simple as tha... | [
{
"body": "<p>I don't know if it's simpler or more readable, it's kind of in the eye of the beholder. the immediate algorithm is more succinct. However it's still a little convoluted.</p>\n\n<p>You can decide for yourself, but here is a different way of writing it.</p>\n\n<p><a href=\"http://jsfiddle.net/BJhSp... | {
"AcceptedAnswerId": "12762",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T14:10:39.863",
"Id": "12735",
"Score": "7",
"Tags": [
"javascript",
"jquery"
],
"Title": "Verifying a South African ID"
} | 12735 |
<p>I'm trying to "sanitize" a textarea input by disallowing repeated characters like "!!!", "???", etc. add spaces after commas, and I would like to optimize the code because I'm not a pro at this.</p>
<p><a href="http://jsfiddle.net/XbZrS/6/" rel="nofollow noreferrer">jsFiddle</a></p>
<pre><code>$("#post_input").key... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T15:28:12.977",
"Id": "20642",
"Score": "0",
"body": "Why do you want to turn it all into one big ugly regex?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T15:29:17.173",
"Id": "20643",
"Scor... | [
{
"body": "<blockquote>\n <p>Prevent repetead characters (all kind of characters) to 3.</p>\n</blockquote>\n\n<p>If you mean replace 4 or more repeated characters with single character:</p>\n\n<pre><code>str.replace(/(.)\\1{3,}/g, '$1');\n</code></pre>\n\n<hr>\n\n<blockquote>\n <p>Add space after commas (,) o... | {
"AcceptedAnswerId": "12741",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T15:21:32.433",
"Id": "12740",
"Score": "1",
"Tags": [
"javascript",
"jquery",
"regex"
],
"Title": "Disallowing repeated characters and space after punctuation"
} | 12740 |
<p>I post the following code writen all by hand. Why I have the feeling that it is a western spaghetti on its own. Second, could that be written better?</p>
<pre><code> <div id="form-board" class="notice" style="height: 200px; min-height: 109px; width: auto;display: none;">
<script type="text/javascrip... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T21:55:24.180",
"Id": "20679",
"Score": "0",
"body": "Yannis did a good job with his review +1 to him. This is just an addition. I think there should be better form names and ID's than inputs, inputs2, etc... These are meaningless. I... | [
{
"body": "<p>Yes it can. Here are few things:</p>\n\n<ul>\n<li>CSS should be in a separate file</li>\n<li>JavaScript should be in a separate file</li>\n<li>JS file should be included at the bottom, before <code></body></code>. At that point all the content of file would already be \"inside\" an <code>onD... | {
"AcceptedAnswerId": "12749",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T17:32:50.913",
"Id": "12747",
"Score": "2",
"Tags": [
"php",
"javascript",
"jquery",
"ajax"
],
"Title": "Is this spaghetti code already?"
} | 12747 |
<p>The code below is slow. Any thoughts on speeding up? </p>
<pre><code>dict1 = {}
dict2 = {}
list_needed = []
for val in dict1.itervalues():
for k,v in d1ct2.iteritems():
if val == k:
list_needed.append([val,v])
</code></pre>
| [] | [
{
"body": "<p>Perhaps,</p>\n\n<pre><code>for val in dict1.itervalues():\n if val in dict2:\n list_needed.append([val,dict2[val]])\n</code></pre>\n\n<p>This is similar to </p>\n\n<pre><code>list_needed = [[val,dict2[val]] for val in dict1.itervalues() if val in dict2]\n</code></pre>\n\n<p>My preference ... | {
"AcceptedAnswerId": "12752",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T18:45:25.203",
"Id": "12751",
"Score": "2",
"Tags": [
"python"
],
"Title": "Speed up two for-loops?"
} | 12751 |
<p>I'm a rank beginner in Python, and I am working my way through various relevant OpenCourseware modules. In response to the prompt </p>
<blockquote>
<p>Write a procedure that takes a list of numbers, nums, and a limit,
limit, and returns a list which is the shortest prefix of nums the sum
of whose values is gre... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-22T07:24:39.357",
"Id": "20836",
"Score": "0",
"body": "I see now that this version was cobbling together a numberlist from the output of print and return, which would be problematic if I tried to pass the result into another function.... | [
{
"body": "<p>Welcome to programming :) I did not understand your question first, then I realized that python might be your first language. In that case congratulations on picking a very nice language as your first language. </p>\n\n<p>Your question seems to ask for the list which is the shortest prefix of nums... | {
"AcceptedAnswerId": "12759",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T21:54:02.620",
"Id": "12753",
"Score": "4",
"Tags": [
"python",
"beginner"
],
"Title": "Taking the first few items of a list until a target sum is exceeded"
} | 12753 |
<p>My first attempt at a user registration code.</p>
<p><code>Login.php</code> defines database log in variables (e.g. Database name, Table name, etc)
<code>Header.php</code> connects to the database.</p>
<p>I used <code>ctype_alum</code> for security of inputs. I also know that I shouldn't use <code>mysql_error()</c... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T04:25:05.693",
"Id": "20695",
"Score": "0",
"body": "I'll write a proper response later if no one else beats me to it, but: You're missing the `()` after one of the mysql_error calls. Also, `pre` should typically be avoided for sty... | [
{
"body": "<p>I think this is better than about 99% of first tries I've ever seen!</p>\n\n<p>Anyway, I've tried my best to address as many things as I saw, whether major or extremely minor. If you have any questions on any points or want to clarify or defend any claims, let me know and I will expand the answer... | {
"AcceptedAnswerId": "12769",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T01:50:20.583",
"Id": "12757",
"Score": "14",
"Tags": [
"php",
"beginner",
"mysql",
"security"
],
"Title": "Basic user registration code"
} | 12757 |
<p>Following is a working solution for a single xml ajax to retrieve category list, then individual ajax calls for each category. This was developed in response to a question on SO.</p>
<p>Solution creates one deffered for the category ajax call, and array of deffereds for the items ajax calls. Bottom of code nests <c... | [] | [
{
"body": "<p>I'm not sure what do you exactly need? \n<a href=\"http://jsfiddle.net/tomalec/GeRkG/1/\" rel=\"nofollow\">http://jsfiddle.net/tomalec/GeRkG/1/</a></p>\n\n<ul>\n<li>Use promise returned by <code>$.post</code>. we don't need <code>var xml_A</code> and <code>$.when(xml_A)</code></li>\n<li>Remove def... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T01:52:07.877",
"Id": "12758",
"Score": "2",
"Tags": [
"javascript",
"jquery",
"ajax",
"promise"
],
"Title": "jQuery nested ajax deffereds- looking for improvements"
} | 12758 |
<p>We were given two countries, namely Brazil and Argentina. Both had one inventory each with 100 iPods in them. The cost of an iPod in Brazil was 100/unit and in Argentina it was 50/unit. But to get iPods form Argentina, you also had to pay 400/10units. Now they give us some number and we had to find out which purchas... | [] | [
{
"body": "<p>Before looking at your design, a few trivial points that you can correct,</p>\n\n<pre><code>#include<iostream>\n#include<string>\n#include<cstdlib>\n</code></pre>\n\n<ul>\n<li>Avoid c style header usage. Instead use the c++ header style, and namespaces.</li>\n<li><p>Instead of <c... | {
"AcceptedAnswerId": "13265",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T05:41:34.097",
"Id": "12763",
"Score": "4",
"Tags": [
"c++",
"homework"
],
"Title": "Inventories of iPods for different countries"
} | 12763 |
<p>How can this be improved?</p>
<pre><code>def quick_sort(temp_list):
#Check if the array is having one element or not
if len(temp_list) == 1:
return temp_list
elif len(temp_list) >= 2:
l_list = list()
g_list = list()
#Choose a pivot
if len(temp_list) % 2 == 0:
p... | [] | [
{
"body": "<p>Some changes to your code, First, your code didn't handle the case of empty list very well. This was why you need a complicated merge. (Also, the operation is not really a merge. A merge kind of means interleaving.)</p>\n\n<pre><code>def quick_sort(temp_list):\n if len(temp_list) <= 1: retur... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T06:47:59.967",
"Id": "12765",
"Score": "7",
"Tags": [
"python",
"quick-sort"
],
"Title": "Quick sort in Python"
} | 12765 |
<p>I have a class which throws a lot of exceptions: </p>
<pre><code> try {
mapper.writeValue(outStream, myVal);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace()... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2017-10-22T19:09:20.287",
"Id": "338928",
"Score": "0",
"body": "multi-catch? might combine a few of them."
}
] | [
{
"body": "<blockquote>\n <p>is it ok to just catch a generic Exception and not catch each individual exception if within the catch clause of each exception im just printing the stack trace ?</p>\n</blockquote>\n\n<p>Yes, it is ok to just catch a generic <code>Exception</code>. The result will be the same if y... | {
"AcceptedAnswerId": "12770",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T08:05:32.967",
"Id": "12767",
"Score": "8",
"Tags": [
"java",
"json",
"error-handling"
],
"Title": "Catching multiple types of exceptions when writing JSON"
} | 12767 |
<p>I'm currently getting the <strong>Facebook comments count</strong> over a query request to the Facbeook api.</p>
<p>The problem is, there are about 15 queries on each site which makes it real slow to load (up to 6 seconds)</p>
<p>The next step is to <strong>get the comments count from the array object</strong>, as... | [] | [
{
"body": "<p>Please use braces <code>{}</code> to wrap your code, even those one line if statements, makes it so much easier to read.</p>\n\n<p>First off, you do know that JSON has an option to output an array right? <code>json_decode( $json, TRUE )</code> returns an array. No need to create a function for it.... | {
"AcceptedAnswerId": "12835",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T09:17:52.577",
"Id": "12772",
"Score": "2",
"Tags": [
"php",
"performance",
"facebook"
],
"Title": "Getting Facebook comments count via FQL"
} | 12772 |
<p>The <a href="https://en.wikipedia.org/wiki/ADO.NET_Entity_Framework" rel="nofollow noreferrer">ADO.NET Entity Framework</a> (EF) is .NET's Object-Relational Mapping (ORM) tool that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access c... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:31:28.927",
"Id": "12775",
"Score": "0",
"Tags": null,
"Title": null
} | 12775 |
The ADO.NET Entity Framework is a set of ORM (Object-Relational-Mapping) tools for the .NET Framework, since version 3.5 SP1. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:31:28.927",
"Id": "12776",
"Score": "0",
"Tags": null,
"Title": null
} | 12776 |
<p>Question goes like this : </p>
<pre><code>input: 1
output:
{}
input: 2
output:
{}{}
{{}}
input: 3
output:
{}{}{}
{{}}{}
{}{{}}
</code></pre>
<p>This is my program : </p>
<pre><code>public class PrintBraces {
int n;
char []braces;
void readData()
{
java.util.Scanner scn=new java.util.Sca... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T11:42:54.127",
"Id": "20702",
"Score": "3",
"body": "Why doesn’t the output for `3` contain `{{{}}}`? Are only two levels of nesting allowed?"
}
] | [
{
"body": "<p>The given problem can be attempted in a slightly different manner. You can see that the pairing corresponds to binary digits with { standing for 1s and } standing for 0s. </p>\n\n<p>For e.g the pairing with the maximum value for say 4 {}'s is 11110000. So all we have to do is to generate every num... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:32:18.457",
"Id": "12777",
"Score": "6",
"Tags": [
"java",
"optimization"
],
"Title": "Printing braces"
} | 12777 |
<p><a href="http://en.wikipedia.org/wiki/Function_%28computer_science%29" rel="nofollow">From Wikipedia</a>:</p>
<blockquote>
<p>In computer programming, a <strong>subroutine</strong> is a sequence of program instructions that perform a specific task, packaged as a unit. This unit can then be used in programs wherev... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:35:40.263",
"Id": "12778",
"Score": "0",
"Tags": null,
"Title": null
} | 12778 |
A function (also called a procedure, method, subroutine, or routine) is a portion of code intended to carry out a single, specific task. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:35:40.263",
"Id": "12779",
"Score": "0",
"Tags": null,
"Title": null
} | 12779 |
Database design is the process of specifying the logical and/or physical parts of a database. The goal of database design is to make a representation of some "universe of discourse" - the types of facts, business rules and other requirements that the database is intended to model. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:37:16.017",
"Id": "12781",
"Score": "0",
"Tags": null,
"Title": null
} | 12781 |
<p>Collections APIs provide developers with a set of classes and interfaces that makes it easier to handle collections of objects. In a sense, collections work a bit like arrays, except their size can change dynamically, and they have more advanced behaviour than arrays. </p>
| [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:39:01.710",
"Id": "12782",
"Score": "0",
"Tags": null,
"Title": null
} | 12782 |
Collections APIs provide developers with a set of classes and interfaces that makes it easier to handle collections of objects. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:39:01.710",
"Id": "12783",
"Score": "0",
"Tags": null,
"Title": null
} | 12783 |
MATLAB is a high-level language and interactive programming environment developed by MathWorks. It is the foundation for a number of other tools, including Simulink and various toolboxes that extend the core capabilities. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:40:10.227",
"Id": "12785",
"Score": "0",
"Tags": null,
"Title": null
} | 12785 |
Architecture encompasses the process, artifacts and high-level structure of a solution. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:41:02.033",
"Id": "12787",
"Score": "0",
"Tags": null,
"Title": null
} | 12787 |
<p><a href="http://en.wikipedia.org/wiki/Type_conversion" rel="nofollow">From Wikipedia</a>:</p>
<blockquote>
<p>In computer science, <strong>type conversion</strong>, <strong>typecasting</strong>, and <strong>coercion</strong> are
different ways of, implicitly or explicitly, changing an entity of one
data type ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:42:56.977",
"Id": "12788",
"Score": "0",
"Tags": null,
"Title": null
} | 12788 |
Casting is a process where an object type is explicitly converted into another type if the conversion is allowed. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:42:56.977",
"Id": "12789",
"Score": "0",
"Tags": null,
"Title": null
} | 12789 |
Synchronization refers to using controls to maintain a coherent representation, such as processes running the same program (process synchronization). | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:44:21.390",
"Id": "12791",
"Score": "0",
"Tags": null,
"Title": null
} | 12791 |
<p>Linux was created by Linus Torvalds in 1991 as a hobby project, and quickly caught as the only freely available Unix-like system of that time. Today, it's one of the biggest operating systems, most notably is the Android project which runs on Linux.</p>
<p>The Linux kernel is written mostly in C and is released und... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:44:59.703",
"Id": "12792",
"Score": "0",
"Tags": null,
"Title": null
} | 12792 |
Linux is a free (libre), open source, Unix-like operating system. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:44:59.703",
"Id": "12793",
"Score": "0",
"Tags": null,
"Title": null
} | 12793 |
The Standard Template Library, or STL, is a C++ library of generic containers, iterators, algorithms, and function objects.
When C++ was standardised, large parts of the STL were adopted into the Standard Library, and these parts in the Standard Library are also sometimes referred to collectively as "the STL". | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:46:14.303",
"Id": "12795",
"Score": "0",
"Tags": null,
"Title": null
} | 12795 |
Generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:47:06.097",
"Id": "12797",
"Score": "0",
"Tags": null,
"Title": null
} | 12797 |
<p>I have a table containing URLs as they should appear in English and equivalent translations of them into other languages. Originally, I was told that there would always be an English translation, so when listing them in the application that updates them I just searched for the ones where <code>iso = 'GB'</code>. H... | [] | [
{
"body": "<p>Your query isn't right, and in my opinion, your schema doesn't make sense either.</p>\n\n<p>What is the purpose of the sub-select in your query? Is your query not equivalent to</p>\n\n<pre><code>SELECT * \n FROM `translations_urls` AS `t`\n GROUP BY `url_gb`\n ORDER BY iso = 'GB' DESC, `... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:48:34.940",
"Id": "12798",
"Score": "2",
"Tags": [
"sql",
"mysql"
],
"Title": "Sanity check on grouping query"
} | 12798 |
<p><strong><a href="http://www.postgresql.org" rel="nofollow">PostgreSQL</a></strong> (<a href="http://wiki.postgresql.org/wiki/Identity_Guidelines" rel="nofollow">often Postgres</a>) is a powerful, object-relational database system (<b>O</b>RDBMS, to be even more specific).</p>
<p>Open source since 1996, it has a pro... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:48:55.393",
"Id": "12799",
"Score": "0",
"Tags": null,
"Title": null
} | 12799 |
PostgreSQL is an open-source, Relational Database Management System (RDBMS) available for many platforms including Linux, UNIX, MS Windows and Mac OS X.
Please mention your PostgreSQL version when asking questions. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:48:55.393",
"Id": "12800",
"Score": "0",
"Tags": null,
"Title": null
} | 12800 |
Bitwise refers to a bitwise operation which operates on one or more bit patterns or binary numerals at the level of their individual bits. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:49:19.963",
"Id": "12802",
"Score": "0",
"Tags": null,
"Title": null
} | 12802 |
<p><a href="http://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29" rel="nofollow">From Wikipedia</a>:</p>
<blockquote>
<p>In computer science, a <strong>stack</strong> is a particular kind of abstract data
type or collection in which the principal (or only) operations on the
collection are the addition of ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:50:31.303",
"Id": "12803",
"Score": "0",
"Tags": null,
"Title": null
} | 12803 |
A stack is a last in, first out (LIFO) abstract data type and data structure. Perhaps the most common use of stacks is to store subroutine arguments and return addresses. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:50:31.303",
"Id": "12804",
"Score": "0",
"Tags": null,
"Title": null
} | 12804 |
XSLT is a transformation language for XML. Its primary function is to transform XML documents into different output formats, commonly other XML, HTML or plain text. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:50:51.663",
"Id": "12806",
"Score": "0",
"Tags": null,
"Title": null
} | 12806 |
Merge sort is an O(n log n) comparison-based sorting algorithm. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:51:26.263",
"Id": "12808",
"Score": "0",
"Tags": null,
"Title": null
} | 12808 |
<p>Recursion is a kind of function call in which a function calls itself. Such functions are also called <strong>recursive</strong> functions. </p>
<p>Some functional programming languages do not define any looping constructs, but rely solely on recursion to repeatedly call code. Likewise, in languages that do provide... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2012-06-20T10:51:55.313",
"Id": "12809",
"Score": "0",
"Tags": null,
"Title": null
} | 12809 |
Recursion in computer science is a method of problem solving where the solution to a problem depends on solutions to smaller instances of the same problem. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:51:55.313",
"Id": "12810",
"Score": "0",
"Tags": null,
"Title": null
} | 12810 |
<p><a href="http://www.gnu.org/software/emacs/" rel="nofollow">GNU Emacs</a> is an extensible, customizable text editor. Begun in the mid-1970s as TECO, it was re-written using C and <a href="http://www.gnu.org/software/emacs/manual/html_node/elisp/index.html" rel="nofollow">Emacs Lisp</a> to provide portability and a... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:52:57.493",
"Id": "12811",
"Score": "0",
"Tags": null,
"Title": null
} | 12811 |
GNU Emacs is an extensible, customizable, self-documenting text editor written in C with Emacs Lisp as its extension language. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:52:57.493",
"Id": "12812",
"Score": "0",
"Tags": null,
"Title": null
} | 12812 |
<p>Questions about Sudoku include:</p>
<h3>Validating a Sudoku:</h3>
<ul>
<li><a href="https://codereview.stackexchange.com/questions/6701/sudoku-solver-optimization">Sudoku Solver Optimization</a></li>
<li><a href="https://codereview.stackexchange.com/questions/46033/sudoku-checker-in-java">Sudoku Checker in Java</a... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:53:22.267",
"Id": "12813",
"Score": "0",
"Tags": null,
"Title": null
} | 12813 |
Sudoku (数独 sūdoku?, すうどく) English pronunciation: /suːˈdoʊkuː/ soo-doh-koo is a logic-based, combinatorial number-placement puzzle. The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 sub-grids that compose the grid (also called "boxes", "blocks", "regions", or "sub-sq... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:53:22.267",
"Id": "12814",
"Score": "0",
"Tags": null,
"Title": null
} | 12814 |
Sed stands for Stream EDitor. It is one of the basic tools in the POSIX environment - it processes one or more files according to an editing script and writes the results to standard output. Created in Bell Labs, it has been around since mid-70s. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:57:02.327",
"Id": "12816",
"Score": "0",
"Tags": null,
"Title": null
} | 12816 |
<p>Immutability is the inability to modify a variable after it is has been created.</p>
<p>It is a pattern found in many branches of programming; immutable objects are used widely within object oriented languages (<em>such as Python's <code>str</code> type, Java's <code>String</code> and <code>Integer</code> type, .NE... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:58:00.000",
"Id": "12817",
"Score": "0",
"Tags": null,
"Title": null
} | 12817 |
Immutability is the inability to modify data after it has been created. Modifications are instead made by copying the data. A property of immutable data is that it is *referentially transparent*. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T10:58:00.000",
"Id": "12818",
"Score": "0",
"Tags": null,
"Title": null
} | 12818 |
<p>Fortran is a general-purpose, procedural, imperative programming language that is especially used for numeric computation and scientific computing.</p>
<p>It has a long history, and is still evolving: the first language proposal was put together by J. W. Backus in 1953, the first international standard was approved... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T11:01:33.583",
"Id": "12819",
"Score": "0",
"Tags": null,
"Title": null
} | 12819 |
Fortran is a general-purpose, procedural, imperative programming language that is especially suited for numeric computation and scientific computing. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T11:01:33.583",
"Id": "12820",
"Score": "0",
"Tags": null,
"Title": null
} | 12820 |
<p>The D language is statically typed and compiles directly to machine code. It supports many programming styles: imperative, object oriented, functional, and metaprogramming. It's a member of the C syntax family, and its appearance is very similar to that of C++. D was originally developed by <a href="http://en.wikipe... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T11:03:17.997",
"Id": "12821",
"Score": "0",
"Tags": null,
"Title": null
} | 12821 |
D is a systems programming language developed by Walter Bright and since 2006 Andrei Alexandrescu. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. Special attention is given to the needs of concurrency, reliability, documen... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T11:03:17.997",
"Id": "12822",
"Score": "0",
"Tags": null,
"Title": null
} | 12822 |
<p>I have a servlet deployed in a Tomcat Servlet Container in this link, <code>http://localhost:9764/example/servlets/servlet/HelloWorldExample</code>. I want to send a HTTP request to that servlet using Java. Just I want to get the return as a String. Currently I am using this code to do it, Is it OK to use this code?... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T03:54:51.573",
"Id": "20708",
"Score": "1",
"body": "This appears ok. What problem you are facing ?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T03:58:50.887",
"Id": "20709",
"Score": "0",
... | [
{
"body": "<p>when you are sending any data to the servlet make sure it you send it via POST/GET depending on how sensitive the information is. In your case the user and password is sent through the get which is unsafe since it can be viewed by anyone. </p>\n\n<p>you can add.<code>urlConnection.setRequestMethod... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-19T03:52:06.413",
"Id": "12826",
"Score": "1",
"Tags": [
"java",
"networking"
],
"Title": "How to access a servlet in Tomcat Contanier using Java"
} | 12826 |
<p>I am wondering if this is a good and correct way to write the implementation of two web service methods (get/set methods).</p>
<p>The <code>setPerson</code> method can be called from different threads from a pool, so I think the best way is to make the method <code>synchronized</code>. Or is it possible to lock the... | [] | [
{
"body": "<p>Just a few notes:</p>\n\n<pre><code>if(!em.getTransaction().isActive()) {\n em.getTransaction().begin();\n}\ntry {\n em.merge(person);\n em.getTransaction().commit(); \n emf.getCache().evict(Person.class);\n} catch (Exception ex) {\n if(em.getTransaction().isActive())\n e... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T13:26:51.347",
"Id": "12833",
"Score": "2",
"Tags": [
"java",
"synchronization",
"web-services"
],
"Title": "Webservice methods using EclipseLink and database entities"
} | 12833 |
<p>I use <code>NPOI</code> to copy Excel formula, but can't find an option to do it in a relative way. Therefore, I've written a function to implement it. The task is "easy". When copying a formula <code>A1+B1</code> of <code>C1</code> to <code>C2</code>, the result will be <code>A2+B2</code>. But the formula can do mo... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T15:42:54.050",
"Id": "20724",
"Score": "1",
"body": "Do you know R1C1 reference style ? It seems to me your are trying to re-invent it."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T16:58:07.703",
... | [
{
"body": "<p>I haven't used NPOI and I would believe you have valid reasons for using it (I'll take a wild guess at saying the thing is running on a server that doesn't have Excel installed), but for the record, if my memory isn't failing me if you used Microsoft VSTO / Excel Interop, you could use a plain &am... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T15:04:28.403",
"Id": "12837",
"Score": "6",
"Tags": [
"c#",
"excel"
],
"Title": "Copy Excel formula in a relative way"
} | 12837 |
<p>I have a custom <code>SPList</code> that has a field <code>Assigned To</code>, now I can add as many items as I want, and they can have same title and same <code>User</code> they are assigned to, but what I want is a script so that I only get the distinct number of user's email address, e.g. if a user is assigned to... | [] | [
{
"body": "<ol>\n<li><p>The <code>my</code> prefixes are unnecessary, I'd call the variables <code>sourceList</code>, <code>sourceListQuery</code>, <code>sourceItems</code> etc.</p></li>\n<li><p>I'd create a method for this:</p>\n\n<pre><code>name = name.Substring(name.IndexOf(\"#\") + 1);\n</code></pre>\n\n<p>... | {
"AcceptedAnswerId": "12843",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T15:42:18.513",
"Id": "12838",
"Score": "2",
"Tags": [
"c#",
"sharepoint"
],
"Title": "Getting SharePoint users and comparing them with SPList"
} | 12838 |
<p>I've got a fairly performance sensitive need for fast prefix lookup, and I've built two different implementations trying to optimize for my use case. The first is built off a <a href="http://en.wikipedia.org/wiki/Trie" rel="nofollow">Trie</a> implementation, and the second uses binary search. Testing them both, th... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T09:34:13.210",
"Id": "20751",
"Score": "1",
"body": "Do you think about pure C character trie implementation, wrapped into python extension like:https://github.com/buriy/python-chartrie"
},
{
"ContentLicense": "CC BY-SA 3.0"... | [
{
"body": "<p>If you need performance I would suggest <a href=\"http://biopython.org\" rel=\"nofollow\">BioPython Library</a> It has nice and very fast implementation of trie with prefix search, serialization, etc.</p>\n\n<p>It's a small example using word file (~179.000 words):</p>\n\n<pre><code>from Bio impo... | {
"AcceptedAnswerId": null,
"CommentCount": "8",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T18:57:02.350",
"Id": "12841",
"Score": "10",
"Tags": [
"python",
"performance",
"binary-search",
"lookup"
],
"Title": "Implementations of prefix lookup tables"
} | 12841 |
<p><a href="http://backbonejs.org" rel="nofollow">Backbone.js</a> is a client-side JavaScript framework that gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all t... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:22:29.670",
"Id": "12844",
"Score": "0",
"Tags": null,
"Title": null
} | 12844 |
Backbone.js is a JavaScript framework that provides structure to RESTful web applications. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:22:29.670",
"Id": "12845",
"Score": "0",
"Tags": null,
"Title": null
} | 12845 |
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:23:33.927",
"Id": "12847",
"Score": "0",
"Tags": null,
"Title": null
} | 12847 |
<p><a href="http://www.gnu.org/software/emacs/manual/html_node/elisp/index.html" rel="nofollow">Emacs Lisp</a> is the extension language for the <a href="http://www.gnu.org/software/emacs/" rel="nofollow">GNU Emacs text editor</a>, and in fact, most of the functionality of Emacs is implemented using Emacs Lisp. Users ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:24:26.437",
"Id": "12848",
"Score": "0",
"Tags": null,
"Title": null
} | 12848 |
Emacs Lisp is the extension language for the GNU Emacs text editor, and in fact, most of the functionality of Emacs is implemented using Emacs Lisp. Users generally customize Emacs' behavior by adding Emacs Lisp statements to their .emacs, or writing separate packages. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:24:26.437",
"Id": "12849",
"Score": "0",
"Tags": null,
"Title": null
} | 12849 |
<p>RSpec is a <a href="http://en.wikipedia.org/wiki/Behavior-driven_development" rel="nofollow">behaviour-driven development</a> (BDD) tool for Ruby programmers. BDD is an approach to software development that combines <a href="http://en.wikipedia.org/wiki/Test-driven_development" rel="nofollow">test-driven development... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:27:16.693",
"Id": "12850",
"Score": "0",
"Tags": null,
"Title": null
} | 12850 |
RSpec is a behaviour-driven development (BDD) framework for the Ruby language. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:27:16.693",
"Id": "12851",
"Score": "0",
"Tags": null,
"Title": null
} | 12851 |
<p>Web services can either be defined using the Web Services Description Language (WSDL) and consumed via Simple Object Access Protocol (SOAP), or follow a Representational State Transfer (REST) model.</p>
| [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:28:38.920",
"Id": "12852",
"Score": "0",
"Tags": null,
"Title": null
} | 12852 |
<h1>What is Groovy?</h1>
<p>Groovy is a dynamic object-oriented programming language for the Java virtual machine (JVM) that can be used anywhere Java is used. The language can be used to combine Java modules, extend existing Java applications and write new applications.</p>
<p>Groovy can serve as a scripting languag... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:29:13.990",
"Id": "12854",
"Score": "0",
"Tags": null,
"Title": null
} | 12854 |
Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It can be used as a scripting language for the Java Platform. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:29:13.990",
"Id": "12855",
"Score": "0",
"Tags": null,
"Title": null
} | 12855 |
Pthreads (POSIX Threads) is a standardised C-based API for creating and manipulating threads on a POSIX-compliant system. It is defined by the standard "POSIX.1c, Threads extensions (IEEE Std 1003.1c-1995)", and subsequently by the Single Unix Specification. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T21:34:23.640",
"Id": "12857",
"Score": "0",
"Tags": null,
"Title": null
} | 12857 |
<p>I am new to Python and want to have a "pythonic" coding style from the very beginning. Following is a piece of codes I wrote to generate all combinations and permutations of a set of symbols, e.g. <code>abc</code> or <code>123</code>. I mainly seek for suggestions on code style but comments on other aspects of code... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T07:18:53.517",
"Id": "20745",
"Score": "1",
"body": "Just in case you didn't know, python has permutations and combinations in itertools package in stdlib."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06... | [
{
"body": "<p>Just use the standard modules :)</p>\n\n<pre><code>import itertools\nfor e in itertools.permutations('abc'):\n print(e)\n</code></pre>\n",
"comments": [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-22T14:55:29.370",
"Id": "20882",
"Score... | {
"AcceptedAnswerId": "12862",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T04:47:38.713",
"Id": "12858",
"Score": "8",
"Tags": [
"python",
"reinventing-the-wheel"
],
"Title": "Generating all combinations and permutations of a set of symbols"
} | 12858 |
<p><strong>Problem</strong>
Starting in the top left corner of a 22 grid, there are 6 routes (without backtracking) to the bottom right corner.</p>
<p><img src="https://i.stack.imgur.com/VN3Ue.gif" alt="enter image description here">
How many routes are there through a 2020 grid?</p>
<p><strong>Solution</strong>
Here... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T07:51:30.230",
"Id": "20746",
"Score": "2",
"body": "How to add memoization? Write a decorator to store the results. This is a common homework problem so I'll leave it at that."
},
{
"ContentLicense": "CC BY-SA 3.0",
"Cr... | [
{
"body": "<p>Finally my memoization technique worked and the result appears in less than a sec</p>\n\n<pre><code> cache = []\nfor i in range(20):\n cache.append([])\n for j in range(20):\n cache[i].append(0)\n\ndef step(i,j):\n if(i==2 or j==2):\n return 1\n if(cache[i][j]>0):\n... | {
"AcceptedAnswerId": "12863",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T07:29:44.907",
"Id": "12861",
"Score": "2",
"Tags": [
"python",
"project-euler"
],
"Title": "How do I add memoization to this problem?"
} | 12861 |
<p>Open source software is software distributed under an open source license. Such a license specifially allow anyone to copy, modify and redistribute the source code without paying royalties or fees. There are dozens of open source licenses. To determine whether a particular license should be considered an Open Source... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T09:50:57.147",
"Id": "12866",
"Score": "0",
"Tags": null,
"Title": null
} | 12866 |
Design pattern to reduce coupling between components, by dynamically injecting into a software component dependencies that it needs to function. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T09:51:50.877",
"Id": "12869",
"Score": "0",
"Tags": null,
"Title": null
} | 12869 |
<h2>Definition:</h2>
<p>SharePoint 2016 is Microsoft's document management and collaboration tool with a software-as-a-service strategy at its core. Like SharePoint 2013, the product is offered in the cloud as part of the Office 365 suite and is known as SharePoint Online; the on-premises version is known as SharePoin... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T09:52:53.250",
"Id": "12870",
"Score": "0",
"Tags": null,
"Title": null
} | 12870 |
The computer program yacc is a parser generator developed by Stephen C. Johnson at AT&T for the Unix operating system. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T09:53:26.673",
"Id": "12873",
"Score": "0",
"Tags": null,
"Title": null
} | 12873 |
Simple Object Access Protocol (SOAP) is a protocol specification for exchanging structured information in the implementation of Web Services. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T09:55:11.087",
"Id": "12875",
"Score": "0",
"Tags": null,
"Title": null
} | 12875 |
<p>The performance of applications is often a paramount concern for mission-critical systems. If your question pertains to execution-time optimization, whether it be database queries, algorithms, or anything that deals with speed or throughput, consider using this tag.</p>
<p>The two main measures of performance are</... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2012-06-21T09:58:05.683",
"Id": "12876",
"Score": "0",
"Tags": null,
"Title": null
} | 12876 |
Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T09:58:05.683",
"Id": "12877",
"Score": "0",
"Tags": null,
"Title": null
} | 12877 |
<p>I'm pretty sure there's a way to make this "3 times" duplicated code into only one. Any idea how to do this?</p>
<pre><code>if (typeof sync.create!='undefined') {
for (var i = 0; i <sync.create.length; i++) {
sync.create[i].modified.id_partenaire=false;
};
}
if (typeof sync.update!='undefine... | [] | [
{
"body": "<p>If this should be executed on all properties of <code>sync</code> in general, i'd go with a <code>for..in</code> loop. </p>\n\n<pre><code>for(var prop in sync){\n if(sync.hasOwnProperty(prop) && typeof sync[prop] !== 'undefined'){\n var i=0, l = sync[prop].length;\n for (i; i < l... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T10:52:04.107",
"Id": "12879",
"Score": "1",
"Tags": [
"javascript"
],
"Title": "Handling create, update, and destroy for sync"
} | 12879 |
<p>I am developing data-interfacing that converts between two different data models.
However, I must be sure that all required fields exist. Therefore I have written this utility class that I can easily use to verify required fields.</p>
<p>However I am unsure whether this is the best way because of the expression tha... | [] | [
{
"body": "<p>I don't see any unnecessary reflection in your code.</p>\n\n<p>One think that could be simplified is your check for <code>string.Empty</code>:</p>\n\n<pre><code>if (fieldValue == null || fieldValue as string == string.Empty)\n</code></pre>\n",
"comments": [
{
"ContentLicense": "C... | {
"AcceptedAnswerId": "12886",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T11:42:44.380",
"Id": "12882",
"Score": "4",
"Tags": [
"c#",
"linq",
"reflection"
],
"Title": "Usage of Expression<Func<T>>"
} | 12882 |
<p>I've been learning Python 2.7 for about a week now and have written a quick program to ask for names of batters and printing a score sheet. I have then added the names to a list which I will use more in other future functions.</p>
<p>I have a few questions:</p>
<ol>
<li><p>I feel like there is too much repetition ... | [] | [
{
"body": "<p>If you find yourself using serialized variable names (player1, player2, etc) it is a pretty sure sign you should be using a list or dictionary instead.</p>\n\n<p>Global is useful if, in a function, you are using a variable from a higher scope and need to store changes back to it. In most cases, it... | {
"AcceptedAnswerId": "12891",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T20:45:44.867",
"Id": "12889",
"Score": "5",
"Tags": [
"python",
"python-2.x"
],
"Title": "Printing a score sheet for baseball batters"
} | 12889 |
<p>I'm in the process of building some templates for Joomla, and although it all works as desired, I can't help thinking that there has to be a more elegant way to do this in PHP than my current approach. For the record, I'm still reasonably new to PHP!</p>
<p>Using collapsible module positions, I need to assign vario... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T15:48:21.540",
"Id": "20780",
"Score": "0",
"body": "I'd imagine there as many ways to accomplish it as there are developers. We generally use Rockettheme templates. Most of them accomplish what you're trying to do, with the newer o... | [
{
"body": "<p>Something somewhat confusing is the comparison to of each $footer# to the string '0' then later comparing it to greater than integer 0. This is practically the definition of weakly typed languages. If you know what $footer# variables actually contain you might be able to simplify this, but here ... | {
"AcceptedAnswerId": "12910",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-20T15:28:17.067",
"Id": "12893",
"Score": "3",
"Tags": [
"beginner",
"php",
"joomla"
],
"Title": "Joomla PHP Template Logic"
} | 12893 |
<pre><code>var searchDetails = "";
searchDetails += $("#last-name").val();
searchDetails += searchDetails != "" ? " "+$("#first-name").val() : $("#first-name").val();
searchDetails += searchDetails != "" ? " "+$("#middle-name").val() : $("#middle-name").val();
if ($("#dob-dd").val() != "" || $("#dob-mm").val() != "" ||... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-25T01:26:31.697",
"Id": "21047",
"Score": "0",
"body": "Shouldn't the fallback value for `dob-yyyy` be `xxxx`? Your code only uses `xx` for the year, but your examples show `xxxx`"
}
] | [
{
"body": "<p>Firstly, I'd create a helper function for the <code>!= \"\"</code> check:</p>\n\n<pre><code>function isEmptyString(value) {\n if (value == \"\") {\n return true;\n }\n return false;\n}\n</code></pre>\n\n<p>It would make the code easier to read.</p>\n\n<p>Then I'd extract out a func... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T18:12:35.927",
"Id": "12898",
"Score": "2",
"Tags": [
"javascript"
],
"Title": "How to simplify code, which adds spaces and commas if field value is not empty?"
} | 12898 |
<p>I have the following code, but I don't know how to make it run faster.</p>
<pre><code>SELECT lot.order as lot_order,
lot.title as lot_title,
lot.id as lot_id,
lot.id_auction,
IF (
(SELECT bid
FROM bid
WHERE lot.id = bid.id_lot
ORDER BY bid.date DES... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T21:47:50.830",
"Id": "20808",
"Score": "0",
"body": "I think English table and column names would improve readability a lot for the majority of users here."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06... | [
{
"body": "<p>This should be a little better. I believe joins are faster than nested selects, and that if with nested select may or may not select twice or use cached response. I can't think of a good way of getting rid of the one nested select. Otherwise, maybe you could write it as a stored procedure or vir... | {
"AcceptedAnswerId": "12920",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T20:07:36.800",
"Id": "12902",
"Score": "2",
"Tags": [
"performance",
"mysql",
"sql"
],
"Title": "Inner select performance"
} | 12902 |
<p>Guava is the open-sourced version of Google's core Java libraries that aims to make working in the Java language more pleasant and more productive.</p>
<p>It contains several core libraries that Google rely on in their Java-based projects: collections, caching, primitives support, concurrency libraries, common anno... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T20:14:34.107",
"Id": "12903",
"Score": "0",
"Tags": null,
"Title": null
} | 12903 |
The Guava project is a set of Java core libraries. They include collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O etc. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T20:14:34.107",
"Id": "12904",
"Score": "0",
"Tags": null,
"Title": null
} | 12904 |
Joda-Time provides a quality replacement for the Java date and time classes. The design allows for multiple calendar systems, while still providing a simple API. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T20:15:25.877",
"Id": "12906",
"Score": "0",
"Tags": null,
"Title": null
} | 12906 |
<p>Forth, invented in 1958, released in the 70's. Rather than using arguments passed to functions, it used words that implicitly operated on the top of the stack. The fallowing is valid Forth code:</p>
<pre><code>: double \ Define the word, double.
( x -- x+x) \ The comment in the ()'s says this function consumes ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T20:50:49.920",
"Id": "12908",
"Score": "0",
"Tags": null,
"Title": null
} | 12908 |
Stack oriented (or based) languages, more recently referred to as concatenative languages, use a global stack for implicit argument passing. In terms of functional programming, they focus on function composition over lambda calculus. The first stack-based language was Forth. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T20:50:49.920",
"Id": "12909",
"Score": "0",
"Tags": null,
"Title": null
} | 12909 |
<p>What would be the most <em>efficent</em> way to calculate this?</p>
<pre><code>var reportLimit = 96*1024;
IEnumerable<int> memoryInUse =
things
.Where(sample => sample.IsOn)
.Select(sample => sample.MemoryInMb)
.ToArray();
int totalUnderReportLimit = memoryInUse.Where(ram => ram <... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T23:10:48.023",
"Id": "20812",
"Score": "1",
"body": "If you want to find out what is faster, running benchmarks is *exactly* what you should do. I'm not sure why are you avoiding that."
},
{
"ContentLicense": "CC BY-SA 3.0",... | [
{
"body": "<p>I guess one way to potentially speed it up (if the issue was with running over the enumerable twice) would be to use a foreach. However, I don't think it's as readable as your solution;</p>\n\n<pre><code>int countOverLimit = 0;\n\nforeach(var ram in memoryUse)\n{\n if(ram <= memoryCalcFacto... | {
"AcceptedAnswerId": "12916",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-06-21T22:37:39.657",
"Id": "12911",
"Score": "5",
"Tags": [
"c#",
"linq"
],
"Title": "Simple LINQ statement for report limit"
} | 12911 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.