body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>This is code of a rails app. The code has the logic used in a search form. It queries a MySQL database. Any thoughts on something that would make this unsafe or violated a rails principle?</p> <p>/app/models/query.rb</p> <pre><code>class Query &lt; ActiveRecord::Base attr_accessible :customer_email, :customer_fi...
[]
[ { "body": "<p>I think you could change your code to this :</p>\n\n<pre><code>class Query &lt; ActiveRecord::Base\n attr_accessible :customer_email, :customer_first_name, :customer_last_name, \n :max_total_amount, :min_total_amount, :order_id, :order_is_deleted,\n :order_max_da...
{ "AcceptedAnswerId": "13542", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T05:26:44.897", "Id": "13530", "Score": "2", "Tags": [ "ruby", "ruby-on-rails", "active-record" ], "Title": "Rails app query form code behind" }
13530
<p>I have a <code>FileAsset</code> class. I have a set of 'filters' with which I determine if a <code>FileAsset</code> should be written to my database. Below is a telescoped version of how the filters work now. My big question is this: Is there a better way? Any advice would be awesome!</p> <p>(By the way, the <c...
[]
[ { "body": "<p>You have written a small DSL to map tests to Python operations. The DSL uses <code>dict</code>s which imposes some limitations. Try this approach instead:</p>\n\n<pre><code>filter1 = FileFilter().filenameEndsWith('.txt').build()\n\nnames = ['test.txt', 'test.jpg']\nto_save = filter(filter1, names)...
{ "AcceptedAnswerId": "13532", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T06:55:44.737", "Id": "13531", "Score": "2", "Tags": [ "python" ], "Title": "Filtering logic" }
13531
<p>I have a MySQL result set in a PHP multidimensional array.</p> <p>I want to iterate through it and output it sanitized. Considering the two alternatives below, are there any performance differences?</p> <p><strong>filter_var_array on the whole result set before iterating:</strong></p> <pre><code>$sql_rows = filte...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T13:34:18.170", "Id": "21936", "Score": "3", "body": "It could go either way. On one hand, you run a function once, on the other you run it multiple times but on much smaller pieces. I'm not sure which would be the better bet for you...
[ { "body": "<p>Is this really the bottleneck in you application? If not choose the readable one. See <em>Effective Java, 2nd Edition, Item 55: Optimize judiciously</em> I know that this is a Java book but this chapter (and many others) is useful for every developer.</p>\n\n<p>Some other notes:</p>\n\n<ol>\n<li><...
{ "AcceptedAnswerId": "13551", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T12:15:54.023", "Id": "13534", "Score": "2", "Tags": [ "php", "performance" ], "Title": "Use filter_var_array on whole array, or inside iteration" }
13534
<p>I have few controls on my page which I want to show/hide and/or enable/disable on some condition.</p> <p>Images to help illustrate the requirements:</p> <p><img src="https://i.stack.imgur.com/Vx1aD.png" alt="screenshot1"> <img src="https://i.stack.imgur.com/yQPOV.png" alt="screenshot2"> <img src="https://i.stack....
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T14:02:34.540", "Id": "21939", "Score": "1", "body": "You need to put your requirements in words here or a embedded picure... you can't expect us to click through your links just to figure out what you're doing..." } ]
[ { "body": "<p>First possible refactoring: define an enumeration for the three possible states</p>\n\n<pre><code>enum InputState{\n Hidden,\n Disabled,\n Enabled\n}\n</code></pre>\n\n<p>and use it with an extension method (or by extending the class)</p>\n\n<pre><code>public static void SetVisibility(thi...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T13:32:03.460", "Id": "13535", "Score": "2", "Tags": [ "c#" ], "Title": "Extract common code to enable/disable, show/hide controls on some condition" }
13535
<p>I was having a problem with the TCP/IP socket communications in a web app where the server that the app was talking to would occasionally send bursts of data that would overflow the low level stream buffer, resulting in lost data.</p> <p>The solution I came up with is basically an unthreaded form of the <a href="ht...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T14:30:53.273", "Id": "22207", "Score": "0", "body": "Would it be at all helpful if I added the unit tests?" } ]
[ { "body": "<p>To be precise I have no real solution to your problem, but if I think about it there should be a few possibilities to find one: First you could think about limiting data send by the App. A limitation could mean a two way communication and/or a sending buffer on side of the App. So you can regulate...
{ "AcceptedAnswerId": "13795", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T14:04:48.067", "Id": "13536", "Score": "11", "Tags": [ "scala", "networking" ], "Title": "Alternate form of BufferedInputStream" }
13536
<p>Which of these 3 python snippets is more pythonic?</p> <p>This 1 liner list comprehensions which is a little overcomplex</p> <pre><code>users_to_sent = [(my_database.get_user_by_id(x), group['num_sent'][x]) for x in user_ids] </code></pre> <p>or this multi liner which is 'too many lines of code'</p> <pre><code>u...
[]
[ { "body": "<p>You'd definitely need to name your function something more descriptive than <code>build_tuple</code> for it to be a good idea (and same with <code>t1</code> and <code>t2</code> in the multi-liner!). </p>\n\n<p>I'd use a function if it's something you do more than once or twice, otherwise I'd prob...
{ "AcceptedAnswerId": "13544", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T16:14:54.093", "Id": "13541", "Score": "1", "Tags": [ "python" ], "Title": "Pythonic style guide" }
13541
<p>I have some C# I/O code that can take one <strong>or</strong> two input files. I would like to wrap the <code>Stream</code> objects in a <code>using</code> block, but cannot find a way to succinctly express this in code.</p> <p>Currently, I have two large files (>1GB), that contain concatenated TIFF files and PDF ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T17:02:30.227", "Id": "21944", "Score": "0", "body": "If you expect additional input streams in the future, then you should treat the input as a *collection* of files, not something like “maybe one, maybe two, maybe three, possibly f...
[ { "body": "<p>The only think that I would do different is that I wouldn't dispose streams inside your <code>FileProcessor</code> classes. Disposing of resources should be done at the same level (or scope) where they were initialized. Unfortunately, even BCL classes like <code>StreamWriter</code> and <code>Binar...
{ "AcceptedAnswerId": "13569", "CommentCount": "6", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T16:47:22.013", "Id": "13543", "Score": "3", "Tags": [ "c#" ], "Title": "Restucture code to wrap optional resources in a using block" }
13543
<p>Any suggestions how I could simplify this LINQ query?</p> <pre><code>from type in assembly.GetTypes() where type.IsPublic &amp;&amp; !type.IsSealed &amp;&amp; type.IsClass where (from method in type.GetMethods() from typeEvent in type.GetEvents() where method.Name.EndsWith("Async") where typeEv...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T18:38:04.620", "Id": "21950", "Score": "2", "body": "What I can see immediately is that you could replace `Count() > 0` with `Any()`, which is simpler and also more efficient." } ]
[ { "body": "<p>You can do a join between the methods and events :</p>\n\n<pre><code>from type in assembly.GetTypes()\nwhere type.IsPublic &amp;&amp; !type.IsSealed &amp;&amp; type.IsClass\nwhere (from method in type.GetMethods()\n join typeEvent in type.GetEvents()\n on method.Name.Replace(\"As...
{ "AcceptedAnswerId": "13546", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T18:25:42.147", "Id": "13545", "Score": "4", "Tags": [ "c#", "linq" ], "Title": "Simplify a complex LINQ query" }
13545
<p>I wrote this code (except the getting text from clipboard part) a while back, and I'm wondering if it could be written better? Can anyone help me improve this code?</p> <p>This code basically takes HTML from the clipboard, and then attempts to fix the indentation and writes it to a new file.</p> <pre><code>public ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T21:04:35.443", "Id": "21952", "Score": "3", "body": "Quick superficial suggestions. I believe CamelCasing is the standard convention for c# variables and Pascalcase method calls. StyleCop would go along way to addressing this. Al...
[ { "body": "<ul>\n<li>What everyone else said about camelCase &amp; style-cop</li>\n<li>slice: need to be careful if start and end values are valid. </li>\n<li>prefix_check: why not put incoming items into hash to this goes from order(n) operation to order(1)?</li>\n<li>fix_tags: name is unclear. Suggest: Adjust...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T19:50:59.500", "Id": "13547", "Score": "2", "Tags": [ "c#", "html" ], "Title": "Fixing indentations in HTML files" }
13547
<p>Here is the current code for the <code>BitArray</code> class needing optimization (implemented on big integers):</p> <pre><code>import itertools ################################################################################ class BitArray: def __init__(self, values=[], max_size=128): self.__data = ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T00:49:16.717", "Id": "21960", "Score": "0", "body": "In order to optimize this, we first need to know how you are using it. Are you really using all those operations? What kind of bitstrings are you storing? It'd be really useful to...
[ { "body": "<h2>Overall implementation decisions</h2>\n\n<p>The first question is whether you have implemented this in the correct language. Python has its low level data structures implemented in C for a reason. A BitArray will be used like those low level data structures, and I suspect it would be better imple...
{ "AcceptedAnswerId": "13568", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-11T21:44:21.667", "Id": "13549", "Score": "1", "Tags": [ "python", "array", "bitwise", "bit-twiddling" ], "Title": "What specific optimizations can be made to this BitArray cl...
13549
<p>If I'm working in a 2D environment and have hundreds of objects, brute force collision-checking would be out of the question, but would my method below work?</p> <p>For example, let's say I have a</p> <pre><code>std::vector&lt;GameObj*&gt; objectsVector </code></pre> <p>to hold all objects and a</p> <pre><code>s...
[]
[ { "body": "<p>If I'm understanding things correctly, (x,y) is an anchor point of your object (say, bottom left), and you're iterating over every single point that could be an anchor point for an object that it's in collision with, then checking if it's an actual anchor point of an existing object.</p>\n\n<p>My ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T03:58:31.770", "Id": "13556", "Score": "5", "Tags": [ "c++", "optimization", "collision" ], "Title": "Collision-checking optimizations" }
13556
<p>This is the pattern I've been using for "if the variable is empty, set a default value", and for variables like <code>$muffin</code>, it has all seemed well and good. But in the following real example, this pattern gives me a super long line which smells a bit to me. Is there a cleaner way to do this?</p> <pre><c...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2017-03-24T10:08:00.087", "Id": "300436", "Score": "0", "body": "Starting with PHP 7.0, [Langen's answer](http://codereview.stackexchange.com/a/114326/80949) is probably the best: `$newsItems[0]['image_url'] = $newsItems[0]['image_url'] ?? '/i...
[ { "body": "<p>Before dealing with your question, I'd like to point out that you probably want to use <code>empty()</code> instead of comparing with an empty string and that if you really want to compare to an empty string, use the <code>===</code> operator.</p>\n\n<p>Anyway, default initialization <em>is</em> a...
{ "AcceptedAnswerId": "13559", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T09:32:52.730", "Id": "13558", "Score": "37", "Tags": [ "php", "formatting" ], "Title": "Setting a default value if a variable is empty" }
13558
<p>I have got a an object that has values true and false for certain keys.I need to find which keys has got a boolean value and convert them to 1 and 0 respectively.Please find the code below.I wanted to check for keys in an object that has got boolean values and then convert them to numbers.Im a noob in Javascript an...
[]
[ { "body": "<p>I would ask in return: Why do you want to convert booleans to numbers? First of all there must have been a reason to use booleans and not numbers in the first place and second most programming languages use the integer values 1 and 0 respectively for True and False (as I am a Python programmer I a...
{ "AcceptedAnswerId": "13604", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T12:39:40.827", "Id": "13561", "Score": "3", "Tags": [ "javascript" ], "Title": "Check for boolean values in an object and convert them to numbers" }
13561
<p>I have an array of points:</p> <pre><code> Point[] line; // { Point(1,1), Point(2,3), Point(1,1) } </code></pre> <p>Assuming Point has the relevant operators, what's the most linq-y way of computing the length of this line?</p> <p>My best effort so far is:</p> <pre><code>float length = Enumerable.Range(0, line.L...
[]
[ { "body": "<p>You could use linq <code>Zip</code> instead of <code>PairwiseMap</code>. There is a drawback, you have to create two new enumerations with points:</p>\n\n<pre><code>// collection of point/tuples\nvar points = new[] { \n Tuple.Create(1f, 1f), \n Tuple.Create(2f, 3f), \n Tuple.Create(5f, 5...
{ "AcceptedAnswerId": "13600", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T15:06:59.230", "Id": "13567", "Score": "3", "Tags": [ "c#", "linq" ], "Title": "Use linq to compute length of line defined as array of points" }
13567
<p>I am trying to hide and show tooltips depending on what element is hovered over. This works as expected and I could continue to rinse and repeat. However, I am wondering if there is a good way to simplify this or make it more compact. Also I was assuming I could use <code>.hover()</code>, but that didn't seem to wo...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T14:25:55.643", "Id": "21974", "Score": "0", "body": "What is the HTML for .remove and .tooltip, how are they related in the DOM?" } ]
[ { "body": "<p>Use an <code>.each</code> \"loop\":</p>\n\n<pre><code>var tooltips = $('.tooltip');\n\n$('.remove').each(function(i) {\n var tooltip = tooltips.eq(i);\n\n $(this).on({\n mouseover: function() { tooltip.show(); },\n mouseout: function() { tooltip.hide(); }\n });\n});\n</code...
{ "AcceptedAnswerId": "13571", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T14:23:20.847", "Id": "13570", "Score": "3", "Tags": [ "javascript", "jquery", "event-handling" ], "Title": "Simplifying multiple mouseover and mouseout functions" }
13570
<p>Right now in my weather app, I have one section of code in my View Controllers to set up the condition image and the background image. It has about 400 lines of <code>if</code>-<code>else</code> statement at the end.</p> <p>The app's performance is fine, but is it bad to have this? Would it be something that, say, ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T14:12:09.563", "Id": "21989", "Score": "5", "body": "Does objective C allow switch-case with strings like the newer versions of Java? If it does I would use switch-case." }, { "ContentLicense": "CC BY-SA 3.0", "Creation...
[ { "body": "<p>Why don't you just rename your Files to the matching Number?</p>\n\n<pre><code>conditionsImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@\"%@.png\", condition]]; \nBGView.image = [UIImage imageNamed:[NSString stringWithFormat:@\"%@.jpg\", condition]];\n</code></pre>\n", "comm...
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T14:09:18.830", "Id": "13577", "Score": "19", "Tags": [ "objective-c", "ios" ], "Title": "Updating images in a weather app" }
13577
<p>This is my feed parser method using feedzirra. It works, but I feel dirty because I can't figure out how to improve this code. Any suggestions?</p> <pre><code>class Feed &lt; ActiveRecord::Base attr_accessible :name, :summary, :url, :published_at, :guid def self.update_from_feed feed_urls = ["url1", "url2...
[]
[ { "body": "<p>Slight cleanup:</p>\n\n<pre><code>class Feed &lt; ActiveRecord::Base\n # ...\n\n def self.update_from_feed\n feed_urls = [\"url1\", \"url2\", \"ulr3\", \"url4\"]\n Feedzirra::Feed.fetch_and_parse(feed_urls).each do |_, feeds|\n feeds.entries.each do |entry|\n # ...\n end\n...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T17:17:06.877", "Id": "13591", "Score": "4", "Tags": [ "optimization", "ruby", "ruby-on-rails", "parsing" ], "Title": "Improving Rails feed parser" }
13591
<p>I want to insert parameters dynamically to statements at sqlite. I now write as follows: </p> <pre><code> tx.executeSql('SELECT Data from Table Where something = "'+ anyvariable+ '"',[],successFn, errorCB); </code></pre> <p>But I guess there is a better (cleaner) method to do it.. Any ideas?</p>
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T15:58:26.180", "Id": "22018", "Score": "0", "body": "No I said I want a better method. the one with \"?\"," }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T17:31:51.867", "Id": "22019", "Score"...
[ { "body": "<p>I would create an object to model my dynamic parameters using the following interfaces:</p>\n\n<pre><code>{ //reduced format\n clause: string,\n params: an array of parameters if more than one is used\n}\n{ //simple entry format\n clause: string\n param: the parameter if only one is us...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T15:44:53.030", "Id": "13592", "Score": "1", "Tags": [ "javascript", "jquery", "sqlite" ], "Title": "Insert dynamic parameters to sqlite database statements" }
13592
<p>I've written a simple scraper that parses HTML using <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a> and collects the data (schedule of sports events), then clubs them together in a list of dicts.</p> <p>The code works just fine, but the way I process the data is pretty horr...
[]
[ { "body": "<p>Personally, I don't like dependencies (in this case requests and BeautifulSoup). Why just not to use the standard modules?</p>\n\n<pre><code>import urllib, re\n\nURL = 'http://icc-cricket.yahoo.net/match_zone/series/fixtures.php?seriesCode=ENG_WI_2012'\npage = urllib.urlopen(URL).read()\n\n# just ...
{ "AcceptedAnswerId": "13640", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T17:43:12.747", "Id": "13593", "Score": "3", "Tags": [ "python", "web-scraping", "beautifulsoup" ], "Title": "Beautifulsoup scraper for sport events" }
13593
<p>I'm quite new to JavaScript and wrote this clone method to be able to clone any kind of object. It works quite well for the cases I've tested until now, but for JSON objects it seemed kind of slow to me. I'm sure there is some additional speed to to squeeze out and a lot of overall improvement to make. But I don't k...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T22:47:36.970", "Id": "22040", "Score": "0", "body": "Why are you extending `Object.prototype`?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T23:38:41.343", "Id": "22042", "Score": "0", "...
[ { "body": "<p>One thing I noticed was that you are using advanced (ECMAScript 5) parts of JavaScript - this will not work in old browsers, such as IE8 (I don't know where you are planning on using this).</p>\n", "comments": [ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T17:44:58.673", "Id": "13594", "Score": "4", "Tags": [ "javascript", "beginner", "performance", "titanium" ], "Title": "Deep clone method" }
13594
<p>I have multiple drop down lists (select &amp; option) that are populated by data from the server. They all have the same options, but I need the use to be able to select every option only once - it can appear as selected only on one list.</p> <p>This is the HTML of a single list - simple select &amp; options list:<...
[]
[ { "body": "<p>I could be wrong, but I think you could shorten ALOT of the code as follows:</p>\n\n<pre><code>$(function () {\n $(\".social-option select\").on(\"change\", function(e) {\n $(\".social-option select option:disabled\").prop(\"disabled\", false);\n $(\".social-option select option:s...
{ "AcceptedAnswerId": "13605", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T20:01:45.533", "Id": "13602", "Score": "1", "Tags": [ "javascript", "jquery", "html" ], "Title": "Social network list management" }
13602
<p>Can this be improved?</p> <pre><code>static int find(string term, string text) { int found = -1; int termIndex = 0; for (int textIndex = 0; textIndex &lt; text.Length; textIndex++) { if (term[termIndex] == text[textIndex]) { if (termIndex ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T20:28:21.957", "Id": "22028", "Score": "3", "body": "I don't code in C#, but is there a reason you can't use `text.indexOf(term)`?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T20:32:35.553", "I...
[ { "body": "<p>I also don't code in C#, but if I'm right the following is the same in Java:</p>\n\n<pre><code>public static int find(final String term, final String text) {\n int found = -1;\n int termIndex = 0;\n\n for (int textIndex = 0; textIndex &lt; text.length(); textIndex++) {\n if (term.c...
{ "AcceptedAnswerId": "13633", "CommentCount": "7", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T20:17:41.117", "Id": "13606", "Score": "3", "Tags": [ "c#", "algorithm", "strings" ], "Title": "Algorithm to find substring in a string" }
13606
<p>I'm new to LINQ, but I have some background in T-SQL. I know there are probably 100 different ways to design a T-SQL statement that would run this much more efficiently, but I'm not sure how I would do it in LINQ and I would like to stick with LINQ. </p> <p>This works perfectly well, I just hate the way it looks an...
[]
[ { "body": "<p>As this is EF code, assuming you have all the associations set up correctly, you should be able to write it something like this:</p>\n\n<pre><code>public IEnumerable&lt;Collection&gt; GetCollectionByUid(long uid) {\n var result =\n (from collection in db.UserCollections\n where col...
{ "AcceptedAnswerId": "13612", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T00:29:21.983", "Id": "13611", "Score": "5", "Tags": [ "c#", "linq", "asp.net-mvc-3" ], "Title": "This LINQ Model Query seems extremely inefficient" }
13611
<p>I have written a templated singleton class in C++ but I am afraid that it is not properly destroyed. Can you advise me on that ? </p> <p>my singleton.h</p> <pre><code>#ifndef SINGLETON_H #define SINGLETON_H template &lt;typename T&gt; class Singleton { public: static T&amp; Instance(); protected: virtual...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T13:07:42.703", "Id": "22064", "Score": "0", "body": "Why are you using pointers? Don’t, then the problems go away. But this code has other problems anyway, such as its non-thread-safe initialisation." }, { "ContentLicense": ...
[ { "body": "<p>A classic singleton looks like this (in C++):</p>\n\n<pre><code>class S\n{\n public:\n static S&amp; getInstance()\n {\n static S instance; // Guaranteed to be destroyed.\n // Instantiated on first use.\n return instance;\n...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T06:55:28.490", "Id": "13615", "Score": "3", "Tags": [ "c++", "singleton", "template" ], "Title": "C++ templated singleton class - properly destroyed?" }
13615
<p>I'm new in PHP, MySQL and OOP, so I tried to write a small project to learn things better. The Pponebook should contains contacts which can be edited, deleted, added, sorted and it has pagination, too. Search is also available. This is my first project in PHP and I am using OOP for the first time, so I am sure that ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T08:05:05.597", "Id": "22050", "Score": "0", "body": "personally I don't like having HTML strings inside PHP script, I prefer to separate server by client. So client ajax calls a server php functions which echoes something like json_...
[ { "body": "<p>Don't know if this is just poor question formatting, or your style, but please indent properly, this isn't really good:</p>\n\n<pre><code>class Contact\n{\nprivate $name;\nprivate $phone ;\nprivate $address;\nprivate $notes ;\n}\n</code></pre>\n\n<p>This would be better:</p>\n\n<pre><code>class Co...
{ "AcceptedAnswerId": "13619", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T06:57:51.833", "Id": "13616", "Score": "4", "Tags": [ "php", "beginner", "object-oriented" ], "Title": "Phonebook - a small PHP project" }
13616
<p>I'm hoping that you kind people could cast an eye over my code and let me know what you think... Have I missed something obvious? Are there any possible race conditions? Is there an entirely different and/or better way to do this? Good and bad, everything is appreciated!</p> <p>So, I have to produce and consume lot...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T10:32:58.973", "Id": "22056", "Score": "0", "body": "If you can use .Net 4.5, problems like this can be solved very easily using TPL Dataflow." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-08-22T10:54:08....
[ { "body": "<p>Your code seems fine and thread-safe to me. Few things to think about:</p>\n\n<ol>\n<li>You're using lots of threads that could block in the unlikely case when the consumer is slow. Doing things asynchronously could help you there, but it's most likely not worth it, because it would be quite compl...
{ "AcceptedAnswerId": "13620", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T10:03:08.163", "Id": "13618", "Score": "2", "Tags": [ "c#", "multithreading" ], "Title": "Slow-producer, fast-consumer IEnumerable wrapper" }
13618
<p>I've decided to do this by writing a simple word counter. The app gets all the params and outputs all the unique words, each one with a counter:</p> <p>"Hello world Hello" would return "Hello: 2", "world: 1"</p> <p>(not taking in consideration the actual output structure)</p> <p>This program is the Python equiva...
[]
[ { "body": "<p>I am new to programming so there is chance to be completely wrong, but isn't this line a problem?</p>\n\n<pre><code>if (result-&gt;word == (unsigned char *)word)\n</code></pre>\n\n<p>I think that you should compare strings using strcmp()</p>\n", "comments": [ { "ContentLicense": ...
{ "AcceptedAnswerId": "13623", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T11:06:20.883", "Id": "13621", "Score": "10", "Tags": [ "c", "algorithm", "hash-map", "pointers" ], "Title": "Simple word counter" }
13621
<p>I have my own PHP MVC framework that I'm iteratively developing (i.e. adding a feature when I have the time). I'm trying to keep it to the best practices I can, while still adding the most in terms of functionality.</p> <p>The latest addition I've implemented is lazy loading for my model properties. I've gone, you ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T10:58:48.523", "Id": "22151", "Score": "0", "body": "Your evaluate() method is going to be a nightmare to debug, it's got really high nPath complexity. Also, evaluate() isn't a great method name, as it tells you very little about w...
[ { "body": "<p><code>Lazy::evaluate</code> has a lot of logic in it that may be better implemented using inheritance. There seem to be several possibilities:</p>\n\n<ul>\n<li>Instantiate a class with or without arguments.</li>\n<li>Call a function or static method with or without arguments.</li>\n<li>Call an ins...
{ "AcceptedAnswerId": "13671", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T14:21:06.427", "Id": "13630", "Score": "1", "Tags": [ "php", "object-oriented", "php5", "reflection", "lazy" ], "Title": "Lazy loading with __get" }
13630
<p>The below code is real and in use, but I've modified it to simplify the process/make it easier to explain.</p> <p>The purpose of this code is to combine data from multiple data sources. All sources are .xls files, but the names will vary based on the date of creation, and the formatting can vary based on the user...
[]
[ { "body": "<p>You can replace all of the Getbook nested ifs with the following. Place this first:</p>\n\n<pre><code>Dim i As Long\nFor i = 0 To 6\n If Not Getbook(\"Please select the Book\" &amp; i &amp; \".\", \"Please select a sheet within Book\" &amp; i &amp; \".\", i) Then\n Exit Sub\n End If\n...
{ "AcceptedAnswerId": "13644", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T15:44:50.917", "Id": "13632", "Score": "6", "Tags": [ "vba", "user-interface" ], "Title": "Multiple nested If checks in VBA" }
13632
<p>Help me make it better. Requirement: support arbitrary number of factors, not just 3 &amp; 5. </p> <pre><code>(ns fizzbuzz.core (:use [clojure.contrib.string :only (join)])) (def targets (sorted-map 3 "fizz" 5 "buzz" 7 "baz")) ;; match any applicable factors (defn match [n, factors] (filter #(= 0 (mod n %)) ...
[]
[ { "body": "<p>I tried keeping your approach, although I would've made it an infinite lazy sequence. Yours is probably a better idea, since you still have the infinite sequence (mapping to range as you did) and you can map it to other non-linear sequences too.</p>\n\n<pre><code>(def targets ;; This is more read...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T16:09:02.257", "Id": "13634", "Score": "4", "Tags": [ "clojure", "fizzbuzz" ], "Title": "Higher-order FizzBuzz in Clojure" }
13634
<p>I built my code according to the algorithm provided in <a href="http://www.youtube.com/watch?v=y_G9BkAm6B8" rel="nofollow">this YouTube video</a>. Please review it and help me find any problems. It definitely takes a lot longer than the <code>qsort()</code> function in C++. But the algorithm I use should be just as ...
[]
[ { "body": "<p>The first major problem I see is that you're not considering <code>rightposition</code> when incrementing <code>leftposition</code> and vice versa. This can cause L and R to cross, which will cause additional unnecessary swaps:</p>\n\n<pre><code>pivot value 7\n\n4,7,3,9,6,2,8,1\n L R ...
{ "AcceptedAnswerId": "13646", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T16:11:25.227", "Id": "13635", "Score": "6", "Tags": [ "c++", "sorting", "quick-sort" ], "Title": "My version of C++ quicksort" }
13635
<p>Our company uses an old version of JAXB so it does not allow generics. Other than that, I am using recursive calls because <code>Rows</code> can have subrows and I want to find out if any of the rows for the given column id <code>i</code> has any values. </p> <p>I am interested to know if I got the recursion right....
[]
[ { "body": "<p>This site is more about the readability and structure of code rather than actual correctness. I will comment on that and maybe a more readable program will help you find any potential errors?</p>\n\n<p>I would recommend that you:</p>\n\n<ul>\n<li>Extract complex if statements to their own methods ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T16:21:03.003", "Id": "13636", "Score": "2", "Tags": [ "java", "recursion", "jaxb" ], "Title": "Finding if value exists in any column recursively" }
13636
<p>I am at a loss as to how to simplify the following two functions that <strong>share variables without polluting the global namespace</strong>. (Partial code for a carousel). I would like to streamline it.</p> <p>Note: snapshotCheck(); is called once on window load. snapshotScroll(); is called on click events.</p> ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T16:55:43.950", "Id": "22073", "Score": "0", "body": "This code doesn't look complete enough to review. [Here are some tips you can use to make it better though.](http://codereview.stackexchange.com/questions/11233/optimizing-and-con...
[ { "body": "<p>If those variables are constant (ie, they don't change between invocations of of the functions), you can put the functions and variables into a closure:</p>\n\n<pre><code>(function() {\n //FIRST FUNCTION\n var imageSum = snapshots.total_entries; //Inner Box\n var dl = $j('#snapshots')[0];...
{ "AcceptedAnswerId": "13638", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T06:32:40.973", "Id": "13637", "Score": "2", "Tags": [ "javascript", "jquery" ], "Title": "Shorten JavaScript Code due to duplicate variables without polluting global namespace" }
13637
<p>I'm VERY new to PHP and have begun writing a basic login for a website that uses data from a Microsoft SQL server to display information on the web. Below are 3 snippets of code (two functions from the same file and one controller file that calls them.)</p> <h1>Connect to MSSQL to validate user (from phplib)</h1> ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-11-17T05:39:20.487", "Id": "29848", "Score": "0", "body": "Minor formatting issue -- hit enter after the line \"This is the function that get called from the main login screen.\"" } ]
[ { "body": "<p>First off, welcome to Code Review. Answers here may be a while in coming. Usually I'm better about getting to these questions but I've been extremely busy the last week and so missed this. Hopefully you're still watching this.</p>\n\n<p>Learning MySQL is a great way to get comfortable with the ide...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T16:47:50.653", "Id": "13639", "Score": "3", "Tags": [ "php", "object-oriented", "security", "sql-server" ], "Title": "PHP Login/User Creation Validation Function" }
13639
<p>My project has a central concept of a <code>Callback&lt;T&gt;</code> which is defined very simply:</p> <pre><code>public interface Callback&lt;T&gt; { void call(T item) throws Exception; } </code></pre> <p>This is used to enforce correct resource management (e.g. database connections, HTTP sessions) while stil...
[]
[ { "body": "<p>The code looks fine. Here are some small notes and questions which you may find useful.</p>\n\n<ol>\n<li><p>The code seems as a custom implementation of actor-based concurrency. It has some implementations (Akka is, for example) which you should check if you haven't seen them already. (In Venkat S...
{ "AcceptedAnswerId": "13889", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T17:24:06.880", "Id": "13642", "Score": "5", "Tags": [ "java", "multithreading", "callback" ], "Title": "\"Piping\" from a callback to an Iterator" }
13642
<p>I promise that I've done my reading on this topic. I've seen many suggestions and critiques, but I haven't seen the argument below critiqued. I'm not trying to beat a dead horse, but I don't think anyone's offered this one up yet:</p> <p><code>x ||= y</code><br> is functionally equivalent to<br> <code>x = y unles...
[]
[ { "body": "<p>I think it really just comes down to opinion.</p>\n\n<p>I think using <code>||=</code> is better in this case, it's easier to glance at the code and see what it's intent is. When using the inline <code>if</code> or <code>unless</code>, I have to scan the whole line to know what is going on.</p>\n\...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T17:26:43.617", "Id": "13643", "Score": "4", "Tags": [ "ruby" ], "Title": "Another ||= question" }
13643
<p>I have a class library in which I'm using generics as below. I'm not sure if it's an improper use or not. So aside from the fact that it works and everything "depends", id like some specific critique on how this usage might fall apart. In particular In wondering about the shadowing of non generic properties with gen...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T08:07:21.903", "Id": "22079", "Score": "1", "body": "As you say, it \"depends\" - in this case, it depends on the purpose of these types. Why do you need to have both generic and non-generic `IPickOrder` and `PickOrder`? Perhaps try...
[ { "body": "<p>I feel you on the \"My reasons are more due to preference than need.\" comment but the inheritance from PickOrder and <code>public new ERPListBase&lt;TPickOrderLine&gt; Lines { get; protected set; }</code> will confuse somebody best case and really mess things up worst case. While it may still gi...
{ "AcceptedAnswerId": "24355", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T08:02:03.157", "Id": "13645", "Score": "2", "Tags": [ "c#", ".net", "generics" ], "Title": "Generics: Is this improper use?" }
13645
<p>I'm trying to create a doubly linked list using the null object design pattern. I've implemented four classes: a <code>node</code> abstract class, <code>nullnode</code> and <code>datanode</code> classes for the null node object and the <code>linkedlist</code> class, for the linked list implementation. I'm not sure i...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-14T07:22:20.057", "Id": "22101", "Score": "1", "body": "I'm sorry, but you don't appear to actually have working code here. That is a prerequisite for asking for a code review." } ]
[ { "body": "<p>The question's classes are <code>node</code>, <code>NullNode</code>, <code>dataNode</code>, and <code>linkedlist</code>. Notice that the naming scheme appears not to be case-aware. It is best to fix this. Let's use camel case and capitalize the first letter. So we'll use <code>Node</code>, <code>N...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-13T23:00:56.787", "Id": "13655", "Score": "0", "Tags": [ "c++", "design-patterns", "linked-list", "null" ], "Title": "Null object design pattern in a linked list" }
13655
<p>This code (<a href="http://jsbin.com/isexez/3/edit" rel="nofollow">http://jsbin.com/isexez/5/edit</a>) functions as expected: (1) it displays the page selected; and (2) it highlights the number of the selected page.</p> <p>I would appreciate help in improving it. </p> <p>I am in the process of writing an ebook (<...
[]
[ { "body": "<p>Here are some ideas:</p>\n\n<ul>\n<li>Use either tab or, preferably, 4-spaces for indention consistently. Right now the indention is all screwy on JSBin.</li>\n<li>Put <em>all</em> your variable declarations at the top, even if you don't define them yet. This'll prevent any confusion from <a href=...
{ "AcceptedAnswerId": "13687", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-14T12:57:59.157", "Id": "13659", "Score": "0", "Tags": [ "javascript", "jquery" ], "Title": "Improve this javascript code: It displays hidden text and highlights the selected page num...
13659
<p>I have just implemented a quick test of the visitor design pattern in C++ and have a few questions regarding the code.</p> <h2>main.cpp</h2> <pre><code>#include &lt;iostream&gt; #include "Base.h" #include "Derived.h" #include "Visitor.h" int main() { Base base; std::cout &lt;&lt; "hello\n"; Base * de...
[]
[ { "body": "<p>Your implementation looks mostly good, however I'm not sure if I'd recommend passing your parameters by value. It may be what you're looking for, but generally I'd consider passing by reference or const-reference - it avoids the need for one or more copies, and means you shouldn't get any object ...
{ "AcceptedAnswerId": "13665", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2012-07-14T13:10:01.453", "Id": "13660", "Score": "13", "Tags": [ "c++", "visitor-pattern" ], "Title": "Visitor pattern in C++" }
13660
<p>I have written a class which I will use as a base class, allowing other classes to extend this class.</p> <p>How can I improve this? Am I breaking any conventions or styling?</p> <pre><code>import requests import feedparser from BeautifulSoup import BeautifulSoup class BaseCrawler(object): ''' Base Class will...
[]
[ { "body": "<p>I'm not sure what you're intending to do with this class so I can only offer some general tips.</p>\n\n<ol>\n<li><p>Make private variables private:</p>\n\n<pre><code>def __init__(self, url):\n self._url = url\n</code></pre></li>\n<li><p>Use properties instead of <code>get_</code> methods. For e...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-14T16:22:03.267", "Id": "13664", "Score": "2", "Tags": [ "python" ], "Title": "Base class for feed-parsing" }
13664
<p>When reigstering a user I request two reads from the database to see if there is a username and email and then I write if the checks pass.. Can anyone tell me if this code will block other users?</p> <p>I am using node with express.js and mongojs.</p> <p>I know I am saving passwords in plaintext.. This will be cha...
[]
[ { "body": "<p>The answer is NO.</p>\n\n<p>The reason is that the calls to db are asynchronous, that's why you pass a function object as a callback.</p>\n", "comments": [], "meta_data": { "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-14T22:46:46.240", ...
{ "AcceptedAnswerId": "13672", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-14T22:21:55.823", "Id": "13667", "Score": "1", "Tags": [ "node.js" ], "Title": "Will this code block in node.js" }
13667
<p>My code listens for a number of events, and calls the Google Analytics event tracking function when they fire.</p> <p>Each event uses a similar pattern. Can I achieve the same functionality without repeating myself?</p> <pre><code>/*jslint debug:true, browser:true, devel:true nomen:true */ /*global _gaq:true, jque...
[]
[ { "body": "<p>Id suggest something like:</p>\n\n<pre><code>$('body').on('click.alert.data-api', '[data-dismiss=\"alert\"]', function () {\n trackEvent('Alerts', $(this).next().text());\n});\n</code></pre>\n\n<p>instead of the whole <code>alert</code> code, and similar things for the other items.</p>\n", "c...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-15T07:05:57.023", "Id": "13675", "Score": "0", "Tags": [ "javascript", "jquery" ], "Title": "Stop repeating myself: Similar pattern used on multiple event handlers" }
13675
<p>I'm playing around with JMock and trying to understand whether I understand the idea correctly.</p> <p>There's an interface <code>Printer</code> aimed to print integers somewhere. There's an interface <code>Calculator</code> aimed to perform math. There's a class <code>CalculatingMachine</code> aimed to connect <co...
[]
[ { "body": "<p>This is technically correct code, whether it's right depends... </p>\n\n<p>This might be the first test for an object that will become more complicated. It's reasonable to start small and work your way up. </p>\n\n<p>If the Calculator is a self-contained implementation that doesn't pull in other d...
{ "AcceptedAnswerId": "13680", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-15T07:52:46.230", "Id": "13676", "Score": "2", "Tags": [ "java", "unit-testing", "junit" ], "Title": "Tesing a simple calculator class with JUnit/JMock" }
13676
<p>This is a solver for Sudoku using backtracking. How can I make it more optimized and clean?</p> <pre><code>#include &lt;stdio.h&gt; int isAvailable(int sudoku[][9], int row, int col, int num) { int i, j; for(i=0; i&lt;9; ++i) if( (sudoku[row][i] == num) || ( sudoku[i][col] == num ) )//checking in...
[]
[ { "body": "<p>Very nice:</p>\n\n<p>Few minor changes I would make.</p>\n\n<p>In <code>isAvailable()</code> I would check row/col/box all at the same time.</p>\n\n<pre><code>int isAvailable(int sudoku[][9], int row, int col, int num)\n{\n //checking in the grid\n int rowStart = (row/3) * 3;\n int colSta...
{ "AcceptedAnswerId": "13688", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-15T08:57:12.143", "Id": "13677", "Score": "10", "Tags": [ "optimization", "c", "sudoku", "backtracking" ], "Title": "Solving Sudoku using backtracking" }
13677
<p>I want to validate a list of objects for example strings. and if one of the objects fails to pass the condition return false as validation result . this is the code I use :</p> <pre><code> public static bool AreValid(string[] strs) { foreach (string str in strs) { if (str != condi...
[]
[ { "body": "<p>Yes, <code>return</code> immediately* returns from the method, no matter where in the method you are. You don't need the <code>break</code>.</p>\n\n<p>But there is even easier way to write this code, using the LINQ method <a href=\"http://msdn.microsoft.com/en-us/library/bb548541.aspx\"><code>All(...
{ "AcceptedAnswerId": "13681", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-15T10:19:41.260", "Id": "13679", "Score": "2", "Tags": [ "c#", "asp.net" ], "Title": "Validating that all strings in an array match a condition" }
13679
<p>I have a simple script that will take a list of hosts and ping each host (there's about 200) a single time before moving on. This is not the most effecient method I am sure, as it is very linear. And it takes a few minutes to complete. I would ideally like to run this script every minute (so each IP address is check...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-15T11:41:53.960", "Id": "22127", "Score": "0", "body": "I think it may be the way I'm reading a file." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-15T13:14:11.567", "Id": "22131", "Score": "0", ...
[ { "body": "<p>Why not using threads ? You could run your pings simultaneously. </p>\n\n<p>This works quite well :</p>\n\n<pre><code>import sys\nimport os\nimport platform\nimport subprocess\nimport threading\n\nplat = platform.system()\nscriptDir = sys.path[0]\nhosts = os.path.join(scriptDir, 'hosts.txt')\nhost...
{ "AcceptedAnswerId": "13691", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-15T11:41:14.833", "Id": "13683", "Score": "6", "Tags": [ "python", "performance", "networking", "status-monitoring" ], "Title": "Pinging a list of hosts" }
13683
<p>Any suggestions/improvements for the following custom thread-pool code?</p> <pre><code>import threading from Queue import Queue class Worker(threading.Thread): def __init__(self, function, in_queue, out_queue): self.function = function self.in_queue, self.out_queue = in_queue, out_queue ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-12-07T21:03:07.577", "Id": "221086", "Score": "0", "body": "I recommend looking into the `multiprocessing.pool.ThreadPool` object, also explained [here](http://stackoverflow.com/questions/3033952/python-thread-pool-similar-to-the-multipro...
[ { "body": "<ol>\n<li><p>The function <a href=\"https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor.map\" rel=\"nofollow\"><code>concurrent.futures.ThreadPoolExecutor.map</code></a> is built into Python 3 and does almost the same thing as the code in the post. If you're still us...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-15T18:56:53.000", "Id": "13690", "Score": "2", "Tags": [ "python", "multithreading" ], "Title": "Custom thread-pooling" }
13690
<p>When I read some code,I think the usage of Event is not necessary,is it right?</p> <pre><code># start server while True: # accept a request here queue.put(info) event.set() # notify all the threads? # pass queue and event here to a Thread constructor </code></pre> <p>other place there are more than...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T01:49:19.680", "Id": "22198", "Score": "0", "body": "In the small snippets of code that you posted, it does indeed seem that `event` is unnecessary. Furthermore, it seems as if event is global, which is probably not a good idea eith...
[ { "body": "<p>As long as <code>queue</code> is actually <code>Queue.Queue</code> (or another collection with its own blocking mechanic), the event object is not required in the code you posted. <del>I'd even say that it's used incorrectly. There is a racing condition when the server calls <code>event.set()</cod...
{ "AcceptedAnswerId": "13741", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T03:42:09.247", "Id": "13693", "Score": "3", "Tags": [ "python", "multithreading" ], "Title": "Is Event.wait necessary here?" }
13693
<p>I am new to Groovy and I am having a little problem with constructors of subclasses. Basically, I have a base abstract class like</p> <pre><code>class BaseClass { def BaseClass(Map options) { // Does something with options, // mainly initialization. } // More methods } </code></pre> <p>and a bunch of...
[]
[ { "body": "<p><code>@InheritConstructors</code> is probably what you are looking for:</p>\n\n<pre><code>@InheritConstructors\nclass AnotherClass extends BaseClass {}\n</code></pre>\n\n<p>will create the constructors corresponding to the superclass constructors for you.</p>\n", "comments": [ { ...
{ "AcceptedAnswerId": "13697", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T07:28:32.593", "Id": "13696", "Score": "12", "Tags": [ "constructor", "groovy" ], "Title": "Constructors and inheritance in Groovy" }
13696
<p>I am writing code for a very basic jQuery slider with the following features:</p> <ol> <li>Slide the content left or right on click of next/previous links till there is no more content on the clicked side.</li> <li>If any content is added dynamically, the entire content should slide.</li> </ol> <p>While there are ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T09:50:26.860", "Id": "22146", "Score": "1", "body": "On code review one is supposed to include at least part of one's code in the question." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T10:05:07.970...
[ { "body": "<p><a href=\"http://jsfiddle.net/RY3TH/3/\" rel=\"nofollow\">JsFiddle</a></p>\n\n<p>Not writing this as a plugin here are some suggestions:</p>\n\n<ol>\n<li>instead of <code>removeClass('a').addClass('b')</code> use <code>toggleClass('a b')</code></li>\n<li>instead of searching the entire DOM for <co...
{ "AcceptedAnswerId": "13713", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T08:46:17.257", "Id": "13698", "Score": "1", "Tags": [ "javascript", "jquery" ], "Title": "Basic jQuery slider" }
13698
<p>I have written a JS library (think, jQuery, but with much much less features, and targeted for newer browsers on mobile). This library provides an extension mechanism. One of the ways the extension can be defined is:</p> <pre><code>$.extension("extname", function(options) { this.forEach(function(elem) { ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-08-15T16:14:20.077", "Id": "23891", "Score": "0", "body": "You say you want to do away with chaining, but your example, `acc.collapse(0).expand(1);` uses chaining. Also, you may want to read this part of Addy Osmani's book about JavaScrip...
[ { "body": "<p>Are you aware that <a href=\"http://wiki.jqueryui.com/w/page/12138135/Widget-factory\" rel=\"nofollow\">you can use JQueryUI widgets like this</a>:</p>\n\n<pre><code>var acc = $('#acc').accordion(options).data('accordion');\nacc.collapse(0);\nacc.expand(1);\nacc.getExpanded(); // etc.\n</code></pr...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T09:03:02.307", "Id": "13699", "Score": "2", "Tags": [ "javascript", "library", "plugin" ], "Title": "Library providing an extension mechanism" }
13699
A plug-in (or plugin) is a set of software components that adds specific abilities to a larger software application. If supported, plug-ins enable customizing the functionality of an application.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T09:47:50.717", "Id": "13702", "Score": "0", "Tags": null, "Title": null }
13702
<p>This is sort of a follow up question on <a href="https://stackoverflow.com/questions/754661/httpruntime-cache-best-practices/11431198">https://stackoverflow.com/questions/754661/httpruntime-cache-best-practices/11431198</a> where a reply from frankadelic contains this quote and code sample from <a href="http://msdn....
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T12:23:46.130", "Id": "22157", "Score": "0", "body": "Did you mean to write `_cachedResults` instead of `_cachedResults`? And what is the type of the object, `List<object>` or `PageDataCollection`?" } ]
[ { "body": "<p>First, I think your code doesn't make much sense. The only reason why <code>Cache</code> can be useful is if you want the cached data to expire after some time or if the memory is low. But you're preventing the memory to be freed by using the field <code>_cachedResults</code>, which will hold the ...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T11:38:52.117", "Id": "13704", "Score": "4", "Tags": [ "c#", "asp.net", "cache" ], "Title": "How to correctly use lock when adding/renewing cached data in asp.net cache?" }
13704
<p>We have an in-house time-tracking application at the office.</p> <p>We, the employees, can view an overview of our hours on a web page. This web page renders a table, with worked hours per day in table cells, which is styled as a monthly calendar. I wrote a small script which I can copy-paste in my console to get a...
[]
[ { "body": "<p>Well, you only need to pass parameters to <code>each</code> if you need the index.</p>\n\n<pre><code>$.each(elementsToParse, function() {\n var text = $(this).text();\n</code></pre>\n\n<p>Also, a more elegant way than <code>substr</code> is just using <code>split</code>. You can <code>trim</cod...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T12:32:55.243", "Id": "13705", "Score": "3", "Tags": [ "javascript", "jquery", "portability" ], "Title": "Optimizing a JavaScript snippet for portability and readability" }
13705
<p>I am filtering a List (childList) based on the contents of another List (parentList).</p> <p>The parentList can contain 0-n entities where items of the childList are referenced by an ID (btw. ID is in this case a string, you could also call it "Name" or whatever you like). I want to filter the childList in a way th...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T13:50:47.673", "Id": "22163", "Score": "0", "body": "Can't you change the entities so that they don't use IDs, but direct references?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T14:02:53.303", ...
[ { "body": "<p>First red flag; you're using <code>Count(predicate) &gt; 0</code>. The Count() overload that takes a predicate must iterate over all elements of the parent enumerable to determine the correct count, and you're telling it to do so for each element of the child list. You simply want to know if at le...
{ "AcceptedAnswerId": "13721", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T12:44:34.087", "Id": "13708", "Score": "1", "Tags": [ "c#", "performance" ], "Title": "Performance Optimization of n:1-mapping" }
13708
<p>The following is a symmetric encryption/decryption routine using AES in GCM mode. This code operates in the application layer, and is meant to receive user specific and confidential information and encrypt it, after which it is stored in a separate database server. It also is called upon to decrypt encrypted informa...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T16:29:49.587", "Id": "22172", "Score": "4", "body": "There are specific style guides that Microsoft publishes regarding [C# documentation comments](http://msdn.microsoft.com/en-us/library/b2s063f7%28VS.80%29.aspx) and [capitalizatio...
[ { "body": "<ol>\n<li>C# uses PascalCase naming convention for method names.</li>\n<li><p>It is accepted practice to reduce indent with multiple <code>using</code> blocks like this (in cases where no additional statements have to be executed in the outer using block):</p>\n\n<pre><code>using (MemoryStream ms = n...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T14:31:31.257", "Id": "13714", "Score": "5", "Tags": [ "c#", "security", "aes" ], "Title": "Symmetric encryption/decryption routine using AES" }
13714
<p>I have this function which returns the time that a Tweet was created based on the <code>created_at</code> value that comes when a timeline is pulled. I also check whether or not the tweet was created more than 2 hours ago, and if it was, have an action execute. I was wondering, is there a way that this code could be...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T13:38:36.967", "Id": "22255", "Score": "0", "body": "`$.browser` is deprecated - is there someway to do that with bug-detection?" } ]
[ { "body": "<p>This doesn't really shorten it, but I think it reads better if you get rid of the diff variable and instead calculate the diff in terms of seconds, minutes, hours and days:</p>\n\n<pre><code>function timeAgo(dateString) {\n var rightNow = new Date(), then = new Date(dateString), seconds, minute...
{ "AcceptedAnswerId": "13729", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T15:08:16.960", "Id": "13717", "Score": "2", "Tags": [ "javascript", "jquery" ], "Title": "Shorten Time Return Function" }
13717
<p>I have created a class intended to average the previous few data points submitted. It is able to change in size and has a feature to bypass the average without affecting the data contained therein. Are there any improvements I could make, or any exceptions thrown in certain situations that I haven't thought of?</p> ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T18:56:33.373", "Id": "22179", "Score": "0", "body": "Are you aware of java.util.ArrayList, or are you required to use an array?" } ]
[ { "body": "<ol>\n<li><p>On <code>new RollingAverage(-1)</code> it throws a <code>NegativeArraySizeException</code>. An <code>IllegalArgumentException</code> with a proper message would be better here since clients should not know that you are using arrays in the implementation.</p></li>\n<li><p>On <code>new Rol...
{ "AcceptedAnswerId": "13728", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T17:47:57.177", "Id": "13719", "Score": "3", "Tags": [ "java" ], "Title": "Rolling Average improvements" }
13719
<p>I have 3 car rental agencies. Each agency requires the data in XML, but in a different format, for example:</p> <p>Agency 1</p> <pre><code>&lt;Rental&gt; &lt;Customer&gt; &lt;FirstName&gt;test&lt;/FirstName&gt; &lt;LastName&gt;test&lt;/LastName&gt; &lt;/Customer&gt; &lt;Pickup date="07/20/2012"/&gt; &lt;Dropoff d...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T21:02:34.560", "Id": "22222", "Score": "0", "body": "There's a date/time type in XML, which should at least help _some_ with stuff in respect to that datatype. I wouldn't be surprised if there's a money-related one too." } ]
[ { "body": "<p>Assuming all three companies require the same information, create a base class \"CarRentalInformation.\" This information will store/transmit all pertinent information.</p>\n\n<p>Create serializer/deserializer classes for all types of can rentals you need. <a href=\"http://www.oodesign.com/facto...
{ "AcceptedAnswerId": "13730", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T19:49:24.430", "Id": "13726", "Score": "3", "Tags": [ "c#", "design-patterns", "object-oriented" ], "Title": "How can I use object oriented principles in the following scenario...
13726
<p>I've been doing some parsing with regular expression named capture groups and decided it might make sense to write an extension to handle this. </p> <p>The code below will create an instance of a specified type and attempt to match the property names to the capture group names and then set the values. It also att...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T15:21:41.813", "Id": "22209", "Score": "0", "body": "Overloads that just take the match pattern and instantiate their own Regex (or just use the static methods) might be called for. The code also requires using only mutable properti...
[ { "body": "<p>If you are doing reflection magics the caller of your method may be as well. If that person already has a <code>Type</code> it can be a bit of a pain in the butt to call your generic method. Since you are already working against a <code>Type</code> offering an overload for it should not be too muc...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T21:28:37.387", "Id": "13731", "Score": "3", "Tags": [ "c#", "regex" ], "Title": "Extension Method for Creating Types from Regular Expression Match Groups" }
13731
<p>I currently have the following jQuery code, which does work, but I know there is a better way of doing it without having to repeat myself so much:</p> <pre><code>&lt;script&gt; $(document).ready(function() { $('.container').hide(); $('#btn-post').click(function() { $('.container').hide(); })...
[]
[ { "body": "<p>Try this:</p>\n<h2><em><a href=\"http://jsbin.com/iniqaj/edit#javascript,html,live\" rel=\"nofollow noreferrer\">jsBin demo</a></em></h2>\n<pre><code>$('.container').hide();\n\n$('.btn').click(function() {\n \n $('.container').hide();\n $('#'+this.id.split('-')[1]+'_container').show();\n\n});\n...
{ "AcceptedAnswerId": "13736", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-16T21:40:07.007", "Id": "13733", "Score": "7", "Tags": [ "javascript", "jquery" ], "Title": "More efficient way of doing this hide()/show() jQuery" }
13733
<p>This is the dashboard controller code in PHP Symfony 2. It collects some aggregate data and points for charts, but i don't like it very much. Do you think that <em>this code belongs to what a controller should do in a MVC patter</em>? How can i refactor it?</p> <pre><code>public function dashboardAction() { $ba...
[]
[ { "body": "<p>Without knowing anything about sympony's details:</p>\n\n<ul>\n<li>I'd refactor most of the code into your view. I prefer to pass the required objects to the view and let the view pull the information it needs from the object(s) </li>\n<li>Rename the variable <code>bag</code> </li>\n<li>Move the s...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T09:27:28.113", "Id": "13742", "Score": "4", "Tags": [ "php", "mvc", "php5", "controller" ], "Title": "PHP MVC controller code needs diet?" }
13742
<p><img src="https://i.stack.imgur.com/0xufA.png" alt="Google Logotype"></p> <h1>About</h1> <p><strong>Google, the search engine</strong><br> Google is the world's foremost search engine and most visited domain that crawls the web and provides users with a list of links relevant to their search.</p> <p><strong>Googl...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T12:00:00.450", "Id": "13744", "Score": "0", "Tags": null, "Title": null }
13744
Google offers a variety of APIs, mostly web APIs for web developers. The APIs are based on popular Google consumer products, including Google Maps, Google Earth, AdSense, Adwords, Google Apps and YouTube.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T12:00:00.450", "Id": "13745", "Score": "0", "Tags": null, "Title": null }
13745
<p>Here is an ant script for generating TeX code and documentation for one LaTeX class and one LaTeX package. It is my first larger ant script: I welcome suggestions for improvements.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;project name="customer TeX code" default="main"&gt; &lt...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T19:11:32.123", "Id": "22329", "Score": "0", "body": "Can’t comment specifically on the ant file but it seems like a lot of effort. Are you aware of the existence of `latexmk` which ships with all modern TeX distributions and which i...
[ { "body": "<p>The <code>bar</code> and <code>foo</code> targets (as well as the conditions on <code>foo.uptodate</code> and <code>bar.uptodate</code>) seems really similar to each other. I'd try to remove this duplication with a <a href=\"http://ant.apache.org/manual/Tasks/presetdef.html\" rel=\"nofollow norefe...
{ "AcceptedAnswerId": "13758", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T14:27:22.410", "Id": "13749", "Score": "2", "Tags": [ "java", "tex", "ant" ], "Title": "ant file for TeX compilation" }
13749
<p>I am primarily a java programmer and for the first time working in C++.</p> <p>I have implemented a Factory design pattern in C++.</p> <pre><code> class TaskFactory { public: typedef Task* (*create_callback)(map&lt;string, string&gt; vMap); static void register_task(const string&amp; ty...
[]
[ { "body": "<p>Few small problems with the factory.</p>\n\n<h3>You are using a pointer to a method.</h3>\n\n<pre><code> typedef Task* (*create_callback)(map&lt;string, string&gt; vMap); \n</code></pre>\n\n<p>As the way of creating your object. This is very C like. It also introduces the possibilities of p...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T16:23:52.987", "Id": "13751", "Score": "8", "Tags": [ "c++", "design-patterns" ], "Title": "Correct implementation of Factory pattern in C++" }
13751
<p>I tried to solve a programming contest <em><a href="https://hallg.inf.unideb.hu/progcont/exercises.html?locale=en&amp;pid=1631">problem</a></em> in Scala, but I have a feeling, that it could be done in a more functional way. I compared it with the solution written in imperative style and it is not shorter or less co...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T15:37:26.793", "Id": "22217", "Score": "1", "body": "In Scala, pattern matching is eager so the first pattern that is matched wins. It is generally a good practice to order pattern matches from most specific to least specific. Your ...
[ { "body": "<p>A good way to think about this problem is to list the different cases when a customer is encountered in the list:</p>\n\n<ol>\n<li>The person arrives and there is a bed available => the person gets a tan and the number of available bed decreases by one </li>\n<li>The person arrives and there is no...
{ "AcceptedAnswerId": "13760", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T15:19:48.610", "Id": "13759", "Score": "5", "Tags": [ "scala", "functional-programming" ], "Title": "Change code to use functional style" }
13759
<p>The stored procedures must return their first resultset in the form:</p> <pre><code>( [index] int, [id] varchar(50) ) </code></pre> <p>where </p> <ul> <li><code>[index]</code> is 0,1,2,3,... and </li> <li><code>[id]</code> is the name of the struct. </li> </ul> <p>As long as the first resultset returns ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T16:27:38.907", "Id": "22323", "Score": "0", "body": "I'm not really sure what the code is trying to do, or what you are asking. That's probably not your fault, my brain hurts so its being rather dense. Anyways, here are some suggest...
[ { "body": "<p>In the way you formed your post it looks like you were asking for a better way to do what you are already doing, which it still apears that you are. That's fine, I just had no idea what you wanted from this code. I had to walk myself through your code step by step, so some of this is just going to...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T18:36:22.110", "Id": "13761", "Score": "2", "Tags": [ "php", "sql-server" ], "Title": "Generic PHP function for making a struct out of multiple resultsets from a stored procedure call...
13761
Apache Ant (formerly Jakarta Ant) is a declarative, XML-based build tool for Java projects. It provides a rich set of standard tasks for performing most common build operations, such as compilation with javac, building archives and running tests. Ant's functionality can be extended through custom tasks and macros.
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T19:20:41.013", "Id": "13764", "Score": "0", "Tags": null, "Title": null }
13764
<p>Since I have little to no knowledge about native languages, I tried once more to write a simple application in C++, this time with a <a href="http://en.wikipedia.org/wiki/Brainfuck" rel="nofollow">Brainfuck</a> parser.</p> <p>It works, kind of, verified with the <a href="http://esolangs.org/wiki/brainfuck" rel="nof...
[]
[ { "body": "<p>You don't need to read the whole program into memory.</p>\n\n<p>You use a stream to represent the program.<br>\nReading a character automatically moves you to the next location. If you need additional control of the stream you can use seekg() to move around the stream a bit more.</p>\n\n<p>Rather ...
{ "AcceptedAnswerId": "13768", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-17T21:56:08.173", "Id": "13767", "Score": "4", "Tags": [ "c++", "parsing", "brainfuck" ], "Title": "Brainfuck parser" }
13767
<p>I have the following class:</p> <pre><code>Class Core { public $security; public $db; public $extra; public function __construct() { spl_autoload_register(array($this, 'loader')); } public function loader($name) { include $name.'.php'; } public function __get($key) { return $this-&gt;extra[$key]; } ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T06:05:23.313", "Id": "22228", "Score": "0", "body": "I think you're just looking for auto loading? http://www.php.net/manual/en/language.oop5.autoload.php" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-...
[ { "body": "<p>There's a lot of design oddities in this, and I don't quite see the value of it. The brevity it allows now will undoubtedly cause issues once you use this in a complex application.</p>\n\n<p>Why is:</p>\n\n<pre><code>$core = new Core();\n$core-&gt;init('User, Control');\n\n$core-&gt;Control-&gt;t...
{ "AcceptedAnswerId": "13817", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T05:35:41.683", "Id": "13771", "Score": "1", "Tags": [ "php" ], "Title": "Dynamically instantiating classes" }
13771
<p>I'm working on a module that downloads a file saves it then validates if the file contents are valid.</p> <p>For simplicity lets assume that the file consists of 3 segments: Header, Body &amp; Footer.</p> <p>Now here is the design I thought of:</p> <pre><code>class File{ private $header; private $body; ...
[]
[ { "body": "<p>Right off the bat, I'd consider getting the file reading for header, body, and footer out of your constructor. Not only are these potentially time-consuming operations, they're also quite likely to fail if you've got a mal-formed file. You'll want to think about whether you'd consider that a \"v...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-12T19:54:02.637", "Id": "13776", "Score": "5", "Tags": [ "php", "object-oriented", "php5", "validation" ], "Title": "Is this a good object oriented design for a file validator?" ...
13776
<p>I need to do pending methods invocation in Java (Android) in my game project. A method represents actions in a scene.</p> <p>Maybe you're familiar with <code>Context.startActivity</code> in Android, which is not suddenly starting the activity, but statements below it is still executed before starting the requested ...
[]
[ { "body": "<p>Your first example (switch-case) is so poorly thought of in the Object Oriented community that there is a refactoring designed specifically to replace it with your third implementation: <a href=\"http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism\" rel=\"nofollow\">Replace C...
{ "AcceptedAnswerId": "13786", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T09:43:06.663", "Id": "13780", "Score": "3", "Tags": [ "java", "android" ], "Title": "Pending method invocation for a game" }
13780
<p>Sometimes there is need to change an integer to text. I often use the following way:</p> <pre><code>"" + myNumber </code></pre> <p>But there is alternative way:</p> <pre><code>Integer.toString(myNumber) </code></pre> <p>Which one is better (performance, readability, safety)? Or are those equal?</p>
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T17:11:41.570", "Id": "22271", "Score": "4", "body": "A very detailed answer to a very similar question on SO: http://stackoverflow.com/a/4105406/843804" } ]
[ { "body": "<p>Integer.toString(myNumber) is the safer way because it throws a malformed exception.</p>\n\n<p>Do not worry about performance at this level. There is an expression: <a href=\"http://c2.com/cgi/wiki?PrematureOptimization\" rel=\"nofollow\">Premature Optimization</a>.</p>\n\n<p><strong>EDIT after co...
{ "AcceptedAnswerId": "13818", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T09:45:10.033", "Id": "13781", "Score": "8", "Tags": [ "java" ], "Title": "Which way is better for converting number to string?" }
13781
<p>I'm trying to merge two nodes. Basically, the idea is to take all children in left and new ones in right. Is there any way to get rid of <code>toAdd</code> variable and do it in a clean way?</p> <p>I don't want to convert any <code>IEnumerable&lt;T&gt;</code> to <code>List</code> or <code>Array</code> in this merge...
[]
[ { "body": "<p>Little cleaner:</p>\n\n<pre><code>// Common Keys between left and right\nvar result = lChildren.Where(s =&gt; rChildren.Select(p =&gt; getKey(p)).Contains(getKey(s))).ToList();\n\n// new keys added to right\nresult.AddRange(rChildren.Where(s =&gt; lChildren.Select(p =&gt; getKey(p)).Contains(getKe...
{ "AcceptedAnswerId": "13796", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T10:48:02.087", "Id": "13783", "Score": "4", "Tags": [ "c#", ".net", "linq" ], "Title": "Joining two IEnumerable<T>" }
13783
<p>I have two different data inputs for the same value, I want to use the non empty one if one of them is, to return the empty string if both are empty, and to flag an error if both are not empty but differ and return one of them.</p> <p>Empty for my criteria matches the meaning of <code>string.IsNullOrEmpty()</code>....
[]
[ { "body": "<p>You have four cases and each of them behaves differently, so you actually need to have four different branches. But you can simplify your code by extracting the checks into variables and using nested <code>if</code>s:</p>\n\n<pre><code>public string CallKey\n{\n get\n {\n bool callKey...
{ "AcceptedAnswerId": "13792", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T14:44:06.237", "Id": "13789", "Score": "2", "Tags": [ "c#" ], "Title": "Simplify value selection" }
13789
<p>I'm brand new to both Ruby and Rails, and while all the following works, it seems a bit messy. </p> <p>This is on a classified model to generate WHERE/AND WHERE clauses based on whether or not the user supplies a value through a dropdown. I'm not sure if there's a more Active Recordy way of doing this:</p> <pre><c...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-08-07T21:54:26.317", "Id": "23366", "Score": "0", "body": "I think you'd better split your question into several" } ]
[ { "body": "<p>Maybe you can convert this:</p>\n\n<pre><code>scope :filter_active_cars, lambda { |options| \n filter = {}\n filter[:cars] = {:year =&gt; options[:year]} unless options[:year].empty?\n filter[:makes] = {:id =&gt; options[:make]} unless options[:make].empty?\n filter[:models] = {:id =&gt; options[:...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T14:52:29.100", "Id": "13790", "Score": "3", "Tags": [ "ruby", "ruby-on-rails" ], "Title": "Ruby Rails - Snippets from a project that don't seem so eloquent" }
13790
<p>This is just playing around and practicing javascript. I am learning JavaScript from Codecademy and I practice coding everyday so I can learn much as possible. I have a lot of <code>if</code> statements, prompt boxes, some alert boxes. I just got finished learning about functions and returns. I just don't know how t...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T22:40:17.010", "Id": "22289", "Score": "3", "body": "Any learning resource that teaches you to use document.write should be shunned and avoided." }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T22:30:0...
[ { "body": "<p>Take a look at this - I modified and left a couple of comments. You're on the right path :) </p>\n\n<pre><code>function stristr (haystack, needle) {\n var pos = 0\n haystack += ''\n\n pos = haystack.toLowerCase().indexOf((needle + '').toLowerCase())\n if (pos &gt;= 0) return haystack.s...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T15:00:38.680", "Id": "13791", "Score": "3", "Tags": [ "javascript", "beginner" ], "Title": "Personal questionnaire using JavaScript prompts" }
13791
<p>Given the following HTML form (fragment):</p> <pre><code>&lt;fieldset id="timesheet-rows"&gt; &lt;legend&gt;Add Entries&lt;/legend&gt; &lt;div id="timesheetrow-0" class="timesheet-row"&gt; &lt;label for="project-0"&gt;Project&lt;/label&gt; &lt;select id="project-0" name="project-0" required&gt;...
[]
[ { "body": "<p>Most of this code is due to the fact that you're increasing the numbers in your attributes. I think that's a mistake. Your rows should all have identical <code>name</code> attributes, stored in an array (e.g. <code>name=\"task[]\"</code>).</p>\n\n<p>The only problem would then be the identical IDs...
{ "AcceptedAnswerId": "13803", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T15:23:21.273", "Id": "13794", "Score": "5", "Tags": [ "javascript", "jquery", "html5", "form" ], "Title": "Dynamically adding rows to an accessible HTML form" }
13794
<p>I have a function that implements parts of reading iCal repetition rules, and returns a list of dates when a certain event takes place.</p> <p>Questions/Concerns of mine</p> <ol> <li>Any comments on the use of anonymous functions? I added them to keep the code as <a href="http://en.wikipedia.org/wiki/Don%27t_repea...
[]
[ { "body": "<p>Something to keep in mind about anonymous functions (also known as lambda functions), is that they should only be used for tasks that are only going to be performed once. These functions are not compiled at runtime and so must be explicitly compiled each time they are run. Another thing to keep in...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T16:16:09.960", "Id": "13799", "Score": "0", "Tags": [ "php", "datetime", "drupal" ], "Title": "Basic function to output repeating dates from iCal format" }
13799
<p><strong>Base Info</strong></p> <ul> <li>Two tables: tData, tData2 </li> <li>Exactly the same columns </li> <li>About 200,000 records</li> <li>SQL Server 2008 R2</li> </ul> <p><strong>Logic</strong></p> <p>At first sight we need to insert tData rows into tData2. What else?</p> <p>We need a renamed version of a co...
[]
[ { "body": "<p>I'm not a DBA/DBMS guru, so just some ideas:</p>\n\n<ul>\n<li>Turn off indexes on <code>tData2</code> during the migration.</li>\n<li>Do it in smaller chunks for smaller transaction log. (<a href=\"https://stackoverflow.com/q/1602244/843804\">Batch commit on large INSERT operation in native SQL?</...
{ "AcceptedAnswerId": "13808", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T19:02:12.610", "Id": "13805", "Score": "1", "Tags": [ "optimization", "performance", "sql", "sql-server" ], "Title": "SQL iteration-Insertion plus renaming" }
13805
<p>I prompt the user for 9 numbers, store those numbers in 9 pointers and display the element 2. It seem to work just fine, but am I forgetting something? Can I improve it but keep it simple? I'm just a beginner testing what I have learned so far.</p> <pre><code>int n; int *array[9]; bool isUsed[10] = {0}; for(int i ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T20:50:54.880", "Id": "22281", "Score": "1", "body": "use an array of int rather than array of int* would be a good start" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T20:51:03.097", "Id": "22282...
[ { "body": "<p>You can definitely improve it, by replacing the array of pointers with a <code>std::vector&lt;int&gt;</code>.</p>\n\n<p>If you must track usage, I suggest using a map instead, where the keys are <code>0...9</code> and the values exist only if the respective index was added.</p>\n", "comments":...
{ "AcceptedAnswerId": null, "CommentCount": "11", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T20:49:09.977", "Id": "13806", "Score": "2", "Tags": [ "c++", "beginner", "homework" ], "Title": "Displaying a certain element among inputted numbers" }
13806
<p>I got some really good responses here last time, which really helped out quite a bit, so I thought I'd try again with a new batch.</p> <p>Below is the second phase of my first Java project: Intercommunication between panels. This builds upon the old code, though it has been heavily modified since the first version....
[]
[ { "body": "<p>I have a few notes:</p>\n\n<ul>\n<li>The reason the this keyword doesn't work in main is because main is a static method. The this keyword refers to the current object, and in static methods, there is no current object. Static methods are associated with the class, not the instance. See <a href=\"...
{ "AcceptedAnswerId": "13932", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T21:11:03.803", "Id": "13809", "Score": "5", "Tags": [ "java", "swing" ], "Title": "Intercommunication Between Cards" }
13809
<pre><code>Function Enumerate-Properties($fileName) { $path = (Get-Item $fileName).FullName $shell = New-Object -COMObject Shell.Application $folder = Split-Path $path $file = Split-Path $path -Leaf $shellfolder = $shell.Namespace($folder) 0..287 | Foreach-Object {'{0} = {1}' -f $_, $shellfolder...
[]
[ { "body": "<p>A first thing to note is that you are creating a lot of COMObjects in a similar manner, we can simply extract that behavior as a separate function. Then, we note that you are expecting file names as parameters where you could expect an item instead; that allows you to pass on items to Create-List3...
{ "AcceptedAnswerId": "13859", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-18T23:21:22.263", "Id": "13816", "Score": "5", "Tags": [ "file", "powershell" ], "Title": "Inspecting properties of files" }
13816
<p> I am writing an API wrapper and the endpoint takes dates in a very specific format.</p> <p>The user of the API can pass in the parameters in whatever format they prefer, but regardless of what they pass in, I want to be able to clean up their input prior to submitting their query.</p> <p>My question centers aroun...
[]
[ { "body": "<p>Here, while it may look nice, the method clean_hash is not general enough to be valid across all Hashes. So adding a method such as clean_hash to all Hashes would only serve to increase the coupling which is bad. A second problem is that you are mutating your method argument which is almost never ...
{ "AcceptedAnswerId": "13822", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T03:30:06.757", "Id": "13820", "Score": "2", "Tags": [ "ruby" ], "Title": "Reformatting a method options hash" }
13820
<p>Every time I go to write an MVVM application (say every 4-6 months) I rewrite my <code>ViewModelBase</code> class. This is for a range of reasons but let's say either I don't have access to prior code, the previous code was built for a client and isn't my code, or I'm working on someone else's machine and still don'...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T10:19:14.580", "Id": "22312", "Score": "0", "body": "I've never considered doing this. I'm interested to see what context would this be useful when using the view model on the view? Do you have any example code of it's usage?" }...
[ { "body": "<p>Specifically related to <code>NotifyPropertyChanged</code> I've found <code>VerifyPropertyName</code> to be useful.</p>\n\n<p>From Josh Smith's site: <a href=\"http://joshsmithonwpf.wordpress.com/2007/08/29/a-base-class-which-implements-inotifypropertychanged/\" rel=\"nofollow\">A base class which...
{ "AcceptedAnswerId": "13849", "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T04:49:42.807", "Id": "13823", "Score": "7", "Tags": [ "c#", "mvvm" ], "Title": "Improvements to a ViewModelBase" }
13823
<p>I'm using this pattern (for want of a better word) repeatedly in my code to call a REST API in my javascript code. Some particulars of the code below.</p> <ol> <li>I have a ConfigViewer javascript class that is responsible for creating, populating and handling events for DOM element.</li> <li>This class constructor...
[]
[ { "body": "<p>It doesn't look like your class has any data, so I must question what's the point. Any instance of the class\nwould be equal to each other.</p>\n\n<p>Your <a href=\"http://misko.hevery.com/code-reviewers-guide/flaw-constructor-does-real-work/\" rel=\"nofollow\">constructor is also doing a lot of r...
{ "AcceptedAnswerId": "13828", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T09:50:41.323", "Id": "13826", "Score": "2", "Tags": [ "javascript", "jquery", "ajax" ], "Title": "Closure handling in javascript / jquery ajax" }
13826
<p>I am in the progress of creating a MVC structured website. I've opted to make my own instead of using pre-constructed MVC systems as a way to teach myself better coding and understanding how applications work. I've got everything laid out, but I'm not happy with my routing system. It is VERY crude and I'd like it to...
[]
[ { "body": "<p>First off, congrats on making your own, that's the best way to learn and usually you don't need all the added overhead that a prefab provides.</p>\n\n<p>In the implementation of MVC I like to use, there is a router between the view and controller, so its more of a MVRC rather than MVC. Just anothe...
{ "AcceptedAnswerId": "13851", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T10:02:07.610", "Id": "13827", "Score": "4", "Tags": [ "php", "array", "mvc", "url", "url-routing" ], "Title": "Routing in MVC with PHP" }
13827
<p>I've created a database connection pool used on the serverside (of a client-server socket app) and was wondering what improvements can be made to help the design and/or efficiency of the solution. The pool is used from multiple threads so synchronisation is important.</p> <p>The application has been running for a ...
[]
[ { "body": "<p>I would advice to look at DBCP library <a href=\"http://commons.apache.org/dbcp/\" rel=\"nofollow\">http://commons.apache.org/dbcp/</a>.</p>\n\n<p>If you are deploying your application in servlet container or application server then it has it's own implementation of the database connection pool. S...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T10:07:23.923", "Id": "13829", "Score": "2", "Tags": [ "java" ], "Title": "Connection pooling with time-alive limited connections" }
13829
<p>Code below is scattered all over the code base : </p> <pre><code>if (StringUtils.contains(manager.getName, "custom")){ } </code></pre> <p>It just checks if an object attribute contains a predefined String and if it does, enter condition.</p> <p>Is there a more elegant way of achieving above, perhaps using an enu...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T12:43:40.063", "Id": "22316", "Score": "1", "body": "Is the string being searched for always the same?" }, { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T13:37:00.537", "Id": "22319", "Score": "0...
[ { "body": "<ol>\n<li><p>It seems <a href=\"http://c2.com/cgi/wiki?DataEnvy\" rel=\"nofollow noreferrer\">data envy</a>. I'd create <code>nameContains</code> method in the <code>Manager</code> class.</p>\n\n<pre><code>public boolean nameContains(final String searchText) {\n if (StringUtils.contains(name, sear...
{ "AcceptedAnswerId": "13832", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T10:27:11.247", "Id": "13831", "Score": "2", "Tags": [ "java", "strings" ], "Title": "How to re-factor a common String comparison" }
13831
<p>I was trying to find a way to redirect to different pages on authorization and authentication failure. I found <a href="https://stackoverflow.com/a/9018300/887149">this</a> to be a possible solution.</p> <p>However, I ended with a different solution by myself. It seems to work fine, however, I am not sure if it is ...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-06-07T12:30:11.757", "Id": "22318", "Score": "0", "body": "If you are confused with how the URL to redirect is formed, just ignore it. Its NOT important!" } ]
[ { "body": "<p>There is something wrong with this Method that makes it a bit confusing.</p>\n\n<blockquote>\n<pre><code> protected override bool AuthorizeCore(HttpContextBase httpContext) {\n if(httpContext.User.Identity.IsAuthenticated) {\n if(string.IsNullOrEmpty(Roles)) {\n ...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-06-07T12:18:59.787", "Id": "13838", "Score": "7", "Tags": [ "c#", "http", "asp.net-mvc-3", "url", "authorization" ], "Title": "Custom Authentication Attribute" }
13838
<p>I have a button group that looks like this:</p> <p><img src="https://i.stack.imgur.com/X2ZLA.png" alt="Button group"></p> <p>The user selects one of the options and they can search for a person based on that criteria.</p> <p>I wrote a switch statement that populates the URL to make the ajax call to get the data ...
[]
[ { "body": "<p>I don't really think putting the URL in your HTML is a good idea; Separating presentation from functionality and all that...</p>\n\n<p>However, instead of using a switch statement, you should be using an object literal to map the URLs to the <code>clickedOptionId</code> key:</p>\n\n<pre><code>var ...
{ "AcceptedAnswerId": "13847", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T15:39:29.777", "Id": "13840", "Score": "1", "Tags": [ "javascript", "jquery", "html5" ], "Title": "JavaScript switch statement to make an AJAX call" }
13840
<p>I made this small class the allows me to navigate large arrays using something like: key1/key2/key3</p> <p>I made this because I was creating large arrays to hold my classes configs and needed a simpler way of accessing the data.</p> <p>Here is the project: - <a href="https://github.com/AntonioCS/settingsManager...
[]
[ { "body": "<p>I swear I've seen this approach somewhere before, I'll have to see if I can't find that link again. Anyways, a couple of drawbacks of this approach is lack of portability and lack of familiarity. Portability meaning no one can move that code without also taking that class with it. Familiarity mean...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T16:09:15.897", "Id": "13843", "Score": "3", "Tags": [ "php", "array" ], "Title": "Small class to manage config data" }
13843
<p>I have written a script, introduced <a href="http://hermannn.com/programs/aa/" rel="nofollow">here</a>, that improves the Linux terminal experience. It basically displays the content of the terminals current folder in a nicer way than the 'ls' command does. I use it all the time myself.</p> <pre><code>#!/usr/bin/p...
[]
[ { "body": "<p><code>use strict;</code> and <code>use warnings;</code> are missing. Add them and declare all your variables.</p>\n\n<pre><code>opendir(CDIR, \".\") or die \"$!\";\n</code></pre>\n\n<p>I believe that it’s advised to use variables in modern Perl:</p>\n\n<pre><code>opendir(my $cdir, '.') or die $!;\...
{ "AcceptedAnswerId": "13875", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T17:19:28.897", "Id": "13845", "Score": "4", "Tags": [ "perl", "linux" ], "Title": "Improved remake of the Linux 'ls' command" }
13845
<p>So I decided to create a trait that I could add to my classes that would add a simple way of binding functions to an event, and to fire those events. It ended up going a little further than I expected it to, and I am getting into things I do not normally work with, such as defining an object via a variable, <code>$a...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T21:13:06.267", "Id": "22339", "Score": "0", "body": "Please provide an example implementation. I find it easier than trying to figure out how something works given no context. Initial comments: All your methods that are prefixed as ...
[ { "body": "<p>I'm not sure I really understand the purpose of this code. From the looks of it, you are recreating the factory design pattern but in a more complicated fashion. Not that I can be sure that this statement is true, your code is pretty hard to follow. But that's what comes from using variable-variab...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T19:23:12.777", "Id": "13850", "Score": "1", "Tags": [ "php", "php5" ], "Title": "PHP 5.4 Event System, just looking for general feedback" }
13850
<p>I have a rather large javascript array of objects that I am transforming into an HTML table. Each object in the array looks like:</p> <pre><code>{ name:'Document Title', url:'/path/to/document.html', categories:['Some Category'], protocols:['ID Number','Another ID'], sites:['Location'] } </code>...
[ { "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T20:09:30.063", "Id": "22333", "Score": "0", "body": "Did you take a look at documentFragment (which is known to be faster) ? Usage : https://developer.mozilla.org/en/DOM/document.createDocumentFragment and article talking about it :...
[ { "body": "<p>If this is on an intranet, with similar machines running this JS, then 2 seconds is fairly ok for 4,200 records...but if its on the internet, you might want to think about doing this server side and just ajax'ing the server generated table code via js...someone running this on an iPad would probab...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-19T19:55:02.220", "Id": "13852", "Score": "1", "Tags": [ "javascript", "jquery", "performance", "array" ], "Title": "Improve speed of object-to-html transform in javascript?" }
13852
<p><strong>Windows PowerShell</strong></p> <p><a href="/questions/tagged/powershell" class="post-tag" title="show questions tagged &#39;powershell&#39;" rel="tag">powershell</a> is an interactive shell and scripting language originally included with Microsoft Windows 7 and Microsoft Windows Server 2008 R2 and above. It...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2012-07-20T08:51:49.777", "Id": "13860", "Score": "0", "Tags": null, "Title": null }
13860
Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remot...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-20T08:51:49.777", "Id": "13861", "Score": "0", "Tags": null, "Title": null }
13861
<p>I have a PhoneGap application that I wrote some time ago. After looking Doug Crockford's video seminar <a href="http://www.youtube.com/watch?v=hQVTIJBZook" rel="nofollow"><em>JavaScript: The Good Parts</em></a>.</p> <p>I was just wondering if the code could be improved for better maintainability and readability as ...
[]
[ { "body": "<p>I think your code looks fine (except for <code>populateReserveList</code>).</p>\n\n<ul>\n<li>I would look into replacing <code>.live()</code> calls with <code>.on()</code> calls as <code>.live()</code> has been deprecated since a while.</li>\n<li>Your <code>success</code> function is so large, it ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2012-07-20T09:17:58.993", "Id": "13862", "Score": "3", "Tags": [ "javascript", "jquery", "design-patterns", "mobile", "phonegap" ], "Title": "Improving PhoneGap/JavaScript applicatio...
13862