body stringlengths 111 6.48k | 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->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&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>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 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>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->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 |
<p>I've implemented a PID controller, but seeing as I'm not an expert in control theory, have I missed any edge cases?</p>
<pre><code>public class PIDController
{
public enum PIDMode
{
Manual,
Auto,
}
public enum PIDAction
{
Indirect,
Direct,
}
public PIDMo... | [] | [
{
"body": "<p>It looks reasonable, but I don't see why you need to make the Proportional term a member of the class, it doesn't need to be saved, at best it might make sense to be able to query it with a get, but a set seems misleading.</p>\n\n<p>I'd be reluctant to allow public setting of the Integral and Deri... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-01-20T06:31:36.730",
"Id": "72",
"Score": "13",
"Tags": [
"algorithm",
"c#"
],
"Title": "Implementation of a PID Controller"
} | 72 |
<p>Is this the best way to implement this pattern in C#?</p>
<pre><code>public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
public static Singleton Instance { get { return instance; } }
static Singleton() {}
private Singleton() {}
}
</code></pre>
| [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-05-07T02:53:33.217",
"Id": "18504",
"Score": "8",
"body": "[Singleton is an antipattern](http://thetechcandy.wordpress.com/2009/12/02/singletons-is-anti-pattern/)."
},
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2012-... | [
{
"body": "<p>I always use this solution if I have to implement a Singleton in C#</p>\n\n<pre><code>public sealed class Logging\n {\n static Logging instance = null;\n static readonly object lockObj = new object();\n\n private Logging()\n {\n }\n\n public static Logg... | {
"AcceptedAnswerId": "81",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-01-20T10:02:03.633",
"Id": "79",
"Score": "67",
"Tags": [
"c#",
"singleton"
],
"Title": "Implementing a Singleton pattern in C#"
} | 79 |
<p>I'm listing elements with a <code>foreach</code>, and I would like to enclose items in something tag <code>n</code> by <code>n</code>:</p>
<pre><code>$i = 0;
$open = $done = TRUE;
$n = 3;
$opening = "<div>";
$closing = "</div>";
$names = array("Doc", "Marty", "George", "Lorraine", "Einstein", "Biff");
... | [
{
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-20T11:03:10.900",
"Id": "104",
"Score": "1",
"body": "@albert can you also add what n and the condition is suppose to represent? Does it get it's value from another part of the code?"
},
{
"ContentLicense": "CC BY-SA 2.5",
... | [
{
"body": "<p>One problem with your solution is that it won't print the last closing <code></div></code> tag if there are less than <code>$n</code> elements inside the last <code><div></code>.</p>\n\n<p>An approach which fixes that problem and also simplifies the conditional logic for deciding when ... | {
"AcceptedAnswerId": "90",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-01-20T10:25:28.040",
"Id": "82",
"Score": "7",
"Tags": [
"php"
],
"Title": "Loop with enclosing items every 'n' steps"
} | 82 |
<p>I was wondering for quite some time how to clean up the below code without blowing it up any further. The extension of the classes is the main concern here, it looks a bit too much like magic. That's mainly because it has to handle all the different cases, and I haven't figured out a way to reduce the code in a mean... | [
{
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-26T23:40:36.333",
"Id": "391",
"Score": "2",
"body": "Don't emulate classes. This is ECMAScript."
},
{
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-02-10T23:32:30.313",
"Id": "1335",
"Score": "0",
"bo... | [
{
"body": "<p>A few tips:</p>\n\n<ul>\n<li>Make sure your using good indentation</li>\n<li>Do not create a function that runs a native method\n<ul>\n<li>so: <code>if(is(\"Function\",ext))</code> becomes <code>if(typeof ext == \"Function\")</code></li>\n</ul></li>\n<li>remove unnecessary comments and comments sh... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-01-20T10:56:43.527",
"Id": "85",
"Score": "19",
"Tags": [
"javascript",
"classes"
],
"Title": "Cleaning up class creation / extension"
} | 85 |
<p>I'm new to Postgres and PostGIS, but not to geospatial applications.</p>
<p>I have a table loaded up with graph data in the form of links (edges). The link database has about <strong>60,000,000</strong> rows. I am trying to extract the nodes to allow for quicker searching. For some of my proof-of-concept work I was... | [
{
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-21T00:40:10.920",
"Id": "173",
"Score": "0",
"body": "Yes Postgres doesn't like the VACUUM ANALYZE in a script like that. However the rest appears to have worked okay."
}
] | [
{
"body": "<p>Check out <a href=\"http://www.postgresql.org/docs/8.2/static/populate.html\" rel=\"noreferrer\">PostgreSQL's tips on adding a lot of data into a table</a>. In particular, are you sure that you need that index before <code>INSERT</code>ing all that data? It might speed things up if you create the ... | {
"AcceptedAnswerId": "254",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-01-20T13:55:23.193",
"Id": "92",
"Score": "8",
"Tags": [
"sql",
"postgresql"
],
"Title": "Extracting nodes from a graph database"
} | 92 |
<p>I have written a method to tokenize HTTP request paths such as <code>/employee/23/edit</code>:</p>
<pre><code>protected void compile(String path){
int mark=0;
for(int i=0; i<path.length(); ++i){
if(path.charAt(i)==DELIM){
if(mark!=i)
tokens.add(path.substring(mark,i));... | [
{
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-20T18:23:19.373",
"Id": "155",
"Score": "1",
"body": "Wouldn't String.split() work better for tokenizing a String (http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#split(java.lang.String))?"
},
{
"ContentL... | [
{
"body": "<p>Your first <code>compile</code> method can be replaced by a single call to <code>String.split</code>.</p>\n\n<p>Assuming the intended behavior for the second <code>compile</code> method is such that \"/foo/b[a]r/baz\" will compile to <code>{\"foo\", \"?\", \"baz\"}</code>, it can be replaced by a ... | {
"AcceptedAnswerId": "110",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-01-20T18:14:40.340",
"Id": "109",
"Score": "14",
"Tags": [
"java",
"parsing",
"url"
],
"Title": "HTTP request path parser"
} | 109 |
<p>I have written this (truncated) code to fetch some tweets:</p>
<pre><code> dispatch_async(dispatch_get_global_queue(0, 0), ^{
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
NSString *JSONStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://search.twitter.com/s... | [] | [
{
"body": "<p>you don't necessarily have to call -setNetworkActivityIndicatorVisible: from the main thread. I didn't find anything in the documentation about UIApplication not being thread safe, and since your application's main thread doesn't have anything in common with the system, you are free to call it whe... | {
"AcceptedAnswerId": "195",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-01-20T19:19:39.800",
"Id": "112",
"Score": "14",
"Tags": [
"multithreading",
"objective-c",
"twitter"
],
"Title": "Fetching tweets"
} | 112 |
<p>I have a Perl application that allows the user to choose between two different formats for data output (and there will likely be more in the near future). In the heart of the algorithm, the code makes a call to a print subroutine.</p>
<pre><code>my $stats = analyze_model_vectors( $reference_vector, $prediction_vect... | [
{
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-05-30T18:26:59.350",
"Id": "4224",
"Score": "1",
"body": "Big if/elsif/else chains are ugly. The canonical method of handling this case in Perl is to use a dispatch table: a hash containing subroutine references. See Charles Bailey's re... | [
{
"body": "<p>I try to avoid Perl if I can, so this is more of a general answer: I've coded like this in an old VB6 app. Each output function had a wrapper function that then called the required implementation using a series of IFs. Sometimes a particular output method wouldn't need anything - eg. \"Start New L... | {
"AcceptedAnswerId": "118",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-20T20:31:26.477",
"Id": "115",
"Score": "14",
"Tags": [
"perl",
"subroutine"
],
"Title": "Subroutine to call other subroutines"
} | 115 |
<p>So I have a series of objects, which I will call Impl1, Impl2, and Impl3. They each implement an interface, called IImpl. I have a Factory class who's task is to retrieve the ImplX which is appropriate for a given circumstance, and pass it on to its callers. So the code in the factory looks like:</p>
<pre><code>... | [
{
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-22T13:52:27.023",
"Id": "245",
"Score": "0",
"body": "I think either we need more information, or you're expectations can't be met: if you are required to pass different kinds of parameters to this factory for it to work properly, then... | [
{
"body": "<p>How about some kind of intermediary blackboard that the client code constructs before calling the factory, and each concrete Impl can poll to construct itself?</p>\n\n<pre><code>// client code:\n\nBlackboard blackboard = new Blackboard();\nblackboard.pushCollectionB(collectionB);\nblackboard.pushC... | {
"AcceptedAnswerId": "129",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-21T14:07:09.330",
"Id": "128",
"Score": "23",
"Tags": [
"c#",
".net",
"design-patterns"
],
"Title": "Best way to pass parameters to Factory class?"
} | 128 |
<p><em>Inspired by <a href="https://codereview.stackexchange.com/q/97">this question</a>, but hopefully not a duplicate.</em></p>
<p>I understand that the Law of Demeter is very useful in case of services interacting with other services, for example it's much easier to mock the other services in unit tests.
What about... | [] | [
{
"body": "<p>I'd say that it isn't cluttering the model personally. You are actually protecting yourself by not exposing internal implementation of your document class. The entire idea is to put all of your behavior into your class instead of having external code modify the class in such a way that it may no... | {
"AcceptedAnswerId": "153",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-21T16:26:15.320",
"Id": "131",
"Score": "27",
"Tags": [
"java",
"design-patterns"
],
"Title": "Law of Demeter and data models?"
} | 131 |
<p>Would this function be sufficient enough to remove all malicious code and foreign characters from a string?</p>
<pre><code>//Clean the string
$out = ltrim($do);
$out = rtrim($out);
$out = preg_replace('/[^(\x20-\x7F)]*/','', strip_tags($out));
</code></pre>
<p>This data is not going into a SQL database, so I dont... | [
{
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-21T18:09:36.597",
"Id": "211",
"Score": "2",
"body": "How are you using this string that you are worried about it being an attack vector? Where is the string coming from? What do you expect it to contain? Please add that to the quest... | [
{
"body": "<p>That one is quite simple (for me at least) since there is a very general answer :)</p>\n\n<h2>NO</h2>\n\n<p>There is no way you can ever really safely \"repair\" user input.</p>\n\n<blockquote>\n <p>\"Please provide a list of everything you shouldn't to with a hammer\" </p>\n</blockquote>\n\n<p>i... | {
"AcceptedAnswerId": "137",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-01-21T18:08:22.390",
"Id": "136",
"Score": "11",
"Tags": [
"php",
"strings",
"security",
"regex"
],
"Title": "Is this a sufficient way to prevent script injections and other bad st... | 136 |
<p>I don't like the fact that I am selecting all the points, even though I only care about the count of them.</p>
<p>Which of the <code>from</code> parts should appear first, if it even matters?</p>
<pre><code>var count = (from type in ValidTypes()
from point in GetData(type)
where point.Radius > reference... | [
{
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-21T19:28:47.677",
"Id": "218",
"Score": "1",
"body": "Is this a Linq to sql query or linq to objects?"
},
{
"ContentLicense": "CC BY-SA 2.5",
"CreationDate": "2011-01-21T19:56:25.033",
"Id": "222",
"Score": "0",
... | [
{
"body": "<p>First, your query is written fine. Its structure is not a concern; the order of the froms is clearly correct, the select is appropriate. Where you could look for improvement that could change the query (code and possibly performance) would be in the <code>GetData</code> method. If, for example, <c... | {
"AcceptedAnswerId": "144",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 3.0",
"CreationDate": "2011-01-21T19:10:07.230",
"Id": "138",
"Score": "13",
"Tags": [
"c#",
"linq"
],
"Title": "Counting the number of points that have both a larger theta and a larger radius than a given point"
} | 138 |
End of preview. Expand in Data Studio
- Downloads last month
- 9