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 |
|---|---|---|---|---|---|---|
8,800 | <p>So I've been poking around with C# a bit lately, and all the Generic Collections have me a little confused. Say I wanted to represent a data structure where the head of a tree was a key value pair, and then there is one optional list of key value pairs below that (but no more levels than these). Would this be suitab... | [
{
"answer_id": 8811,
"author": "Adam Haile",
"author_id": 194,
"author_profile": "https://Stackoverflow.com/users/194",
"pm_score": 8,
"selected": true,
"text": "<p>There is an actual Data Type called KeyValuePair, use like this</p>\n\n<pre><code>KeyValuePair<string, string> myKeyV... | 2008/08/12 | [
"https://Stackoverflow.com/questions/8800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61/"
] | So I've been poking around with C# a bit lately, and all the Generic Collections have me a little confused. Say I wanted to represent a data structure where the head of a tree was a key value pair, and then there is one optional list of key value pairs below that (but no more levels than these). Would this be suitable?... | There is an actual Data Type called KeyValuePair, use like this
```
KeyValuePair<string, string> myKeyValuePair = new KeyValuePair<string,string>("defaultkey", "defaultvalue");
``` |
8,832 | <p>I hope I can explain this clearly enough, but if not let me know and I'll try to clarify.</p>
<p>I'm currently developing a site using ColdFusion and have a mod_rewrite rule in place to make it look like the site is using PHP. Any requests for index.php get processed by index.cfm (the rule maps *.php to *.cfm).</p>... | [
{
"answer_id": 8861,
"author": "jj33",
"author_id": 430,
"author_profile": "https://Stackoverflow.com/users/430",
"pm_score": 0,
"selected": false,
"text": "<p>Post the rules you already have as a starting point so people don't have to recreate it to help you.</p>\n\n<p>I would suggest t... | 2008/08/12 | [
"https://Stackoverflow.com/questions/8832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1025/"
] | I hope I can explain this clearly enough, but if not let me know and I'll try to clarify.
I'm currently developing a site using ColdFusion and have a mod\_rewrite rule in place to make it look like the site is using PHP. Any requests for index.php get processed by index.cfm (the rule maps \*.php to \*.cfm).
This work... | You can use the `S` flag to skip the `404` rule, like this:
```
RewriteEngine on
# Do not separate these two rules so long as the first has S=1
RewriteRule (.*)\.php$ $1.cfm [S=1]
RewriteRule \.cfm$ - [R=404]
```
If you are also using the `Alias` option then you should also add the `PT` flag. See the [mod\_rewrite ... |
8,880 | <p>Using the Windows API, how can I get a list of domains on my network?</p>
| [
{
"answer_id": 8881,
"author": "JosephStyons",
"author_id": 672,
"author_profile": "https://Stackoverflow.com/users/672",
"pm_score": 2,
"selected": false,
"text": "<p>Answered my own question:</p>\n\n<p>Use the <a href=\"http://msdn.microsoft.com/en-us/library/aa370623(VS.85).aspx\" rel... | 2008/08/12 | [
"https://Stackoverflow.com/questions/8880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | Using the Windows API, how can I get a list of domains on my network? | You will need to use some LDAP queries
Here is some code I have used in a previous script (it was taken off the net somewhere, and I've left in the copyright notices)
-------------------------------------------------------------------------------------------------------------------------------
```
' This VBScript cod... |
8,941 | <p><strong>Is there a way to enforce/limit the types that are passed to primitives?</strong> <em>(bool, int, string, etc.)</em></p>
<p>Now, I know you can limit the generic type parameter to a type or interface implementation via the <em>where</em> clause. However, this doesn't fit the bill for primitives (AFAIK) becau... | [
{
"answer_id": 8945,
"author": "Lars Mæhlum",
"author_id": 960,
"author_profile": "https://Stackoverflow.com/users/960",
"pm_score": 6,
"selected": false,
"text": "<pre><code>public class Class1<GenericType> where GenericType : struct\n{\n}\n</code></pre>\n\n<p>This one seemed to d... | 2008/08/12 | [
"https://Stackoverflow.com/questions/8941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] | **Is there a way to enforce/limit the types that are passed to primitives?** *(bool, int, string, etc.)*
Now, I know you can limit the generic type parameter to a type or interface implementation via the *where* clause. However, this doesn't fit the bill for primitives (AFAIK) because they do not all have a common gro... | Primitives appear to be specified in the [`TypeCode`](http://msdn.microsoft.com/en-us/library/system.typecode.aspx) enumeration:
Perhaps there is a way to find out if an object contains the `TypeCode enum` without having to cast it to an specific object or call `GetType()` or `typeof()`?
**Update** It was right under... |
8,948 | <p>Is there a maintained package I can use to retrieve and set MP3 ID3 metadata using Python?</p>
| [
{
"answer_id": 8974,
"author": "PabloG",
"author_id": 394,
"author_profile": "https://Stackoverflow.com/users/394",
"pm_score": 3,
"selected": false,
"text": "<p>A simple example from the book Dive Into Python works ok for me, <a href=\"http://www.diveintopython.org/download/diveintopyth... | 2008/08/12 | [
"https://Stackoverflow.com/questions/8948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145/"
] | Is there a maintained package I can use to retrieve and set MP3 ID3 metadata using Python? | I used [eyeD3](http://eyed3.nicfit.net/) the other day with a lot of success. I found that it could add artwork to the ID3 tag which the other modules I looked at couldn't. You'll have to install using pip or download the tar and execute `python setup.py install` from the source folder.
Relevant examples from the web... |
8,966 | <p>I want to implement a paperless filing system and was looking to use WIA with C# for the image acquisition. There are quite a few sample projects on CodeProject, etc. However, after downloading every one of them that I can find, I have run into a problem.</p>
<p>In each and every one of them, the reference to WIALi... | [
{
"answer_id": 9026,
"author": "J Wynia",
"author_id": 1124,
"author_profile": "https://Stackoverflow.com/users/1124",
"pm_score": 0,
"selected": false,
"text": "<p>It doesn't <strong>need</strong> to be WIA. I was mostly looking at the WIA setup because it offers the same basic interfac... | 2008/08/12 | [
"https://Stackoverflow.com/questions/8966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1124/"
] | I want to implement a paperless filing system and was looking to use WIA with C# for the image acquisition. There are quite a few sample projects on CodeProject, etc. However, after downloading every one of them that I can find, I have run into a problem.
In each and every one of them, the reference to WIALib is broke... | To access WIA, you'll need to add a reference to the COM library, "Microsoft Windows Image Acquisition Library v2.0" (wiaaut.dll).
add a "using WIA;"
```
const string wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}";
CommonDialogClass wiaDiag = new CommonDialogClass();
WIA.ImageFile wiaImage = null;
wiaImage ... |
8,970 | <p>Is it possible to access the iSight camera on a macbook programmatically? By this I mean I would like to be able to just grab still frames from the iSight camera on command and then do something with them. If so, is it only accessible using objective c, or could other languages be used as well? </p>
| [
{
"answer_id": 8977,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 2,
"selected": false,
"text": "<p>I don't have a Mac here, but there is some Documentation up here:</p>\n\n<p><a href=\"http://developer.apple.com/documenta... | 2008/08/12 | [
"https://Stackoverflow.com/questions/8970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | Is it possible to access the iSight camera on a macbook programmatically? By this I mean I would like to be able to just grab still frames from the iSight camera on command and then do something with them. If so, is it only accessible using objective c, or could other languages be used as well? | You should check out the [QTKit Capture documentation](http://developer.apple.com/documentation/QuickTime/Conceptual/QTKitCaptureProgrammingGuide/Introduction/chapter_1_section_1.html#//apple_ref/doc/uid/TP40004574-CH1-DontLinkElementID_41).
On Leopard, you can get at all of it over the RubyCocoa bridge:
```
require ... |
9,002 | <p>When I use the sp_send_dbmail stored procedure, I get a message saying that my mail was queued. However, it never seems to get delivered. I can see them in the queue if I run this SQL:</p>
<pre><code>SELECT * FROM msdb..sysmail_allitems WHERE sent_status = 'unsent'
</code></pre>
<p>This SQL returns a 1:</p>
<pre>... | [
{
"answer_id": 9212,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried </p>\n\n<pre><code>sysmail_stop_sp\n</code></pre>\n\n<p>then </p>\n\n<pre><code>sysmail_start_sp\n</code></pre>\n"... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162/"
] | When I use the sp\_send\_dbmail stored procedure, I get a message saying that my mail was queued. However, it never seems to get delivered. I can see them in the queue if I run this SQL:
```
SELECT * FROM msdb..sysmail_allitems WHERE sent_status = 'unsent'
```
This SQL returns a 1:
```
SELECT is_broker_enabled FROM... | Could be oodles of things. For example, I've seen (yes, actually seen) this happen after:
* Domain controller reboot
* Exchange server reboot
* Router outage
* Service account changes
* SQL Server running out of disk space
So until it happens again, I wouldn't freak out over it. |
9,009 | <p>This snippet of Perl code in my program is giving the wrong result.</p>
<pre><code>$condition ? $a = 2 : $a = 3 ;
print $a;
</code></pre>
<p>No matter what the value of <code>$condition</code> is, the output is always 3, how come?</p>
| [
{
"answer_id": 9011,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 7,
"selected": true,
"text": "<p>This is explained in the Perl <a href=\"http://perldoc.perl.org/perlop.html#Conditional-Operator\" rel=\"noreferrer\">documentatio... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/238/"
] | This snippet of Perl code in my program is giving the wrong result.
```
$condition ? $a = 2 : $a = 3 ;
print $a;
```
No matter what the value of `$condition` is, the output is always 3, how come? | This is explained in the Perl [documentation](http://perldoc.perl.org/perlop.html#Conditional-Operator).
Because of Perl operator precedence the statement is being parsed as
```
($condition ? $a= 2 : $a ) = 3 ;
```
Because the ?: operator produces an assignable result, 3 is assigned to the result of the condition.
... |
9,018 | <p>I am working at a client site where there is a proxy server (<code>HTTP</code>) in place. If I do a hard reset of the emulator it forgets network connection settings for the emulator and settings in the hosted Windows Mobile OS. If I 'save state and exit' it will lose all of these settings. I need to do hard resets ... | [
{
"answer_id": 9011,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 7,
"selected": true,
"text": "<p>This is explained in the Perl <a href=\"http://perldoc.perl.org/perlop.html#Conditional-Operator\" rel=\"noreferrer\">documentatio... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636/"
] | I am working at a client site where there is a proxy server (`HTTP`) in place. If I do a hard reset of the emulator it forgets network connection settings for the emulator and settings in the hosted Windows Mobile OS. If I 'save state and exit' it will lose all of these settings. I need to do hard resets regularly whic... | This is explained in the Perl [documentation](http://perldoc.perl.org/perlop.html#Conditional-Operator).
Because of Perl operator precedence the statement is being parsed as
```
($condition ? $a= 2 : $a ) = 3 ;
```
Because the ?: operator produces an assignable result, 3 is assigned to the result of the condition.
... |
9,019 | <p>I have a stored procedure which takes as its parameter a <em>varchar</em> which needs to be cast as a <em>datetime</em> for later use:</p>
<pre><code>SET @the_date = CAST(@date_string AS DATETIME)
</code></pre>
<p>I'm expecting the date string to be supplied in the format "DD-MON-YYYY", but in an effort to code de... | [
{
"answer_id": 9023,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 0,
"selected": false,
"text": "<p>Found <a href=\"http://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1030/"
] | I have a stored procedure which takes as its parameter a *varchar* which needs to be cast as a *datetime* for later use:
```
SET @the_date = CAST(@date_string AS DATETIME)
```
I'm expecting the date string to be supplied in the format "DD-MON-YYYY", but in an effort to code defensively, if for some reason it can't b... | I'm having a similar issue. You might be able to do something like this:
```
SET arithabort arith_overflow off
SET @the_date = CAST(@date_string AS DATETIME)
IF @the_date is NULL
set @the_date = getdate()
SET arithabort arith_overflow on
```
However, this doesn't work well in a select. It will work well in a cur... |
9,022 | <p>Inside an asp.net page, should I use</p>
<pre><code><html><title>My page's title from México</title></html>
</code></pre>
<p>Or </p>
<pre><code><html><title>My page&rsquo;s title from M&eacute;xico</title></html>
</code></pre>
<p>Both examples have the same... | [
{
"answer_id": 9023,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 0,
"selected": false,
"text": "<p>Found <a href=\"http://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296/"
] | Inside an asp.net page, should I use
```
<html><title>My page's title from México</title></html>
```
Or
```
<html><title>My page’s title from México</title></html>
```
Both examples have the same output. Since asp.net encodes all my pages to utf-8, there is no need to use html entities, is that righ... | I'm having a similar issue. You might be able to do something like this:
```
SET arithabort arith_overflow off
SET @the_date = CAST(@date_string AS DATETIME)
IF @the_date is NULL
set @the_date = getdate()
SET arithabort arith_overflow on
```
However, this doesn't work well in a select. It will work well in a cur... |
9,024 | <p>I'm using <code>IIS 5.1</code> in Windows XP on my development computer. I'm going to set up HTTPS on my company's web server, but I want to try doing it locally before doing it on a production system.</p>
<p>But when I go into the Directory Security tab of my web site's configuration section, the "Secure communica... | [
{
"answer_id": 9023,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 0,
"selected": false,
"text": "<p>Found <a href=\"http://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/614/"
] | I'm using `IIS 5.1` in Windows XP on my development computer. I'm going to set up HTTPS on my company's web server, but I want to try doing it locally before doing it on a production system.
But when I go into the Directory Security tab of my web site's configuration section, the "Secure communication" groupbox is dis... | I'm having a similar issue. You might be able to do something like this:
```
SET arithabort arith_overflow off
SET @the_date = CAST(@date_string AS DATETIME)
IF @the_date is NULL
set @the_date = getdate()
SET arithabort arith_overflow on
```
However, this doesn't work well in a select. It will work well in a cur... |
9,033 | <p>This came to my mind after I learned the following from <a href="http://www.stackoverflow.com/questions/8941/generic-type-checking">this question</a>:</p>
<pre><code>where T : struct
</code></pre>
<p>We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc.</p>
<p>Som... | [
{
"answer_id": 9035,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 8,
"selected": false,
"text": "<p>\"<a href=\"http://msdn.microsoft.com/en-us/library/9k7k7cf0(VS.80).aspx\" rel=\"nofollow noreferrer\">yield</a>\" would c... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | This came to my mind after I learned the following from [this question](http://www.stackoverflow.com/questions/8941/generic-type-checking):
```
where T : struct
```
We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc.
Some of us even mastered the stuff like [Generi... | This isn't C# per se, but I haven't seen anyone who really uses `System.IO.Path.Combine()` to the extent that they should. In fact, the whole Path class is really useful, but **no one uses it!**
I'm willing to bet that every production app has the following code, even though it shouldn't:
```
string path = dir + "\\"... |
9,044 | <p>I have a base class that represents a database test in TestNG, and I want to specify that all classes extending from this class are of a group "db-test", however I have found that this doesn't seem possible. I have tried the @Test annotation:</p>
<pre><code>@Test(groups = { "db-test" })
public class DBTestBase {
}... | [
{
"answer_id": 9137,
"author": "Sam Merrell",
"author_id": 782,
"author_profile": "https://Stackoverflow.com/users/782",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure how the annotation inheritance works for TestNG but this <a href=\"http://web.archive.org/web/20100104232432... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I have a base class that represents a database test in TestNG, and I want to specify that all classes extending from this class are of a group "db-test", however I have found that this doesn't seem possible. I have tried the @Test annotation:
```
@Test(groups = { "db-test" })
public class DBTestBase {
}
```
However,... | The answer is through a custom **org.testng.IMethodSelector**:
Its **includeMethod()** can exclude any method we want, like a public not-annotated method.
However, to register a custom *Java* MethodSelector, you must add it to the **XMLTest** instance managed by any TestRunner, which means you need your own **custom ... |
9,052 | <p>I'm working on a spec for a piece of software for my company and as part of the auditing system I think it would be neat if there was a way to grab the current Active Directory user.</p>
<p>Hopefully something like:</p>
<pre><code>Dim strUser as String
strUser = ActiveDirectory.User()
MsgBox "Welcome back, " &... | [
{
"answer_id": 9054,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://bytes.com/forum/thread717576.html\" rel=\"nofollow noreferrer\">Try this article</a> - I have some code... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | I'm working on a spec for a piece of software for my company and as part of the auditing system I think it would be neat if there was a way to grab the current Active Directory user.
Hopefully something like:
```
Dim strUser as String
strUser = ActiveDirectory.User()
MsgBox "Welcome back, " & strUser
``` | [Try this article](http://bytes.com/forum/thread717576.html) - I have some code at work that will erm, work if this doesn't...
Relevant quote:
>
>
> ```vba
> Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
> (ByVal IpBuffer As String, nSize As Long) As Long
> Priva... |
9,081 | <p>How do I <code>grep</code> and show the preceding and following 5 lines surrounding each matched line?</p>
| [
{
"answer_id": 9083,
"author": "Pat Notz",
"author_id": 825,
"author_profile": "https://Stackoverflow.com/users/825",
"pm_score": 13,
"selected": true,
"text": "<p>For <strong>BSD</strong> or <strong>GNU</strong> <code>grep</code> you can use <code>-B num</code> to set how many lines bef... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | How do I `grep` and show the preceding and following 5 lines surrounding each matched line? | For **BSD** or **GNU** `grep` you can use `-B num` to set how many lines before the match and `-A num` for the number of lines after the match.
```
grep -B 3 -A 2 foo README.txt
```
If you want the same number of lines before and after you can use `-C num`.
```
grep -C 3 foo README.txt
```
This will show 3 lines ... |
9,104 | <p>I'm thinking that the reason I can't do this is because it might be a huge security hole, but here goes...</p>
<p>I want to have a bookmark on my browser (FF3, preferably) that is only a snippet of javascript code. It would merely construct a URL based on the current date and then do a window.location = on that UR... | [
{
"answer_id": 9105,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 7,
"selected": true,
"text": "<p>What you want is a <a href=\"http://en.wikipedia.org/wiki/Bookmarklet\" rel=\"noreferrer\">bookmarklet</a> they are easy to create... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/232/"
] | I'm thinking that the reason I can't do this is because it might be a huge security hole, but here goes...
I want to have a bookmark on my browser (FF3, preferably) that is only a snippet of javascript code. It would merely construct a URL based on the current date and then do a window.location = on that URL.
I know ... | What you want is a [bookmarklet](http://en.wikipedia.org/wiki/Bookmarklet) they are easy to create and should work in most major browsers.
Edit: Stack overflow seems not to allow creating bookmarklets in the context of the site, basically you can create a new bookmark and type the following in the location field
```
... |
9,122 | <p>I'm trying to use a select statement to get all of the columns from a certain MySQL table except one. Is there a simple way to do this?</p>
<p>EDIT: There are 53 columns in this table (NOT MY DESIGN)</p>
| [
{
"answer_id": 9123,
"author": "Thomas Owens",
"author_id": 572,
"author_profile": "https://Stackoverflow.com/users/572",
"pm_score": 5,
"selected": false,
"text": "<p>To the best of my knowledge, there isn't. You can do something like:</p>\n\n<pre><code>SELECT col1, col2, col3, col4 FRO... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44/"
] | I'm trying to use a select statement to get all of the columns from a certain MySQL table except one. Is there a simple way to do this?
EDIT: There are 53 columns in this table (NOT MY DESIGN) | Actually there is a way, you need to have permissions of course for doing this ...
```
SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '<columns_to_omit>,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '<table>' AND TABLE_SCHEMA = '<database>'), ' FROM <table>');
PREPARE stmt1 FROM @... |
9,191 | <p>I'd like to ask a question then follow it up with my own answer, but also see what answers other people have.</p>
<p>We have two large files which we'd like to read from two separate threads concurrently. One thread will sequentially read fileA while the other thread will sequentially read fileB. There is no lock... | [
{
"answer_id": 9193,
"author": "pauldoo",
"author_id": 755,
"author_profile": "https://Stackoverflow.com/users/755",
"pm_score": 3,
"selected": false,
"text": "<p>I'd like to add some further notes in my response. All other non-Microsoft operating systems we have tested do not suffer fr... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/755/"
] | I'd like to ask a question then follow it up with my own answer, but also see what answers other people have.
We have two large files which we'd like to read from two separate threads concurrently. One thread will sequentially read fileA while the other thread will sequentially read fileB. There is no locking or commu... | The problem seems to be in Windows I/O scheduling policy. According to what I found [here](http://engr.smu.edu/~kocan/7343/fall05/slides/chapter11.ppt "I/O management and disk scheduling") there are many ways for an O.S. to schedule disk requests. While Linux and others can choose between different policies, before Vis... |
9,240 | <p>Say you have an application divided into 3-tiers: GUI, business logic, and data access. In your business logic layer you have described your business objects: getters, setters, accessors, and so on... you get the idea. The interface to the business logic layer guarantees safe usage of the business logic, so all the ... | [
{
"answer_id": 9250,
"author": "Lars Mæhlum",
"author_id": 960,
"author_profile": "https://Stackoverflow.com/users/960",
"pm_score": 0,
"selected": false,
"text": "<p>I always create a separate assembly that contains: </p>\n\n<ul>\n<li>A lot of small Interfaces (think ICreateRepository,... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Say you have an application divided into 3-tiers: GUI, business logic, and data access. In your business logic layer you have described your business objects: getters, setters, accessors, and so on... you get the idea. The interface to the business logic layer guarantees safe usage of the business logic, so all the met... | If I understand the question correctly, you've created a domain model and you would like to write an object-relational mapper to map between records in your database and your domain objects. However, you're concerned about polluting your domain model with the 'plumbing' code that would be necessary to read and write to... |
9,256 | <p>Thanks to FireFox's buggy implementation of ActiveX components (it really should take an image of them when printing) Flex components (in our case charts) don't print in FX.</p>
<p>They print fine in IE7, even IE6.</p>
<p>We need these charts to print, but they also have dynamic content. I don't really want to dr... | [
{
"answer_id": 16362,
"author": "Matt MacLean",
"author_id": 22,
"author_profile": "https://Stackoverflow.com/users/22",
"pm_score": 3,
"selected": true,
"text": "<p>Using the ACPrintManager I was able to get firefox 3 to print perfectly!</p>\n\n<p>The one thing I had to add to the examp... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | Thanks to FireFox's buggy implementation of ActiveX components (it really should take an image of them when printing) Flex components (in our case charts) don't print in FX.
They print fine in IE7, even IE6.
We need these charts to print, but they also have dynamic content. I don't really want to draw them again as i... | Using the ACPrintManager I was able to get firefox 3 to print perfectly!
The one thing I had to add to the example was to check if stage was null, and callLater if the stage was null.
```
private function initPrint():void {
//if we don't have a stage, wait until the next frame and try again
if ( stage == nul... |
9,275 | <p>I writing a report in Visual Studio that takes a user input parameter and runs against an ODBC datasource. I would like to write the query manually and have reporting services replace part of the where clause with the parameter value before sending it to the database. What seems to be happening is that the <code>@pa... | [
{
"answer_id": 9325,
"author": "Jorriss",
"author_id": 621,
"author_profile": "https://Stackoverflow.com/users/621",
"pm_score": 4,
"selected": true,
"text": "<p>It sounds like you'll need to treat the SQL Statement as an expression. For example:</p>\n\n<pre><code>=\"Select col1, col2 fr... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1104/"
] | I writing a report in Visual Studio that takes a user input parameter and runs against an ODBC datasource. I would like to write the query manually and have reporting services replace part of the where clause with the parameter value before sending it to the database. What seems to be happening is that the `@parmName` ... | It sounds like you'll need to treat the SQL Statement as an expression. For example:
```
="Select col1, col2 from table 1 Where col3 = " & Parameters!Param1.Value
```
If the where clause is a string you would need to do the following:
```
="Select col1, col2 from table 1 Where col3 = '" & Parameters!Param1.Value &... |
9,279 | <p>I absolutely love the <a href="http://winscp.net/eng/docs/task_keep_up_to_date" rel="noreferrer">Keep Remote Directory Up-to-date</a> feature in <a href="http://winscp.net/" rel="noreferrer">Winscp</a>. Unfortunately, I can't find anything as simple to use in OS X or Linux. I know the same thing can <em>theoreticall... | [
{
"answer_id": 9287,
"author": "dwj",
"author_id": 346,
"author_profile": "https://Stackoverflow.com/users/346",
"pm_score": 5,
"selected": true,
"text": "<p>How \"real-time\" do you want the syncing? I would still lean toward rsync since you know it is going to be fully supported on bot... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/302/"
] | I absolutely love the [Keep Remote Directory Up-to-date](http://winscp.net/eng/docs/task_keep_up_to_date) feature in [Winscp](http://winscp.net/). Unfortunately, I can't find anything as simple to use in OS X or Linux. I know the same thing can *theoretically* be accomplished using [changedfiles](http://freshmeat.net/p... | How "real-time" do you want the syncing? I would still lean toward rsync since you know it is going to be fully supported on both platforms (Windows, too, with cygwin) and you can run it via a cron job. I have a super-simple bash file that I run on my system (this does *not* remove old files):
```
#!/bin/sh
rsync -avr... |
9,289 | <p>I would like to filter an array of items by using the <code>map()</code> function. Here is a code snippet:</p>
<pre><code>var filteredItems = items.map(function(item)
{
if( ...some condition... )
{
return item;
}
});
</code></pre>
<p>The problem is that filtered out items still uses space in th... | [
{
"answer_id": 9295,
"author": "Patrick",
"author_id": 429,
"author_profile": "https://Stackoverflow.com/users/429",
"pm_score": 4,
"selected": false,
"text": "<p>That's not what map does. You really want <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/268/"
] | I would like to filter an array of items by using the `map()` function. Here is a code snippet:
```
var filteredItems = items.map(function(item)
{
if( ...some condition... )
{
return item;
}
});
```
The problem is that filtered out items still uses space in the array and I would like to completel... | You should use the `filter` method rather than map unless you want to mutate the items in the array, in addition to filtering.
eg.
```
var filteredItems = items.filter(function(item)
{
return ...some condition...;
});
```
[Edit: Of course you could always do `sourceArray.filter(...).map(...)` to both filter and... |
9,301 | <p>I'm having trouble with events in Internet Explorer 7.</p>
<p>When I have a form with <strong>two or more</strong> <code>input[type=text]</code> and I press enter, the events occurs in this order:</p>
<ol>
<li>submit button (<code>onClick</code>)</li>
<li>form (<code>onSubmit</code>)</li>
</ol>
<p>Sample code:</p... | [
{
"answer_id": 9327,
"author": "andrewrk",
"author_id": 432,
"author_profile": "https://Stackoverflow.com/users/432",
"pm_score": 1,
"selected": false,
"text": "<p>If you want code to run when the user presses enter, <strong>just use the onSubmit handler.</strong></p>\n\n<p>If you want c... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1100/"
] | I'm having trouble with events in Internet Explorer 7.
When I have a form with **two or more** `input[type=text]` and I press enter, the events occurs in this order:
1. submit button (`onClick`)
2. form (`onSubmit`)
Sample code:
```
<form onSubmit="{alert('form::onSubmit'); return false;}">
<input type="text">
... | The button's onclick should (I think) only fire if the button is actually clicked (or when the focus is on it and the user clicks enter), unless you've added logic to change that.
Is the addition of the extra textbox possibly changing the tab order of your elements (perhaps making the button the default control in tha... |
9,303 | <p>How do you retrieve selected text using Regex in C#?</p>
<p>I am looking for C# code that is equivalent to this Perl code:</p>
<pre><code>$indexVal = 0;
if($string =~ /Index: (\d*)/){$indexVal = $1;}
</code></pre>
| [
{
"answer_id": 9306,
"author": "Patrick",
"author_id": 429,
"author_profile": "https://Stackoverflow.com/users/429",
"pm_score": 4,
"selected": true,
"text": "<pre><code>int indexVal = 0;\nRegex re = new Regex(@\"Index: (\\d*)\")\nMatch m = re.Match(s)\n\nif(m.Success)\n indexVal = int.... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/889/"
] | How do you retrieve selected text using Regex in C#?
I am looking for C# code that is equivalent to this Perl code:
```
$indexVal = 0;
if($string =~ /Index: (\d*)/){$indexVal = $1;}
``` | ```
int indexVal = 0;
Regex re = new Regex(@"Index: (\d*)")
Match m = re.Match(s)
if(m.Success)
indexVal = int.TryParse(m.Groups[1].toString());
```
I might have the group number wrong, but you should be able to figure it out from here. |
9,304 | <p><em>Note: This was posted when I was starting out C#. With 2014 knowledge, I can truly say that auto-properties are among the best things that ever happened to the C# language.</em></p>
<p>I am used to create my properties in C# using a private and a public field:</p>
<pre><code>private string title;
public string... | [
{
"answer_id": 9308,
"author": "Ray",
"author_id": 233,
"author_profile": "https://Stackoverflow.com/users/233",
"pm_score": 5,
"selected": false,
"text": "<p>I personally love auto-properties. What's wrong with saving the lines of code? If you want to do stuff in getters or setters, the... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | *Note: This was posted when I was starting out C#. With 2014 knowledge, I can truly say that auto-properties are among the best things that ever happened to the C# language.*
I am used to create my properties in C# using a private and a public field:
```
private string title;
public string Title
{
get { return ti... | We use them all the time in Stack Overflow.
You may also be interested in a discussion of [Properties vs. Public Variables](http://blog.codinghorror.com/properties-vs-public-variables/). IMHO that's really what this is a reaction to, and for that purpose, it's great. |
9,314 | <p>I have a .NET 2.0 windows forms app, which makes heavy use of the <code>ListView</code> control.</p>
<p>I've subclassed the <code>ListView</code> class into a templated <code>SortableListView<T></code> class, so it can be a bit smarter about how it displays things, and sort itself.</p>
<p>Unfortunately this ... | [
{
"answer_id": 9320,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 3,
"selected": false,
"text": "<p>I've had a problem like this (tho not the same) in the past where my control was in a different namespace to my form even tho ... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234/"
] | I have a .NET 2.0 windows forms app, which makes heavy use of the `ListView` control.
I've subclassed the `ListView` class into a templated `SortableListView<T>` class, so it can be a bit smarter about how it displays things, and sort itself.
Unfortunately this seems to break the Visual Studio Forms Designer, in both... | >
> when you added the listview, did you add it to the toolbox and then add it to the form?
>
>
>
No, I just edited `Main.Designer.cs` and changed it from `System.Windows.Forms.ListView` to `MyApp.Controls.SortableListView<Image>`
Suspecting it might have been due to the generics led me to actually finding a solu... |
9,321 | <p>How do you create a static class in C++? I should be able to do something like:</p>
<pre><code>cout << "bit 5 is " << BitParser::getBitAt(buffer, 5) << endl;
</code></pre>
<p>Assuming I created the <code>BitParser</code> class. What would the <code>BitParser</code> class definition look like?</p>... | [
{
"answer_id": 9326,
"author": "Philip Reynolds",
"author_id": 1087,
"author_profile": "https://Stackoverflow.com/users/1087",
"pm_score": 4,
"selected": false,
"text": "<p>In C++ you want to create a static function of a class (not a static class).</p>\n\n<pre><code>class BitParser {\np... | 2008/08/12 | [
"https://Stackoverflow.com/questions/9321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/432/"
] | How do you create a static class in C++? I should be able to do something like:
```
cout << "bit 5 is " << BitParser::getBitAt(buffer, 5) << endl;
```
Assuming I created the `BitParser` class. What would the `BitParser` class definition look like? | If you're looking for a way of applying the "static" keyword to a class, like you can in C# for example, then you won't be able to without using Managed C++.
But the looks of your sample, you just need to create a public static method on your BitParser object. Like so:
**BitParser.h**
```
class BitParser
{
public:
... |
9,336 | <p>I'm trying to generate a sitemap.xml on the fly for a particular asp.net website.</p>
<p>I found a couple solutions:<br /></p>
<ol>
<li><a href="http://sitemap.chinookwebs.com/" rel="nofollow noreferrer">chinookwebs</a></li>
<li><a href="http://web.archive.org/web/20080307061444/http://www.cervoproject.info:80/sitem... | [
{
"answer_id": 9360,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 0,
"selected": false,
"text": "<p>Custom handler to generate the sitemap. </p>\n"
},
{
"answer_id": 9382,
"author": "Matt Mitchell",
"autho... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296/"
] | I'm trying to generate a sitemap.xml on the fly for a particular asp.net website.
I found a couple solutions:
1. [chinookwebs](http://sitemap.chinookwebs.com/)
2. [cervoproject](http://web.archive.org/web/20080307061444/http://www.cervoproject.info:80/sitemaps.aspx)
3. [newtonking](http://www.codeplex.com/Sitemaps)... | Usually you'll use an [HTTP Handler](http://www.google.com/search?q=HTTPHandler+ASP.NET&spell=1) for this. Given a request for...
>
> <http://www.yoursite.com/sitemap.axd>
>
>
>
...your handler will respond with a formatted XML sitemap. Whether that sitemap is generated on the fly, from a database, or some other ... |
9,338 | <p>One of the articles I really enjoyed reading recently was <a href="http://blog.last.fm/2008/08/01/quality-control" rel="nofollow noreferrer">Quality Control by Last.FM</a>. In the spirit of this article, I was wondering if anyone else had favorite monitoring setups for web type applications. Or maybe if you don't be... | [
{
"answer_id": 9360,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 0,
"selected": false,
"text": "<p>Custom handler to generate the sitemap. </p>\n"
},
{
"answer_id": 9382,
"author": "Matt Mitchell",
"autho... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1063/"
] | One of the articles I really enjoyed reading recently was [Quality Control by Last.FM](http://blog.last.fm/2008/08/01/quality-control). In the spirit of this article, I was wondering if anyone else had favorite monitoring setups for web type applications. Or maybe if you don't believe in Log Monitoring, why?
I'm loo... | Usually you'll use an [HTTP Handler](http://www.google.com/search?q=HTTPHandler+ASP.NET&spell=1) for this. Given a request for...
>
> <http://www.yoursite.com/sitemap.axd>
>
>
>
...your handler will respond with a formatted XML sitemap. Whether that sitemap is generated on the fly, from a database, or some other ... |
9,341 | <p>Simple ASP.NET application.</p>
<p>I have two drop-down controls. On the first-drop down I have a JavaScript <code>onChange</code> event. The JavaScript enables the second drop-down and removes a value from it (the value selected in the first drop-down). If they click the blank first value of the drop-down, then th... | [
{
"answer_id": 9343,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 2,
"selected": false,
"text": "<p>If the second dropdown is initially enabled through javascript (I'm assuming this is during a javascript onchange, s... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233/"
] | Simple ASP.NET application.
I have two drop-down controls. On the first-drop down I have a JavaScript `onChange` event. The JavaScript enables the second drop-down and removes a value from it (the value selected in the first drop-down). If they click the blank first value of the drop-down, then the second drop-down wi... | ```
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void indexChanged(object sender, EventArgs e)
{
Label1.Text = " I did something! ";
}
</script>
<html xmlns="ht... |
9,355 | <p>I can display and select a single file in windows explorer like this:</p>
<pre><code>explorer.exe /select, "c:\path\to\file.txt"
</code></pre>
<p>However, I can't work out how to select more than one file. None of the permutations of select I've tried work.</p>
<p>Note: I looked at these pages for docs, ne... | [
{
"answer_id": 9359,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 2,
"selected": false,
"text": "<p>it cannot be done through explorer.exe</p>\n"
},
{
"answer_id": 9497,
"author": "bruceatk",
"author_id": 7... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234/"
] | I can display and select a single file in windows explorer like this:
```
explorer.exe /select, "c:\path\to\file.txt"
```
However, I can't work out how to select more than one file. None of the permutations of select I've tried work.
Note: I looked at these pages for docs, neither helped.
<https://support.microsof... | This should be possible with the shell function [`SHOpenFolderAndSelectItems`](http://msdn.microsoft.com/en-us/library/bb762232(VS.85).aspx)
**EDIT**
Here is some sample code showing how to use the function in C/C++, without error checking:
```
//Directory to open
ITEMIDLIST *dir = ILCreateFromPath(_T("C:\\"));
//I... |
9,409 | <p>I have a datagrid getting bound to a dataset, and I want to display the average result in the footer for a column populated with integers.</p>
<p>The way I figure, there's 2 ways I can think of:</p>
<p>1."Use the <strong>Source</strong>, Luke"<br>
In the code where I'm calling DataGrid.DataBind(), use the DataTabl... | [
{
"answer_id": 9384,
"author": "Ray",
"author_id": 233,
"author_profile": "https://Stackoverflow.com/users/233",
"pm_score": 4,
"selected": true,
"text": "<p>See this KB Article. <a href=\"http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277\" rel=\"noreferrer\">How to configur... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/952/"
] | I have a datagrid getting bound to a dataset, and I want to display the average result in the footer for a column populated with integers.
The way I figure, there's 2 ways I can think of:
1."Use the **Source**, Luke"
In the code where I'm calling DataGrid.DataBind(), use the DataTable.Compute() method (*or in my c... | See this KB Article. [How to configure SQL Server 2005 to allow remote connections](http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277).
Oh, and remember that the SQLServer name will probably be MyMachineName\SQLExpress |
9,410 | <p>I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C?</p>
| [
{
"answer_id": 9411,
"author": "saint_groceon",
"author_id": 59,
"author_profile": "https://Stackoverflow.com/users/59",
"pm_score": 2,
"selected": false,
"text": "<p>You need to pass a <a href=\"http://www.newty.de/fpt/fpt.html#passPtr\" rel=\"nofollow noreferrer\">function pointer</a>.... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/432/"
] | I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C? | **Declaration**
A prototype for a function which takes a function parameter looks like the following:
```
void func ( void (*f)(int) );
```
This states that the parameter `f` will be a pointer to a function which has a `void` return type and which takes a single `int` parameter. The following function (`print`) is ... |
9,434 | <p>In my ASP.NET User Control I'm adding some JavaScript to the <code>window.onload</code> event:</p>
<pre><code>if (!Page.ClientScript.IsStartupScriptRegistered(this.GetType(), onloadScriptName))
Page.ClientScript.RegisterStartupScript(this.GetType(), onloadScriptName,
"window.onload = function() {myFunction()... | [
{
"answer_id": 9440,
"author": "Derek Park",
"author_id": 872,
"author_profile": "https://Stackoverflow.com/users/872",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know a lot about ASP.NET, but why not write a custom function for the onload event that in turn calls both functio... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233/"
] | In my ASP.NET User Control I'm adding some JavaScript to the `window.onload` event:
```
if (!Page.ClientScript.IsStartupScriptRegistered(this.GetType(), onloadScriptName))
Page.ClientScript.RegisterStartupScript(this.GetType(), onloadScriptName,
"window.onload = function() {myFunction();};", true);
... | Most of the "solutions" suggested are Microsoft-specific, or require bloated libraries. Here's one good way. This works with W3C-compliant browsers and with Microsoft IE.
```
if (window.addEventListener) // W3C standard
{
window.addEventListener('load', myFunction, false); // NB **not** 'onload'
}
else if (window.a... |
9,486 | <p>I could swear I've seen people typing function headers and then hitting some key combination to auto-create function braces and insert the cursor between them like so:</p>
<pre><code>void foo()_
</code></pre>
<p>to</p>
<pre><code>void foo()
{
_
}
</code></pre>
<p>Is this a built-in feature?</p>
| [
{
"answer_id": 9488,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 2,
"selected": false,
"text": "<p>It can be achieved by using code snippets, some are already built in (try typing \"svm\" and hitting TAB-TAB)..</p>\n\n<p>... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] | I could swear I've seen people typing function headers and then hitting some key combination to auto-create function braces and insert the cursor between them like so:
```
void foo()_
```
to
```
void foo()
{
_
}
```
Is this a built-in feature? | Check out [Resharper](http://www.jetbrains.com/resharper/documentation/feature_map.html) - it is a Visual Studio add-on with this feature, among many other development helps.
Also see [C# Completer](http://www.knowdotnet.com/articles/csharpcompleter.html), another add-on.
If you want to roll your own, check out [this... |
9,614 | <p>Suppose we have a table A:</p>
<pre><code>itemid mark
1 5
2 3
</code></pre>
<p>and table B:</p>
<pre><code>itemid mark
1 3
3 5
</code></pre>
<p>I want to join A*B on A.itemid=B.itemid both right and left ways. i.e. result:</p>
<pre><code>itemid A.mark B.mark
1 5 3
2 3 NUL... | [
{
"answer_id": 9625,
"author": "roo",
"author_id": 716,
"author_profile": "https://Stackoverflow.com/users/716",
"pm_score": 2,
"selected": false,
"text": "<p>Could do with some work but here is some sql</p>\n\n<pre><code>select distinct T.itemid, A.mark as \"A.mark\", B.mark as \"B.mark... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/844/"
] | Suppose we have a table A:
```
itemid mark
1 5
2 3
```
and table B:
```
itemid mark
1 3
3 5
```
I want to join A\*B on A.itemid=B.itemid both right and left ways. i.e. result:
```
itemid A.mark B.mark
1 5 3
2 3 NULL
3 NULL 5
```
Is there a way to do it in one quer... | It's called a full outer join and it's not supported natively in MySQL, judging from its [docs](http://dev.mysql.com/doc/refman/4.1/en/join.html). You can work around this limitation using UNION as described in the comments to the page I linked to.
[edit] Since others posted snippets, here you go. You can see explanat... |
9,632 | <p>Apparantly when users right-click in our WPF application, and they use the Windows Classic theme, the default ContextMenu of the TextBox (which contains Copy, Cut and Paste) has a black background.</p>
<p>I know this works well:</p>
<pre><code><Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentati... | [
{
"answer_id": 9864,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Try removing the x:Key attribute from the Style resource, leaving TargetType. I know, you're supposed to have that x:Key for... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/900/"
] | Apparantly when users right-click in our WPF application, and they use the Windows Classic theme, the default ContextMenu of the TextBox (which contains Copy, Cut and Paste) has a black background.
I know this works well:
```
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http... | Due to a late bug report we discovered that we cannot use the ApplicationComands Cut Paste and Copy directly in a partial trusted application. Therefor, using these commands in any Commmand of your controls will do absolutely nothing when executed.
So in essence Brads answer was almost there, it sure looked the right ... |
9,666 | <p>I've been raised to believe that if multiple threads can access a variable, then all reads from and writes to that variable must be protected by synchronization code, such as a "lock" statement, because the processor might switch to another thread halfway through a write.</p>
<p>However, I was looking through Syste... | [
{
"answer_id": 9682,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 0,
"selected": false,
"text": "<p>I thought they were - I'm not sure of the point of the lock in your example unless you're also doing something to s_Provider at... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1016/"
] | I've been raised to believe that if multiple threads can access a variable, then all reads from and writes to that variable must be protected by synchronization code, such as a "lock" statement, because the processor might switch to another thread halfway through a write.
However, I was looking through System.Web.Secu... | For the definitive answer go to the spec. :)
Partition I, Section 12.6.6 of the CLI spec states: "A conforming CLI shall guarantee that read and write access to properly aligned memory locations no larger than the native word size is atomic when all the write accesses to a location are the same size."
So that confirm... |
9,667 | <p>Given a handle of type <code>HWND</code> is it possible to confirm that the handle represents a real window?</p>
| [
{
"answer_id": 9670,
"author": "Serge",
"author_id": 1007,
"author_profile": "https://Stackoverflow.com/users/1007",
"pm_score": 5,
"selected": true,
"text": "<p>There is a function <code>IsWindow</code> which does exactly what you asked for.</p>\n\n<pre><code>BOOL isRealHandle = IsWindo... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/887/"
] | Given a handle of type `HWND` is it possible to confirm that the handle represents a real window? | There is a function `IsWindow` which does exactly what you asked for.
```
BOOL isRealHandle = IsWindow(unknwodnHandle);
```
Look at [this link](http://msdn.microsoft.com/en-us/library/ms633528(VS.85).aspx) for more information. |
9,673 | <p>I have been working with a <code>string[]</code> array in C# that gets returned from a function call. I could possibly cast to a <code>Generic</code> collection, but I was wondering if there was a better way to do it, possibly by using a temp array.</p>
<p><strong>What is the best way to remove duplicates from a C#... | [
{
"answer_id": 9677,
"author": "Matthew Schinckel",
"author_id": 188,
"author_profile": "https://Stackoverflow.com/users/188",
"pm_score": 4,
"selected": false,
"text": "<p>If you needed to sort it, then you could implement a sort that also removes duplicates.</p>\n\n<p>Kills two birds w... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] | I have been working with a `string[]` array in C# that gets returned from a function call. I could possibly cast to a `Generic` collection, but I was wondering if there was a better way to do it, possibly by using a temp array.
**What is the best way to remove duplicates from a C# array?** | You could possibly use a LINQ query to do this:
```
int[] s = { 1, 2, 3, 3, 4};
int[] q = s.Distinct().ToArray();
``` |
9,687 | <p>I'm looking for a pattern for performing a dynamic search on multiple tables.</p>
<p>I have no control over the legacy (and poorly designed) database table structure.</p>
<p>Consider a scenario similar to a resume search where a user may want to perform a search against any of the data in the resume and get back a... | [
{
"answer_id": 9889,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>As far as I understand (and I'm also someone who has written against a horrible legacy database), there is no such thing as d... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1097/"
] | I'm looking for a pattern for performing a dynamic search on multiple tables.
I have no control over the legacy (and poorly designed) database table structure.
Consider a scenario similar to a resume search where a user may want to perform a search against any of the data in the resume and get back a list of resumes ... | As far as I understand (and I'm also someone who has written against a horrible legacy database), there is no such thing as dynamic WHERE clauses. It has NOT been solved.
Personally, I prefer to generate my dynamic searches in code. Makes testing convenient. Note, when you create your sql queries in code, don't conca... |
9,702 | <p>As part of our current database work, we are looking at a dealing with the process of updating databases.</p>
<p>A point which has been brought up recurrently, is that of dealing with system vs. user values; in our project user and system vals are stored together. For example...</p>
<p>We have a list of templates.... | [
{
"answer_id": 9707,
"author": "John Smithers",
"author_id": 1069,
"author_profile": "https://Stackoverflow.com/users/1069",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe I didn't get it, but couldn't you use GUIDs as Ids and still have user and system data together? Then you can a... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1193/"
] | As part of our current database work, we are looking at a dealing with the process of updating databases.
A point which has been brought up recurrently, is that of dealing with system vs. user values; in our project user and system vals are stored together. For example...
We have a list of templates.
```
1, <system ... | I have never had problems (performance or development - TDD & unit testing included) using GUIDs as the ID for my databases, and I've worked on some pretty big ones. Have a look [here](http://www.sql-server-performance.com/articles/per/guid_performance_p2.aspx), [here](http://weblogs.asp.net/wwright/archive/2007/11/04/... |
9,734 | <p>Why does C#.Net allow the declaration of the string object to be case-insensitive?</p>
<pre><code>String sHello = "Hello";
string sHello = "Hello";
</code></pre>
<p>Both the lower-case and upper-case S of the word String are acceptable and this seems to be the only object that allows this.</p>
<p>Can anyone expla... | [
{
"answer_id": 9739,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 2,
"selected": false,
"text": "<p>\"String\" is the name of the class. \"string\" is keyword that maps this class.</p>\n\n<p>it's the same like</p>\n\n<ul>... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] | Why does C#.Net allow the declaration of the string object to be case-insensitive?
```
String sHello = "Hello";
string sHello = "Hello";
```
Both the lower-case and upper-case S of the word String are acceptable and this seems to be the only object that allows this.
Can anyone explain why? | **`string`** is a language keyword while `System.String` is the type it aliases.
Both compile to exactly the same thing, similarly:
* **`int`** is `System.Int32`
* **`long`** is `System.Int64`
* **`float`** is `System.Single`
* **`double`** is `System.Double`
* **`char`** is `System.Char`
* **`byte`** is `System.Byte... |
9,750 | <p>I was reading Joel's book where he was suggesting as interview question:</p>
<blockquote>
<p>Write a program to reverse the "ON" bits in a given byte.</p>
</blockquote>
<p>I only can think of a solution using C. </p>
<p>Asking here so you can show me how to do in a Non C way (if possible)</p>
| [
{
"answer_id": 9752,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "<p>What specifically does that question mean?</p>\n\n<p>Does <em>reverse</em> mean setting 1's to 0's and vice versa?</... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/123/"
] | I was reading Joel's book where he was suggesting as interview question:
>
> Write a program to reverse the "ON" bits in a given byte.
>
>
>
I only can think of a solution using C.
Asking here so you can show me how to do in a Non C way (if possible) | >
> What specifically does that question mean?
>
>
>
Good question. If reversing the "ON" bits means reversing only the bits that are "ON", then you will always get 0, no matter what the input is. If it means reversing *all* the bits, i.e. changing all 1s to 0s and all 0s to 1s, which is how I initially read it, t... |
9,805 | <p>I am currently writing a small calendar in ASP.Net C#. Currently to produce the rows of the weeks I do the following for loop:</p>
<pre><code>var iWeeks = 6;
for (int w = 0; w < iWeeks; w++) {
</code></pre>
<p>This works fine, however, some month will only have 5 weeks and in some rare cases, 4.</p>
<p>How can... | [
{
"answer_id": 9806,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "<p>How about checking which week the first and last days will be in?</p>\n"
},
{
"answer_id": 9810,
"author... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] | I am currently writing a small calendar in ASP.Net C#. Currently to produce the rows of the weeks I do the following for loop:
```
var iWeeks = 6;
for (int w = 0; w < iWeeks; w++) {
```
This works fine, however, some month will only have 5 weeks and in some rare cases, 4.
How can I calculate the number of rows that... | Here is the method that does it:
```
public int GetWeekRows(int year, int month)
{
DateTime firstDayOfMonth = new DateTime(year, month, 1);
DateTime lastDayOfMonth = new DateTime(year, month, 1).AddMonths(1).AddDays(-1);
System.Globalization.Calendar calendar = System.Threading.Thread.CurrentThread.Current... |
9,831 | <p>I've asked this question to the forums on the Mootools website and one person said that my class selection was corrupted before an admin came along and changed my post status to invalid. Needless to say this did not help much. I then posted to a google group for Mootools with no response. My question is why doesn... | [
{
"answer_id": 12910,
"author": "maxsilver",
"author_id": 1477,
"author_profile": "https://Stackoverflow.com/users/1477",
"pm_score": 3,
"selected": true,
"text": "<p>Ok, it looks like there are a couple of issues here. As far as I can tell, there is no such thing as a \"droppable\" in m... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1491425/"
] | I've asked this question to the forums on the Mootools website and one person said that my class selection was corrupted before an admin came along and changed my post status to invalid. Needless to say this did not help much. I then posted to a google group for Mootools with no response. My question is why doesn't the... | Ok, it looks like there are a couple of issues here. As far as I can tell, there is no such thing as a "droppable" in mootools. This means your events like 'enter', 'leave' and 'drop' won't work. (These are events on the drag object)
If you change those names to events that elements in mootools have (as in, DOM events... |
9,882 | <p>I am working on a project that requires the parsing of log files. I am looking for a fast algorithm that would take groups messages like this:</p>
<blockquote>
<p>The temperature at P1 is 35F.</p>
<p>The temperature at P1 is 40F.</p>
<p>The temperature at P3 is 35F.</p>
<p>Logger stopped.</p>
<p>Logger started.</p>
... | [
{
"answer_id": 9886,
"author": "John Downey",
"author_id": 200,
"author_profile": "https://Stackoverflow.com/users/200",
"pm_score": 4,
"selected": false,
"text": "<p>I think you might be overlooking and missed fscanf() and sscanf(). Which are the opposite of fprintf() and sprintf().</p>... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on a project that requires the parsing of log files. I am looking for a fast algorithm that would take groups messages like this:
>
> The temperature at P1 is 35F.
>
>
> The temperature at P1 is 40F.
>
>
> The temperature at P3 is 35F.
>
>
> Logger stopped.
>
>
> Logger started.
>
>
> The tempe... | Overview:
A **naïve!!** algorithm keeps track of the frequency of words in a per-column manner, where one can assume that each line can be separated into columns with a delimiter.
Example input:
>
> The dog jumped over the moon
>
> The cat jumped over the moon
>
> The moon jumped over the moon
>
> The c... |
9,928 | <p>I am working on a small webapp and I want to use Groovy to write some unit testing for my app. Most of my coding is done on Eclipse and I really want to run all the unit testing with the graphical test runner within Eclipse (I really like the green bar :) )</p>
<p>Sadly, after 4 hours of try-and-error, I'm still no... | [
{
"answer_id": 55705,
"author": "Kivus",
"author_id": 5590,
"author_profile": "https://Stackoverflow.com/users/5590",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately, the Groovy Eclipse plugin is pretty horrible at giving actual helpful information to let you know what is goi... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on a small webapp and I want to use Groovy to write some unit testing for my app. Most of my coding is done on Eclipse and I really want to run all the unit testing with the graphical test runner within Eclipse (I really like the green bar :) )
Sadly, after 4 hours of try-and-error, I'm still not able to ... | You might want to give the updated plugin a try, see the [the recent blog post](http://blog.springsource.com/2009/07/30/a-groovier-eclipse-experience) for more details. The theme of this alpha release is *providing an optimized edit/save/compile/test experience*, which seems to be your exact use case.
![Groovy Eclipse... |
9,938 | <p>I am trying to find a generic way of accessing a set of containers. I have a standard vector and list in addition to another custom list.</p>
<p>The custom list defines an iterator;</p>
<pre><code>class Iterator: public std::iterator<std::forward_iterator_tag, T> {
// ...
}
Iterator begin() {
return... | [
{
"answer_id": 9972,
"author": "David Sykes",
"author_id": 259,
"author_profile": "https://Stackoverflow.com/users/259",
"pm_score": 5,
"selected": true,
"text": "<p>Here are some articles you might find of interest</p>\n\n<p><a href=\"http://accu.org/index.php/journals/479\" rel=\"noref... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263/"
] | I am trying to find a generic way of accessing a set of containers. I have a standard vector and list in addition to another custom list.
The custom list defines an iterator;
```
class Iterator: public std::iterator<std::forward_iterator_tag, T> {
// ...
}
Iterator begin() {
return (Iterator(root));
}
Itera... | Here are some articles you might find of interest
[Giving STL Iterators a Base Class](http://accu.org/index.php/journals/479)
[Type Erasure for C++ Iterators](http://thbecker.net/free_software_utilities/type_erasure_for_cpp_iterators/start_page.html)
[any\_iterator Class Reference](http://stlab.adobe.com/classadobe_... |
9,974 | <p>This is a question I asked on another forum which received some decent answers, but I wanted to see if anyone here has more insight.</p>
<p>The problem is that you have one of your pages in a web application timing out when it gets to a stored procedure call, so you use Sql Profiler, or your application trace logs,... | [
{
"answer_id": 9982,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": -1,
"selected": false,
"text": "<p>Try changing the SelectCommand timeout value:</p>\n\n<pre><code>DataAdapter.SelectCommand.CommandTimeout = 120;\n</code><... | 2008/08/13 | [
"https://Stackoverflow.com/questions/9974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] | This is a question I asked on another forum which received some decent answers, but I wanted to see if anyone here has more insight.
The problem is that you have one of your pages in a web application timing out when it gets to a stored procedure call, so you use Sql Profiler, or your application trace logs, to find t... | This is what I've learned so far from my research.
.NET sends in connection settings that are not the same as what you get when you log in to management studio. Here is what you see if you sniff the connection with Sql Profiler:
```
-- network protocol: TCP/IP
set quoted_identifier off
set arithabort off
set nu... |
10,042 | <p>What's the best way to make a linked list in Java?</p>
| [
{
"answer_id": 10050,
"author": "dlinsin",
"author_id": 198,
"author_profile": "https://Stackoverflow.com/users/198",
"pm_score": 6,
"selected": false,
"text": "<p>Java has a <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedList.html\" rel=\"noreferrer\">LinkedList</a> i... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/571/"
] | What's the best way to make a linked list in Java? | The obvious solution to developers familiar to Java is to use the **LinkedList** class already provided in **java.util**. Say, however, you wanted to make your own implementation for some reason. Here is a quick example of a linked list that inserts a new link at the beginning of the list, deletes from the beginning of... |
10,071 | <p>I'm working on an app that grabs and installs a bunch of updates off an an external server, and need some help with threading. The user follows this process:</p>
<ul>
<li>Clicks button</li>
<li>Method checks for updates, count is returned.</li>
<li>If greater than 0, then ask the user if they want to install using ... | [
{
"answer_id": 10116,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried putting a </p>\n\n<pre><code>Application.DoEvents()\n</code></pre>\n\n<p>in here</p>\n\n<pre><code>if (... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636/"
] | I'm working on an app that grabs and installs a bunch of updates off an an external server, and need some help with threading. The user follows this process:
* Clicks button
* Method checks for updates, count is returned.
* If greater than 0, then ask the user if they want to install using MessageBox.Show().
* If yes,... | Your UI isn't updating because all the work is happening in the user interface thread.
Your call to:
```
this.BeginInvoke((MethodInvoker)delegate() {update.Action.Run(); })
```
is saying invoke update.Action.Run() on the thread that created "this" (your form), which is the user interface thread.
```
Application.D... |
10,123 | <p>I'm trying to decode the result of the Python os.wait() function. This returns, according to the Python docs:</p>
<blockquote>
<p>a tuple containing its pid and exit status indication: a 16-bit number, whose low byte is the signal number that killed the process, and whose high byte is the exit status (if the sign... | [
{
"answer_id": 10129,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 5,
"selected": true,
"text": "<p>This will do what you want:</p>\n\n<pre><code>signum = status & 0xff\nexitstatus = (status & 0xff00) >> 8... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742/"
] | I'm trying to decode the result of the Python os.wait() function. This returns, according to the Python docs:
>
> a tuple containing its pid and exit status indication: a 16-bit number, whose low byte is the signal number that killed the process, and whose high byte is the exit status (if the signal number is zero); ... | This will do what you want:
```
signum = status & 0xff
exitstatus = (status & 0xff00) >> 8
``` |
10,149 | <p>For context, I am something of an emacs newbie. I haven't used it for very long, but have been using it more and more (I like it a lot). Also I'm comfortable with lisp, but not super familiar with elisp.</p>
<p>What I need to do is bind a regular expression to a keyboard combination because I use this particular ... | [
{
"answer_id": 10161,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 4,
"selected": true,
"text": "<p>You can use macros, just do <kbd>C-x (</kbd> then do everything for the macro, then <kbd>C-x )</kbd> to end the macro, the... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/92/"
] | For context, I am something of an emacs newbie. I haven't used it for very long, but have been using it more and more (I like it a lot). Also I'm comfortable with lisp, but not super familiar with elisp.
What I need to do is bind a regular expression to a keyboard combination because I use this particular regex so oft... | You can use macros, just do `C-x (` then do everything for the macro, then `C-x )` to end the macro, then `C-x e` will execute the last defined macro. Then, you can name it using `M-x name-last-kbd-macro` which lets you assign a name to it, which you can then invoke with `M-x TESTIT`, then store the definition using `M... |
10,158 | <p>What's the easiest way to do an "instring" type function with a regex? For example, how could I reject a whole string because of the presence of a single character such as <code>:</code>? For example: </p>
<ul>
<li><code>this</code> - okay</li>
<li><code>there:is</code> - not okay because of <code>:</code></li>
</u... | [
{
"answer_id": 10168,
"author": "Adam Lerman",
"author_id": 673,
"author_profile": "https://Stackoverflow.com/users/673",
"pm_score": 0,
"selected": false,
"text": "<p>I dont know regex syntax very well but could you not do:</p>\n\n<p><code>[any alpha numeric]\\*:[any alphanumeric]\\*</c... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64/"
] | What's the easiest way to do an "instring" type function with a regex? For example, how could I reject a whole string because of the presence of a single character such as `:`? For example:
* `this` - okay
* `there:is` - not okay because of `:`
More practically, how can I match the following string:
```
//foo/bar/... | I'm still not sure whether you just wanted to detect if the Xpath contains a namespace, or whether you want to remove the references to the namespace. So here's some sample code (in C#) that does both.
```
class Program
{
static void Main(string[] args)
{
string withNamespace = @"//foo/ns2:bar/baz[1]/n... |
10,190 | <p>Many applications have grids that display data from a database table one page at a time. Many of them also let the user pick the number of records per page, sort by any column, and navigate back and forth through the results.</p>
<p>What's a good algorithm to implement this pattern without bringing the entire table... | [
{
"answer_id": 10194,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 5,
"selected": true,
"text": "<p>On MS SQL Server 2005 and above, <a href=\"http://msdn.microsoft.com/en-us/library/ms186734.aspx\" rel=\"noreferrer\">ROW_... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/373/"
] | Many applications have grids that display data from a database table one page at a time. Many of them also let the user pick the number of records per page, sort by any column, and navigate back and forth through the results.
What's a good algorithm to implement this pattern without bringing the entire table to the cl... | On MS SQL Server 2005 and above, [ROW\_NUMBER()](http://msdn.microsoft.com/en-us/library/ms186734.aspx) seems to work:
[T-SQL: Paging with ROW\_NUMBER()](http://blogs.x2line.com/al/archive/2005/11/18/1323.aspx)
```
DECLARE @PageNum AS INT;
DECLARE @PageSize AS INT;
SET @PageNum = 2;
SET @PageSize = 10;
WITH OrdersRN... |
10,205 | <p>I'm looking at parsing a delimited string, something on the order of</p>
<p>a,b,c</p>
<p>But this is a very simple example, and parsing delimited data can get complex; for instance</p>
<p>1,"Your simple algorithm, it fails",True</p>
<p>would blow your naiive string.Split implementation to bits. Is there anythin... | [
{
"answer_id": 10210,
"author": "Vaibhav",
"author_id": 380,
"author_profile": "https://Stackoverflow.com/users/380",
"pm_score": 0,
"selected": false,
"text": "<p>I am thinking that a generic framework would need to specify between two things:\n1. What are the delimiting characters.\n2.... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm looking at parsing a delimited string, something on the order of
a,b,c
But this is a very simple example, and parsing delimited data can get complex; for instance
1,"Your simple algorithm, it fails",True
would blow your naiive string.Split implementation to bits. Is there anything I can freely use/steal/copy an... | I use this to read from a file
```
string filename = @textBox1.Text;
string[] fields;
string[] delimiter = new string[] {"|"};
using (Microsoft.VisualBasic.FileIO.TextFieldParser parser =
new Microsoft.VisualBasic.FileIO.TextFieldParser(filename)) {
parser.Delimiters = delimiter;
parser.HasFieldsEnclose... |
10,229 | <p>Consider this problem: I have a program which should fetch (let's say) 100 records from a database, and then for each one it should get updated information from a web service. There are two ways to introduce parallelism in this scenario:</p>
<ol>
<li><p>I start each request to the web service on a new Thread. The n... | [
{
"answer_id": 10264,
"author": "Derek Park",
"author_id": 872,
"author_profile": "https://Stackoverflow.com/users/872",
"pm_score": 2,
"selected": false,
"text": "<p>Two things to consider.</p>\n<h3>1. How long will it take to process a record?</h3>\n<p>If record processing is very quic... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/380/"
] | Consider this problem: I have a program which should fetch (let's say) 100 records from a database, and then for each one it should get updated information from a web service. There are two ways to introduce parallelism in this scenario:
1. I start each request to the web service on a new Thread. The number of simulta... | Option 3 is the best:
Use Async IO.
Unless your request processing is complex and heavy, your program is going to spend 99% of it's time waiting for the HTTP requests.
This is exactly what Async IO is designed for - Let the windows networking stack (or .net framework or whatever) worry about all the waiting, and jus... |
10,314 | <p>Being new to Objective-C (but a long term C/++) programmer I'm looking for advice/recommendations on naming conventions for variables.</p>
<p>My personal preference would be to utilize a prefix for instance variables both for clarity within functions and to prevent shadowing of function parameters. However I'm a fa... | [
{
"answer_id": 10342,
"author": "Kristopher Johnson",
"author_id": 1175,
"author_profile": "https://Stackoverflow.com/users/1175",
"pm_score": 1,
"selected": false,
"text": "<p>I don't like using underscores as prefixes for any identifiers, because C and C++ both reserve certain undersco... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1043/"
] | Being new to Objective-C (but a long term C/++) programmer I'm looking for advice/recommendations on naming conventions for variables.
My personal preference would be to utilize a prefix for instance variables both for clarity within functions and to prevent shadowing of function parameters. However I'm a fan of prope... | Most Cocoa projects use underbar as a non-`IBOutlet` instance variable prefix, and use no prefix for `IBOutlet` instance variables.
The reason I don't use underbars for `IBOutlet` instance variables is that when a nib file is loaded, if you have a setter method for a connected outlet, that setter will be called. *Howe... |
10,323 | <p>I recently read a nice <a href="http://macdevelopertips.com/ruby/using-a-string-as-a-file-in-ruby.html" rel="noreferrer">post</a> on using <code>StringIO</code> in Ruby. What the author doesn't mention, though, is that <code>StringIO</code> is just an "I." There's no "O." You <em>can't</em> do this, for example:<... | [
{
"answer_id": 10335,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 2,
"selected": false,
"text": "<p>Well, a StringBuffer is not quite as necessary in Ruby, mainly because Strings in Ruby are mutable... thus you can build ... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I recently read a nice [post](http://macdevelopertips.com/ruby/using-a-string-as-a-file-in-ruby.html) on using `StringIO` in Ruby. What the author doesn't mention, though, is that `StringIO` is just an "I." There's no "O." You *can't* do this, for example:
```
s = StringIO.new
s << 'foo'
s << 'bar'
s.to_s
# => should ... | I looked at the ruby documentation for `StringIO`, and it looks like what you want is [`StringIO#string`](http://ruby-doc.org/stdlib/libdoc/stringio/rdoc/classes/StringIO.html#method-i-string), not `StringIO#to_s`
Thus, change your code to:
```
s = StringIO.new
s << 'foo'
s << 'bar'
s.string
``` |
10,349 | <p>I'm sure there is a good (or at least decent) reason for this. What is it?</p>
| [
{
"answer_id": 10354,
"author": "Adam Haile",
"author_id": 194,
"author_profile": "https://Stackoverflow.com/users/194",
"pm_score": 1,
"selected": false,
"text": "<p>It is so that you don't have two things trying to update the control at the same time. (This could happen if the CPU swit... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] | I'm sure there is a good (or at least decent) reason for this. What is it? | Because you can easily end up with a deadlock (among other issues).
For exmaple, your secondary thread could be trying to update the UI control, but the UI control will be waiting for a resource locked by the secondary thread to be released, so both threads end up waiting for each other to finish. As others have comm... |
10,366 | <p>I have an absolutely positioned <code>div</code> that I want to show when the user clicks a link. The <code>onclick</code> of the link calls a js function that sets the display of the div to block (also tried: "", <code>inline</code>, <code>table-cell</code>, <code>inline-table</code>, etc). This works great in IE7,... | [
{
"answer_id": 10368,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 1,
"selected": false,
"text": "<p>Check the error console (Tools Menu > Error Console in Firefox 3) to make sure that there isn't another error happe... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/521/"
] | I have an absolutely positioned `div` that I want to show when the user clicks a link. The `onclick` of the link calls a js function that sets the display of the div to block (also tried: "", `inline`, `table-cell`, `inline-table`, etc). This works great in IE7, not at all in every other browser I've tried (FF2, FF3, O... | Since setting the properties with javascript never seemed to work, but setting using Firebug's inspect did, I started to suspect that the javascript ID selector was broken - maybe there were multiple items in the DOM with the same ID? The source didn't show that there were, but looping through all divs using javascript... |
10,435 | <p>I have a website that works correctly under IIS 6.0: It authenticates users with windows credentials, and then when talking to the service that hits the DB, it passes the credentials.</p>
<p>In IIS 7.0, the same config settings do not pass the credentials, and the DB gets hit with NT AUTHORITY\ANONYMOUS.</p>
<p>Is... | [
{
"answer_id": 10444,
"author": "Guy",
"author_id": 993,
"author_profile": "https://Stackoverflow.com/users/993",
"pm_score": 0,
"selected": false,
"text": "<p>Interesting... I have the opposite problem - <strong>Not being able</strong> to get the authentication to be passed from the cli... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/781/"
] | I have a website that works correctly under IIS 6.0: It authenticates users with windows credentials, and then when talking to the service that hits the DB, it passes the credentials.
In IIS 7.0, the same config settings do not pass the credentials, and the DB gets hit with NT AUTHORITY\ANONYMOUS.
Is there something ... | There has been changes between IIS7 and IIS6.0. I found for you one blog post that might actually help you ([click here to see it](http://mvolo.com/blogs/serverside/archive/2007/12/08/IIS-7.0-Breaking-Changes-ASP.NET-2.0-applications-Integrated-mode.aspx)).
Are you running your application in Integrated Mode or in Cla... |
10,443 | <p>I have this program, we'll call it Host. Host does all kinds of good stuff, but it needs to be able to accept input through the command line <strong>while it's running</strong>. This means it has to somehow send its other process data and then quit. For example, I need to be able to do this:</p>
<pre><code>./Host -... | [
{
"answer_id": 10445,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": -1,
"selected": false,
"text": "<p>So, I may be missing the point here, but by deafult a C program's main function takes two arguments; argc, a count of the n... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/432/"
] | I have this program, we'll call it Host. Host does all kinds of good stuff, but it needs to be able to accept input through the command line **while it's running**. This means it has to somehow send its other process data and then quit. For example, I need to be able to do this:
```
./Host --blahblah 3 6 3 5
```
Thi... | If you were on Windows, I'd tell you to use a hidden window to receive the messages, but since you used `./`, I assume you want something Unix-based.
In that case, I'd go with a [named pipe](http://en.wikipedia.org/wiki/Named_pipe). Sun has a [tutorial](http://developers.sun.com/solaris/articles/named_pipes.html) abou... |
10,456 | <p>The 'click sound' in question is actually a system wide preference, so I only want it to be disabled when my application has focus and then re-enable when the application closes/loses focus.</p>
<p>Originally, I wanted to ask this question here on stackoverflow, but I was not yet in the beta. So, after googling for... | [
{
"answer_id": 10463,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 5,
"selected": true,
"text": "<p>I've noticed that if you use WebBrowser.Document.Write rather than WebBrowser.DocumentText then the click sound doesn't... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1147/"
] | The 'click sound' in question is actually a system wide preference, so I only want it to be disabled when my application has focus and then re-enable when the application closes/loses focus.
Originally, I wanted to ask this question here on stackoverflow, but I was not yet in the beta. So, after googling for the answe... | I've noticed that if you use WebBrowser.Document.Write rather than WebBrowser.DocumentText then the click sound doesn't happen.
So instead of this:
```
webBrowser1.DocumentText = "<h1>Hello, world!</h1>";
```
try this:
```
webBrowser1.Document.OpenNew(true);
webBrowser1.Document.Write("<h1>Hello, world!</h1>");
`... |
10,499 | <p>Sometimes I get Oracle connection problems because I can't figure out which tnsnames.ora file my database client is using.</p>
<p>What's the best way to figure this out? ++happy for various platform solutions. </p>
| [
{
"answer_id": 10501,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 5,
"selected": false,
"text": "<p>For linux:</p>\n\n<pre><code>$ strace sqlplus -L scott/tiger@orcl 2>&1| grep -i 'open.*tnsnames.ora'\n</code></... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | Sometimes I get Oracle connection problems because I can't figure out which tnsnames.ora file my database client is using.
What's the best way to figure this out? ++happy for various platform solutions. | Oracle provides a utility called `tnsping`:
```
R:\>tnsping someconnection
TNS Ping Utility for 32-bit Windows: Version 9.0.1.3.1 - Production on 27-AUG-20
08 10:38:07
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
C:\Oracle92\network\ADMIN\sqlnet.ora
C:\Oracle92\network\ADMIN\tn... |
10,506 | <p>I am having a strange DB2 issue when I run DBUnit tests. My DBUnit tests are highly customized, but I don't think it is the issue. When I run the tests, I get a failure: </p>
<blockquote>
<p>SQLCODE: -1084, SQLSTATE: 57019</p>
</blockquote>
<p><a href="https://www1.columbia.edu/sec/acis/db2/db2m0/sql1000.htm" ... | [
{
"answer_id": 10501,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 5,
"selected": false,
"text": "<p>For linux:</p>\n\n<pre><code>$ strace sqlplus -L scott/tiger@orcl 2>&1| grep -i 'open.*tnsnames.ora'\n</code></... | 2008/08/13 | [
"https://Stackoverflow.com/questions/10506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I am having a strange DB2 issue when I run DBUnit tests. My DBUnit tests are highly customized, but I don't think it is the issue. When I run the tests, I get a failure:
>
> SQLCODE: -1084, SQLSTATE: 57019
>
>
>
[which translates to](https://www1.columbia.edu/sec/acis/db2/db2m0/sql1000.htm)
>
> SQL1084C Share... | Oracle provides a utility called `tnsping`:
```
R:\>tnsping someconnection
TNS Ping Utility for 32-bit Windows: Version 9.0.1.3.1 - Production on 27-AUG-20
08 10:38:07
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
C:\Oracle92\network\ADMIN\sqlnet.ora
C:\Oracle92\network\ADMIN\tn... |
10,533 | <p>Here's a problem I ran into recently. I have attributes strings of the form</p>
<pre><code>"x=1 and y=abc and z=c4g and ..."
</code></pre>
<p>Some attributes have numeric values, some have alpha values, some have mixed, some have dates, etc.</p>
<p>Every string is <em>supposed</em> to have "<code>x=someval and y... | [
{
"answer_id": 10537,
"author": "Derek Park",
"author_id": 872,
"author_profile": "https://Stackoverflow.com/users/872",
"pm_score": 0,
"selected": false,
"text": "<p>Here's basically what I did to solve this:</p>\n\n<pre><code>($x_str, $y_str, $remainder) = split(/ and /, $str, 3);\n\ni... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/872/"
] | Here's a problem I ran into recently. I have attributes strings of the form
```
"x=1 and y=abc and z=c4g and ..."
```
Some attributes have numeric values, some have alpha values, some have mixed, some have dates, etc.
Every string is *supposed* to have "`x=someval and y=anotherval`" at the beginning, but some don't... | I'm not the best at regular expressions, but this seems pretty close to what you're looking for:
```
/x=(.+) and y=([^ ]+)( and (.*))?/
```
Except you use $1, $2, and $4. In use:
```
my @strs = ("x=1 and y=abc and z=c4g and w=v4l",
"x=yes and y=no",
"z=nox and w=noy");
foreach (@strs) {
... |
10,564 | <p>I'm trying out <strong>Git on Windows</strong>. I got to the point of trying "git commit" and I got this error:</p>
<blockquote>
<p>Terminal is dumb but no VISUAL nor
EDITOR defined. Please supply the
message using either -m or -F option.</p>
</blockquote>
<p>So I figured out I need to have an environment va... | [
{
"answer_id": 10574,
"author": "J Wynia",
"author_id": 1124,
"author_profile": "https://Stackoverflow.com/users/1124",
"pm_score": 1,
"selected": false,
"text": "<p>I've had difficulty getting Git to cooperate with <a href=\"http://en.wikipedia.org/wiki/WordPad\" rel=\"nofollow noreferr... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/437/"
] | I'm trying out **Git on Windows**. I got to the point of trying "git commit" and I got this error:
>
> Terminal is dumb but no VISUAL nor
> EDITOR defined. Please supply the
> message using either -m or -F option.
>
>
>
So I figured out I need to have an environment variable called EDITOR. No problem. I set it ... | Update September 2015 (6 years later)
The [last release of git-for-Windows (2.5.3)](https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1) now includes:
>
> By configuring **`git config core.editor notepad`**, users [can now use `notepad.exe` as their default editor](https://github.com/git-for-windows... |
10,616 | <p>I'm an <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="noreferrer">ASP.NET</a> developer who has used <code>Microsoft SQL Server</code> for all my database needs (both at work and for personal projects). </p>
<p>I am considering trying out the <a href="http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29" re... | [
{
"answer_id": 10623,
"author": "Jeff Atwood",
"author_id": 1,
"author_profile": "https://Stackoverflow.com/users/1",
"pm_score": 8,
"selected": true,
"text": "<p>One thing you have to watch out for is the fairly severe differences in the way SQL Server and MySQL implement the SQL s... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/285/"
] | I'm an [ASP.NET](http://en.wikipedia.org/wiki/ASP.NET) developer who has used `Microsoft SQL Server` for all my database needs (both at work and for personal projects).
I am considering trying out the [LAMP](http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29) stack for some of my personal projects.
What are so... | One thing you have to watch out for is the fairly severe differences in the way SQL Server and MySQL implement the SQL syntax.
Here's a nice [Comparison of Different SQL Implementations](http://troels.arvin.dk/db/rdbms/).
For example, take a look at the top-n section. In MySQL:
```
SELECT age
FROM person
ORDER BY ag... |
10,635 | <p>I wrote a simple batch file as a PowerShell script, and I am getting errors when they run.</p>
<p>It's in a scripts directory in my path. This is the error I get:</p>
<blockquote>
<p>Cannot be loaded because the execution of scripts is disabled on this system.
Please see "get-help about-signing".</p>
</block... | [
{
"answer_id": 10638,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 8,
"selected": true,
"text": "<p>It could be PowerShell's default security level, which (IIRC) will only run signed scripts.</p>\n\n<p>Try typing this:<... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220/"
] | I wrote a simple batch file as a PowerShell script, and I am getting errors when they run.
It's in a scripts directory in my path. This is the error I get:
>
> Cannot be loaded because the execution of scripts is disabled on this system.
> Please see "get-help about-signing".
>
>
>
I looked in the help, but it... | It could be PowerShell's default security level, which (IIRC) will only run signed scripts.
Try typing this:
```none
set-executionpolicy remotesigned
```
That will tell PowerShell to allow local (that is, on a local drive) unsigned scripts to run.
Then try executing your script again. |
10,668 | <p>I've been trying to understand how to read the memory of other processes on Mac OS X, but I'm not having much luck. I've seen many examples online using <code>ptrace</code> with <code>PEEKDATA</code> and such, however it doesn't have that option on BSD <sup>[<a href="http://developer.apple.com/documentation/Darwin/R... | [
{
"answer_id": 10676,
"author": "Derek Park",
"author_id": 872,
"author_profile": "https://Stackoverflow.com/users/872",
"pm_score": 4,
"selected": false,
"text": "<p>Matasano Chargen had a good post a while back on porting some debugging code to OS X, which included learning how to read... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1114/"
] | I've been trying to understand how to read the memory of other processes on Mac OS X, but I'm not having much luck. I've seen many examples online using `ptrace` with `PEEKDATA` and such, however it doesn't have that option on BSD [[`man ptrace`](http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/p... | Matasano Chargen had a good post a while back on porting some debugging code to OS X, which included learning how to read and write memory in another process (among other things).
[It has to work, otherwise GDB wouldn't](http://replay.web.archive.org/20090627062246/http://www.matasano.com/log/1100/what-ive-been-doing-... |
10,680 | <p>Is there any difference between</p>
<pre><code> int on_exit(void (*function)(int , void *), void *arg);
</code></pre>
<p>and</p>
<pre><code> int atexit(void (*function)(void));
</code></pre>
<p>other than the fact that the function used by on_exit gets the exit status?</p>
<p>That is, if I don't care about ... | [
{
"answer_id": 10684,
"author": "Derek Park",
"author_id": 872,
"author_profile": "https://Stackoverflow.com/users/872",
"pm_score": 4,
"selected": false,
"text": "<p>You should use <code>atexit()</code> if possible. <code>on_exit()</code> is nonstandard and less common. For example, i... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1084/"
] | Is there any difference between
```
int on_exit(void (*function)(int , void *), void *arg);
```
and
```
int atexit(void (*function)(void));
```
other than the fact that the function used by on\_exit gets the exit status?
That is, if I don't care about the exit status, is there any reason to use one or the ... | According to [this link](http://www.delorie.com/gnu/docs/glibc/libc_560.html) I found, it seems there are a few differences. `on_exit` will let you pass in an argument that is passed in to the `on_exit` function when it is called... which might let you set up some pointers to do some cleanup work on when it is time to ... |
10,752 | <p>I know the so-called textbook definition of unit tests and integration tests. What I am curious about is when it is time to write unit tests... I will write them to cover as many sets of classes as possible.</p>
<p>For example, if I have a <code>Word</code> class, I will write some unit tests for the <code>Word</c... | [
{
"answer_id": 10756,
"author": "DevelopingChris",
"author_id": 1220,
"author_profile": "https://Stackoverflow.com/users/1220",
"pm_score": 4,
"selected": false,
"text": "<p>using Single responsibility design, its black and white. More than 1 responsibility, its an integration test. </p>... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I know the so-called textbook definition of unit tests and integration tests. What I am curious about is when it is time to write unit tests... I will write them to cover as many sets of classes as possible.
For example, if I have a `Word` class, I will write some unit tests for the `Word` class. Then, I begin writing... | The key difference, to me, is that **integration tests** reveal if a feature is working or is broken, since they stress the code in a scenario close to reality. They invoke one or more software methods or features and test if they act as expected.
On the opposite, a **Unit test** testing a single method relies on the ... |
10,793 | <p>I'm dynamically loading user controls adding them to the Controls collection of the web form.</p>
<p>I'd like to hide user controls if they cause a unhandled exception while rendering.</p>
<p>So, I tried hooking to the Error event of each UserControl but it seems that this event never fires for the UserControls as... | [
{
"answer_id": 10797,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 0,
"selected": false,
"text": "<p>Global.asax and Application_Error?</p>\n\n<p><a href=\"http://www.15seconds.com/issue/030102.htm\" rel=\"nofollow norefer... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1269/"
] | I'm dynamically loading user controls adding them to the Controls collection of the web form.
I'd like to hide user controls if they cause a unhandled exception while rendering.
So, I tried hooking to the Error event of each UserControl but it seems that this event never fires for the UserControls as it does for Page... | mmilic, following on from [your response](https://stackoverflow.com/questions/10793/catching-unhandled-exceptions-in-aspnet-usercontrols#10910) to my [previous idea](https://stackoverflow.com/questions/10793/catching-unhandled-exceptions-in-aspnet-usercontrols#10815)..
No additional logic required! That's the point, y... |
10,808 | <p>Ok, so I've been refactoring my code in my little Rails app in an effort to remove duplication, and in general make my life easier (as I like an easy life). Part of this refactoring, has been to move code that's common to two of my models to a module that I can include where I need it.</p>
<p>So far, so good. Look... | [
{
"answer_id": 11719,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 0,
"selected": false,
"text": "<p>Rather than checking if the super method exists, you can just define it</p>\n\n<pre><code>class ActiveRecord::Base\n ... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/841/"
] | Ok, so I've been refactoring my code in my little Rails app in an effort to remove duplication, and in general make my life easier (as I like an easy life). Part of this refactoring, has been to move code that's common to two of my models to a module that I can include where I need it.
So far, so good. Looks like it's... | You can use this:
```
super if defined?(super)
```
Here is an example:
```
class A
end
class B < A
def t
super if defined?(super)
puts "Hi from B"
end
end
B.new.t
``` |
10,810 | <p>I'm doing a authorization check from a WinForms application with the help of the AzMan authorization provider from Enterprise Library and am receiving the the following error:</p>
<blockquote>
<p>Unable to update the password. The value provided as the current password is incorrect. (Exception from HRESULT: 0x800... | [
{
"answer_id": 11719,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 0,
"selected": false,
"text": "<p>Rather than checking if the super method exists, you can just define it</p>\n\n<pre><code>class ActiveRecord::Base\n ... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966/"
] | I'm doing a authorization check from a WinForms application with the help of the AzMan authorization provider from Enterprise Library and am receiving the the following error:
>
> Unable to update the password. The value provided as the current password is incorrect. (Exception from HRESULT: 0x8007052B) (Microsoft.Pr... | You can use this:
```
super if defined?(super)
```
Here is an example:
```
class A
end
class B < A
def t
super if defined?(super)
puts "Hi from B"
end
end
B.new.t
``` |
10,819 | <p>For certain types of sql queries, an auxiliary table of numbers can be very useful. It may be created as a table with as many rows as you need for a particular task or as a user defined function that returns the number of rows required in each query.</p>
<p>What is the optimal way to create such a function?</p>
| [
{
"answer_id": 39122,
"author": "mrdenny",
"author_id": 4197,
"author_profile": "https://Stackoverflow.com/users/4197",
"pm_score": 4,
"selected": false,
"text": "<p>The most optimal function would be to use a table instead of a function. Using a function causes extra CPU load to create... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/224/"
] | For certain types of sql queries, an auxiliary table of numbers can be very useful. It may be created as a table with as many rows as you need for a particular task or as a user defined function that returns the number of rows required in each query.
What is the optimal way to create such a function? | Heh... sorry I'm so late responding to an old post. And, yeah, I had to respond because the most popular answer (at the time, the Recursive CTE answer with the link to 14 different methods) on this thread is, ummm... performance challenged at best.
First, the article with the 14 different solutions is fine for seeing ... |
10,822 | <p>What would be a very fast way to determine if your connectionstring lets you connect to a database?</p>
<p>Normally a connection attempt keeps the user waiting a long time before notifying the attempt was futile anyway.</p>
| [
{
"answer_id": 10823,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 2,
"selected": false,
"text": "<p>Shorten the timeout on the connection string and execute something trivial.</p>\n\n<p>The wait should be about the same as the... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1271/"
] | What would be a very fast way to determine if your connectionstring lets you connect to a database?
Normally a connection attempt keeps the user waiting a long time before notifying the attempt was futile anyway. | You haven't mentioned what database you are connecting to, however. In [SQL Server 2005](http://en.wikipedia.org/wiki/Microsoft_SQL_Server#SQL_Server_2005), from .NET, you can specify a connection timeout in your connection string like so:
```
server=<server>;database=<database>;uid=<user>;password=<password>;Connect ... |
10,825 | <p>In SQL Server I have a <code>DATETIME</code> column which includes a time element.</p>
<p>Example: </p>
<pre><code>'14 AUG 2008 14:23:019'
</code></pre>
<p>What is the <strong>best</strong> method to only select the records for a particular day, ignoring the time part?</p>
<p>Example: (Not safe, as it does no... | [
{
"answer_id": 10826,
"author": "Guy",
"author_id": 993,
"author_profile": "https://Stackoverflow.com/users/993",
"pm_score": 6,
"selected": true,
"text": "<p>Technique 1:</p>\n\n<pre><code> DECLARE @p_date DATETIME\n SET @p_date = CONVERT( DATETIME, '14 AUG 2008', 106 )\n\n SELECT ... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/993/"
] | In SQL Server I have a `DATETIME` column which includes a time element.
Example:
```
'14 AUG 2008 14:23:019'
```
What is the **best** method to only select the records for a particular day, ignoring the time part?
Example: (Not safe, as it does not match the time part and returns no rows)
```
DECLARE @p_date DA... | Technique 1:
```
DECLARE @p_date DATETIME
SET @p_date = CONVERT( DATETIME, '14 AUG 2008', 106 )
SELECT *
FROM table1
WHERE column_datetime >= @p_date
AND column_datetime < DATEADD(d, 1, @p_date)
```
The advantage of this is that it will use any index on 'column\_datetime' if it exists. |
10,855 | <p>I'm trying to perform a LINQ query on a DataTable object and bizarrely I am finding that performing such queries on DataTables is not straightforward. For example:</p>
<pre><code>var results = from myRow in myDataTable
where results.Field("RowNo") == 1
select results;
</code></pre>
<p>This is not allowed. How do I... | [
{
"answer_id": 10856,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 6,
"selected": false,
"text": "<p>It's not that they were deliberately not allowed on DataTables, it's just that DataTables pre-date the IQueryable and gen... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445/"
] | I'm trying to perform a LINQ query on a DataTable object and bizarrely I am finding that performing such queries on DataTables is not straightforward. For example:
```
var results = from myRow in myDataTable
where results.Field("RowNo") == 1
select results;
```
This is not allowed. How do I get something like this w... | You can't query against the `DataTable`'s *Rows* collection, since `DataRowCollection` doesn't implement `IEnumerable<T>`. You need to use the `AsEnumerable()` extension for `DataTable`. Like so:
```
var results = from myRow in myDataTable.AsEnumerable()
where myRow.Field<int>("RowNo") == 1
select myRow;
```
And as ... |
10,870 | <p>Once I've called <code>DragManager.acceptDrag</code> is there any way to "unaccept" the drag? Say that I have a view which can accept drag and drop, but only in certain areas. Once the user drags over one of these areas I call <code>DragManager.acceptDrag(this)</code> (from a <code>DragEvent.DRAG_OVER</code> handler... | [
{
"answer_id": 11209,
"author": "Matt MacLean",
"author_id": 22,
"author_profile": "https://Stackoverflow.com/users/22",
"pm_score": 3,
"selected": false,
"text": "<p>Are you using only the dragEnter method? If you are trying to reject the drag while still dragging over the same componen... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1109/"
] | Once I've called `DragManager.acceptDrag` is there any way to "unaccept" the drag? Say that I have a view which can accept drag and drop, but only in certain areas. Once the user drags over one of these areas I call `DragManager.acceptDrag(this)` (from a `DragEvent.DRAG_OVER` handler), but if the user then moves out of... | Are you using only the dragEnter method? If you are trying to reject the drag while still dragging over the same component you need to use both the dragEnter and dragOver methods.
Check out this example:
```
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absol... |
10,877 | <p>How can I left-align the numbers in an ordered list?</p>
<pre><code>1. an item
// skip some items for brevity
9. another item
10. notice the 1 is under the 9, and the item contents also line up
</code></pre>
<p>Change the character after the number in an ordered list?</p>
<pre><code>1) an item
</code></pre>
<... | [
{
"answer_id": 10887,
"author": "Marcus Downing",
"author_id": 1000,
"author_profile": "https://Stackoverflow.com/users/1000",
"pm_score": 5,
"selected": false,
"text": "<p>The CSS for styling lists is <a href=\"http://www.w3.org/TR/REC-CSS2/generate.html#lists\" rel=\"noreferrer\">here<... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/486/"
] | How can I left-align the numbers in an ordered list?
```
1. an item
// skip some items for brevity
9. another item
10. notice the 1 is under the 9, and the item contents also line up
```
Change the character after the number in an ordered list?
```
1) an item
```
Also is there a CSS solution to change from num... | This is the solution I have working in Firefox 3, Opera and Google Chrome. The list still displays in IE7 (but without the close bracket and left align numbers):
```css
ol {
counter-reset: item;
margin-left: 0;
padding-left: 0;
}
li {
display: block;
margin-bottom: .5em;
margin-left: 2em;
}
li::b... |
10,905 | <p>You should be able to create a generic form:</p>
<pre><code>public partial class MyGenericForm<T> :
Form where T : class
{
/* form code */
public List<T> TypedList { get; set; }
}
</code></pre>
<p>Is valid C#, and compiles. However the designer won't work and the form will throw a runtime ... | [
{
"answer_id": 10906,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 0,
"selected": false,
"text": "<p>I have a hack to workaround this, which works but isn't ideal:</p>\n\n<p>Add a new class to the project that inherits the form... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | You should be able to create a generic form:
```
public partial class MyGenericForm<T> :
Form where T : class
{
/* form code */
public List<T> TypedList { get; set; }
}
```
Is valid C#, and compiles. However the designer won't work and the form will throw a runtime exception if you have any images statin... | Yes you can! Here's a blog post I made a while ago with the trick:
[Designing Generic Forms](http://www.madprops.org/blog/designing-generic-forms/)
Edit: Looks like you're already doing it this way. This method works fine so I wouldn't consider it too hacky. |
10,915 | <p>Warning - I am very new to NHibernate. I know this question seems simple - and I'm sure there's a simple answer, but I've been spinning my wheels for some time on this one. I am dealing with a legacy db which really can't be altered structurally. I have a details table which lists payment plans that have been accept... | [
{
"answer_id": 10993,
"author": "DavidWhitney",
"author_id": 1297,
"author_profile": "https://Stackoverflow.com/users/1297",
"pm_score": 0,
"selected": false,
"text": "<p>The approach I'd take to model this is as follows:</p>\n\n<p>Customer object contains an ICollection <PaymentPlan&... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1284/"
] | Warning - I am very new to NHibernate. I know this question seems simple - and I'm sure there's a simple answer, but I've been spinning my wheels for some time on this one. I am dealing with a legacy db which really can't be altered structurally. I have a details table which lists payment plans that have been accepted ... | I'd steer away from having child object containing their logical parent, it can get very messy and very recursive pretty quickly when you do that. I'd take a look at how you're intending to use the domain model before you do that sort of thing. You can easily still have the ID references in the tables and just leave th... |
10,926 | <p>I'm building a listing/grid control in a <code>Flex</code> application and using it in a <code>.NET</code> web application. To make a really long story short I am getting XML from a webservice of serialized objects. I have a page limit of how many things can be on a page. I've taken a data grid and made it page, ... | [
{
"answer_id": 11048,
"author": "Matt Dillard",
"author_id": 863,
"author_profile": "https://Stackoverflow.com/users/863",
"pm_score": 0,
"selected": false,
"text": "<p>I don't immediately see the problem, so I can only venture a guess. The <code>delete</code> line that you've got is lo... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290/"
] | I'm building a listing/grid control in a `Flex` application and using it in a `.NET` web application. To make a really long story short I am getting XML from a webservice of serialized objects. I have a page limit of how many things can be on a page. I've taken a data grid and made it page, sort across pages, and handl... | Thanks for the answers guys.
@Theo:
I tried the replace several different ways. For some reason it would never error, but never update the list.
@Matt:
I figured out a solution. The issue wasn't coming from what you suggested, but from how the delete works with Lists (at least how I have it in this instance).
The Da... |
10,985 | <p>Does anyone know how I can, in platform-independent C++ code prevent an object from being created on the heap? That is, for a class "Foo", I want to prevent users from doing this:</p>
<pre><code>Foo *ptr = new Foo;
</code></pre>
<p>and only allow them to do this:</p>
<pre><code>Foo myfooObject;
</code></pre>
<p>... | [
{
"answer_id": 11000,
"author": "David",
"author_id": 381,
"author_profile": "https://Stackoverflow.com/users/381",
"pm_score": 0,
"selected": false,
"text": "<p>You could declare a function called \"operator new\" inside the Foo class which would block the access to the normal form of n... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1304/"
] | Does anyone know how I can, in platform-independent C++ code prevent an object from being created on the heap? That is, for a class "Foo", I want to prevent users from doing this:
```
Foo *ptr = new Foo;
```
and only allow them to do this:
```
Foo myfooObject;
```
Does anyone have any ideas?
Cheers, | [Nick's answer](https://stackoverflow.com/questions/10985/how-to-prevent-an-object-being-created-on-the-heap#11003) is a good starting point, but incomplete, as you actually need to overload:
```
private:
void* operator new(size_t); // standard new
void* operator new(size_t, void*); // placement new... |
10,990 | <p>Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups.</p>
<p>I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user for the upload process to work, so I created the folder and then set p... | [
{
"answer_id": 11005,
"author": "Ryan Ahearn",
"author_id": 75,
"author_profile": "https://Stackoverflow.com/users/75",
"pm_score": 7,
"selected": true,
"text": "<p>You can create a new group with both the apache user and FTP user as members and then make the permission on the upload fol... | 2008/08/14 | [
"https://Stackoverflow.com/questions/10990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1153/"
] | Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups.
I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user for the upload process to work, so I created the folder and then set permissions... | You can create a new group with both the apache user and FTP user as members and then make the permission on the upload folder 775. This should give both the apache and FTP users the ability to write to the files in the folder but keep everyone else from modifying them. |
11,028 | <p>When I'm joining three or more tables together by a common column, I'd write my query like this:</p>
<pre><code>SELECT *
FROM a, b, c
WHERE a.id = b.id
AND b.id = c.id
</code></pre>
<p>a colleague recently asked my why I didn't do explicit <em>Join Transitive Closure</em> in my queries like this:</p>
<pre><... | [
{
"answer_id": 11031,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 2,
"selected": false,
"text": "<p>No this syntax stems from the days before joins were in the language. Not sure of the problems associated with it, but t... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1030/"
] | When I'm joining three or more tables together by a common column, I'd write my query like this:
```
SELECT *
FROM a, b, c
WHERE a.id = b.id
AND b.id = c.id
```
a colleague recently asked my why I didn't do explicit *Join Transitive Closure* in my queries like this:
```
SELECT *
FROM a, b, c
WHERE a.id = b... | You don't need to do this in todays database engines, but there was a time when things like that would give the query optimizer more hints as to possible index paths and thus to speedier results.
These days that entire syntax is going out anyway. |
11,043 | <p>What are the pros and cons of using table aliases in SQL? I personally try to avoid them, as I think they make the code less readable (especially when reading through large where/and statements), but I'd be interested in hearing any counter-points to this. When is it generally a good idea to use table aliases, and... | [
{
"answer_id": 11049,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 5,
"selected": false,
"text": "<p>Well, there are some cases you <em>must</em> use them, like when you need to join to the same table twice in one qu... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/637/"
] | What are the pros and cons of using table aliases in SQL? I personally try to avoid them, as I think they make the code less readable (especially when reading through large where/and statements), but I'd be interested in hearing any counter-points to this. When is it generally a good idea to use table aliases, and do y... | Table aliases are a necessary evil when dealing with highly normalized schemas. For example, and I'm not the architect on this DB so bear with me, it can take 7 joins in order to get a clean and complete record back which includes a person's name, address, phone number and company affiliation.
Rather than the somewha... |
11,045 | <p>How can I get a user-defined function to re-evaluate itself based on changed data in the spreadsheet?</p>
<p>I tried <strong><kbd>F9</kbd></strong> and <strong><kbd>Shift</kbd>+<kbd>F9</kbd></strong>.</p>
<p>The only thing that seems to work is editing the cell with the function call and then pressing Enter.</p>
| [
{
"answer_id": 11061,
"author": "Brian Sullivan",
"author_id": 767,
"author_profile": "https://Stackoverflow.com/users/767",
"pm_score": 4,
"selected": false,
"text": "<p>Okay, found this one myself. You can use <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>F9</kbd> to accomplish this.</p>\n"
}... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/767/"
] | How can I get a user-defined function to re-evaluate itself based on changed data in the spreadsheet?
I tried **`F9`** and **`Shift`+`F9`**.
The only thing that seems to work is editing the cell with the function call and then pressing Enter. | You should use `Application.Volatile` in the top of your function:
```
Function doubleMe(d)
Application.Volatile
doubleMe = d * 2
End Function
```
It will then reevaluate whenever the workbook changes (if your calculation is set to automatic). |
11,085 | <p>In Perl, an object is just a reference to any of the basic Perl data types that has been blessed into a particular class. When you use the ref() function on an unblessed reference, you are told what data type the reference points to. However, when you call ref() on a blessed reference, you are returned the name of... | [
{
"answer_id": 42237,
"author": "Jagmal",
"author_id": 4406,
"author_profile": "https://Stackoverflow.com/users/4406",
"pm_score": 2,
"selected": false,
"text": "<p>And my first thought on this was: \"Objects in Perl are always hash refs, so what the hack?\"</p>\n\n<p>But, Scalar::Util::... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/166/"
] | In Perl, an object is just a reference to any of the basic Perl data types that has been blessed into a particular class. When you use the ref() function on an unblessed reference, you are told what data type the reference points to. However, when you call ref() on a blessed reference, you are returned the name of the ... | `Scalar::Util::reftype()` is the cleanest solution. The [`Scalar::Util`](http://search.cpan.org/dist/Scalar-List-Utils/lib/Scalar/Util.pm) module was added to the Perl core in version 5.7 but is available for older versions (5.004 or later) from CPAN.
You can also probe with `UNIVERSAL::isa()`:
```
$x->isa('HASH') ... |
11,088 | <p>In Java, there is no such thing as an unsigned byte.</p>
<p>Working with some low level code, occasionally you need to work with bytes that have unsigned values greater than 128, which causes Java to interpret them as a negative number due to the MSB being used for sign.</p>
<p>What's a good way to work around thi... | [
{
"answer_id": 11092,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": -1,
"selected": false,
"text": "<p>I guess you could just use a short to store them. Not very efficient, but really the only option besides some herculean... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1309/"
] | In Java, there is no such thing as an unsigned byte.
Working with some low level code, occasionally you need to work with bytes that have unsigned values greater than 128, which causes Java to interpret them as a negative number due to the MSB being used for sign.
What's a good way to work around this? (Saying don't ... | When reading any single value from the array copy it into something like a short or an int and manually convert the negative number into the positive value it should be.
```
byte[] foobar = ..;
int value = foobar[10];
if (value < 0) value += 256 // Patch up the 'falsely' negative value
```
You can do a similar conve... |
11,099 | <p>In the case of languages that support single decision and action without brackets, such as the following example:</p>
<pre><code>if (var == true)
doSomething();
</code></pre>
<p>What is the preferred way of writing this? Should brackets always be used, or should their usage be left as a preference of the indiv... | [
{
"answer_id": 11102,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 2,
"selected": false,
"text": "<p>It doesn't really matter, as long as you're consistent with it.</p>\n\n<p>There does seem to be a tendency to demand sameness wi... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1185/"
] | In the case of languages that support single decision and action without brackets, such as the following example:
```
if (var == true)
doSomething();
```
What is the preferred way of writing this? Should brackets always be used, or should their usage be left as a preference of the individual developer? Additiona... | There isn't really a right answer. This is what coding standards within the company are for. If you can keep it consistent across the whole company then it will be easy to read. I personally like
```
if ( a == b) {
doSomething();
}
else {
doSomething();
}
```
but this is a holy war. |
11,112 | <p>Most wiki software I've presents lots of "features" on their pages. This is fine for desktop users, but is annoying when using an iPhone or other mobile device. <br /><br />I'd prefer pages that just had the content, along with maybe an Edit button and a Search button. The editors are also often too fancy for mob... | [
{
"answer_id": 11102,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 2,
"selected": false,
"text": "<p>It doesn't really matter, as long as you're consistent with it.</p>\n\n<p>There does seem to be a tendency to demand sameness wi... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1175/"
] | Most wiki software I've presents lots of "features" on their pages. This is fine for desktop users, but is annoying when using an iPhone or other mobile device.
I'd prefer pages that just had the content, along with maybe an Edit button and a Search button. The editors are also often too fancy for mobile users; a s... | There isn't really a right answer. This is what coding standards within the company are for. If you can keep it consistent across the whole company then it will be easy to read. I personally like
```
if ( a == b) {
doSomething();
}
else {
doSomething();
}
```
but this is a holy war. |
11,141 | <p>Recently I have been investigating the possibilities of caching in ASP.NET.</p>
<p>I rolled my own "Cache", because I didn't know any better, it looked a bit like this:</p>
<pre><code>public class DataManager
{
private static DataManager s_instance;
public static DataManager GetInstance()
{
... | [
{
"answer_id": 11146,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 3,
"selected": true,
"text": "<p>I think the maxim \"let the computer do it; it's smarter than you\" applies here. Just like memory management and ot... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Recently I have been investigating the possibilities of caching in ASP.NET.
I rolled my own "Cache", because I didn't know any better, it looked a bit like this:
```
public class DataManager
{
private static DataManager s_instance;
public static DataManager GetInstance()
{
}
private D... | I think the maxim "let the computer do it; it's smarter than you" applies here. Just like memory management and other complicated things, the computer is a lot more informed about what it's doing than your are; consequently, able to get more performance than you are.
Microsoft has had a team of engineers working on it... |
11,194 | <p>We're working on a Log Viewer. The use will have the option to filter by user, severity, etc. In the Sql days I'd add to the query string, but I want to do it with Linq. How can I conditionally add where-clauses?</p>
| [
{
"answer_id": 11201,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 0,
"selected": false,
"text": "<p>Just use C#'s && operator:</p>\n\n<pre><code>var items = dc.Users.Where(l => l.Date == DateTime.Today &a... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1204/"
] | We're working on a Log Viewer. The use will have the option to filter by user, severity, etc. In the Sql days I'd add to the query string, but I want to do it with Linq. How can I conditionally add where-clauses? | if you want to only filter if certain criteria is passed, do something like this
```
var logs = from log in context.Logs
select log;
if (filterBySeverity)
logs = logs.Where(p => p.Severity == severity);
if (filterByUser)
logs = logs.Where(p => p.User == user);
```
Doing so this way will allow yo... |