Dataset Viewer
Auto-converted to Parquet Duplicate
body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>I am playing with different ways to do database interaction in PHP, and one of the ideas I have been playing with is connecting to the DB in the constructor and disconnecting in the destructor. This is the code from my <code>Database</code> class.</p> <pre><code>function __construct() { $this-&gt;link = mysql_con...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2020-11-18T07:49:12.973", "Id": "496986", "Score": "0", "body": "Look at the URL number. This is the first question humanity ever asked here!" } ]
[ { "body": "<p>You could use MySQLi (PHP extension) which is class based by default instead of MySQL. It \nis very easy to set up multiple connections. You are, however, required to know the connection you are querying always.</p>\n\n<hr>\n\n<p>Congrats with the first question.</p>\n", "comments": [], "m...
{ "AcceptedAnswerId": "5", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-19T21:02:47.183", "Id": "1", "Score": "39", "Tags": [ "php", "mysql", "constructor" ], "Title": "Database connection in constructor and destructor" }
1
<p>I'd like suggestions for optimizing this brute force solution to <a href="http://projecteuler.net/index.php?section=problems&amp;id=1">problem 1</a>. The algorithm currently checks every integer between 3 and 1000. I'd like to cut as many unnecessary calls to <code>isMultiple</code> as possible:</p> <pre><code>''...
[ { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-19T21:06:48.893", "Id": "3", "Score": "1", "body": "Are you trying to optimize the algorithm or the code itself?" }, { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-19T21:07:15.663", "Id": "5", "Score":...
[ { "body": "<p>I think the best way to cut out possible checks is something like this:</p>\n\n<pre><code>valid = set([])\n\nfor i in range(3, end, 3):\n valid.add(i)\n\nfor i in range(5, end, 5):\n valid.add(i)\n\ntotal = sum(valid)\n</code></pre>\n\n<p>There's still a bit of redundancy (numbers which are mult...
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-19T21:04:27.573", "Id": "2", "Score": "56", "Tags": [ "python", "optimization", "algorithm", "programming-challenge" ], "Title": "Project Euler problem 1 in Python - Multiples of...
2
<p>Basically, I had written this class a little while ago to ease autoloading of our local libraries. </p> <p>The premise is that everything is split by packages into multiple layers of sub-packages. Classes are named using CamelCasing. So, a class' name is related to its package as follows: <code>PackageSubpackageS...
[]
[ { "body": "<p>The first problem I see is that there are a lot of cases where someone will want to create a class with more than one word in the name (DataMapper), and the autoloader you have provided won't allow for that. I would recommend using another character to delimit between package names. The Zend Fra...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-19T21:07:43.573", "Id": "4", "Score": "27", "Tags": [ "php", "library" ], "Title": "PHP Autoloader Library" }
4
<p>I started programming with Java and C++, so I'm used to having a 'main' function that calls other functions that do the actual work. At university I was always told that doing actual computation in the main function is bad practice. I'm currently playing around with Python, and I have trouble figuring out how to wri...
[]
[ { "body": "<p>In most of the Python code I've ever seen, there is normally a main function defined that you call from the condition you put to establish the script was executed and not imported. I believe that's the standard way of doing things in Python, but I don't believe its actually a written rule anywher...
{ "AcceptedAnswerId": "8", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-19T21:16:08.443", "Id": "7", "Score": "60", "Tags": [ "python", "programming-challenge" ], "Title": "Using separate functions for Project Euler 1" }
7
<p>I have a method that has a lot of loops:</p> <pre><code>private void update(double depth) { Console.WriteLine("update with level " + depth); this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { List&lt;Grid...
[ { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-19T21:26:50.047", "Id": "29", "Score": "17", "body": "tl;dr. You'll likely have a better response if you remove a lot of the boilerplate or focus on the part you're really interested in. I think pseudo-code would help a lot here." ...
[ { "body": "<p>Break this down into several methods - it's very long, meaning it's not easy to read.</p>\n", "comments": [ { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-20T00:28:01.803", "Id": "67", "Score": "1", "body": "Actually it is even longer...
{ "AcceptedAnswerId": "13", "CommentCount": "4", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-19T21:19:59.470", "Id": "9", "Score": "34", "Tags": [ "c#", "performance", "algorithm" ], "Title": "Too many loops in Drawing App" }
9
<p>I use <a href="https://codeigniter.com/" rel="nofollow noreferrer">CodeIgniter</a> at work, and one of our model files had a lot of subqueries in it. I originally had to manually write each subquery, and wondered if I could use active records instead.</p> <p>So, to make my life easier, I made a subquery library for...
[ { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-19T21:50:27.920", "Id": "42", "Score": "1", "body": "Why is $db an array?" }, { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-19T21:55:41.490", "Id": "46", "Score": "0", "body": "@Time Machine: `$db...
[ { "body": "<p>I may be missing something here,\nBut to me it seems that you have a class that you pass a pre-built query into?</p>\n\n<p>I am thinking would it not be beneficial to have a subquery built the same way as the top level queries?</p>\n", "comments": [ { "ContentLicense": "CC BY-SA ...
{ "AcceptedAnswerId": "277", "CommentCount": "10", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2011-01-19T21:24:11.093", "Id": "12", "Score": "29", "Tags": [ "php", "mysql", "codeigniter" ], "Title": "CodeIgniter Active Record Subqueries" }
12
<p>So I've had a problem where I need to compare data in 2 different tables on two different servers. Now, I know MySQL supports <code>CHECKSUM TABLES</code>, but from my testing and understanding, it's not reliable across server instances and versions. </p> <p>So I created this query:</p> <pre><code>$part = '@CRC ...
[ { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-19T21:37:10.357", "Id": "35", "Score": "1", "body": "It may be overkill for your problem but have you looked at MYSQL clusters to handle mirroring and distributing of data. It would offer other features that may be useful." }, { ...
[ { "body": "<p>We use <a href=\"http://www.maatkit.org/doc/mk-table-checksum.html\"><code>mk-table-checksum</code></a>. </p>\n\n<p>It works really great in Master-Slave context where it also allows to sync differences in both directions depending on your choice.</p>\n\n<p>Saidly from what i've seen most people i...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-19T21:28:43.283", "Id": "16", "Score": "9", "Tags": [ "php", "mysql", "sql" ], "Title": "Comparing data in 2 tables on different servers with CHECKSUM" }
16
<p>A while back, I reverse-engineered a checksum algorithm from an <a href="http://en.wikipedia.org/wiki/Massively_multiplayer_online_game" rel="noreferrer">MMO</a> used to check the validity of an item that's linked to chat (similar to <a href="http://en.wikipedia.org/wiki/World_of_Warcraft" rel="noreferrer"><em>WoW</...
[]
[ { "body": "<p>The only things I can see having problems are your acronym variable names i.e. (eax, ecx, ebx, and edi) don't explain what the variables are storing clearly for someone not experienced with doing checksums.</p>\n\n<p>The other thing I can see for readability issues is your all lowercase variable n...
{ "AcceptedAnswerId": "30", "CommentCount": "0", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-19T22:02:29.033", "Id": "22", "Score": "20", "Tags": [ "c++", "checksum" ], "Title": "Custom checksum algorithm" }
22
<p>I'm generating CSV strings for various 3rd party utilities and this section of code gets repeated in many classes. Is there a better way to generate this string?</p> <pre><code>public override string CsvString() { return ( string.Format("\u0022{0}\u0022,\u0022{1}\u0022,\u0022{2}\u0022,\u0022{3}\u0022,\u...
[ { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-19T23:02:53.407", "Id": "56", "Score": "0", "body": "I would use a StringBuilder if this was for Java. There might be a C# equivalent?" }, { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-19T23:37:37.547", "...
[ { "body": "<p>Use a <code>StringBuilder</code>:</p>\n\n<pre><code>sbuilder.AppendFormat(\"\\u0022{0}\\u0022,\\u0022{1}\\u0022,\\u0022{2}\\u0022,\\u0022{3}\\u0022,\\u0022{4}\\u0022,\\u0022{5}\\u0022,\\u0022{6}\\u0022,\\u0022{7}\\u0022,\\u0022{8}\\u0022,\\u0022{9}\\u0022,\\u0022{10}\\u0022,\\u0022{11}\\u0022,\\u0...
{ "AcceptedAnswerId": "74", "CommentCount": "2", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-19T22:56:59.883", "Id": "36", "Score": "23", "Tags": [ "c#", "csv", "strings" ], "Title": "Generating CSV strings for various 3rd party utilities" }
36
<p>A few functions to let me manage TAGS files more easily. Typically, my projects contain at least one sub-folder. I got sick of manually updating, so I wrote this to help me update a single TAGS file per project (always in the projects' root directory).</p> <p>Please share your thoughts (aside from "Why are you usin...
[]
[ { "body": "<h3>General notes</h3>\n\n<ul>\n<li>Always prefix your functions with the name of your package or project, e.g. <code>tagariffic-create-tag-table</code> and so on. Emacs has no package scoping.</li>\n<li>Whenever possible (i.e. in the absence of mutual recursion), define your functions before using t...
{ "AcceptedAnswerId": "3633", "CommentCount": "0", "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-20T00:10:13.883", "Id": "45", "Score": "16", "Tags": [ "elisp" ], "Title": "Emacs Etags Shortcut Functions" }
45
<p>This shows a test case for an old caching library that I use for a project. It features simple save/load/delete functions (sadly static calls) but what I want to focus on is the test code written for this class.</p> <p>In my opinion the unit tests for a class should show how all functions in the class work and what...
[ { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-20T19:19:00.860", "Id": "162", "Score": "0", "body": "This looks like the long-code-questions version of Stack Overflow" } ]
[ { "body": "<p>I lack the syntax knowledge to say I understand the class. I can say reading it is a bit hard due to long lines and the fact that the dominant patterns are repetitive method/variable names. Test names are descriptive enough </p>\n\n<p>Maybe if you could extract methods like <code>DatenCache::load<...
{ "AcceptedAnswerId": "62", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-20T00:42:35.173", "Id": "47", "Score": "12", "Tags": [ "php", "unit-testing", "cache" ], "Title": "Test case for a caching library" }
47
<p>I am currently developing a custom CMS being built on top of Codeigniter and was wondering if you can spot any flaws in my page fetching model code. The page fetching model is not entirely complete but the main functionality for retrieving a page is done, as well as retrieving modules assigned to a page (a module is...
[]
[ { "body": "<p>I don't know Codeigniter so i can't comment on \"is this a propper model\". For my answer i'm just going to assume it is.</p>\n\n<p>It's not much code so i'm going to focus on some details: </p>\n\n<hr>\n\n<pre><code> public function __construct()\n {\n parent::__construct();\n }\n</code><...
{ "AcceptedAnswerId": "289", "CommentCount": "0", "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-20T00:51:36.533", "Id": "48", "Score": "7", "Tags": [ "php", "codeigniter", "mvc" ], "Title": "Critique My Codeigniter Custom CMS Pages Model" }
48
<p>Here's my <code>bootstrap.php</code> for my PHP/MySQL/Doctrine app. It's my first PHP app so I'm interested in learning from the experience of others how this could be improved - security-wise, performance-wise, or otherwise.</p> <pre><code>//------------------------------------------------------------------------...
[ { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-20T01:30:57.793", "Id": "73", "Score": "0", "body": "How different is this from the default template? Can you link to it?" }, { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-20T03:30:06.800", "Id": "80", ...
[ { "body": "<p>Here are a few lines that might be useful to add if you would like to use these options:</p>\n\n<pre><code>/**\n * Needed for SoftDelete to work\n */\n$manager-&gt;setAttribute(Doctrine::ATTR_USE_DQL_CALLBACKS, true);\n\n/**\n * Tell doctrine to look for custom ___Table classes in the models folde...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-20T00:52:25.113", "Id": "49", "Score": "6", "Tags": [ "php", "mysql", "doctrine" ], "Title": "PHP/Doctrine bootstrap for review" }
49
<p>I'm making a "guess that tune" game in Visual Basic 6 that is supposed to play each song in a random order:</p> <pre><code>' from frmGuessGame.frm Private Sub Swap(ByRef Value1 As Variant, ByRef Value2 As Variant) Dim Temporary As Variant Temporary = Value1 Value1 = Value2 Value2 = Temporary End Sub Private Sub Sh...
[ { "ContentLicense": "CC BY-SA 2.5", "CreationDate": "2011-01-20T00:55:48.870", "Id": "70", "Score": "0", "body": "Aside: [My question from the proposal](http://area51.stackexchange.com/proposals/11464/code-review/25308#25308). I actually wrote this code years ago (2004) before I knew any better....
[ { "body": "<p>I would probably do something like this:</p>\n\n<p>I don't know VB so this is pseudo code.</p>\n\n<pre><code>Private Function Shuffle(playlist) as Playlist\n{\n Dim PlayList as NewPlayList\n Dim RandomIndex as Integer\n\n while(playlist has elements)\n {\n RandomIndex = (Random n...
{ "AcceptedAnswerId": "98", "CommentCount": "1", "ContentLicense": "CC BY-SA 3.0", "CreationDate": "2011-01-20T00:54:38.853", "Id": "50", "Score": "19", "Tags": [ "algorithm", "vb6", "random", "shuffle" ], "Title": "Shuffling algorithm for a \"guess that tune\" game" }
50
End of preview. Expand in Data Studio

Dataset Card for "base_code_review"

More Information needed

Downloads last month
22