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 |
|---|---|---|---|---|---|---|
120,033 | <p>In C++, it's not possible to initialize array members in the initialization list, thus member objects should have default constructors and they should be properly initialized in the constructor. Is there any (reasonable) workaround for this apart from not using arrays?</p>
<p>[Anything that can be initialized using... | [
{
"answer_id": 120084,
"author": "Suma",
"author_id": 16673,
"author_profile": "https://Stackoverflow.com/users/16673",
"pm_score": 3,
"selected": true,
"text": "<p>One possible workaround is to avoid the compiler calling the OtherClass constructor at all, and to call it on your own usin... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20957/"
] | In C++, it's not possible to initialize array members in the initialization list, thus member objects should have default constructors and they should be properly initialized in the constructor. Is there any (reasonable) workaround for this apart from not using arrays?
[Anything that can be initialized using only the ... | One possible workaround is to avoid the compiler calling the OtherClass constructor at all, and to call it on your own using placement new to initialize it whichever way you need. Example:
```
class Foo
{
private:
char inst[3*sizeof(OtherClass)]; // Array size fixed. OtherClass has no default ctor.
// u... |
120,061 | <p>I try to fetch a Wikipedia article with Python's urllib:</p>
<pre><code>f = urllib.urlopen("http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes")
s = f.read()
f.close()
</code></pre>
<p>However instead of the html page I get the following response: Error - Wikimedia Foundation:</... | [
{
"answer_id": 120073,
"author": "Vasil",
"author_id": 7883,
"author_profile": "https://Stackoverflow.com/users/7883",
"pm_score": 1,
"selected": false,
"text": "<p>Try changing the user agent header you are sending in your request to something like:\nUser-Agent: Mozilla/5.0 (X11; U; Lin... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20999/"
] | I try to fetch a Wikipedia article with Python's urllib:
```
f = urllib.urlopen("http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes")
s = f.read()
f.close()
```
However instead of the html page I get the following response: Error - Wikimedia Foundation:
```
Request: GET http://en.wik... | You need to use the [urllib2](http://docs.python.org/lib/module-urllib2.html) that superseedes [urllib](http://docs.python.org/lib/module-urllib.html) in the [python std library](http://docs.python.org/lib/) in order to change the user agent.
Straight from the [examples](http://web.archive.org/web/20070202031348/http:... |
120,071 | <p>I have a string of arbitrary length, and starting at position p0, I need to find the first occurrence of one of three 3-letter patterns.</p>
<p>Assume the string contain only letters. I need to find the count of triplets starting at position p0 and jumping forward in triplets until the first occurrence of either 'a... | [
{
"answer_id": 120094,
"author": "Mike G.",
"author_id": 18901,
"author_profile": "https://Stackoverflow.com/users/18901",
"pm_score": 4,
"selected": false,
"text": "<pre><code>$string=~/^ # from the start of the string\n (?:.{$p0}) # skip (don't capture) \"$p0\" occurrences... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15161/"
] | I have a string of arbitrary length, and starting at position p0, I need to find the first occurrence of one of three 3-letter patterns.
Assume the string contain only letters. I need to find the count of triplets starting at position p0 and jumping forward in triplets until the first occurrence of either 'aaa' or 'bb... | Moritz says this might be faster than a regex. Even if it's a little slower, it's easier to understand at 5 am. :)
```
#0123456789.123456789.123456789.
my $string = "alsdhfaaasccclaaaagalkfgblkgbklfs";
my $pos = 9;
my $length = 3;
my $regex = qr/^(aaa|bbb|ccc)/;
while( $pos < length $string ... |
120,082 | <p>I have a problem with the design of a <code>VetoableChangeListener</code>. I implement the <code>VetoableChangeListener</code> interface to listen changes of a property in a model class, so when the model fires </p>
<pre><code>vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException
</code></pre>
<p>…I... | [
{
"answer_id": 120712,
"author": "tim_yates",
"author_id": 6509,
"author_profile": "https://Stackoverflow.com/users/6509",
"pm_score": 0,
"selected": false,
"text": "<p>You should check the Vetoable change before you change the model, not after...</p>\n\n<p>ie: if there is a problem, th... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518/"
] | I have a problem with the design of a `VetoableChangeListener`. I implement the `VetoableChangeListener` interface to listen changes of a property in a model class, so when the model fires
```
vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException
```
…I try to save the change in a DB, which could fai... | Your "workaround" is not really a workaround but in fact sounds like the proper solution to me: confirming that there is in fact a change for the current state of the object prior to attempting to "change" the persisted version. This will also be much more efficient (database access is expensive). |
120,083 | <p>Is there a way to alter the precision of an existing decimal column in Microsoft SQL Server?</p>
| [
{
"answer_id": 120821,
"author": "VanSkalen",
"author_id": 7367,
"author_profile": "https://Stackoverflow.com/users/7367",
"pm_score": 9,
"selected": true,
"text": "<pre><code>ALTER TABLE Testing ALTER COLUMN TestDec decimal(16,1)\n</code></pre>\n\n<p>Just put <code>decimal(precision, sc... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12767/"
] | Is there a way to alter the precision of an existing decimal column in Microsoft SQL Server? | ```
ALTER TABLE Testing ALTER COLUMN TestDec decimal(16,1)
```
Just put `decimal(precision, scale)`, replacing the precision and scale with your desired values.
I haven't done any testing with this with data in the table, but if you alter the precision, you would be subject to losing data if the new precision is low... |
120,102 | <p>My stored procedure is called as below from an SQL instegartion package within SQL Server 2005</p>
<p>EXEC ? = Validation.PopulateFaultsFileDetails ? , 0</p>
<p>Though i'm not sure what the ? means</p>
| [
{
"answer_id": 120115,
"author": "Rob",
"author_id": 7872,
"author_profile": "https://Stackoverflow.com/users/7872",
"pm_score": 1,
"selected": false,
"text": "<p>The ? stands fora variable, to be precise, a parameter. The first ? is the return value of the stored prcoedure and the secon... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21004/"
] | My stored procedure is called as below from an SQL instegartion package within SQL Server 2005
EXEC ? = Validation.PopulateFaultsFileDetails ? , 0
Though i'm not sure what the ? means | When this SQL statment is called, both question marks (?) will be replaced. The first will be replaced by a variable which will receive the return value of the stored procedure. The second will be replaced by a value which will be passed into the stored procedure. The code to use this statement will look something like... |
120,114 | <p>I am using following PHP code to connect to MS Access database:</p>
<pre><code>$odb_conn = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". $db_path.";";
$odb_conn->open($connstr);
</code></pre>
<p>How can I retrieve database catalog/metadata from the mdb file?</p>
<p><... | [
{
"answer_id": 120195,
"author": "Abbas",
"author_id": 4714,
"author_profile": "https://Stackoverflow.com/users/4714",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>MSysObjects</code> table can be used to query metadata in Access:</p>\n\n<pre><code>SELECT NAME\nFROM MSysObjects... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6561/"
] | I am using following PHP code to connect to MS Access database:
```
$odb_conn = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". $db_path.";";
$odb_conn->open($connstr);
```
How can I retrieve database catalog/metadata from the mdb file?
**FOUND THE SOLUTION**
```
$rs_meta ... | You will find information on ADO here :
* <http://msdn.microsoft.com/en-us/library/ms675532(VS.85).aspx>
* <http://www.w3schools.com/ado/default.asp>
The connection object has an OpenSchema method to get database schema information.
I don't know how to use MS Acces DB with PHP and how your new COM() object works, b... |
120,170 | <p>I'm doing some testing on Firefox toolbars for the sake of learning and I can't find out any information on how to store the contents of a "search" drop-down inside the user's profile.</p>
<p>Is there any tutorial on how to sort this out?</p>
| [
{
"answer_id": 121358,
"author": "Gustavo Carreno",
"author_id": 8167,
"author_profile": "https://Stackoverflow.com/users/8167",
"pm_score": 2,
"selected": true,
"text": "<p>Since it's taking quite a bit to get an answer I went and investigate it myself.\nHere is what I've got now. Not a... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167/"
] | I'm doing some testing on Firefox toolbars for the sake of learning and I can't find out any information on how to store the contents of a "search" drop-down inside the user's profile.
Is there any tutorial on how to sort this out? | Since it's taking quite a bit to get an answer I went and investigate it myself.
Here is what I've got now. Not all is clear to me but it works.
Let's assume you have a <textbox> like this, on your .xul:
```
<textbox id="search_with_history" />
```
You now have to add some other attributes to enable history.
```
<... |
120,180 | <p>I'm looking for a way to do query auto-completion/suggestions in Lucene. I've Googled around a bit and played around a bit, but all of the examples I've seen seem to be setting up filters in Solr. We don't use Solr and aren't planning to move to using Solr in the near future, and Solr is obviously just wrapping arou... | [
{
"answer_id": 120430,
"author": "Alexandre Victoor",
"author_id": 11897,
"author_profile": "https://Stackoverflow.com/users/11897",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the class <strong>PrefixQuery</strong> on a \"dictionary\" index. The class <strong>LuceneDiction... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6282/"
] | I'm looking for a way to do query auto-completion/suggestions in Lucene. I've Googled around a bit and played around a bit, but all of the examples I've seen seem to be setting up filters in Solr. We don't use Solr and aren't planning to move to using Solr in the near future, and Solr is obviously just wrapping around ... | Based on @Alexandre Victoor's answer, I wrote a little class based on the Lucene Spellchecker in the contrib package (and using the LuceneDictionary included in it) that does exactly what I want.
This allows re-indexing from a single source index with a single field, and provides suggestions for terms. Results are sor... |
120,191 | <p>So you've created a ruby library.</p>
<p>How do you create and publish your rubygem? And what common pitfalls and gotchas are there pertaining to creating and publishing rubygems?</p>
| [
{
"answer_id": 120390,
"author": "user6325",
"author_id": 6325,
"author_profile": "https://Stackoverflow.com/users/6325",
"pm_score": 2,
"selected": false,
"text": "<p>I recommend <a href=\"http://gems.github.com\" rel=\"nofollow noreferrer\">github</a> as a place to start, especially fo... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8683/"
] | So you've created a ruby library.
How do you create and publish your rubygem? And what common pitfalls and gotchas are there pertaining to creating and publishing rubygems? | There are several tools to help you build your own gems. [hoe](http://seattlerb.rubyforge.org/hoe/) and [newgem](http://newgem.rubyforge.org/) are the best-known, and have a lot of good qualities. However, hoe adds itself as a dependency to your gem, and newgem has become a very large tool, one that I find unwieldy whe... |
120,201 | <p>I want to upload and then process a file in a Ruby on Rails app. The file upload is usually quite short, but the server-side processing can take some time (more than 20 seconds) so I want to give the user some indicator - something better than a meaningless 'processing...' screen.</p>
<p>I'm trying to use the foll... | [
{
"answer_id": 120317,
"author": "liangzan",
"author_id": 11927,
"author_profile": "https://Stackoverflow.com/users/11927",
"pm_score": 3,
"selected": true,
"text": "<p><code>periodically_call_remote()</code> updates a <code>div</code>. It won't call your JavaScript function. I'm no Java... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6106/"
] | I want to upload and then process a file in a Ruby on Rails app. The file upload is usually quite short, but the server-side processing can take some time (more than 20 seconds) so I want to give the user some indicator - something better than a meaningless 'processing...' screen.
I'm trying to use the following code ... | `periodically_call_remote()` updates a `div`. It won't call your JavaScript function. I'm no JavaScript guru, but to solve your problem, you should do your own `xmlhttp` call. If I were you, I'd use prototype's AJAX request
<http://www.prototypejs.org/api/ajax/request>
and use JavaScript's settimeout or setinterval t... |
120,206 | <p>The problem is not about randomness itself (we have rand), but in cryptographically secure PRNG. What can be used on Linux, or ideally POSIX? Does NSS have something useful?</p>
<p><strong>Clarification</strong>: I know about /dev/random, but it may run out of entropy pool. And I'm not sure whether /dev/urandom is ... | [
{
"answer_id": 120209,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>/dev/random</code> device is intended to be a source of cryptographically secure bits.</p>\n"
},
{
"... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9403/"
] | The problem is not about randomness itself (we have rand), but in cryptographically secure PRNG. What can be used on Linux, or ideally POSIX? Does NSS have something useful?
**Clarification**: I know about /dev/random, but it may run out of entropy pool. And I'm not sure whether /dev/urandom is guaranteed to be crypto... | Use `/dev/random` (requires user input, eg mouse movements) or `/dev/urandom`. The latter has an entropy pool and doesn't require any user input unless the pool is empty.
You can read from the pool like this:
```
char buf[100];
FILE *fp;
if (fp = fopen("/dev/urandom", "r")) {
fread(&buf, sizeof(char), 100, fp);
... |
120,212 | <p>I am using VMware Server 1.0.7 on Windows XP SP3 at the moment to test software in virtual machines.</p>
<p>I have also tried Microsoft Virtual PC (do not remeber the version, could be 2004 or 2007) and VMware was way faster at the time.</p>
<p>I have heard of Parallels and VirtualBox but I did not have the time t... | [
{
"answer_id": 120209,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>/dev/random</code> device is intended to be a source of cryptographically secure bits.</p>\n"
},
{
"... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17469/"
] | I am using VMware Server 1.0.7 on Windows XP SP3 at the moment to test software in virtual machines.
I have also tried Microsoft Virtual PC (do not remeber the version, could be 2004 or 2007) and VMware was way faster at the time.
I have heard of Parallels and VirtualBox but I did not have the time to try them out. A... | Use `/dev/random` (requires user input, eg mouse movements) or `/dev/urandom`. The latter has an entropy pool and doesn't require any user input unless the pool is empty.
You can read from the pool like this:
```
char buf[100];
FILE *fp;
if (fp = fopen("/dev/urandom", "r")) {
fread(&buf, sizeof(char), 100, fp);
... |
120,228 | <p>I have a site on my webhotel I would like to run some scheduled tasks on. What methods of achieving this would you recommend?</p>
<p>What I’ve thought out so far is having a script included in the top of every page and then let this script check whether it’s time to run this job or not.</p>
<p>This is just a quick... | [
{
"answer_id": 120236,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 5,
"selected": false,
"text": "<p>That's what cronjobs are made for. <code>man crontab</code> assuming you are running a linux server. If you do... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15214/"
] | I have a site on my webhotel I would like to run some scheduled tasks on. What methods of achieving this would you recommend?
What I’ve thought out so far is having a script included in the top of every page and then let this script check whether it’s time to run this job or not.
This is just a quick example of what ... | That's what cronjobs are made for. `man crontab` assuming you are running a linux server. If you don't have shell access or no way to setup cronjobs, there are free services that setup cronjobs on external servers and ping one of your URLs. |
120,244 | <p>I'm trying to put together a selector in SASS that will operate on the visted, hovered state of a link, but I can't quite seem to get the markup right, can someone enlighten me?
I was writing it like this:</p>
<pre><code> &:visited:hover
attribute: foo
</code></pre>
| [
{
"answer_id": 120515,
"author": "user6325",
"author_id": 6325,
"author_profile": "https://Stackoverflow.com/users/6325",
"pm_score": 1,
"selected": false,
"text": "<pre><code>a\n &:visited:hover\n :attribute foo\n</code></pre>\n\n<p>Try that - note that identation is two spaces, ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2977/"
] | I'm trying to put together a selector in SASS that will operate on the visted, hovered state of a link, but I can't quite seem to get the markup right, can someone enlighten me?
I was writing it like this:
```
&:visited:hover
attribute: foo
``` | ```
a
&:visited:hover
attribute: foo
```
Nowadays, this is the only valid form. Indention has to be consistent (2 spaces are recommended) and the colon follows the attribute. |
120,250 | <p>Python allocates integers automatically based on the underlying system architecture. Unfortunately I have a huge dataset which needs to be fully loaded into memory. </p>
<p>So, is there a way to force Python to use only 2 bytes for some integers (equivalent of C++ 'short')?</p>
| [
{
"answer_id": 120256,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 5,
"selected": false,
"text": "<p>Nope. But you can use short integers in arrays:</p>\n\n<pre><code>from array import array\na = array(\"h\") # h... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21029/"
] | Python allocates integers automatically based on the underlying system architecture. Unfortunately I have a huge dataset which needs to be fully loaded into memory.
So, is there a way to force Python to use only 2 bytes for some integers (equivalent of C++ 'short')? | Nope. But you can use short integers in arrays:
```
from array import array
a = array("h") # h = signed short, H = unsigned short
```
As long as the value stays in that array it will be a short integer.
* documentation for the [array module](http://docs.python.org/dev/library/array) |
120,262 | <p>Say for instance I was writing a function that was designed to accept multiple argument types:</p>
<pre><code>var overloaded = function (arg) {
if (is_dom_element(arg)) {
// Code for DOM Element argument...
}
};
</code></pre>
<p>What's the best way to implement <strong><code>is_dom_element</code></... | [
{
"answer_id": 120275,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 2,
"selected": false,
"text": "<p>Probably this one here:</p>\n\n<pre><code>node instanceof HTMLElement\n</code></pre>\n\n<p>That should work in m... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10942/"
] | Say for instance I was writing a function that was designed to accept multiple argument types:
```
var overloaded = function (arg) {
if (is_dom_element(arg)) {
// Code for DOM Element argument...
}
};
```
What's the best way to implement **`is_dom_element`** so that it works in a cross-browser, fairl... | jQuery checks the nodeType property. So you would have:
```
var overloaded = function (arg) {
if (arg.nodeType) {
// Code for DOM Element argument...
}
};
```
Although this would detect all DOM objects, not just elements. If you want elements alone, that would be:
```
var overloaded = function (arg)... |
120,266 | <p>In my database, I have a model which has a field which should be selected from one of a list of options. As an example, consider a model which needs to store a measurement, such as 5ft or 13cm or 12.24m3. The obvious way to achieve this is to have a decimal field and then some other field to store the unit of measur... | [
{
"answer_id": 120281,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 2,
"selected": false,
"text": "<p>I would go with option one. How large will it be the UnitOfMeasurement table? And, if using an integer primary key, why do y... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In my database, I have a model which has a field which should be selected from one of a list of options. As an example, consider a model which needs to store a measurement, such as 5ft or 13cm or 12.24m3. The obvious way to achieve this is to have a decimal field and then some other field to store the unit of measureme... | Have you seen [constant\_cache](http://github.com/vigetlabs/constant_cache/tree/master)? It's sort of the combination of the best of 1 and 2 - lookup data is stored in the DB, but it's exposed as class constants on the lookup model and only loaded at application start, so you don't suffer the join penalties constantly.... |
120,334 | <p>I currentyl have no clue on how to sort an array which contains UTF-8 encoded strings in PHP. The array comes from a LDAP server so sorting via a database (would be no problem) is no solution.
The following does not work on my windows development machine (although I'd think that this should be at least a possible s... | [
{
"answer_id": 120361,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 2,
"selected": false,
"text": "<p>This is a very complex <a href=\"http://unicode.org/reports/tr10/\" rel=\"nofollow noreferrer\">issue</a>, since UTF-8 encod... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11354/"
] | I currentyl have no clue on how to sort an array which contains UTF-8 encoded strings in PHP. The array comes from a LDAP server so sorting via a database (would be no problem) is no solution.
The following does not work on my windows development machine (although I'd think that this should be at least a possible solu... | Eventually this problem cannot be solved in a simple way without using recoded strings (UTF-8 → Windows-1252 or ISO-8859-1) as suggested by ΤΖΩΤΖΙΟΥ due to an obvious PHP bug as discovered by Huppie.
To summarize the problem, I created the following code snippet which clearly demonstrates that the problem is the strcol... |
120,420 | <p>I would like to have information about the icons which are displayed alongside the site URLs on a web browser. Is this some browser specific feature? Where do we specify the icon source, ie, is it in some tag on the web page itself ?</p>
| [
{
"answer_id": 120427,
"author": "Chris",
"author_id": 15578,
"author_profile": "https://Stackoverflow.com/users/15578",
"pm_score": -1,
"selected": false,
"text": "<p>It was originally a windows icon format file, stored under the URL <a href=\"http://site/favicon.ico\" rel=\"nofollow no... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11614/"
] | I would like to have information about the icons which are displayed alongside the site URLs on a web browser. Is this some browser specific feature? Where do we specify the icon source, ie, is it in some tag on the web page itself ? | These icons are called [favicons](http://en.wikipedia.org/wiki/Favicon)
Most web browsers support <http://mysite.com/favicon.ico> but the proper way to do it is to include an icon meta tag in the head profile.
```
<head profile="http://www.w3.org/2005/10/profile">
<link rel="icon"
type="image/png"
href=... |
120,422 | <p>How do I iterate over a set of records in RPG(LE) with embedded SQL?</p>
| [
{
"answer_id": 120993,
"author": "Mike Wills",
"author_id": 2535,
"author_profile": "https://Stackoverflow.com/users/2535",
"pm_score": 5,
"selected": true,
"text": "<p>Usually I'll create a cursor and fetch each record.</p>\n\n<pre><code> //********************************************... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I iterate over a set of records in RPG(LE) with embedded SQL? | Usually I'll create a cursor and fetch each record.
```
//***********************************************************************
// Main - Main Processing Routine
begsr Main;
exsr BldSqlStmt;
if OpenSqlCursor() = SQL_SUCCESS;
dow FetchNextRow() = SQL_SUCCESS;
exsr ProcessRow;
... |
120,467 | <p>I would like to confirm that the following analysis is correct:</p>
<p>I am building a web app in RoR. I have a data structure for my postgres db designed (around 70 tables; this design may need changes and additions during development to reflect Rails ways of doing things. EG, I designed some user and role tables ... | [
{
"answer_id": 120491,
"author": "Jean",
"author_id": 7898,
"author_profile": "https://Stackoverflow.com/users/7898",
"pm_score": 2,
"selected": false,
"text": "<p>Proposition 1 is mistaken : you can definitely define referential integrity using migrations if only by using direct SQL ins... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6941/"
] | I would like to confirm that the following analysis is correct:
I am building a web app in RoR. I have a data structure for my postgres db designed (around 70 tables; this design may need changes and additions during development to reflect Rails ways of doing things. EG, I designed some user and role tables - but if i... | Proposition 1 is false in at least two situations - you can use plugins like [foreign\_key\_migrations](http://github.com/vigetlabs/foreign_key_migrations/tree) to do the following:
```
def self.up
create_table :users do |t|
t.column :department_id, :integer, :references => :departments
end
end
```
which cre... |
120,470 | <p>I'm using nhibernate to store some user settings for an app in a SQL Server Compact Edition table.</p>
<p>This is an excerpt the mapping file:</p>
<pre><code><property name="Name" type="string" />
<property name="Value" type="string" />
</code></pre>
<p>Name is a regular string/nvarchar(50), and Value... | [
{
"answer_id": 120560,
"author": "Jimmeh",
"author_id": 20749,
"author_profile": "https://Stackoverflow.com/users/20749",
"pm_score": 0,
"selected": false,
"text": "<pre><code><property name=\"Value\" type=\"string\" />\n <column name=\"Value\" sql-type=\"StringClob\" />\n&l... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21033/"
] | I'm using nhibernate to store some user settings for an app in a SQL Server Compact Edition table.
This is an excerpt the mapping file:
```
<property name="Name" type="string" />
<property name="Value" type="string" />
```
Name is a regular string/nvarchar(50), and Value is set as ntext in the DB
I'm trying to wri... | Okay, with many thanks to Artur in [this thread](http://groups.google.com/group/nhusers/browse_thread/thread/4f865f0f516234ca), here's the solution:
Inherit from the SqlServerCeDriver with a new one, and override the InitializeParamter method:
```
using System.Data;
using System.Data.SqlServerCe;
using NHibernate.Driv... |
120,503 | <p>I'm trying to populate a TDBGrid with the results of the following TQuery against the file Journal.db:</p>
<pre><code>select * from Journal
where Journal.where = "RainPump"
</code></pre>
<p>I've tried both <code>Journal."Where"</code> and <code>Journal.[Where]</code> to no avail.</p>
<p>I've also tried: <code>se... | [
{
"answer_id": 120518,
"author": "Johan Bresler",
"author_id": 3535708,
"author_profile": "https://Stackoverflow.com/users/3535708",
"pm_score": 0,
"selected": false,
"text": "<pre><code>select * from Journal where Journal.\"where\" = \"RainPump\"\n</code></pre>\n"
},
{
"answer_i... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11781/"
] | I'm trying to populate a TDBGrid with the results of the following TQuery against the file Journal.db:
```
select * from Journal
where Journal.where = "RainPump"
```
I've tried both `Journal."Where"` and `Journal.[Where]` to no avail.
I've also tried: `select Journal.[Where] as "Location"` with the same result.
J... | You can insert the resultset into a new table with "values" (specifying no column names) where you have given your own column names in the new table and then do a select from that table, Using a TQuery, something like:
```
Query1.sql.clear;
query1,sql.add('Insert into newtable values (select * from Journal);');
query1... |
120,504 | <p>I'm trying to run the following SQL statement in Oracle, and it takes ages to run:</p>
<pre><code>SELECT orderID FROM tasks WHERE orderID NOT IN
(SELECT DISTINCT orderID FROM tasks WHERE
engineer1 IS NOT NULL AND engineer2 IS NOT NULL)
</code></pre>
<p>If I run just the sub-part that is in the IN clause, that ru... | [
{
"answer_id": 120516,
"author": "Georgi",
"author_id": 13209,
"author_profile": "https://Stackoverflow.com/users/13209",
"pm_score": 2,
"selected": false,
"text": "<p>The \"IN\" - clause is known in Oracle to be pretty slow. In fact, the internal query optimizer in Oracle cannot handle ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7261/"
] | I'm trying to run the following SQL statement in Oracle, and it takes ages to run:
```
SELECT orderID FROM tasks WHERE orderID NOT IN
(SELECT DISTINCT orderID FROM tasks WHERE
engineer1 IS NOT NULL AND engineer2 IS NOT NULL)
```
If I run just the sub-part that is in the IN clause, that runs very quickly in Oracle,... | Often this type of problem goes away if you analyze the tables involved (so Oracle has a better idea of the distribution of the data)
```
ANALYZE TABLE tasks COMPUTE STATISTICS;
``` |
120,540 | <p>I´m programming a .NET Compact Framework application which shows maps on a PDA.</p>
<p>I´ve created an ad hoc component that paints it´s own piece of the whole map, using several of this components the big picture is composed. I did it this way to avoid the latency of painting the whole map in a single step.</p>
<... | [
{
"answer_id": 120553,
"author": "Mendelt",
"author_id": 3320,
"author_profile": "https://Stackoverflow.com/users/3320",
"pm_score": 2,
"selected": false,
"text": "<p>The approach is wrong. Code that updates the ui has to run on the ui thread. You'll get an exception if you update the ui... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/623/"
] | I´m programming a .NET Compact Framework application which shows maps on a PDA.
I´ve created an ad hoc component that paints it´s own piece of the whole map, using several of this components the big picture is composed. I did it this way to avoid the latency of painting the whole map in a single step.
What I would li... | The approach is wrong. Code that updates the ui has to run on the ui thread. You'll get an exception if you update the ui from another thread. |
120,561 | <p>We have a vxWorks design which requires one task to process both high and low priority messages sent over two message queues.<br>
The messages for a given priority have to be processed in FIFO order. </p>
<p>For example, process all the high priority messages in the order they were received, then process the low p... | [
{
"answer_id": 120788,
"author": "Benoit",
"author_id": 10703,
"author_profile": "https://Stackoverflow.com/users/10703",
"pm_score": 1,
"selected": false,
"text": "<p>In vxWorks, you can't wait directly on multiple queues. You can however use the OS events (from eventLib) to achieve th... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] | We have a vxWorks design which requires one task to process both high and low priority messages sent over two message queues.
The messages for a given priority have to be processed in FIFO order.
For example, process all the high priority messages in the order they were received, then process the low priority mess... | If you use named pipes (pipeDevCreate(), write(), read()) instead of message queues, you can use select() to block until there are messages in either pipe.
Whenever select() triggers, you process all messages in the high priority pipe. Then you process a single message from the low priority pipe. Then call select a... |
120,584 | <p>In a <a href="http://www.pygame.org/" rel="nofollow noreferrer">pyGame</a> application, I would like to render resolution-free GUI widgets described in SVG.</p>
<p>How can I achieve this?</p>
<p>(I like the <a href="http://ocemp.sourceforge.net/gui.html" rel="nofollow noreferrer">OCEMP GUI</a> toolkit but it seems t... | [
{
"answer_id": 120794,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 3,
"selected": false,
"text": "<p>You can use <a href=\"http://www.cairographics.org/\" rel=\"noreferrer\">Cairo</a> (with PyCairo), which has suppor... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8450/"
] | In a [pyGame](http://www.pygame.org/) application, I would like to render resolution-free GUI widgets described in SVG.
How can I achieve this?
(I like the [OCEMP GUI](http://ocemp.sourceforge.net/gui.html) toolkit but it seems to be bitmap dependent for its rendering) | This is a complete example which combines hints by other people here.
It should render a file called test.svg from the current directory. It was tested on Ubuntu 10.10, python-cairo 1.8.8, python-pygame 1.9.1, python-rsvg 2.30.0.
```
#!/usr/bin/python
import array
import math
import cairo
import pygame
import rsvg
... |
120,587 | <p>I would like to trash the mail received by a single qmail alias. I don't want any mail delivery errors, and I want qmail to be happy about having delivered the mail.</p>
<p>How can I do this, preferably without adding another local email account?</p>
| [
{
"answer_id": 120771,
"author": "Roman Odaisky",
"author_id": 21055,
"author_profile": "https://Stackoverflow.com/users/21055",
"pm_score": 2,
"selected": false,
"text": "<p>Create an alias by creating a file /var/qmail/aliases/.qmail-<em>blackhole</em> with this content:</p>\n\n<pre><c... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15992/"
] | I would like to trash the mail received by a single qmail alias. I don't want any mail delivery errors, and I want qmail to be happy about having delivered the mail.
How can I do this, preferably without adding another local email account? | Create an alias with only a comment and no delivery instructions, like:
```
echo "# drop all messages on the floor" > ~alias/.qmail-devnull
```
Replace "devnull" with whatever alias name you need of course. |
120,588 | <p>I'm using Hibernate for ORM of my Java app to an Oracle database (not that the database vendor matters, we may switch to another database one day), and I want to retrieve objects from the database according to user-provided strings. For example, when searching for people, if the user is looking for people who live i... | [
{
"answer_id": 120600,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 0,
"selected": false,
"text": "<p>Most default database collations are not case-sensitive, but in the SQL Server world it can be set at the instance, t... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2819/"
] | I'm using Hibernate for ORM of my Java app to an Oracle database (not that the database vendor matters, we may switch to another database one day), and I want to retrieve objects from the database according to user-provided strings. For example, when searching for people, if the user is looking for people who live in '... | For the simple case you describe, look at Restrictions.ilike(), which does a case-insensitive search.
```
Criteria crit = session.createCriteria(Person.class);
crit.add(Restrictions.ilike('town', '%fran%');
List results = crit.list();
``` |
120,607 | <p>I am trying to separate some asp logic out into a separate page.
For now, I am trying to call a simple function. </p>
<p>Here is the simple index page that I am using</p>
<pre><code><html>
<head>
<title>Calling a webservice from classic ASP</title>
</head>
<body>
<%
If Reques... | [
{
"answer_id": 120619,
"author": "Matthias Meid",
"author_id": 17713,
"author_profile": "https://Stackoverflow.com/users/17713",
"pm_score": 1,
"selected": false,
"text": "<p>If I remember correctly, you need no brackets for calls without a return value (untested solution):</p>\n\n<pre><... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11612/"
] | I am trying to separate some asp logic out into a separate page.
For now, I am trying to call a simple function.
Here is the simple index page that I am using
```
<html>
<head>
<title>Calling a webservice from classic ASP</title>
</head>
<body>
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
%>
<!--... | `aspfunctions.asp` should be inside tags so the asp is "executed", e.g.
aspfunctions.asp file:
```
<%
sub doStuff()
Response.Write("In Do Stuff")
end sub
%>
```
Otherwise the asp in `aspfunctions.asp` is just seen as plain-text, so as far as the server is concerned, `doStuff` has never been defined. |
120,618 | <p>What logging solutions exist for j2me? </p>
<p>I'm specifically interested in easily excluding logging for "release" version, to have a smaller package & memory footprint. </p>
| [
{
"answer_id": 120772,
"author": "Scott Bennett-McLeish",
"author_id": 1915,
"author_profile": "https://Stackoverflow.com/users/1915",
"pm_score": 1,
"selected": false,
"text": "<p>I've used <a href=\"http://www.mobilelandscape.uklinux.net/j2medownload/MIDPLogger.php\" rel=\"nofollow nor... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6827/"
] | What logging solutions exist for j2me?
I'm specifically interested in easily excluding logging for "release" version, to have a smaller package & memory footprint. | If you are using preprocessing and obfuscation with Proguard, then you can have a simple logging class.
```
public class Log {
public static void debug(final String message) {
//#if !release.build
System.out.println(message);
//#endif
}
}
```
Or do logging where ever you need to. Now, if release.buil... |
120,627 | <p>I would like to replace the default malloc at link time to use a custom malloc. But when I try to redefine malloc in my program, I get this error:</p>
<pre><code>MSVCRT.lib(MSVCR80.dll) : error LNK2005: _malloc already defined in test.lib(test.obj)
</code></pre>
<p>This works perfectly on any Unix, and it works on... | [
{
"answer_id": 120650,
"author": "dguaraglia",
"author_id": 2384,
"author_profile": "https://Stackoverflow.com/users/2384",
"pm_score": 2,
"selected": false,
"text": "<p>I think it depends in which order you link the files. I think you need to link your custom function first, then the im... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14443/"
] | I would like to replace the default malloc at link time to use a custom malloc. But when I try to redefine malloc in my program, I get this error:
```
MSVCRT.lib(MSVCR80.dll) : error LNK2005: _malloc already defined in test.lib(test.obj)
```
This works perfectly on any Unix, and it works on Windows with most functio... | There is really good discussion of how hard this is here:
<http://benjamin.smedbergs.us/blog/2008-01-10/patching-the-windows-crt/>
~~Apparently, you need to patch the CRT~~
Edit: actually, a MS employee gave the technique in the discussion. You need to move your malloc to a lib, and then link it before the CRT
"he ... |
120,648 | <p>I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in ... | [
{
"answer_id": 120670,
"author": "Jimmeh",
"author_id": 20749,
"author_profile": "https://Stackoverflow.com/users/20749",
"pm_score": 3,
"selected": false,
"text": "<p>I use MbUnit for my Unit Testing. They have an option to Ignore tests, which show up as Orange (rather than Green or Red... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3320/"
] | I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of a todo-list. To make sure I don't forget I put an Assert.Fail() in the... | For this scenario, rather than calling Assert.Fail, I do the following (in C# / NUnit)
```
[Test]
public void MyClassDoesSomething()
{
throw new NotImplementedException();
}
```
It is more explicit than an Assert.Fail.
There seems to be general agreement that it is preferable to use more explicit assertions tha... |
120,656 | <p>How do I get a list of all files (and directories) in a given directory in Python?</p>
| [
{
"answer_id": 120676,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 9,
"selected": false,
"text": "<p>You can use</p>\n\n<pre><code>os.listdir(path)\n</code></pre>\n\n<p>For reference and more os functions look here:</p>\n... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17693/"
] | How do I get a list of all files (and directories) in a given directory in Python? | This is a way to traverse every file and directory in a directory tree:
```
import os
for dirname, dirnames, filenames in os.walk('.'):
# print path to all subdirectories first.
for subdirname in dirnames:
print(os.path.join(dirname, subdirname))
# print path to all filenames.
for filename in... |
120,657 | <p>I'm currently having a major issue with a python script. The script runs arbitrary commands through a handler to convert incorrect error reporting into correct error reporting.</p>
<p>The issue I'm having is getting the script to work correctly on windows with a command that contains ampersands in it's path. I've a... | [
{
"answer_id": 120705,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 1,
"selected": false,
"text": "<p>A proper answer will need more information than that. What are you actually doing? How does it fail? Are you usi... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16035/"
] | I'm currently having a major issue with a python script. The script runs arbitrary commands through a handler to convert incorrect error reporting into correct error reporting.
The issue I'm having is getting the script to work correctly on windows with a command that contains ampersands in it's path. I've attempted q... | Make sure you are using lists and no shell expansion:
```
subprocess.Popen(['command', 'argument1', 'argument2'], shell=False)
``` |
120,662 | <p>I'm trying to run SQuirreL SQL.<br>
I've downloaded it and installed it, but when I try to run it I get this error message: </p>
<blockquote>
<p>Java Virtual Machine Launcher.<br>
Could not find the main class.<br>
Program will exit. </p>
</blockquote>
<p>I get the gist of this, but I have not idea how to f... | [
{
"answer_id": 120698,
"author": "tim_yates",
"author_id": 6509,
"author_profile": "https://Stackoverflow.com/users/6509",
"pm_score": 2,
"selected": false,
"text": "<p>Have you followed these instructions:</p>\n\n<p><a href=\"http://www.squirrelsql.org/#installation\" rel=\"nofollow nor... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7211/"
] | I'm trying to run SQuirreL SQL.
I've downloaded it and installed it, but when I try to run it I get this error message:
>
> Java Virtual Machine Launcher.
>
> Could not find the main class.
>
> Program will exit.
>
>
>
I get the gist of this, but I have not idea how to fix it. Any help?
### more in... | Is Java installed on your computer? Is the path to its bin directory set properly (in other words if you type 'java' from the command line do you get back a list of instructions or do you get something like "java is not recognized as a .....")?
You could try try running `squirrel-sql.jar` from the command line (from t... |
120,693 | <p>I've got a function that runs a user generated Regex. However, if the user enters a regex that won't run then it stops and falls over. I've tried wrapping the line in a Try/Catch block but alas nothing happens.</p>
<p>If it helps, I'm running jQuery but the code below does not have it as I'm guessing that it's a li... | [
{
"answer_id": 120716,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 3,
"selected": false,
"text": "<p>The problem is with this line:</p>\n\n<pre><code>var grep = new RegExp('gr[');\n</code></pre>\n\n<p>'[' is a special cha... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | I've got a function that runs a user generated Regex. However, if the user enters a regex that won't run then it stops and falls over. I've tried wrapping the line in a Try/Catch block but alas nothing happens.
If it helps, I'm running jQuery but the code below does not have it as I'm guessing that it's a little more ... | Try this the new RegExp is throwing the exception
Regex
```
<script type="text/javascript" charset="utf-8">
var grep;
try {
grep = new RegExp("gr[");
}
catch(e) {
alert(e);
}
try
{
... |
120,702 | <p>Using Scala's command line REPL:</p>
<pre><code>def foo(x: Int): Unit = {}
def foo(x: String): Unit = {println(foo(2))}
</code></pre>
<p>gives</p>
<pre><code>error: type mismatch;
found: Int(2)
required: String
</code></pre>
<p>It seems that you can't define overloaded recursive methods in the REPL. I thought th... | [
{
"answer_id": 121647,
"author": "user21167",
"author_id": 21167,
"author_profile": "https://Stackoverflow.com/users/21167",
"pm_score": 2,
"selected": false,
"text": "<p>REPL will accept if you copy both lines and paste both at same time.</p>\n"
},
{
"answer_id": 122338,
"au... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15627/"
] | Using Scala's command line REPL:
```
def foo(x: Int): Unit = {}
def foo(x: String): Unit = {println(foo(2))}
```
gives
```
error: type mismatch;
found: Int(2)
required: String
```
It seems that you can't define overloaded recursive methods in the REPL. I thought this was a bug in the Scala REPL and filed it, but ... | The issue is due to the fact that the interpreter most often has to *replace* existing elements with a given name, rather than overload them. For example, I will often be running through experimenting with something, often creating a method called `test`:
```
def test(x: Int) = x + x
```
A little later on, let's say... |
120,731 | <p>Let's assume you have one massive table with three columns as shown below:</p>
<pre><code>[id] INT NOT NULL,
[date] SMALLDATETIME NOT NULL,
[sales] FLOAT NULL
</code></pre>
<p>Also assume you are limited to one physical disk and one filegroup (PRIMARY). You expect this table to hold sales for 10,000,000+ ids, a... | [
{
"answer_id": 120815,
"author": "Biri",
"author_id": 968,
"author_profile": "https://Stackoverflow.com/users/968",
"pm_score": 0,
"selected": false,
"text": "<p>If you are using the partitions in the select statements, then you cn gain some speed.</p>\n\n<p>If you are not using it, only... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4391/"
] | Let's assume you have one massive table with three columns as shown below:
```
[id] INT NOT NULL,
[date] SMALLDATETIME NOT NULL,
[sales] FLOAT NULL
```
Also assume you are limited to one physical disk and one filegroup (PRIMARY). You expect this table to hold sales for 10,000,000+ ids, across 100's of dates (easil... | This table is awesomely narrow. If the real table will be this narrow, you should be happy to have table scans instead of index->lookups.
I would do this:
```
CREATE TABLE Narrow
(
[id] INT NOT NULL,
[date] SMALLDATETIME NOT NULL,
[sales] FLOAT NULL,
PRIMARY KEY(id, date) --EDIT, just noticed your id is not ... |
120,751 | <p>I have been trying to use routes.rb for creating a URL /similar-to-:product (where product is dynamic) for my website. The issue is that routes.rb readily supports URLs like /:product-similar but doesn't support the former because it requires :product to be preceded with a separator ('/' is a separator but '-' isn't... | [
{
"answer_id": 120819,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 0,
"selected": false,
"text": "<p>I'm a little confused, but could you maybe add \"to-\" as a seperator? </p>\n"
},
{
"answer_id": 1224... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17494/"
] | I have been trying to use routes.rb for creating a URL /similar-to-:product (where product is dynamic) for my website. The issue is that routes.rb readily supports URLs like /:product-similar but doesn't support the former because it requires :product to be preceded with a separator ('/' is a separator but '-' isn't). ... | In fact you can add `-` as a separator, then use route globbing.
```
map.similar_product '/similar-to-*product', :controller => 'products', :action => 'similar'
```
then, in ProductsController#similar
```
@product = Product.find_by_slug params[:product].join('-')
```
Though refactoring does seem nicer, since with... |
120,763 | <p>I have a helper class pulling a string from an XML file. That string is a file path (so it has backslashes in it). I need to use that string as it is... How can I use it like I would with the literal command?</p>
<p>Instead of this:</p>
<pre><code>string filePath = @"C:\somepath\file.txt";
</code></pre>
<p>I want... | [
{
"answer_id": 120776,
"author": "brock.holum",
"author_id": 15860,
"author_profile": "https://Stackoverflow.com/users/15860",
"pm_score": 5,
"selected": true,
"text": "<p>I don't think you have to worry about it if you already have the value. The @ operator is for when you're specifying... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14777/"
] | I have a helper class pulling a string from an XML file. That string is a file path (so it has backslashes in it). I need to use that string as it is... How can I use it like I would with the literal command?
Instead of this:
```
string filePath = @"C:\somepath\file.txt";
```
I want to do this:
```
string filePath... | I don't think you have to worry about it if you already have the value. The @ operator is for when you're specifying the string (like in your first code snippet).
What are you attempting to do with the path string that isn't working? |
120,766 | <p>I have several <li> elements with different id's on ASP.NET page:</p>
<pre><code><li id="li1" class="class1">
<li id="li2" class="class1">
<li id="li3" class="class1">
</code></pre>
<p>and can change their class using JavaScript like this:</p>
<pre><code>li1.className="class2"
</code></pre>
... | [
{
"answer_id": 120774,
"author": "stefano m",
"author_id": 19261,
"author_profile": "https://Stackoverflow.com/users/19261",
"pm_score": 2,
"selected": false,
"text": "<p>you must set runat=\"server\" like:</p>\n\n<pre><code><li id=\"li1\" runat=\"server\">stuff</li>\n</code>... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] | I have several <li> elements with different id's on ASP.NET page:
```
<li id="li1" class="class1">
<li id="li2" class="class1">
<li id="li3" class="class1">
```
and can change their class using JavaScript like this:
```
li1.className="class2"
```
But is there a way to change <li> element class using ASP.NET? It c... | The FindControl method searches for server controls. That is, it looks for controls with the attribute "runat" set to "server", as in:
```
<li runat="server ... ></li>
```
Because your <li> tags are not server controls, FindControl cannot find them. You can add the "runat" attribute to these controls or use ClientSc... |
120,783 | <p>Currently I have this (edited after reading advice):</p>
<pre><code>struct Pair<T, K> : IEqualityComparer<Pair<T, K>>
{
readonly private T _first;
readonly private K _second;
public Pair(T first, K second)
{
_first = first;
_second = second;
}
public T Fi... | [
{
"answer_id": 120812,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 2,
"selected": false,
"text": "<p>Your IEqualityComparer implementation should be a different class (and definately not a struct as you want to reuse the ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | Currently I have this (edited after reading advice):
```
struct Pair<T, K> : IEqualityComparer<Pair<T, K>>
{
readonly private T _first;
readonly private K _second;
public Pair(T first, K second)
{
_first = first;
_second = second;
}
public T First { get { return _first; } }
... | It looks like you need IEquatable instead:
```
internal struct Pair<T, K> : IEquatable<Pair<T, K>>
{
private readonly T _first;
private readonly K _second;
public Pair(T first, K second)
{
_first = first;
_second = second;
}
public T First
{
get { return _first; }
}
public K Second
{... |
120,797 | <p>Many times, a Java app needs to connect to the Internet. The most common example happens when it is reading an XML file and needs to download its schema.</p>
<p>I am behind a proxy server. How can I set my JVM to use the proxy ?</p>
| [
{
"answer_id": 120802,
"author": "Leonel",
"author_id": 15649,
"author_profile": "https://Stackoverflow.com/users/15649",
"pm_score": 10,
"selected": true,
"text": "<p>From the Java documentation (<em>not</em> the javadoc API):</p>\n<p><a href=\"http://download.oracle.com/javase/6/docs/t... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15649/"
] | Many times, a Java app needs to connect to the Internet. The most common example happens when it is reading an XML file and needs to download its schema.
I am behind a proxy server. How can I set my JVM to use the proxy ? | From the Java documentation (*not* the javadoc API):
<http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html>
Set the JVM flags `http.proxyHost` and `http.proxyPort` when starting your JVM on the command line.
This is usually done in a shell script (in Unix) or bat file (in Windows). Here's the ex... |
120,804 | <p>I am going through John Resig's excellent <a href="http://ejohn.org/apps/learn/#47" rel="noreferrer">Advanced javascript tutorial</a> and I do not thoroughly understand what's the difference between the following calls: (please note that 'arguments' is a builtin javascript word and is not exactly an array hence the ... | [
{
"answer_id": 121054,
"author": "ujh",
"author_id": 4936,
"author_profile": "https://Stackoverflow.com/users/4936",
"pm_score": 3,
"selected": false,
"text": "<p>Array is just a function, albeit a special one (used to initialize arrays). Array.slice is a reference to the slice() functio... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21075/"
] | I am going through John Resig's excellent [Advanced javascript tutorial](http://ejohn.org/apps/learn/#47) and I do not thoroughly understand what's the difference between the following calls: (please note that 'arguments' is a builtin javascript word and is not exactly an array hence the hacking with the Array.slice in... | Not quite.
Watch what happens when you call String.substring.call("foo", 1) and String().substring.call("foo", 2):
```
>>> String.substring.call("foo", 1)
"1"
>>> String().substring.call("foo", 1)
"oo"
```
Array.slice is *neither* properly referencing the slice function attached to the Array prototype nor the slic... |
120,851 | <p>We are creating an XBAP application that we need to have rounded corners in various locations in a single page and we would like to have a WPF Rounded Corner container to place a bunch of other elements within. Does anyone have some suggestions or sample code on how we can best accomplish this? Either with styles... | [
{
"answer_id": 120895,
"author": "kobusb",
"author_id": 1620,
"author_profile": "https://Stackoverflow.com/users/1620",
"pm_score": 9,
"selected": true,
"text": "<p>You don't need a custom control, just put your container in a border element:</p>\n\n<pre><code><Border BorderBrush=\"#F... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21096/"
] | We are creating an XBAP application that we need to have rounded corners in various locations in a single page and we would like to have a WPF Rounded Corner container to place a bunch of other elements within. Does anyone have some suggestions or sample code on how we can best accomplish this? Either with styles on a ... | You don't need a custom control, just put your container in a border element:
```
<Border BorderBrush="#FF000000" BorderThickness="1" CornerRadius="8">
<Grid/>
</Border>
```
You can replace the `<Grid/>` with any of the layout containers... |
120,858 | <p>Is it possible to, for instance, replace and free a TEdit with a subclassed component instantiated (conditionally) at runtime? If so, how and when it should be done? I've tried to set the parent to nil and to call free() in the form constructor and AfterConstruction methods but in both cases I got a runtime error.</... | [
{
"answer_id": 121091,
"author": "Loesje",
"author_id": 17559,
"author_profile": "https://Stackoverflow.com/users/17559",
"pm_score": 3,
"selected": false,
"text": "<p>You have to call RemoveControl of the TEdit's parent to remove the control. Use InsertControl to add the new control. </... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16120/"
] | Is it possible to, for instance, replace and free a TEdit with a subclassed component instantiated (conditionally) at runtime? If so, how and when it should be done? I've tried to set the parent to nil and to call free() in the form constructor and AfterConstruction methods but in both cases I got a runtime error.
---... | This more generic routine works either with a Form or Frame (updated to use a subclass for the new control):
```
function ReplaceControlEx(AControl: TControl; const AControlClass: TControlClass; const ANewName: string; const IsFreed : Boolean = True): TControl;
begin
if AControl = nil then
begin
Result := nil;... |
120,876 | <p>What are the C++ rules for calling the base class constructor from a derived class?</p>
<p>For example, I know in Java, you must do it as the first line of the subclass constructor (and if you don't, an implicit call to a no-arg super constructor is assumed - giving you a compile error if that's missing).</p>
| [
{
"answer_id": 120916,
"author": "luke",
"author_id": 16434,
"author_profile": "https://Stackoverflow.com/users/16434",
"pm_score": 11,
"selected": true,
"text": "<p>Base class constructors are automatically called for you if they have no argument. If you want to call a superclass const... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4465/"
] | What are the C++ rules for calling the base class constructor from a derived class?
For example, I know in Java, you must do it as the first line of the subclass constructor (and if you don't, an implicit call to a no-arg super constructor is assumed - giving you a compile error if that's missing). | Base class constructors are automatically called for you if they have no argument. If you want to call a superclass constructor with an argument, you must use the subclass's constructor initialization list. Unlike Java, C++ supports multiple inheritance (for better or worse), so the base class must be referred to by na... |
120,886 | <p>Suppose we have an iterator (an infinite one) that returns lists (or finite iterators), for example one returned by</p>
<pre><code>infinite = itertools.cycle([[1,2,3]])
</code></pre>
<p>What is a good Python idiom to get an iterator (obviously infinite) that will return each of the elements from the first iterator, ... | [
{
"answer_id": 120905,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 4,
"selected": false,
"text": "<p>Use a generator:</p>\n\n<pre><code>(item for it in infinite for item in it)\n</code></pre>\n\n<p>The * construct... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12166/"
] | Suppose we have an iterator (an infinite one) that returns lists (or finite iterators), for example one returned by
```
infinite = itertools.cycle([[1,2,3]])
```
What is a good Python idiom to get an iterator (obviously infinite) that will return each of the elements from the first iterator, then each from the secon... | Starting with Python 2.6, you can use [`itertools.chain.from_iterable`](https://docs.python.org/library/itertools.html#itertools.chain.from_iterable):
```
itertools.chain.from_iterable(iterables)
```
You can also do this with a nested generator comprehension:
```
def flatten(iterables):
return (elem for iterabl... |
120,900 | <p>I'm working on databases that have moving tables auto-generated by some obscure tools. By the way, we have to track information changes in the table via some triggers. And, of course, it occurs that some changes in the table structure broke some triggers, by removing a column or changing its type, for example.</p>
... | [
{
"answer_id": 120911,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 5,
"selected": true,
"text": "<pre><code>SELECT *\nFROM ALL_OBJECTS\nWHERE OBJECT_NAME = trigger_name\nAND OBJECT_TYPE = 'TRIGGER'\nAND STATUS... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9396/"
] | I'm working on databases that have moving tables auto-generated by some obscure tools. By the way, we have to track information changes in the table via some triggers. And, of course, it occurs that some changes in the table structure broke some triggers, by removing a column or changing its type, for example.
So, the... | ```
SELECT *
FROM ALL_OBJECTS
WHERE OBJECT_NAME = trigger_name
AND OBJECT_TYPE = 'TRIGGER'
AND STATUS <> 'VALID'
``` |
120,917 | <p>How to create a database using T SQL script on a specified location? Let's say, I want to create a SQL server database on <code>D:\temp\dbFolder</code>. How to do this?</p>
| [
{
"answer_id": 120940,
"author": "Leah",
"author_id": 5506,
"author_profile": "https://Stackoverflow.com/users/5506",
"pm_score": 6,
"selected": true,
"text": "<p>When you create the new database you specify the location. For example:</p>\n\n<pre><code>USE [master]\nGO\n\n CREATE DATA... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | How to create a database using T SQL script on a specified location? Let's say, I want to create a SQL server database on `D:\temp\dbFolder`. How to do this? | When you create the new database you specify the location. For example:
```
USE [master]
GO
CREATE DATABASE [AdventureWorks] ON PRIMARY
( NAME = N'AdventureWorks_Data', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf' , SIZE = 167872KB , MAXSIZE = UNLIMITED, FIL... |
120,928 | <p>I have a web part that I've developed, and if I manually install the web part it is fine.</p>
<p>However when I have packaged the web part following the instructions on this web site as a guide:
<a href="http://www.theartofsharepoint.com/2007/05/how-to-build-solution-pack-wsp.html" rel="noreferrer">http://www.thear... | [
{
"answer_id": 121305,
"author": "Keith Sirmons",
"author_id": 1048,
"author_profile": "https://Stackoverflow.com/users/1048",
"pm_score": 0,
"selected": false,
"text": "<p>Have you recycled your worker process or reset IIS?</p>\n"
},
{
"answer_id": 121883,
"author": "Communi... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a web part that I've developed, and if I manually install the web part it is fine.
However when I have packaged the web part following the instructions on this web site as a guide:
<http://www.theartofsharepoint.com/2007/05/how-to-build-solution-pack-wsp.html>
I get this error in the log files:
```
09/23/2008... | Figured it out.
The error message is the one from the .webpart file:
```
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<!--
The following Guid is used as a reference to the web part class,
and it will be automatically re... |
120,936 | <p>I can add custom version strings to a C++ DLL in Visual Studio by editing the .rc file by hand. For example, if I add to the VersionInfo section of the .rc file</p>
<pre><code>VALUE "BuildDate", "2008/09/19 15:42:52"
</code></pre>
<p>Then that date is visible in the file explorer, in the DLL's properties, under t... | [
{
"answer_id": 120958,
"author": "Khoth",
"author_id": 20686,
"author_profile": "https://Stackoverflow.com/users/20686",
"pm_score": 2,
"selected": false,
"text": "<p>In AssemblyInfo.cs, you can put:</p>\n\n<pre><code>[assembly: System.Reflection.AssemblyInformationalVersion(\"whatever y... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] | I can add custom version strings to a C++ DLL in Visual Studio by editing the .rc file by hand. For example, if I add to the VersionInfo section of the .rc file
```
VALUE "BuildDate", "2008/09/19 15:42:52"
```
Then that date is visible in the file explorer, in the DLL's properties, under the Version tab.
Can I do t... | Expanding on the Khoth's answer, In AssemblyInfo.cs:
You can do:
```
[assembly: CustomResource("Build Date", "12/12/2012")]
```
Where CustomResource is defined as:
```
[AttributeUsage(AttributeTargets.Assembly)]
public class CustomResourceAttribute : Attribute
{
private string the_variable;
public ... |
120,951 | <p>I'd like to know do I normalize a URL in python. </p>
<p>For example, If I have a url string like : "<a href="http://www.example.com/foo" rel="noreferrer">http://www.example.com/foo</a> goo/bar.html"</p>
<p>I need a library in python that will transform the extra space (or any other non normalized character) to a ... | [
{
"answer_id": 120959,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 3,
"selected": false,
"text": "<h3>Py3</h3>\n\n<pre><code>from urllib.parse import urlparse, urlunparse, quote\ndef myquote(url):\n parts = urlparse(url)\n... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] | I'd like to know do I normalize a URL in python.
For example, If I have a url string like : "<http://www.example.com/foo> goo/bar.html"
I need a library in python that will transform the extra space (or any other non normalized character) to a proper URL. | Have a look at this module: [werkzeug.utils](https://github.com/pallets/werkzeug/blob/master/src/werkzeug/urls.py). (now in `werkzeug.urls`)
The function you are looking for is called "url\_fix" and works like this:
```
>>> from werkzeug.urls import url_fix
>>> url_fix(u'http://de.wikipedia.org/wiki/Elf (Begriffsklär... |
120,952 | <p>I have an SP that takes 10 seconds to run about 10 times (about a second every time it is ran). The platform is asp .net, and the server is SQL Server 2005. I have indexed the table (not on the PK also), and that is not the issue. Some caveats:</p>
<ul>
<li>usp_SaveKeyword is not the issue. I commented out that en... | [
{
"answer_id": 120973,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 1,
"selected": false,
"text": "<p>Triggers!</p>\n\n<p>They are insidious indeed.</p>\n"
},
{
"answer_id": 121009,
"author": "stephbu",
"autho... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7952/"
] | I have an SP that takes 10 seconds to run about 10 times (about a second every time it is ran). The platform is asp .net, and the server is SQL Server 2005. I have indexed the table (not on the PK also), and that is not the issue. Some caveats:
* usp\_SaveKeyword is not the issue. I commented out that entire SP and it... | Why are you using `top 1 @SearchID` instead of `max (SearchID)` or `where exists` in this query? `top` requires you to run the query and retrieve the first row from the result set. If the result set is large this could consume quite a lot of resources before you get out the final result set.
```
SELECT TOP 1 @SearchID... |
120,966 | <p>I was writing a (seemingly) straight-forward SQL snippet that drops a column after it makes sure the column exists.<br>
The problem: if the column does NOT exist, the code <em>inside</em> the IF clause complains that it can't find the column! Well, <em>doh</em>, that's why it's inside the IF clause!<br>
So my questi... | [
{
"answer_id": 120974,
"author": "Rob",
"author_id": 7872,
"author_profile": "https://Stackoverflow.com/users/7872",
"pm_score": 0,
"selected": false,
"text": "<p>It may never be executed, but it's parsed for validity by Sql Server. The only way to \"get around\" this is to construct a b... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11545/"
] | I was writing a (seemingly) straight-forward SQL snippet that drops a column after it makes sure the column exists.
The problem: if the column does NOT exist, the code *inside* the IF clause complains that it can't find the column! Well, *doh*, that's why it's inside the IF clause!
So my question is, why does a p... | ```
IF exists (select * from syscolumns
WHERE id=object_id('Table_MD') and name='timeout')
BEGIN
DECLARE @SQL nvarchar(1000)
SET @SQL = N'ALTER TABLE [dbo].[Table_MD] DROP COLUMN timeout'
EXEC sp_executesql @SQL
END
GO
```
Reason:
When Sql server compiles the code, they check it for used objects ( if ... |
120,997 | <p>I'm just getting started with Custom User Controls in C# and I'm wondering if there are any examples out there of how to write one which accepts nested tags?</p>
<p>For example, when you create an <code>asp:repeater</code> you can add a nested tag for <code>itemtemplate</code>.</p>
| [
{
"answer_id": 121007,
"author": "Rob",
"author_id": 7872,
"author_profile": "https://Stackoverflow.com/users/7872",
"pm_score": 5,
"selected": true,
"text": "<p>I wrote a <a href=\"https://robertwray.co.uk/blog/describing-asp-net-control-properties-declaratively\" rel=\"nofollow norefer... | 2008/09/23 | [
"https://Stackoverflow.com/questions/120997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11508/"
] | I'm just getting started with Custom User Controls in C# and I'm wondering if there are any examples out there of how to write one which accepts nested tags?
For example, when you create an `asp:repeater` you can add a nested tag for `itemtemplate`. | I wrote a [blog post](https://robertwray.co.uk/blog/describing-asp-net-control-properties-declaratively) about this some time ago. In brief, if you had a control with the following markup:
```
<Abc:CustomControlUno runat="server" ID="Control1">
<Children>
<Abc:Control1Child IntegerProperty="1" />
</Chi... |
121,000 | <p>I'm trying to create an Extension Method for MVC's htmlHelper.
The purpose is to enable or disable an ActionLink based on the AuthorizeAttribute set on the controller/action.
Borrowing from the <a href="http://blog.maartenballiauw.be/post/2008/08/29/Building-an-ASPNET-MVC-sitemap-provider-with-security-trimming.aspx... | [
{
"answer_id": 121353,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 0,
"selected": false,
"text": "<p>Your ViewPage has a reference to the view context, so you could make it an extension method on that instead.</p>\n\... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3396/"
] | I'm trying to create an Extension Method for MVC's htmlHelper.
The purpose is to enable or disable an ActionLink based on the AuthorizeAttribute set on the controller/action.
Borrowing from the [MVCSitemap](http://blog.maartenballiauw.be/post/2008/08/29/Building-an-ASPNET-MVC-sitemap-provider-with-security-trimming.asp... | Here is the working code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Principal;
using System.Web.Routing;
using System.Web.Mvc;
using System.Collections;
using System.Reflection;
namespace System.Web.Mvc.Html
{
public static class HtmlHelperExtens... |
121,025 | <p>How do I get the modified date/time of a file in Python?</p>
| [
{
"answer_id": 121030,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 6,
"selected": true,
"text": "<pre><code>os.path.getmtime(filepath)\n</code></pre>\n\n<p>or</p>\n\n<pre><code>os.stat(filepath).st_mtime\n</code><... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17693/"
] | How do I get the modified date/time of a file in Python? | ```
os.path.getmtime(filepath)
```
or
```
os.stat(filepath).st_mtime
``` |
121,059 | <p>What is the best way to divide a 32 bit integer into four (unsigned) chars in C#.</p>
| [
{
"answer_id": 121089,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 2,
"selected": false,
"text": "<p>It's not clear if this is really what you want, but:</p>\n\n<pre><code>int x = yourNumber();\nchar a = (char)(x &... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14759/"
] | What is the best way to divide a 32 bit integer into four (unsigned) chars in C#. | Quick'n'dirty:
```csharp
int value = 0x48454C4F;
Console.WriteLine(Encoding.ASCII.GetString(
BitConverter.GetBytes(value).Reverse().ToArray()
));
```
Converting the int to bytes, reversing the byte-array for the correct order and then getting the ASCII character representation from it.
EDIT: The `Reverse` method ... |
121,063 | <p>I've recently acquired a second monitor and now run VS2008 SP1 maximized on my secondary (and bigger) monitor. This theoretically has the benefit of opening the application under development on the primary monitor, where -- as it seems to me -- all newly started applications go. So far, so good. The problem though i... | [
{
"answer_id": 121089,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 2,
"selected": false,
"text": "<p>It's not clear if this is really what you want, but:</p>\n\n<pre><code>int x = yourNumber();\nchar a = (char)(x &... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] | I've recently acquired a second monitor and now run VS2008 SP1 maximized on my secondary (and bigger) monitor. This theoretically has the benefit of opening the application under development on the primary monitor, where -- as it seems to me -- all newly started applications go. So far, so good. The problem though is n... | Quick'n'dirty:
```csharp
int value = 0x48454C4F;
Console.WriteLine(Encoding.ASCII.GetString(
BitConverter.GetBytes(value).Reverse().ToArray()
));
```
Converting the int to bytes, reversing the byte-array for the correct order and then getting the ASCII character representation from it.
EDIT: The `Reverse` method ... |
121,066 | <p>I want to attach a click event to a button element and then later remove it, but I can't get <code>unclick()</code> or <code>unbind()</code> event(s) to work as expected. In the code below, the button is <code>tan</code> colour and the click event works.</p>
<pre><code>window.onload = init;
function init() {
... | [
{
"answer_id": 121084,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 2,
"selected": false,
"text": "<p>unbind is your friend.</p>\n\n<pre><code>$(\"#startButton\").unbind('click')\n</code></pre>\n"
},
{
"answer_id"... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | I want to attach a click event to a button element and then later remove it, but I can't get `unclick()` or `unbind()` event(s) to work as expected. In the code below, the button is `tan` colour and the click event works.
```
window.onload = init;
function init() {
$("#startButton").css('background-color', 'beige... | There's no such thing as `unclick()`. Where did you get that from?
You can remove individual event handlers from an element by calling unbind:
```
$("#startButton").unbind("click", process_click);
```
If you want to remove all handlers, or you used an anonymous function as a handler, you can omit the second argumen... |
121,116 | <p>I have a managed DLL (written in C++/CLI) that contains a class used by a C# executable. In the constructor of the class, I need to get access to the full path of the executable referencing the DLL. In the actual app I know I can use the Application object to do this, but how can I do it from a managed DLL?</p>
| [
{
"answer_id": 121137,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 5,
"selected": true,
"text": "<pre><code>Assembly.GetCallingAssembly()\n</code></pre>\n\n<p>or</p>\n\n<pre><code>Assembly.GetExecutingAssembly()\n</code><... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3114/"
] | I have a managed DLL (written in C++/CLI) that contains a class used by a C# executable. In the constructor of the class, I need to get access to the full path of the executable referencing the DLL. In the actual app I know I can use the Application object to do this, but how can I do it from a managed DLL? | ```
Assembly.GetCallingAssembly()
```
or
```
Assembly.GetExecutingAssembly()
```
or
```
Assembly.GetEntryAssembly()
```
Depending on your need.
Then use Location or CodeBase property (I never remember which one). |
121,117 | <p>Are there any good webservices out there that provide good lookup information for Countries and States/Provinces?</p>
<p>If so what ones do you use?</p>
| [
{
"answer_id": 121160,
"author": "Owen",
"author_id": 2109,
"author_profile": "https://Stackoverflow.com/users/2109",
"pm_score": 4,
"selected": true,
"text": "<p>If you only need US information, the US Postal Service provides a set of web services it calls WebTools for this exact thing.... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8897/"
] | Are there any good webservices out there that provide good lookup information for Countries and States/Provinces?
If so what ones do you use? | If you only need US information, the US Postal Service provides a set of web services it calls WebTools for this exact thing. <https://www.usps.com/business/web-tools-apis/welcome.htm>. You will need to register to be able to use them but once you're registered they are really simple to use. You just send an XML reques... |
121,147 | <p>I'd like to be able to determine if a directory such as a '.app' is considered to be a package or bundle from Finder's point of view on the command line. I don't think this would be difficult to do with a small shell program, but I'd rather not re-invent the wheel if I don't have to.</p>
| [
{
"answer_id": 121181,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": -1,
"selected": false,
"text": "<p>A bundle should always have a file `./contents/Info.plist'. You can check for the existance of this in a directory, ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4468/"
] | I'd like to be able to determine if a directory such as a '.app' is considered to be a package or bundle from Finder's point of view on the command line. I don't think this would be difficult to do with a small shell program, but I'd rather not re-invent the wheel if I don't have to. | Update:
-------
On all systems with Spotlight, using `mdls` you can detect bundles looking at the kMDItemContentTypeTree property. E.g.:
```
mdls -name kMDItemContentTypeTree "/Applications/Safari.app"
```
produces the following output for me
```
kMDItemContentTypeTree = (
"com.apple.application-bundle",
"... |
121,162 | <p>What does the <code>explicit</code> keyword mean in C++?</p>
| [
{
"answer_id": 121163,
"author": "Skizz",
"author_id": 1898,
"author_profile": "https://Stackoverflow.com/users/1898",
"pm_score": 13,
"selected": true,
"text": "<p>The compiler is allowed to make one implicit conversion to resolve the parameters to a function. What this means is that th... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1898/"
] | What does the `explicit` keyword mean in C++? | The compiler is allowed to make one implicit conversion to resolve the parameters to a function. What this means is that the compiler can use constructors callable with a **single parameter** to convert from one type to another in order to get the right type for a parameter.
Here's an example class with a constructor ... |
121,167 | <p>What are some of the lesser-known but useful features and techniques that people are using in their Greasemonkey scripts?</p>
<p>(Please, just one feature per answer.)</p>
<p>Similar threads:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/61088/hidden-features-of-javascript">Hidden Features of JavaScri... | [
{
"answer_id": 121197,
"author": "Chris Noe",
"author_id": 14749,
"author_profile": "https://Stackoverflow.com/users/14749",
"pm_score": 3,
"selected": false,
"text": "<p>Data can be persisted across page loads by storing it as a mozilla preference value via <code>GM_setValue(keyname, va... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14749/"
] | What are some of the lesser-known but useful features and techniques that people are using in their Greasemonkey scripts?
(Please, just one feature per answer.)
Similar threads:
* [Hidden Features of JavaScript](https://stackoverflow.com/questions/61088/hidden-features-of-javascript)
* [Hidden Features of Java](http... | Greasemonkey scripts often need to search for content on a page. Instead of digging through the DOM, try using XPath to locate nodes of interest. The `document.evaluate()` method lets you provide an XPath expression and will return a collection of matching nodes. Here's a nice [tutorial](http://www-xray.ast.cam.ac.uk/~... |
121,199 | <p>How is it possible in Eclipse JDT to convert a multiline selection to String. Like the following</p>
<p>From:</p>
<pre><code>xxxx
yyyy
zzz
</code></pre>
<p>To:</p>
<pre><code>"xxxx " +
"yyyy " +
"zzz"
</code></pre>
<p>I tried the following template </p>
<pre><code>"${line_selection}${cursor}"+
</code></pre>
<... | [
{
"answer_id": 121420,
"author": "Diomidis Spinellis",
"author_id": 20520,
"author_profile": "https://Stackoverflow.com/users/20520",
"pm_score": 2,
"selected": false,
"text": "<p>This may not be exactly the answer you're looking for. You can easily achieve what you're asking by using t... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How is it possible in Eclipse JDT to convert a multiline selection to String. Like the following
From:
```
xxxx
yyyy
zzz
```
To:
```
"xxxx " +
"yyyy " +
"zzz"
```
I tried the following template
```
"${line_selection}${cursor}"+
```
but that way I only get the whole block surrounded not each line separately. ... | Maybe this is not what you mean but...
If I'm on a line in Eclipse and I enter double quotation marks, then inside that paste a multiline selection (like your xyz example) it will paste out like this:
```
"xxxx\n" +
"yyyy\n" +
"zzz"
```
Then you could just find/replace in a selection for `"\n"` to `""`, if you... |
121,202 | <p>I work with quite a bit of multi-platform C/C++ code, separated by common #defines (#if WIN, #if UNIX, etc). It would be nice if I could have vim automatically fold the sections I'm currently not interested in when I open a file. I've searched through the vim script archives, but I haven't found anything useful. ... | [
{
"answer_id": 121278,
"author": "hometoast",
"author_id": 2009,
"author_profile": "https://Stackoverflow.com/users/2009",
"pm_score": 3,
"selected": false,
"text": "<p>Just add a folding region to your syntax\n<a href=\"http://vim.wikia.com/wiki/Syntax_folding_of_Vim_scripts#Syntax_defi... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21138/"
] | I work with quite a bit of multi-platform C/C++ code, separated by common #defines (#if WIN, #if UNIX, etc). It would be nice if I could have vim automatically fold the sections I'm currently not interested in when I open a file. I've searched through the vim script archives, but I haven't found anything useful. Any su... | Just add a folding region to your syntax
<http://vim.wikia.com/wiki/Syntax_folding_of_Vim_scripts#Syntax_definitions>
```
:syn region myFold start="\#IF" end="\#ENDIF" transparent fold
:syn sync fromstart
:set foldmethod=syntax
``` |
121,237 | <p>I would like to convert a string into a node. I have a method that is defined to take a node, but the value I have is a string (it is hard coded). How do I turn that string into a node?</p>
<p>So, given an XQuery method:</p>
<pre><code>define function foo($bar as node()*) as node() {
(: unimportant details :)
}
... | [
{
"answer_id": 121249,
"author": "Sixty4Bit",
"author_id": 1681,
"author_profile": "https://Stackoverflow.com/users/1681",
"pm_score": 5,
"selected": true,
"text": "<p><strong>MarkLogic solutions:</strong></p>\n\n<p>The best way to convert a string into a node is to use:</p>\n\n<pre><cod... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1681/"
] | I would like to convert a string into a node. I have a method that is defined to take a node, but the value I have is a string (it is hard coded). How do I turn that string into a node?
So, given an XQuery method:
```
define function foo($bar as node()*) as node() {
(: unimportant details :)
}
```
I have a string... | **MarkLogic solutions:**
The best way to convert a string into a node is to use:
```
xdmp:unquote($string).
```
Conversely if you want to convert a node into a string you would use:
```
xdmp:quote($node).
```
**Language agnostic solutions:**
Node to string is:
```
fn:string($node)
``` |
121,240 | <p>What is the best (cleanest, most efficient) way to write saturating addition in C?</p>
<p>The function or macro should add two unsigned inputs (need both 16- and 32-bit versions) and return all-bits-one (0xFFFF or 0xFFFFFFFF) if the sum overflows.</p>
<p>Target is x86 and ARM using gcc (4.1.2) and Visual Studio (f... | [
{
"answer_id": 121263,
"author": "DGentry",
"author_id": 4761,
"author_profile": "https://Stackoverflow.com/users/4761",
"pm_score": 3,
"selected": false,
"text": "<pre><code>uint32_t saturate_add32(uint32_t a, uint32_t b)\n{\n uint32_t sum = a + b;\n if ((sum < a) || (sum < ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8964/"
] | What is the best (cleanest, most efficient) way to write saturating addition in C?
The function or macro should add two unsigned inputs (need both 16- and 32-bit versions) and return all-bits-one (0xFFFF or 0xFFFFFFFF) if the sum overflows.
Target is x86 and ARM using gcc (4.1.2) and Visual Studio (for simulation onl... | You probably want portable C code here, which your compiler will turn into proper ARM assembly. ARM has conditional moves, and these can be conditional on overflow. The algorithm then becomes: add and conditionally set the destination to unsigned(-1), if overflow was detected.
```c
uint16_t add16(uint16_t a, uint16_t ... |
121,243 | <p>What are some hidden features of <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow noreferrer">SQL Server</a>?</p>
<p>For example, undocumented system stored procedures, tricks to do things which are very useful but not documented enough?</p>
<hr>
<h2>Answers</h2>
<p><em>Thanks to everybo... | [
{
"answer_id": 121275,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 3,
"selected": false,
"text": "<p>Here are some features I find useful but a lot of people don't seem to know about:</p>\n\n<pre><code>sp_tables\n</code></... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7028/"
] | What are some hidden features of [SQL Server](http://en.wikipedia.org/wiki/Microsoft_SQL_Server)?
For example, undocumented system stored procedures, tricks to do things which are very useful but not documented enough?
---
Answers
-------
*Thanks to everybody for all the great answers!*
**Stored Procedures**
* **... | In Management Studio, you can put a number after a GO end-of-batch marker to cause the batch to be repeated that number of times:
```
PRINT 'X'
GO 10
```
Will print 'X' 10 times. This can save you from tedious copy/pasting when doing repetitive stuff. |
121,253 | <p>I'm having a strange problem in Visual Studio 2008 where my "Pending Checkins" window never updates. I open it up, and it says "Updating..." like usual, but I never see the "X remaining" message, and nothing happens. It just sits there doing nothing.</p>
<p>Checked-out stuff still shows as checked out in Solution... | [
{
"answer_id": 122020,
"author": "EvilEddie",
"author_id": 12986,
"author_profile": "https://Stackoverflow.com/users/12986",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried the Visual SourceSafe 2005 Update patch?</p>\n"
},
{
"answer_id": 192168,
"author": "Ryan ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5486/"
] | I'm having a strange problem in Visual Studio 2008 where my "Pending Checkins" window never updates. I open it up, and it says "Updating..." like usual, but I never see the "X remaining" message, and nothing happens. It just sits there doing nothing.
Checked-out stuff still shows as checked out in Solution Explorer. S... | Hooray! I found a solution. For anyone else that stumbles across this, here's the deal.
I discovered today that the Pending Checkins window wasn't broken for *all* solutions, but only for a particular one. Also, though I didn't realize it was related, every time I opened the solution, I was getting:
**"Some of the pr... |
121,274 | <p>How would I go about binding the following object, Car, to a gridview?</p>
<pre>
public class Car
{
long Id {get; set;}
Manufacturer Maker {get; set;}
}
public class Manufacturer
{
long Id {get; set;}
String Name {get; set;}
}
</pre>
<p>The primitive types get bound easy but I have found no way of dis... | [
{
"answer_id": 121328,
"author": "hollystyles",
"author_id": 2083160,
"author_profile": "https://Stackoverflow.com/users/2083160",
"pm_score": 3,
"selected": false,
"text": "<pre><code> public class Manufacturer\n {\n long Id {get; set;}\n String Name {get; set;}\n\n ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15771/"
] | How would I go about binding the following object, Car, to a gridview?
```
public class Car
{
long Id {get; set;}
Manufacturer Maker {get; set;}
}
public class Manufacturer
{
long Id {get; set;}
String Name {get; set;}
}
```
The primitive types get bound easy but I have found no way of displaying anyth... | Allright guys... This question was posted waaay back but I just found a fairly nice & simple way to do this by using reflection in the cell\_formatting event to go retrieve the nested properties.
Goes like this:
```
private void Grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
... |
121,282 | <p>If I do something like:</p>
<pre><code>$ cat /bin/ls
</code></pre>
<p>into my terminal, I understand why I see a bunch of binary data, representing the ls executable. But afterwards, when I get my prompt back, my own keystrokes look crazy. I type "a" and I get a weird diagonal line. I type "b" and I get a degree s... | [
{
"answer_id": 121297,
"author": "Steve g",
"author_id": 12092,
"author_profile": "https://Stackoverflow.com/users/12092",
"pm_score": 2,
"selected": false,
"text": "<p>You're getting some control characters piped into the shell that are telling the shell to alter its behavior and print ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | If I do something like:
```
$ cat /bin/ls
```
into my terminal, I understand why I see a bunch of binary data, representing the ls executable. But afterwards, when I get my prompt back, my own keystrokes look crazy. I type "a" and I get a weird diagonal line. I type "b" and I get a degree symbol.
Why does this happ... | Because somewhere in your binary data were some control sequences that your terminal interpreted as requests to, for example, change the character set used to draw. You can restore everything to normal like so:
```
reset
``` |
121,309 | <p>In an ASP.NET 2.0 website, I have a string representing some well-formed XML. I am currently creating an XmlDocument object with it and running an XSL transformation for display in a Web form. Everything was operating fine until the XML input started to contain namespaces.</p>
<p>How can I read in this string and... | [
{
"answer_id": 121407,
"author": "ckarras",
"author_id": 5688,
"author_profile": "https://Stackoverflow.com/users/5688",
"pm_score": 1,
"selected": false,
"text": "<p>Your code looks right.</p>\n\n<p>The problem is probably in the xml document you're trying to load.\nIt must have element... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19626/"
] | In an ASP.NET 2.0 website, I have a string representing some well-formed XML. I am currently creating an XmlDocument object with it and running an XSL transformation for display in a Web form. Everything was operating fine until the XML input started to contain namespaces.
How can I read in this string and allow names... | Gut feel - one of the namespaces declared in //content:encoding is being dropped (probably because you're using the literal .InnerXml property)
What's 'w' namespace evaluate to in the myNav DOM? You'll want to add xmlns:w= to your post node. There will probably be others too. |
121,318 | <p>I need to have a script read the files coming in and check information for verification.</p>
<p>On the first line of the files to be read is a date but in numeric form. eg: 20080923
But before the date is other information, I need to read it from position 27. Meaning line 1 position 27, I need to get that number ... | [
{
"answer_id": 121336,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 4,
"selected": true,
"text": "<pre><code>sed 1q $file | cut -c27-34\n</code></pre>\n\n<p>The <code>sed</code> command reads the first line of th... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21151/"
] | I need to have a script read the files coming in and check information for verification.
On the first line of the files to be read is a date but in numeric form. eg: 20080923
But before the date is other information, I need to read it from position 27. Meaning line 1 position 27, I need to get that number and see if ... | ```
sed 1q $file | cut -c27-34
```
The `sed` command reads the first line of the file and the `cut` command chops out characters 27-34 of the one line, which is where you said the date is.
*Added later:*
For the more general case - where you need to read line 24, for example, instead of the first line, you need a s... |
121,324 | <p>I'm looking for a framework to generate Java source files.</p>
<p>Something like the following API:</p>
<pre><code>X clazz = Something.createClass("package name", "class name");
clazz.addSuperInterface("interface name");
clazz.addMethod("method name", returnType, argumentTypes, ...);
File targetDir = ...;
clazz.g... | [
{
"answer_id": 121367,
"author": "Steve g",
"author_id": 12092,
"author_profile": "https://Stackoverflow.com/users/12092",
"pm_score": 1,
"selected": false,
"text": "<p>If you REALLY need the source, I don't know of anything that generates source. You can however use <a href=\"http://as... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16135/"
] | I'm looking for a framework to generate Java source files.
Something like the following API:
```
X clazz = Something.createClass("package name", "class name");
clazz.addSuperInterface("interface name");
clazz.addMethod("method name", returnType, argumentTypes, ...);
File targetDir = ...;
clazz.generate(targetDir);
... | Sun provides an API called CodeModel for generating Java source files using an API. It's not the easiest thing to get information on, but it's there and it works extremely well.
The easiest way to get hold of it is as part of the JAXB 2 RI - the XJC schema-to-java generator uses CodeModel to generate its java source, ... |
121,326 | <p>What does it mean when it gives a backtrace with the following output?</p>
<pre><code>#0 0x00000008009c991c in pthread_testcancel () from /lib/libpthread.so.2
#1 0x00000008009b8120 in sigaction () from /lib/libpthread.so.2
#2 0x00000008009c211a in pthread_mutexattr_init () from /lib/libpthread.so.2
#3 0x0000000... | [
{
"answer_id": 121361,
"author": "Hannes Ovrén",
"author_id": 13565,
"author_profile": "https://Stackoverflow.com/users/13565",
"pm_score": 2,
"selected": false,
"text": "<p>Make sure you compile with debug symbols. (For gcc I think that is the -g option). Then you should be able to get ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10264/"
] | What does it mean when it gives a backtrace with the following output?
```
#0 0x00000008009c991c in pthread_testcancel () from /lib/libpthread.so.2
#1 0x00000008009b8120 in sigaction () from /lib/libpthread.so.2
#2 0x00000008009c211a in pthread_mutexattr_init () from /lib/libpthread.so.2
#3 0x0000000000000000 in ?... | gdb wasn't able to extract the proper return address from pthread\_mutexattr\_init; it got an address of 0. The "??" is the result of looking up address 0 in the symbol table. It cannot find a symbolic name, so it prints a default "??"
Unfortunately right offhand I don't know why it could not extract the correct retur... |
121,382 | <p>Is there a way to comment out markup in an <code>.ASPX</code> page so that it isn't delivered to the client? I have tried the standard comments <code><!-- --></code> but this just gets delivered as a comment and doesn't prevent the control from rendering. </p>
| [
{
"answer_id": 121397,
"author": "BigJump",
"author_id": 8542,
"author_profile": "https://Stackoverflow.com/users/8542",
"pm_score": 3,
"selected": false,
"text": "<p>Another way assuming it's not server side code you want to comment out is...</p>\n\n<pre><code><asp:panel runat=\"serv... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10676/"
] | Is there a way to comment out markup in an `.ASPX` page so that it isn't delivered to the client? I have tried the standard comments `<!-- -->` but this just gets delivered as a comment and doesn't prevent the control from rendering. | ```
<%--
Commented out HTML/CODE/Markup. Anything with
this block will not be parsed/handled by ASP.NET.
<asp:Calendar runat="server"></asp:Calendar>
<%# Eval(“SomeProperty”) %>
--%>
```
[Source](http://weblogs.asp.net/scottgu/archive/2006/07/09/Tip_2F00_Trick_... |
121,387 | <p>Table: </p>
<pre><code>UserId, Value, Date.
</code></pre>
<p>I want to get the UserId, Value for the max(Date) for each UserId. That is, the Value for each UserId that has the latest date. Is there a way to do this simply in SQL? (Preferably Oracle)</p>
<p><strong>Update:</strong> Apologies for any ambiguity: I n... | [
{
"answer_id": 121416,
"author": "jdmichal",
"author_id": 12275,
"author_profile": "https://Stackoverflow.com/users/12275",
"pm_score": 2,
"selected": false,
"text": "<p>I think something like this. (Forgive me for any syntax mistakes; I'm used to using HQL at this point!)</p>\n\n<p>EDIT... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21154/"
] | Table:
```
UserId, Value, Date.
```
I want to get the UserId, Value for the max(Date) for each UserId. That is, the Value for each UserId that has the latest date. Is there a way to do this simply in SQL? (Preferably Oracle)
**Update:** Apologies for any ambiguity: I need to get ALL the UserIds. But for each UserI... | This will retrieve all rows for which the my\_date column value is equal to the maximum value of my\_date for that userid. This may retrieve multiple rows for the userid where the maximum date is on multiple rows.
```
select userid,
my_date,
...
from
(
select userid,
my_date,
...
max... |
121,392 | <p>I have a bunch (hundreds) of files that are supposed to have Unix line endings. I strongly suspect that some of them have Windows line endings, and I want to programmatically figure out which ones do.</p>
<p>I know I can just run <pre>flip -u</pre> or something similar in a script to convert everything, but I want ... | [
{
"answer_id": 121415,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 0,
"selected": false,
"text": "<p>Windows use char 13 & 10 for line ending, unix only one of them ( i don't rememeber which one ). So you can replace ch... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18177/"
] | I have a bunch (hundreds) of files that are supposed to have Unix line endings. I strongly suspect that some of them have Windows line endings, and I want to programmatically figure out which ones do.
I know I can just run
```
flip -u
```
or something similar in a script to convert everything, but I want to be able ... | You could use grep
```
egrep -l $'\r'\$ *
``` |
121,396 | <p>When you call the <code>object.__repr__()</code> method in Python you get something like this back: </p>
<blockquote>
<pre><code><__main__.Test object at 0x2aba1c0cf890>
</code></pre>
</blockquote>
<p>Is there any way to get a hold of the memory address if you overload <code>__repr__()</code>, other then ca... | [
{
"answer_id": 121422,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 6,
"selected": false,
"text": "<p>Just use </p>\n\n<pre><code>id(object)\n</code></pre>\n"
},
{
"answer_id": 121426,
"author": "Thomas Wo... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/452521/"
] | When you call the `object.__repr__()` method in Python you get something like this back:
>
>
> ```
> <__main__.Test object at 0x2aba1c0cf890>
>
> ```
>
>
Is there any way to get a hold of the memory address if you overload `__repr__()`, other then calling `super(Class, obj).__repr__()` and regexing it out? | The [Python manual](https://docs.python.org/2/library/functions.html#id) has this to say about `id()`:
>
> Return the "identity'' of an object.
> This is an integer (or long integer)
> which is guaranteed to be unique and
> constant for this object during its
> lifetime. Two objects with
> non-overlapping lifeti... |
121,439 | <p>I'm running <code>Django 1.0</code> and I'm close to deploying my app. As such, I'll be changing the DEBUG setting to False.</p>
<p>With that being said, I'd still like to include the stacktrace on my 500.html page when errors occur. By doing so, users can copy-and-paste the errors and easily email them to the de... | [
{
"answer_id": 121474,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 5,
"selected": true,
"text": "<p>Automatically log your 500s, that way:</p>\n\n<ul>\n<li>You know when they occur.</li>\n<li>You don't need to rely o... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10040/"
] | I'm running `Django 1.0` and I'm close to deploying my app. As such, I'll be changing the DEBUG setting to False.
With that being said, I'd still like to include the stacktrace on my 500.html page when errors occur. By doing so, users can copy-and-paste the errors and easily email them to the developers.
Any thoughts... | Automatically log your 500s, that way:
* You know when they occur.
* You don't need to rely on users sending you stacktraces.
Joel recommends even going so far as automatically creating tickets in your bug tracker when your application experiences a failure. Personally, I create a (private) RSS feed with the stacktra... |
121,453 | <p>There is a way to know the flash player version installed on the computer that runs our SWF file with Action Script 3.0?</p>
| [
{
"answer_id": 121486,
"author": "davr",
"author_id": 14569,
"author_profile": "https://Stackoverflow.com/users/14569",
"pm_score": 2,
"selected": false,
"text": "<p>It's in <a href=\"http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/Capabilities.html#version\" rel=\... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20601/"
] | There is a way to know the flash player version installed on the computer that runs our SWF file with Action Script 3.0? | If you are programming from within the IDE the following will get you the version
```
trace(Capabilities.version);
```
If you are building a custom class the following should help.
Make sure that this following code goes into a file named VersionCheck.as
>
>
> ```
>
> package
> {
> import flash.system.Capab... |
121,493 | <p>I'm no crypto expert, but as I understand it, 3DES is a symmetric encryption algorithm, which means it doesnt use public/private keys.</p>
<p>Nevertheless, I have been tasked with encrypting data using a public key, (specifically, a .CER file).
If you ignore the whole symmetric/asymmetric thang, I should just be ab... | [
{
"answer_id": 121526,
"author": "jlew",
"author_id": 7450,
"author_profile": "https://Stackoverflow.com/users/7450",
"pm_score": 3,
"selected": true,
"text": "<p>cryptoProvider.Key = cert.GetPublicKey()?</p>\n"
},
{
"answer_id": 121527,
"author": "Seb Nilsson",
"author_i... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21002/"
] | I'm no crypto expert, but as I understand it, 3DES is a symmetric encryption algorithm, which means it doesnt use public/private keys.
Nevertheless, I have been tasked with encrypting data using a public key, (specifically, a .CER file).
If you ignore the whole symmetric/asymmetric thang, I should just be able to use ... | cryptoProvider.Key = cert.GetPublicKey()? |
121,499 | <p>Suppose I attach an <code>blur</code> function to an HTML input box like this:</p>
<pre><code><input id="myInput" onblur="function() { ... }"></input>
</code></pre>
<p>Is there a way to get the ID of the element which caused the <code>blur</code> event to fire (the element which was clicked) inside the... | [
{
"answer_id": 121517,
"author": "brock.holum",
"author_id": 15860,
"author_profile": "https://Stackoverflow.com/users/15860",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Edit:</strong>\nA hacky way to do it would be to create a variable that keeps track of focus for every elem... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6264/"
] | Suppose I attach an `blur` function to an HTML input box like this:
```
<input id="myInput" onblur="function() { ... }"></input>
```
Is there a way to get the ID of the element which caused the `blur` event to fire (the element which was clicked) inside the function? How?
For example, suppose I have a span like thi... | Hmm... In Firefox, you can use `explicitOriginalTarget` to pull the element that was clicked on. I expected `toElement` to do the same for IE, but it does not appear to work... However, you can pull the newly-focused element from the document:
```
function showBlur(ev)
{
var target = ev.explicitOriginalTarget||docu... |
121,511 | <p>I have inherited a poorly written web application that seems to have errors when it tries to read in an xml document stored in the database that has an "&" in it. For example there will be a tag with the contents: "Prepaid & Charge". Is there some secret simple thing to do to have it not get an error parsi... | [
{
"answer_id": 121529,
"author": "Steve g",
"author_id": 12092,
"author_profile": "https://Stackoverflow.com/users/12092",
"pm_score": 2,
"selected": false,
"text": "<p>You can replace & with <code>&amp;</code></p>\n\n<p>Or you might also be able to use <a href=\"http://en.wikipe... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13593/"
] | I have inherited a poorly written web application that seems to have errors when it tries to read in an xml document stored in the database that has an "&" in it. For example there will be a tag with the contents: "Prepaid & Charge". Is there some secret simple thing to do to have it not get an error parsing that chara... | The problem is the xml is not well-formed. Properly generated xml would list the data like this:
>
> `Prepaid & Charge`
>
>
>
I've fixed the same problem before, and I did it with this regex:
```
Regex badAmpersand = new Regex("&(?![a-zA-Z]{2,6};|#[0-9]{2,4};)");
```
Combine that with a string constant def... |
121,521 | <p>I use the on-demand (hosted) version of FogBugz. I would like to start using Mercurial for source control. I would like to integrate FogBugz and a BitBucket repository.
I gave it a bit of a try but things weren't going very well. </p>
<p>FogBugz requires that you hook up your Mercurial client to a fogbugz.py pyt... | [
{
"answer_id": 123314,
"author": "Stefan Rusek",
"author_id": 19704,
"author_profile": "https://Stackoverflow.com/users/19704",
"pm_score": 4,
"selected": true,
"text": "<p>From the sounds of it you are wanting to run the hook on your local machine. The hook and directions are intended f... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498/"
] | I use the on-demand (hosted) version of FogBugz. I would like to start using Mercurial for source control. I would like to integrate FogBugz and a BitBucket repository.
I gave it a bit of a try but things weren't going very well.
FogBugz requires that you hook up your Mercurial client to a fogbugz.py python script. T... | From the sounds of it you are wanting to run the hook on your local machine. The hook and directions are intended for use on the central server.
If you are the only one working in your repository or don't mind commit not showing up in FB until after you do a pull, then you can add the hook locally to your primary clon... |
121,579 | <p>I don't know if anyone has seen this issue before but I'm just stumped. Here's the unhandled exception message that my error page is capturing. </p>
<blockquote>
<p>Error Message: Validation of
viewstate MAC failed. If this
application is hosted by a Web Farm or
cluster, ensure that configuration
specifi... | [
{
"answer_id": 121583,
"author": "Chris Driver",
"author_id": 5217,
"author_profile": "https://Stackoverflow.com/users/5217",
"pm_score": 5,
"selected": true,
"text": "<p>I seem to recall that this error can occur if you click a button/link etc before the page has fully loaded.</p>\n\n<p... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21165/"
] | I don't know if anyone has seen this issue before but I'm just stumped. Here's the unhandled exception message that my error page is capturing.
>
> Error Message: Validation of
> viewstate MAC failed. If this
> application is hosted by a Web Farm or
> cluster, ensure that configuration
> specifies the same valid... | I seem to recall that this error can occur if you click a button/link etc before the page has fully loaded.
If this is the case, the error is caused by an ASP.net 2.0 feature called Event Validation. This is a security feature that ensures that postback actions only come from events allowed and created by the server t... |
121,581 | <p>In SQL Server what is the simplest/cleanest way to make a datetime representing the first of the month based on another datetime? eg I have a variable or column with 3-Mar-2005 14:23 and I want to get 1-Mar-2005 00:00 (as a datetime, not as varchar)</p>
| [
{
"answer_id": 121596,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 3,
"selected": false,
"text": "<pre><code>SELECT DATEADD(mm, DATEDIFF(mm, 0, @date), 0)\n</code></pre>\n"
},
{
"answer_id": 121602,
"auth... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8479/"
] | In SQL Server what is the simplest/cleanest way to make a datetime representing the first of the month based on another datetime? eg I have a variable or column with 3-Mar-2005 14:23 and I want to get 1-Mar-2005 00:00 (as a datetime, not as varchar) | ```
Select DateAdd(Month, DateDiff(Month, 0, GetDate()), 0)
```
To run this on a column, replace GetDate() with your column name.
The trick to this code is with DateDiff. DateDiff returns an integer. The second parameter (the 0) represents the 0 date in SQL Server, which is Jan 1, 1900. So, the datediff calculates t... |
121,605 | <p>What is the best way to reduce the size of the viewstate hidden field in JSF?
I have noticed that my view state is approximately 40k this goes down to the client and back to the server on every request and response espically coming to the server this is a significant slowdown for the user. </p>
<p>My Environment J... | [
{
"answer_id": 121624,
"author": "David Waters",
"author_id": 12148,
"author_profile": "https://Stackoverflow.com/users/12148",
"pm_score": 4,
"selected": false,
"text": "<p>If you are using MyFaces you can try this setting to compress the viewstate before sending to the client.</p>\n\n<... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12148/"
] | What is the best way to reduce the size of the viewstate hidden field in JSF?
I have noticed that my view state is approximately 40k this goes down to the client and back to the server on every request and response espically coming to the server this is a significant slowdown for the user.
My Environment JSF 1.2, MyF... | Have you tried setting the state saving to server? This should only send an id to the client, and keep the full state on the server. Simply add the following to the file *web.xml* :
```
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
``... |
121,631 | <p>Is there a difference in performance (in oracle) between</p>
<pre><code>Select * from Table1 T1
Inner Join Table2 T2 On T1.ID = T2.ID
</code></pre>
<p>And</p>
<pre><code>Select * from Table1 T1, Table2 T2
Where T1.ID = T2.ID
</code></pre>
<p>?</p>
| [
{
"answer_id": 121648,
"author": "Craig Trader",
"author_id": 12895,
"author_profile": "https://Stackoverflow.com/users/12895",
"pm_score": 6,
"selected": false,
"text": "<p>If the query optimizer is doing its job right, there should be no difference between those queries. They are just... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] | Is there a difference in performance (in oracle) between
```
Select * from Table1 T1
Inner Join Table2 T2 On T1.ID = T2.ID
```
And
```
Select * from Table1 T1, Table2 T2
Where T1.ID = T2.ID
```
? | No! The same execution plan, look at these two tables:
```
CREATE TABLE table1 (
id INT,
name VARCHAR(20)
);
CREATE TABLE table2 (
id INT,
name VARCHAR(20)
);
```
The execution plan for the query using the inner join:
```
-- with inner join
EXPLAIN PLAN FOR
SELECT * FROM table1 t1
INNER JOIN table2 t2 ON ... |
121,656 | <p>I have the following string and I would like to remove <code><bpt *>*</bpt></code> and <code><ept *>*</ept></code> (notice the additional tag content inside them that also needs to be removed) without using a XML parser (overhead too large for tiny strings).</p>
<pre><code>The big <bpt i... | [
{
"answer_id": 121727,
"author": "davenpcj",
"author_id": 4777,
"author_profile": "https://Stackoverflow.com/users/4777",
"pm_score": 1,
"selected": false,
"text": "<p>I presume you want to drop the tag entirely?</p>\n\n<pre><code>(<bpt .*?>.*?</bpt>)|(<ept .*?>.*?</... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508/"
] | I have the following string and I would like to remove `<bpt *>*</bpt>` and `<ept *>*</ept>` (notice the additional tag content inside them that also needs to be removed) without using a XML parser (overhead too large for tiny strings).
```
The big <bpt i="1" x="1" type="bold"><b></bpt>black<ept i="1"></b></ept> <bpt ... | If you just want to remove all the tags from the string, use this (C#):
```
try {
yourstring = Regex.Replace(yourstring, "(<[be]pt[^>]+>.+?</[be]pt>)", "");
} catch (ArgumentException ex) {
// Syntax error in the regular expression
}
```
EDIT:
I decided to add on to my solution with a better option. The pre... |
121,662 | <p>Ok, so we have clients and those clients get to customize their web facing page. One option we are giving them is to be able to change the color of a graphic (it's like a framish-looking bar) using one of those hex wheels or whatever. </p>
<p>So, I've thought about it, and I don't know where to start. I am sending ... | [
{
"answer_id": 121692,
"author": "Aaron Jensen",
"author_id": 11229,
"author_profile": "https://Stackoverflow.com/users/11229",
"pm_score": 1,
"selected": false,
"text": "<p>What exactly will be changing? Depending on what's changing you may be able to overlay a transparent png on top of... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140/"
] | Ok, so we have clients and those clients get to customize their web facing page. One option we are giving them is to be able to change the color of a graphic (it's like a framish-looking bar) using one of those hex wheels or whatever.
So, I've thought about it, and I don't know where to start. I am sending comps out ... | I'm sort of intuiting that you'll have a black on white bitmap that you use as the base image. The client can then select any other color combination. This may not be exactly your situation, but it should get us started. (The code below is VB -- it's what I know, but converting to C# should be trivial for you.)
```
Im... |
121,665 | <p>How does one invoke a groovy method that prints to stdout, appending the output to a string?</p>
| [
{
"answer_id": 121776,
"author": "Joe Skora",
"author_id": 14057,
"author_profile": "https://Stackoverflow.com/users/14057",
"pm_score": 5,
"selected": true,
"text": "<p>This demonstrates how you can do this. Paste this into a Groovy script file and run it. You will see the first call ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How does one invoke a groovy method that prints to stdout, appending the output to a string? | This demonstrates how you can do this. Paste this into a Groovy script file and run it. You will see the first call functions as normal. The second call produces no results. Finally, the last step in the main prints the results of the second call that were redirected to a ByteArrayOutputStream.
Have fun!
```
void doS... |
121,676 | <p>Inside a .NET 3.5 web app running impersonation I am trying to execute a process via:</p>
<pre><code>var process = new Process
{ StartInfo =
{ CreateNoWindow = true,
FileName = "someFileName",
Domain = "someDomain",
... | [
{
"answer_id": 121721,
"author": "Charles Graham",
"author_id": 7705,
"author_profile": "https://Stackoverflow.com/users/7705",
"pm_score": 0,
"selected": false,
"text": "<p>I ran into the same problem that you did on a project. There <em>should</em> be a way to spawn a process out of y... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Inside a .NET 3.5 web app running impersonation I am trying to execute a process via:
```
var process = new Process
{ StartInfo =
{ CreateNoWindow = true,
FileName = "someFileName",
Domain = "someDomain",
Username =... | You can use ProcessStartInfo which allows you to specify credentials. The trick is that the password is a secure string, so you have to pass it as a byte array.
The code might look something like:
```
Dim startInfo As New ProcessStartInfo(programName)
With startInfo
.Domain = "test.local"
... |
121,700 | <p>In an attempt to add some parameter validation and correct usage semantics to our application, we are trying to add correct exception handling to our .NET applications.</p>
<p>My question is this: When throwing exceptions in ADO.NET if a particular query returns no data or the data could not be found, what type of ... | [
{
"answer_id": 121746,
"author": "Richard Yorkshire",
"author_id": 21001,
"author_profile": "https://Stackoverflow.com/users/21001",
"pm_score": 2,
"selected": false,
"text": "<p>As far as ADO.net is concerned, a query that returns zero rows is not an error. If your application wishes to... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15766/"
] | In an attempt to add some parameter validation and correct usage semantics to our application, we are trying to add correct exception handling to our .NET applications.
My question is this: When throwing exceptions in ADO.NET if a particular query returns no data or the data could not be found, what type of exception ... | The [MSDN guidelines](http://msdn.microsoft.com/en-us/library/ms229021(VS.80).aspx) state:
* Consider throwing existing exceptions residing in the System namespaces instead of creating custom exception types.
* Do create and throw custom exceptions if you have an error condition that can be programmatically handled in... |
121,715 | <p>Java Newbie here. I have a JFrame that I added to my netbeans project, and I've added the following method to it, which creates a JTable. Problem is, for some reason when I call this method, the JTable isn't displayed. Any suggestions?</p>
<pre><code>public void showFromVectors(Vector colNames, Vector data) {
... | [
{
"answer_id": 121777,
"author": "davenpcj",
"author_id": 4777,
"author_profile": "https://Stackoverflow.com/users/4777",
"pm_score": 2,
"selected": true,
"text": "<p>\"this\" in your context is unclear. Is it inside an applet? a JFrame?</p>\n\n<p>You may be having a layout issue, make s... | 2008/09/23 | [
"https://Stackoverflow.com/questions/121715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11820/"
] | Java Newbie here. I have a JFrame that I added to my netbeans project, and I've added the following method to it, which creates a JTable. Problem is, for some reason when I call this method, the JTable isn't displayed. Any suggestions?
```
public void showFromVectors(Vector colNames, Vector data) {
jt = new j... | "this" in your context is unclear. Is it inside an applet? a JFrame?
You may be having a layout issue, make sure you've called setLayout on your class with a new borderlayout.
In a swing application, you'd want to use getRootContentPane().add() instead of a raw add(), depending on the version.
Java tutorial on addin... |