body stringlengths 25 86.7k | comments list | answers list | meta_data dict | question_id stringlengths 1 6 |
|---|---|---|---|---|
<p>The <a href="https://developers.facebook.com" rel="nofollow noreferrer">Facebook Platform</a> is a software environment provided by the social networking service Facebook for third-party developers to <a href="https://developers.facebook.com/docs/" rel="nofollow noreferrer">create their own applications</a> and serv... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:01:00.623",
"Id": "42210",
"Score": "0",
"Tags": null,
"Title": null
} | 42210 |
Facebook Platform lets developers integrate their apps directly into the Facebook social networking service. Use this tag for questions which may arise when developing FOR Facebook. This tag is NOT for support questions about using the Facebook website or the official Facebook app. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:01:00.623",
"Id": "42211",
"Score": "0",
"Tags": null,
"Title": null
} | 42211 |
<p>The link between dynamic programming and recursion is actually very strong.</p>
<p>Any dynamic programming solution can be transformed into a recursive solution (with memoization), with identical performance characteristics, e.g O(n*n). The difference is primarily one of presentation.</p>
<p>The <a href="http://e... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:02:14.520",
"Id": "42212",
"Score": "0",
"Tags": null,
"Title": null
} | 42212 |
Dynamic programming is an algorithmic technique for efficiently solving problems with a recursive structure containing many overlapping subproblems. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:02:14.520",
"Id": "42213",
"Score": "0",
"Tags": null,
"Title": null
} | 42213 |
<p><a href="http://laravel.com/" rel="nofollow">Laravel</a> is a <a href="/questions/tagged/framework" class="post-tag" title="show questions tagged 'framework'" rel="tag">framework</a> for <a href="/questions/tagged/php" class="post-tag" title="show questions tagged 'php'" rel="tag">php</a> web develop... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:02:52.430",
"Id": "42214",
"Score": "0",
"Tags": null,
"Title": null
} | 42214 |
Laravel is an open-source PHP web development framework created by Taylor Otwell. Laravel helps you create applications using simple, expressive syntax. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:02:52.430",
"Id": "42215",
"Score": "0",
"Tags": null,
"Title": null
} | 42215 |
<p>Initially released as an add-on to Internet Information Services (IIS) via the Windows NT 4.0 Option Pack, it was subsequently included as a free component of Windows Server (since the initial release of Windows 2000 Server). </p>
<p>ASP 2.0 provided six built-in objects: Application, ASPError, Request, Response, S... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:03:19.273",
"Id": "42216",
"Score": "0",
"Tags": null,
"Title": null
} | 42216 |
<p>The 2.0 version of the .NET Framework.</p>
<p>Version Number: 2.0.50727.42<br>
Release Date: 2005-11-07</p>
<p>A listing of the releases of the .NET Framework can be found here:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/List_of_.NET_Framework_versions" rel="nofollow">List of .NET Framework versions</a></... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:04:03.763",
"Id": "42218",
"Score": "0",
"Tags": null,
"Title": null
} | 42218 |
The 2.0 version of the .NET Framework. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:04:03.763",
"Id": "42219",
"Score": "0",
"Tags": null,
"Title": null
} | 42219 |
<p><a href="http://en.wikipedia.org/wiki/Base64" rel="nofollow">Base64</a> is a group of similar encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The Base64 term originates from a specific MIME content transfer encoding.</p>
<p>Base64 uses characte... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:04:33.013",
"Id": "42220",
"Score": "0",
"Tags": null,
"Title": null
} | 42220 |
Base64 is an encoding scheme (with some variations in the presentation) that represents binary data in an ASCII string format. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:04:33.013",
"Id": "42221",
"Score": "0",
"Tags": null,
"Title": null
} | 42221 |
<p>Code relating to the recording, playback, or manipulation of audio data.</p>
| [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:05:00.330",
"Id": "42222",
"Score": "0",
"Tags": null,
"Title": null
} | 42222 |
Code relating to sound recording, playback, and manipulation of audio data and hardware. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:05:00.330",
"Id": "42223",
"Score": "0",
"Tags": null,
"Title": null
} | 42223 |
<p>There are a number of techniques to compress information, with most algorithms working to compress image, speech, music or video. Encoding the same information in lesser bits results in saving some crucial resource such as transmission bandwidth or hard-disk space. Compression algorithms also take advantage of human... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:05:33.690",
"Id": "42224",
"Score": "0",
"Tags": null,
"Title": null
} | 42224 |
The name given to the process of encoding data such that it uses lesser number of bits as compared to the original representation. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:05:33.690",
"Id": "42225",
"Score": "0",
"Tags": null,
"Title": null
} | 42225 |
<p>Razor is a template language used by <a href="http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx" rel="nofollow noreferrer">ASP.NET Web Pages</a> and <a href="http://weblogs.asp.net/scottgu/archive/2010/07/27/introducing-asp-net-mvc-3-preview-1.aspx" rel="nofollow noreferrer">ASP.NET MVC</a> (s... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2014-02-20T00:08:31.373",
"Id": "42226",
"Score": "0",
"Tags": null,
"Title": null
} | 42226 |
Razor is a template language used by ASP.NET Web Pages and ASP.NET MVC (since version 3). It supports seamless transitions between HTML markup and C# or VB code. Transitions between markup and code are indicated by the "@" sign. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:08:31.373",
"Id": "42227",
"Score": "0",
"Tags": null,
"Title": null
} | 42227 |
Locking allows controlled access to specific resources. Exclusive access is the most common requirement, but other variations are possible. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:09:15.050",
"Id": "42229",
"Score": "0",
"Tags": null,
"Title": null
} | 42229 |
<p>UTF-8 is a character encoding that can describe the set of <a href="/questions/tagged/unicode" class="post-tag" title="show questions tagged 'unicode'" rel="tag">unicode</a> code points in byte sequences of one to six bytes.</p>
<p>UTF-8 is the most widely used character encoding, and is recommended for use... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:09:57.270",
"Id": "42230",
"Score": "0",
"Tags": null,
"Title": null
} | 42230 |
UTF-8 (Unicode Transformation Format, 8 bits) is a character encoding that describes each Unicode code point using a byte sequence of one to six bytes. It is backwards-compatible with ASCII while still supporting representation of all Unicode code points. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:09:57.270",
"Id": "42231",
"Score": "0",
"Tags": null,
"Title": null
} | 42231 |
<p>My game uses configuration files in JSON format. One of them is used for setting up control bindings, and it looks like this:</p>
<pre><code>{
"DisplaySettings": {
"IsFullScreen": false,
"PreferredBackBufferWidth": 800,
"PreferredBackBufferHeight": 600
},
"GamePadSettings": {
"Back": "Exit",
... | [] | [
{
"body": "<p>I'm not sure about binding directly to methods based on a configuration file like this, because it means you have to be very careful about what methods does your <code>Game</code> type expose (assuming the player has access to the configuration file, which it probably does).</p>\n\n<p>Consider add... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:10:17.650",
"Id": "42232",
"Score": "5",
"Tags": [
"c#",
"game",
"json",
"reflection",
"dependency-injection"
],
"Title": "Setting up keyboard bindings using JSON and r... | 42232 |
<p><a href="http://struts.apache.org/2.x/" rel="nofollow">Apache Struts 2</a> is an extensible framework based on model–view–controller (MVC) architecture for creating enterprise-ready Java web applications. The framework is designed to streamline the full development cycle, from building, to deploying, to maintaining... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:12:32.173",
"Id": "42235",
"Score": "0",
"Tags": null,
"Title": null
} | 42235 |
Apache Struts 2 is an extensible framework based on model–view–controller (MVC) architecture for creating enterprise-ready Java web applications.
| [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:12:32.173",
"Id": "42236",
"Score": "0",
"Tags": null,
"Title": null
} | 42236 |
A subroutine (e.g. procedure or subprogram) is a portion of code within a larger program, which performs a specific task and can be relatively independent of the remaining code. The syntax of many programming languages includes support for creating self contained subroutines, and for calling and returning from them. T... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:12:53.707",
"Id": "42238",
"Score": "0",
"Tags": null,
"Title": null
} | 42238 |
<p>The ISO definition of usability:</p>
<blockquote>
<p>The <em>effectiveness, efficiency and
satisfaction</em> with which specified
users achieve specified goals in
particular environments. </p>
<p><strong>Effectiveness</strong>: the accuracy and
completeness with which specified
users can achieve s... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:13:40.320",
"Id": "42239",
"Score": "0",
"Tags": null,
"Title": null
} | 42239 |
The effectiveness, efficiency and satisfaction with which users achieve specified goals in particular environments. This covers ease of use and learnability of software applications and websites. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T00:13:40.320",
"Id": "42240",
"Score": "0",
"Tags": null,
"Title": null
} | 42240 |
<p>I'm making a Backbone-Marionette app with a file structure that matches restful verbs as much as possible. It looks something like this:</p>
<blockquote>
<pre><code>+ backbone
+ apps
+ student
+ show
+ list
+ new
+ lesson
+ show
+ new
+ edit
</code></pre>
</blockquote>
... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T01:55:54.723",
"Id": "42246",
"Score": "3",
"Tags": [
"javascript",
"backbone.js"
],
"Title": "Different templates for various resource representations in Marionette"
} | 42246 |
<p>Please take a look at this code:</p>
<pre><code>class error_stream: boost::noncopyable
{
public:
template<typename T>
std::ostream& operator<<(T&& arg)
{
return strm() << std::forward<T>(arg);
}
std::string str() { return strm().str(); }
bool empty... | [] | [
{
"body": "<p>This seems overcomplicated to me. Lazy-loading something doesn't require placement-new trickery and mucking around with alignments. Why not simply store a pointer to the stream which is only initialised when the user performs some kind of operation? This is the general way to do lazy-loading:</p>\... | {
"AcceptedAnswerId": "42261",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T02:17:45.283",
"Id": "42248",
"Score": "10",
"Tags": [
"c++",
"c++11",
"stream",
"wrapper"
],
"Title": "Correct usage of alignas in std::ostringstream wrapper"
} | 42248 |
<p>How can I optimize the following PHP/JS code?</p>
<p>It works like a charm but I think it is too long and I'm sure it could be optimized. If I have another form, I'll need to copy paste some lines from my PHP code and it'll be quickly overkill.</p>
<hr>
<p>JavaScript:</p>
<pre><code><script>
$(document).re... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-27T07:10:51.580",
"Id": "74026",
"Score": "0",
"body": "Consider using PHP's [filter_var()](http://www.php.net/manual/en/filter.examples.validation.php) to check the emails."
}
] | [
{
"body": "<h3>At least for the PHP part:</h3>\n<p>You should make it into a function where you return status instead of going over every possibility even if you have a <em>fail</em>.</p>\n<pre><code>function validate_post() {\n if ( ... )\n return "no";\n if ( ... )\n return "yes&q... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T02:44:01.697",
"Id": "42250",
"Score": "6",
"Tags": [
"javascript",
"php",
"jquery",
"json",
"form"
],
"Title": "Account-Creation form"
} | 42250 |
<p>With iOS7, Apple introduced <code>AVCaptureMetadataOutputObjects</code>, which is used for scanning barcodes. If you check out the web for how to scan barcodes in iOS, almost everyone is talking about ZBarSDK. And before iOS7, this was definitely the way to go. But as of iOS7, ZBarSDK has a pretty nasty memory le... | [] | [
{
"body": "<p>One possible improvement for the sake of convenience could be to add some meta groups to the enum.</p>\n\n<p>For example:</p>\n\n<pre><code>typedef NS_OPTIONS(unsigned short, BarcodeType) {\n CODE_UPCE = 1 << 0,\n CODE_CODE39 = 1 << 1,\n CODE_CODE39MO... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T03:23:28.193",
"Id": "42252",
"Score": "5",
"Tags": [
"objective-c",
"ios"
],
"Title": "AVCaptureMetadataOutputObjects Wrapper"
} | 42252 |
<p>This project has <a href="https://github.com/patrickmarabeas/ng-FitText.js/blob/49038a2d0857194edfd83ad6fd62f62185f43a26/angularjs-fittext.js" rel="nofollow">evolved a lot</a> since I started learning Angular. I'm pretty happy with it now, and I'm wondering if there's anything I can improve upon, or have forgotten a... | [] | [
{
"body": "<ul>\n<li><p>As personal opinion, I wouldn't use <code>config</code> as name for <code>.value</code>, it sounds too generic and can be confused with <code>.config</code> method of the <code>module</code> API.</p></li>\n<li><p>Putting comments like <code>//default is false</code> looks confusing - why... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T03:48:17.143",
"Id": "42254",
"Score": "0",
"Tags": [
"javascript",
"html",
"angular.js"
],
"Title": "Angular version of FitText"
} | 42254 |
<h2><a href="http://www.tornadoweb.org/" rel="nofollow">Tornado</a></h2>
<p>A web server and a web framework for <a href="http://www.python.org/" rel="nofollow">Python</a>. Originally built to power <a href="http://friendfeed.com/" rel="nofollow">FriendFeed</a> (owned by Facebook), it is now an open source project and... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T03:48:38.710",
"Id": "42255",
"Score": "0",
"Tags": null,
"Title": null
} | 42255 |
Tornado is a scalable web server and web framework for Python specializing in handling thousands of simultaneous connections and real-time services. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T03:48:38.710",
"Id": "42256",
"Score": "0",
"Tags": null,
"Title": null
} | 42256 |
<p>I have code which gets data from a <code>POST</code> request (<code>request.form</code> dict), compares with corresponding attribute in object <code>accident</code> and does some action. The code looks needlessly verbose. How can I optimize it?</p>
<pre><code>if accident.status == 1:
if request.form.get('reaso... | [] | [
{
"body": "<p>I'm not 100% sure there is a particularly elegant way to write this. If the code did not have a different body for each <code>if</code> statement, one could rewrite it like this</p>\n\n<pre><code>FORM_VALUES = {\n \"priority\": accident.priority,\n \"status\": accident.status,\n \"duratio... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T04:31:00.167",
"Id": "42259",
"Score": "11",
"Tags": [
"python",
"form",
"hash-map",
"mongodb"
],
"Title": "Conditionally set attributes in MongoDB based on form fields"
} | 42259 |
<p>So, I am not sure if I should have <code>Vertex</code> <em>extend</em> <code>Point</code>, because the <code>equals()</code> and <code>compareTo()</code> functions are already parameterized with <code>Point</code>. I guess I don't really need compare to...</p>
<p>Does this structure look good? I used a <code>Map</c... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T11:35:32.633",
"Id": "72729",
"Score": "0",
"body": "After doing some research, I found that the best answer for this question: [SO: How do I properly extend the AS3 Point class?](http://stackoverflow.com/a/9015761/1762224) states t... | [
{
"body": "<p><code>adjList</code> needs a more descriptive name. Specifically as a class member variable, it deserves the few extra characters it would take to be called <code>adjacencyList</code>.</p>\n\n<p>Additionally, you have extended <code>Point</code>, but do not use any of <code>Point</code>'s function... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T05:15:15.933",
"Id": "42262",
"Score": "3",
"Tags": [
"graph",
"actionscript-3",
"actionscript"
],
"Title": "Actionscript Graph data structure implementation"
} | 42262 |
<pre><code>char *cat_string(char *to_cat, char *destination) {
char *copy = destination;
while (*copy != '\0') {
*copy++;
}
while (*to_cat != '\0') {
*copy++ = *to_cat++;
}
*copy = '\0';
return destination;
}
</code></pre>
<p>I would like to know if this is an efficient and effective way of writi... | [] | [
{
"body": "<p>You renamed <code>strcat()</code> to <code>cat_string()</code>, so I suppose it's fitting that you reversed the traditional order of the parameters as well. ☺</p>\n\n<p>I would make three changes:</p>\n\n<ul>\n<li>Changing the first argument to <code>const</code> helps prevent users notice if the... | {
"AcceptedAnswerId": "42266",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T05:30:09.337",
"Id": "42264",
"Score": "5",
"Tags": [
"c",
"beginner",
"strings"
],
"Title": "Writing strcat (string concatenate) in C"
} | 42264 |
<p>As a follow-up on <a href="https://codereview.stackexchange.com/questions/38619/in-memory-cache-implementation">my earlier question</a>, here is the new implementation. The major change is now that the base class just deals in <code>ICacheValue</code> values which are implemented by the derived classes and generated... | [] | [
{
"body": "<blockquote>\n <p>Unfortunately requires some casting in the derived classes but I don't think there is a way around it in C#.</p>\n</blockquote>\n\n<p>There is a way around that.</p>\n\n<p>Define a 3rd template parameter to specify the type of cache value; use a <code>where</code> constraint on the... | {
"AcceptedAnswerId": "42272",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T07:16:30.533",
"Id": "42269",
"Score": "4",
"Tags": [
"c#",
"multithreading",
"cache"
],
"Title": "In-memory cache implementation revisited"
} | 42269 |
<p>How can I reduce cyclomatic complexity of validation and refactor it better way?</p>
<pre><code>Class Document
def initialize(opts)
@opts = opts
return ArgumentError unless valid?
end
def valid?
return false if @opts.nil?
return false if @opts[:property_1].nil?
return false if @opts[:prop... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T09:50:11.330",
"Id": "72719",
"Score": "2",
"body": "Welcome to Code Review. We can usually give better advice for you if you provide real code from an actual project that you are working on, without stripping out the context. As it... | [
{
"body": "<p>You could write that as</p>\n\n<pre><code>def valid?\n @opts && !@opts[:property].nil? ? true : false\nend\n</code></pre>\n\n<p>but usually it would be good enough to return a truthy or falsy value instead of a Boolean:</p>\n\n<pre><code>def valid?\n @opts && !@opts[:property].ni... | {
"AcceptedAnswerId": "42289",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2014-02-20T09:04:59.910",
"Id": "42275",
"Score": "2",
"Tags": [
"ruby",
"validation",
"null",
"cyclomatic-complexity"
],
"Title": "Validating the presence of properties in a document... | 42275 |
<p>This integration test involves database access and hence opening and closing a database connection. Does it look correct? I am concerned about ensuring the the database connection is closed should the test fail.</p>
<pre><code>"use strict";
describe("MyCtorFunction", function () {
describe("myMethod", function ... | [] | [
{
"body": "<p>From a once over and reading some Jasmine docs:</p>\n\n<ul>\n<li><p>I am not a big fan of <code>_db</code> and <code>_testContext</code>, I see no reason for the underscores.</p></li>\n<li><p>It is not guaranteed that <code>_db</code> will be set in <br><code>new MyCtorFunction(_db).myMethod(_test... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T09:13:14.510",
"Id": "42276",
"Score": "2",
"Tags": [
"javascript",
"jasmine",
"integration-testing"
],
"Title": "Integration test for database access"
} | 42276 |
<p>I have this assignment where I'm supposed to code an algorithm for finding the quantity of <a href="http://en.wikipedia.org/wiki/Longest_increasing_subsequence" rel="nofollow noreferrer">Longest Increasing Subsequences</a> from an array of (different) integers and print them all.</p>
<p>I developed one which always ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T21:37:20.053",
"Id": "72844",
"Score": "0",
"body": "Please clarify the problem specification.... if you are allowed to 'skip' out-of-sequence numbers, can you skip 'inconvenient' numbers too? Is the longest sequence in `[1,2,8,3,4,... | [
{
"body": "<p><strong>Note</strong>: This review is based on the (apparently incorrect) assumption that the sequence in question is 'contiguous'. In other words, the 'right solutions' in the example:</p>\n\n<pre><code>[2,-3,4,90,-2,-1,-10,-9,-8]\n</code></pre>\n\n<p>are:</p>\n\n<pre><code>[-3, 4, 90] and [-10, ... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T09:19:56.137",
"Id": "42277",
"Score": "4",
"Tags": [
"java",
"algorithm",
"matrix",
"dynamic-programming"
],
"Title": "Returning all the LIS of given array of int"
} | 42277 |
<p>I'm trying to create some easily accessible database of different skills. General idea is that every skill should do something different and be able to act on different things (ex. one skill which icreases weapon attack by 'x' [it acts on weapon] and other one which icreases chances to drop item by 'z'% [it acts on ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T10:40:00.930",
"Id": "72724",
"Score": "0",
"body": "Okay, found solution to the whole problem in general, but the approach is completly different. I still wonder if it could be handled in the way it is in posted code, just improved... | [
{
"body": "<p>Hmmm,</p>\n\n<p>Well I think the way you are going about it, while functionally correct won't scale well.</p>\n\n<p>Ideally you want to try more of an aggregation. Off the top of my head I would approach this like:</p>\n\n<pre><code>interface Skill\n{\n string Name{get;}\n double value{get;}\n... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T09:24:12.867",
"Id": "42278",
"Score": "7",
"Tags": [
"c#",
"game",
"generics",
"hash-map",
"delegates"
],
"Title": "Game passive skill system"
} | 42278 |
<p>Because the throughput of my radio and device is limited, I wanted to compress my control string. I decided to compress the command into an 8 bytes (quasi) string (throttle high, throttle low, pitch, roll, yaw plus/minus, yaw value, checksum, stop byte) and after parsing in four variables:</p>
<ul>
<li>Pitch (betwe... | [] | [
{
"body": "<blockquote>\n <p>I don't know exactly why (maybe radio, maybe I caused unexpected behavior because of type conversions here).</p>\n</blockquote>\n\n<p>Can you keep statistics on how many checksum errors there are?</p>\n\n<ul>\n<li>If there are many that implies that the communications link is noisy... | {
"AcceptedAnswerId": "42284",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T10:28:34.763",
"Id": "42282",
"Score": "1",
"Tags": [
"c++",
"c",
"arduino"
],
"Title": "Enhancing parser for 8 byte command string (expect problems with type conversions) for ... | 42282 |
<p>I have written the following script that I'd like to have reviewed:</p>
<pre><code>#!/usr/bin/python
import os
os.system('hg tags > tags.txt')
file = 'tags.txt'
path = os.path.join(os.getcwd(), file)
fp = open(path)
for i, line in enumerate(fp):
if i == 1:
latestTagLine = line
elif i == 2... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T17:23:13.417",
"Id": "72801",
"Score": "3",
"body": "I don't normally edit the code in the question to fix the whitespace. However, since you double-spaced the entire post, including the `hg tags` output (which the code expects to b... | [
{
"body": "<ol>\n<li>Your code does not run. I'll assume <code>latestTagLine</code> should be indented once more and the ` is to be removed at the end of the line.</li>\n<li><del>You have way too much blank lines, it doesn't help anyone.</del> <em>Formatting subsequently cleaned up.</em></li>\n<li>You could use... | {
"AcceptedAnswerId": "42324",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T11:03:04.667",
"Id": "42285",
"Score": "5",
"Tags": [
"python",
"parsing",
"child-process"
],
"Title": "Extract changesets between last two tags in Mercurial"
} | 42285 |
<p>In C++, I have made a basic memset / memcpy / strcpy implementation, yet I am worried that they are slower than the STL equivalent, as they are probably made in assembly, which I do not know. Is there any way of making these quicker, still using C++?</p>
<pre><code>#define BYTE unsigned char
typedef BYTE byte;
vo... | [] | [
{
"body": "<p>You can test for yourself if your implementation is faster or slower than the \"official\" one: Simply write a test program that allocates large chunks of memory and then make a number of calls to your implementation and take the time. Then, rewrite your program to use the corresponding STL functi... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T11:07:12.597",
"Id": "42286",
"Score": "1",
"Tags": [
"c++",
"performance"
],
"Title": "C++ memset / memcpy / strcpy implementation performance"
} | 42286 |
<p>I have a main menu in my application. It loads depending on the role of the user that I validate from a table in my data base, but I have to recreate this menu every time I call a new controller.</p>
<p>User Controller:</p>
<pre><code>class User extends Ci_Controller {
function __construct(){
parent... | [] | [
{
"body": "<p>You need to extend <code>CI_Controller</code> with your code and extend your classses from your custom class, not default. I'll try to explain:</p>\n\n<p>At first create MY_Controller.php at /application/core/ with next content:</p>\n\n<pre><code> <?php\n\n class MY_Controller extends C... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T13:20:43.267",
"Id": "42296",
"Score": "2",
"Tags": [
"php",
"mvc",
"codeigniter",
"controller"
],
"Title": "CodeIgniter maintain data through Controllers"
} | 42296 |
<p>I have tried to implement a basic vector type in C++, yet I am not sure if I can do anything any more efficiently.</p>
<pre><code>template < typename _Ty > class vector
{
public:
typedef _Ty *iterator;
typedef _Ty _Value_type;
typedef vector<_Ty> _Myt;
vector()
: __size(0), __ca... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T05:53:50.637",
"Id": "72928",
"Score": "2",
"body": "Stop using underscore at the beginning of your identifiers (the rules are non trivial). An initial underscore followed by a capitol letter or double underscore anywhere are actual... | [
{
"body": "<p>I think your <code>~vector()</code> destructor is doing the wrong thing:</p>\n\n<ul>\n<li>It should free the memory which you allocated using <code>calloc</code></li>\n<li>It shouldn't <code>memset</code> over the objects contained in the array</li>\n<li>My guess is that it should explicitly destr... | {
"AcceptedAnswerId": "42341",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T13:20:47.847",
"Id": "42297",
"Score": "12",
"Tags": [
"c++",
"optimization",
"vectors"
],
"Title": "C++ vector implementation"
} | 42297 |
<p>I am working on the largest Java program I have undertaken to date and feel uncertain in my current code practices. I think that I state and repeat things that don't need to be which can become a headache as development goes on. Specifically, in my GridBag Constraints. I have worked with GridBagLayout before and had... | [] | [
{
"body": "<p>From a quick look at your code, I can say that your constructor is too big. I would suggest to refactored your constructor into smaller functions with only one task to do. I would probably have different method for each \"zone\" or \"group\" of elements.</p>\n\n<p>There is a lot of magic numbers i... | {
"AcceptedAnswerId": "42322",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T15:10:04.680",
"Id": "42309",
"Score": "6",
"Tags": [
"java",
"swing",
"gui"
],
"Title": "Reducing repetition and utlizing EDT"
} | 42309 |
<p>I have the following Lua script which I use against my redis environment to perform some non-production analytics on my data.</p>
<p>My dataset contains hundreds of millions of records, hence I want to make sure that the approach that I am taking is optimal for query performance and best coding practices.</p>
<pre... | [] | [
{
"body": "<p>There are a few little things that can be improved:</p>\n\n<pre><code>-- For users 'sizeBytes' is the Table[ID] to allow sorting. Collissions are not a big deal\nlocal function userAgregations(table, key, size)\n table[size] = key\nend\n</code></pre>\n\n<p>If using LuaJIT, this function might be... | {
"AcceptedAnswerId": "42333",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T15:32:20.027",
"Id": "42311",
"Score": "8",
"Tags": [
"optimization",
"algorithm",
"performance",
"lua"
],
"Title": "Performing non-production analytics on data"
} | 42311 |
<p>I have asked a question on Stack Overflow and one of the guys actually managed to hack my contact form and inject a fake email into the <code>$header</code> of the PHP! </p>
<p>So after talking to him, he sent me a few articles, and I aimed to update the PHP to secure this gap and prevent the spam. </p>
<p><strong... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T16:16:32.027",
"Id": "72787",
"Score": "4",
"body": "You don't have to validate email address yourself. PHP has a built in function filter_var($email, FILTER_VALIDATE_EMAIL);"
}
] | [
{
"body": "<p>@James is correct, <a href=\"http://www.php.net/manual/en/filter.examples.validation.php\">PHP has function to validate</a> so you don't have to (and they're better).</p>\n\n<p>Your <code>switch (true)</code> is <a href=\"http://jsperf.com/if-else-chain-vs-switch-true\">bothering me</a>. I think a... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T15:48:25.360",
"Id": "42313",
"Score": "3",
"Tags": [
"php",
"security",
"email"
],
"Title": "Preventing email injection"
} | 42313 |
<p>I have an application which retrieves data from a (potentially) very large XML file. A combination of XMLReader and XDocument seemed to be the only way I could manage the entire thing the way I wanted. It <strong>works</strong>, and it does so fairly quickly and efficiently. But I have a few review questions. </... | [] | [
{
"body": "<p>My first observations is: wrap disposable classes in using. The code as is probably has a memory leak in it:</p>\n\n<pre><code>using (var streamReader = new StreamReader(Path, Encoding.GetEncoding(\"ISO-8859-9\"))\nusing (var xmlReader = XmlReader.Create(streamReader))\n{\n // rest of logic.\n... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T16:03:02.250",
"Id": "42316",
"Score": "5",
"Tags": [
"c#",
"xml",
"factory-method"
],
"Title": "Anonymous methods, factory methods, threading, and XML input"
} | 42316 |
<p>I am using the GeoComplete plugin with RequireJS
It works, but please could someone confirm I've done this correctly, mainly my understanding of shim:</p>
<pre><code> requirejs.config({
waitSeconds: 120,
paths: {
async: './lib/async',
jquery: './lib/jquery-1.7.2.min',
... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-25T15:41:07.270",
"Id": "73693",
"Score": "1",
"body": "Does it work as you expected? If it does, you have probably done it correctly :)"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-25T15:42:25.513",
... | [
{
"body": "<p>The only thing that I see looking at this code is that you didn't keep a fully consistent formatting, and I at first thought you had an extra set of brackets or parentheses.</p>\n\n<p><img src=\"https://i.stack.imgur.com/SWuyB.png\" alt=\"enter image description here\"></p>\n\n<p>You should do it ... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T16:45:24.270",
"Id": "42321",
"Score": "2",
"Tags": [
"javascript",
"require.js"
],
"Title": "Using GeoComplete with RequireJS (with shim config)"
} | 42321 |
<p>I've recently stumbled upon an interesting challenge for me:</p>
<blockquote>
<p>You should develop C application, that solves math expressions. Operations such as (+,-,*,/) should be supported, as well as (cos, sin, exp). Application should replace constants Pi and E with built-in values. We may have any amount of ... | [] | [
{
"body": "<p>You're right that a proper expression parser would be the superior approach. Nevertheless, your <em>ad hoc</em> solution works surprisingly well, though it will have some odd behaviour.</p>\n\n<p>I'll just start by pointing out that your exception handling in <code>main()</code> is shaky. If you... | {
"AcceptedAnswerId": "42399",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T17:08:40.060",
"Id": "42323",
"Score": "13",
"Tags": [
"java",
"beginner",
"parsing",
"recursion",
"math-expression-eval"
],
"Title": "Math expression solver"
} | 42323 |
<p>I want to create XML messages for webservice communication. These messages should be created from a pool of reusable elements. Therefore I have created different classes. A "factory" class, that only returns a message class. An element class, that consists of the reusable parts and the message classes that are the b... | [] | [
{
"body": "<p>Your message classes currently have two responsibilities: representing an application logic message and transforming itself into a representation. If you want to add other ways of serialization you have to modify the message classes itself.</p>\n\n<p>The message classes only should represent the m... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T17:35:44.707",
"Id": "42327",
"Score": "3",
"Tags": [
"php",
"object-oriented",
"classes",
"xml",
"dom"
],
"Title": "Best practice to create XML messages with DOMDocument ... | 42327 |
<p>Given an array of n elements, where each element is at most k away from its target position, devise an algorithm that sorts in O(n log k) time.
For example, let us consider k is 2, an element at index 7 in the sorted array, can be at indexes 5, 6, 7, 8, 9 in the given array. I'm looking for code review, best practi... | [] | [
{
"body": "<p><code>kSortDontModifyInput()</code> and <code>kSortMoidifyInput()</code> use the same algorithm to do the sorting. The only difference is that <code>kSortDontModifyInput()</code> creates a new array instead of using the given one. Therefor you can implment <code>kSortDontMoidifyInput()</code> by m... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T17:49:57.523",
"Id": "42328",
"Score": "4",
"Tags": [
"java",
"algorithm",
"sorting"
],
"Title": "Produce a nearly sorted (or K sorted) array"
} | 42328 |
<p>A couple of days ago I <a href="https://codereview.stackexchange.com/questions/41725/factory-for-classes-unknown-at-compile-time">posted my code</a> that models systems made up of moving parts. I got several great tips and ideas and here is my latest version. My actions are now methods annotated with @Action (instea... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T13:41:28.567",
"Id": "72967",
"Score": "2",
"body": "Last time the accepted answer says: `ArrayList<...>` reference types should be simply `List<...>`. But you still have `ArrayList`s all over."
},
{
"ContentLicense": "CC BY... | [
{
"body": "<ol>\n<li><pre><code>private final Map<Class<? extends Agent>, List<? extends Agent>> listOfAgents =\n new HashMap<Class<? extends Agent>, List<? extends Agent>>();\n</code></pre>\n\n<p>The map creation would be readable with Java 7's diamond operator</p>\n\n<pr... | {
"AcceptedAnswerId": "42719",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T18:30:04.827",
"Id": "42332",
"Score": "7",
"Tags": [
"java",
"design-patterns",
"beginner",
"generics",
"simulation"
],
"Title": "Model simulation using Java annotatio... | 42332 |
<p>I asked <a href="https://stackoverflow.com/questions/21913273/stdbad-cast-exception-thrown-by-dynamic-cast">this</a> question on Stack Overflow and in the comments someone had this to say.</p>
<blockquote>
<p>In a proper design, you should almost never have to do a dynamic_cast, even if it's hidden inside some ni... | [] | [
{
"body": "<p>There are a number of ways you can remove the dynamic cast here. The first thing that comes to my mind in this case is the Decorator Pattern which will allow you to compose your properties classes.</p>\n\n<p>Alternatively,</p>\n\n<p>A simpler solution might be to make the <code>getComponentPropert... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T19:25:45.450",
"Id": "42335",
"Score": "5",
"Tags": [
"c++",
"inheritance",
"casting",
"polymorphism",
"c++03"
],
"Title": "Avoiding casts in abstract types"
} | 42335 |
<p>Does this look like a good method to hash a user password? I'm not very familiar with how this whole hashing process works and below is a bunch of stuff I've seen on many different posts.</p>
<p>My main concern are all of the numbers. Do they all need to match? Do they need to match something like the <code>array... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T23:07:54.353",
"Id": "72859",
"Score": "0",
"body": "Both `RNGCryptoServiceProvider` and `Rfc2898DeriveBytes` implement `IDisposable`, so you should be wrapping each of their lifetimes in `using` statements."
},
{
"ContentLi... | [
{
"body": "<p>Looks fine for the most part. The main thing here is to make sure that the function to generate and compare the hash with existing matches what you have.</p>\n\n<p>As far as <code>Array.Copy</code>, check out <a href=\"http://msdn.microsoft.com/en-us/library/system.array.copy%28v=vs.110%29.aspx\" ... | {
"AcceptedAnswerId": "42349",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T22:10:12.757",
"Id": "42342",
"Score": "2",
"Tags": [
"c#",
"hashcode"
],
"Title": "Hashing a password"
} | 42342 |
<p>I'm not sure about that if else statement in function Change(). I'm guessing there is a way to eliminate this and make better use of OOP principles. Does anyone have any suggestions? </p>
<p>PS This code is functional and produces the desired result.</p>
<pre><code>using System;
using System.Collections.Generic... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T22:41:22.260",
"Id": "72848",
"Score": "0",
"body": "Is this functional code? As in, you can run it and it works?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T22:50:24.687",
"Id": "72852",
... | [
{
"body": "<p>You can do this more elegantly by specifying a <code>Func</code> delegate instead of an enum and a set of interfaces.</p>\n\n<pre><code>class Program\n{\n static void Main(string[] args)\n {\n string message = \"mytext\";\n\n Changer chng = new Changer();\n\n string mess... | {
"AcceptedAnswerId": null,
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T22:20:24.873",
"Id": "42343",
"Score": "2",
"Tags": [
"c#",
"design-patterns",
".net"
],
"Title": "Are there any improvements I can make to my implementation of the strategy patte... | 42343 |
<p>I have several generic methods that use the <code>typeof</code> operator to determine the type of mapper class to create. Eventually this is going to get out of hand.</p>
<p>Can anyone suggest a better way to handle this? I have been reading up a bit and it seems like an abstract factory pattern or IOC would be a... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T08:41:40.317",
"Id": "72941",
"Score": "0",
"body": "The over-the-counter remedy would be visitor pattern or making each document map itself, but the real useful answer would depend on who owns what classes, for example if different... | [
{
"body": "<p>IOC vs Abstract factory is kind of an apples to oranges question. Abstract factory assumes you have a collection of related classes for which you don't want to know any of details involved in creating instances of those classes. IOC doesn't necessarily abstract you away from the creation, it jus... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T22:23:46.990",
"Id": "42344",
"Score": "5",
"Tags": [
"c#",
"factory-method"
],
"Title": "Abstract factory or inversion of control pattern?"
} | 42344 |
<p>I got a lot of good feedback on <a href="https://codereview.stackexchange.com/q/42232/29587">my other question</a>. So I will take another swing at it, post my revisions, and hopefully get some more.</p>
<p>First, the configuration hasn't changed. Here's the JSON file:</p>
<pre><code>{
"DisplaySettings": {
"... | [] | [
{
"body": "<p>I guess one minor thing is I might suggest refactoring DoAction to something like below.</p>\n\n<p>Whether that helps improve the code I guess is a matter of opinion. To me though it does appear that you can only do one action at a time so having multiple if statements does not seem plausible to ... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T22:30:06.413",
"Id": "42345",
"Score": "12",
"Tags": [
"c#",
"game",
"json",
"dependency-injection"
],
"Title": "Setting up keyboard bindings using JSON (no reflection!)"
} | 42345 |
<pre><code>str, ski = int(input("text here")), int(input("text here"))
if str < 1 or str > 50 or ski < 1 or ski > 50:
print("did not enter between 1 and 50")
</code></pre>
<p>Is there anyway to shorten the if statement in that code? I find that it is a bit too long, but I don't really know how... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T00:10:54.327",
"Id": "72880",
"Score": "1",
"body": "When asking a question, *please make an effort to choose a good title* that tells the community specifically what the point of the code in question is. I have edited the title to ... | [
{
"body": "<p>+1 <em>@instanceofTom</em> and you could remove some more duplication and create a more readable code with a named function which would tell the intent of the condition:</p>\n\n<pre><code>def is_valid_property(property):\n return 1 <= property <= 50\n\nif (not is_valid_property(strength) ... | {
"AcceptedAnswerId": "42355",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T22:34:35.240",
"Id": "42346",
"Score": "6",
"Tags": [
"python"
],
"Title": "Checking if multiple user-entered numbers are in the right range"
} | 42346 |
<p>Here is a SQLite Helper Class I created. Any input appreciated, including security and simplification.</p>
<pre><code>using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Syst... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-27T21:42:11.387",
"Id": "74134",
"Score": "1",
"body": "Please see [Can I edit my own question to include suggested changes from answers?](http://meta.codereview.stackexchange.com/a/1483/34757)"
}
] | [
{
"body": "<p>Some things that jump at me for the first look.</p>\n\n<ol>\n<li><p>Your DataType should definitely not be a String but some Enum. This makes passing invalid arguments to the function almost impossible. something like the following should do:</p>\n\n\n\n<pre class=\"lang-c# prettyprint-override\">... | {
"AcceptedAnswerId": "42947",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-20T23:58:34.717",
"Id": "42356",
"Score": "7",
"Tags": [
"c#",
"sqlite",
"helper"
],
"Title": "SQLite Helper Class in C#"
} | 42356 |
<p>For learning purposes, I made this little class which determines the <a href="http://en.wikipedia.org/wiki/Condorcet_winner" rel="nofollow noreferrer">Condorcet winner of a rank voting election</a> (basically, a Condorcet winner is a candidate that would beat every other candidate in a head-to-head election).</p>
<p... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T05:19:56.623",
"Id": "72926",
"Score": "0",
"body": "Please fix your indentation. Indentation is crucial in Python."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T08:12:45.627",
"Id": "72937",
... | [
{
"body": "<p>The purpose of your class is to perform a single computation: given <code>filename</code>, determine <code>winner</code>. That's a task for a function; there is no need for a class. You can turn each method to an independent function that takes one or two arguments and returns one or two values in... | {
"AcceptedAnswerId": "42403",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2014-02-21T00:29:22.623",
"Id": "42359",
"Score": "15",
"Tags": [
"python",
"algorithm",
"object-oriented",
"python-3.x"
],
"Title": "Condorcet voting method in OOP Python"
} | 42359 |
<p>Programming associated with creating and managing networks as well as adding network connectivity to a (set of) programs. This tag is designated for software related interfacing with networking protocols. Typically, the term is not associated with interfacing with the hardware, but basic knowledge of how the hardwar... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:19:29.783",
"Id": "42361",
"Score": "0",
"Tags": null,
"Title": null
} | 42361 |
Networking is associated with creating and managing networks as well as adding network connectivity to a (set of) programs. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:19:29.783",
"Id": "42362",
"Score": "0",
"Tags": null,
"Title": null
} | 42362 |
"Promises" are a particular tactic for deferred computing, suitable for several styles of concurrency: thread and event loop concurrency for local computation, and both synchronous and asynchronous remote messaging. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:24:38.070",
"Id": "42364",
"Score": "0",
"Tags": null,
"Title": null
} | 42364 |
<h3>A brief introduction</h3>
<p>system.reactive refers to the Reactive Extensions (Rx), a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. <strong>System.Reactive</strong> is the root namespace used through the library. Using Rx, developers <strong... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:26:35.287",
"Id": "42365",
"Score": "0",
"Tags": null,
"Title": null
} | 42365 |
System.Reactive refers to the Reactive Extensions for .NET, also known as Rx, but it more specifically refers to the use of the System.Reactive.dll assembly, which is part of Rx. System.Reactive provides developers with a reactive programming model, as opposed to the traditional imperative programming model. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:26:35.287",
"Id": "42366",
"Score": "0",
"Tags": null,
"Title": null
} | 42366 |
Hashcode is a result of applying a hash function to data, usually an integer. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:28:18.317",
"Id": "42368",
"Score": "0",
"Tags": null,
"Title": null
} | 42368 |
<p>The Roman numeral system is an ancient way of representing numbers. The symbols are I, IV, V, IX, X, XL, L, XC, C, CD, D, CM, and M. These symbols are valued as follows:</p>
<blockquote>
<p>I = 1<br>
IV = 4<br>
V = 5<br>
IX = 9<br>
X = 10<br>
XL = 40<br>
L = 50<br>
XC = 90<br>
C = 100<br>
CD =... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:29:18.820",
"Id": "42369",
"Score": "0",
"Tags": null,
"Title": null
} | 42369 |
The Roman numeral system is an ancient way of representing numbers. The symbols are I, V, X, L, C, D and M. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:29:18.820",
"Id": "42370",
"Score": "0",
"Tags": null,
"Title": null
} | 42370 |
<p>Windows Phone is a mobile operating system developed by Microsoft, and is the successor to its Windows Mobile platform. </p>
<h3>Development Platforms</h3>
<ul>
<li><strong>Windows Phone 7.0 (deprecated)</strong>: <a href="http://stackoverflow.com/questions/tagged/silverlight">Silverlight</a> and <a href="http://... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:29:53.937",
"Id": "42371",
"Score": "0",
"Tags": null,
"Title": null
} | 42371 |
Windows Phone is Microsoft's mobile operating system and software development platform. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:29:53.937",
"Id": "42372",
"Score": "0",
"Tags": null,
"Title": null
} | 42372 |
<p>Mobile development refers to the process of programming specifically for hand-held devices, such as cell phones and PDAs.</p>
<p>Mobile computing is human–computer interaction by which a computer is expected to be transported during normal usage. Mobile computing involves mobile communication, mobile hardware, and ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:30:44.770",
"Id": "42373",
"Score": "0",
"Tags": null,
"Title": null
} | 42373 |
<p>Initially ported from <a href="http://www.junit.org/" rel="nofollow">JUnit</a>, the current production release, version 2.6, is the seventh major release of this xUnit based unit testing tool for Microsoft .NET. It is written entirely in C# and has been completely redesigned to take advantage of many .NET language f... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:31:38.023",
"Id": "42375",
"Score": "0",
"Tags": null,
"Title": null
} | 42375 |
NUnit is an open source unit testing framework for Microsoft .NET and Silverlight written in C#. It serves the same purpose as JUnit does in the Java world, and is one of many in the xUnit family. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:31:38.023",
"Id": "42376",
"Score": "0",
"Tags": null,
"Title": null
} | 42376 |
<p>Clients are generally classified as either "fat clients", "thin clients", or "hybrid clients".</p>
<p><strong>Fat</strong></p>
<p>A <a href="http://en.wikipedia.org/wiki/Fat_client" rel="nofollow">fat client</a>, also known as a rich client or thick client, is a client that performs the bulk of any data processing... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:33:43.437",
"Id": "42377",
"Score": "0",
"Tags": null,
"Title": null
} | 42377 |
A client is an application or system that accesses a service made available by a server. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:33:43.437",
"Id": "42378",
"Score": "0",
"Tags": null,
"Title": null
} | 42378 |
<p>The AWT is now part of the Java Foundation Classes (JFC) — the standard API for providing a graphical user interface (GUI) for a Java program.</p>
<p>AWT is also the GUI toolkit for a number of Java ME profiles. For example, Connected Device Configuration profiles require Java runtimes on mobile telephones to suppo... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:34:15.143",
"Id": "42379",
"Score": "0",
"Tags": null,
"Title": null
} | 42379 |
The Abstract Window Toolkit (AWT) is Java's original platform-independent windowing, graphics, and user-interface widget toolkit. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:34:15.143",
"Id": "42380",
"Score": "0",
"Tags": null,
"Title": null
} | 42380 |
<p>I have an application that allows the user to place a string of text into a PDF document. I have three different ways that they can do this:</p>
<ol>
<li><strong>Use a Form Field.</strong> Then they have four properties to define:
<ol>
<li>Provide field name</li>
<li>provide instance of the field</li>
<li>provide ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T03:22:40.117",
"Id": "72898",
"Score": "0",
"body": "Is `Placement` a subclass of something like `Form` or is it just a class? Do those properties need to be available to an [IDE designer](http://msdn.microsoft.com/en-us/library/h51... | [
{
"body": "<p>not very sure about your placement class, whether it's a pure class designed to encapsulate options, or a win-form. </p>\n\n<p>If it's the former, i would suggest you use Polymorphism to have certain abstract layer, a quick sample:</p>\n\n<p>At your side: </p>\n\n<pre><code>public abstract class P... | {
"AcceptedAnswerId": "42386",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T01:52:04.117",
"Id": "42382",
"Score": "6",
"Tags": [
"c#",
"classes"
],
"Title": "How can I layout this class to make it easier to use for API developers?"
} | 42382 |
<p>I am currently working on a problem of an online judge (not a contest). The program must calculate how many years will require for the population A (which is always less than B) to be higher than B. If the time is more than a Century then print "More than a century" in Portuguese.<br>
Input</p>
<pre><code>1
90000 1... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T03:44:07.107",
"Id": "72907",
"Score": "0",
"body": "What exactly is the program supposed to do?"
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T03:53:19.437",
"Id": "72908",
"Score": "0",
... | [
{
"body": "<p>First, the syntax error:</p>\n\n<pre><code> String [] = arr = tL.split(\" \");\n</code></pre>\n\n<p>You probably meant</p>\n\n<pre><code> String[] arr = tL.split(\" \");\n</code></pre>\n\n<p>Now, let's make all of your variable names readable. Longer names take the same amount of tim... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T03:39:14.397",
"Id": "42385",
"Score": "5",
"Tags": [
"java",
"optimization"
],
"Title": "How to optimize population projections for speed?"
} | 42385 |
<p>I have my program working. I just need to redo it a little bit, and it could use some improvements.</p>
<p>I got different % rates depending on what the income and status is.</p>
<pre><code>#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <cstdio>
//functions called
floa... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T08:04:43.917",
"Id": "72936",
"Score": "1",
"body": "This is some sort of school project I guess? A couple of questions: 1. Have you learned about `struct`? 2. Have you learned about passing pointers to functions? (Example: `void so... | [
{
"body": "<h1>Things you did well:</h1>\n\n<ul>\n<li><p>You used the function <a href=\"http://en.cppreference.com/w/c/io/gets\" rel=\"nofollow noreferrer\"><code>gets_s</code></a>, which is an <a href=\"https://en.wikipedia.org/wiki/C11_%28C_standard_revision%29\" rel=\"nofollow noreferrer\">optional C11</a> ... | {
"AcceptedAnswerId": "42388",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T03:53:03.893",
"Id": "42387",
"Score": "11",
"Tags": [
"c"
],
"Title": "Total income program"
} | 42387 |
<pre><code>#include <iostream>
#include <fstream>
#include <algorithm>
#include <thread>
#include <cmath>
#include <sstream>
#include <cstdlib>
using namespace std;
ostream* outfile = &cout;
bool testCantor(unsigned long long p, unsigned long long q){
while(q % 3 == ... | [] | [
{
"body": "<p>It's probably not going to speed it up a huge amount, but you are doing un-necessary dynamic allocations for <code>thread</code> and <code>string</code> (and leaking memory in the process, as these are never <code>delete</code>d).</p>\n\n<pre><code>void genRational(unsigned long long minNum, unsig... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T05:47:22.533",
"Id": "42394",
"Score": "3",
"Tags": [
"c++",
"optimization",
"mathematics"
],
"Title": "Filtering function"
} | 42394 |
<p>In my game, I need to detect whether any buttons/keys are pressed at all before I try to process any input. This is easy enough for keys since the XNA library provides a <code>GetPressedKeys</code> method on the <code>KeyboardState</code> class:</p>
<pre><code>private void ProcessKeyboard()
{
keyboardState = Ke... | [] | [
{
"body": "<p>Rather than using an array to return you should use a <code>List<T></code> which can be easily appended to:</p>\n\n<pre><code>public static List<Buttons> GetPressedButtons( this GamePadState gamePadState )\n{\n var pressedButtons = List<Buttons>();\n\n foreach ( Buttons but... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T06:03:05.643",
"Id": "42395",
"Score": "4",
"Tags": [
"c#",
"game",
"extension-methods",
"event-handling"
],
"Title": "Get array of pressed buttons using extension method"
} | 42395 |
<blockquote>
<p>Given a source and destination, in an integer matrix, find path, such
that the next position in the path has a greater than or equal to
value than the previous position. In other words monotonically
increasing. In event of multiple paths, a non-optimal solution may be
returned.</p>
</blockquot... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T10:20:39.603",
"Id": "72943",
"Score": "4",
"body": "You've indicated that you are preparing for interviews, and indeed we've seen your coding skills improve over the last 88 questions. I think that if you try answering some other u... | [
{
"body": "<p>Just two quick notes:</p>\n\n<ol>\n<li><p>It's usually a good practice to make a copy of mutable input parameters. (<code>int[][] m</code> array in this case.) It prohibits malicious clients to modify the internal structure of the class or it could save you from a few hours of debugging. (<em>Effe... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T06:41:23.887",
"Id": "42396",
"Score": "3",
"Tags": [
"java",
"matrix"
],
"Title": "Path from source to destination, with increasing values"
} | 42396 |
<p>This is my first major PHP project and I haven't gotten much feedback. I wanted to learn how to use PHP and I wanted to learn about Minecraft's status protocol, so I did what was obvious at the time.</p>
<h1>File listing</h1>
<p>The code is also <a href="https://github.com/winny-/mcstat" rel="nofollow noreferrer"... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2015-07-03T11:32:05.537",
"Id": "174622",
"Score": "1",
"body": "Looks fairly concise, I would maybe `FILTER` your `GETs` though using PHP's `filter_input` function `$foo = filter_input(INPUT_GET, 'foo', FILTER_SANITIZE_SPECIAL_CHARS);`"
},
... | [
{
"body": "<h2>Foreword</h2>\n\n<p>Bearing in mind that this post was created more than 4 years ago, you likely have changed the code and learned more about PHP features - perhaps you don't even use/maintain this code anymore. I honestly have never played Minecraft, nor had any reason to monitor server statuses... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2014-02-21T10:25:12.670",
"Id": "42405",
"Score": "7",
"Tags": [
"php",
"networking",
"minecraft"
],
"Title": "Minecraft query tools"
} | 42405 |
<p>I came across this snippet and am wondering if I should return blank in this case.</p>
<p>Which is more practical to return: <code>blank</code> or <code>null</code>?</p>
<pre><code>public String getInfo() {
String result = "";
String uri = clientConfiguration.getUri();
String regex = "http://(.*)/conso... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T10:33:15.097",
"Id": "72946",
"Score": "7",
"body": "It is entirely dependent on the context (ie, callers); what is more, your regex is seriously flawed. Hint: use the `URI` class to parse URIs in general (and this includes URLs)"
... | [
{
"body": "<p>I agree with <code>fge</code>, it depends on the context. A third approach: it might be better to throw an exception in that case.</p>\n\n<p>Another note: you don't need to declare the <code>result</code> variable at the beginning of the method, declare on the first use. Actually, you could comple... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T10:28:07.527",
"Id": "42406",
"Score": "2",
"Tags": [
"java",
"null"
],
"Title": "Which Java string value is preferred to return: blank or null?"
} | 42406 |
<p>Based on this <a href="https://stackoverflow.com/questions/11187582/javascript-sandbox-pattern-example-implementation">Stack Overflow</a> question I came up with the following code. I'd like your general thoughts about it. Code style, functional, logical, disadvantages, just anything you can come up based on the co... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T10:53:30.103",
"Id": "72950",
"Score": "0",
"body": "In `box.loadScript` you can reduce to `var urls = [].concat(options.url||options.urls||[])` and you save the line below."
},
{
"ContentLicense": "CC BY-SA 3.0",
"Creat... | [
{
"body": "<p>From a reverse once over:</p>\n\n<ul>\n<li><code>$(this).attr('id')</code> -> could be <code>this.id</code></li>\n<li>The <code>click</code> handler should not have to know where the path is of the js file</li>\n<li>The <code>click</code> handler should not have to deal with the failure of loading... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T10:31:29.013",
"Id": "42407",
"Score": "6",
"Tags": [
"javascript",
"optimization",
"design-patterns",
"sandbox"
],
"Title": "JavaScript Sandbox Pattern"
} | 42407 |
<p>LCA = <a href="http://en.wikipedia.org/wiki/Lowest_common_ancestor" rel="nofollow">Lowest Common Ancestor</a></p>
<p>The following code finds the lowest common ancestor in tree of nodes, where a node can have two parents, left and right.</p>
<p>The tree looks like this:</p>
<pre><code> J-K
/ \
E-F-G-H-... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T12:36:31.830",
"Id": "72956",
"Score": "2",
"body": "You use the words *\"finds the lowest common ancestor in tree of nodes\"* but the picture you draw is not a tree, and nowhere in your code do you have a 'root'... your 'find' meth... | [
{
"body": "<p><strong>Naming</strong> - the method <code>find(Node, TreeSet<Node>)</code> implies it will find the <code>Node</code> inside the <code>TreeSet</code>, which, of course it doesn't - a better name might be <code>buildNodeParents</code> or something like that.</p>\n\n<p>Also, your <code>Node</... | {
"AcceptedAnswerId": "42410",
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T10:41:15.963",
"Id": "42408",
"Score": "1",
"Tags": [
"java",
"optimization",
"algorithm",
"recursion",
"tree"
],
"Title": "Lowest common ancestor in recursive tree tra... | 42408 |
<p>A day ago I have asked a question on here about <a href="https://codereview.stackexchange.com/questions/42313/preventing-email-injection/42329?noredirect=1#42329">Preventing email injection</a>. I had some feedback and worked on it, and below is the latest update.</p>
<p>Could anyone please share their opinion? Is... | [] | [
{
"body": "<ul>\n<li>Due to the nested and long conditions the code becomes hard to follow\nat some points. Early returns prevent nesting of conditions.</li>\n<li>Some code is duplicate (step 9)</li>\n<li>Possibly some values could be overwritten by url-forging (depending on the server-configuration). (step 5)<... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T11:45:35.020",
"Id": "42411",
"Score": "3",
"Tags": [
"php",
"security",
"email"
],
"Title": "Preventing email injection - Part 2"
} | 42411 |
<p>The following code is intended to implement a <a href="https://www.nuget.org/packages/LinFu.DynamicProxy.OfficialRelease/">LinFu DynamicProxy interceptor</a> to lazy load given virtual properties from an Umbraco datastore.</p>
<p>My concerns:</p>
<ol>
<li>Thread safety, Have I covered all the bases, Am I storing v... | [] | [
{
"body": "<p>I'm not familiar with Umbraco, and I could not find any documentation on LinFu, I do, however, have some remarks on your code:</p>\n\n<p><strong>Comments</strong> - your code is more than 40% comments, and un-useful comments at that - a comment that tells me that <code>id</code> is <code>/// The i... | {
"AcceptedAnswerId": "42456",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T12:47:32.033",
"Id": "42413",
"Score": "5",
"Tags": [
"c#",
"thread-safety"
],
"Title": "Am I using Lazy initialization properly?"
} | 42413 |
<p>I'm running into a problem with my code in a ASP.NET MVC application. Maybe it's not a problem and I'm just being paranoid, but it seems like a problem to me (might be because I've just read the book <em>Clean Code</em>).</p>
<p>I am using the repository-pattern with the unit of work-pattern to abstract the data ac... | [] | [
{
"body": "<p>Yes, #3 is the one - this is exactly what Dependency Injection/Inversion of Control containers are meant for - removing the assembly part of the services from the main code.</p>\n\n<p>Using an external DI framework will also give you additional benefits, such as stubbing out services while unit te... | {
"AcceptedAnswerId": "42426",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T14:29:16.580",
"Id": "42419",
"Score": "2",
"Tags": [
"c#",
"design-patterns",
"dependency-injection",
"asp.net-mvc"
],
"Title": "How to declutter dependencies?"
} | 42419 |
<p>I've been doing a lot of Project Euler lately and just wanted to make sure my implementation was as good as it could be. Does anyone have any suggestions to speed this up?</p>
<pre><code>def sieve(upperlimit):
# mark off all multiples of 2 so we can use 2*p as the step for the inner loop
l = [2] + [x if x %... | [] | [
{
"body": "<p>You have correctly implemented the optimization <code>p ** 2 > upperlimit</code>, but, there is a more efficient way to do it...</p>\n\n<p><code>p ** 2 > upperlimit</code> calculates the square of <code>p</code> for every iteration through the loop. The product is not hugely expensive, but i... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T14:41:59.543",
"Id": "42420",
"Score": "28",
"Tags": [
"python",
"performance",
"primes",
"python-3.x",
"sieve-of-eratosthenes"
],
"Title": "Sieve of Eratosthenes - Python... | 42420 |
<p>This is a bidirectional map implementation that stores the values as <em>pairs on the heap</em>, and uses pointer arithmetic for efficient lookup.</p>
<p><a href="http://codepad.org/a6ozZQxd" rel="nofollow">codepad link, may be easier to read</a></p>
<pre><code>#include <iostream>
#include <set>
#inclu... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2018-04-26T21:39:12.590",
"Id": "370877",
"Score": "0",
"body": "Can you please separate the test and non-test code into different segments (with separate include's), for easier copy-and-paste? Also, do you have a version of this on GitHub?"
... | [
{
"body": "<p>Here you assert that the type is standard layout (for use of <code>offsetof</code>)</p>\n\n<pre><code> inline const char* getPairBasePtr(const T2* mItem) const noexcept\n {\n static_assert(std::is_standard_layout<BMPair>::value, \"BMPair must have standard layout\");\n re... | {
"AcceptedAnswerId": "42440",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T15:37:02.497",
"Id": "42427",
"Score": "4",
"Tags": [
"c++",
"c++11",
"collections",
"pointers",
"hash-map"
],
"Title": "Bidirectional map based on memory manipulation"... | 42427 |
<p>I'd like to see how to improve this code. I have a UITableView that I'm 'hiding' a section when the user taps on that section's header. I thought this was a pretty cool implementation I came up with, but it turns out when this section is hidden and the user pulls to refresh, about 1-2MB is added into memory every ti... | [] | [
{
"body": "<p>The memory leak is more on topic for StackOverflow, but while this question is here and open, I'll make some comments on the stuff that's on topic...</p>\n\n<p>Your <code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section</code> method really, really bothers m... | {
"AcceptedAnswerId": "42479",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T16:05:02.267",
"Id": "42429",
"Score": "2",
"Tags": [
"objective-c",
"ios"
],
"Title": "UITableView 'hidden' section causing more memory allocations every time on pull to refresh"
... | 42429 |
<p>The primary goal of this code is to convert a PDF file to images. I also create a directory under <code>C:/Media</code> based on a combination of the PDF name and current date and insert the uploaded PDF to the same directory as the images for safe keeping. </p>
<p>I am primarily concerned that I am over-complicati... | [] | [
{
"body": "<p>I see that you're using Java 7, you could use the try-with-resource for all you're IO operation. It will close the stream you're using in your application. </p>\n\n<pre><code> try{\n File newFile = new File(\"C:\\\\Media\\\\\" + directory + \"\\\\\" + filename);\n\n inStream ... | {
"AcceptedAnswerId": "42444",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T16:18:07.240",
"Id": "42431",
"Score": "6",
"Tags": [
"java",
"image",
"pdf"
],
"Title": "Ghost4J PDF to image conversion"
} | 42431 |
<p>I was tasked at work to improve a system where through a web interface a client, which eventually became us, uploads a bunch of images with descriptions (latter coming from csv files), the images are then automatically resized yada yada for the site. </p>
<p>Nowt wrong with the latter, but the upload and image desc... | [] | [
{
"body": "<p>Your code is so full of irrelevant content that distracts from the purpose of the code.</p>\n\n<p>The most <em>Beautiful</em> shell scripts are the ones that do a job, and do it well. They do it in a standard way with the least surprise. They accept input from pipes, redirects, and files, and they... | {
"AcceptedAnswerId": "42471",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T16:24:54.923",
"Id": "42432",
"Score": "9",
"Tags": [
"php",
"bash",
"linux",
"console",
"awk"
],
"Title": "Bash script - automate an upload image + description process... | 42432 |
<p>I would really appreciate some good advice on how to refactor a small app:</p>
<p>It basically reads a CSV (energy/heat values?), computes some stuff, and then prepares some data which should later be sent to GNUplot.</p>
<p>For example, I'm unsure about this:</p>
<p><strong>Is it good practice to send variables ... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T16:34:45.853",
"Id": "73009",
"Score": "2",
"body": "Please edit the question so that the code to be reviewed is embedded in the text of the question (otherwise it can't be answered); see [Can I put my code on a third party site and... | [
{
"body": "<p>I've seen much worse C code. For the most part I think your code is reasonably well organized and your approach of manipulating data via pointers into functions is standard C practice when dealing with large data structures. </p>\n\n<p>C is not OO and you can only go so far before you re-invent C+... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T16:28:42.250",
"Id": "42433",
"Score": "6",
"Tags": [
"c",
"csv"
],
"Title": "Read CSV, compute some stuff and prepare data to be sent to GNUPlot"
} | 42433 |
<p>I have a <code>MouseInputHandler</code> class that registers itself to an <code>InputManager</code>. When the InputManager class receives events they are forwarded to MouseInputHandler which changes its state to reflect the state of the mouse. A mouse as an input device provides a large number of different propertie... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T19:13:52.040",
"Id": "73074",
"Score": "0",
"body": "I went with the struct + accessor method approach as suggested by ChrisW. Placing the variables separately did not come to my mind for some reason."
},
{
"ContentLicense":... | [
{
"body": "<p>You could represent the mouse state using a struct:</p>\n\n<pre><code>struct MouseSettings\n{\n Signal btnLeft_, btnMiddle_, btnRight_, btnX1_, btnX2_;\n int32_t absX_, absY_, relX_, relY_, scrollX_, scrollY_;\n}\n\nclass MouseInputHandler : public InputHandler\n{\npublic:\n MouseInputHan... | {
"AcceptedAnswerId": "42451",
"CommentCount": "6",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2014-02-21T18:13:28.153",
"Id": "42447",
"Score": "6",
"Tags": [
"c++",
"object-oriented",
"c++11",
"event-handling",
"sdl"
],
"Title": "Mouse input handler which exposes read-onl... | 42447 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.