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 |
|---|---|---|---|---|---|---|
513,672 | <pre><code> using (FileStream fileStream = new FileStream(path))
{
// do something
}
</code></pre>
<p>Now I know the using pattern is an implementation of IDisposable, namely that a Try/Catch/Finally is set up and Dispose is called on the object. My question is how the Close method is handled.</p>
<p><a href... | [
{
"answer_id": 513683,
"author": "George Mauer",
"author_id": 5056,
"author_profile": "https://Stackoverflow.com/users/5056",
"pm_score": 3,
"selected": false,
"text": "<p>using calls Dispose() only. The Dispose() method might call Close() if that is how it is implemented.</p>\n"
},
... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8873/"
] | ```
using (FileStream fileStream = new FileStream(path))
{
// do something
}
```
Now I know the using pattern is an implementation of IDisposable, namely that a Try/Catch/Finally is set up and Dispose is called on the object. My question is how the Close method is handled.
[MSDN](http://msdn.microsoft.com/... | The `using` statement *only* knows about `Dispose()`, but `Stream.Dispose` calls `Close()`, as [documented in MSDN](http://msdn.microsoft.com/en-us/library/ms227422.aspx):
>
> Note that because of backward
> compatibility requirements, this
> method's implementation differs from
> the recommended guidance for the
... |
513,675 | <p>I'm using Python 2.6 to read latin2 encoded file with windows line endings ('\r\n').</p>
<pre><code>import codecs
file = codecs.open('stackoverflow_secrets.txt', encoding='latin2', mode='rt')
line = file.readline()
print(repr(line))
</code></pre>
<p>outputs : <code>u'login: yabcok\n'</code></p>
<pre><code>file =... | [
{
"answer_id": 513820,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 2,
"selected": false,
"text": "<p>Are you sure that your examples are correct? The <a href=\"http://docs.python.org/library/codecs.html#module-codecs... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43399/"
] | I'm using Python 2.6 to read latin2 encoded file with windows line endings ('\r\n').
```
import codecs
file = codecs.open('stackoverflow_secrets.txt', encoding='latin2', mode='rt')
line = file.readline()
print(repr(line))
```
outputs : `u'login: yabcok\n'`
```
file = codecs.open('stackoverflow_secrets.txt', encodi... | Are you sure that your examples are correct? The [documentation](http://docs.python.org/library/codecs.html#module-codecs) of the codecs module says:
>
> Note: Files are always opened in binary mode, even if no binary mode was specified. This is done to avoid data loss due to encodings using 8-bit values. This means... |
513,676 | <p>I am trying to following instructions to import android java source to
eclipse on mac:</p>
<p><a href="http://source.android.com/source/using-eclipse.html" rel="noreferrer">http://source.android.com/source/using-eclipse.html</a></p>
<p>I did create a new partition ('Mac OS Extended, case sensitive, journaled) on M... | [
{
"answer_id": 4864853,
"author": "ajh158",
"author_id": 273628,
"author_profile": "https://Stackoverflow.com/users/273628",
"pm_score": 5,
"selected": false,
"text": "<p>I just ran into this issue. It occurs when you have a case mismatch on package names. I resolved it by closing Ecli... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60311/"
] | I am trying to following instructions to import android java source to
eclipse on mac:
<http://source.android.com/source/using-eclipse.html>
I did create a new partition ('Mac OS Extended, case sensitive, journaled) on Mac.
I was able to build android sdk successfully at command line.
But when I try to create a new ... | I just ran into this issue. It occurs when you have a case mismatch on package names. I resolved it by closing Eclipse and reconciling all package names in my project folder (under bin, gen and src) as well as in my AndroidManifest.xml. Once everything matched, I reopened Eclipse, did a Clean and Build and the error we... |
513,678 | <p>I have created a custom TextBox control which also contains a RequiredFieldValidator. Everything works fine but the problem is in display. The display is something like this: </p>
<pre><code>[TextBox Control] [Validation Error Message]
</code></pre>
<p>I want the display to be something like this: (the validation... | [
{
"answer_id": 513730,
"author": "azamsharp",
"author_id": 3797,
"author_profile": "https://Stackoverflow.com/users/3797",
"pm_score": 0,
"selected": false,
"text": "<p>Here is the ugly solution: </p>\n\n<pre><code>protected override void Render(System.Web.UI.HtmlTextWriter writer)\n ... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3797/"
] | I have created a custom TextBox control which also contains a RequiredFieldValidator. Everything works fine but the problem is in display. The display is something like this:
```
[TextBox Control] [Validation Error Message]
```
I want the display to be something like this: (the validation error message should be a... | You're really close to doing it right! Try this:
```
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
if(_req != null)
_req.RenderControl(writer);
base.Render(writer);
}
```
That will render the validation control before your TextBox instead of afterwards. If you want to change t... |
513,697 | <p>I have several somewhat separate programs, that conceptually can fit into a single project. However, I'm having trouble telling Eclipse to make several folders inside a project folder.</p>
<p>A simple form of the structure would be:</p>
<pre><code>/UberProject
/UberProject/ProgramA/
/UberProject/ProgramA/com/pkg/... | [
{
"answer_id": 513699,
"author": "Mat",
"author_id": 42974,
"author_profile": "https://Stackoverflow.com/users/42974",
"pm_score": 2,
"selected": false,
"text": "<p>Do you need UberProject? I have the same layout but have multiple top-level projects created with File|New project. If not,... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18160/"
] | I have several somewhat separate programs, that conceptually can fit into a single project. However, I'm having trouble telling Eclipse to make several folders inside a project folder.
A simple form of the structure would be:
```
/UberProject
/UberProject/ProgramA/
/UberProject/ProgramA/com/pkg/NiftyReader.java
/Uber... | There are probably several ways to do this:
1) UberProject is your JavaProject. Right click ProgramA -> Build Path -> Use as source folder. Right click ProgramB -> Build Path -> Use as source folder. Both ProgramA and ProgramB will do incremental builds to the same directory.
2) Two java projects (ProgramA and Progra... |
513,718 | <p>I'm inserting a large amount of rows into an empty table with a primary key constraint on one column.
If there is a duplicate key error, is there any way to find out the value of the key (or row) that caused the error?</p>
<p>Validating the data prior to the insert is sadly not something I can do right now.</p>
<p... | [
{
"answer_id": 513775,
"author": "Bravax",
"author_id": 13911,
"author_profile": "https://Stackoverflow.com/users/13911",
"pm_score": 0,
"selected": false,
"text": "<p>Revised:<br>\nSince you don't want to insert twice, could you:</p>\n\n<pre><code>Drop the primary key constraint.\nInser... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62651/"
] | I'm inserting a large amount of rows into an empty table with a primary key constraint on one column.
If there is a duplicate key error, is there any way to find out the value of the key (or row) that caused the error?
Validating the data prior to the insert is sadly not something I can do right now.
Using SQL 2008.
... | There's not a way of doing it that won't slow your process down, but here's one way that will make it easier. You can add an instead-of trigger on that table for inserts and updates. The trigger will check each record before inserting it and make sure it won't cause a primary key violation. You can even create a second... |
513,727 | <p>I am 'fixing up' an old Access Database, and the client requested that a DATE field be added to a form.
Problem is, I have NEVER used Access before. I'm a SQL guy, and I build my own UI's.
This forms thing is getting the better of me.</p>
<p>Ok - So I have two tables:
tblQuestionairre
QuestionairreID
EventID
blah ... | [
{
"answer_id": 513775,
"author": "Bravax",
"author_id": 13911,
"author_profile": "https://Stackoverflow.com/users/13911",
"pm_score": 0,
"selected": false,
"text": "<p>Revised:<br>\nSince you don't want to insert twice, could you:</p>\n\n<pre><code>Drop the primary key constraint.\nInser... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13959/"
] | I am 'fixing up' an old Access Database, and the client requested that a DATE field be added to a form.
Problem is, I have NEVER used Access before. I'm a SQL guy, and I build my own UI's.
This forms thing is getting the better of me.
Ok - So I have two tables:
tblQuestionairre
QuestionairreID
EventID
blah blah blah
... | There's not a way of doing it that won't slow your process down, but here's one way that will make it easier. You can add an instead-of trigger on that table for inserts and updates. The trigger will check each record before inserting it and make sure it won't cause a primary key violation. You can even create a second... |
513,735 | <p>When I click <code>togglediv</code>, <strong><code>commentdiv</code></strong> must be visible or hidden. The following code is running on Firefox but not Internet Explorer: </p>
<pre><code>$(document).ready(function(){
$("#togglediv").click(function(){
if( $("#commentdiv").is(":visible") ) {
... | [
{
"answer_id": 513752,
"author": "jeroen",
"author_id": 42139,
"author_profile": "https://Stackoverflow.com/users/42139",
"pm_score": 3,
"selected": false,
"text": "<p>There is a function <strong>toggle</strong> in jquery that does exactly what you want without having to check for visibi... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62659/"
] | When I click `togglediv`, **`commentdiv`** must be visible or hidden. The following code is running on Firefox but not Internet Explorer:
```
$(document).ready(function(){
$("#togglediv").click(function(){
if( $("#commentdiv").is(":visible") ) {
$("#commentdiv").hide("slow");
$("#... | I would try:
```
$(document).ready(function() {
$("#togglediv").click(function() {
// note: do this first because the :hidden test fails if you
// do it after triggering a slow animation
$("#togglediv").text($("#commentdiv").is(":hidden") ? "Hide" : "Sgiw");
$("#commentdiv").toggle('slow');
});
});... |
513,747 | <p>I have a website that is MySQL/PHP. Occasionally, I cannot connect because of</p>
<pre><code>Warning: mysql_connect() [function.mysql-connect]:
User foo has already more than 'max_user_connections' active connections in /home/foo/public_html/utilities.php
</code></pre>
<p>I use a discount web host service and can'... | [
{
"answer_id": 513759,
"author": "cbrulak",
"author_id": 29505,
"author_profile": "https://Stackoverflow.com/users/29505",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://pear.php.net/package/MDB2\" rel=\"nofollow noreferrer\">Pear MDB2</a></p>\n\n<p>I would use Pear MD2B,... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a website that is MySQL/PHP. Occasionally, I cannot connect because of
```
Warning: mysql_connect() [function.mysql-connect]:
User foo has already more than 'max_user_connections' active connections in /home/foo/public_html/utilities.php
```
I use a discount web host service and can't really prevent it from h... | If you turn off displaying errors (which you should probably do in production anyway), then you can then print your own error if the connection attempt fails.
```
ini_set('display_errors', false);
if (!$link = mysql_connect($host, $user, $pass)) {
die('could not connect...');
}
```
If you can't change the ini se... |
513,768 | <p>When you install a ClickOnce application, the program runs after the install. Is it possible to install <em>without</em> running?</p>
<p>I know I can use a setup and deployment project and create an installer, but I'd prefer to use ClickOnce.</p>
| [
{
"answer_id": 513825,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": true,
"text": "<p>I guess you could fake it. Introduce an \"IsInstalled\" boolean property, defaulted to false. Then in Program.cs, chan... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1616/"
] | When you install a ClickOnce application, the program runs after the install. Is it possible to install *without* running?
I know I can use a setup and deployment project and create an installer, but I'd prefer to use ClickOnce. | I guess you could fake it. Introduce an "IsInstalled" boolean property, defaulted to false. Then in Program.cs, change your Main() method to look like this:
```
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!Properties.Settings... |
513,774 | <p>I’m trying to set up a server to data-source paged service. I’ve got everything set up so that I’m getting my assembler called and am returning values, but I’m not getting “paged” calls.</p>
<p>Specifically:</p>
<pre><code>public Collection fill(List fillArgs, int begin, int rows)
</code></pre>
<p>is always call... | [
{
"answer_id": 513825,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": true,
"text": "<p>I guess you could fake it. Introduce an \"IsInstalled\" boolean property, defaulted to false. Then in Program.cs, chan... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62660/"
] | I’m trying to set up a server to data-source paged service. I’ve got everything set up so that I’m getting my assembler called and am returning values, but I’m not getting “paged” calls.
Specifically:
```
public Collection fill(List fillArgs, int begin, int rows)
```
is always called with `begin == -1` and `rows ==... | I guess you could fake it. Introduce an "IsInstalled" boolean property, defaulted to false. Then in Program.cs, change your Main() method to look like this:
```
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!Properties.Settings... |
513,783 | <p>I've got a windows forms map in a WindowsFormsHost, and I need it to resize with the window.</p>
<p>I'm just not sure what event to listen to, to do this. I need the map to only resize once the mouse is up, otherwise it lags out, and tries drawing itself a million times when you resize a window really slowly.</p>
| [
{
"answer_id": 514052,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 4,
"selected": true,
"text": "<p>Waiting on a timer is a very, very bad idea, quite simply, it's a heuristic and you are guessing when the resize opera... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66731/"
] | I've got a windows forms map in a WindowsFormsHost, and I need it to resize with the window.
I'm just not sure what event to listen to, to do this. I need the map to only resize once the mouse is up, otherwise it lags out, and tries drawing itself a million times when you resize a window really slowly. | Waiting on a timer is a very, very bad idea, quite simply, it's a heuristic and you are guessing when the resize operation is done.
A better idea would be to derive a class from [`WindowsFormsHost`](http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.aspx) and override the [`WndPr... |
513,785 | <p>I wrote an answer yesterday to this:
<a href="https://stackoverflow.com/questions/192479/whats-the-coolest-hack-youve-seen-or-done">What's the coolest hack you've seen or done?</a>
and I was trying really hard to remember my 6502 assembly, and I couldn't for the life of me remember how to branch if less than... | [
{
"answer_id": 513845,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 0,
"selected": false,
"text": "<p>First Google hit: <a href=\"http://en.wikibooks.org/wiki/6502_Assembly#Branch\" rel=\"nofollow noreferrer\">http:/... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12386/"
] | I wrote an answer yesterday to this:
[What's the coolest hack you've seen or done?](https://stackoverflow.com/questions/192479/whats-the-coolest-hack-youve-seen-or-done)
and I was trying really hard to remember my 6502 assembly, and I couldn't for the life of me remember how to branch if less than...
```
:1
lda $C... | **BCC is branch if less than**; BCS is branch if greater than or equal. There's a nice tutorial [here](http://www.6502.org/tutorials/compare_beyond.html).
However stu's code can be written more concisely without CMP:
```
BIT $C010 ;clear the keyboard strobe
:1
LDA $C000 ;check for a keypress
BPL :1 ;ta... |
513,788 | <p>The only way I came up for deleting a file from a zipfile was to create a temporary zipfile without the file to be deleted and then rename it to the original filename.</p>
<p>In python 2.4 the ZipInfo class had an attribute <code>file_offset</code>, so it was possible to create a second zip file and copy the data t... | [
{
"answer_id": 513889,
"author": "mdm",
"author_id": 25318,
"author_profile": "https://Stackoverflow.com/users/25318",
"pm_score": 6,
"selected": false,
"text": "<p>The following snippet worked for me (deletes all *.exe files from a Zip archive):</p>\n\n<pre><code>zin = zipfile.ZipFile (... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49219/"
] | The only way I came up for deleting a file from a zipfile was to create a temporary zipfile without the file to be deleted and then rename it to the original filename.
In python 2.4 the ZipInfo class had an attribute `file_offset`, so it was possible to create a second zip file and copy the data to other file without ... | The following snippet worked for me (deletes all \*.exe files from a Zip archive):
```
zin = zipfile.ZipFile ('archive.zip', 'r')
zout = zipfile.ZipFile ('archve_new.zip', 'w')
for item in zin.infolist():
buffer = zin.read(item.filename)
if (item.filename[-4:] != '.exe'):
zout.writestr(item, buffer)
zo... |
513,793 | <p>I am making use of AJAX on my site and I would like to show users progress of a file that is being downloaded by my server.</p>
<p>The download is done by script that <strong>outputs a percentage to the shell</strong>. I would like to pass this info back to the user using AJAX. How can I do this?</p>
<p>Thank you ... | [
{
"answer_id": 513842,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 3,
"selected": true,
"text": "<p>Instead of exec, you could use <a href=\"http://uk3.php.net/popen\" rel=\"nofollow noreferrer\">popen</a>. This will gi... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51649/"
] | I am making use of AJAX on my site and I would like to show users progress of a file that is being downloaded by my server.
The download is done by script that **outputs a percentage to the shell**. I would like to pass this info back to the user using AJAX. How can I do this?
Thank you for any help and direction.
I... | Instead of exec, you could use [popen](http://uk3.php.net/popen). This will give you a handle you use with fread to grab the output your command generates as it happens.
You'll need to parse out the updates it makes to the percentage indicator. Once you have that data, there are a few ways you could get it to a client... |
513,800 | <p>From the facebook canvas, I need to be able to access an iframe window. Normally you could do this with window.frames, but FJBS doesn't seem to allow access to the window object.</p>
<p>Has anyone figured out how to access window objects?</p>
| [
{
"answer_id": 515034,
"author": "meouw",
"author_id": 12161,
"author_profile": "https://Stackoverflow.com/users/12161",
"pm_score": 3,
"selected": false,
"text": "<p>you could try this. Let me know how it works. </p>\n\n<pre><code>var myIframe = document.getElementById('myIframeId');\n... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20176/"
] | From the facebook canvas, I need to be able to access an iframe window. Normally you could do this with window.frames, but FJBS doesn't seem to allow access to the window object.
Has anyone figured out how to access window objects? | you could try this. Let me know how it works.
```
var myIframe = document.getElementById('myIframeId');
// could retrieve window or document depending on the browser
// (if FBJS allows it!?)
var myIframeWin = myIframe.contentWindow || myIframe.contentDocument;
if( !myIframeWin.document ) { //we've found the documen... |
513,802 | <p>While parsing an XML File using the XMLReader Method, how do I get the parent node of an element ?</p>
<pre><code>$xml = new XMLReader();
$xml->XML($xmlString);
while($xml->read())
{
$xml->localName; // gives tag name
$xml->value; // gives tag value
// how do I access the parent of this element
}
</c... | [
{
"answer_id": 513809,
"author": "cbrulak",
"author_id": 29505,
"author_profile": "https://Stackoverflow.com/users/29505",
"pm_score": 0,
"selected": false,
"text": "<p>I think you want: <a href=\"http://ca.php.net/manual/en/xmlreader.movetoelement.php\" rel=\"nofollow noreferrer\">XMLRe... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241755/"
] | While parsing an XML File using the XMLReader Method, how do I get the parent node of an element ?
```
$xml = new XMLReader();
$xml->XML($xmlString);
while($xml->read())
{
$xml->localName; // gives tag name
$xml->value; // gives tag value
// how do I access the parent of this element
}
``` | Short Version: You don't, at least not directly. It's up to the programmer to code context into their parsing algorithm with XMLReader.
Long Version: PHP's XMLReader is what's called a *pull parser*. Pull parsers differ from a tree/dom based parser in that they can deal with text streams. In other words, they can begi... |
513,806 | <p>I've written several scripts that make use of the gdata API, and they all (obviously) have my API key and client ID in plain-text. How am I supposed to distribute these?</p>
| [
{
"answer_id": 513829,
"author": "Sam Corder",
"author_id": 2351,
"author_profile": "https://Stackoverflow.com/users/2351",
"pm_score": 3,
"selected": true,
"text": "<p>Move the variables into a separate module and replace your values with dummy values. Make sure you trap for an invalid... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62673/"
] | I've written several scripts that make use of the gdata API, and they all (obviously) have my API key and client ID in plain-text. How am I supposed to distribute these? | Move the variables into a separate module and replace your values with dummy values. Make sure you trap for an invalid key and provide instructions on how to obtain a key and where to place it. In your code you can just import the values from that module.
```
import gdata_api_key
print gdata_api_key.key_value
``` |
513,818 | <p>Is there a standard way to bind arrays (of scalars) in a SQL query? I want to bind into an <code>IN</code> clause, like so:</p>
<pre><code>SELECT * FROM junk WHERE junk.id IN (?);
</code></pre>
<p>I happen to be using <code>Perl::DBI</code> which coerces parameters to scalars, so I end up with useless queries like... | [
{
"answer_id": 513859,
"author": "John Fouhy",
"author_id": 15154,
"author_profile": "https://Stackoverflow.com/users/15154",
"pm_score": 2,
"selected": false,
"text": "<p>In python, I've always ended up doing something like:</p>\n\n<pre><code>query = 'select * from junk where junk.id in... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | Is there a standard way to bind arrays (of scalars) in a SQL query? I want to bind into an `IN` clause, like so:
```
SELECT * FROM junk WHERE junk.id IN (?);
```
I happen to be using `Perl::DBI` which coerces parameters to scalars, so I end up with useless queries like:
```
SELECT * FROM junk WHERE junk.id IN ('ARR... | You specify "this is the SQL for a query with one parameter" -- that won't work when you want many parameters. It's a pain to deal with, of course. Two other variations to what was suggested already:
1) Use DBI->quote instead of place holders.
```
my $sql = "select foo from bar where baz in ("
. join(",", ... |
513,823 | <p>I'm consuming a webservice from my application in C# .net (2.0) that return values (as string) like this:</p>
<pre><code>%23k.%0d%16%c4%8a%18%efG%28%b9c%12%b7%f1%e2%e7j%93
</code></pre>
<p>I know that the real value for that is:</p>
<pre><code>236B2E0D16C48A18EF4728B96312B7F1E2E76A93
</code></pre>
<p>But I don't... | [
{
"answer_id": 513828,
"author": "eulerfx",
"author_id": 13855,
"author_profile": "https://Stackoverflow.com/users/13855",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not certain of this, but try using the System.Web.HttpUtility.UrlDecode method</p>\n"
},
{
"answer_id": 513... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] | I'm consuming a webservice from my application in C# .net (2.0) that return values (as string) like this:
```
%23k.%0d%16%c4%8a%18%efG%28%b9c%12%b7%f1%e2%e7j%93
```
I know that the real value for that is:
```
236B2E0D16C48A18EF4728B96312B7F1E2E76A93
```
But I don't know how to convert from the returned value to t... | Going down the line:
If you encounter '%' copy the next two characters
Otherwise take the ascii code of the character found and output as hex
```
%23 => 23
k => 6B
. => 2E
%0d => 0D
```
[ASCII Table](http://www.asciitable.com/)
But in code I'm pretty sure this will work:
```
char c = 'k';
int ascii = (in... |
513,832 | <p>I've been using the <code>==</code> operator in my program to compare all my strings so far.
However, I ran into a bug, changed one of them into <code>.equals()</code> instead, and it fixed the bug.</p>
<p>Is <code>==</code> bad? When should it and should it not be used? What's the difference?</p>
| [
{
"answer_id": 513839,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 14,
"selected": true,
"text": "<p><code>==</code> tests for reference equality (whether they are the same object).</p>\n<p><code>.equals()</code> tes... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25645/"
] | I've been using the `==` operator in my program to compare all my strings so far.
However, I ran into a bug, changed one of them into `.equals()` instead, and it fixed the bug.
Is `==` bad? When should it and should it not be used? What's the difference? | `==` tests for reference equality (whether they are the same object).
`.equals()` tests for value equality (whether they contain the same data).
[Objects.equals()](http://docs.oracle.com/javase/7/docs/api/java/util/Objects.html#equals(java.lang.Object,%20java.lang.Object)) checks for `null` before calling `.equals()`... |
513,837 | <p>Yesterday I was playing with jQGrid plugin and ASP.NET. Everything turned out well, my grid is working now, but I have two methods, that make my code smell. </p>
<p>Smelly methods:</p>
<pre><code>private IOrderedEnumerable<Employee> GetOrderedEmployees(Column sortColumn, bool ascending)
{
switch ... | [
{
"answer_id": 513843,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 4,
"selected": true,
"text": "<p>I think that you may be going over the top here. Returning lambdas (IMO) is far more confusing than a simple switch stateme... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62664/"
] | Yesterday I was playing with jQGrid plugin and ASP.NET. Everything turned out well, my grid is working now, but I have two methods, that make my code smell.
Smelly methods:
```
private IOrderedEnumerable<Employee> GetOrderedEmployees(Column sortColumn, bool ascending)
{
switch (sortColumn)
{
... | I think that you may be going over the top here. Returning lambdas (IMO) is far more confusing than a simple switch statement or if;else if;else block. There may be a better way, but sometimes you do need to check a condition, especially with columns (I HATE working with ListViews, but they are necessary and often requ... |
513,865 | <p>I have a file with a little over a million lines.</p>
<pre><code> {<uri::rdfserver#null> <uri::d41d8cd98f00b204e9800998ecf8427e> <uri::TickerDailyPriceVolume> "693702"^^<xsd:long>}
{<uri::rdfserver#null> <uri::d41d8cd98f00b204e9800998ecf8427e> <uri::TickerDailyPriceId> <... | [
{
"answer_id": 513907,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 5,
"selected": true,
"text": "<p>The fastest (as shown below) is a simple string split:</p>\n<pre><code>line.Split(new char[] { '{', '<', '>', '}', ... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | I have a file with a little over a million lines.
```
{<uri::rdfserver#null> <uri::d41d8cd98f00b204e9800998ecf8427e> <uri::TickerDailyPriceVolume> "693702"^^<xsd:long>}
{<uri::rdfserver#null> <uri::d41d8cd98f00b204e9800998ecf8427e> <uri::TickerDailyPriceId> <uri::20fb8f7d-30ef-dd11-a78d-001f29e570a8>}
```
Each lin... | The fastest (as shown below) is a simple string split:
```
line.Split(new char[] { '{', '<', '>', '}', ' ', '^', '"' },
StringSplitOptions.RemoveEmptyEntries);
```
The next fastest is an anchored regular expression (ugly):
```
Regex lineParse
= new Regex(@"^\{(<([^>]+)>\s*){3,4}(""([^""]+)""\^\^<([^>... |
513,882 | <p>I have about 10million values that I need to put in some type of look up table, so I was wondering which would be more efficient a <i>list</i> or <i>dict</i>?</p>
<p>I know you can do something like this for both:</p>
<pre><code>if something in dict_of_stuff:
pass
</code></pre>
<p>and</p>
<pre><code>if somet... | [
{
"answer_id": 513886,
"author": "SilentGhost",
"author_id": 12855,
"author_profile": "https://Stackoverflow.com/users/12855",
"pm_score": 2,
"selected": false,
"text": "<p>if data are unique set() will be the most efficient, but of two - dict (which also requires uniqueness, oops :)</p>... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41718/"
] | I have about 10million values that I need to put in some type of look up table, so I was wondering which would be more efficient a *list* or *dict*?
I know you can do something like this for both:
```
if something in dict_of_stuff:
pass
```
and
```
if something in list_of_stuff:
pass
```
My thought is th... | Speed
=====
Lookups in lists are O(n), lookups in dictionaries are amortized O(1), with regard to the number of items in the data structure. If you don't need to associate values, use sets.
Memory
======
Both dictionaries and sets use hashing and they use much more memory than only for object storage. According to A... |
513,896 | <p>all. I'm using conditional commenting in IE to fix some CSS problem that i'm having with IE7.</p>
<p>I have a all.css file that work on firefox and ie7 with some execptions that will only fix the IE7 css problem. I put my fix on all_iefixes.css both files is in App_Themes/Default/ folder.</p>
<p>I use have a maste... | [
{
"answer_id": 513921,
"author": "BC.",
"author_id": 54838,
"author_profile": "https://Stackoverflow.com/users/54838",
"pm_score": 2,
"selected": false,
"text": "<p>You should avoid using relative paths in your master pages unless you can generate it with code:</p>\n\n<p>You can try usin... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] | all. I'm using conditional commenting in IE to fix some CSS problem that i'm having with IE7.
I have a all.css file that work on firefox and ie7 with some execptions that will only fix the IE7 css problem. I put my fix on all\_iefixes.css both files is in App\_Themes/Default/ folder.
I use have a master page (Default... | You should avoid using relative paths in your master pages unless you can generate it with code:
You can try using server tags to resolve the path, but this is not always possible (for instance, if youre manipulating the control tree in code)
```
@import "<% this.ResolveUrl("~/App_Themes/Default/all_iefixes.css") %>"... |
513,911 | <p>Given the following XML:</p>
<pre><code><databases>
<database>
<title_display>Aardvark</title_display>
</database>
<database>
<title_display>Apple</title_display>
</database>
<database>
<title_display>Blue&... | [
{
"answer_id": 513958,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 1,
"selected": false,
"text": "<p>You could try this for grouping. Note that xslt2.0 has a for-each-group that makes this much easier.</p>\n\n<pre><code>&... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43004/"
] | Given the following XML:
```
<databases>
<database>
<title_display>Aardvark</title_display>
</database>
<database>
<title_display>Apple</title_display>
</database>
<database>
<title_display>Blue</title_display>
</database>
<database>
<title_display>Car</title... | **Here is a more efficient solution, using the classical Muenchian method for grouping -- with keys**.
**This transformation**:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="vLower" select=
"'abcdefghi... |
513,912 | <p>I am coding VB.NET in VS2008.</p>
<p>I have a comma delimited string of numbers, i.e. 16,7,99,1456,1,3</p>
<p>I do this in VB:</p>
<pre><code>Dim MyArr() As String = MyString.Split(",")
</code></pre>
<p>Will MyArr keep the items in the order they were in the string?</p>
<p>If I do this:</p>
<pre><code>For Each... | [
{
"answer_id": 513917,
"author": "ahockley",
"author_id": 8209,
"author_profile": "https://Stackoverflow.com/users/8209",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, in your example the items will stay in the original order.</p>\n\n<p>The MSDN documentation indicates that an Array ... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22828/"
] | I am coding VB.NET in VS2008.
I have a comma delimited string of numbers, i.e. 16,7,99,1456,1,3
I do this in VB:
```
Dim MyArr() As String = MyString.Split(",")
```
Will MyArr keep the items in the order they were in the string?
If I do this:
```
For Each S as String in MyString.Split(",")
'Do something with... | Yes, in your example the items will stay in the original order.
The MSDN documentation indicates that an Array is not necessarily sorted just because it's an Array, but once the items are in the Array, they won't be rearranged. The Split() operation will break it down based on the given token, preserving the order. |
513,919 | <p>I am working with the OpenSSL library's X509 certificate class, and I need to query the "key usage" extension. </p>
<p>After abandoning OpenSSL's vapourware "documentation", some shot-in-the-dark web searching eventually revealed that I needed to call </p>
<pre><code>X509_get_ext_d2i(X509 *x, int nid, int *crit, i... | [
{
"answer_id": 514261,
"author": "Joe",
"author_id": 57135,
"author_profile": "https://Stackoverflow.com/users/57135",
"pm_score": 1,
"selected": false,
"text": "<p>The second parameter (nid) determines the returned type.</p>\n\n<p>Looking at this code:</p>\n\n<p><a href=\"http://opengro... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working with the OpenSSL library's X509 certificate class, and I need to query the "key usage" extension.
After abandoning OpenSSL's vapourware "documentation", some shot-in-the-dark web searching eventually revealed that I needed to call
```
X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx)
```
and s... | The easiest solutions to read the key usage seems to be
```
X509* x509_cert = ...
// without X509_check_ca x509_cert->ex_kusage always returns 0 (no idea why)
int ca = X509_check_ca(x509_cert);
unsigned long usage = x509_cert->ex_kusage;
```
The resulting values are defined in opensc/pkcs15-init.h
```
SC_PKCS15INIT... |
513,942 | <p>I have an action called List that shows the results of a search. It receives parameters through the querystring because they are optional. My method signature looks like this:</p>
<pre><code>public ActionResult List(List<int> categoryIDs, string school, int? stateID, int? page)
</code></pre>
<p>CategoryIDs i... | [
{
"answer_id": 514573,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to do this:</p>\n\n\n\n<p>All the current values should be passed in by default. I'd have to try it out ... | 2009/02/04 | [
"https://Stackoverflow.com/questions/513942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62686/"
] | I have an action called List that shows the results of a search. It receives parameters through the querystring because they are optional. My method signature looks like this:
```
public ActionResult List(List<int> categoryIDs, string school, int? stateID, int? page)
```
CategoryIDs is a multi-select box and I am do... | I think there's no `ActionLink` overload that helps you do that by default. You need to populate the `RouteValueDictionary` instance with the parameters you want to include.
For the list of category, try s/t like `categoryIDs=2,3,4,5` etc. since repeating keys are not allowed in `RouteValueDictionary`. After that, in... |
513,944 | <p>If you are going to be generating a page as a string and outputting all the content via Response.Write at the last minute where should you put this code?</p>
<p>I need to be able to dynamically write a bunch of JavaScript to the client to use some of the new Google visualization jsapi. I noticed this last release ... | [
{
"answer_id": 513993,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>Is the code parameterizable? That is can you control the differences between one invocation and another via some sm... | 2009/02/05 | [
"https://Stackoverflow.com/questions/513944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | If you are going to be generating a page as a string and outputting all the content via Response.Write at the last minute where should you put this code?
I need to be able to dynamically write a bunch of JavaScript to the client to use some of the new Google visualization jsapi. I noticed this last release of the MVC ... | You could also use the `ActionResult` type `Content` to return a plain string to the browser.
```
public ActionResult myAction() {
Return Content("Hello World!");
}
```
However, I am not sure whether this is the best approach when returning JavaScript. You might want to consider writing your own `JavaScriptResul... |
513,949 | <p>I have a standard ASP.NET MVC (RC Refresh) web project, with the standard ASP.NET Membership provider and the Account controller that is included in the project template.</p>
<p>When I check "Remember me" in my Login form, I am still not being remembered by the site. (Firefox remembers my username and password, but... | [
{
"answer_id": 514003,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>You need to generate a persistent cookie in the controller method that handles logon when the Remember Me box is che... | 2009/02/05 | [
"https://Stackoverflow.com/questions/513949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38055/"
] | I have a standard ASP.NET MVC (RC Refresh) web project, with the standard ASP.NET Membership provider and the Account controller that is included in the project template.
When I check "Remember me" in my Login form, I am still not being remembered by the site. (Firefox remembers my username and password, but what I ex... | You need to pass true/false to the SetAuthCookie method.
```
public ActionResult Login (string email, string password, bool rememberMe, string returnUrl)
{
// snip
FormsAuth.SetAuthCookie(username, rememberMe); // <- true/false
// snip
}
```
and make sure that `bool rememberMe` reflects the status o... |
513,952 | <p>I have:</p>
<pre><code>class Car {..}
class Other{
List<T> GetAll(){..}
}
</code></pre>
<p>I want to do:</p>
<pre><code>Type t = typeof(Car);
List<t> Cars = GetAll<t>();
</code></pre>
<p>How can I do this?</p>
<p>I want to return a generic collection from the database of a type that I discov... | [
{
"answer_id": 513967,
"author": "Tron",
"author_id": 22290,
"author_profile": "https://Stackoverflow.com/users/22290",
"pm_score": 6,
"selected": true,
"text": "<pre><code>Type generic = typeof(List<>); \nType specific = generic.MakeGenericType(typeof(int)); \nConstructorInf... | 2009/02/05 | [
"https://Stackoverflow.com/questions/513952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47619/"
] | I have:
```
class Car {..}
class Other{
List<T> GetAll(){..}
}
```
I want to do:
```
Type t = typeof(Car);
List<t> Cars = GetAll<t>();
```
How can I do this?
I want to return a generic collection from the database of a type that I discover at runtime using reflection. | ```
Type generic = typeof(List<>);
Type specific = generic.MakeGenericType(typeof(int));
ConstructorInfo ci = specific.GetConstructor(Type.EmptyTypes);
object o = ci.Invoke(new object[] { });
``` |
513,968 | <p>I have a project to do in school which is baffeling me... I am SSHing into a Solaris computer in the computer lab from my own Debian box via</p>
<pre><code>ssh -Y name@***.cs.<school>
</code></pre>
<p>I can get in just fine, and the X11 seems to be working also. However, this peticular project requires us ... | [
{
"answer_id": 514026,
"author": "derobert",
"author_id": 27727,
"author_profile": "https://Stackoverflow.com/users/27727",
"pm_score": 2,
"selected": false,
"text": "<p>When you use ssh -Y, you're requesting that remote clients be forwarded to your local X server, with full permissions.... | 2009/02/05 | [
"https://Stackoverflow.com/questions/513968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62248/"
] | I have a project to do in school which is baffeling me... I am SSHing into a Solaris computer in the computer lab from my own Debian box via
```
ssh -Y name@***.cs.<school>
```
I can get in just fine, and the X11 seems to be working also. However, this peticular project requires us to find the window id of a netscap... | I sat down to an actual machine to perform the same tests, and they all fail there too... I would open 2 netscape windows and try to direct the command to one at a time. The most recently opened one would work properly, but any command directed to the other one would be forwarded to the same window, so at this point I ... |
513,977 | <p>I am trying to put all the pieces together for my MVVM Silverlight application and I see some blogs touch on Service Locators. </p>
<p>What is a service locator and when should it be used?</p>
| [
{
"answer_id": 514494,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 1,
"selected": false,
"text": "<p>Service locator is a design pattern similiar to dependency injection.</p>\n\n<p>It allows a consumer to program aga... | 2009/02/05 | [
"https://Stackoverflow.com/questions/513977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/831/"
] | I am trying to put all the pieces together for my MVVM Silverlight application and I see some blogs touch on Service Locators.
What is a service locator and when should it be used? | I've used ServiceLocator in combination with MVVM to enable declarative binding from the View to the ViewModel.
The ServiceLocator is pull-based while IoC containers are push-based. For instance:
If you use an IoC container you'll probably create something like this:
```
public MyViewModel(IDataRepository repository... |
513,981 | <p>So I installed Ruby On Rails using the Windows Installer.</p>
<p>Now the startup guides says I have to start up an Terminal and run the Rails command to make a project. I don't have a terminal, so how do I execute a Rails command and make a project??</p>
<p>The CMD command line in Windows does not recognize "rails... | [
{
"answer_id": 513987,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I think they mean the command window. Try running it from a command line.</p>\n"
},
{
"answer_id": 513992,
"aut... | 2009/02/05 | [
"https://Stackoverflow.com/questions/513981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So I installed Ruby On Rails using the Windows Installer.
Now the startup guides says I have to start up an Terminal and run the Rails command to make a project. I don't have a terminal, so how do I execute a Rails command and make a project??
The CMD command line in Windows does not recognize "rails"
I don't think ... | It seems to be a bug in the rails.bat file because of double-quotes, like:
```
@"ruby.exe"" "%~dpn0" %*
```
Remove the double quotes:
<http://sepitfalls.blogspot.com/2008/12/updateing-rubygems-broke-gem-command.html> |
513,995 | <p>i have an image that contains a series of images, e.g.:</p>
<blockquote>
<p><a href="https://i.stack.imgur.com/MzWW1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MzWW1.png" alt="enter image description here"></a></p>
</blockquote>
<p>In the olden days, i would load the image into the <a hre... | [
{
"answer_id": 513987,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I think they mean the command window. Try running it from a command line.</p>\n"
},
{
"answer_id": 513992,
"aut... | 2009/02/05 | [
"https://Stackoverflow.com/questions/513995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] | i have an image that contains a series of images, e.g.:
>
> [](https://i.stack.imgur.com/MzWW1.png)
>
>
>
In the olden days, i would load the image into the [ImageList common control](http://msdn.microsoft.com/en-us/library/bb761389(VS.85).aspx) ... | It seems to be a bug in the rails.bat file because of double-quotes, like:
```
@"ruby.exe"" "%~dpn0" %*
```
Remove the double quotes:
<http://sepitfalls.blogspot.com/2008/12/updateing-rubygems-broke-gem-command.html> |
513,997 | <p>Is it better to use </p>
<pre><code>$.get("http://www.example.com/mydirectory", function(data) {
$(".someclass").html(data);
});
</code></pre>
<p>or </p>
<pre><code>$('.tripPlannerBottom').load("http://www.example.com/mydirectory");
</code></pre>
<p>any speed or performance benefits?</p>
| [
{
"answer_id": 514010,
"author": "Cody Caughlan",
"author_id": 25398,
"author_profile": "https://Stackoverflow.com/users/25398",
"pm_score": 4,
"selected": false,
"text": "<p>I have no benchmark data to back my claim up, but by looking at the source, $.get + html() and .load() are basica... | 2009/02/05 | [
"https://Stackoverflow.com/questions/513997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60461/"
] | Is it better to use
```
$.get("http://www.example.com/mydirectory", function(data) {
$(".someclass").html(data);
});
```
or
```
$('.tripPlannerBottom').load("http://www.example.com/mydirectory");
```
any speed or performance benefits? | .load, .get & .post are wrappers around the .ajax method.
There is no performance boost apart from few chars you save in typing without having to create the settings if using the .ajax method. |
514,018 | <p><strong>RESOLVED</strong></p>
<p>From the developer: the problem was that a previous version of the code was still writing to the table which used manual ids instead of the auto increment. Note to self: always check for other possible locations where the table is written to.</p>
<p>We are getting duplicate keys in... | [
{
"answer_id": 514032,
"author": "staticsan",
"author_id": 28832,
"author_profile": "https://Stackoverflow.com/users/28832",
"pm_score": 2,
"selected": false,
"text": "<p>Does the sales_id field have a primary (or unique) key? If not, then something else is probably making inserts or upd... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | **RESOLVED**
From the developer: the problem was that a previous version of the code was still writing to the table which used manual ids instead of the auto increment. Note to self: always check for other possible locations where the table is written to.
We are getting duplicate keys in a table. They are not inserte... | I have had a few duplicate key error suddenly appear in MySql databases in the past even though the primary key is defined and auto\_increment. Each and every time it has been because the table has become corrupted.
If it is corrupt performing a check tables should expose the problem. You can do this by running:
```
... |
514,023 | <p>I'm having trouble trying to think what the best way is to recreate a database object in a controller Action.</p>
<p>I want to make use of ModelBinders so in my action I have access to the object via a parameter, rather than having to repeat code to get an object from the database based on an identifier parameter. ... | [
{
"answer_id": 514062,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>I get the model object from the database, then use UpdateModel (or TryUpdateModel) on the object to update values fr... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5556/"
] | I'm having trouble trying to think what the best way is to recreate a database object in a controller Action.
I want to make use of ModelBinders so in my action I have access to the object via a parameter, rather than having to repeat code to get an object from the database based on an identifier parameter. So I was t... | I get the model object from the database, then use UpdateModel (or TryUpdateModel) on the object to update values from the form parameters.
```
public ActionResult Update( int id )
{
DataContext dc = new DataContext();
MyModel model = dc.MyModels.Where( m => m.ID == id ).SingleOrDefault();
string[] whi... |
514,029 | <p>So from this string:</p>
<p>"name[id]"</p>
<p>I need this:</p>
<p>"id"</p>
<p>I used str.split ('[]'), but it didn't work. Does it only take a single delimiter?</p>
| [
{
"answer_id": 514045,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 5,
"selected": true,
"text": "<p>Use a regular expression:</p>\n\n<pre><code>import re \ns = \"name[id]\"\nre.find(r\"\\[(.*?)\\]\", s).group(1) # = ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51816/"
] | So from this string:
"name[id]"
I need this:
"id"
I used str.split ('[]'), but it didn't work. Does it only take a single delimiter? | Use a regular expression:
```
import re
s = "name[id]"
re.find(r"\[(.*?)\]", s).group(1) # = 'id'
```
`str.split()` takes a string on which to split input. For instance:
```
"i,split,on commas".split(',') # = ['i', 'split', 'on commas']
```
The `re` module also allows you to split by regular expression, which ca... |
514,038 | <p>It seems like in most mainstream programming languages, <strong>returning multiple values from a function</strong> is an extremely awkward thing. </p>
<p>The typical solutions are to make either a <strong>struct</strong> or a plain old data <strong>class</strong> and return that, or to pass at least some of the par... | [
{
"answer_id": 514053,
"author": "SilentGhost",
"author_id": 12855,
"author_profile": "https://Stackoverflow.com/users/12855",
"pm_score": 2,
"selected": false,
"text": "<p>i thinks python's is the most natural way, when I had to do same thing in php the only was to wrap return into an a... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23903/"
] | It seems like in most mainstream programming languages, **returning multiple values from a function** is an extremely awkward thing.
The typical solutions are to make either a **struct** or a plain old data **class** and return that, or to pass at least some of the parameters by reference or pointer instead of return... | Pretty much all ML-influenced functional langues (which is most of them) also have great tuple support that makes this sort of thing trivial.
For C++ I like boost::tuple plus boost::tie (or std::tr1 if you have it)
```
typedef boost::tuple<double,double,double> XYZ;
XYZ foo();
double x,y,z;
boost::tie(x,y,z) = foo(... |
514,043 | <p><strong>Is there a way to set a table's visibility to false, if the table has no rows?</strong></p>
<p>I want to hide a table in Reporting Services when it has no rows.</p>
<p>Setting NoRows to <strong>=""</strong> isn't sufficient in this case as space is still left for the table, and some of the table's formatti... | [
{
"answer_id": 514100,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 8,
"selected": true,
"text": "<p>Try setting the table's \"Visibility.Hidden\" property to this expression:</p>\n\n<pre><code>=CountRows() = 0\n</code>... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59587/"
] | **Is there a way to set a table's visibility to false, if the table has no rows?**
I want to hide a table in Reporting Services when it has no rows.
Setting NoRows to **=""** isn't sufficient in this case as space is still left for the table, and some of the table's formatting is still visible.
I'm using Microsoft V... | Try setting the table's "Visibility.Hidden" property to this expression:
```
=CountRows() = 0
``` |
514,044 | <p>In c#,
I use a decimal out DbParameter for a Sql Server stored procedure.
I create parameter like that</p>
<hr>
<pre><code>DbParameter prm = comm.CreateParameter();
prm.ParameterName = "@Price";
prm.DbType = DbType.Decimal;
prm.Direction = ParameterDirection.Output;
comm.Parameters.Add(prm);
//and set the va... | [
{
"answer_id": 514084,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 1,
"selected": false,
"text": "<p>First, you don't need to parse the string to get the Decimal, you should be able to cast directly to it:</p>\n\n<pre>... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53124/"
] | In c#,
I use a decimal out DbParameter for a Sql Server stored procedure.
I create parameter like that
---
```
DbParameter prm = comm.CreateParameter();
prm.ParameterName = "@Price";
prm.DbType = DbType.Decimal;
prm.Direction = ParameterDirection.Output;
comm.Parameters.Add(prm);
//and set the value of comm.Par... | Adding to Marc's suggestion, you can change the code to
`IDbDataParameter prm = comm.CreateParameter();`
Rest of the code should work fine.
Precision and Scale properties are "explicit interface implementation" in DbParameter. |
514,061 | <p>EDIT: i want to use libsox to programatically convert a wav file's sample rate, audio format, channels, and etc. </p>
<p>in the libsox man page, there are a bunch of functions I can use but I'm clueless as hell on what to do. Can anyone give me a sort of steps on how to do it? </p>
<p>Help?</p>
<hr>
<p>Can anyon... | [
{
"answer_id": 514178,
"author": "jfsantos",
"author_id": 62695,
"author_profile": "https://Stackoverflow.com/users/62695",
"pm_score": 0,
"selected": false,
"text": "<p>Well, I guess your question has something to do with the last sentence. If you have an interleaved buffer, the number ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | EDIT: i want to use libsox to programatically convert a wav file's sample rate, audio format, channels, and etc.
in the libsox man page, there are a bunch of functions I can use but I'm clueless as hell on what to do. Can anyone give me a sort of steps on how to do it?
Help?
---
Can anyone please explain this?
`... | I'd recommend a combination of libsndfile and libsamplerate
<http://www.mega-nerd.com/SRC>
>
> SRC provides a small set of converters
> to allow quality to be traded off
> against computation cost. The current
> best converter provides a
> signal-to-noise ratio of 145dB with
> -3dB passband extending from DC to... |
514,068 | <p>Does Python have extension methods like C#? Is it possible to call a method like:</p>
<pre><code>MyRandomMethod()
</code></pre>
<p>on existing types like <code>int</code>?</p>
<pre><code>myInt.MyRandomMethod()
</code></pre>
| [
{
"answer_id": 514081,
"author": "SilentGhost",
"author_id": 12855,
"author_profile": "https://Stackoverflow.com/users/12855",
"pm_score": 3,
"selected": false,
"text": "<p>not sure if that what you're asking but you can extend existing types and then call whatever you like on the new th... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51816/"
] | Does Python have extension methods like C#? Is it possible to call a method like:
```
MyRandomMethod()
```
on existing types like `int`?
```
myInt.MyRandomMethod()
``` | You can add whatever methods you like on class objects defined in Python code (AKA monkey patching):
```
>>> class A(object):
>>> pass
>>> def stuff(self):
>>> print self
>>> A.test = stuff
>>> A().test()
```
This does not work on builtin types, because their `__dict__` is not writable (it's a `dictproxy`)... |
514,111 | <p>Lets say you want to create a listing of widgets</p>
<p>The Widget Manufacturers all create widgets with different number and types of attributes. And the Widget sellers all have different preferences on what type and number of attributes they want to store in the database and display.</p>
<p>The problem here now ... | [
{
"answer_id": 514126,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 3,
"selected": true,
"text": "<p>I would have a table for widgets and one for widget attributes. For example:</p>\n\n<pre><code>Widgets\n - Id\n -... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29338/"
] | Lets say you want to create a listing of widgets
The Widget Manufacturers all create widgets with different number and types of attributes. And the Widget sellers all have different preferences on what type and number of attributes they want to store in the database and display.
The problem here now is that each time... | I would have a table for widgets and one for widget attributes. For example:
```
Widgets
- Id
- Name
WidgetAttributes
- Id
- Name
```
Then, you would have another table which has what widgets have which attributes:
```
WidgetAttributeMap
- Id
- WidgetId
(a value from the Id column in the Widg... |
514,118 | <p>I've read the <a href="http://en.wikipedia.org/wiki/Duff%27s_device" rel="noreferrer">article on Wikipedia on the Duff's device</a>, and I don't get it. I am really interested, but I've read the explanation there a couple of times and I still don't get it how the Duff's device works.</p>
<p>What would a more detail... | [
{
"answer_id": 514150,
"author": "Ric Tokyo",
"author_id": 42019,
"author_profile": "https://Stackoverflow.com/users/42019",
"pm_score": 7,
"selected": false,
"text": "<p>The <a href=\"http://www.ddj.com/web-development/184406208\" rel=\"noreferrer\">explanation in Dr. Dobb's Journal</a>... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42303/"
] | I've read the [article on Wikipedia on the Duff's device](http://en.wikipedia.org/wiki/Duff%27s_device), and I don't get it. I am really interested, but I've read the explanation there a couple of times and I still don't get it how the Duff's device works.
What would a more detailed explanation be? | There are some good explanations elsewhere, but let me give it a try. (This is a lot easier on a whiteboard!) Here's the Wikipedia example with some notations.
Let's say you're copying 20 bytes. The flow control of the program for the first pass is:
```
int count; // Set to 20
{
int n = (co... |
514,120 | <p>I have a Silverlight menu for my application with an image as the background. I use some empty HyperlinkButton at a specific position and size to simulate a real button on the image (think as a HTML image-map):</p>
<pre><code><HyperlinkButton x:Name="Portfolio" Width="86" Height="40" Canvas.Top="50" NavigateUri=... | [
{
"answer_id": 517514,
"author": "adler77",
"author_id": 62736,
"author_profile": "https://Stackoverflow.com/users/62736",
"pm_score": 1,
"selected": false,
"text": "<p>For info on styling controls, see <a href=\"http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-7-using-cont... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18623/"
] | I have a Silverlight menu for my application with an image as the background. I use some empty HyperlinkButton at a specific position and size to simulate a real button on the image (think as a HTML image-map):
```
<HyperlinkButton x:Name="Portfolio" Width="86" Height="40" Canvas.Top="50" NavigateUri="/portfolio"/>
<H... | I found the answer in other blog, just set IsTabStop="False" in the HyperLinkButton instance. |
514,155 | <p>I want to up the time my users will stay logged into my site without getting automatically logged out after a period of inactivity. I'm tracking the logged in status using PHP sessions.</p>
<p>How can I set this, I'm trying to control this from my .htaccess file.</p>
| [
{
"answer_id": 514167,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 5,
"selected": true,
"text": "<p><strike>You can't do that from the htaccess file but</strike> You can change this line in your <code>php.ini</code>... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] | I want to up the time my users will stay logged into my site without getting automatically logged out after a period of inactivity. I'm tracking the logged in status using PHP sessions.
How can I set this, I'm trying to control this from my .htaccess file. | You can't do that from the htaccess file but You can change this line in your `php.ini` file.
```
session.gc_maxlifetime = 1440
```
Update: it seems to be possible, so i stand corrected
```
php_value session.gc_maxlifetime 3600
```
I haven't tried this out though. |
514,194 | <p>I am using fully qualified name of the enum inside a method in one of my class. But I am getting compiler warning which says <em>"warning C4482: nonstandard extension used: enum 'Foo' used in qualified name"</em>. In C++, do we need to use enums without the qualified name? But IMO, that looks ugly. </p>
<p>Any thou... | [
{
"answer_id": 514205,
"author": "sth",
"author_id": 56338,
"author_profile": "https://Stackoverflow.com/users/56338",
"pm_score": 7,
"selected": true,
"text": "<p>Yes, enums don't create a new \"namespace\", the values in the enum are directly available in the surrounding scope. So you ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50419/"
] | I am using fully qualified name of the enum inside a method in one of my class. But I am getting compiler warning which says *"warning C4482: nonstandard extension used: enum 'Foo' used in qualified name"*. In C++, do we need to use enums without the qualified name? But IMO, that looks ugly.
Any thoughts? | Yes, enums don't create a new "namespace", the values in the enum are directly available in the surrounding scope. So you get:
```
enum sample {
SAMPLE_ONE = 1,
SAMPLE_TWO = 2
};
int main() {
std::cout << "one = " << SAMPLE_ONE << std::endl;
return 0;
}
``` |
514,199 | <p>I asked about finding in subdirs with criteria. First answer was use FindFirstFileEx(). It seems the function is no good for this purpose or I'm using it wrong.</p>
<p>So can someone explain how I would go about searching in a folder, and all it's subfolders for files that match (to give some sample criteria) <em... | [
{
"answer_id": 514212,
"author": "ChrisW",
"author_id": 49942,
"author_profile": "https://Stackoverflow.com/users/49942",
"pm_score": 0,
"selected": false,
"text": "<p>I think you use <code>FindFirstFile</code> to find <strong>all</strong> files and ignore the ones whose <code>WIN32_FIND... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21880/"
] | I asked about finding in subdirs with criteria. First answer was use FindFirstFileEx(). It seems the function is no good for this purpose or I'm using it wrong.
So can someone explain how I would go about searching in a folder, and all it's subfolders for files that match (to give some sample criteria) *.doc;*.txt;\*.... | From [MSDN](http://msdn.microsoft.com/en-us/library/aa364419(VS.85).aspx):
If you refer to the code fragment in that page:
```
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
void _tmain(int argc, TCHAR *argv[])
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
if( argc != 2 )
{
_tprintf(TE... |
514,216 | <p>I am running </p>
<pre><code>ruby script/generate scaffold
</code></pre>
<p>or</p>
<pre><code>ruby script/generate model
</code></pre>
<p>and I know the basic syntax, like</p>
<pre><code>ruby script/generate scaffold Dude name:string face:boolean
</code></pre>
<p>but I do not know things like:</p>
<ul>
<li>sh... | [
{
"answer_id": 514235,
"author": "Ronnie Liew",
"author_id": 1987,
"author_profile": "https://Stackoverflow.com/users/1987",
"pm_score": 3,
"selected": false,
"text": "<p>This document on <a href=\"http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations\" rel=\"nofollow noreferrer\... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] | I am running
```
ruby script/generate scaffold
```
or
```
ruby script/generate model
```
and I know the basic syntax, like
```
ruby script/generate scaffold Dude name:string face:boolean
```
but I do not know things like:
* should names of variables have underscores or be camelCased?
* what kind of variable ... | Type the command without arguments and the documentation is revealed:
```
$ script/generate model
```
You can use either camelcase or underscores for the model name.
* Model names are singular; controller names are plural.
* Field names use underscores.
I can't remember all the possible field types, I just look th... |
514,232 | <p>Using PHP and MySQL, I have a forum system I'm trying to build. What I want to know is, how can I set it so that when a user reads a forum entry, it shows as read JUST for that user, no matter what forum they are in, until someone else posts on it.</p>
<p>Currently, for each thread, I have a table with a PostID, an... | [
{
"answer_id": 514256,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 1,
"selected": false,
"text": "<p>There's no easy way to do this. There are plenty of ways to do it, but each grows exponentially larger as the u... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50544/"
] | Using PHP and MySQL, I have a forum system I'm trying to build. What I want to know is, how can I set it so that when a user reads a forum entry, it shows as read JUST for that user, no matter what forum they are in, until someone else posts on it.
Currently, for each thread, I have a table with a PostID, and has the ... | May be storing in another table UserID,threadID, LastReadDateTime when the user read that thread.
```
if (LastPostDateTime > LastReadDateTime) you got an unread post.
```
Sadly you have a great overhead, on every read you'll have a write. |
514,239 | <p>I have a stored procedure and if the stored procedure does this:</p>
<pre><code>SELECT 0 As Ret
DELETE FROM table where value1 = 1
</code></pre>
<p>Returns 1 row result with its value of 0 and column name Ret</p>
<p>But if I do this:</p>
<pre><code>DELETE FROM table where value1 = 1
SELECT 0 As Ret
</code></pre>... | [
{
"answer_id": 514247,
"author": "cmsjr",
"author_id": 23114,
"author_profile": "https://Stackoverflow.com/users/23114",
"pm_score": 1,
"selected": false,
"text": "<p>Explicitly set a variable to @@RowCount and then return it</p>\n\n<pre><code>Declare @ret int\nSelect @ret = @@RowCount\n... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | I have a stored procedure and if the stored procedure does this:
```
SELECT 0 As Ret
DELETE FROM table where value1 = 1
```
Returns 1 row result with its value of 0 and column name Ret
But if I do this:
```
DELETE FROM table where value1 = 1
SELECT 0 As Ret
```
I get no returned results.
My question is, how do... | Ok I found that you can use the ODBC call SQLMoreResults to get the next result set. So you can keep calling this SQLMoreResults function until there are no more result sets left.
In my case after calling SQLMoreResults I got my expected result set.
This is pretty cool because it means that a single stored procedur... |
514,252 | <p>Is it possible to specify a relative connection string for an AzMan XML store?</p>
<p>My current connection string is <code>connectionString="msxml://c:/azman.xml"</code> but I really need to make that relative so other developers and automated builds can get the latest authorization store.</p>
<p>MS documentation... | [
{
"answer_id": 514271,
"author": "Glennular",
"author_id": 14753,
"author_profile": "https://Stackoverflow.com/users/14753",
"pm_score": 3,
"selected": false,
"text": "<p>Adding the ~ will make it relative to the application</p>\n\n<pre><code><add name=\"AuthorizationServices\" connec... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2660/"
] | Is it possible to specify a relative connection string for an AzMan XML store?
My current connection string is `connectionString="msxml://c:/azman.xml"` but I really need to make that relative so other developers and automated builds can get the latest authorization store.
MS documentation seems to suggest that `conn... | It is possible to enter the token {currentPath} into the connection string used by the security application block.
This gave me the behavior I was after, allowing the AzMan.xml file to be accessed from with the application folder.
The connection string I am using is:
```
<authorizationProviders>
<add storeLocation... |
514,264 | <p>MSBuild 3.5</p>
<p>I have the following project structure:</p>
<pre><code>trunk/MainSolution.sln
trunk/Build/MyBuild.Proj
trunk/Library/...
trunk/etc...
</code></pre>
<p>So far, I've been using the following property to find out the project root folder:</p>
<pre><code><RootFolder>$(MSBuildProjectDirectory)... | [
{
"answer_id": 514932,
"author": "Julien Hoarau",
"author_id": 12248,
"author_profile": "https://Stackoverflow.com/users/12248",
"pm_score": 5,
"selected": true,
"text": "<p>Item metadata is your friend!</p>\n\n<pre><code><Target Name=\"GetMSBuildProjectParentDirectory\">\n <!-... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25020/"
] | MSBuild 3.5
I have the following project structure:
```
trunk/MainSolution.sln
trunk/Build/MyBuild.Proj
trunk/Library/...
trunk/etc...
```
So far, I've been using the following property to find out the project root folder:
```
<RootFolder>$(MSBuildProjectDirectory)\..\</RootFolder>
```
Everything was working gre... | Item metadata is your friend!
```
<Target Name="GetMSBuildProjectParentDirectory">
<!-- First you create the MSBuildProject Parent directory Item -->
<CreateItem Include="$(MSBuildProjectDirectory)\..\">
<Output ItemName="MSBuildProjectParentDirectory" TaskParameter="Include"/>
</CreateItem>
<!-- You can ... |
514,284 | <p>I am developing a framework, and some of the objects have reaaally long names. I don't really like this, but I don't like acronyms either. I am trying to come up with a shorter name for "EventModelSocket", basically a wrapper around the .Net socket class that implements various events, and methods to send files, obj... | [
{
"answer_id": 514288,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "<p>Well, are the long names hurting something?</p>\n\n<p>(edit) two other thoughts:</p>\n\n<ul>\n<li>use <code>var</c... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52589/"
] | I am developing a framework, and some of the objects have reaaally long names. I don't really like this, but I don't like acronyms either. I am trying to come up with a shorter name for "EventModelSocket", basically a wrapper around the .Net socket class that implements various events, and methods to send files, object... | Push some of it into the namespace.
For example:
```
EventModelSocketObjectReceivedEventArgs
```
becomes
```
EventModel.Sockets.ReceivedEventArgs
``` |
514,332 | <p>I'm trying to get the {smartassembly} .NET obfuscator to work with my system. I currently store user data in a series of serialized dictionary classes, and then deserialize those classes to get the data back. I'm already ignoring assembly version information, just because that way making life a pain. That code is... | [
{
"answer_id": 514345,
"author": "MichaelGG",
"author_id": 27012,
"author_profile": "https://Stackoverflow.com/users/27012",
"pm_score": -1,
"selected": false,
"text": "<p>Obfuscation doesn't provide security in the first place. So, you may want to consider dropping it, period.</p>\n\n<p... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21981/"
] | I'm trying to get the {smartassembly} .NET obfuscator to work with my system. I currently store user data in a series of serialized dictionary classes, and then deserialize those classes to get the data back. I'm already ignoring assembly version information, just because that way making life a pain. That code is [adap... | Perhaps consider a serializer that isn't tied to the type and field-names? For example, [protobuf-net](http://code.google.com/p/protobuf-net/) is a binary serializer, but uses numeric tags set (via an attribute) against each member. This means:
* serialization isn't tied to the assembly version at all
* the field name... |
514,358 | <p>I just had my desktop computer replaced. Both my previous computer and this one have Windows XP. In order to work with the many Linux servers we have, I installed Cygwin along with its xterm package. However, I cannot run startx to start the X-window server as I did with my previous computer. I've been looking o... | [
{
"answer_id": 514400,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 1,
"selected": false,
"text": "<p>When you installed Cygwin, did you install the full package set? The default is to only install a baseline of package... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14382/"
] | I just had my desktop computer replaced. Both my previous computer and this one have Windows XP. In order to work with the many Linux servers we have, I installed Cygwin along with its xterm package. However, I cannot run startx to start the X-window server as I did with my previous computer. I've been looking online t... | Disclaimer: I know this answer does not answer your question directly, but it offers a good alternative.
I use Cygwin + [XMing](http://www.straightrunning.com/XmingNotes/) to run remote X applications:
1. Launch XMing
2. Start my favorite Cygwin shell (zsh)
```
export DISPLAY=localhost:0
ssh -X myserver.domain
```
... |
514,371 | <p>What's the "Bad magic number" ImportError in python, and how do I fix it?</p>
<p>The only thing I can find online suggests this is caused by compiling a .py -> .pyc file and then trying to use it with the wrong version of python. In my case, however, the file seems to import fine some times but not others, and I'm ... | [
{
"answer_id": 514395,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 10,
"selected": true,
"text": "<p>The magic number comes from UNIX-type systems where the first few bytes of a file held a marker indicating the file t... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28035/"
] | What's the "Bad magic number" ImportError in python, and how do I fix it?
The only thing I can find online suggests this is caused by compiling a .py -> .pyc file and then trying to use it with the wrong version of python. In my case, however, the file seems to import fine some times but not others, and I'm not sure w... | The magic number comes from UNIX-type systems where the first few bytes of a file held a marker indicating the file type.
Python puts a similar marker into its `pyc` files when it creates them.
Then the python interpreter makes sure this number is correct when loading it.
Anything that damages this magic number will... |
514,377 | <p>I'd like to show or hide a few fields in a form in Rails, depending on the state of a select field in the form. I don't (currently) need a second database lookup for the fields, so I'm trying to keep it all confined to the view. I have the outline sketched out, but I'm having some trouble with the implementation det... | [
{
"answer_id": 514409,
"author": "Christopher Swasey",
"author_id": 59272,
"author_profile": "https://Stackoverflow.com/users/59272",
"pm_score": 2,
"selected": false,
"text": "<p>As a rails developer, I suggest adhering to the principles of unobtrusive javascript. When it comes to rails... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47291/"
] | I'd like to show or hide a few fields in a form in Rails, depending on the state of a select field in the form. I don't (currently) need a second database lookup for the fields, so I'm trying to keep it all confined to the view. I have the outline sketched out, but I'm having some trouble with the implementation detail... | As a rails developer, I suggest adhering to the principles of unobtrusive javascript. When it comes to rails, what this usually means is that you shouldn't just write one big view to handle all your functionality. This makes your HTML view easier to develop and maintain, it makes your behavior easier to maintain, and i... |
514,387 | <p>I am using strongly-typed dataset as an ORM to wrap around my Microsoft Access database, now I am looking for a way to create an equivalent of </p>
<pre><code>UPDATE table1
SET table1.nationality = 'england'
WHERE table1.nationality in (SELECT table2.nationality
FROM table2
... | [
{
"answer_id": 554196,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 0,
"selected": false,
"text": "<p>are you using a table adapter?</p>\n\n<p>if so, can you not just right-click and choose Add Query, select new Sele... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | I am using strongly-typed dataset as an ORM to wrap around my Microsoft Access database, now I am looking for a way to create an equivalent of
```
UPDATE table1
SET table1.nationality = 'england'
WHERE table1.nationality in (SELECT table2.nationality
FROM table2
... | Like steven A low said.. but you use MS acces.. so params must be '?'
Right-click adapter and choose Add Query, select new Select/Update/SQL statement, then enter
```
UPDATE table1 SET
table1.nationality = ?
WHERE table1.nationality in (
select table2.nationality
from table2
where table2.gender = ... |
514,399 | <p>I'm trying to create a linq query based on some dynamic/optional arguments passed into a method.</p>
<pre><code>User [Table] -> zero to many -> Vehicles [Table]
User [Table] -> zero to many -> Pets
</code></pre>
<p>So we want all users (including any vechile and/or pet info). Optional filters are </p>
... | [
{
"answer_id": 514402,
"author": "Rex M",
"author_id": 67,
"author_profile": "https://Stackoverflow.com/users/67",
"pm_score": 1,
"selected": false,
"text": "<p>If you are trying to change tables or joins of a LINQ to SQL query at runtime you need to do that with reflection. LINQ express... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I'm trying to create a linq query based on some dynamic/optional arguments passed into a method.
```
User [Table] -> zero to many -> Vehicles [Table]
User [Table] -> zero to many -> Pets
```
So we want all users (including any vechile and/or pet info). Optional filters are
* Vehicle numberplate
* Pet name
Because... | I think you are heading in the wrong direction. You can easily use the fact that LINQ queries are composable here.
First, you would always use the outer join, and get all users with the appropriate vehicles and pets:
```
// Get all the users.
IQueryable<User> users = dbContext.Users;
```
Then you would add the filt... |
514,407 | <p>I'm using the Java matcher to try and match the following:</p>
<pre><code>@tag TYPE_WITH_POSSIBLE_SUBTYPE -PARNAME1=PARVALUE1 -PARNAME2=PARVALUE2: MESSAGE
</code></pre>
<p>The TYPE_WITH_POSSIBLE_SUBTYPE consists of letters with periods.</p>
<p>Every parameter has to consist of letters, and every value has to cons... | [
{
"answer_id": 514427,
"author": "Mike",
"author_id": 62248,
"author_profile": "https://Stackoverflow.com/users/62248",
"pm_score": 1,
"selected": false,
"text": "<p>Try this out (you may need to add extra '\\' to make it work within a string.</p>\n\n<pre><code>(@tag)\\s*(\\w*)\\s*(-[\\w... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23072/"
] | I'm using the Java matcher to try and match the following:
```
@tag TYPE_WITH_POSSIBLE_SUBTYPE -PARNAME1=PARVALUE1 -PARNAME2=PARVALUE2: MESSAGE
```
The TYPE\_WITH\_POSSIBLE\_SUBTYPE consists of letters with periods.
Every parameter has to consist of letters, and every value has to consist of numerics/letters. There... | If you want to capture each parameter separately, you have to have a capture group for each one. Of course, you can't do that because you don't know how many parameters there will be. I recommend a different approach:
```
Pattern p = Pattern.compile("@tag\\s+([^:]++):\\s*(.*)");
Matcher m = p.matcher(s);
if (m.find())... |
514,420 | <p>I'd like to know how to limit an input value to signed decimals using <code>std::cin</code>.</p>
| [
{
"answer_id": 514436,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 3,
"selected": false,
"text": "<p>If the backing variable of the <code>cin</code> is a number, and the string provided is not a number, the return value is ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53797/"
] | I'd like to know how to limit an input value to signed decimals using `std::cin`. | ```
double i;
//Reading the value
cin >> i;
//Numeric input validation
if(!cin.eof())
{
peeked = cin.peek();
if(peeked == 10 && cin.good())
{
//Good!
count << "i is a decimal";
}
else
{
count << "i is not a decimal";
cin.clear();
... |
514,435 | <p>I'm trying to write a branchless function to return the MAX or MIN of two integers without resorting to if (or ?:). Using <a href="https://stackoverflow.com/questions/227383/how-do-i-programmatically-return-the-max-of-two-integers-without">the usual technique</a> I can do this easily enough for a given word size:</p... | [
{
"answer_id": 514468,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 4,
"selected": true,
"text": "<p><strong>EDIT:</strong> This answer is from before C++11. Since then, C++11 and later has offered <code>make_signed<... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53543/"
] | I'm trying to write a branchless function to return the MAX or MIN of two integers without resorting to if (or ?:). Using [the usual technique](https://stackoverflow.com/questions/227383/how-do-i-programmatically-return-the-max-of-two-integers-without) I can do this easily enough for a given word size:
```
inline int3... | **EDIT:** This answer is from before C++11. Since then, C++11 and later has offered `make_signed<T>` and much more as part of the standard library
---
Generally, looks good, but for 100% portability, replace that 8 with `CHAR_BIT` (or `numeric_limits<char>::max()`) since it isn't guaranteed that characters are 8-bit.... |
514,440 | <p>I've noticed the returnurl URL parameter on the Stackoverflow login/logout links are not escaped but when I try to add path as a parameter to a route it gets escaped.</p>
<p>So /login?returnurl=/questions/ask shows /login?returnurl=%2fquestions%2fask and it's kind of ugly. How do I get it to not escape the returnu... | [
{
"answer_id": 514497,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 0,
"selected": false,
"text": "<p>My solutionto a similar problem was to write my own extension. After digging around in the code I couldn't find a w... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2572/"
] | I've noticed the returnurl URL parameter on the Stackoverflow login/logout links are not escaped but when I try to add path as a parameter to a route it gets escaped.
So /login?returnurl=/questions/ask shows /login?returnurl=%2fquestions%2fask and it's kind of ugly. How do I get it to not escape the returnurl value?
... | I understand one of the comments about encoding happening for a reason; this would only be an exception, not the rule.
Here's what I put together, how can it be improved?
```
public static string ActionLinkNoEscape(this HtmlHelper html, string linkText, string actionName, string controllerName, object values, obj... |
514,442 | <p>I wonder how do the decentralized DVCS's work? If there is no central server how can a developer machine knows and syncs the repository with the other developer machines' repositories. And how does the changes are merged? Because lack of central server seems like to me the system might cause each repository have a d... | [
{
"answer_id": 514497,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 0,
"selected": false,
"text": "<p>My solutionto a similar problem was to write my own extension. After digging around in the code I couldn't find a w... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50676/"
] | I wonder how do the decentralized DVCS's work? If there is no central server how can a developer machine knows and syncs the repository with the other developer machines' repositories. And how does the changes are merged? Because lack of central server seems like to me the system might cause each repository have a diff... | I understand one of the comments about encoding happening for a reason; this would only be an exception, not the rule.
Here's what I put together, how can it be improved?
```
public static string ActionLinkNoEscape(this HtmlHelper html, string linkText, string actionName, string controllerName, object values, obj... |
514,448 | <p>In Python (specifically Python 3.0 but I don't think it matters), how do I easily write a loop over a sequence of characters having consecutive character codes? I want to do something like this pseudocode:</p>
<pre><code>for Ch from 'a' to 'z' inclusive: #
f(Ch)
</code></pre>
<p>Example: how about a nice "pyth... | [
{
"answer_id": 514466,
"author": "sykora",
"author_id": 53850,
"author_profile": "https://Stackoverflow.com/users/53850",
"pm_score": 5,
"selected": false,
"text": "<p>You have a constant in the string module called <code>ascii_lowercase</code>, try that out:</p>\n\n<pre><code>>>&g... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61923/"
] | In Python (specifically Python 3.0 but I don't think it matters), how do I easily write a loop over a sequence of characters having consecutive character codes? I want to do something like this pseudocode:
```
for Ch from 'a' to 'z' inclusive: #
f(Ch)
```
Example: how about a nice "pythonic" version of the follo... | You have a constant in the string module called `ascii_lowercase`, try that out:
```
>>> from string import ascii_lowercase
```
Then you can iterate over the characters in that string.
```
>>> for i in ascii_lowercase :
... f(i)
```
For your pangram question, there is a very simple way to find out if a string... |
514,449 | <p>When the following code executes:</p>
<pre><code> select sum(qty) from inventTrans
index hint TransTypeIdx
where inventTrans.ItemId == itemId
&& inventTrans.TransType == InventTransType::Sales
&& inventTrans.InventDimId == inventDimId
notE... | [
{
"answer_id": 514466,
"author": "sykora",
"author_id": 53850,
"author_profile": "https://Stackoverflow.com/users/53850",
"pm_score": 5,
"selected": false,
"text": "<p>You have a constant in the string module called <code>ascii_lowercase</code>, try that out:</p>\n\n<pre><code>>>&g... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When the following code executes:
```
select sum(qty) from inventTrans
index hint TransTypeIdx
where inventTrans.ItemId == itemId
&& inventTrans.TransType == InventTransType::Sales
&& inventTrans.InventDimId == inventDimId
notExists join custTable
w... | You have a constant in the string module called `ascii_lowercase`, try that out:
```
>>> from string import ascii_lowercase
```
Then you can iterate over the characters in that string.
```
>>> for i in ascii_lowercase :
... f(i)
```
For your pangram question, there is a very simple way to find out if a string... |
514,475 | <p>im writing a simple propositional logic formula parser in python which uses regular expressions re module and the lex/yacc module for lexing/parsing. Originally my code could pick out implication as ->, but adding logical equivalence (<->) caused issues with the compiled expressions</p>
<pre><code>IMPLICATION = ... | [
{
"answer_id": 514502,
"author": "sykora",
"author_id": 53850,
"author_profile": "https://Stackoverflow.com/users/53850",
"pm_score": 0,
"selected": false,
"text": "<p>I think you can solve this simply by reordering your checking to match equivalences first, and then implications. Howeve... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62740/"
] | im writing a simple propositional logic formula parser in python which uses regular expressions re module and the lex/yacc module for lexing/parsing. Originally my code could pick out implication as ->, but adding logical equivalence (<->) caused issues with the compiled expressions
```
IMPLICATION = re.compile('[\s]*... | As far as I can tell, your regular expressions are equivalent to the following:
```
# This is bad, because IMPLICATION also will match every
# string that EQUIVALENCE matches
IMPLICATION = re.compile("->")
EQUIVALENCE = re.compile("<->")
```
As you've written it, you're also matching for *zero or more* whitespace ch... |
514,477 | <p>In ASP.NET MVC, how does the controller pass information between the model and the view?</p>
<p>Let's say I have a list of baseball players in my database. After I query those players using LINQ in the controller, how do I then pass this information on to view (my list of baseball players and their stats)?</p>
<p... | [
{
"answer_id": 514512,
"author": "Edwin Jarvis",
"author_id": 18623,
"author_profile": "https://Stackoverflow.com/users/18623",
"pm_score": 3,
"selected": true,
"text": "<p>The controller has a ViewData field that you can use. It's a dictionary and you can use like that:</p>\n\n<blockquo... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58179/"
] | In ASP.NET MVC, how does the controller pass information between the model and the view?
Let's say I have a list of baseball players in my database. After I query those players using LINQ in the controller, how do I then pass this information on to view (my list of baseball players and their stats)?
And after I pass ... | The controller has a ViewData field that you can use. It's a dictionary and you can use like that:
>
> ViewData["players"] = yourList;
>
>
>
After that you can access the same ViewData on the View:
```
<? foreach(var player in ViewData["players"] as List) {} ?>
```
You can also make a strong typed view, changi... |
514,478 | <p>I'm fairly new to Java (been writing other stuff for many years) and unless I'm missing something (and I'm happy to be wrong here) the following is a fatal flaw...</p>
<pre><code>String foo = new String();
thisDoesntWork(foo);
System.out.println(foo);//this prints nothing
public static void thisDoesntWork(String f... | [
{
"answer_id": 514486,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 3,
"selected": false,
"text": "<p>When you pass \"foo\", you're passing the <em>reference</em> to \"foo\" as a value to ThisDoesntWork(). That means... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59947/"
] | I'm fairly new to Java (been writing other stuff for many years) and unless I'm missing something (and I'm happy to be wrong here) the following is a fatal flaw...
```
String foo = new String();
thisDoesntWork(foo);
System.out.println(foo);//this prints nothing
public static void thisDoesntWork(String foo){
foo = ... | [This rant](http://javadude.com/articles/passbyvalue.htm) explains it better than I could ever even try to:
>
> In Java, primitives are passed by value. However, Objects are not
> passed by reference. A correct statement would be Object references
> are passed by value.
>
>
> |
514,482 | <p>I been reading bad things about the <strong>with</strong> keyword in delphi but, in my opinion, if you don't over use it. It can make your code look simple.</p>
<p>I often put all my TClientDataSets and TFields in TDataModules. So in my forms I had code like this</p>
<pre><code>procedure TMyForm.AddButtonClick(Sen... | [
{
"answer_id": 514508,
"author": "Jamey McElveen",
"author_id": 30099,
"author_profile": "https://Stackoverflow.com/users/30099",
"pm_score": 5,
"selected": false,
"text": "<p>The <code>with</code> statement has its place but I have to agree that overuse can lead to ambiguous code. A goo... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24293/"
] | I been reading bad things about the **with** keyword in delphi but, in my opinion, if you don't over use it. It can make your code look simple.
I often put all my TClientDataSets and TFields in TDataModules. So in my forms I had code like this
```
procedure TMyForm.AddButtonClick(Sender: TObject);
begin
with Long... | The biggest danger of with, outside of pathological conditions like "with A, B, C, D" is that your code can silently change meaning with no notice to you. Consider this example:
```
with TFoo.Create
try
Bar := Baz;
DoSomething();
finally
Free;
end;
```
You write this code knowing that Bar is a property of TFoo... |
514,484 | <p>I want to right pad my string with blank spaces.
The following function works for all characters except the blank.</p>
<pre><code>myString.PadRight(50,"x")
</code></pre>
<p>Edit:</p>
<p>myString.PadRight(50) does pad a string with blank spaces, but when this string is used in the following statement, the blank pa... | [
{
"answer_id": 514511,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": false,
"text": "<p>I think if you just omit the character specifier it will pad on the right with spaces.</p>\n\n<pre><code>var newStri... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to right pad my string with blank spaces.
The following function works for all characters except the blank.
```
myString.PadRight(50,"x")
```
Edit:
myString.PadRight(50) does pad a string with blank spaces, but when this string is used in the following statement, the blank padding is gone.
```
myCheckBox.Te... | I think if you just omit the character specifier it will pad on the right with spaces.
```
var newString = myString.PadRight(50);
```
See the doc [reference](http://msdn.microsoft.com/en-us/library/system.string.padright.aspx). It sure seems like it should work by specifying the space character as well, though. I do... |
514,506 | <p>Why is it that the below makes the text red?</p>
<pre><code>#stories li a {color:red}
.default li.expand a {color:green}
li.expand a {color:blue}
</code></pre>
<hr>
<pre><code><ul id="stories" class="default">
<li>this is the end</li>
<li class="expand">this is the end</li>
</c... | [
{
"answer_id": 514527,
"author": "sykora",
"author_id": 53850,
"author_profile": "https://Stackoverflow.com/users/53850",
"pm_score": 3,
"selected": false,
"text": "<p>According to <a href=\"http://htmldog.com/guides/cssadvanced/specificity/\" rel=\"noreferrer\">http://htmldog.com/guides... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43465/"
] | Why is it that the below makes the text red?
```
#stories li a {color:red}
.default li.expand a {color:green}
li.expand a {color:blue}
```
---
```
<ul id="stories" class="default">
<li>this is the end</li>
<li class="expand">this is the end</li>
```
Only if I put #stories on the others will the text change.... | It's a matter of "CSS Specificity". Andy Clarke's article [CSS: Spcificity Wars](http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html) does a pretty good job explaining it with a little humor. Although Eric Meyer adds more clarity in [his comment](http://www.stuffandnonsense.co.uk/archives/css_specifici... |
514,557 | <p>Without resorting to using an ActiveX or some other kind of client side coding:</p>
<p>Is it possible to determine if a visitor to a website arrived to a page via his bookmarks or the home page?</p>
<p>Personally I think its impossible, but I would like to be sure or proven wrong.</p>
<p>The way I am doing someth... | [
{
"answer_id": 514570,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 3,
"selected": true,
"text": "<p>Short answer, no.</p>\n\n<p>Long answer, not in a portable foolproof manner.</p>\n"
},
{
"answer_id": 514580,
... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42019/"
] | Without resorting to using an ActiveX or some other kind of client side coding:
Is it possible to determine if a visitor to a website arrived to a page via his bookmarks or the home page?
Personally I think its impossible, but I would like to be sure or proven wrong.
The way I am doing something like this at the mom... | Short answer, no.
Long answer, not in a portable foolproof manner. |
514,603 | <p>I need to design a Key/value table in my database and I'm looking for guidance on the best way to do this. Basically, I need to be able to associate values to a dynamic set of named properties and apply them to an external key.</p>
<p>The operations I need to be able to support are:</p>
<ul>
<li>Apply a key/value... | [
{
"answer_id": 514613,
"author": "Sam Saffron",
"author_id": 17174,
"author_profile": "https://Stackoverflow.com/users/17174",
"pm_score": 2,
"selected": false,
"text": "<p>An option that may be worth exploring is digesting the key using SHA1 or MD5 before inserting it into the table. </... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to design a Key/value table in my database and I'm looking for guidance on the best way to do this. Basically, I need to be able to associate values to a dynamic set of named properties and apply them to an external key.
The operations I need to be able to support are:
* Apply a key/value pair to a group of it... | You are employing a database model called [Entity-Attribute-Value](http://en.wikipedia.org/wiki/Entity-attribute-value_model). This is a common way to store key/value pairs in a relational database, but it has a number of weaknesses with respect to database normalization and efficiency.
Yes, the table design you showe... |
514,609 | <p>I can read one record from Xml just fine with some code I have, but how do you read multiple in an xml file such as so:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<XXX_XXX_response xmlns="http://example.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://e... | [
{
"answer_id": 514650,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>XPathDocument (CreateNavigator) & XPathNavigator are the classes you can use.</p>\n\n<p>Also, XPathNavigator ha... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/93468/"
] | I can read one record from Xml just fine with some code I have, but how do you read multiple in an xml file such as so:
```
<?xml version="1.0" encoding="UTF-8"?>
<XXX_XXX_response xmlns="http://example.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.com/1.0/ http://... | You can read the xml like this and store objects of class Album in a generic list.
```
List<Album> albums = new List<Album>();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("MyXml.xml");
XmlElement root = doc.DocumentElement;
XmlNodeList nodes = root.SelectNodes("/album");
foreach (XmlNode node in nodes)
{
... |
514,610 | <p>Being weak on regular expressions, I've been working with them to improve. One concept I've been trying to do is to remove all HTML elements except for a list of allowed ones.</p>
<p>I've managed to do the reverse -- remove a specified list of elements:</p>
<pre><code><\/?(strong|em|a)[^>]*>
</code></pre... | [
{
"answer_id": 514615,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 0,
"selected": false,
"text": "<p>Assuming PCRE, use (?!<i>elements</i>) instead of (<i>elements</i>).</p>\n"
},
{
"answer_id": 514739,
"author... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23666/"
] | Being weak on regular expressions, I've been working with them to improve. One concept I've been trying to do is to remove all HTML elements except for a list of allowed ones.
I've managed to do the reverse -- remove a specified list of elements:
```
<\/?(strong|em|a)[^>]*>
```
However I want the opposite, and remo... | ```
/<(.|\n)*?>/g
```
[matches all HTML tags pairs including attributes in the tags](http://www.pagecolumn.com/tool/all_about_html_tags.htm)
Exclude tags strong and em
```
(?!strong|em)
```
matches all HTML tags pairs but strong and em
```
<((?!strong|em).|\n)*?>
``` |
514,617 | <p>I have a small project I am doing in Python using web.py. It's a name generator, using 4 "parts" of a name (<code>firstname, middlename, anothername, surname</code>). Each part of the name is a collection of entites in a MySQL databse (<code>name_part (id, part, type_id)</code>, and <code>name_part_type (id, descrip... | [
{
"answer_id": 514629,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 3,
"selected": true,
"text": "<p>I think what you're after is:</p>\n\n<pre><code>select * from name_part\n where type_id=[something]\n order by u... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31307/"
] | I have a small project I am doing in Python using web.py. It's a name generator, using 4 "parts" of a name (`firstname, middlename, anothername, surname`). Each part of the name is a collection of entites in a MySQL databse (`name_part (id, part, type_id)`, and `name_part_type (id, description)`). Basic stuff, I guess.... | I think what you're after is:
```
select * from name_part
where type_id=[something]
order by used_count asc, rand()
limit 1
```
This will put the lesser used names at the top of the list and, if there's multiples with the same (lowest) used\_count, they'll sort randomly. |
514,621 | <p>Looking through my server logs, I see that a lot of pages on my site are requesting <code>favicon.ico</code>, <code>favicon.jpg</code>, <code>favicon.png</code>, etc in a variety of different directories.</p>
<p>Instead of wading through each page to try to figure out where each incorrect request is coming from, I'... | [
{
"answer_id": 514633,
"author": "alex",
"author_id": 31671,
"author_profile": "https://Stackoverflow.com/users/31671",
"pm_score": 4,
"selected": true,
"text": "<p>Try this</p>\n\n<pre><code>RewriteCond %{REQUEST_URI} !^/favicon\\.ico [NC] # if not already going to favicon.ico\nRewriteC... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | Looking through my server logs, I see that a lot of pages on my site are requesting `favicon.ico`, `favicon.jpg`, `favicon.png`, etc in a variety of different directories.
Instead of wading through each page to try to figure out where each incorrect request is coming from, I'm writing some apache redirect rules to cha... | Try this
```
RewriteCond %{REQUEST_URI} !^/favicon\.ico [NC] # if not already going to favicon.ico
RewriteCond %{REQUEST_URI} favicon\.ico [NC] # edit this line to match your favicon matching regex
RewriteRule (.*) http://www.domain.com.au/favicon.ico [R=301,L] #redirect to the real address
``` |
514,635 | <p>How can space and tab be represented in an XML tag?</p>
<p>Are there any special characters that can represent them?</p>
| [
{
"answer_id": 514669,
"author": "galets",
"author_id": 14395,
"author_profile": "https://Stackoverflow.com/users/14395",
"pm_score": 6,
"selected": false,
"text": "<p>I think you could use an actual space or tab directly in XML document, but if you are looking for special characters to ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22162/"
] | How can space and tab be represented in an XML tag?
Are there any special characters that can represent them? | I think you could use an actual space or tab directly in XML document, but if you are looking for special characters to represent them so that text processors can't mess them up, then it's:
```
space =  
tab = 	
``` |
514,637 | <p>I am trying to optimize a small, highly used function which uses the high bits in an unsigned short int to indicate the values of an array to sum together. At first I was using the obvious approach shown below. Please note that loop unrolling is not explicitly shown as it should be done by the compiler.</p>
<pre><c... | [
{
"answer_id": 514652,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "<p>This depends <strong>totally</strong> on the compiler, machine instruction set and, probably, phase of the moon.</p>\... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61793/"
] | I am trying to optimize a small, highly used function which uses the high bits in an unsigned short int to indicate the values of an array to sum together. At first I was using the obvious approach shown below. Please note that loop unrolling is not explicitly shown as it should be done by the compiler.
```
int total ... | You could make it branchless without a multiply. It looks like for each bit set you are using that bit position as an index into an array.
First, you can easily extract bits set with:
```
unsigned short set_mask= i & -i;
i&= i - 1;
```
Then, you can get the bit index by counting the bits set in `(set_mask - 1)`. Th... |
514,638 | <p>I've implemented my own copy of the model view presenter pattern (in vein of web client software factory) so I can leverage my own DI framework instead of being tied to WCSF's ObjectBuilder which I had numerous problems with. I've come up with a few ways to do it but none of them particularly make me happy. I wanted... | [
{
"answer_id": 531166,
"author": "Pablo Fernandez",
"author_id": 7595,
"author_profile": "https://Stackoverflow.com/users/7595",
"pm_score": 4,
"selected": true,
"text": "<p>I'd Use solution #1b, and create a <a href=\"http://martinfowler.com/eaaCatalog/layerSupertype.html\" rel=\"norefe... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37055/"
] | I've implemented my own copy of the model view presenter pattern (in vein of web client software factory) so I can leverage my own DI framework instead of being tied to WCSF's ObjectBuilder which I had numerous problems with. I've come up with a few ways to do it but none of them particularly make me happy. I wanted to... | I'd Use solution #1b, and create a [layer supertype](http://martinfowler.com/eaaCatalog/layerSupertype.html) for all the pages, in order to DRY the presenter initialization a bit more. like this:
Page code:
```
public partial class _Default : AbstractPage, IEmployeeView
{
private EmployeePresenter presenter;
... |
514,673 | <p>The closest I've seen in the PHP docs, is to fread() a given length, but that doesnt specify which line to start from. Any other suggestions?</p>
| [
{
"answer_id": 514717,
"author": "grom",
"author_id": 486,
"author_profile": "https://Stackoverflow.com/users/486",
"pm_score": 5,
"selected": true,
"text": "<p>You not going to be able to read starting from line X because lines can be of arbitrary length. So you will have to read from t... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24744/"
] | The closest I've seen in the PHP docs, is to fread() a given length, but that doesnt specify which line to start from. Any other suggestions? | You not going to be able to read starting from line X because lines can be of arbitrary length. So you will have to read from the start counting the number of lines read to get to line X. For example:
```
<?php
$f = fopen('sample.txt', 'r');
$lineNo = 0;
$startLine = 3;
$endLine = 6;
while ($line = fgets($f)) {
$l... |
514,678 | <p>In the SharePoint install document I have it says,</p>
<blockquote>
<p>If you use a domain user account for
the SQL Server service account, you
must make sure that a valid service
principal name (SPN) for that account
and instance of SQL Server on their
database server exists in their
environment. Thi... | [
{
"answer_id": 514752,
"author": "codekaizen",
"author_id": 58391,
"author_profile": "https://Stackoverflow.com/users/58391",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not 100% sure about this, but I know how to use SetSPN from Win2k, so I'd say you want \"http/servername\" if yo... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6268/"
] | In the SharePoint install document I have it says,
>
> If you use a domain user account for
> the SQL Server service account, you
> must make sure that a valid service
> principal name (SPN) for that account
> and instance of SQL Server on their
> database server exists in their
> environment. This is the case
... | The syntax would look something like the following:
```
SetSPN -a http/www.mywebsite.com serviceaccountname
```
or
```
SetSPN -a http/www.mywebsite.com domainname\serviceaccountname
```
Try and think of it this way: You want to register the owner of the http service for www.mywebsite.com to the domain\serviceacco... |
514,688 | <p>I have a URL which requires some parameters. The values of those parameters can be accented characters, so I absolutely need to UrlEncode them. Strangely, I see a difference between the behavior or Javascript and .NET.</p>
<p>Let's pretend I try to UrlEncode the word "éléphant". In JavaScript (according to this Web... | [
{
"answer_id": 514700,
"author": "Sciolist",
"author_id": 16045,
"author_profile": "https://Stackoverflow.com/users/16045",
"pm_score": 4,
"selected": true,
"text": "<p>System.Web.HttpUtility.UrlEncode will use UTF8 (i think..) as its default encoder, you can change this by specifying on... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42024/"
] | I have a URL which requires some parameters. The values of those parameters can be accented characters, so I absolutely need to UrlEncode them. Strangely, I see a difference between the behavior or Javascript and .NET.
Let's pretend I try to UrlEncode the word "éléphant". In JavaScript (according to this WebSite: <htt... | System.Web.HttpUtility.UrlEncode will use UTF8 (i think..) as its default encoder, you can change this by specifying one..
```
System.Web.HttpUtility.UrlEncode("éléphant", Encoding.Default); // %e9l%e9phant
```
Though it may be preferable to specify an actual codepage or what not, instead of relying on the OS defaul... |
514,714 | <p>I am writing somewhat of a proxy program in Java. Here's how it works:</p>
<ol>
<li>The browser will be connected to the program.</li>
<li>Any requests by the browser will be first be printed out to standard out, then forwarded to the server.</li>
<li>The server then returns a response, which is also printed to sta... | [
{
"answer_id": 514700,
"author": "Sciolist",
"author_id": 16045,
"author_profile": "https://Stackoverflow.com/users/16045",
"pm_score": 4,
"selected": true,
"text": "<p>System.Web.HttpUtility.UrlEncode will use UTF8 (i think..) as its default encoder, you can change this by specifying on... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20526/"
] | I am writing somewhat of a proxy program in Java. Here's how it works:
1. The browser will be connected to the program.
2. Any requests by the browser will be first be printed out to standard out, then forwarded to the server.
3. The server then returns a response, which is also printed to standard out, then forwarded... | System.Web.HttpUtility.UrlEncode will use UTF8 (i think..) as its default encoder, you can change this by specifying one..
```
System.Web.HttpUtility.UrlEncode("éléphant", Encoding.Default); // %e9l%e9phant
```
Though it may be preferable to specify an actual codepage or what not, instead of relying on the OS defaul... |
514,721 | <p>Is it possible to truncate a Java string to the closest word boundary after a number of characters. Similar to the PHP wordwrap() function, shown in this <a href="https://stackoverflow.com/questions/79960/how-to-truncate-a-string-in-php-to-the-word-closest-to-a-certain-number-of-charac">example</a>.</p>
| [
{
"answer_id": 514740,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 5,
"selected": true,
"text": "<p>Use a <code>java.text.BreakIterator</code>, something like this:</p>\n\n<pre><code>String s = ...;\nint number_chars = .... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264/"
] | Is it possible to truncate a Java string to the closest word boundary after a number of characters. Similar to the PHP wordwrap() function, shown in this [example](https://stackoverflow.com/questions/79960/how-to-truncate-a-string-in-php-to-the-word-closest-to-a-certain-number-of-charac). | Use a `java.text.BreakIterator`, something like this:
```
String s = ...;
int number_chars = ...;
BreakIterator bi = BreakIterator.getWordInstance();
bi.setText(s);
int first_after = bi.following(number_chars);
// to truncate:
s = s.substring(0, first_after);
``` |
514,725 | <p>I am new to git, and have a subversion repository that I want to be able to import into a git repository occasionally (for deployment). So I want to perform most of the updates using svn but wanted to see what's the best way to push it to git (just the default/master branch).</p>
| [
{
"answer_id": 514736,
"author": "Andrew Vit",
"author_id": 61439,
"author_profile": "https://Stackoverflow.com/users/61439",
"pm_score": 2,
"selected": false,
"text": "<p>Why not just work in git on your workstation too? That would be the most straightforward.</p>\n\n<ul>\n<li><code>git... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47110/"
] | I am new to git, and have a subversion repository that I want to be able to import into a git repository occasionally (for deployment). So I want to perform most of the updates using svn but wanted to see what's the best way to push it to git (just the default/master branch). | I know you only want to import the master/trunk branch of your svn repository, but I would like to mention **[svn2git](http://rubyforge.org/projects/svn2git/)** in order to import your svn into a git repository.
It is better than `git svn clone` because if you have this code in svn:
```
trunk
...
branches
... |
514,754 | <p>I have a web application that I am trying to build and publish. The odd thing is that when I do clean, build or rebuild everything seems fine. When I do a publish though I get the message that the publish failed, but get no further information:</p>
<pre><code>========== Publish: 0 succeeded, 1 failed, 0 skipped =... | [
{
"answer_id": 514789,
"author": "Alexander Prokofyev",
"author_id": 11256,
"author_profile": "https://Stackoverflow.com/users/11256",
"pm_score": 2,
"selected": false,
"text": "<p>Output window (Ctrl+Alt+O) shows informational messages and errors during publish. Do you have differences ... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25719/"
] | I have a web application that I am trying to build and publish. The odd thing is that when I do clean, build or rebuild everything seems fine. When I do a publish though I get the message that the publish failed, but get no further information:
```
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
```
... | Ankh seems to cause some issues. I found that you have to open visual studio, then disable Ankh by going to Tools -> Options -> Source Control -> Choose None as the Current source control plugin. Then close visual studio and re-open it. Then publish seems to work... |
514,767 | <p>I'm writing an Applescript playlist generator. Part of the process is to read the iTunes Library XML file to get a list of all of the genres in a user's library. This is the python implementation, which works as I'd like:</p>
<pre><code> #!/usr/bin/env python
# script to get all of the genres from itunes
imp... | [
{
"answer_id": 514919,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 3,
"selected": true,
"text": "<p>Why are you using regex to parse XML? Why not use a proper XML library? Python has some great utilities like ElementTre... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60664/"
] | I'm writing an Applescript playlist generator. Part of the process is to read the iTunes Library XML file to get a list of all of the genres in a user's library. This is the python implementation, which works as I'd like:
```
#!/usr/bin/env python
# script to get all of the genres from itunes
import re,sys,sets
... | Why are you using regex to parse XML? Why not use a proper XML library? Python has some great utilities like ElementTree that make walking the DOM a lot easier, and it yields nice, friendly objects rather than untyped strings.
Here are some ways of parsing XML using Applescript:
[Applescript XML Parser](http://lists.... |
514,771 | <p>I am running a long linux program in a remote machine, and I want to stop it, but my problem is that if I use the kill command then the program will exit without saving results. Normally what I do to finish the program is use <kbd>Ctrl</kbd>+<kbd>C</kbd> and in that case the program saves the results, but right now ... | [
{
"answer_id": 514801,
"author": "Firas Assaad",
"author_id": 23153,
"author_profile": "https://Stackoverflow.com/users/23153",
"pm_score": 8,
"selected": true,
"text": "<p>Try:</p>\n\n<pre><code>kill -SIGINT processPIDHere\n</code></pre>\n\n<p>Basically <kbd>Ctrl C</kbd> sends the <code... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39160/"
] | I am running a long linux program in a remote machine, and I want to stop it, but my problem is that if I use the kill command then the program will exit without saving results. Normally what I do to finish the program is use `Ctrl`+`C` and in that case the program saves the results, but right now I am not in the machi... | Try:
```
kill -SIGINT processPIDHere
```
Basically `Ctrl C` sends the `SIGINT` (interrupt) signal while kill sends the `SIGTERM` (termination) signal by default unless you specify the signal to send. |
514,776 | <p>When a user have changed something in a form, then clicks on any link that will direct him to another page, I'd like to trigger a popup with a "Would you like to Save before leaving?" option. </p>
<p>How can I do this? </p>
| [
{
"answer_id": 514808,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 0,
"selected": false,
"text": "<p>This is how it can be done but this is not always reliable:</p>\n\n<pre><code><html>\n<head>\n<script type... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61635/"
] | When a user have changed something in a form, then clicks on any link that will direct him to another page, I'd like to trigger a popup with a "Would you like to Save before leaving?" option.
How can I do this? | Example:
```
<script type="text/javascript">
var shouldConfirm = false;
window.onbeforeunload = function() {
if(shouldConfirm) {
return "You have made unsaved changes. Would you still like to leave this page?";
}
}
</script>
<input id="FullName" type="text" />
<script... |
514,777 | <p>In my Java web application, the NTLM domain controller name is specified in web.xml like this:</p>
<pre><code><filter>
<!-- other code -->
<init-param>
<param-name>jcifs.http.domainController</param-name>
<param-value>DCNAME</param-value>
</init-pa... | [
{
"answer_id": 514831,
"author": "Nrj",
"author_id": 11614,
"author_profile": "https://Stackoverflow.com/users/11614",
"pm_score": 0,
"selected": false,
"text": "<p>Can read it inside the init() of the servlet using JNDI to which you are passing this param.</p>\n"
},
{
"answer_id... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In my Java web application, the NTLM domain controller name is specified in web.xml like this:
```
<filter>
<!-- other code -->
<init-param>
<param-name>jcifs.http.domainController</param-name>
<param-value>DCNAME</param-value>
</init-param>
<!-- other code -->
</filter>
```
In the above XML, ... | See this [link](http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html). You need to define an environment resource like this:
```
<Environment name="myName" value="whatever"
type="java.lang.String" override="false"/>
```
and then read it from code:
```
Context initCtx = new InitialContext();
C... |
514,817 | <p>I am trying to create a view for the following query.</p>
<pre><code>SELECT DISTINCT
products.pid AS id,
products.pname AS name,
products.p_desc AS description,
products.p_loc AS location,
products.p_uid AS userid,
products.isaproduct AS whatisit
FROM products
UNION
SELECT DIST... | [
{
"answer_id": 514823,
"author": "Learning",
"author_id": 18275,
"author_profile": "https://Stackoverflow.com/users/18275",
"pm_score": 2,
"selected": false,
"text": "<p>You might want to swith the order of userid and location in the second select. The column names should match 1 to 1 in... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to create a view for the following query.
```
SELECT DISTINCT
products.pid AS id,
products.pname AS name,
products.p_desc AS description,
products.p_loc AS location,
products.p_uid AS userid,
products.isaproduct AS whatisit
FROM products
UNION
SELECT DISTINCT
service... | ```
CREATE VIEW vw_product_services AS
SELECT DISTINCT products.pid AS id,
products.pname AS name,
products.p_desc AS description,
products.p_loc AS location,
products.p_uid AS userid,
products.isaproduct AS whatisit
FROM product... |
514,824 | <p>I have a class in C++ with the following member:</p>
<pre><code>map< someEnum, vector<SomeObject*>* > someMap
</code></pre>
<p>So I have a map that gives me a vector of objects for each enumeration I have. For the life of me, I cannot understand how C++ is initializing these objects. Does it deep initi... | [
{
"answer_id": 514843,
"author": "Jesse Beder",
"author_id": 112,
"author_profile": "https://Stackoverflow.com/users/112",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like the map gives you a pointer to a vector of objects. If you try to use the map via</p>\n\n<p><code>mymap[M... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24545/"
] | I have a class in C++ with the following member:
```
map< someEnum, vector<SomeObject*>* > someMap
```
So I have a map that gives me a vector of objects for each enumeration I have. For the life of me, I cannot understand how C++ is initializing these objects. Does it deep initialize them by default? If not, what do... | The rule is: If an STL container contains **pointers to objects**, it it does **not** create objects on heap and assign them to these pointers. If, however, it contains **objects** themselves, it **does** call the default constructor of each contained object and thus initialises them.
What you have here is a map conta... |
514,839 | <p>I have just coded up a web based flv file download utility. When I try to download an flv file, the browser does not show a progress bar as in I do not see the time left for download. Somewhere I read that this happens if the flv file you are trying to download does not have a meta tag associated with it. So I ran m... | [
{
"answer_id": 514918,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 3,
"selected": true,
"text": "<p>It is likely that your web server is not setting the Content-length header correctly, or something like that. </p>\n\n<p... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38857/"
] | I have just coded up a web based flv file download utility. When I try to download an flv file, the browser does not show a progress bar as in I do not see the time left for download. Somewhere I read that this happens if the flv file you are trying to download does not have a meta tag associated with it. So I ran my f... | It is likely that your web server is not setting the Content-length header correctly, or something like that.
Is your file really only 167 bytes? That seems somewhat small. |
514,870 | <p>I'm working in C++.</p>
<p>I want to write a potentially very long formatted string using sprintf (specifically a secure counted version like _snprintf_s, but the idea is the same). The approximate length is unknown at compile time so I'll have to use some dynamically allocated memory rather than relying on a big ... | [
{
"answer_id": 514894,
"author": "jasonmray",
"author_id": 17230,
"author_profile": "https://Stackoverflow.com/users/17230",
"pm_score": 0,
"selected": false,
"text": "<p>I've looked for the same functionality you're talking about, but as far as I know, something as simple as the C99 met... | 2009/02/05 | [
"https://Stackoverflow.com/questions/514870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56786/"
] | I'm working in C++.
I want to write a potentially very long formatted string using sprintf (specifically a secure counted version like \_snprintf\_s, but the idea is the same). The approximate length is unknown at compile time so I'll have to use some dynamically allocated memory rather than relying on a big static bu... | The man page for `snprintf` says:
```
Return value
Upon successful return, these functions return the number of
characters printed (not including the trailing '\0' used to end
output to strings). The functions snprintf and vsnprintf do not
write more than size bytes (including the... |