qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
23,802 | <p>I'm wondering what the best practice is for handling the problem with having to "include" so many files in my PHP scripts in order to ensure that all the classes I need to use are accessible to my script. </p>
<p>Currently, I'm just using <a href="http://php.net/manual/en/function.include-once.php" rel="nofollow no... | [
{
"answer_id": 23805,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 0,
"selected": false,
"text": "<p><code>__autoload</code> works well if you have a consistent naming convention for your classes that tell the functi... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1862/"
] | I'm wondering what the best practice is for handling the problem with having to "include" so many files in my PHP scripts in order to ensure that all the classes I need to use are accessible to my script.
Currently, I'm just using [include\_once](http://php.net/manual/en/function.include-once.php) to include the clas... | I my applications I usually have `setup.php` file that includes all core classes (i.e. framework and accompanying libraries). My custom classes are loaded using autoloader aided by directory layout map.
Each time new class is added I run command line builder script that scans whole directory tree in search for model c... |
23,853 | <p>I am using Struts + Velocity in a Java application, but after I submit a form, the confirmation page (Velocity template) shows the variable names instead an empty label, like the Age in following example:</p>
<blockquote>
<p><strong>Name</strong>: Fernando</p>
<p><strong>Age</strong>: {person.age}</p>
<p><strong>Sex... | [
{
"answer_id": 23879,
"author": "Jason Sparks",
"author_id": 512,
"author_profile": "https://Stackoverflow.com/users/512",
"pm_score": 7,
"selected": true,
"text": "<p>You can mark variables as \"<a href=\"https://velocity.apache.org/engine/1.5/user-guide.html#quietreferencenotation\" re... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2274/"
] | I am using Struts + Velocity in a Java application, but after I submit a form, the confirmation page (Velocity template) shows the variable names instead an empty label, like the Age in following example:
>
> **Name**: Fernando
>
>
> **Age**: {person.age}
>
>
> **Sex**: Male
>
>
>
I would like to know how to ... | You can mark variables as "[silent](https://velocity.apache.org/engine/1.5/user-guide.html#quietreferencenotation)" like this:
```
$!variable
```
If $variable is null, nothing will be rendered. If it is not null, its value will render as it normally would. |
23,867 | <p>The <code>Close</code> method on an <code>ICommunicationObject</code> can throw two types of exceptions as MSDN outlines <a href="http://msdn.microsoft.com/en-us/library/ms195520.aspx" rel="nofollow noreferrer">here</a>. I understand why the <code>Close</code> method can throw those exceptions, but what I don't unde... | [
{
"answer_id": 23879,
"author": "Jason Sparks",
"author_id": 512,
"author_profile": "https://Stackoverflow.com/users/512",
"pm_score": 7,
"selected": true,
"text": "<p>You can mark variables as \"<a href=\"https://velocity.apache.org/engine/1.5/user-guide.html#quietreferencenotation\" re... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/781/"
] | The `Close` method on an `ICommunicationObject` can throw two types of exceptions as MSDN outlines [here](http://msdn.microsoft.com/en-us/library/ms195520.aspx). I understand why the `Close` method can throw those exceptions, but what I don't understand is why the `Dispose` method on a service proxy calls the `Close` m... | You can mark variables as "[silent](https://velocity.apache.org/engine/1.5/user-guide.html#quietreferencenotation)" like this:
```
$!variable
```
If $variable is null, nothing will be rendered. If it is not null, its value will render as it normally would. |
23,907 | <p>Basically I want to get the number of lines-of-code in the repository after each commit.</p>
<p>The only (really crappy) ways I have found is to use <code>git filter-branch</code> to run <code>wc -l *</code>, and a script that runs <code>git reset --hard</code> on each commit, then runs <code>wc -l</code></p>
<p>T... | [
{
"answer_id": 24190,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>The first thing that jumps to mind is the possibility of your git history having a nonlinear history. You might have di... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] | Basically I want to get the number of lines-of-code in the repository after each commit.
The only (really crappy) ways I have found is to use `git filter-branch` to run `wc -l *`, and a script that runs `git reset --hard` on each commit, then runs `wc -l`
To make it a bit clearer, when the tool is run, it would outpu... | You might also consider [gitstats](http://gitstats.sourceforge.net/), which generates this graph as an html file. |
23,918 | <p>I'm trying to do a simple rotation in OpenGL but must be missing the point.
I'm not looking for a specific fix so much as a quick explanation or link that explains OpenGL rotation more generally.</p>
<p>At the moment I have code like this:</p>
<pre><code>glPushMatrix();
glRotatef(90.0, 0.0, 1.0, 0.0);
glBegin(... | [
{
"answer_id": 23925,
"author": "spate",
"author_id": 2276,
"author_profile": "https://Stackoverflow.com/users/2276",
"pm_score": 3,
"selected": false,
"text": "<p>Ensure that you're modifying the modelview matrix by putting the following before the glRotatef call:</p>\n\n<pre><code>glMa... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | I'm trying to do a simple rotation in OpenGL but must be missing the point.
I'm not looking for a specific fix so much as a quick explanation or link that explains OpenGL rotation more generally.
At the moment I have code like this:
```
glPushMatrix();
glRotatef(90.0, 0.0, 1.0, 0.0);
glBegin(GL_TRIANGLES); ... | Do you get a 1 unit straight line? It seems that 90deg rot. around Y is going to have you looking at the side of a triangle with no depth.
You should try rotating around the Z axis instead and see if you get something that makes more sense.
OpenGL has two matrices related to the display of geometry, the ModelView an... |
23,930 | <p>I want to see all the different ways you can come up with, for a factorial subroutine, or program. The hope is that anyone can come here and see if they might want to learn a new language.</p>
<h2>Ideas:</h2>
<ul>
<li>Procedural</li>
<li>Functional</li>
<li>Object Oriented</li>
<li>One liners</li>
<li>Obfuscated</li... | [
{
"answer_id": 23932,
"author": "Brad Gilbert",
"author_id": 1337,
"author_profile": "https://Stackoverflow.com/users/1337",
"pm_score": 2,
"selected": false,
"text": "<h1>Perl 6: Functional</h1>\n\n<pre><code>multi factorial ( Int $n where { $n <= 0 } ){\n return 1;\n}\nmulti factor... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1337/"
] | I want to see all the different ways you can come up with, for a factorial subroutine, or program. The hope is that anyone can come here and see if they might want to learn a new language.
Ideas:
------
* Procedural
* Functional
* Object Oriented
* One liners
* Obfuscated
* Oddball
* Bad Code
* [Polyglot](http://en.w... | Polyglot: 5 languages, all using bignums
========================================
So, I wrote a polyglot which works in the three languages I often write in, as well as one from my other answer to this question and one I just learned today. It's a standalone program, which reads a single line containing a nonnegative ... |
23,931 | <p>Given two different image files (in whatever format I choose), I need to write a program to predict the chance if one being the illegal copy of another. The author of the copy may do stuff like rotating, making negative, or adding trivial details (as well as changing the dimension of the image).</p>
<p>Do you know ... | [
{
"answer_id": 23946,
"author": "Nick",
"author_id": 1490,
"author_profile": "https://Stackoverflow.com/users/1490",
"pm_score": 5,
"selected": false,
"text": "<p>Read the paper: <a href=\"http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.81.3347&rep=rep1&type=pdf\" rel=\"... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Given two different image files (in whatever format I choose), I need to write a program to predict the chance if one being the illegal copy of another. The author of the copy may do stuff like rotating, making negative, or adding trivial details (as well as changing the dimension of the image).
Do you know any algori... | These are simply ideas I've had thinking about the problem, never tried it but I like thinking about problems like this!
**Before you begin**
Consider normalising the pictures, if one is a higher resolution than the other, consider the option that one of them is a compressed version of the other, therefore scaling th... |
23,962 | <p>For example,
Look at the code that calculates the n-th Fibonacci number:</p>
<pre><code>fib(int n)
{
if(n==0 || n==1)
return 1;
return fib(n-1) + fib(n-2);
}
</code></pre>
<p>The problem with this code is that it will generate stack overflow error for any number greater than 15 (in most computers).... | [
{
"answer_id": 23964,
"author": "jfs",
"author_id": 718,
"author_profile": "https://Stackoverflow.com/users/718",
"pm_score": 1,
"selected": false,
"text": "<p>Try using a map, n is the key and its corresponding Fibonacci number is the value.</p>\n<p>@Paul</p>\n<p>Thanks for the info. I ... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184/"
] | For example,
Look at the code that calculates the n-th Fibonacci number:
```
fib(int n)
{
if(n==0 || n==1)
return 1;
return fib(n-1) + fib(n-2);
}
```
The problem with this code is that it will generate stack overflow error for any number greater than 15 (in most computers).
Assume that we are calcu... | Yes your insight is correct.
This is called [dynamic programming](http://en.wikipedia.org/wiki/Dynamic_programming). It is usually a common memory runtime trade-off.
In the case of fibo, you don't even need to cache everything :
[edit]
The author of the question seems to be looking for a general method to cache rathe... |
23,970 | <p>Joe Van Dyk <a href="http://www.zenspider.com/pipermail/ruby/2008-August/004223.html" rel="noreferrer">asked the Ruby mailing list</a>:</p>
<blockquote>
<p>Hi,</p>
<p>In Ruby, I guess you can't marshal a lambda/proc object, right? Is
that possible in lisp or other languages?</p>
<p>What I was trying ... | [
{
"answer_id": 23974,
"author": "James A. Rosen",
"author_id": 1190,
"author_profile": "https://Stackoverflow.com/users/1190",
"pm_score": 2,
"selected": false,
"text": "<p>Try <a href=\"http://seattlerb.rubyforge.org/ruby2ruby/\" rel=\"nofollow noreferrer\">ruby2ruby</a></p>\n"
},
{... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | Joe Van Dyk [asked the Ruby mailing list](http://www.zenspider.com/pipermail/ruby/2008-August/004223.html):
>
> Hi,
>
>
> In Ruby, I guess you can't marshal a lambda/proc object, right? Is
> that possible in lisp or other languages?
>
>
> What I was trying to do:
>
>
>
```
l = lamda { ... }
Bj.submit "/path/... | You cannot marshal a Lambda or Proc. This is because both of them are considered closures, which means they close around the memory on which they were defined and can reference it. (In order to marshal them you'd have to Marshal all of the memory they could access at the time they were created.)
As Gaius pointed out t... |
23,996 | <p>I'm working with <a href="http://webby.rubyforge.org" rel="nofollow noreferrer" title="Webby">Webby</a> and am looking for some clarification. Can I define attributes like <code>title</code> or <code>author</code> in my layout?</p>
| [
{
"answer_id": 24010,
"author": "John",
"author_id": 2168,
"author_profile": "https://Stackoverflow.com/users/2168",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://webby.rubyforge.org/tutorial/\" rel=\"nofollow noreferrer\">I've never used it but the tutorial here:</a></p... | 2008/08/23 | [
"https://Stackoverflow.com/questions/23996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2165/"
] | I'm working with [Webby](http://webby.rubyforge.org "Webby") and am looking for some clarification. Can I define attributes like `title` or `author` in my layout? | Not really. The layout has access to the page attributes rather than the other way.
The easiest way to do what you want is to populate the SITE.page\_defaults hash in your site's Rakefile (probably build.rake). Add something like the following:
```
SITE.page_defaults['title'] = "My awesome title"
SITE.pag... |
24,046 | <p>I do some minor programming and web work for a local community college. Work that includes maintaining a very large and soul destroying website that consists of a hodge podge of VBScript, javascript, Dreamweaver generated cruft and a collection of add-ons that various conmen have convinced them to buy over the years... | [
{
"answer_id": 24049,
"author": "Teifion",
"author_id": 1384652,
"author_profile": "https://Stackoverflow.com/users/1384652",
"pm_score": 2,
"selected": false,
"text": "<p>I have no idea what's causing the problem but I know who might be able to help you. Safari is built on <a href=\"htt... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2051/"
] | I do some minor programming and web work for a local community college. Work that includes maintaining a very large and soul destroying website that consists of a hodge podge of VBScript, javascript, Dreamweaver generated cruft and a collection of add-ons that various conmen have convinced them to buy over the years.
... | Stefan's iframe solution works, but if that's not elegant enough, I find the following JavaScript also solves it:
```
window.onunload = function(){};
```
That is, if your menu is JavaScript, then you might prefer to solve this issue with JavaScript too.
The unload event handler definition idea came from this Firefo... |
24,113 | <p>We have been developing an Outlook Add-in using Visual Studio 2008. However I am facing a strange behavior while adding a command button to a custom command bar. This behavior is reflected when we add the button in the reply, reply all and forward windows. The issue is that the caption of the command button is not v... | [
{
"answer_id": 24258,
"author": "Ryan Farley",
"author_id": 1627,
"author_profile": "https://Stackoverflow.com/users/1627",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know the answer to your question, but I would highly recommend Add-In Express for doing the addin. See <a href... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2528/"
] | We have been developing an Outlook Add-in using Visual Studio 2008. However I am facing a strange behavior while adding a command button to a custom command bar. This behavior is reflected when we add the button in the reply, reply all and forward windows. The issue is that the caption of the command button is not visi... | I don't know the answer to your question, but I would highly recommend Add-In Express for doing the addin. See <http://www.add-in-express.com/add-in-net/>. I've used this in many projects, including some commercial software and it is completely awesome.
It does all the Outlook (and office) integration for you so you ... |
24,130 | <p>Which is better to use in PHP, a 2D array or a class? I've included an example of what I mean by this.</p>
<pre><code>// Using a class
class someClass
{
public $name;
public $height;
public $weight;
function __construct($name, $height, $weight)
{
$this -> name = $name;
... | [
{
"answer_id": 24131,
"author": "robintw",
"author_id": 1912,
"author_profile": "https://Stackoverflow.com/users/1912",
"pm_score": 2,
"selected": false,
"text": "<p>It depends exactly what you mean by 'better'. I'd go for the object oriented way (using classes) because I find it makes f... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | Which is better to use in PHP, a 2D array or a class? I've included an example of what I mean by this.
```
// Using a class
class someClass
{
public $name;
public $height;
public $weight;
function __construct($name, $height, $weight)
{
$this -> name = $name;
$this -> heigh... | The "class" that you've constructed above is what most people would use a *struct* for in other languages. I'm not sure what the performance implications are in PHP, though I suspect instantiating the objects is probably more costly here, if only by a little bit.
That being said, if the cost is relatively low, it IS a... |
24,200 | <p>I am hitting some performance bottlenecks with my C# client inserting bulk data into a SQL Server 2005 database and I'm looking for ways in which to speed up the process.</p>
<p>I am already using the SqlClient.SqlBulkCopy (which is based on TDS) to speed up the data transfer across the wire which helped a lot, but... | [
{
"answer_id": 24204,
"author": "jason saldo",
"author_id": 1293,
"author_profile": "https://Stackoverflow.com/users/1293",
"pm_score": -1,
"selected": false,
"text": "<p>Yes your ideas will help.<br>\nLean on option 1 if there are no reads happening while your loading.<br>\nLean on opti... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1948/"
] | I am hitting some performance bottlenecks with my C# client inserting bulk data into a SQL Server 2005 database and I'm looking for ways in which to speed up the process.
I am already using the SqlClient.SqlBulkCopy (which is based on TDS) to speed up the data transfer across the wire which helped a lot, but I'm still... | Here's how you can disable/enable indexes in SQL Server:
```
--Disable Index ALTER INDEX [IX_Users_UserID] SalesDB.Users DISABLE
GO
--Enable Index ALTER INDEX [IX_Users_UserID] SalesDB.Users REBUILD
```
Here are some resources to help you find a solution:
[Some bulk loading speed comparisons](http://weblogs.sqlteam.... |
24,207 | <p>I'm trying to use “rusage” statistics in my program to get data similar to that of the <a href="http://en.wikipedia.org/wiki/Time_%28Unix%29" rel="nofollow noreferrer">time</a> tool. However, I'm pretty sure that I'm doing something wrong. The values seem about right but can be a bit weird at times. I didn't find go... | [
{
"answer_id": 26827,
"author": "Mike Haboustak",
"author_id": 2146,
"author_profile": "https://Stackoverflow.com/users/2146",
"pm_score": 2,
"selected": false,
"text": "<p>I think there's probably a bug somewhere in your composition of sec and usec. I can't really say what exactly witho... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1968/"
] | I'm trying to use “rusage” statistics in my program to get data similar to that of the [time](http://en.wikipedia.org/wiki/Time_%28Unix%29) tool. However, I'm pretty sure that I'm doing something wrong. The values seem about right but can be a bit weird at times. I didn't find good resources online. Does somebody know ... | What is the purpose of:
```
while (usec >= 1000)
usec /= 10;
```
I gather that you want the most significant three digits of the usec; in that case, the most straightforward way I can think of is to divide usec by 1000, and be done with that.
Test cases:
* 999999 ⇒ 999
* 99999 ⇒ 999 (should be 099)
* 9999 ⇒ 99... |
24,262 | <p>While creating a file synchronization program in C# I tried to make a method <code>copy</code> in <code>LocalFileItem</code> class that uses <code>System.IO.File.Copy(destination.Path, Path, true)</code> method where <code>Path</code> is a <code>string</code>.<br>
After executing this code with destination. <code>Pa... | [
{
"answer_id": 24274,
"author": "Michał Piaskowski",
"author_id": 1534,
"author_profile": "https://Stackoverflow.com/users/1534",
"pm_score": 3,
"selected": true,
"text": "<p>It seems you have misplaced the parameters in File.Copy(), it should be File.Copy(string source, string destinat... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2605/"
] | While creating a file synchronization program in C# I tried to make a method `copy` in `LocalFileItem` class that uses `System.IO.File.Copy(destination.Path, Path, true)` method where `Path` is a `string`.
After executing this code with destination. `Path = "C:\\Test2"` and `this.Path = "C:\\Test\\F1.txt"` I get an ... | It seems you have misplaced the parameters in File.Copy(), it should be File.Copy(string source, string destination).
Also is "C:\Test2" a directory? You can't copy file to a directory.
Use something like that instead:
```
File.Copy(
sourceFile,
Path.Combine(destinationDir,Path.GetFileName(sourceFile))
... |
24,315 | <p>In C# I can use the FileSystemWatcher object to watch for a specific file and raise an event when it is created, modified, etc.</p>
<p>The problem I have with this class is that it raises the event the moment the file becomes created, even if the process which created the file is still in the process of writing. I ... | [
{
"answer_id": 24323,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if there is a way of an event actually being raised by the standard class, but I eas experiencing similar proble... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | In C# I can use the FileSystemWatcher object to watch for a specific file and raise an event when it is created, modified, etc.
The problem I have with this class is that it raises the event the moment the file becomes created, even if the process which created the file is still in the process of writing. I have found... | You can use a file system watcher to check when the file has been changed. It only becomes "changed" after whichever program had the file previously closes the file. I know you asked for C#, but my VB.Net is much better. Hope you or someone else can translate.
It tries to open the file, if it isn't available, it adds ... |
24,468 | <p>When I try to run a .NET assembly (<code>boo.exe</code>) from a network share (mapped to a drive), it fails since it's only partially trusted:</p>
<pre><code>Unhandled Exception: System.Security.SecurityException: That assembly does not allow partially trusted callers.
at System.Security.CodeAccessSecurityEngine... | [
{
"answer_id": 24477,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 4,
"selected": true,
"text": "<p>With .NET 3.5 SP1, .NET assemblies running from UNC shares have full permissions. </p>\n\n<p>See Brad Abrams's ... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/616/"
] | When I try to run a .NET assembly (`boo.exe`) from a network share (mapped to a drive), it fails since it's only partially trusted:
```
Unhandled Exception: System.Security.SecurityException: That assembly does not allow partially trusted callers.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(A... | With .NET 3.5 SP1, .NET assemblies running from UNC shares have full permissions.
See Brad Abrams's [Allow .exes to be run off a network shares](http://blogs.msdn.com/brada/archive/2007/10/26/adhoc-poll-allowing-net-exes-to-run-off-a-network-share.aspx) for workaround and discussions, and finally the follow up [.NET ... |
24,470 | <p>Trying to find some simple SQL Server PIVOT examples. Most of the examples that I have found involve counting or summing up numbers. I just want to pivot some string data. For example, I have a query returning the following.</p>
<pre><code>Action1 VIEW
Action1 EDIT
Action2 VIEW
Action3 VIEW
Action3 EDIT ... | [
{
"answer_id": 24538,
"author": "vzczc",
"author_id": 224,
"author_profile": "https://Stackoverflow.com/users/224",
"pm_score": 3,
"selected": false,
"text": "<p>Well, for your sample and any with a limited number of unique columns, this should do it.</p>\n\n<pre><code>select \n disti... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2626/"
] | Trying to find some simple SQL Server PIVOT examples. Most of the examples that I have found involve counting or summing up numbers. I just want to pivot some string data. For example, I have a query returning the following.
```
Action1 VIEW
Action1 EDIT
Action2 VIEW
Action3 VIEW
Action3 EDIT
```
I would l... | Remember that the MAX aggregate function will work on text as well as numbers. This query will only require the table to be scanned once.
```
SELECT Action,
MAX( CASE data WHEN 'View' THEN data ELSE '' END ) ViewCol,
MAX( CASE data WHEN 'Edit' THEN data ELSE '' END ) EditCol
FROM t
GROUP BY Action
``... |
24,495 | <p>I have a Struts + Velocity structure like for example, a Person class, whose one property is a Car object (with its own getter/setter methods) and it is mapped to a Velocity form that submits to an Action, using ModelDriven and getModel structure.</p>
<p>I what to put a button on the form that shows "View Car" if c... | [
{
"answer_id": 24510,
"author": "Brian Matthews",
"author_id": 1969,
"author_profile": "https://Stackoverflow.com/users/1969",
"pm_score": 4,
"selected": true,
"text": "<p>You should change the #if line to:</p>\n\n<pre><code>#if($car)\n</code></pre>\n"
},
{
"answer_id": 64065,
... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2274/"
] | I have a Struts + Velocity structure like for example, a Person class, whose one property is a Car object (with its own getter/setter methods) and it is mapped to a Velocity form that submits to an Action, using ModelDriven and getModel structure.
I what to put a button on the form that shows "View Car" if car propert... | You should change the #if line to:
```
#if($car)
``` |
24,515 | <p>Not very technical, but... I have to implement a bad words filter in a new site we are developing. So I need a "good" bad words list to feed my db with... any hint / direction? Looking around with google I <a href="http://urbanoalvarez.es/blog/2008/04/04/bad-words-list/" rel="noreferrer">found this</a> one, and it's... | [
{
"answer_id": 24527,
"author": "AgentConundrum",
"author_id": 1588,
"author_profile": "https://Stackoverflow.com/users/1588",
"pm_score": 6,
"selected": false,
"text": "<p>Beware of <a href=\"http://thedailywtf.com/Articles/The-Clbuttic-Mistake-.aspx\" rel=\"noreferrer\">clbuttic mistak... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1178/"
] | Not very technical, but... I have to implement a bad words filter in a new site we are developing. So I need a "good" bad words list to feed my db with... any hint / direction? Looking around with google I [found this](http://urbanoalvarez.es/blog/2008/04/04/bad-words-list/) one, and it's a start, but nothing more.
Ye... | I didn't see any language specified but you can use this for PHP it will generate a RegEx for each instered work so that even intentional mis-spellings (i.e. @ss, i3itch ) will also be caught.
```
<?php
/**
* @author unkwntech@unkwndesign.com
**/
if($_GET['act'] == 'do')
{
$pattern['a'] = '/[a]/'; $replace['a... |
24,516 | <p>I'm trying to parse a grammar in ocamlyacc (pretty much the same as regular yacc) which supports function application with no operators (like in Ocaml or Haskell), and the normal assortment of binary and unary operators. I'm getting a reduce/reduce conflict with the '-' operator, which can be used both for subtracti... | [
{
"answer_id": 24589,
"author": "James A. Rosen",
"author_id": 1190,
"author_profile": "https://Stackoverflow.com/users/1190",
"pm_score": 4,
"selected": true,
"text": "<p>Unfortunately, the only answer I can come up with means increasing the complexity of the grammar.</p>\n\n<ol>\n<li>s... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1891/"
] | I'm trying to parse a grammar in ocamlyacc (pretty much the same as regular yacc) which supports function application with no operators (like in Ocaml or Haskell), and the normal assortment of binary and unary operators. I'm getting a reduce/reduce conflict with the '-' operator, which can be used both for subtraction ... | Unfortunately, the only answer I can come up with means increasing the complexity of the grammar.
1. split `expr` into `simple_expr` and `expr_with_prefix`
2. allow only `simple_expr` or `(expr_with_prefix)` in an APPLY
The first step turns your reduce/reduce conflict into a shift/reduce conflict, but the parentheses... |
24,542 | <p>Is there any reason not to use the bitwise operators &, |, and ^ for "bool" values in C++? </p>
<p>I sometimes run into situations where I want exactly one of two conditions to be true (XOR), so I just throw the ^ operator into a conditional expression. I also sometimes want all parts of a condition to be evalu... | [
{
"answer_id": 24552,
"author": "kokos",
"author_id": 1065,
"author_profile": "https://Stackoverflow.com/users/1065",
"pm_score": 4,
"selected": false,
"text": "<p>The raised eyebrows should tell you enough to stop doing it. You don't write the code for the compiler, you write it for you... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1891/"
] | Is there any reason not to use the bitwise operators &, |, and ^ for "bool" values in C++?
I sometimes run into situations where I want exactly one of two conditions to be true (XOR), so I just throw the ^ operator into a conditional expression. I also sometimes want all parts of a condition to be evaluated whether t... | `||` and `&&` are boolean operators and the built-in ones are guaranteed to return either `true` or `false`. Nothing else.
`|`, `&` and `^` are bitwise operators. When the domain of numbers you operate on is just 1 and 0, then they are exactly the same, but in cases where your booleans are not strictly 1 and 0 – as is... |
24,546 | <p>I'm trying to fetch Wikipedia pages using <a href="http://search.cpan.org/dist/libwww-perl" rel="noreferrer">LWP::Simple</a>, but they're not coming back. This code:</p>
<pre><code>#!/usr/bin/perl
use strict;
use LWP::Simple;
print get("http://en.wikipedia.org/wiki/Stack_overflow");
</code></pre>
<p>doesn't print... | [
{
"answer_id": 24574,
"author": "Jesse Beder",
"author_id": 112,
"author_profile": "https://Stackoverflow.com/users/112",
"pm_score": 5,
"selected": true,
"text": "<p>Apparently Wikipedia blocks LWP::Simple requests: <a href=\"http://www.perlmonks.org/?node_id=695886\" rel=\"noreferrer\"... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/112/"
] | I'm trying to fetch Wikipedia pages using [LWP::Simple](http://search.cpan.org/dist/libwww-perl), but they're not coming back. This code:
```
#!/usr/bin/perl
use strict;
use LWP::Simple;
print get("http://en.wikipedia.org/wiki/Stack_overflow");
```
doesn't print anything. But if I use some other webpage, say `<http... | Apparently Wikipedia blocks LWP::Simple requests: <http://www.perlmonks.org/?node_id=695886>
The following works instead:
```
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
my $url = "http://en.wikipedia.org/wiki/Stack_overflow";
my $ua = LWP::UserAgent->new();
my $res = $ua->get($url);
print $res->content;
``` |
24,551 | <p>I've been programming in C# and Java recently and I am curious where the best place is to initialize my class fields.</p>
<p>Should I do it at declaration?:</p>
<pre><code>public class Dice
{
private int topFace = 1;
private Random myRand = new Random();
public void Roll()
{
// ......
}... | [
{
"answer_id": 24558,
"author": "kokos",
"author_id": 1065,
"author_profile": "https://Stackoverflow.com/users/1065",
"pm_score": 9,
"selected": true,
"text": "<p>My rules:</p>\n\n<ol>\n<li>Don't initialize with the default values in declaration (<code>null</code>, <code>false</code>, <c... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] | I've been programming in C# and Java recently and I am curious where the best place is to initialize my class fields.
Should I do it at declaration?:
```
public class Dice
{
private int topFace = 1;
private Random myRand = new Random();
public void Roll()
{
// ......
}
}
```
or in a cons... | My rules:
1. Don't initialize with the default values in declaration (`null`, `false`, `0`, `0.0`…).
2. Prefer initialization in declaration if you don't have a constructor parameter that changes the value of the field.
3. If the value of the field changes because of a constructor parameter put the initialization in t... |
24,556 | <p>In LINQ to SQL, is it possible to check to see if an entity is already part of the data context before trying to attach it?</p>
<p>A little context if it helps...</p>
<p>I have this code in my <code>global.asax</code> as a helper method. Normally, between requests, this isn't a problem. But right after signing i... | [
{
"answer_id": 24558,
"author": "kokos",
"author_id": 1065,
"author_profile": "https://Stackoverflow.com/users/1065",
"pm_score": 9,
"selected": true,
"text": "<p>My rules:</p>\n\n<ol>\n<li>Don't initialize with the default values in declaration (<code>null</code>, <code>false</code>, <c... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2595/"
] | In LINQ to SQL, is it possible to check to see if an entity is already part of the data context before trying to attach it?
A little context if it helps...
I have this code in my `global.asax` as a helper method. Normally, between requests, this isn't a problem. But right after signing in, this is getting called more... | My rules:
1. Don't initialize with the default values in declaration (`null`, `false`, `0`, `0.0`…).
2. Prefer initialization in declaration if you don't have a constructor parameter that changes the value of the field.
3. If the value of the field changes because of a constructor parameter put the initialization in t... |
24,580 | <p>How do you turn a Visual Studio build that you'd perform in the IDE into a script that you can run from the command line?</p>
| [
{
"answer_id": 24581,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 2,
"selected": false,
"text": "<p>Look into build tool <a href=\"http://en.wikipedia.org/wiki/NAnt\" rel=\"nofollow noreferrer\">NAnt</a> or <a href=\"http... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2541/"
] | How do you turn a Visual Studio build that you'd perform in the IDE into a script that you can run from the command line? | With VS2008 you can do this:
```
devenv solution.sln /build configuration
``` |
24,622 | <p>I can set the PHP include path in the <code>php.ini</code>:</p>
<pre><code>include_path = /path/to/site/includes/
</code></pre>
<p>But then other websites are affected so that is no good.</p>
<p>I can set the PHP include in the start of every file:</p>
<pre><code>$path = '/path/to/site/includes/';
set_include_pa... | [
{
"answer_id": 24631,
"author": "Erik van Brakel",
"author_id": 909,
"author_profile": "https://Stackoverflow.com/users/909",
"pm_score": 5,
"selected": true,
"text": "<p>If you're using apache as a webserver you can override (if you allow it) settings using <em>.htaccess</em> files. See... | 2008/08/23 | [
"https://Stackoverflow.com/questions/24622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2118/"
] | I can set the PHP include path in the `php.ini`:
```
include_path = /path/to/site/includes/
```
But then other websites are affected so that is no good.
I can set the PHP include in the start of every file:
```
$path = '/path/to/site/includes/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
```
... | If you're using apache as a webserver you can override (if you allow it) settings using *.htaccess* files. See [the PHP manual](http://us2.php.net/configuration.changes) for details.
Basically you put a file called *.htaccess* in your website root, which contains some PHP `ini` values. Provided you configured Apache t... |
24,715 | <p>I'm implementing a tagging system for a website. There are multiple tags per object and multiple objects per tag. This is accomplished by maintaining a table with two values per record, one for the ids of the object and the tag.</p>
<p>I'm looking to write a query to find the objects that match a given set of tags.... | [
{
"answer_id": 24720,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": -1,
"selected": false,
"text": "<p>I'd suggest making your table have 1 tag per record, like this:</p>\n\n<pre><code> apple -> fruit\n apple -> red\... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] | I'm implementing a tagging system for a website. There are multiple tags per object and multiple objects per tag. This is accomplished by maintaining a table with two values per record, one for the ids of the object and the tag.
I'm looking to write a query to find the objects that match a given set of tags. Suppose I... | Given:
* object table (primary key id)
* objecttags table (foreign keys objectId, tagid)
* tags table (primary key id)
```
SELECT distinct o.*
from object o join objecttags ot on o.Id = ot.objectid
join tags t on ot.tagid = t.id
where t.Name = 'fruit' or t.name = 'food';
```
This seems backwards,... |
24,723 | <p>Jeff actually posted about this in <a href="http://refactormycode.com/codes/333-sanitize-html" rel="noreferrer">Sanitize HTML</a>. But his example is in C# and I'm actually more interested in a Java version. Does anyone have a better version for Java? Is his example good enough to just convert directly from C# to Ja... | [
{
"answer_id": 27705,
"author": "svrist",
"author_id": 86,
"author_profile": "https://Stackoverflow.com/users/86",
"pm_score": 0,
"selected": false,
"text": "<p>The biggest problem by using jeffs code is the @ which currently isnt available. </p>\n\n<p>I would probably just take the \"ra... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1406/"
] | Jeff actually posted about this in [Sanitize HTML](http://refactormycode.com/codes/333-sanitize-html). But his example is in C# and I'm actually more interested in a Java version. Does anyone have a better version for Java? Is his example good enough to just convert directly from C# to Java?
[Update] I have put a boun... | Don't do this with regular expressions. Remember, you're not protecting just against valid HTML; you're protecting against the DOM that web browsers create. Browsers can be tricked into producing valid DOM from invalid HTML quite easily.
For example, see this list of [obfuscated XSS attacks](http://ha.ckers.org/xss.h... |
24,730 | <p>I'm doing a little bit of work on a horrid piece of software built by Bangalores best.</p>
<p>It's written in mostly classic ASP/VbScript, but "ported" to ASP.NET, though most of the code is classic ASP style in the ASPX pages :(</p>
<p>I'm getting this message when it tries to connect to my local database:</p>
<... | [
{
"answer_id": 24744,
"author": "Dale Ragan",
"author_id": 1117,
"author_profile": "https://Stackoverflow.com/users/1117",
"pm_score": 3,
"selected": true,
"text": "<p>I ran into this a long time ago with working in ASP. I found this knowledge base article and it helped me out. I hope ... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I'm doing a little bit of work on a horrid piece of software built by Bangalores best.
It's written in mostly classic ASP/VbScript, but "ported" to ASP.NET, though most of the code is classic ASP style in the ASPX pages :(
I'm getting this message when it tries to connect to my local database:
**Multiple-step OLE DB... | I ran into this a long time ago with working in ASP. I found this knowledge base article and it helped me out. I hope it solves your problem.
<http://support.microsoft.com/kb/269495>
If this doesn't work and everything checks out, then it is probably your connection string. I would try these steps next:
Remove:
```... |
24,734 | <p>I'm trying to add support for stackoverflow feeds in my rss reader but <strong>SelectNodes</strong> and <strong>SelectSingleNode</strong> have no effect. This is probably something to do with ATOM and xml namespaces that I just don't understand yet.</p>
<p>I have gotten it to work by removing all attributes from th... | [
{
"answer_id": 24738,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 2,
"selected": false,
"text": "<p>You've guessed correctly: you're asking for nodes not in a namespace, but these nodes are in a namespace.</p>\n\n<p>De... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1147/"
] | I'm trying to add support for stackoverflow feeds in my rss reader but **SelectNodes** and **SelectSingleNode** have no effect. This is probably something to do with ATOM and xml namespaces that I just don't understand yet.
I have gotten it to work by removing all attributes from the **feed** tag, but that's a hack an... | Don't confuse the namespace names in the XML file with the namespace names for your namespace manager. They're both shortcuts, and they don't necessarily have to match.
So you can register "<http://www.w3.org/2005/Atom>" as "atom", and then do a SelectNodes for "atom:entry". |
24,797 | <p>What is the best way to convert a UTC datetime into local datetime. It isn't as simple as a getutcdate() and getdate() difference because the difference changes depending on what the date is.</p>
<p>CLR integration isn't an option for me either.</p>
<p>The solution that I had come up with for this problem a few mo... | [
{
"answer_id": 25032,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 0,
"selected": false,
"text": "<p>Maintain a TimeZone table, or shell out with an extended stored proc (xp_cmdshell or a COM component, or your own) a... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1950/"
] | What is the best way to convert a UTC datetime into local datetime. It isn't as simple as a getutcdate() and getdate() difference because the difference changes depending on what the date is.
CLR integration isn't an option for me either.
The solution that I had come up with for this problem a few months back was to ... | Create two tables and then join to them to convert stored GMT dates to local time:
```
TimeZones e.g.
--------- ----
TimeZoneId 19
Name Eastern (GMT -5)
Offset -5
```
Create the daylight savings table and populate it with as much information as you can (local laws change all the time so th... |
24,816 | <p>Does anyone know of an easy way to escape HTML from strings in <a href="http://jquery.com/" rel="noreferrer">jQuery</a>? I need to be able to pass an arbitrary string and have it properly escaped for display in an HTML page (preventing JavaScript/HTML injection attacks). I'm sure it's possible to extend jQuery to ... | [
{
"answer_id": 24870,
"author": "tghw",
"author_id": 2363,
"author_profile": "https://Stackoverflow.com/users/2363",
"pm_score": 6,
"selected": false,
"text": "<p>If you're escaping for HTML, there are only three that I can think of that would be really necessary:</p>\n\n<pre><code>html.... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657/"
] | Does anyone know of an easy way to escape HTML from strings in [jQuery](http://jquery.com/)? I need to be able to pass an arbitrary string and have it properly escaped for display in an HTML page (preventing JavaScript/HTML injection attacks). I'm sure it's possible to extend jQuery to do this, but I don't know enough ... | Since you're using [jQuery](https://jquery.com/), you can just set the element's [`text`](http://api.jquery.com/text/) property:
```
// before:
// <div class="someClass">text</div>
var someHtmlString = "<script>alert('hi!');</script>";
// set a DIV's text:
$("div.someClass").text(someHtmlString);
// after:
// <div c... |
24,821 | <p>This problem started <a href="http://forums.asp.net/t/1304033.aspx" rel="nofollow noreferrer">on a different board</a>, but <a href="https://stackoverflow.com/users/60/dave-ward">Dave Ward</a>, who was very prompt and helpful there is also here, so I'd like to pick up here for hopefully the last remaining piece of t... | [
{
"answer_id": 25031,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know that you can force buffering - but a reverse proxy server between you and the server would affect buffe... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1953/"
] | This problem started [on a different board](http://forums.asp.net/t/1304033.aspx), but [Dave Ward](https://stackoverflow.com/users/60/dave-ward), who was very prompt and helpful there is also here, so I'd like to pick up here for hopefully the last remaining piece of the puzzle.... | Hey, Jason. Sorry you're still having trouble with this.
What I would do is set up a simple page like:
```
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
Response.Write(i + "<br />");
Response.Flush();
Thread.Sleep(1000);
}
}
```
As we discussed before, ma... |
24,829 | <pre><code>public class MyClass
{
public int Age;
public int ID;
}
public void MyMethod()
{
MyClass m = new MyClass();
int newID;
}
</code></pre>
<p>To my understanding, the following is true:</p>
<ol>
<li>The reference m lives on the stack and goes out of scope when MyMethod() exits.</li>
<li>The v... | [
{
"answer_id": 24832,
"author": "Patrick",
"author_id": 429,
"author_profile": "https://Stackoverflow.com/users/429",
"pm_score": 2,
"selected": false,
"text": "<ol>\n<li>Any references or value types that an object own live in the heap.</li>\n<li>Only if you're casting ints to Objects.<... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1880/"
] | ```
public class MyClass
{
public int Age;
public int ID;
}
public void MyMethod()
{
MyClass m = new MyClass();
int newID;
}
```
To my understanding, the following is true:
1. The reference m lives on the stack and goes out of scope when MyMethod() exits.
2. The value type newID lives on the stack ... | Value-type values for a class *have* to live together with the object instance in the managed heap. The thread's stack for a method only lives for the duration of a method; how can the value persist if it only exists within that stack?
A class' object size in the managed heap is the sum of its value-type fields, refer... |
24,849 | <p>Is there any JavaScript method similar to the jQuery <code>delay()</code> or <code>wait()</code> (to delay the execution of a script for a specific amount of time)?</p>
| [
{
"answer_id": 24850,
"author": "Patrick",
"author_id": 429,
"author_profile": "https://Stackoverflow.com/users/429",
"pm_score": 4,
"selected": false,
"text": "<p>You need to use <a href=\"http://www.w3schools.com/jsref/met_win_settimeout.asp\" rel=\"noreferrer\">setTimeout</a> and pass... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184/"
] | Is there any JavaScript method similar to the jQuery `delay()` or `wait()` (to delay the execution of a script for a specific amount of time)? | There is the following:
```
setTimeout(function, milliseconds);
```
function which can be passed the time after which the function will be executed.
See: [Window `setTimeout()` Method](https://www.w3schools.com/jsref/met_win_settimeout.asp). |
24,853 | <p>In C, what is the difference between using <code>++i</code> and <code>i++</code>, and which should be used in the incrementation block of a <code>for</code> loop?</p>
| [
{
"answer_id": 24856,
"author": "Ryan Fox",
"author_id": 55,
"author_profile": "https://Stackoverflow.com/users/55",
"pm_score": 6,
"selected": false,
"text": "<p><code>++i</code> increments the value, then returns it.</p>\n\n<p><code>i++</code> returns the value, and then increments it.... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | In C, what is the difference between using `++i` and `i++`, and which should be used in the incrementation block of a `for` loop? | * `++i` will increment the value of `i`, and then return the incremented value.
```
i = 1;
j = ++i;
(i is 2, j is 2)
```
* `i++` will increment the value of `i`, but return the original value that `i` held before being incremented.
```
i = 1;
j = i++;
(i is 2, j is 1)
```
For a `for` loop, either works. `++i... |
24,881 | <p>I'm trying to solve <a href="http://uva.onlinejudge.org/external/1/100.pdf" rel="noreferrer">the 3n+1 problem</a> and I have a <code>for</code> loop that looks like this: </p>
<pre><code>for(int i = low; i <= high; ++i)
{
res = runalg(i);
if (res > highestres)
... | [
{
"answer_id": 24882,
"author": "OysterD",
"author_id": 2638,
"author_profile": "https://Stackoverflow.com/users/2638",
"pm_score": 8,
"selected": true,
"text": "<p>I'd try to declare <code>i</code> outside of the loop!</p>\n\n<p>Good luck on solving 3n+1 :-)</p>\n\n<p>Here's an example:... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I'm trying to solve [the 3n+1 problem](http://uva.onlinejudge.org/external/1/100.pdf) and I have a `for` loop that looks like this:
```
for(int i = low; i <= high; ++i)
{
res = runalg(i);
if (res > highestres)
{
highestres = res;
... | I'd try to declare `i` outside of the loop!
Good luck on solving 3n+1 :-)
Here's an example:
```c
#include <stdio.h>
int main() {
int i;
/* for loop execution */
for (i = 10; i < 20; i++) {
printf("i: %d\n", i);
}
return 0;
}
```
Read more on for loops in C [here](https://www.tutorial... |
24,886 | <p>Is there a performance difference between <code>i++</code> and <code>++i</code> if the resulting value is not used?</p>
| [
{
"answer_id": 24887,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 10,
"selected": true,
"text": "<p>Executive summary: No.</p>\n\n<p><code>i++</code> could potentially be slower than <code>++i</code>, since the old va... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | Is there a performance difference between `i++` and `++i` if the resulting value is not used? | Executive summary: No.
`i++` could potentially be slower than `++i`, since the old value of `i`
might need to be saved for later use, but in practice all modern
compilers will optimize this away.
We can demonstrate this by looking at the code for this function,
both with `++i` and `i++`.
```
$ cat i++.c
extern void ... |
24,891 | <p>I've always heard that in C you have to really watch how you manage memory. And I'm still beginning to learn C, but thus far, I have not had to do any memory managing related activities at all.. I always imagined having to release variables and do all sorts of ugly things. But this doesn't seem to be the case.</p>
... | [
{
"answer_id": 24893,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "<p>You have to do \"memory management\" when you want to use memory on the heap rather than the stack. If you don't know ho... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I've always heard that in C you have to really watch how you manage memory. And I'm still beginning to learn C, but thus far, I have not had to do any memory managing related activities at all.. I always imagined having to release variables and do all sorts of ugly things. But this doesn't seem to be the case.
Can som... | There are two places where variables can be put in memory. When you create a variable like this:
```
int a;
char c;
char d[16];
```
The variables are created in the "**stack**". Stack variables are automatically freed when they go out of scope (that is, when the code can't reach them anymore). You might hear them c... |
24,901 | <p>We have the question <a href="/q/24886">is there a performance difference between <code>i++</code> and <code>++i</code> <strong>in C</strong>?</a></p>
<p>What's the answer for C++?</p>
| [
{
"answer_id": 24904,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 10,
"selected": true,
"text": "<p>[Executive Summary: Use <code>++i</code> if you don't have a specific reason to use <code>i++</code>.]</p>\n\n<p>For C... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | We have the question [is there a performance difference between `i++` and `++i` **in C**?](/q/24886)
What's the answer for C++? | [Executive Summary: Use `++i` if you don't have a specific reason to use `i++`.]
For C++, the answer is a bit more complicated.
If `i` is a simple type (not an instance of a C++ class), [then the answer given for C ("No there is no performance difference")](https://stackoverflow.com/a/24887/194894) holds, since the c... |
24,915 | <p>My colleagues are attempting to connect BizTalk 2006 R2 via DB2/MVS adapter to a database hosted on z/OS mainframe. When testing the connecting settings, they are getting the following error</p>
<pre><code>Could not connect to data source 'New Data Source':
The network connection was terminated because the host fai... | [
{
"answer_id": 24925,
"author": "Sean Kearon",
"author_id": 2608,
"author_profile": "https://Stackoverflow.com/users/2608",
"pm_score": 0,
"selected": false,
"text": "<p>I've never used this adapter but myself, so I'm guessing, but maybe it's to do with the account that BizTalk is using ... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2663/"
] | My colleagues are attempting to connect BizTalk 2006 R2 via DB2/MVS adapter to a database hosted on z/OS mainframe. When testing the connecting settings, they are getting the following error
```
Could not connect to data source 'New Data Source':
The network connection was terminated because the host failed to send an... | Why, it certainly took Microsoft long enough to explicitly confirm this:
**proxy connections via DB2Connect is not supported by BizTalk DB2 Adapter**
Since our customer's policy is to only access DB2 databases via DB2Connect, the adapter is out of the question.
**MORE BACKGROUND INFO**
The reason why the DB2 Adapte... |
24,929 | <p>What is the difference between the <code>EXISTS</code> and <code>IN</code> clause in SQL?</p>
<p>When should we use <code>EXISTS</code>, and when should we use <code>IN</code>?</p>
| [
{
"answer_id": 24930,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 6,
"selected": false,
"text": "<p>I'm assuming you know what they do, and thus are used differently, so I'm going to understand your question as: Whe... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2528/"
] | What is the difference between the `EXISTS` and `IN` clause in SQL?
When should we use `EXISTS`, and when should we use `IN`? | The `exists` keyword can be used in that way, but really it's intended as a way to avoid counting:
```sql
--this statement needs to check the entire table
select count(*) from [table] where ...
--this statement is true as soon as one match is found
exists ( select * from [table] where ... )
```
This is most useful ... |
24,931 | <ol>
<li>Is it possible to capture Python interpreter's output from a Python script?</li>
<li>Is it possible to capture Windows CMD's output from a Python script?</li>
</ol>
<p>If so, which librar(y|ies) should I look into?</p>
| [
{
"answer_id": 24939,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "<p>In which context are you asking?</p>\n\n<p>Are you trying to capture the output from a program you start on the com... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1670/"
] | 1. Is it possible to capture Python interpreter's output from a Python script?
2. Is it possible to capture Windows CMD's output from a Python script?
If so, which librar(y|ies) should I look into? | If you are talking about the python interpreter or CMD.exe that is the 'parent' of your script then no, it isn't possible. In every POSIX-like system (now you're running Windows, it seems, and that might have some quirk I don't know about, YMMV) each process has three streams, standard input, standard output and standa... |
24,941 | <p>I am using <a href="http://www.simpletest.org/" rel="nofollow noreferrer">Simpletest</a> as my unit test framework for the PHP site I am currently working on. I like the fact that it is shipped with a simple HTML reporter, but I would like a bit more advanced reporter.</p>
<p>I have read the reporter API documentat... | [
{
"answer_id": 24939,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "<p>In which context are you asking?</p>\n\n<p>Are you trying to capture the output from a program you start on the com... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/276/"
] | I am using [Simpletest](http://www.simpletest.org/) as my unit test framework for the PHP site I am currently working on. I like the fact that it is shipped with a simple HTML reporter, but I would like a bit more advanced reporter.
I have read the reporter API documentation, but it would be nice to be able to use an ... | If you are talking about the python interpreter or CMD.exe that is the 'parent' of your script then no, it isn't possible. In every POSIX-like system (now you're running Windows, it seems, and that might have some quirk I don't know about, YMMV) each process has three streams, standard input, standard output and standa... |
24,954 | <p>How to determine the applications associated with a particular extension (e.g. .JPG) and then determine where the executable to that application is located so that it can be launched via a call to say System.Diagnostics.Process.Start(...).</p>
<p>I already know how to read and write to the registry. It is the layo... | [
{
"answer_id": 24956,
"author": "Erik Öjebo",
"author_id": 276,
"author_profile": "https://Stackoverflow.com/users/276",
"pm_score": -1,
"selected": false,
"text": "<p>The file type associations are stored in the Windows registry, so you should be able to use the <a href=\"http://msdn.mi... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669/"
] | How to determine the applications associated with a particular extension (e.g. .JPG) and then determine where the executable to that application is located so that it can be launched via a call to say System.Diagnostics.Process.Start(...).
I already know how to read and write to the registry. It is the layout of the r... | Sample code:
```
using System;
using Microsoft.Win32;
namespace GetAssociatedApp
{
class Program
{
static void Main(string[] args)
{
const string extPathTemplate = @"HKEY_CLASSES_ROOT\{0}";
const string cmdPathTemplate = @"HKEY_CLASSES_ROOT\{0}\shell\open\command";
... |
24,991 | <p>I have defined a Java function:</p>
<pre><code>static <T> List<T> createEmptyList() {
return new ArrayList<T>();
}
</code></pre>
<p>One way to call it is like so:</p>
<pre><code>List<Integer> myList = createEmptyList(); // Compiles
</code></pre>
<p>Why can't I call it by explicitly pa... | [
{
"answer_id": 24997,
"author": "Cheekysoft",
"author_id": 1820,
"author_profile": "https://Stackoverflow.com/users/1820",
"pm_score": 5,
"selected": false,
"text": "<p>You can, if you pass in the type as a method parameter.</p>\n\n<pre><code>static <T> List<T> createEmptyLis... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/755/"
] | I have defined a Java function:
```
static <T> List<T> createEmptyList() {
return new ArrayList<T>();
}
```
One way to call it is like so:
```
List<Integer> myList = createEmptyList(); // Compiles
```
Why can't I call it by explicitly passing the generic type argument? :
```
Object myObject = createEmtpyList... | When the java compiler cannot infer the parameter type by itself for a static method, you can always pass it using the full qualified method name: Class . < Type > method();
```
Object list = Collections.<String> emptyList();
``` |
24,993 | <p>I have a WCF Web Service which is referenced from a class library. After the project is run, when creating the service client object from inside a class library, I receive an InvalidOperationException with message:</p>
<blockquote>
<p>Could not find default endpoint element that references contract
'MyServiceRe... | [
{
"answer_id": 25004,
"author": "Richard Morgan",
"author_id": 2258,
"author_profile": "https://Stackoverflow.com/users/2258",
"pm_score": 0,
"selected": false,
"text": "<p>It would probably help if you posted your app.config file, since this kind of error tends to point to a problem in ... | 2008/08/24 | [
"https://Stackoverflow.com/questions/24993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | I have a WCF Web Service which is referenced from a class library. After the project is run, when creating the service client object from inside a class library, I receive an InvalidOperationException with message:
>
> Could not find default endpoint element that references contract
> 'MyServiceReference.IMyService'... | >
> Here is my app.config file of the class library:
>
>
>
You should put this configuration settings to main app's config file. .NET application (which is calling your class library) uses data from it's own config file not from your library config file. |
25,007 | <p>What's the easiest way to convert a percentage to a color ranging from Green (100%) to Red (0%), with Yellow for 50%?</p>
<p>I'm using plain 32bit RGB - so each component is an integer between 0 and 255. I'm doing this in C#, but I guess for a problem like this the language doesn't really matter that much.</p>
<p>... | [
{
"answer_id": 25012,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 1,
"selected": false,
"text": "<p>As yellow is a mix of red and green, you can probably start with <code>#F00</code> and then slide green up until yo... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199387/"
] | What's the easiest way to convert a percentage to a color ranging from Green (100%) to Red (0%), with Yellow for 50%?
I'm using plain 32bit RGB - so each component is an integer between 0 and 255. I'm doing this in C#, but I guess for a problem like this the language doesn't really matter that much.
Based on Marius a... | I made this function in JavaScript. It returns the color is a css string. It takes the percentage as a variable, with a range from 0 to 100. The algorithm could be made in any language:
```
function setColor(p){
var red = p<50 ? 255 : Math.round(256 - (p-50)*5.12);
var green = p>50 ? 255 : Math.round((p)*5.12)... |
25,033 | <p>I am using the code snippet below, however it's not working quite as I understand it should. </p>
<pre><code>public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
try {
line = br.readLine();
while(line != null)... | [
{
"answer_id": 25036,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>No input is not the same as the end of the stream. You can usually simulate the end of the stream in a console by p... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2628/"
] | I am using the code snippet below, however it's not working quite as I understand it should.
```
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
try {
line = br.readLine();
while(line != null) {
Sy... | >
> From my understanding of this, readLine should return null the first time no input is entered other than a line termination, like '\r'.
>
>
>
That is not correct. `readLine` will return `null` if the end of the stream is reached. That is, for example, if you are reading a file, and the file ends, or if you're ... |
25,041 | <p>Using CSS,</p>
<p>I'm trying to specify the height of a <code>span</code> tag in Firefox, but it's just not accepting it (IE does).</p>
<p>Firefox accepts the <code>height</code> if I use a <code>div</code>, but the problem with using a <code>div</code> is the annoying line break after it, which I can't have in th... | [
{
"answer_id": 25045,
"author": "Cade",
"author_id": 565,
"author_profile": "https://Stackoverflow.com/users/565",
"pm_score": 2,
"selected": false,
"text": "<p>Since you're displaying it inline, the height should be set at the height of your line-height attribute.</p>\n\n<p>Depending on... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1693/"
] | Using CSS,
I'm trying to specify the height of a `span` tag in Firefox, but it's just not accepting it (IE does).
Firefox accepts the `height` if I use a `div`, but the problem with using a `div` is the annoying line break after it, which I can't have in this particular instance.
I tried setting the CSS style attri... | ```
<style>
#div1 { float:left; height:20px; width:20px; }
#div2 { float:left; height:30px; width:30px }
</style>
<div id="div1">FirstDiv</div>
<div id="div2">SecondDiv</div>
```
As long as the container for whatever is holding `div's` 1 and 2 is wide enough for them to fit, this should be fine. |
25,046 | <p>I've just started learning Lisp and I can't figure out how to compile and link lisp code to an executable.</p>
<p>I'm using <code>clisp</code> and <code>clisp -c</code> produces two files:</p>
<ul>
<li>.fas</li>
<li>.lib</li>
</ul>
<p>What do I do next to get an executable?</p>
| [
{
"answer_id": 25057,
"author": "Patrik Svensson",
"author_id": 936,
"author_profile": "https://Stackoverflow.com/users/936",
"pm_score": 4,
"selected": false,
"text": "<p>Take a look at the the official clisp homepage. There is a FAQ that answers this question.</p>\n\n<p><a href=\"http:... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2450/"
] | I've just started learning Lisp and I can't figure out how to compile and link lisp code to an executable.
I'm using `clisp` and `clisp -c` produces two files:
* .fas
* .lib
What do I do next to get an executable? | I was actually trying to do this today, and I found typing this into the CLisp REPL worked:
```
(EXT:SAVEINITMEM "executable.exe"
:QUIET t
:INIT-FUNCTION 'main
:EXECUTABLE t
:NORC t)
```
where main is the name of the function you want to call when t... |
25,116 | <p>In Python you can use <a href="https://docs.python.org/library/struct.html" rel="noreferrer">StringIO</a> for a file-like buffer for character data. <a href="https://docs.python.org/library/mmap.html" rel="noreferrer">Memory-mapped file</a> basically does similar thing for binary data, but it requires a file that is... | [
{
"answer_id": 25123,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 2,
"selected": false,
"text": "<p>Look at the struct package: <a href=\"https://docs.python.org/library/struct.html\" rel=\"nofollow noreferrer\">https://do... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679/"
] | In Python you can use [StringIO](https://docs.python.org/library/struct.html) for a file-like buffer for character data. [Memory-mapped file](https://docs.python.org/library/mmap.html) basically does similar thing for binary data, but it requires a file that is used as the basis. Does Python have a file object that is ... | You are probably looking for [io.BytesIO](http://docs.python.org/release/3.1.3/library/io.html#binary-i-o) class. It works exactly like StringIO except that it supports binary data:
```
from io import BytesIO
bio = BytesIO(b"some initial binary data: \x00\x01")
```
StringIO will throw TypeError:
```
from io import ... |
25,128 | <p>Is it possible to create images with PHP (as opposed to simply linking to them via HTML) and if so, where should I go first to learn about such a thing?</p>
| [
{
"answer_id": 25131,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "<p>Yes this is possible. I believe there are multiple libraries to accomplish this. The most widely used is probably <... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | Is it possible to create images with PHP (as opposed to simply linking to them via HTML) and if so, where should I go first to learn about such a thing? | I prefer the [GD library](http://www.php.net/gd) - check out [the Examples](http://www.php.net/manual/en/image.examples.php), and this example:
```
<?php
header ("Content-type: image/png");
$im = @imagecreatetruecolor(120, 20)
or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im,... |
25,147 | <p>I have two arrays of animals (for example).</p>
<pre><code>$array = array(
array(
'id' => 1,
'name' => 'Cat',
),
array(
'id' => 2,
'name' => 'Mouse',
)
);
$array2 = array(
array(
'id' => 2,
'age' => 321,
),
array(
... | [
{
"answer_id": 25155,
"author": "Erik van Brakel",
"author_id": 909,
"author_profile": "https://Stackoverflow.com/users/909",
"pm_score": 2,
"selected": false,
"text": "<p>First off, why don't you use the ID as the index (or key, in the mapping-style array that php arrays are imo)?</p>\n... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2118/"
] | I have two arrays of animals (for example).
```
$array = array(
array(
'id' => 1,
'name' => 'Cat',
),
array(
'id' => 2,
'name' => 'Mouse',
)
);
$array2 = array(
array(
'id' => 2,
'age' => 321,
),
array(
'id' => 1,
'age' => 123... | This does what Erik suggested (id no. as array key) and merges vlaues in `$array2` to `$results`.
```
$results = array();
foreach($array as $subarray)
{
$results[$subarray['id']] = array('name' => $subarray['name']);
}
foreach($array2 as $subarray)
{
if(array_key_exists($subarray['id'], $results))
{
... |
25,158 | <p>I'm rewriting an old application and use this as a good opportunity to try out C# and .NET development (I usually do a lot of plug-in stuff in C).</p>
<p>The application is basically a timer collecting data. It has a start view with a button to start the measurement. During the measurement the app has five differen... | [
{
"answer_id": 25170,
"author": "Adam Haile",
"author_id": 194,
"author_profile": "https://Stackoverflow.com/users/194",
"pm_score": 2,
"selected": false,
"text": "<p>Tabbed forms are usually good... but only if you want the user to be able to see any view at any time... and it sounds li... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2703/"
] | I'm rewriting an old application and use this as a good opportunity to try out C# and .NET development (I usually do a lot of plug-in stuff in C).
The application is basically a timer collecting data. It has a start view with a button to start the measurement. During the measurement the app has five different views de... | Creating a bunch of overlaid panels is a design-time nightmare.
I would suggest using a tab control with each "view" on a separate tab, and then picking the correct tab at runtime. You can avoid showing the tab headers by putting something like this in your form's Load event:
```
tabControl1.Top = tabControl1.Top - t... |
25,161 | <p>I have an image and on it are logos (it's a map), I want to have a little box popup with information about that logo's location when the user moves their mouse over said logo.</p>
<p>Can I do this without using a javascript framework and if so, are there any small libraries/scripts that will let me do such a thing?... | [
{
"answer_id": 25165,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 3,
"selected": false,
"text": "<p>A single image alone doesn't give the browser the semantic information on the logos within. You could use an <a href=... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | I have an image and on it are logos (it's a map), I want to have a little box popup with information about that logo's location when the user moves their mouse over said logo.
Can I do this without using a javascript framework and if so, are there any small libraries/scripts that will let me do such a thing? | Yes, you can do this without Javascript. Use an HTML image map, with title attributes, like this:
```
<img usemap="#logo" src="http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png">
<map name="logo">
<area shape="rect" href="" coords="52,42,121,65" title="Stack">
<area shape="rect" href="" coords="122,42,24... |
25,182 | <p>I'm writing a program that sends an email out at a client's specific local time. I have a .NET method that takes a timezone & time and destination timezone and returns the time in that timezone. So my method is to select every distinct timezone in the database, check if it is the correct time using the method, t... | [
{
"answer_id": 25186,
"author": "Michał Piaskowski",
"author_id": 1534,
"author_profile": "https://Stackoverflow.com/users/1534",
"pm_score": 1,
"selected": false,
"text": "<p>My first guess would be that <pre>SELECT email FROM tClient WHERE timezoneID in (1, 4, 9)</pre> will be faster a... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | I'm writing a program that sends an email out at a client's specific local time. I have a .NET method that takes a timezone & time and destination timezone and returns the time in that timezone. So my method is to select every distinct timezone in the database, check if it is the correct time using the method, then sel... | Hey! These queries are not equivalent.
======================================
Results will be same only if assuming that one email belongs only to the one time zone. Of course it does however SQL engine doesn't know that and tries to remove duplicities. So the first query should be faster.
Always use UNION ALL, unles... |
25,200 | <p>I don't like the AutoSize property of the Label control. I have a custom Label that draws a fancy rounded border among other things. I'm placing a <code>AutoSize = false</code> in my constructor, however, when I place it in design mode, the property always is True. </p>
<p>I have overridden other properties with su... | [
{
"answer_id": 25219,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 2,
"selected": false,
"text": "<p>Your problem could be that you're not actually overriding Autosize in your code (ie, in the same way that you're ov... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2684/"
] | I don't like the AutoSize property of the Label control. I have a custom Label that draws a fancy rounded border among other things. I'm placing a `AutoSize = false` in my constructor, however, when I place it in design mode, the property always is True.
I have overridden other properties with success but this one is... | I've seen similar behaviour when setting certain properties of controls in the constructor of the form itself. They seem to revert back to their design-time defaults.
I notice you're already overriding the OnLoad method. Have you tried setting AutoSize = false there? Or are you mainly concerned with providing a *defau... |
25,224 | <p>I have a postgres database with a user table (userid, firstname, lastname) and a usermetadata table (userid, code, content, created datetime). I store various information about each user in the usermetadata table by code and keep a full history. so for example, a user (userid 15) has the following metadata:</p>
<pr... | [
{
"answer_id": 25248,
"author": "Henrik Gustafsson",
"author_id": 2010,
"author_profile": "https://Stackoverflow.com/users/2010",
"pm_score": 2,
"selected": true,
"text": "<p>I suppose you're not willing to modify your schema, so I'm afraid my answe might not be of much help, but here go... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2462/"
] | I have a postgres database with a user table (userid, firstname, lastname) and a usermetadata table (userid, code, content, created datetime). I store various information about each user in the usermetadata table by code and keep a full history. so for example, a user (userid 15) has the following metadata:
```
15, 'Q... | I suppose you're not willing to modify your schema, so I'm afraid my answe might not be of much help, but here goes...
One possible solution would be to have the time field empty until it was replaced by a newer value, when you insert the 'deprecation date' instead. Another way is to expand the table with an 'active' ... |
25,225 | <p>I have a couple of files containing a value in each line.</p>
<p><strong>EDIT :</strong></p>
<p>I figured out the answer to this question while in the midst of writing the post and didn't realize I had posted it by mistake in its incomplete state.</p>
<p>I was trying to do:</p>
<pre><code>paste -d ',' file1 file... | [
{
"answer_id": 25229,
"author": "sparkes",
"author_id": 269,
"author_profile": "https://Stackoverflow.com/users/269",
"pm_score": 0,
"selected": false,
"text": "<p>you probably need to clarify or retag your question but as it stands the answer is below.</p>\n\n<p>joining two files under ... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1582/"
] | I have a couple of files containing a value in each line.
**EDIT :**
I figured out the answer to this question while in the midst of writing the post and didn't realize I had posted it by mistake in its incomplete state.
I was trying to do:
```
paste -d ',' file1 file2 file 3 file 4 > file5.csv
```
and was gettin... | file 1:
```
1
2
3
```
file2:
```
2
4
6
```
```
paste --delimiters=\; file1 file2
```
Will yield:
```
1;2
3;4
5;6
``` |
25,238 | <blockquote>
<p>What's the best way to make an element of 100% minimum height across a
wide range of browsers ?</p>
</blockquote>
<p>In particular if you have a layout with a <code>header</code> and <code>footer</code> of fixed <code>height</code>,</p>
<p>how do you make the middle content part fill <code>100%</c... | [
{
"answer_id": 25249,
"author": "ollifant",
"author_id": 2078,
"author_profile": "https://Stackoverflow.com/users/2078",
"pm_score": 7,
"selected": false,
"text": "<p>I am using the following one: <a href=\"http://www.xs4all.nl/~peterned/examples/csslayout1.html\" rel=\"noreferrer\">CSS ... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1725/"
] | >
> What's the best way to make an element of 100% minimum height across a
> wide range of browsers ?
>
>
>
In particular if you have a layout with a `header` and `footer` of fixed `height`,
how do you make the middle content part fill `100%` of the space in between with the `footer` fixed to the bottom ? | I am using the following one: [CSS Layout - 100 % height](http://www.xs4all.nl/~peterned/examples/csslayout1.html)
>
> **Min-height**
>
>
> The #container element of this page has a min-height of 100%. That
> way, if the content requires more height than the viewport provides,
> the height of #content forces #con... |
25,240 | <p>FCKeditor has InsertHtml API (<a href="http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/JavaScript_API" rel="nofollow noreferrer">JavaScript API document</a>) that inserts HTML in the current cursor position. How do I insert at the very end of the document?</p>
<p>Do I need to start browser sniffing with so... | [
{
"answer_id": 25291,
"author": "Ryan Doherty",
"author_id": 956,
"author_profile": "https://Stackoverflow.com/users/956",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like you could use a combination of GetHTML and SetHTML to get the current contents, append your html and rein... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2515/"
] | FCKeditor has InsertHtml API ([JavaScript API document](http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/JavaScript_API)) that inserts HTML in the current cursor position. How do I insert at the very end of the document?
Do I need to start browser sniffing with something like this
```
if ( element.insertAdjac... | It looks like you could use a combination of GetHTML and SetHTML to get the current contents, append your html and reinsert everything into the editor. Although it does say
>
> Note that when using this method, you will lose any listener that you may have previously registered on the editor.EditorDocument.
>
>
>
... |
25,259 | <p>What is a good complete <a href="http://en.wikipedia.org/wiki/Regular_expression" rel="noreferrer">regular expression</a> or some other process that would take the title:</p>
<blockquote>
<p>How do you change a title to be part of the URL like Stack Overflow?</p>
</blockquote>
<p>and turn it into </p>
<pre clas... | [
{
"answer_id": 25263,
"author": "Dale Ragan",
"author_id": 1117,
"author_profile": "https://Stackoverflow.com/users/1117",
"pm_score": 4,
"selected": false,
"text": "<p>You will want to setup a custom route to point the <a href=\"http://en.wikipedia.org/wiki/Uniform_Resource_Locator\" re... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] | What is a good complete [regular expression](http://en.wikipedia.org/wiki/Regular_expression) or some other process that would take the title:
>
> How do you change a title to be part of the URL like Stack Overflow?
>
>
>
and turn it into
```none
how-do-you-change-a-title-to-be-part-of-the-url-like-stack-overfl... | Here's how we do it. Note that there are probably more edge conditions than you realize at first glance.
This is the second version, unrolled for 5x more performance (and yes, I benchmarked it). I figured I'd optimize it because this function can be called hundreds of times per page.
```
/// <summary>
/// Produces op... |
25,282 | <p>The point of this question is to collect a list of examples of hashtable implementations using arrays in different languages. It would also be nice if someone could throw in a pretty detailed overview of how they work, and what is happening with each example. </p>
<p><strong>Edit:</strong> </p>
<p>Why not just use... | [
{
"answer_id": 25298,
"author": "Jason Z",
"author_id": 2470,
"author_profile": "https://Stackoverflow.com/users/2470",
"pm_score": 0,
"selected": false,
"text": "<p>I think you need to be a little more specific. There are several variations on hashtables with regards to the following o... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1797/"
] | The point of this question is to collect a list of examples of hashtable implementations using arrays in different languages. It would also be nice if someone could throw in a pretty detailed overview of how they work, and what is happening with each example.
**Edit:**
Why not just use the built in hash functions i... | A hash table a data structure that allows lookup of items in constant time. It works by hashing a value and converting that value to an offset in an array. The concept of a hash table is fairly easy to understand, but implementing is obviously harder. I'm not pasting the whole hash table here, but here are some snippet... |
25,297 | <p>I would like to use <code>as</code> and <code>is</code> as members of an enumeration. I know that this is possible in VB.NET to write it like this:</p>
<pre><code>Public Enum Test
[as] = 1
[is] = 2
End Enum
</code></pre>
<p>How do I write the equivalent statement in C#?
The following code does not compile:... | [
{
"answer_id": 25300,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 6,
"selected": true,
"text": "<p>Prefixing reserved words in C# is done with @.</p>\n\n<pre><code>public enum Test\n{\n @as = 1,\n @is = 2\n}\n</c... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2717/"
] | I would like to use `as` and `is` as members of an enumeration. I know that this is possible in VB.NET to write it like this:
```
Public Enum Test
[as] = 1
[is] = 2
End Enum
```
How do I write the equivalent statement in C#?
The following code does not compile:
```
public enum Test
{
as = 1,
is = 2
... | Prefixing reserved words in C# is done with @.
```
public enum Test
{
@as = 1,
@is = 2
}
``` |
25,349 | <p>I have a string that has some Environment.Newline in it. I'd like to strip those from the string and instead, replace the Newline with something like a comma. </p>
<p>What would be, in your opinion, the best way to do this using C#.NET 2.0?</p>
| [
{
"answer_id": 25350,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 0,
"selected": false,
"text": "<p>The best way is the builtin way: Use <code>string.Replace</code>. Why do you need alternatives?</p>\n"
},
{
... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2684/"
] | I have a string that has some Environment.Newline in it. I'd like to strip those from the string and instead, replace the Newline with something like a comma.
What would be, in your opinion, the best way to do this using C#.NET 2.0? | Why not:
```
string s = "foobar\ngork";
string v = s.Replace(Environment.NewLine,",");
System.Console.WriteLine(v);
``` |
25,449 | <p>I want to create a Java program that can be extended with plugins. How can I do that and where should I look for?</p>
<p>I have a set of interfaces that the plugin must implement, and it should be in a jar. The program should watch for new jars in a relative (to the program) folder and registered them somehow.</p>
... | [
{
"answer_id": 25454,
"author": "John with waffle",
"author_id": 279,
"author_profile": "https://Stackoverflow.com/users/279",
"pm_score": 1,
"selected": false,
"text": "<p>Have you considered building on top of Eclipse's Rich Client Platform, and then exposing the Eclipse extension fram... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] | I want to create a Java program that can be extended with plugins. How can I do that and where should I look for?
I have a set of interfaces that the plugin must implement, and it should be in a jar. The program should watch for new jars in a relative (to the program) folder and registered them somehow.
---
Although... | I've done this for software I've written in the past, it's very handy. I did it by first creating an Interface that all my 'plugin' classes needed to implement. I then used the Java [ClassLoader](http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html) to load those classes and create instances of them.
On... |
25,461 | <p>In a project I am interfacing between C++ and a C library that uses stdbool.h defined as such.</p>
<pre><code>#ifndef _STDBOOL_H
#define _STDBOOL_H
/* C99 Boolean types for compilers without C99 support */
/* http://www.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html */
#if !defined(__cplusplus)
#if !d... | [
{
"answer_id": 25482,
"author": "wilhelmtell",
"author_id": 456,
"author_profile": "https://Stackoverflow.com/users/456",
"pm_score": 2,
"selected": false,
"text": "<p>Size is not the only thing that will be inconsistent here. In C++ bool is a keyword, and C++ guarantees that a bool can... | 2008/08/24 | [
"https://Stackoverflow.com/questions/25461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1675/"
] | In a project I am interfacing between C++ and a C library that uses stdbool.h defined as such.
```
#ifndef _STDBOOL_H
#define _STDBOOL_H
/* C99 Boolean types for compilers without C99 support */
/* http://www.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html */
#if !defined(__cplusplus)
#if !defined(__GNUC_... | I found the answer to my own question by finding a more compatible implementation of `stdbool.h` that is compliant with the C99 standard.
```
#ifndef _STDBOOL_H
#define _STDBOOL_H
#include <stdint.h>
/* C99 Boolean types for compilers without C99 support */
/* http://www.opengroup.org/onlinepubs/009695399/basedefs/s... |
25,481 | <p>I'm trying to call an Antlr task in my Ant build.xml as follows:</p>
<pre><code><path id="classpath.build">
<fileset dir="${dir.lib.build}" includes="**/*.jar" />
</path>
...
<target name="generate-lexer" depends="init">
<antlr target="${file.antlr.lexer}">
<classpath refi... | [
{
"answer_id": 25484,
"author": "James A. Rosen",
"author_id": 1190,
"author_profile": "https://Stackoverflow.com/users/1190",
"pm_score": 3,
"selected": true,
"text": "<p>The current Antlr-task jar is available at <a href=\"http://www.antlr.org/share/1169924912745/antlr3-task.zip\" rel=... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I'm trying to call an Antlr task in my Ant build.xml as follows:
```
<path id="classpath.build">
<fileset dir="${dir.lib.build}" includes="**/*.jar" />
</path>
...
<target name="generate-lexer" depends="init">
<antlr target="${file.antlr.lexer}">
<classpath refid="classpath.build"/>
</antlr>
</target>
```... | The current Antlr-task jar is available at <http://www.antlr.org/share/1169924912745/antlr3-task.zip>
It can be found on the [antlr.org](http://antlr.org) website under the "File Sharing" heading. |
25,499 | <p>I'm using Visual C++ 2005 and would like to know the simplest way to connect to a MS SQL Server and execute a query.</p>
<p>I'm looking for something as simple as ADO.NET's SqlCommand class with it's ExecuteNonQuery(), ExecuteScalar() and ExecuteReader().</p>
<p>Sigh offered an answer using CDatabase and ODBC.</p>... | [
{
"answer_id": 25542,
"author": "Rob Allen",
"author_id": 149,
"author_profile": "https://Stackoverflow.com/users/149",
"pm_score": 0,
"selected": false,
"text": "<p>Try the Microsoft Enterprise Library. A version should be available <a href=\"http://www.codeplex.com/entlib\" rel=\"nofol... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2768/"
] | I'm using Visual C++ 2005 and would like to know the simplest way to connect to a MS SQL Server and execute a query.
I'm looking for something as simple as ADO.NET's SqlCommand class with it's ExecuteNonQuery(), ExecuteScalar() and ExecuteReader().
Sigh offered an answer using CDatabase and ODBC.
Can anybody demonst... | With MFC use CDatabase and ExecuteSQL if going via a ODBC connection.
```
CDatabase db(ODBCConnectionString);
db.Open();
db.ExecuteSQL(blah);
db.Close();
``` |
25,550 | <p>We get a large amount of data from our clients in pdf files in varying formats [layout-wise], these files are typically report output, and are typically properly annotated [they don't usually need OCR], but not formatted well enough that simply copying several hundred pages of text out of acrobat is not going to wor... | [
{
"answer_id": 25565,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Have you looked at Aspose? We're using it for an ASP.net app and I've seen some examples of vbscript using it as well. It's ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775/"
] | We get a large amount of data from our clients in pdf files in varying formats [layout-wise], these files are typically report output, and are typically properly annotated [they don't usually need OCR], but not formatted well enough that simply copying several hundred pages of text out of acrobat is not going to work.
... | We use [Xpdf](http://www.foolabs.com/xpdf/about.html) in one of our applications. Its a c++ library which is primarily used for pdf rendering, although it does have a text extractor which could be useful for this project. |
25,552 | <p>I'm currently building a Java app that could end up being run on many different platforms, but primarily variants of Solaris, Linux and Windows.</p>
<p>Has anyone been able to successfully extract information such as the current disk space used, CPU utilisation and memory used in the underlying OS? What about just ... | [
{
"answer_id": 25583,
"author": "Matt Cummings",
"author_id": 828,
"author_profile": "https://Stackoverflow.com/users/828",
"pm_score": 5,
"selected": false,
"text": "<p>I think the best method out there is to implement the <a href=\"https://github.com/hyperic/sigar\" rel=\"nofollow nore... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1693/"
] | I'm currently building a Java app that could end up being run on many different platforms, but primarily variants of Solaris, Linux and Windows.
Has anyone been able to successfully extract information such as the current disk space used, CPU utilisation and memory used in the underlying OS? What about just what the J... | You can get some limited memory information from the Runtime class. It really isn't exactly what you are looking for, but I thought I would provide it for the sake of completeness. Here is a small example. Edit: You can also get disk usage information from the java.io.File class. The disk space usage stuff requires Jav... |
25,561 | <p>I am attempting to parse a string like the following using a .NET regular expression:</p>
<pre><code>H3Y5NC8E-TGA5B6SB-2NVAQ4E0
</code></pre>
<p>and return the following using Split:
H3Y5NC8E
TGA5B6SB
2NVAQ4E0</p>
<p>I validate each character against a specific character set (note that the letters 'I'... | [
{
"answer_id": 25567,
"author": "Steve M",
"author_id": 1693,
"author_profile": "https://Stackoverflow.com/users/1693",
"pm_score": 0,
"selected": false,
"text": "<p>Why use Regex? If the groups are always split by a -, can't you use Split()?</p>\n"
},
{
"answer_id": 25569,
"... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2754/"
] | I am attempting to parse a string like the following using a .NET regular expression:
```
H3Y5NC8E-TGA5B6SB-2NVAQ4E0
```
and return the following using Split:
H3Y5NC8E
TGA5B6SB
2NVAQ4E0
I validate each character against a specific character set (note that the letters 'I', 'O', 'U' & 'W' are absent), so using str... | I have discovered the answer I was after. Here is my working code:
```
static void Main(string[] args)
{
string pattern = @"^\s*((?<group>[ABCDEFGHJKLMNPQRSTVXYZ0123456789]{8})-?){3}\s*$";
string input = "H3Y5NC8E-TGA5B6SB-2NVAQ4E0";
Regex re = new Regex(pattern);
Match m = re.M... |
25,566 | <p>I wrote an O(n!) sort for my amusement that can't be trivially optimized to run faster without replacing it entirely. [And no, I didn't just randomize the items until they were sorted]. </p>
<p>How might I write an even worse Big-O sort, without just adding extraneous junk that could be pulled out to reduce the t... | [
{
"answer_id": 25572,
"author": "Ryan Fox",
"author_id": 55,
"author_profile": "https://Stackoverflow.com/users/55",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"https://stackoverflow.com/users/13/chris-jester-young\">Chris</a> and I mentioned <a href=\"https://stackoverflow.c... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2775/"
] | I wrote an O(n!) sort for my amusement that can't be trivially optimized to run faster without replacing it entirely. [And no, I didn't just randomize the items until they were sorted].
How might I write an even worse Big-O sort, without just adding extraneous junk that could be pulled out to reduce the time complexi... | There's a (proven!) worst sorting algorithm called [slow sort](http://c2.com/cgi/wiki?SlowSort) that uses the “multiply and surrender” paradigm and runs in exponential time.
While your algorithm is slower, it doesn't progress steadily but instead performs random jumps. Additionally, slow sort's best case is still expo... |
25,637 | <p>Is there a way to shutdown a computer using a built-in Java method?</p>
| [
{
"answer_id": 25644,
"author": "David McGraw",
"author_id": 568,
"author_profile": "https://Stackoverflow.com/users/568",
"pm_score": 8,
"selected": true,
"text": "<p>Create your own function to execute an OS command through the <a href=\"http://www.computerhope.com/shutdown.htm\" rel=\... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2598/"
] | Is there a way to shutdown a computer using a built-in Java method? | Create your own function to execute an OS command through the [command line](http://www.computerhope.com/shutdown.htm)?
For the sake of an example. But know where and why you'd want to use this as others note.
```
public static void main(String arg[]) throws IOException{
Runtime runtime = Runtime.getRuntime();
... |
25,642 | <p>I want to catch the NavigationService.Navigating event from my Page, to prevent the user from navigating forward. I have an event handler defined thusly:</p>
<pre><code>void PreventForwardNavigation(object sender, NavigatingCancelEventArgs e)
{
if (e.NavigationMode == NavigationMode.Forward)
{
e.Can... | [
{
"answer_id": 25644,
"author": "David McGraw",
"author_id": 568,
"author_profile": "https://Stackoverflow.com/users/568",
"pm_score": 8,
"selected": true,
"text": "<p>Create your own function to execute an OS command through the <a href=\"http://www.computerhope.com/shutdown.htm\" rel=\... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615/"
] | I want to catch the NavigationService.Navigating event from my Page, to prevent the user from navigating forward. I have an event handler defined thusly:
```
void PreventForwardNavigation(object sender, NavigatingCancelEventArgs e)
{
if (e.NavigationMode == NavigationMode.Forward)
{
e.Cancel = true;
... | Create your own function to execute an OS command through the [command line](http://www.computerhope.com/shutdown.htm)?
For the sake of an example. But know where and why you'd want to use this as others note.
```
public static void main(String arg[]) throws IOException{
Runtime runtime = Runtime.getRuntime();
... |
25,646 | <p>The following code writes no data to the back buffer on Intel integrated video cards,for example, on a MacBook. On ATI cards, such as in the iMac, it draws to the back buffer. The width and height are correct (and 800x600 buffer) and m_PixelBuffer is correctly filled with 0xAA00AA00.</p>
<p>My best guess so far is ... | [
{
"answer_id": 25864,
"author": "basszero",
"author_id": 287,
"author_profile": "https://Stackoverflow.com/users/287",
"pm_score": 2,
"selected": false,
"text": "<p>I've always had problems with OpenGL implementations from Intel, though I'm not sure that's your problem this time. I think... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1329401/"
] | The following code writes no data to the back buffer on Intel integrated video cards,for example, on a MacBook. On ATI cards, such as in the iMac, it draws to the back buffer. The width and height are correct (and 800x600 buffer) and m\_PixelBuffer is correctly filled with 0xAA00AA00.
My best guess so far is that ther... | I've always had problems with OpenGL implementations from Intel, though I'm not sure that's your problem this time. I think you're running into some byte-order issues. Give this a read and feel free to experiment with different constants for packing and color order.
<http://developer.apple.com/documentation/MacOSX/Con... |
25,653 | <p>Is there any way to apply an attribute to a model file in ASP.NET Dynamic Data to hide the column?</p>
<p>For instance, I can currently set the display name of a column like this:</p>
<pre><code>[DisplayName("Last name")]
public object Last_name { get; set; }
</code></pre>
<p>Is there a similar way to hide a colu... | [
{
"answer_id": 25667,
"author": "Christian Hagelid",
"author_id": 202,
"author_profile": "https://Stackoverflow.com/users/202",
"pm_score": 5,
"selected": true,
"text": "<p>Had no idea what ASP.NET Dynamic Data was so you promted me to so some research :)</p>\n\n<p>Looks like the propert... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | Is there any way to apply an attribute to a model file in ASP.NET Dynamic Data to hide the column?
For instance, I can currently set the display name of a column like this:
```
[DisplayName("Last name")]
public object Last_name { get; set; }
```
Is there a similar way to hide a column?
**Edit**: Many thanks to Chr... | Had no idea what ASP.NET Dynamic Data was so you promted me to so some research :)
Looks like the property you are looking for is
```
[ScaffoldColumn(false)]
```
There is also a similar property for tables
```
[ScaffoldTable(false)]
```
[source](http://davidhayden.com/blog/dave/archive/2008/05/15/DynamicDataWeb... |
25,672 | <p>Been going over my predecessor's code and see usage of the "request" scope frequently. What is the appropriate usage of this scope?</p>
| [
{
"answer_id": 26725,
"author": "Adam Tuttle",
"author_id": 751,
"author_profile": "https://Stackoverflow.com/users/751",
"pm_score": 5,
"selected": true,
"text": "<p>There are several scopes that are available to any portion of your code: Session, Client, Cookie, Application, and Reques... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Been going over my predecessor's code and see usage of the "request" scope frequently. What is the appropriate usage of this scope? | There are several scopes that are available to any portion of your code: Session, Client, Cookie, Application, and Request. Some are inadvisable to use in certain ways (i.e. using Request or Application scope inside your Custom Tags or CFC's; this is [coupling](http://en.wikipedia.org/wiki/Coupling_%28computer_science%... |
25,746 | <p>I'm learning objective-C and Cocoa and have come across this statement:</p>
<blockquote>
<p>The Cocoa frameworks expect that global string constants rather than string literals are used for dictionary keys, notification and exception names, and some method parameters that take strings.</p>
</blockquote>
<p>I've ... | [
{
"answer_id": 25750,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 2,
"selected": false,
"text": "<p>Let's use C++, since my Objective C is totally non-existent.</p>\n\n<p>If you stash a string into a constant variable:... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2799/"
] | I'm learning objective-C and Cocoa and have come across this statement:
>
> The Cocoa frameworks expect that global string constants rather than string literals are used for dictionary keys, notification and exception names, and some method parameters that take strings.
>
>
>
I've only worked in higher level lang... | In Objective-C, the syntax `@"foo"` is an **immutable**, **literal** instance of `NSString`. It does not make a constant string from a string literal as Mike assume.
Objective-C compilers typically *do* intern literal strings within compilation units — that is, they coalesce multiple uses of the same literal string — ... |
25,752 | <p>In a drop down list, I need to add spaces in front of the options in the list. I am trying</p>
<pre><code><select>
<option>&#32;&#32;Sample</option>
</select>
</code></pre>
<p>for adding two spaces but it displays no spaces. How can I add spaces before option texts?</p>
| [
{
"answer_id": 25754,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 2,
"selected": false,
"text": "<pre><code>&nbsp;\n</code></pre>\n\n<p>Can you try that? Or is it the same?</p>\n"
},
{
"answer_id": 25758,
"au... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | In a drop down list, I need to add spaces in front of the options in the list. I am trying
```
<select>
<option>  Sample</option>
</select>
```
for adding two spaces but it displays no spaces. How can I add spaces before option texts? | Isn't ` ` the entity for space?
```
<select>
<option> option 1</option>
<option> option 2</option>
</select>
```
Works for me...
### EDIT:
Just checked this out, there *may* be compatibility issues with this in older browsers, but all seems to work fine for me here. Just thought I should let you know a... |
25,767 | <p>What is the quickest way to get a large amount of data (think golf) and the most efficient (think performance) to get a large amount of data from a MySQL database to a session without having to continue doing what I already have:</p>
<pre><code>$sql = "SELECT * FROM users WHERE username='" . mysql_escape_string($_P... | [
{
"answer_id": 25770,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 0,
"selected": false,
"text": "<p>OK, this doesn't answer your question, but doesn't your current code leave you open to SQL Injection?</p>\n<p>I could be ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] | What is the quickest way to get a large amount of data (think golf) and the most efficient (think performance) to get a large amount of data from a MySQL database to a session without having to continue doing what I already have:
```
$sql = "SELECT * FROM users WHERE username='" . mysql_escape_string($_POST['username'... | I came up with this and it appears to work.
```
while($row = mysql_fetch_assoc($result))
{
$_SESSION = array_merge_recursive($_SESSION, $row);
}
``` |
25,771 | <p>How can I insert compilation timestamp information into an executable I build with Visual C++ 2005? I want to be able to output something like this when I execute the program:</p>
<blockquote>
<p>This build XXXX was compiled at dd-mm-yy, hh:mm.</p>
</blockquote>
<p>where date and time reflect the time when the p... | [
{
"answer_id": 25780,
"author": "sparkes",
"author_id": 269,
"author_profile": "https://Stackoverflow.com/users/269",
"pm_score": 3,
"selected": false,
"text": "<pre><code>__DATE__ \n__TIME__\n</code></pre>\n\n<p>are predefined as part of the standards for C99 so should be available to y... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I insert compilation timestamp information into an executable I build with Visual C++ 2005? I want to be able to output something like this when I execute the program:
>
> This build XXXX was compiled at dd-mm-yy, hh:mm.
>
>
>
where date and time reflect the time when the project was built. They should no... | Though not your exact format, **DATE** will be of the format Mmm dd yyyy, while **TIME** will be of the format hh:mm:ss. You can create a string like this and use it in whatever print routine makes sense for you:
```
const char *buildString = "This build XXXX was compiled at " __DATE__ ", " __TIME__ ".";
```
(Note o... |
25,785 | <p>Is there a simple way, in a pretty standard UNIX environment with bash, to run a command to delete all but the most recent X files from a directory?</p>
<p>To give a bit more of a concrete example, imagine some cron job writing out a file (say, a log file or a tar-ed up backup) to a directory every hour. I'd like a... | [
{
"answer_id": 25789,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 7,
"selected": false,
"text": "<p>Remove all but 5 (or whatever number) of the most recent files in a directory.</p>\n\n<pre><code>rm `ls -t | awk 'NR>5'`\n... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] | Is there a simple way, in a pretty standard UNIX environment with bash, to run a command to delete all but the most recent X files from a directory?
To give a bit more of a concrete example, imagine some cron job writing out a file (say, a log file or a tar-ed up backup) to a directory every hour. I'd like a way to ha... | **For Linux** (GNU tools), an efficient & robust way to keep the `n` newest files in the current directory while removing the rest:
```bash
n=5
find . -maxdepth 1 -type f -printf '%T@ %p\0' |
sort -z -nrt ' ' -k1,1 |
sed -z -e "1,${n}d" -e 's/[^ ]* //' |
xargs -0r rm -f
```
---
**For BSD**, `find` doesn't have the... |
25,803 | <p>For a given class I would like to have tracing functionality i.e. I would like to log every method call (method signature and actual parameter values) and every method exit (just the method signature). </p>
<p>How do I accomplish this assuming that: </p>
<ul>
<li>I don't want to use any 3rd party
AOP libraries... | [
{
"answer_id": 25806,
"author": "kokos",
"author_id": 1065,
"author_profile": "https://Stackoverflow.com/users/1065",
"pm_score": -1,
"selected": false,
"text": "<ol>\n<li>Write your own AOP library.</li>\n<li>Use reflection to generate a logging proxy over your instances (not sure if yo... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2800/"
] | For a given class I would like to have tracing functionality i.e. I would like to log every method call (method signature and actual parameter values) and every method exit (just the method signature).
How do I accomplish this assuming that:
* I don't want to use any 3rd party
AOP libraries for C#,
* I don't want t... | C# is not an AOP oriented language. It has some AOP features and you can emulate some others but making AOP with C# is painful.
I looked up for ways to do exactly what you wanted to do and I found no easy way to do it.
As I understand it, this is what you want to do:
```
[Log()]
public void Method1(String name, Int3... |
25,807 | <p>If I have Python code</p>
<pre><code>class A():
pass
class B():
pass
class C(A, B):
pass
</code></pre>
<p>and I have class <code>C</code>, is there a way to iterate through it's super classed (<code>A</code> and <code>B</code>)? Something like pseudocode:</p>
<pre><code>>>> magicGetSuperClass... | [
{
"answer_id": 25815,
"author": "John",
"author_id": 2168,
"author_profile": "https://Stackoverflow.com/users/2168",
"pm_score": 6,
"selected": true,
"text": "<p><code>C.__bases__</code> is an array of the super classes, so you could implement your hypothetical function like so:</p>\n\n<... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679/"
] | If I have Python code
```
class A():
pass
class B():
pass
class C(A, B):
pass
```
and I have class `C`, is there a way to iterate through it's super classed (`A` and `B`)? Something like pseudocode:
```
>>> magicGetSuperClasses(C)
(<type 'A'>, <type 'B'>)
```
One solution seems to be [inspect module](... | `C.__bases__` is an array of the super classes, so you could implement your hypothetical function like so:
```
def magicGetSuperClasses(cls):
return cls.__bases__
```
But I imagine it would be easier to just reference `cls.__bases__` directly in most cases. |
25,841 | <p>How do you get the maximum number of bytes that can be passed to a <code>sendto(..)</code> call for a socket opened as a UDP port?</p>
| [
{
"answer_id": 25853,
"author": "Kristof Provost",
"author_id": 1466,
"author_profile": "https://Stackoverflow.com/users/1466",
"pm_score": 2,
"selected": false,
"text": "<p>As UDP is not connection oriented there's no way to indicate that two packets belong together. As a result you're ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/842/"
] | How do you get the maximum number of bytes that can be passed to a `sendto(..)` call for a socket opened as a UDP port? | Use getsockopt(). [This site](http://www.mkssoftware.com/docs/man3/getsockopt.3.asp) has a good breakdown of the usage and options you can retrieve.
In Windows, you can do:
```
int optlen = sizeof(int);
int optval;
getsockopt(socket, SOL_SOCKET, SO_MAX_MSG_SIZE, (int *)&optval, &optlen);
```
For Linux, according t... |
25,846 | <p>I know that MAC OS X 10.5 comes with Apache installed but I would like to install the latest Apache without touching the OS Defaults incase it causes problems in the future with other udpates. So I have used the details located at: <a href="http://diymacserver.com/installing-apache/compiling-apache-on-leopard/" rel=... | [
{
"answer_id": 25851,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 2,
"selected": false,
"text": "<p>Add this to your ~/.bash_profile which means that your architecture is 64-bit ant you’d like to compile Universal binaries.</... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2196/"
] | I know that MAC OS X 10.5 comes with Apache installed but I would like to install the latest Apache without touching the OS Defaults incase it causes problems in the future with other udpates. So I have used the details located at: <http://diymacserver.com/installing-apache/compiling-apache-on-leopard/> But I'm unsure ... | Add this to your ~/.bash\_profile which means that your architecture is 64-bit ant you’d like to compile Universal binaries.
```
export CFLAGS="-arch x86_64"
``` |
25,871 | <p>We created several custom web parts for SharePoint 2007. They work fine. However whenever they are loaded, we get an error in the event log saying:</p>
<blockquote>
<p>error initializing safe control - Assembly: ...</p>
</blockquote>
<p>The assembly actually loads fine. Additionally, it is correctly listed in th... | [
{
"answer_id": 25882,
"author": "Daniel Pollard",
"author_id": 2758,
"author_profile": "https://Stackoverflow.com/users/2758",
"pm_score": 2,
"selected": false,
"text": "<p>You need to add a safecontrol entry to the web,config file, have a look at the following:</p>\n\n<pre><code><Saf... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We created several custom web parts for SharePoint 2007. They work fine. However whenever they are loaded, we get an error in the event log saying:
>
> error initializing safe control - Assembly: ...
>
>
>
The assembly actually loads fine. Additionally, it is correctly listed in the `web.config` and `GAC`.
Any i... | You need to add a safecontrol entry to the web,config file, have a look at the following:
```
<SafeControls>
<SafeControl
Assembly = "Text"
Namespace = "Text"
Safe = "TRUE" | "FALSE"
TypeName = "Text"/>
...
</SafeControls>
```
<http://msdn.microsoft.com/en-us/library/ms413697.aspx> |
25,914 | <p>I'm trying to setup CruiseControl.net webdashboard at the moment. So far it works nice, but I have a problem with the NAnt Build Timing Report.</p>
<p>Firstly, my current <code>ccnet.config</code> file looks something like this:</p>
<pre><code><project name="bla">
...
<prebuild>
<nant .../>
<... | [
{
"answer_id": 26166,
"author": "Mike Caron",
"author_id": 2836,
"author_profile": "https://Stackoverflow.com/users/2836",
"pm_score": -1,
"selected": false,
"text": "<p>Not a direct answer to your question, but you might want to check out Hudson. It has the benefit of being much easier ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1085/"
] | I'm trying to setup CruiseControl.net webdashboard at the moment. So far it works nice, but I have a problem with the NAnt Build Timing Report.
Firstly, my current `ccnet.config` file looks something like this:
```
<project name="bla">
...
<prebuild>
<nant .../>
</prebuild>
<tasks>
<nant .../>
</tasks>
<publishers>... | Apparently this can be solved by selecting only the first `<buildresults>` node in webdashboard's NAntTiming.xsl. Because each duplicate summary contains the same info this change in `<div id="NAntTimingReport">` section seems to be sufficient:
```
<xsl:variable name="buildresults" select="//build/buildresults[1]" />
... |
25,938 | <p>I need to have a summary field in each page of the report and in page 2 and forward the same summary has to appear at the top of the page. Anyone know how to do this?
Ex:</p>
<pre><code>>
> Page 1
>
> Name Value
> a 1
> b 3
> Total 4
>
> Page 2
> Name Valu... | [
{
"answer_id": 26144,
"author": "Carlton Jenke",
"author_id": 1215,
"author_profile": "https://Stackoverflow.com/users/1215",
"pm_score": 0,
"selected": false,
"text": "<p>I do not understand your question all the way.</p>\n\n<p>If you need an overall summary that is repeated, you would ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1154/"
] | I need to have a summary field in each page of the report and in page 2 and forward the same summary has to appear at the top of the page. Anyone know how to do this?
Ex:
```
>
> Page 1
>
> Name Value
> a 1
> b 3
> Total 4
>
> Page 2
> Name Value
> Total Before 4
> c 5
> d ... | Create a new Running Total Field called, for example "RTotal". In "Field to summarize" select "Value", in "Type of summary" select "sum", under "Evaluate" select "For each record". You can then drag this field into your report to use as the "Total" at the bottom of each page.
You cannot use this running total field in... |
25,969 | <p>I am trying to <code>INSERT INTO</code> a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the <code>SQL</code> engine of the day (<a href="http://en.wikipedia.org/wiki/MySQL" rel="noreferrer">MySQL</a... | [
{
"answer_id": 25971,
"author": "Claude Houle",
"author_id": 244,
"author_profile": "https://Stackoverflow.com/users/244",
"pm_score": 12,
"selected": true,
"text": "<p>Try:</p>\n<pre><code>INSERT INTO table1 ( column1 )\nSELECT col1\nFROM table2 \n</code></pre>\n<p>This is standard... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/244/"
] | I am trying to `INSERT INTO` a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the `SQL` engine of the day ([MySQL](http://en.wikipedia.org/wiki/MySQL), [Oracle](http://en.wikipedia.org/wiki/Oracle_Datab... | Try:
```
INSERT INTO table1 ( column1 )
SELECT col1
FROM table2
```
This is standard ANSI SQL and should work on any DBMS
It definitely works for:
* Oracle
* MS SQL Server
* MySQL
* Postgres
* SQLite v3
* Teradata
* DB2
* Sybase
* Vertica
* HSQLDB
* H2
* AWS RedShift
* SAP HANA
* Google Spanner |
25,975 | <p>The Compact Framework doesn't support Assembly.GetEntryAssembly to determine the launching .exe. So is there another way to get the name of the executing .exe?</p>
<p>EDIT: I found the answer on Peter Foot's blog: <a href="http://peterfoot.net/default.aspx" rel="nofollow noreferrer">http://peterfoot.net/default.asp... | [
{
"answer_id": 25987,
"author": "Timbo",
"author_id": 1810,
"author_profile": "https://Stackoverflow.com/users/1810",
"pm_score": 3,
"selected": true,
"text": "<p>I am not sure whether it works from managed code (or even the compact framework), but in Win32 you can call GetModuleFileName... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1382/"
] | The Compact Framework doesn't support Assembly.GetEntryAssembly to determine the launching .exe. So is there another way to get the name of the executing .exe?
EDIT: I found the answer on Peter Foot's blog: <http://peterfoot.net/default.aspx>
Here is the code:
```
byte[] buffer = new byte[MAX_PATH * 2];
int chars = ... | I am not sure whether it works from managed code (or even the compact framework), but in Win32 you can call GetModuleFileName to find the running exe file.
[MSDN: GetModuleFileName](http://msdn.microsoft.com/en-us/library/ms683197(VS.85).aspx) |
25,982 | <p>Given that my client code knows everything it needs to about the remoting object, what's the simplest way to connect to it?</p>
<p>This is what I'm doing at the moment:</p>
<pre><code>ChannelServices.RegisterChannel(new HttpChannel(), false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(IRemoteS... | [
{
"answer_id": 26307,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>WCF. </p>\n\n<p>I have used IPC before there was a WCF, and believe me, IPC is a bear. And it isn't documented fully/corre... | 2008/08/25 | [
"https://Stackoverflow.com/questions/25982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2373/"
] | Given that my client code knows everything it needs to about the remoting object, what's the simplest way to connect to it?
This is what I'm doing at the moment:
```
ChannelServices.RegisterChannel(new HttpChannel(), false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(IRemoteServer), "RemoteServer... | The first two lines are in the server-side code, for marshaling out the server object, yes?
In that case, yes, the third line is the simplest you can get at client-side.
In addition, you can serve out additional server-side objects from the **MyServerObject** instance, if you include public accessors for them in **IR... |
26,007 | <p>Is there an easy way to iterate over an associative array of this structure in PHP:</p>
<p>The array <code>$searches</code> has a numbered index, with between 4 and 5 associative parts. So I not only need to iterate over <code>$searches[0]</code> through <code>$searches[n]</code>, but also <code>$searches[0]["part0... | [
{
"answer_id": 26013,
"author": "Re0sless",
"author_id": 2098,
"author_profile": "https://Stackoverflow.com/users/2098",
"pm_score": 3,
"selected": false,
"text": "<p>You should be able to use a nested foreach statment</p>\n\n<p>from the <a href=\"http://uk3.php.net/foreach\" rel=\"noref... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] | Is there an easy way to iterate over an associative array of this structure in PHP:
The array `$searches` has a numbered index, with between 4 and 5 associative parts. So I not only need to iterate over `$searches[0]` through `$searches[n]`, but also `$searches[0]["part0"]` through `$searches[n]["partn"]`. The hard pa... | Nest two [`foreach` loops](http://php.net/foreach):
```
foreach ($array as $i => $values) {
print "$i {\n";
foreach ($values as $key => $value) {
print " $key => $value\n";
}
print "}\n";
}
``` |
26,020 | <p>I've done this before in C++ by including sqlite.h but is there a similarly easy way in C#?</p>
| [
{
"answer_id": 26027,
"author": "robintw",
"author_id": 1912,
"author_profile": "https://Stackoverflow.com/users/1912",
"pm_score": 3,
"selected": false,
"text": "<p>There is a list of Sqlite wrappers for .Net at <a href=\"http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers\" rel=\"noref... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2674/"
] | I've done this before in C++ by including sqlite.h but is there a similarly easy way in C#? | [Microsoft.Data.Sqlite](https://www.nuget.org/packages/Microsoft.Data.Sqlite) by Microsoft has over 9000 downloads every day, so I think you are safe using that one.
Example usage from [the documentation](https://learn.microsoft.com/dotnet/standard/data/sqlite/):
```
using (var connection = new SqliteConnection("Data... |
26,021 | <p>For our application, we keep large amounts of data indexed by three integer columns (source, type and time). Loading significant chunks of that data can take some time and we have implemented various measures to reduce the amount of data that has to be searched and loaded for larger queries, such as storing larger g... | [
{
"answer_id": 26046,
"author": "Jeff Atwood",
"author_id": 1,
"author_profile": "https://Stackoverflow.com/users/1",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>This made me wonder if the performance impact of disk I/O is actually much heavier than I thought.</p>\n</blo... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | For our application, we keep large amounts of data indexed by three integer columns (source, type and time). Loading significant chunks of that data can take some time and we have implemented various measures to reduce the amount of data that has to be searched and loaded for larger queries, such as storing larger gran... | >
> This made me wonder if the performance impact of disk I/O is actually much heavier than I thought.
>
>
>
Definitely. If you have to go to disk, the performance hit is many orders of magnitude greater than memory. This reminds me of the classic Jim Gray paper, [Distributed Computing Economics](http://research.m... |
26,062 | <p>I have an Access database in which I drop the table and then create the table afresh. However, I need to be able to test for the table in case the table gets dropped but not created (i.e. when someone stops the DTS package just after it starts -roll-eyes- ). If I were doing this in the SQL database I would just do... | [
{
"answer_id": 26045,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 2,
"selected": false,
"text": "<p>I would reccomend sticking to what you know - PHP is more than capable.</p>\n\n<p>I used to play a game called <a href=\"http... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730/"
] | I have an Access database in which I drop the table and then create the table afresh. However, I need to be able to test for the table in case the table gets dropped but not created (i.e. when someone stops the DTS package just after it starts -roll-eyes- ). If I were doing this in the SQL database I would just do:
``... | >
> I would reccomend sticking to what you know - PHP is more than capable.
>
>
>
That's true of course, but:
>
> I don't mind, and I would even like to use this as an excuse, learning some new thing like Python or Ruby.
>
>
>
Then writing a browser game is an excellent opportunity to do this. Learning somet... |