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 |
|---|---|---|---|---|---|---|
383,739 | <p>I am using the toggle() with jQuery and I have a sidebar on my page and each header is </p>
<pre><code><h2 class="sidebar-header">
</code></pre>
<p>One section of my code will look like:</p>
<pre><code> <div class="sidebar-section">
<h2 class="sidebar-header">SUBSCRIBE</h2>
... | [
{
"answer_id": 383750,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 1,
"selected": false,
"text": "<p>Try something like this:</p>\n\n<p>Suppose you have the following code:</p>\n\n<pre><code><div class=\"topdiv\... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using the toggle() with jQuery and I have a sidebar on my page and each header is
```
<h2 class="sidebar-header">
```
One section of my code will look like:
```
<div class="sidebar-section">
<h2 class="sidebar-header">SUBSCRIBE</h2>
<p class="sidebar">Make sure you subscribe to stay in ... | Try this:
[nextAll](http://docs.jquery.com/Traversing/nextAll)
```
$(".sidebar-header").click(function() {
$(this).nextAll().toggle();
});
``` |
383,760 | <p>I am trying to make a search view in Django. It is a search form with freetext input + some options to select, so that you can filter on years and so on. This is some of the code I have in the view so far, the part that does the filtering. And I would like some input on how expensive this would be on the database se... | [
{
"answer_id": 383776,
"author": "hasen",
"author_id": 35364,
"author_profile": "https://Stackoverflow.com/users/35364",
"pm_score": 3,
"selected": true,
"text": "<p>filter itself doesn't execute a query, no query is executed until you explicitly fetch items from query (e.g. get), and li... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42546/"
] | I am trying to make a search view in Django. It is a search form with freetext input + some options to select, so that you can filter on years and so on. This is some of the code I have in the view so far, the part that does the filtering. And I would like some input on how expensive this would be on the database serve... | filter itself doesn't execute a query, no query is executed until you explicitly fetch items from query (e.g. get), and list( query ) also executes it. |
383,765 | <p>How can I get a DataSet with all the data from a SQL Express server using C#?</p>
<p>Thanks</p>
<p>edit: To clarify, I do want all the data from every table. The reason for this, is that it is a relatively small database. Previously I'd been storing all three tables in an XML file using DataSet's abilities. Howeve... | [
{
"answer_id": 383770,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "<p>I think you need to narrow down the question somewhat... <em>All</em> the data? You mean, all the data in every ta... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | How can I get a DataSet with all the data from a SQL Express server using C#?
Thanks
edit: To clarify, I do want all the data from every table. The reason for this, is that it is a relatively small database. Previously I'd been storing all three tables in an XML file using DataSet's abilities. However, I want to migr... | You can use the GetSchema method to get all the tables in the database and then use a data adapter to fill a dataset. Something like this (I don't know if it compiles, I just paste some code and change it a bit):
```
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.SqlClient");
DataTable table... |
383,780 | <p>I have a simple text field for "Phone Number" in a contact form on a client's website. The formmail script returns whatever the user types into the field. For example, they'll receive "000-000-0000", "0000000000", (000) 000-000, etc. The client would like to receive all phone numbers in this form: 000-000-0000. Can ... | [
{
"answer_id": 383796,
"author": "clawr",
"author_id": 46201,
"author_profile": "https://Stackoverflow.com/users/46201",
"pm_score": 0,
"selected": false,
"text": "<p>something like this</p>\n\n<pre><code>function formatPhone($number)\n{\n $number = str_replace(array('(', ')', '-', ' ')... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48047/"
] | I have a simple text field for "Phone Number" in a contact form on a client's website. The formmail script returns whatever the user types into the field. For example, they'll receive "000-000-0000", "0000000000", (000) 000-000, etc. The client would like to receive all phone numbers in this form: 000-000-0000. Can som... | ```
<?php
function formatPhone($number)
{
$number = preg_replace('/[^\d]/', '', $number); //Remove anything that is not a number
if(strlen($number) < 10)
{
return false;
}
return substr($number, 0, 3) . '-' . substr($number, 3, 3) . '-' . substr($number, 6);
}
foreach(array('(858)555121... |
383,783 | <p>I'm currently wrestling with an Oracle SQL DATE conversion problem using iBATIS from Java.</p>
<p>Am using the Oracle JDBC thin driver ojdbc14 version 10.2.0.4.0. iBATIS version 2.3.2. Java 1.6.0_10-rc2-b32.</p>
<p>The problem revolves around a column of DATE type that is being returned by this snippet of SQL:</p>... | [
{
"answer_id": 383897,
"author": "ninesided",
"author_id": 1030,
"author_profile": "https://Stackoverflow.com/users/1030",
"pm_score": 0,
"selected": false,
"text": "<p>The problem is the use of <code>java.sql.Date</code>. According to the <a href=\"http://java.sun.com/j2se/1.5.0/docs/ap... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48048/"
] | I'm currently wrestling with an Oracle SQL DATE conversion problem using iBATIS from Java.
Am using the Oracle JDBC thin driver ojdbc14 version 10.2.0.4.0. iBATIS version 2.3.2. Java 1.6.0\_10-rc2-b32.
The problem revolves around a column of DATE type that is being returned by this snippet of SQL:
```
SELECT *
FROM ... | The full info (and it's more complex than described here and might depend upon which particular version of the Oracle drivers are in use) is in Richard Yee's answer here - [now expired link to Nabble]
---
Quick grab before it expires from nabble...
Roger,
See: <http://www.oracle.com/technetwork/database/enterprise-e... |
383,784 | <p>There is a nice feature in Visual Studio: you can create special code areas which can be minimized just as class methods in Eclipse are minimized. Like:</p>
<pre><code>#region
//some code
#endregion
</code></pre>
<p>Is there a way do make such pleasant feature in Eclipse?</p>
| [
{
"answer_id": 383791,
"author": "Stefan Schmidt",
"author_id": 1958045,
"author_profile": "https://Stackoverflow.com/users/1958045",
"pm_score": 2,
"selected": false,
"text": "<p>If you mean by minimizing folding, then I don't think Eclipse has the folding option you want. When I look a... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35594/"
] | There is a nice feature in Visual Studio: you can create special code areas which can be minimized just as class methods in Eclipse are minimized. Like:
```
#region
//some code
#endregion
```
Is there a way do make such pleasant feature in Eclipse? | It's called "collapse all", click on the editor view that you want to collapse all your methods in go to
help>
key assist...>
double click "collapse all">, everything is collapsed |
383,801 | <p>I believe i have set up Pg properly, but my script doesn't seem to be connecting to the database. I am testing with:</p>
<pre>
$database="networkem";
$user="postgres";
$password="";
$host="localhost";
$dbh = DBI->connect("DBI:Pg:dbname=$dbname;host=$host", $user, $password);
</pre>
<p>My pg_hba reads:</p>
<pre>
... | [
{
"answer_id": 383877,
"author": "Schwern",
"author_id": 14660,
"author_profile": "https://Stackoverflow.com/users/14660",
"pm_score": 4,
"selected": false,
"text": "<p>Rather than play 20 questions to debug your setup, <code>DBI->errstr</code> will say why the connection failed.</p>\... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I believe i have set up Pg properly, but my script doesn't seem to be connecting to the database. I am testing with:
```
$database="networkem";
$user="postgres";
$password="";
$host="localhost";
$dbh = DBI->connect("DBI:Pg:dbname=$dbname;host=$host", $user, $password);
```
My pg\_hba reads:
```
host all postgr... | Rather than play 20 questions to debug your setup, `DBI->errstr` will say why the connection failed.
```
my $dbh = DBI->connect(...) or die DBI->errstr;
```
Though if I had to guess... since Postgres authenticates based on host and login user, I suspect the confusion lies between the user name you're giving to the P... |
383,831 | <p>I've got a mySql stored procedure that looks like this--</p>
<pre><code>delimiter |
create procedure GetEmployeeById(in ID varchar(45))
begin
select id,
firstName,
lastName,
phone,
address1,
address2,
city,
state,
zip,
username,
password,
emptypeid... | [
{
"answer_id": 383841,
"author": "MarkR",
"author_id": 13724,
"author_profile": "https://Stackoverflow.com/users/13724",
"pm_score": 4,
"selected": true,
"text": "<p>Because, it's comparing t.id with itself, which will always be true. Call your formal parameter something else.</p>\n"
}... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/94958/"
] | I've got a mySql stored procedure that looks like this--
```
delimiter |
create procedure GetEmployeeById(in ID varchar(45))
begin
select id,
firstName,
lastName,
phone,
address1,
address2,
city,
state,
zip,
username,
password,
emptypeid
from mysche... | Because, it's comparing t.id with itself, which will always be true. Call your formal parameter something else. |
383,833 | <p>Suppose I'm implementing a queue in java and I have a reference to the initial node, called ini and another to the last one, called last. Now, I start inserting objects into the queue. At one point, I decide I want an operation to clear the queue. Then I do this:</p>
<pre><code>ini = null;
last = null;
</code></pre... | [
{
"answer_id": 383836,
"author": "sk.",
"author_id": 16399,
"author_profile": "https://Stackoverflow.com/users/16399",
"pm_score": 4,
"selected": false,
"text": "<p>As long as no item in the queue is referenced anywhere else in your code, the garbage collector will be able to reclaim tha... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Suppose I'm implementing a queue in java and I have a reference to the initial node, called ini and another to the last one, called last. Now, I start inserting objects into the queue. At one point, I decide I want an operation to clear the queue. Then I do this:
```
ini = null;
last = null;
```
Am I leaking memory?... | As long as no item in the queue is referenced anywhere else in your code, the garbage collector will be able to reclaim that memory. Setting pointers to null in Java is not the same as in C where setting a malloc'ed pointer to null prevents it from being freed. In Java, memory is reclaimed when it is no longer reachabl... |
383,850 | <p>Is there a convention for naming the private method that I have called "<code>_Add</code>" here? I am not a fan of the leading underscore but it is what one of my teammates suggests.</p>
<pre><code>public Vector Add(Vector vector) {
// check vector for null, and compare Length to vector.Length
return _Add(v... | [
{
"answer_id": 383851,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": false,
"text": "<p>I've never seen any coding convention in C# that distinguished between public and private methods. I don't suggest... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45914/"
] | Is there a convention for naming the private method that I have called "`_Add`" here? I am not a fan of the leading underscore but it is what one of my teammates suggests.
```
public Vector Add(Vector vector) {
// check vector for null, and compare Length to vector.Length
return _Add(vector);
}
public static ... | I usually see and use either "AddCore" or "InnerAdd" |
383,857 | <p>I'm having trouble trying to set the value of a property after i cast it. I'm not sure if this is called <em>boxing</em>.</p>
<p>Anyways, the new variable is getting set, but the original is not. I thought the new variable is just a <em>reference</em> to the original. But when i check the intellisence/debug watcher... | [
{
"answer_id": 383863,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 0,
"selected": false,
"text": "<p>You have <em>read</em> from the <code>TagList</code> property. That makes <code>tags</code> hold the same value as ... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I'm having trouble trying to set the value of a property after i cast it. I'm not sure if this is called *boxing*.
Anyways, the new variable is getting set, but the original is not. I thought the new variable is just a *reference* to the original. But when i check the intellisence/debug watcher, the original property ... | Tags and data are completely isolated variables. Just because you assign an object to `tags`, this makes no difference to the *variable* `data`.
What you are getting confused is that when the two *variables* point to the same *object*, then changes to the (single) *object* will be seen through either *variable*.
Basi... |
383,888 | <p>Suppose I have this:</p>
<pre><code>class test<T>
{
private T[] elements;
private int size;
public test(int size)
{
this.size = size;
elements = new T[this.size];
}
}
</code></pre>
<p>It seems this isn't possible because the compiler doesn't know what constructor to call o... | [
{
"answer_id": 383892,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 0,
"selected": false,
"text": "<p>I may be wrong, but your declaration seems strange, shouldn't you have :</p>\n\n<pre><code>private T[] elements;\n</code></... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Suppose I have this:
```
class test<T>
{
private T[] elements;
private int size;
public test(int size)
{
this.size = size;
elements = new T[this.size];
}
}
```
It seems this isn't possible because the compiler doesn't know what constructor to call once it tries to replace the gene... | The problem is that since the generic type parameter `T` is transformed into `Object` by the compiler (it's called *type erasure*), you actually create an array of `Object`. What you can do is provide a `Class<T>` to the function:
```
class test<T>
{
private T[] elements;
private int size;
public test(Clas... |
383,898 | <p>This is something I've pondered over for a while, as I've seen both used in practise.</p>
<h2>Method 1</h2>
<pre><code><ol>
<li>List item 1</li>
<li>List item 2
<ol>
<li>List item 3</li>
</ol>
</li>
<li>List item ... | [
{
"answer_id": 383906,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 2,
"selected": false,
"text": "<p>Method 1 is correct.</p>\n"
},
{
"answer_id": 383915,
"author": "Rob Kennedy",
"author_id": 33732,
"a... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] | This is something I've pondered over for a while, as I've seen both used in practise.
Method 1
--------
```
<ol>
<li>List item 1</li>
<li>List item 2
<ol>
<li>List item 3</li>
</ol>
</li>
<li>List item 4</li>
</ol>
```
This seems semantically correct to me, since the sub-... | Method 2 is not valid HTML. `OL` is not allowed as a direct child of another `OL` element. Only `LI` is allowed in an `OL`.
Also, the membership of the sublist to item 2 is only apparent to a human reader because of the indentation. Make the indentation even with the `LI`s, and it appears as though the inner list is i... |
383,899 | <p>this question is an extension to a <a href="https://stackoverflow.com/questions/383857/why-is-this-property-not-getting-set" title="My previous question about reference and property setting">previous question i asked</a> (and was answered). I'm refactoring my code an playing around with / experimenting with various ... | [
{
"answer_id": 383905,
"author": "Tim Merrifield",
"author_id": 36706,
"author_profile": "https://Stackoverflow.com/users/36706",
"pm_score": 5,
"selected": true,
"text": "<p>What about this, so you only do the cast once:</p>\n\n<pre><code>ITagElement someData = data as ITagElement\nif (... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | this question is an extension to a [previous question i asked](https://stackoverflow.com/questions/383857/why-is-this-property-not-getting-set "My previous question about reference and property setting") (and was answered). I'm refactoring my code an playing around with / experimenting with various refactored solutions... | What about this, so you only do the cast once:
```
ITagElement someData = data as ITagElement
if (someData != null)
{
if (someData.TagList.IsNullOrEmpty())
{
someData.TagList = new List<Tag>();
}
someData.TagList.Add(new Tag
{
K = xmlReader.GetAttribute("k"),
V = xmlReader.... |
383,912 | <p>I'd like to know if there's an easier way to batch insert a set of records if they don't already exist in a table. For example I have a Tags table in the database having ID, Name columns - given a list of tag names I want to add only those that are not already present. Here's what I came up with:</p>
<pre><code>pri... | [
{
"answer_id": 383905,
"author": "Tim Merrifield",
"author_id": 36706,
"author_profile": "https://Stackoverflow.com/users/36706",
"pm_score": 5,
"selected": true,
"text": "<p>What about this, so you only do the cast once:</p>\n\n<pre><code>ITagElement someData = data as ITagElement\nif (... | 2008/12/21 | [
"https://Stackoverflow.com/questions/383912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48065/"
] | I'd like to know if there's an easier way to batch insert a set of records if they don't already exist in a table. For example I have a Tags table in the database having ID, Name columns - given a list of tag names I want to add only those that are not already present. Here's what I came up with:
```
private static vo... | What about this, so you only do the cast once:
```
ITagElement someData = data as ITagElement
if (someData != null)
{
if (someData.TagList.IsNullOrEmpty())
{
someData.TagList = new List<Tag>();
}
someData.TagList.Add(new Tag
{
K = xmlReader.GetAttribute("k"),
V = xmlReader.... |
383,921 | <p>I have the types <code>Rock</code>, <code>Paper</code>, and <code>Scissors</code>. These are components, or "hands" of the Rock, Paper, Scissors game. Given two players' hands the game must decide who wins. How do I solve the problem of storing this chain chart</p>
<p><img src="https://upload.wikimedia.org/wikip... | [
{
"answer_id": 383926,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>Have a GameStrategy class that implements a Win method. The win method takes a list of Hands, and returns either a Ha... | 2008/12/21 | [
"https://Stackoverflow.com/questions/383921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456/"
] | I have the types `Rock`, `Paper`, and `Scissors`. These are components, or "hands" of the Rock, Paper, Scissors game. Given two players' hands the game must decide who wins. How do I solve the problem of storing this chain chart
</a> in my code to show me what a variable is, what its value is, and the same for anything that it contains.</p>
<p>What is a good Python equivalent for this?</p>
| [
{
"answer_id": 383951,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 2,
"selected": false,
"text": "<p><code>print</code></p>\n\n<p>For your own classes, just def a <code>__str__</code> method</p>\n"
},
{
"answer_id": ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/383944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20267/"
] | When debugging in PHP, I frequently find it useful to simply stick a [var\_dump()](http://php.net/var-dump) in my code to show me what a variable is, what its value is, and the same for anything that it contains.
What is a good Python equivalent for this? | To display a value nicely, you can use the [pprint](http://docs.python.org/library/pprint.html) module. The easiest way to dump all variables with it is to do
```
from pprint import pprint
pprint(globals())
pprint(locals())
```
If you are running in CGI, a useful debugging feature is the [cgitb](http://docs.python.... |
383,947 | <p>I have seen this mentioned a few times and I am not clear on what it means. When and why would you do this? </p>
<p>I know what interfaces do, but the fact I am not clear on this makes me think I am missing out on using them correctly. </p>
<p>Is it just so if you were to do:</p>
<pre><code>IInterface classRef = ... | [
{
"answer_id": 383952,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 5,
"selected": false,
"text": "<p>You should look into Inversion of Control:</p>\n\n<ul>\n<li><a href=\"http://martinfowler.com/articles/injection.h... | 2008/12/21 | [
"https://Stackoverflow.com/questions/383947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35454/"
] | I have seen this mentioned a few times and I am not clear on what it means. When and why would you do this?
I know what interfaces do, but the fact I am not clear on this makes me think I am missing out on using them correctly.
Is it just so if you were to do:
```
IInterface classRef = new ObjectWhatever()
```
Y... | There are some wonderful answers on here to this questions that get into all sorts of great detail about interfaces and loosely coupling code, inversion of control and so on. There are some fairly heady discussions, so I'd like to take the opportunity to break things down a bit for understanding why an interface is use... |
383,966 | <p>More specifically, I'm trying to check if given string (a sentence) is in Turkish. </p>
<p>I can check if the string has Turkish characters such as Ç, Ş, Ü, Ö, Ğ etc. However that's not very reliable as those might be converted to C, S, U, O, G before I receive the string.</p>
<p>Another method is to have the 100 ... | [
{
"answer_id": 383988,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "https://Stackoverflow.com/users/32638",
"pm_score": 5,
"selected": true,
"text": "<p>One option would be to use a Bayesian Classifier such as <a href=\"http://www.divmod.org/trac/wiki/DivmodReverend\" ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/383966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | More specifically, I'm trying to check if given string (a sentence) is in Turkish.
I can check if the string has Turkish characters such as Ç, Ş, Ü, Ö, Ğ etc. However that's not very reliable as those might be converted to C, S, U, O, G before I receive the string.
Another method is to have the 100 most used words i... | One option would be to use a Bayesian Classifier such as [Reverend](http://www.divmod.org/trac/wiki/DivmodReverend). The Reverend homepage gives this suggestion for a naive language detector:
```
from reverend.thomas import Bayes
guesser = Bayes()
guesser.train('french', 'le la les du un une je il elle de en')
guesser... |
383,973 | <p>This is a fundamental question, but an important one none the less...</p>
<p><strong>When starting a C++ program whose main method has the following common signature:</strong></p>
<pre><code>int main(int argc, char* args[]) {
//Magic!
return 0;
}
</code></pre>
<p><strong>is args[0] always guaranteed to be... | [
{
"answer_id": 383976,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 6,
"selected": true,
"text": "<p>It is not always. It's the value that you gave the program by the Operation System. For example when star... | 2008/12/21 | [
"https://Stackoverflow.com/questions/383973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3552/"
] | This is a fundamental question, but an important one none the less...
**When starting a C++ program whose main method has the following common signature:**
```
int main(int argc, char* args[]) {
//Magic!
return 0;
}
```
**is args[0] always guaranteed to be the path to the currently running program? What abo... | It is not always. It's the value that you gave the program by the Operation System. For example when starting a program using `exec` you can set that to an arbitrary value:
```
int execve(const char *filename, char *const argv[],
char *const envp[]);
```
The first parameter is the file to start, and argv ... |
383,978 | <p>Here's a small test program I wrote:</p>
<pre><code>#import <Foundation/Foundation.h>
int main(int argc, char **argv) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *arr = [NSArray array];
printf("Arr isMemberOfClass NSArray: %d\n", [arr isMemberOfClass:[NSArray class]])... | [
{
"answer_id": 384013,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>I've never used -isMemberOfClass: myself, because if I've added functionality to an existing class it's usually been throug... | 2008/12/21 | [
"https://Stackoverflow.com/questions/383978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | Here's a small test program I wrote:
```
#import <Foundation/Foundation.h>
int main(int argc, char **argv) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *arr = [NSArray array];
printf("Arr isMemberOfClass NSArray: %d\n", [arr isMemberOfClass:[NSArray class]]);
printf("Arr is... | You generally want `isKindOfClass:`, not `isMemberOfClass:`. The difference is that `isKindOfClass:` will return `YES` if the receiver is a member of a subclass of the class in question, whereas `isMemberOfClass:` will return `NO` in the same case.
As Graham Lee points out, `NSArray` is a class cluster. That means tha... |
383,995 | <p>I have the points by the end of the GenerateButton class but now that I got my public double[][] matrix with all the points in, where do I begin drawing them???</p>
<p>my Main.java:</p>
<pre><code>import java.awt.*;
import javax.swing.*;
public class Main {
public static Display display = new Display();
... | [
{
"answer_id": 384072,
"author": "James",
"author_id": 41039,
"author_profile": "https://Stackoverflow.com/users/41039",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not quite exactly sure what you are asking. Normally, you put all of the drawing functionality in the paint() method.... | 2008/12/21 | [
"https://Stackoverflow.com/questions/383995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] | I have the points by the end of the GenerateButton class but now that I got my public double[][] matrix with all the points in, where do I begin drawing them???
my Main.java:
```
import java.awt.*;
import javax.swing.*;
public class Main {
public static Display display = new Display();
public static void ... | I'm not quite exactly sure what you are asking. Normally, you put all of the drawing functionality in the paint() method. However, you generally want to keep any long running work off of the AWT dispatch thread which is the same thread that your buttons' actionPerformed() method is invoked on. To keep your program resp... |
384,004 | <p>I am using LINQ to EF and have the following LINQ query:</p>
<pre><code>var results = (from x in ctx.Items
group x by x.Year into decades
orderby decades.Count() descending
select new { Decade = decades.Key, DecadeCount = decades.Count() });
</code></pre>
<p>So this kin... | [
{
"answer_id": 384007,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you would chain the SelectMany method to the end of your result. This returns an IEnumerable of IEnumerables.</... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25719/"
] | I am using LINQ to EF and have the following LINQ query:
```
var results = (from x in ctx.Items
group x by x.Year into decades
orderby decades.Count() descending
select new { Decade = decades.Key, DecadeCount = decades.Count() });
```
So this kind of gets me to where I wa... | It looks like we cannot do a grouping or select or similar on calculated fields that are definied in the partial classes on the entity framework.
The calculated fields can be used on LINQ to objects (so you could return all the data as objects and then do a grouping) |
384,036 | <p>I want to set up a continuous integration and test framework for my open source C++ project. The desired features are:</p>
<pre><code>1. check out the source code
2. run all the unit and other tests
3. run performance tests (these measure the software quality - for example how long does it take the system to comple... | [
{
"answer_id": 384065,
"author": "wilhelmtell",
"author_id": 456,
"author_profile": "https://Stackoverflow.com/users/456",
"pm_score": 2,
"selected": false,
"text": "<p>Your question is twofold. As you pointed out yourself, the choice of a unit-testing library is one question. Yes, I t... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19501/"
] | I want to set up a continuous integration and test framework for my open source C++ project. The desired features are:
```
1. check out the source code
2. run all the unit and other tests
3. run performance tests (these measure the software quality - for example how long does it take the system to complete the test)
4... | I am using CruiseControl and UnitTest++ today for exactly this task.
UnitTest++ is really nice although I feel sometimes limited by it around the corner. At least it is 10 times better than cppunit. Still haven't tried the google testing framework, it will be for my next project.
I have been extremely disappointed by... |
384,042 | <p>Is there a built in way to limit the depth of a System.Collection.Generics.Stack? So that if you are at max capacity, pushing a new element would remove the bottom of the stack?</p>
<p>I know I can do it by converting to an array and rebuilding the stack, but I figured there's probably a method on it already.</p>
... | [
{
"answer_id": 384047,
"author": "Ryan Lundy",
"author_id": 5486,
"author_profile": "https://Stackoverflow.com/users/5486",
"pm_score": 2,
"selected": false,
"text": "<p>I can't see a way. You can inherit from <code>Stack<T></code>, but there doesn't appear to be anything useful t... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | Is there a built in way to limit the depth of a System.Collection.Generics.Stack? So that if you are at max capacity, pushing a new element would remove the bottom of the stack?
I know I can do it by converting to an array and rebuilding the stack, but I figured there's probably a method on it already.
EDIT: I wrote ... | What you are looking for is called a **dropout stack**. AFAIK, the BCL does not contain one, although they are trivial to implement. Typically Undo and Redo functionality relies on such data structures.
They are basically an array, and when you push onto the stack the 'top' of the stack moves around the array. Eventua... |
384,053 | <p>Should be super simple for you guys...div one gets clicked, div two appears. What I don't know how to do is make div 2 go away when div one is clicked again.</p>
<pre><code><img src="/..." width="" height"" onClick="MM_showHideLayers('logo','','show','logoEasterEgg','',show')">
</code></pre>
<p>What should I... | [
{
"answer_id": 384057,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 0,
"selected": false,
"text": "<p><del>You are going to need to add another function call to hide the other div after the first call to show it.</p>\... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39781/"
] | Should be super simple for you guys...div one gets clicked, div two appears. What I don't know how to do is make div 2 go away when div one is clicked again.
```
<img src="/..." width="" height"" onClick="MM_showHideLayers('logo','','show','logoEasterEgg','',show')">
```
What should I add to this line of code to mak... | You could do something similar to what was suggested in response to [this](https://stackoverflow.com/questions/233936/jquery-swapping-elements) question with jQuery.
Basically just have a class for the div which you add and remove based on whether it is already there. |
384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | [
{
"answer_id": 384125,
"author": "airmind",
"author_id": 48087,
"author_profile": "https://Stackoverflow.com/users/48087",
"pm_score": 8,
"selected": false,
"text": "<p>I already knew about the color escapes, I used them in my bash prompt a while ago. Thanks anyway.<br>\nWhat I wanted wa... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48087/"
] | Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized).
Now, Python has the `logging` module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible with Python, but I ca... | I already knew about the color escapes, I used them in my bash prompt a while ago. Thanks anyway.
What I wanted was to integrate it with the logging module, which I eventually did after a couple of tries and errors.
Here is what I end up with:
```
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
... |
384,078 | <p>When I have tables in my database that have PK/FK relationships (int) and when they are modeled by the Entity Framework designer everything seems as it should be. I can write the code below and everything seems like it's going to work fine as well but then when I run the code I get an error on the project.Status.St... | [
{
"answer_id": 384100,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 4,
"selected": true,
"text": "<p>Try using Include(RelationshipName)</p>\n\n<pre><code>Dim db As New MyDbModel.MyDbEntities() \nDim project As MyDbMo... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47167/"
] | When I have tables in my database that have PK/FK relationships (int) and when they are modeled by the Entity Framework designer everything seems as it should be. I can write the code below and everything seems like it's going to work fine as well but then when I run the code I get an error on the project.Status.Status... | Try using Include(RelationshipName)
```
Dim db As New MyDbModel.MyDbEntities()
Dim project As MyDbModel.Project = (From p In db.Project.Include("Status") Where p.ProjectID = 1).First
Response.Write(project.ProjectName)
Response.Write(project.Status.StatusName)
``` |
384,089 | <p>I am try to use stringWithFormat to set a numerical value on the text property of a label but the following code is not working. I cannot cast the int to NSString. I was expecting that the method would know how to automatically convert an int to NSString.</p>
<p>What do I need to do here?</p>
<pre><code>- (IBActio... | [
{
"answer_id": 384090,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 8,
"selected": true,
"text": "<p>Do this:</p>\n\n<pre><code>label.text = [NSString stringWithFormat:@\"%d\", count];\n</code></pre>\n"
},
{
... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10366/"
] | I am try to use stringWithFormat to set a numerical value on the text property of a label but the following code is not working. I cannot cast the int to NSString. I was expecting that the method would know how to automatically convert an int to NSString.
What do I need to do here?
```
- (IBAction) increment: (id) se... | Do this:
```
label.text = [NSString stringWithFormat:@"%d", count];
``` |
384,108 | <p>I read through a bunch of questions asking about simple source code control tools and Git seemed like a reasonable choice. I have it up and running, and it works well so far. One aspect that I like about CVS is the automatic incrementation of a version number.</p>
<p>I understand that this makes less sense in a dis... | [
{
"answer_id": 384112,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 5,
"selected": false,
"text": "<p>Not sure this will ever be in Git. To <a href=\"http://www.gelato.unsw.edu.au/archives/git/0610/28891.html\" rel=\"norefer... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45978/"
] | I read through a bunch of questions asking about simple source code control tools and Git seemed like a reasonable choice. I have it up and running, and it works well so far. One aspect that I like about CVS is the automatic incrementation of a version number.
I understand that this makes less sense in a distributed r... | The SHA is just one representation of a version (albeit canonical). The `git describe` command offers others and does so quite well.
For example, when I run `git describe` in my master branch of my [Java memcached client](http://github.com/dustin/java-memcached-client) source, I get this:
```
2.2-16-gc0cd61a
```
Th... |
384,119 | <p>If I've queued up some email to be sent via the System.Net.Mail.SMTPClent, where can I find this mail? With the Windows SMTP Client, it's in the C:\inetpub\mailroot folder - is there a similar folder for the .NET client?</p>
<p>EDIT: Here's an example. If I turn off the outgoing SMTP server on my XP computer and th... | [
{
"answer_id": 384128,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": true,
"text": "<p>From the looks of the MSDN pages for SmtpClient, it's configurable. You can use the <a href=\"http://msdn.microsoft.co... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8114/"
] | If I've queued up some email to be sent via the System.Net.Mail.SMTPClent, where can I find this mail? With the Windows SMTP Client, it's in the C:\inetpub\mailroot folder - is there a similar folder for the .NET client?
EDIT: Here's an example. If I turn off the outgoing SMTP server on my XP computer and then run an ... | From the looks of the MSDN pages for SmtpClient, it's configurable. You can use the [DeliveryMethod](http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.deliverymethod.aspx) property to decide whether mail is sent immediately, whether it's queued into the IIS pickup folder (presumably C:\inetpub\mailroot... |
384,124 | <p>Where did the term "caret" originate for a text insertion point? I've tried to google for it, but this is something difficult to locate (even my historic computer reference books don't seem to help here).</p>
<p>I'm reasonably sure I remember some archaic Wang/mainframe apps that used a literal caret (ie: ^) as a ... | [
{
"answer_id": 384130,
"author": "John",
"author_id": 2168,
"author_profile": "https://Stackoverflow.com/users/2168",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://en.wikipedia.org/wiki/Caret\" rel=\"nofollow noreferrer\">Wikipedia</a> says:</p>\n\n<blockquote>\n <p>...... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Where did the term "caret" originate for a text insertion point? I've tried to google for it, but this is something difficult to locate (even my historic computer reference books don't seem to help here).
I'm reasonably sure I remember some archaic Wang/mainframe apps that used a literal caret (ie: ^) as a text insert... | It comes from pen-and-paper text editing, where a ^ mark is used to indicate inserted text. The mark is named for its purpose according to the Latin derivation noted by others. |
384,145 | <p>I have a page structure similar to this:</p>
<pre><code><body>
<div id="parent">
<div id="childRightCol">
/*Content*/
</div>
<div id="childLeftCol">
/*Content*/
</div>
</div>
</body>
</code></pre>
<p>I would like for the parent <code>d... | [
{
"answer_id": 384149,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 5,
"selected": false,
"text": "<p>add a <code>clear:both</code>. assuming that your columns are floating. Depending on how your height is specified pa... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10589/"
] | I have a page structure similar to this:
```
<body>
<div id="parent">
<div id="childRightCol">
/*Content*/
</div>
<div id="childLeftCol">
/*Content*/
</div>
</div>
</body>
```
I would like for the parent `div` to expand in `height` when the inner `div`'s `height` increases.
**Edit:**... | Try this for the parent, it worked for me.
```
overflow:auto;
```
**UPDATE:**
One more solution that worked:
**Parent**:
```
display: table;
```
**Child**:
```
display: table-row;
``` |
384,157 | <p>I am working on a script to send data to a mysql table and I have it all working properly but the success part of the call, it is not loading my results in to my results column on my page. My code is below.</p>
<p>Any suggestions on what I can do to fix that? I am guessing the problem is within my "success:" option... | [
{
"answer_id": 384167,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 0,
"selected": false,
"text": "<p>You might be getting an error try adding a debug statement to your ajax call using the error setting</p>\n\n<pre><code... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on a script to send data to a mysql table and I have it all working properly but the success part of the call, it is not loading my results in to my results column on my page. My code is below.
Any suggestions on what I can do to fix that? I am guessing the problem is within my "success:" option in my AJA... | Questions to ask yourself...
1. Does jQuery even run your success callback?
2. If so is the response data well formed markup?
To begin I would add a "debugger;" statement to your success function (assuming you have firefox and firebug). This will enable you to break into the script console and get a better understand... |
384,184 | <p>I'm trying to setup the MVC development enviroment on my laptop. I'm running WinXP Pro with IIS 5.1</p>
<p>I got the environment setup with the sample MVC application that come with beta. I can only get to the home page. when i try to open About us page. i run into the page can not be found error. Is it the routing... | [
{
"answer_id": 384188,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 1,
"selected": false,
"text": "<p>Your issue is that IIS 5/6 don't play nice with routes without extensions, the home page is resolving because its pointin... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] | I'm trying to setup the MVC development enviroment on my laptop. I'm running WinXP Pro with IIS 5.1
I got the environment setup with the sample MVC application that come with beta. I can only get to the home page. when i try to open About us page. i run into the page can not be found error. Is it the routing not set i... | Your issue is that IIS 5/6 don't play nice with routes without extensions, the home page is resolving because its pointing to default.aspx,
In a nutshell, do this:
>
> If \*.mvc extension is not registered to the hosting , it will give 404 exception. The working way of hosting MVC apps in that case is to modify glo... |
384,189 | <p>I'd like to swap out an sql:query for some Java code that builds a complex query with several parameters. The current sql is a simple select.</p>
<pre>
<sql:query
var="result"
dataSource="${dSource}"
sql="select * from TABLE ">
</sql:query>
</pre>
<p>How do I take my Java ResultSet (ie. rs = stmt.e... | [
{
"answer_id": 384719,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 0,
"selected": false,
"text": "<p>If you're using a web framework like spring mvn or struts, you have a controller class that is executed before the a... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to swap out an sql:query for some Java code that builds a complex query with several parameters. The current sql is a simple select.
```
<sql:query
var="result"
dataSource="${dSource}"
sql="select * from TABLE ">
</sql:query>
```
How do I take my Java ResultSet (ie. rs = stmt.executeQuery(sql);) a... | Model (Row):
```
public class Row {
private String name;
// Add/generate constructor(s), getters and setters.
}
```
DAO:
```
public List<Row> list() throws SQLException {
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
List<Row> rows = new ArrayList<Row... |
384,200 | <p>Forgive me, for I am fairly new to C++, but I am having some trouble regarding operator ambiguity. I think it is compiler-specific, for the code compiled on my desktop. However, it fails to compile on my laptop. I think I know what's going wrong, but I don't see an elegant way around it. Please let me know if I am m... | [
{
"answer_id": 384210,
"author": "Larry Gritz",
"author_id": 3832,
"author_profile": "https://Stackoverflow.com/users/3832",
"pm_score": 1,
"selected": false,
"text": "<p>It's too hard to get rid of the ambiguity. It could easily interpret it as the direct [] access, or cast-to-float* f... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48096/"
] | Forgive me, for I am fairly new to C++, but I am having some trouble regarding operator ambiguity. I think it is compiler-specific, for the code compiled on my desktop. However, it fails to compile on my laptop. I think I know what's going wrong, but I don't see an elegant way around it. Please let me know if I am maki... | This is explained in the book "C++ Templates - The Complete Guide". It's because your operator[] takes size\_t, but you pass a different type which first has to undergo an implicit conversion to size\_t. On the other side, the conversion operator can be chosen too, and then the returned pointer can be subscript. So the... |
384,214 | <p>I have an html page that contains startdate and enddate as user inputs. I need to let the user choose from a calendar for these inputs, instead of requiring the user to type the dates. Can you suggest anything to help?</p>
<p>EDIT:</p>
<p>I have an HTML page:</p>
<pre><code>StartDate: yyyy-mm-dd EndD... | [
{
"answer_id": 384216,
"author": "Vijay Dev",
"author_id": 27474,
"author_profile": "https://Stackoverflow.com/users/27474",
"pm_score": 2,
"selected": false,
"text": "<p>Check this out - <a href=\"http://www.xaprb.com/blog/2005/09/29/javascript-date-chooser/\" rel=\"nofollow noreferrer\... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48094/"
] | I have an html page that contains startdate and enddate as user inputs. I need to let the user choose from a calendar for these inputs, instead of requiring the user to type the dates. Can you suggest anything to help?
EDIT:
I have an HTML page:
```
StartDate: yyyy-mm-dd EndDate: yyyy-mm-dd
```
Currenl... | Check this out - <http://www.xaprb.com/blog/2005/09/29/javascript-date-chooser/>
By the way, you ought to be more clear and specific in asking your question. |
384,220 | <p>I have a crazy navigation menu that I have to code. It's kind of tough. Please see the screenshot of the design here:</p>
<p><a href="https://i.stack.imgur.com/l3U7W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l3U7W.png" alt="nav menu"></a>
</p>
<p><a href="http://i41.tinypic.com/307xfo9.png... | [
{
"answer_id": 384241,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 2,
"selected": false,
"text": "<p>You can use either:</p>\n\n<pre><code>background: transparent;\nbackground: inherit;\n</code></pre>\n\n<p>But... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a crazy navigation menu that I have to code. It's kind of tough. Please see the screenshot of the design here:
[](https://i.stack.imgur.com/l3U7W.png)
[navigation menu screenshot](http://i41.tinypic.com/307xfo9.png)
As you can see, the background of the "Home" m... | You can use either:
```
background: transparent;
background: inherit;
```
But, you'll need to structure your HTML so that the ***Home***, ***Journal***, etc. links are embedded in the box with the background.
---
For rounded corners, [check this out](https://stackoverflow.com/questions/7089/what-is-the-best-way-to... |
384,228 | <p>I'm having some trouble updating a row in a MySQL database. Here is the code I'm trying to run:</p>
<pre><code>import MySQLdb
conn=MySQLdb.connect(host="localhost", user="root", passwd="pass", db="dbname")
cursor=conn.cursor()
cursor.execute("UPDATE compinfo SET Co_num=4 WHERE ID=100")
cursor.execute("SELECT Co_n... | [
{
"answer_id": 384240,
"author": "Zoredache",
"author_id": 20267,
"author_profile": "https://Stackoverflow.com/users/20267",
"pm_score": 7,
"selected": true,
"text": "<p>I am not certain, but I am going to guess you are using a INNODB table, and you haven't done a commit. I believe MySQ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38/"
] | I'm having some trouble updating a row in a MySQL database. Here is the code I'm trying to run:
```
import MySQLdb
conn=MySQLdb.connect(host="localhost", user="root", passwd="pass", db="dbname")
cursor=conn.cursor()
cursor.execute("UPDATE compinfo SET Co_num=4 WHERE ID=100")
cursor.execute("SELECT Co_num FROM compin... | I am not certain, but I am going to guess you are using a INNODB table, and you haven't done a commit. I believe MySQLdb enable transactions automatically.
Call `conn.commit()` before calling `close`.
From the FAQ: [Starting with 1.2.0, MySQLdb disables autocommit by default](http://mysql-python.sourceforge.net/FAQ.h... |
384,262 | <pre><code>var insInvoice = new NpgsqlCommand(
@"INSERT INTO invoice_detail(
invoice_id,
invoice_detail_id,
product_id,
qty,
price,
amount)
VALUES (
:_invoice_id,
:_invoice_detail_id,
:_product_id,
:_qty,
:_price,
:_qty * :_price)", c);
with(var p = insInvoice.P... | [
{
"answer_id": 384274,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 0,
"selected": false,
"text": "<p>I have done something similar:</p>\n\n<pre><code>var insInvoice = new NpgsqlCommand(...);\ninsInvoice.Parameters.With... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11432/"
] | ```
var insInvoice = new NpgsqlCommand(
@"INSERT INTO invoice_detail(
invoice_id,
invoice_detail_id,
product_id,
qty,
price,
amount)
VALUES (
:_invoice_id,
:_invoice_detail_id,
:_product_id,
:_qty,
:_price,
:_qty * :_price)", c);
with(var p = insInvoice.Parameter... | As you've got an "Add" method with the right form, you can use a collection initialiser for the parameters:
```
var insInvoice = new NpgsqlCommand(sql)
{
Parameters =
{
{ "_invoice_id", NpgsqlDbType.Uuid, 0, "invoice_id" },
{ "_invoice_detail_id", NpgsqlDbType.Uuid, 0, "invoice_detail_id" },
... |
384,284 | <p>Is there a way to rename an open file in Emacs? While I'm viewing it? Something like save-as, but the original one should go away.</p>
| [
{
"answer_id": 384346,
"author": "Matt Curtis",
"author_id": 17221,
"author_profile": "https://Stackoverflow.com/users/17221",
"pm_score": 8,
"selected": true,
"text": "<p>Try this function from <a href=\"http://steve.yegge.googlepages.com/my-dot-emacs-file\" rel=\"noreferrer\">Steve Yeg... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | Is there a way to rename an open file in Emacs? While I'm viewing it? Something like save-as, but the original one should go away. | Try this function from [Steve Yegge's .emacs](http://steve.yegge.googlepages.com/my-dot-emacs-file):
```
;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file
(defun rename-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "sNew name: ")
(let ((n... |
384,286 | <p>I'm trying to get:</p>
<pre><code>document.createElement('div') //=> true
{tagName: 'foobar something'} //=> false
</code></pre>
<p>In my own scripts, I used to just use this since I never needed <code>tagName</code> as a property:</p>
<pre><code>if (!object.tagName) throw ...;
</code></pre>
<p>So for th... | [
{
"answer_id": 384301,
"author": "finpingvin",
"author_id": 46054,
"author_profile": "https://Stackoverflow.com/users/46054",
"pm_score": 3,
"selected": false,
"text": "<p>This is from the lovely JavaScript library <a href=\"http://en.wikipedia.org/wiki/MooTools\" rel=\"nofollow noreferr... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15031/"
] | I'm trying to get:
```
document.createElement('div') //=> true
{tagName: 'foobar something'} //=> false
```
In my own scripts, I used to just use this since I never needed `tagName` as a property:
```
if (!object.tagName) throw ...;
```
So for the second object, I came up with the following as a quick solution ... | This might be of interest:
```
function isElement(obj) {
try {
//Using W3 DOM2 (works for FF, Opera and Chrome)
return obj instanceof HTMLElement;
}
catch(e){
//Browsers not supporting W3 DOM2 don't have HTMLElement and
//an exception is thrown and we end up here. Testing some
//properties th... |
384,291 | <p>We have a web application that takes user inputs or database lookups to form some operations against some physical resources. The design can be simply presented as following diagram:</p>
<p>user input <=> model object <=> database storage</p>
<p>validations are needed with request coming from user input but ... | [
{
"answer_id": 384791,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "https://Stackoverflow.com/users/32638",
"pm_score": 1,
"selected": false,
"text": "<p>Doing validation in the constructor really isn't the \"Django way\". Since the data you need to validate is coming... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We have a web application that takes user inputs or database lookups to form some operations against some physical resources. The design can be simply presented as following diagram:
user input <=> model object <=> database storage
validations are needed with request coming from user input but NOT when coming from da... | Doing validation in the constructor really isn't the "Django way". Since the data you need to validate is coming from the client-side, using [new forms](http://docs.djangoproject.com/en/dev/topics/forms/) (probably with a [ModelForm](http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#topics-forms-modelforms)... |
384,294 | <p>While disassembling the .Net Source Code using Reflector, I came upon the Equals implementation in the Object Class and it refers to </p>
<pre><code>bool InternalEquals(object objA, object objB);
</code></pre>
<p>Which again refers to </p>
<pre><code>internal static extern bool InternalEquals(object objA, object ... | [
{
"answer_id": 384296,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 4,
"selected": false,
"text": "<p>It's declared as <code>[MethodImpl(MethodImplOptions.InternalCall)]</code>. It means that it's implemented in the CLR itsel... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45972/"
] | While disassembling the .Net Source Code using Reflector, I came upon the Equals implementation in the Object Class and it refers to
```
bool InternalEquals(object objA, object objB);
```
Which again refers to
```
internal static extern bool InternalEquals(object objA, object objB);
```
I am now confused regard... | It's declared as `[MethodImpl(MethodImplOptions.InternalCall)]`. It means that it's implemented in the CLR itself, as a native procedure, not a .NET assembly.
You can view a similar CLR source code by looking at [Microsoft SSCLI (aka Rotor)](http://www.microsoft.com/downloads/details.aspx?FamilyId=8C09FD61-3F26-4555-A... |
384,304 | <p>How can I create a local user account using .NET 2.0 and c# and also be able to set the "Password never expires" to never. </p>
<p>I have tried using "Net.exe" using Process.Start and passing its parameters but it seems that the "net user" is unable to set the "Password never expires" to never.</p>
| [
{
"answer_id": 384307,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 6,
"selected": true,
"text": "<p>Read this excellent CodeProject article</p>\n\n<p><a href=\"http://www.codeproject.com/KB/system/everythingInAD.aspx\" re... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34623/"
] | How can I create a local user account using .NET 2.0 and c# and also be able to set the "Password never expires" to never.
I have tried using "Net.exe" using Process.Start and passing its parameters but it seems that the "net user" is unable to set the "Password never expires" to never. | Read this excellent CodeProject article
[**Howto: (Almost) Everything In Active Directory via C#**](http://www.codeproject.com/KB/system/everythingInAD.aspx)
There is a section "Create User Account" and "Dealing with User Passwords".
**UPDATE:**
*To adapt the code for local accounts replace the respective lines wit... |
384,306 | <p>I am upgrading an unmanaged C++ application to use the XP/Vista style common controls by adding a manifest. According to MSDN's page on <a href="http://msdn.microsoft.com/en-us/library/aa374191.aspx" rel="nofollow noreferrer">application manifests</a>, you are required to specify the name and version in the manifes... | [
{
"answer_id": 384307,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 6,
"selected": true,
"text": "<p>Read this excellent CodeProject article</p>\n\n<p><a href=\"http://www.codeproject.com/KB/system/everythingInAD.aspx\" re... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25637/"
] | I am upgrading an unmanaged C++ application to use the XP/Vista style common controls by adding a manifest. According to MSDN's page on [application manifests](http://msdn.microsoft.com/en-us/library/aa374191.aspx), you are required to specify the name and version in the manifest, and optionally the description:
```
<... | Read this excellent CodeProject article
[**Howto: (Almost) Everything In Active Directory via C#**](http://www.codeproject.com/KB/system/everythingInAD.aspx)
There is a section "Create User Account" and "Dealing with User Passwords".
**UPDATE:**
*To adapt the code for local accounts replace the respective lines wit... |
384,310 | <p>On a site with a high number of users, should paging be handled in code, or with a stored procedure. If you have employed caching, please include your success factors.</p>
| [
{
"answer_id": 384312,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "<p>Personally, I never page stuff outside SQL Server. I do this at database level as if you have a million records to be paged... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | On a site with a high number of users, should paging be handled in code, or with a stored procedure. If you have employed caching, please include your success factors. | I would do it at database level. Talking about sql server 2005, i would use the new ROW\_NUMBER() function, look at:
[Paging SQL Server 2005 Results](https://stackoverflow.com/questions/2840/paging-sql-server-2005-results)
Where a typical sql would be:
```
SELECT Row_Number() OVER(ORDER BY UserName) As RowID, UserFir... |
384,318 | <p>In any class, how do I explicitly refer to a certain method of my class?</p>
<p>For example, this code works:</p>
<pre><code>class Test : IEnumerable<T> {
public IEnumerator<T> GetEnumerator() { return null; }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
</code></pre>
... | [
{
"answer_id": 384319,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 3,
"selected": true,
"text": "<p>If you use explicit interface implementation, you need to access the method through that interface.</p>\n\n<p>So no... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] | In any class, how do I explicitly refer to a certain method of my class?
For example, this code works:
```
class Test : IEnumerable<T> {
public IEnumerator<T> GetEnumerator() { return null; }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
```
But this one doesn't!
```
class Test : IE... | If you use explicit interface implementation, you need to access the method through that interface.
So no, there is no way other than what you propose in the text.
In this case though you will typically not use explicit implementation for the generic interface.
**Edit**: If the documentation warning is the source of... |
384,324 | <p>I have the following code in my index.html</p>
<pre><code><li>
<select name="cmbtype" style="display:none" id="cmbtype" onChange="Changetype()">
<option value="0">
<input type="image" src="images/ocean.png" value="Play" onclick="previewplay(); " />
</option>
</select>
</li&g... | [
{
"answer_id": 384343,
"author": "jishi",
"author_id": 33663,
"author_profile": "https://Stackoverflow.com/users/33663",
"pm_score": 3,
"selected": false,
"text": "<p>Why do you have the input in your select?</p>\n\n<p>It probably inherits the display: none therefor not getting rendered,... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have the following code in my index.html
```
<li>
<select name="cmbtype" style="display:none" id="cmbtype" onChange="Changetype()">
<option value="0">
<input type="image" src="images/ocean.png" value="Play" onclick="previewplay(); " />
</option>
</select>
</li>
```
In firefox, opera and IE 7 I see the ocean.png ... | Why do you have the input in your select?
It probably inherits the display: none therefor not getting rendered, which I would assume would be the correct behaviour.
Maybe IE, firefox and opera finds it illegal syntax and rewrite the input outside of the select, but webkit does not. |
384,326 | <p>I have been playing around with CSS Style Switching on my blog www.whataboutki.com and have also added Google Friend Connect. I would now like to change the colours of the GFC widget when the user changes styles. This is the script for GFC... the div id="div-1229769625913" does that mean I can access that from my cs... | [
{
"answer_id": 384343,
"author": "jishi",
"author_id": 33663,
"author_profile": "https://Stackoverflow.com/users/33663",
"pm_score": 3,
"selected": false,
"text": "<p>Why do you have the input in your select?</p>\n\n<p>It probably inherits the display: none therefor not getting rendered,... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have been playing around with CSS Style Switching on my blog www.whataboutki.com and have also added Google Friend Connect. I would now like to change the colours of the GFC widget when the user changes styles. This is the script for GFC... the div id="div-1229769625913" does that mean I can access that from my css f... | Why do you have the input in your select?
It probably inherits the display: none therefor not getting rendered, which I would assume would be the correct behaviour.
Maybe IE, firefox and opera finds it illegal syntax and rewrite the input outside of the select, but webkit does not. |
384,336 | <p>I'm trying to pass information to a python page via the url. I have the following link text:</p>
<pre><code>"<a href='complete?id=%s'>" % (str(r[0]))
</code></pre>
<p>on the complete page, I have this:</p>
<pre><code>import cgi
def complete():
form = cgi.FieldStorage()
db = MySQLdb.connect(user="", ... | [
{
"answer_id": 384355,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 1,
"selected": false,
"text": "<p>The error means that <code>form["id"]</code> failed to find the key <code>"id"</code> in <code>cgi.Fiel... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I'm trying to pass information to a python page via the url. I have the following link text:
```
"<a href='complete?id=%s'>" % (str(r[0]))
```
on the complete page, I have this:
```
import cgi
def complete():
form = cgi.FieldStorage()
db = MySQLdb.connect(user="", passwd="", db="todo")
c = db.cursor()
... | The error means that `form["id"]` failed to find the key `"id"` in `cgi.FieldStorage()`.
To test what keys are in the called URL, use [cgi.test()](http://docs.python.org/library/cgi.html#cgi.test):
>
> cgi.test()
>
>
> Robust test CGI script, usable as main program. Writes minimal HTTP headers and formats all info... |
384,392 | <p>still trying to find where i would use the "yield" keyword in a real situation.</p>
<p>I see this thread on the subject </p>
<p><a href="https://stackoverflow.com/questions/39476/what-is-the-yield-keyword-used-for-in-c">What is the yield keyword used for in C#?</a></p>
<p>but in the accepted answer, they have thi... | [
{
"answer_id": 384403,
"author": "Trap",
"author_id": 7839,
"author_profile": "https://Stackoverflow.com/users/7839",
"pm_score": 0,
"selected": false,
"text": "<p>You might want to iterate through various collections:</p>\n\n<pre><code>public IEnumerable<ICustomer> Customers()\n{\... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | still trying to find where i would use the "yield" keyword in a real situation.
I see this thread on the subject
[What is the yield keyword used for in C#?](https://stackoverflow.com/questions/39476/what-is-the-yield-keyword-used-for-in-c)
but in the accepted answer, they have this as an example where someone is it... | If you build and return a List (say it has 1 million elements), that's a big chunk of memory, and also of work to create it.
Sometimes the caller may only want to know what the first element is. Or they might want to write them to a file as they get them, rather than building the whole list in memory and then writing ... |
384,401 | <p>I'm currently trying to implement a class to handle secure communications between instances of my app using RSACrytoServiceProveider class.
First question : is it a good idea implement a single class to handle sender/reciever roles or should i split the roles into individual classes ?. This is what i have done so f... | [
{
"answer_id": 384416,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>I would make the encrypt/sign/decrypt/verify methods take parameters for the data rather than having member variables ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48127/"
] | I'm currently trying to implement a class to handle secure communications between instances of my app using RSACrytoServiceProveider class.
First question : is it a good idea implement a single class to handle sender/reciever roles or should i split the roles into individual classes ?. This is what i have done so far:... | I would make the encrypt/sign/decrypt/verify methods take parameters for the data rather than having member variables for them. Having member variables for the key and provider seems okay though. Basically I'd expect to use the same key multiple times but not the same data.
I'd also make it immutable - make all the va... |
384,419 | <p>I have a list that looks like (A (B (C D)) (E (F))) which represents this tree:</p>
<pre><code> A
/ \
B E
/ \ /
C D F
</code></pre>
<p>How do I print it as (A B E C D F) ?</p>
<p>This is as far as I managed:</p>
<pre><code>((lambda(tree) (loop for ele in tree do (print ele))) my-list)
</c... | [
{
"answer_id": 384582,
"author": "namin",
"author_id": 34596,
"author_profile": "https://Stackoverflow.com/users/34596",
"pm_score": 2,
"selected": false,
"text": "<p>It seems that the way you represent your list is inconsistent. For your example, I imagine it should be: <code>(A ((B (C ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15345/"
] | I have a list that looks like (A (B (C D)) (E (F))) which represents this tree:
```
A
/ \
B E
/ \ /
C D F
```
How do I print it as (A B E C D F) ?
This is as far as I managed:
```
((lambda(tree) (loop for ele in tree do (print ele))) my-list)
```
But it prints:
```
A
(B (C D))
(E (F))
N... | Taking your question at face value, you want to print out the nodes in 'breadth-first' order, rather than using one of the standard, depth-first orderings: 'in-order' or 'pre-order' or 'post-order'.
* in-order: C B D A E F
* pre-order: A B C D E F
* post-order: C D B F E A
* requested order: A B E C D F
In your tree ... |
384,431 | <pre><code>game.h needs:
- packet.h
- socket.h
server.h needs:
- socket.h
socket.h needs:
- game.h
</code></pre>
<p>The problem comes when I try to include socket.h into game.h, because socket.h has game.h included already. How do I solve these kind of problems?</p>
| [
{
"answer_id": 384434,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 5,
"selected": true,
"text": "<p>The usual way, use #ifdef and #define in your header files</p>\n\n<p>inside game.h:</p>\n\n<pre><code>#ifndef GAME_... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
game.h needs:
- packet.h
- socket.h
server.h needs:
- socket.h
socket.h needs:
- game.h
```
The problem comes when I try to include socket.h into game.h, because socket.h has game.h included already. How do I solve these kind of problems? | The usual way, use #ifdef and #define in your header files
inside game.h:
```
#ifndef GAME_H
#define GAME_H
.. rest of your header file here
#endif
```
This way, the contents will be read multiple times, but only defined once.
**Edit**: Removed underscores at start and end of identifier per comments. |
384,442 | <p>I have byte array as input. I would like to convert that array to string that contains hexadecimal representation of array values. This is F# code:</p>
<pre><code>let ByteToHex bytes =
bytes
|> Array.map (fun (x : byte) -> String.Format("{0:X2}", x))
let ConcatArray stringArray = String.Join(null, ... | [
{
"answer_id": 384447,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": -1,
"selected": false,
"text": "<p>To be honest, that doesn't look terrible (although I also have <em>very</em> little F# experience). Does F# offer... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25732/"
] | I have byte array as input. I would like to convert that array to string that contains hexadecimal representation of array values. This is F# code:
```
let ByteToHex bytes =
bytes
|> Array.map (fun (x : byte) -> String.Format("{0:X2}", x))
let ConcatArray stringArray = String.Join(null, (ByteToHex stringAr... | There is nothing inherently wrong with your example. If you'd like to get it down to a single expression then use the String.contcat method.
```
let ByteToHex bytes =
bytes
|> Array.map (fun (x : byte) -> System.String.Format("{0:X2}", x))
|> String.concat System.String.Empty
```
Under the hood, String... |
384,462 | <p>if i have a protected method, can i pass in a parameter where the data type is declared internal?</p>
| [
{
"answer_id": 384464,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>No, unless the type (with the protected member) is itself internal. Internal types cannot be part of a public/prote... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | if i have a protected method, can i pass in a parameter where the data type is declared internal? | No, unless the type (with the protected member) is itself internal. Internal types cannot be part of a public/protected API, as the consumer would have no way of using it.
You could, however, consider using a public interface to abstract the type - i.e.
```
public interface IFoo {}
internal class Foo : IFoo {}
public... |
384,496 | <p>Executing this code:</p>
<pre><code>mainLyr = [[CALayer layer] retain];
[mainLyr setFrame:CGRectMake(0.0,0.0,23.0,23.0)];
</code></pre>
<p>in debugger, I found that after <code>retain</code>, the reference count of <code>mainLyr</code> is 2. This is correct.</p>
<p>But after <code>setFrame</code>, the reference c... | [
{
"answer_id": 384490,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 2,
"selected": false,
"text": "<p>Not an expert, but I hate when characters I choose and not that bizarre are rejected. So, I think I agree with your gut.</p... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47936/"
] | Executing this code:
```
mainLyr = [[CALayer layer] retain];
[mainLyr setFrame:CGRectMake(0.0,0.0,23.0,23.0)];
```
in debugger, I found that after `retain`, the reference count of `mainLyr` is 2. This is correct.
But after `setFrame`, the reference count increased to 3. Why? And how to find out if a method will inc... | Any printable, non-whitespace ASCII character (between 33 and 126 inclusive) are typically allowed in passwords. Many security professionals (and SO commenters) are advising the use of a [passphrase](http://www.iusmentis.com/security/passphrasefaq/) in place of a password, so you'd have to allow spaces. The argument is... |
384,500 | <p>Here is the scenario:<br>
ThickBox is opened from parent window (when button is pressed) with Ajax content (div based form) that contains the set of inputs with autocomplete support. Once ThickBox(form) is closed the input values should be passed to parent window.</p>
<p>Question:<br>
The content of ThickBox is loa... | [
{
"answer_id": 384560,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 3,
"selected": true,
"text": "<p>My prefered option is to investigate other modal plugin options such as <a href=\"http://dev.iceburg.net/jquery/jqModal/... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42512/"
] | Here is the scenario:
ThickBox is opened from parent window (when button is pressed) with Ajax content (div based form) that contains the set of inputs with autocomplete support. Once ThickBox(form) is closed the input values should be passed to parent window.
Question:
The content of ThickBox is loaded dynamica... | My prefered option is to investigate other modal plugin options such as [jqModal](http://dev.iceburg.net/jquery/jqModal/#how). This does expose onShow and onHide event hooks that you can utilise.
Thickbox is showing its age, it does not expose any 'show' events that you can observe.
If you are hell bent on using thic... |
384,502 | <p>Not to long ago, someone told me that <code>long</code> are not 64 bits on 64 bit machines and I should always use <code>int</code>. This did not make sense to me. I have seen docs (such as the one on Apple's official site) say that <code>long</code> are indeed 64 bits when compiling for a 64-bit CPU. I looked up wh... | [
{
"answer_id": 384504,
"author": "PolyThinker",
"author_id": 47707,
"author_profile": "https://Stackoverflow.com/users/47707",
"pm_score": -1,
"selected": false,
"text": "<p>If you need to use integers of certain length, you probably should use some platform independent headers to help y... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Not to long ago, someone told me that `long` are not 64 bits on 64 bit machines and I should always use `int`. This did not make sense to me. I have seen docs (such as the one on Apple's official site) say that `long` are indeed 64 bits when compiling for a 64-bit CPU. I looked up what it was on 64-bit Windows and foun... | In the Unix world, there were a few possible arrangements for the sizes of integers and pointers for 64-bit platforms. The two mostly widely used were ILP64 (actually, only a very few examples of this; Cray was one such) and LP64 (for almost everything else). The acronynms come from 'int, long, pointers are 64-bit' and... |
384,574 | <p>I am trying to figure out a clean way to intercept uncaught exceptions that occur in my application. </p>
<p>I have log4j configured for logging the normal application flow and caught exceptions, so that is taken care of. Right now, I have a class that takes all error-level messages and adds them to a queue to be e... | [
{
"answer_id": 384585,
"author": "kdgregory",
"author_id": 42126,
"author_profile": "https://Stackoverflow.com/users/42126",
"pm_score": 4,
"selected": true,
"text": "<p>Per the J2EE 1.4 spec, uncaught exceptions within a servlet may be forwarded to an error page as defined in the deploy... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13812/"
] | I am trying to figure out a clean way to intercept uncaught exceptions that occur in my application.
I have log4j configured for logging the normal application flow and caught exceptions, so that is taken care of. Right now, I have a class that takes all error-level messages and adds them to a queue to be emailed in ... | Per the J2EE 1.4 spec, uncaught exceptions within a servlet may be forwarded to an error page as defined in the deployment descriptor. When this happens, the page implementation will receive the original request and response objects, with the addition of a request attribute named javax.servlet.error.exception that cont... |
384,583 | <p><strong>Operations:</strong></p>
<p>Delete in DataGridView selected row from Dataset:</p>
<pre><code>FuDataSet.FuRow row = (FuDataSet.FuRow) ((DataRowView)FuBindingSource.Current).Row;
row.Delete();
</code></pre>
<p>To add a new Row I'm doing:</p>
<pre><code>FuDataSet.FuRow row = FuDataSet.Fus.NewFuRow();
row.So... | [
{
"answer_id": 385011,
"author": "NR.",
"author_id": 48142,
"author_profile": "https://Stackoverflow.com/users/48142",
"pm_score": 1,
"selected": false,
"text": "<p>Does your table have an auto increment identity column as the primary key? If so it might not be updating the dataset table... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | **Operations:**
Delete in DataGridView selected row from Dataset:
```
FuDataSet.FuRow row = (FuDataSet.FuRow) ((DataRowView)FuBindingSource.Current).Row;
row.Delete();
```
To add a new Row I'm doing:
```
FuDataSet.FuRow row = FuDataSet.Fus.NewFuRow();
row.Someting = "Some initial Content";
row.SomethingElse = "Mor... | Does your table have an auto increment identity column as the primary key? If so it might not be updating the dataset table with the new value after the insert, so when you come to delete it, it cannot find the row in the database. That could explain why it works once you called the Fill() method.
You will need to so... |
384,592 | <p>I want to use this pattern:</p>
<pre><code>SqlCommand com = new SqlCommand(sql, con);
com.CommandType = CommandType.StoredProcedure;//um
com.CommandTimeout = 120;
//com.Connection = con; //EDIT: per suggestions below
SqlParameter par;
par = new SqlParameter("@id", SqlDbType.Int);
par.Direction = ParameterDirectio... | [
{
"answer_id": 384608,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 3,
"selected": false,
"text": "<p>The Cache itself is thread-safe but that doesn't confer thread-safety on the objects that you place within it. T... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33264/"
] | I want to use this pattern:
```
SqlCommand com = new SqlCommand(sql, con);
com.CommandType = CommandType.StoredProcedure;//um
com.CommandTimeout = 120;
//com.Connection = con; //EDIT: per suggestions below
SqlParameter par;
par = new SqlParameter("@id", SqlDbType.Int);
par.Direction = ParameterDirection.Input;
com.... | I should have asked how to lock an item in ASP.NET cache, instead of saying what I was intending to put in the cache.
```
lock(Cache)
{
// do something with cache that otherwise wouldn't be threadsafe
}
```
Reference: <http://www.codeguru.com/csharp/.net/net_asp/article.php/c5363> |
384,593 | <p>Im trying to save a bitmap jpg format with a specified encoding quality. However im getting an exception ("Parameter is not valid.") when calling the save method.</p>
<p>If i leave out the two last parameters in the bmp.save it works fine.</p>
<pre><code> EncoderParameters eps = new EncoderParameters(1);
... | [
{
"answer_id": 384614,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 6,
"selected": true,
"text": "<p>GDI+ is pretty flaky. You'll need to use 16L for the value or cast to (long).</p>\n"
},
{
"answer_id": 131... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36476/"
] | Im trying to save a bitmap jpg format with a specified encoding quality. However im getting an exception ("Parameter is not valid.") when calling the save method.
If i leave out the two last parameters in the bmp.save it works fine.
```
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = ... | GDI+ is pretty flaky. You'll need to use 16L for the value or cast to (long). |
384,632 | <p>The documentation for <a href="http://msdn.microsoft.com/en-us/library/k3e17y47(VS.80).aspx" rel="nofollow noreferrer">Sort</a> says that Sort will throw an ArgumentException if "The implementation of comparer caused an error during the sort. For example, comparer might not return 0 when comparing an item with itsel... | [
{
"answer_id": 384647,
"author": "Greg Dean",
"author_id": 1200558,
"author_profile": "https://Stackoverflow.com/users/1200558",
"pm_score": 3,
"selected": true,
"text": "<p>The sort algorithm (QuickSort) relies on a predictable IComparer implementation. After a few dozen layers of indi... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38206/"
] | The documentation for [Sort](http://msdn.microsoft.com/en-us/library/k3e17y47(VS.80).aspx) says that Sort will throw an ArgumentException if "The implementation of comparer caused an error during the sort. For example, comparer might not return 0 when comparing an item with itself."
Apart from the example given, can a... | The sort algorithm (QuickSort) relies on a predictable IComparer implementation. After a few dozen layers of indirection in the BCL you end up at this method:
```
public void Sort(T[] keys, int index, int length, IComparer<T> comparer)
{
try
{
...
ArraySortHelper<T>.QuickSort(keys, index, index... |
384,633 | <p>i am new to .net 3.5.
I have a collection of items:</p>
<pre><code>IList<Model> models;
</code></pre>
<p>where</p>
<pre><code>class Model
{
public string Name
{
get;
private set;
}
}
</code></pre>
<p>I would like to get the element, which has the longest name's length.
I tried </p... | [
{
"answer_id": 384649,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>There isn't a built-in way of doing this, unfortunately - but it's really easy to write an extension method to do it.... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40872/"
] | i am new to .net 3.5.
I have a collection of items:
```
IList<Model> models;
```
where
```
class Model
{
public string Name
{
get;
private set;
}
}
```
I would like to get the element, which has the longest name's length.
I tried
```
string maxItem = models.Max<Model>(model => model.Na... | This is how I got it to work. Maybe there's a better way, I'm not sure:
```
decimal de = d.Max(p => p.Name.Length);
Model a = d.First(p => p.Name.Length == de);
``` |
384,639 | <p>The task seems to be pretty easy: how to include a Javascript file in xml-document so that at least Opera and Firefox could actually parse it and execute the code?</p>
| [
{
"answer_id": 384648,
"author": "stalepretzel",
"author_id": 1615,
"author_profile": "https://Stackoverflow.com/users/1615",
"pm_score": -1,
"selected": false,
"text": "<p>A function that should help you is the eval() function. This function will evaluate any string you pass to it as J... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34134/"
] | The task seems to be pretty easy: how to include a Javascript file in xml-document so that at least Opera and Firefox could actually parse it and execute the code? | Add a script stating XHTML namespace, it will run just fine.
```
<xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml"
src="file.js"
type="application/javascript"/>
```
See also
<http://www.ibm.com/developerworks/xml/library/x-ffox3/> |
384,690 | <pre><code> TMyDataList<T: TBaseDatafile, constructor> = class(TObjectList<TBaseDatafile>)
public
constructor Create;
procedure upload(db: TDataSet);
end;
</code></pre>
<p>I read in a blog post (I don't remember where now) that this is the way to declare a generic-based class with a spe... | [
{
"answer_id": 384822,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>The definition of TObjectList<> is:</p>\n\n<pre><code>TObjectList<T: class> = class(TList<T>)\n</co... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32914/"
] | ```
TMyDataList<T: TBaseDatafile, constructor> = class(TObjectList<TBaseDatafile>)
public
constructor Create;
procedure upload(db: TDataSet);
end;
```
I read in a blog post (I don't remember where now) that this is the way to declare a generic-based class with a specific base type for the generic... | The definition of TObjectList<> is:
```
TObjectList<T: class> = class(TList<T>)
```
So you like to do something like:
```
TMyDataList<T: TBaseDatafile> = class(TObjectList<T>)
```
Unfortunately, that won't work. Luckily:
```
TMyDataList<T: class> = class(TObjectList<T>)
```
Works, but that is probably not wha... |
384,721 | <p>I've recently started poking around in Visual Studio 2005, and I'm mucking about in Visual C++. When I double click on a control in the designer, it opens the .h file, which I've understood to be for prototype declarations, and if I put all the guts to the functions in there, I can get my program to work, but I don... | [
{
"answer_id": 384713,
"author": "Greg Dean",
"author_id": 1200558,
"author_profile": "https://Stackoverflow.com/users/1200558",
"pm_score": -1,
"selected": false,
"text": "<p>I suspect just about any type of exception you care to throw. Why would only certain exceptions be allowed?</p>... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48151/"
] | I've recently started poking around in Visual Studio 2005, and I'm mucking about in Visual C++. When I double click on a control in the designer, it opens the .h file, which I've understood to be for prototype declarations, and if I put all the guts to the functions in there, I can get my program to work, but I don't l... | You can get:
* FaultException or derived class (FaultException<T>) if an unhandled exception is thrown by the service implementation.
* CommunicationException if an error occurs communicating with the service.
There may be others but these are the ones you will typically handle. |
384,755 | <p>I use LINQ-to-SQL to load data from a database that has two tables in a one-to-many relationship (one Recipe has many Ingredients).</p>
<p>I load a Recipe and LINQ retrieves Ingredient objects into an EntitySet that is binded into a ListBox.</p>
<p>If I want to delete some Ingredients off a Recipe, I get a "An att... | [
{
"answer_id": 388030,
"author": "Andrew Theken",
"author_id": 32238,
"author_profile": "https://Stackoverflow.com/users/32238",
"pm_score": 0,
"selected": false,
"text": "<p>you need to decouple the save code from the events in your GUI, it seems like you're a little to eager to save th... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48159/"
] | I use LINQ-to-SQL to load data from a database that has two tables in a one-to-many relationship (one Recipe has many Ingredients).
I load a Recipe and LINQ retrieves Ingredient objects into an EntitySet that is binded into a ListBox.
If I want to delete some Ingredients off a Recipe, I get a "An attempt was made to ... | ```
try
{
// Needed for existing records, but will fail for new records
yourLINQDataContext.Ingredients.DeleteOnSubmit(ingredient);
}
catch (Exception)
{
// Swallow
}
yourRecipeObject.Ingredients.Remove(ingredient);
``` |
384,759 | <p>How do I convert a PIL <code>Image</code> back and forth to a NumPy array so that I can do faster pixel-wise transformations than PIL's <code>PixelAccess</code> allows? I can convert it to a NumPy array via:</p>
<pre><code>pic = Image.open("foo.jpg")
pix = numpy.array(pic.getdata()).reshape(pic.size[0], pi... | [
{
"answer_id": 384926,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 10,
"selected": true,
"text": "<p>You're not saying how exactly <code>putdata()</code> is not behaving. I'm assuming you're doing</p>\n<pre><code>>>> ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145/"
] | How do I convert a PIL `Image` back and forth to a NumPy array so that I can do faster pixel-wise transformations than PIL's `PixelAccess` allows? I can convert it to a NumPy array via:
```
pic = Image.open("foo.jpg")
pix = numpy.array(pic.getdata()).reshape(pic.size[0], pic.size[1], 3)
```
But how do I load it back... | You're not saying how exactly `putdata()` is not behaving. I'm assuming you're doing
```
>>> pic.putdata(a)
Traceback (most recent call last):
File "...blablabla.../PIL/Image.py", line 1185, in putdata
self.im.putdata(data, scale, offset)
SystemError: new style getargs format but argument is not a tuple
```
Th... |
384,762 | <p>I used MySQL Workbench to generate a database and now I inserted it into the command-line client using:</p>
<blockquote>
<p>mysql> . C:\Documents and
Settings\kdegroote\My
Documents\School\2008-2009\ICT2
\Gegevensbanken\Labo\Hoofdstuk 3 oef
6\pizzasecondtry.sql</p>
</blockquote>
<p>For some reason, the l... | [
{
"answer_id": 384768,
"author": "derobert",
"author_id": 27727,
"author_profile": "https://Stackoverflow.com/users/27727",
"pm_score": 1,
"selected": false,
"text": "<p>Try <code>use PizzaDelivery</code> before running show tables. You created your tables in the <code>PizzaDelivery</cod... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] | I used MySQL Workbench to generate a database and now I inserted it into the command-line client using:
>
> mysql> . C:\Documents and
> Settings\kdegroote\My
> Documents\School\2008-2009\ICT2
> \Gegevensbanken\Labo\Hoofdstuk 3 oef
> 6\pizzasecondtry.sql
>
>
>
For some reason, the last table won't be accepted.... | You can often get more information from an InnoDB error like this:
```
mysql> SHOW ENGINE INNODB STATUS;
```
The output is long, but among the status output I saw this:
```
------------------------
LATEST FOREIGN KEY ERROR
------------------------
081221 12:02:36 Error in foreign key constraint creation
for table ... |
384,771 | <p>for writing an offline client to the Google Reader service I would like to know how to best sync with the service. </p>
<p>There doesn't seem to be official documentation yet and the best source I found so far is this: <a href="http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI" rel="noreferrer">http://code.goog... | [
{
"answer_id": 995771,
"author": "Fenton",
"author_id": 75525,
"author_profile": "https://Stackoverflow.com/users/75525",
"pm_score": 1,
"selected": false,
"text": "<p>The Google API hasn't yet been released, at which point this answer may change.</p>\n\n<p>Currently, you would have to c... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45867/"
] | for writing an offline client to the Google Reader service I would like to know how to best sync with the service.
There doesn't seem to be official documentation yet and the best source I found so far is this: <http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI>
Now consider this: With the information from above... | To get the latest entries, use the standard from-newest-date-descending download, which will start from the latest entries. You will receive a "continuation" token in the XML result, looking something like this:
```
<gr:continuation>CArhxxjRmNsC</gr:continuation>`
```
Scan through the results, pulling out anything n... |
384,776 | <p>I've seen on the internet quite a few examples of binding a boolean to the Visibility property of a control in XAML. Most of the good examples use a BooleanToVisibiliy converter.</p>
<p>I'd like to just set the Visible property on the control to bind to a System.Windows.Visibility property in the code-behind, but ... | [
{
"answer_id": 384785,
"author": "Craig Shearer",
"author_id": 14537,
"author_profile": "https://Stackoverflow.com/users/14537",
"pm_score": 4,
"selected": true,
"text": "<p>I think the problem is that WPF can't know that your ActionsVisible property has changed since you've not notified... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24841/"
] | I've seen on the internet quite a few examples of binding a boolean to the Visibility property of a control in XAML. Most of the good examples use a BooleanToVisibiliy converter.
I'd like to just set the Visible property on the control to bind to a System.Windows.Visibility property in the code-behind, but it doesn't ... | I think the problem is that WPF can't know that your ActionsVisible property has changed since you've not notified the fact.
Your class will need to implement INotifyPropertyChanged, then in your set method for ActionsVisible you'll need to fire the PropertyChanged event with ActionsVisible as the property name that h... |
384,797 | <p>Firstly, <em>Real World Haskell</em>, which I am reading, says to never use <code>foldl</code> and instead use <code>foldl'</code>. So I trust it. </p>
<p>But I'm hazy on when to use <code>foldr</code> vs. <code>foldl'</code>. Though I can see the structure of how they work differently laid out in front of me, I'm... | [
{
"answer_id": 384802,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": false,
"text": "<p>Their semantics differ so you can't just interchange <code>foldl</code> and <code>foldr</code>. The one folds the ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38803/"
] | Firstly, *Real World Haskell*, which I am reading, says to never use `foldl` and instead use `foldl'`. So I trust it.
But I'm hazy on when to use `foldr` vs. `foldl'`. Though I can see the structure of how they work differently laid out in front of me, I'm too stupid to understand when "which is better." I guess it s... | The recursion for `foldr f x ys` where `ys = [y1,y2,...,yk]` looks like
```
f y1 (f y2 (... (f yk x) ...))
```
whereas the recursion for `foldl f x ys` looks like
```
f (... (f (f x y1) y2) ...) yk
```
An important difference here is that if the result of `f x y` can be computed using only the value of `x`, then ... |
384,809 | <p>I have a mac with a custom PHP 5 install that built from about a year ago. I remember it took all Sunday and I had to compile about 20 times to get it right. The MySQL I have is from entropy and was precompiled.</p>
<p>Now I need to get PDO with the MySQL driver working and the driver is not installed. I tried the ... | [
{
"answer_id": 384893,
"author": "ieure",
"author_id": 45224,
"author_profile": "https://Stackoverflow.com/users/45224",
"pm_score": 4,
"selected": true,
"text": "<p>You're going to need to compile it by hand, instead of via PECL. You'll need to know where your MySQL install is. I don’t ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577/"
] | I have a mac with a custom PHP 5 install that built from about a year ago. I remember it took all Sunday and I had to compile about 20 times to get it right. The MySQL I have is from entropy and was precompiled.
Now I need to get PDO with the MySQL driver working and the driver is not installed. I tried the "pecl inst... | You're going to need to compile it by hand, instead of via PECL. You'll need to know where your MySQL install is. I don’t know about the Entropy packages, but the builds provided by MySQL (which I recommend) install into `/usr/local/mysql`.
```
$ pecl download pdo_mysql
$ tar xzf PDO_MYSQL-1.0.2.tgz
$ cd PDO_MYSQL-1.0... |
384,820 | <p>Is there a way to specify some JavaScript to execute on the OnBlur event of an ASP.NET text box? It seems to me like if I add any event handlers to the TextBox object they will just cause postbacks to the server isntead of doing what I want. Basically, I just want to be able to have the textbox be rendered in this... | [
{
"answer_id": 384826,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 4,
"selected": false,
"text": "<p>In your codebehind, add this:</p>\n\n<pre><code>myTextBox.Attributes.Add(\"onblur\",\"alert('1234');\");\n</code></pre>\n... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] | Is there a way to specify some JavaScript to execute on the OnBlur event of an ASP.NET text box? It seems to me like if I add any event handlers to the TextBox object they will just cause postbacks to the server isntead of doing what I want. Basically, I just want to be able to have the textbox be rendered in this HTML... | Could also go for:
```
<asp:TextBox runat="server" onblur="Javascript:alert('1234');" />
```
if you dont feel like setting it up in the codebehind.
Im guessing the reason why you end up with postbacks, must be because you have set AutoPostBack on the textbox to true. That makes the textbox postback when the client-... |
384,851 | <p>I've been tasked with designing a very simple SSO (single sign-on) process. My employer has specified that it should be implemented in SAML. I'd like to create messages that are absolutely as simple as possible while confirming to the SAML spec. </p>
<p>I'd be really grateful if some of you would look at my request... | [
{
"answer_id": 419221,
"author": "metadaddy",
"author_id": 33905,
"author_profile": "https://Stackoverflow.com/users/33905",
"pm_score": 4,
"selected": false,
"text": "<p>You don't need a Subject in the request - looking at the specs, I think it can be this simple:</p>\n\n<pre><code><... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44683/"
] | I've been tasked with designing a very simple SSO (single sign-on) process. My employer has specified that it should be implemented in SAML. I'd like to create messages that are absolutely as simple as possible while confirming to the SAML spec.
I'd be really grateful if some of you would look at my request and respo... | You don't need a Subject in the request - looking at the specs, I think it can be this simple:
```
<?xml version="1.0" encoding="UTF-8"?>
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
ID="abc" Version="2.0" IssueInstant="1970-01-01T00:00:00.000Z"
</samlp:AuthnRequest>
```
Omitting all the ... |
384,871 | <p>I need to build an assembler for a CPU architecture that I've built. The architecture is similar to MIPS, but this is of no importance.</p>
<p>I started using C#, although C++ would be more appropriate. (C# means faster development time for me).</p>
<p>My only problem is that I can't come with a good design for th... | [
{
"answer_id": 384888,
"author": "Hernán",
"author_id": 48026,
"author_profile": "https://Stackoverflow.com/users/48026",
"pm_score": 3,
"selected": false,
"text": "<p>Look at this Assembler Development Kit from Randy Hyde's author of the famous \"The Art of Assembly Language\":</p>\n\n<... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47117/"
] | I need to build an assembler for a CPU architecture that I've built. The architecture is similar to MIPS, but this is of no importance.
I started using C#, although C++ would be more appropriate. (C# means faster development time for me).
My only problem is that I can't come with a good design for this application. I... | I've written three or four simple assemblers. Without using a parser generator, what I did was model the [S-C assembler](http://stjarnhimlen.se/apple2/) that I knew best for 6502.
To do this, I used a simple syntax - a line was one of the following:
```
nothing
[label] [instruction] [comment]
[label] [directive] [com... |
384,873 | <p>I am looking at some javascript code and it has this in a function:</p>
<pre><code>$$('.CssClass').each(function(x) { .... } )
</code></pre>
<p>I get that the intent is to apply the anonymous function to each element with a class of CssClass, but I can't work what the $$ refers to ... and can't google for $$!</p>... | [
{
"answer_id": 384876,
"author": "Kezzer",
"author_id": 39693,
"author_profile": "https://Stackoverflow.com/users/39693",
"pm_score": 2,
"selected": false,
"text": "<p>Are you looking at a library such as mootools by chance? This is used as a short-hand to certain types of objects by acc... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3631/"
] | I am looking at some javascript code and it has this in a function:
```
$$('.CssClass').each(function(x) { .... } )
```
I get that the intent is to apply the anonymous function to each element with a class of CssClass, but I can't work what the $$ refers to ... and can't google for $$!
**Update**: thanks for the hi... | Probably [this](http://www.prototypejs.org/api/utility#method-%24%24) prototype function:
```
$$(cssRule...) -> [HTMLElement...]
```
>
> Takes an arbitrary number of CSS
> selectors (strings) and returns a
> document-order array of extended DOM
> elements that match any of them.
>
>
>
[http://www.prototypejs... |
384,874 | <p>My problem is very similar to eight queens puzzle.</p>
<p>I've got 2-dimensional array (N x N) that for example, looks like this:</p>
<pre><code>0,0,0,0,1 y
0,0,0,0,0 |
0,0,0,0,0 V
0,0,0,1,0
0,0,0,0,0
x->
</code></pre>
<p>I'm checking horizontally, vertically and diagonally for occurrences of 1</p>
<pre><code... | [
{
"answer_id": 384887,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 5,
"selected": true,
"text": "<p>One possible solution:</p>\n\n<pre><code>def collision(x1, y1, x2, y2):\n return x1 == x2 or y1 == y2 or abs(x1-x2) == abs(... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9099/"
] | My problem is very similar to eight queens puzzle.
I've got 2-dimensional array (N x N) that for example, looks like this:
```
0,0,0,0,1 y
0,0,0,0,0 |
0,0,0,0,0 V
0,0,0,1,0
0,0,0,0,0
x->
```
I'm checking horizontally, vertically and diagonally for occurrences of 1
```
\,0,|,0,/
0,\,|,/,0
-,-,1,-,-
0,/,|,\,0
/,0,|,... | One possible solution:
```
def collision(x1, y1, x2, y2):
return x1 == x2 or y1 == y2 or abs(x1-x2) == abs(y1-y2)
```
i.e. there is a collision if the two points are on the same horizontal row, same vertical row or same diagonal (vertical distance == horizontal distance). |
384,890 | <p><strong>ADDENDUM EDIT:</strong></p>
<blockquote>
<p>Have not accepted an answer to this as
there has not been any feedback from
experienced Spring Framework
developers.</p>
</blockquote>
<p>I've been working on a replacement DSL to use for Spring-Framework applicationContext.xml files (where bean initializ... | [
{
"answer_id": 384892,
"author": "Hernán",
"author_id": 48026,
"author_profile": "https://Stackoverflow.com/users/48026",
"pm_score": 0,
"selected": false,
"text": "<p>Rebuild your project or recompile only the a.cpp file. Warnings are output by the compiler, so you won't get warnings fo... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48048/"
] | **ADDENDUM EDIT:**
>
> Have not accepted an answer to this as
> there has not been any feedback from
> experienced Spring Framework
> developers.
>
>
>
I've been working on a replacement DSL to use for Spring-Framework applicationContext.xml files (where bean initialization and dependency relationships are des... | Essentially, you're out of luck. The C++ compilation will discard all of the errors and warnings. Because it only recompiles .CPP files that have a missing .OBJ file (i.e. the ones that had errors and failed last time), you'll only see the errors.
You have a few options. Off the top of my head:
* Write a macro that r... |
384,913 | <p>I need to work with array from several threads, so I use CRITICAL SECTION to give it an exclusive access to the data.<br>
Here is my template:<br></p>
<pre><code>#include "stdafx.h"
#ifndef SHAREDVECTOR_H
#define SHAREDVECTOR_H
#include <vector>
#include <windows.h>
template<class T>
class Share... | [
{
"answer_id": 384922,
"author": "Arnout",
"author_id": 3496,
"author_profile": "https://Stackoverflow.com/users/3496",
"pm_score": 1,
"selected": false,
"text": "<p><code>EnterCriticalSection</code> doesn't take a <strong>const</strong> argument. That's a compilation error, BTW, not a l... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28298/"
] | I need to work with array from several threads, so I use CRITICAL SECTION to give it an exclusive access to the data.
Here is my template:
```
#include "stdafx.h"
#ifndef SHAREDVECTOR_H
#define SHAREDVECTOR_H
#include <vector>
#include <windows.h>
template<class T>
class SharedVector {
std::vector<T> vect;
... | Just declare `cs` as:
```
mutable CRITICAL_SECTION cs;
```
or else remove the const clause on `size()`
Entering a critical section modifies the `CRITICAL_SECTION`, and leaving modifies it again. Since entering and leaving a critical section doesn't make the `size()` method call logically non-`const`, I'd say leave ... |
384,916 | <p>I'm setting up a site where users have their own "profile". I'm using routes for neat URLs and I wondered what are the pros/cons to the following:</p>
<pre><code>example.com/:username
</code></pre>
<p>Or should I include a static route to filter that it's a profile page request?</p>
<pre><code>example.com/u/:user... | [
{
"answer_id": 384921,
"author": "DanSingerman",
"author_id": 43965,
"author_profile": "https://Stackoverflow.com/users/43965",
"pm_score": 2,
"selected": false,
"text": "<p>I don't think you'd want </p>\n\n<pre><code>example.com/:username\n</code></pre>\n\n<p>as that would put restricti... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31399/"
] | I'm setting up a site where users have their own "profile". I'm using routes for neat URLs and I wondered what are the pros/cons to the following:
```
example.com/:username
```
Or should I include a static route to filter that it's a profile page request?
```
example.com/u/:username
example.com/something-static/:us... | I don't think you'd want
```
example.com/:username
```
as that would put restrictions on the usernames available so as not to clash with other paths under the url.
I would propose
```
profiles.example.com/:username
``` |
384,918 | <p>The following method does not compile. Visual Studio warns "An out parameter may not be used within an anonymous method". The <code>WithReaderLock(Proc action)</code> method takes a <code>delegate void Proc()</code>.</p>
<pre><code>public Boolean TryGetValue(TKey key, out TValue value)
{
Boolean got = false;
... | [
{
"answer_id": 384920,
"author": "Anthony Mastrean",
"author_id": 3619,
"author_profile": "https://Stackoverflow.com/users/3619",
"pm_score": 1,
"selected": false,
"text": "<p>The simple answer is to just copy the logic inside the method. But then we stretch the DRY principle and have to... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619/"
] | The following method does not compile. Visual Studio warns "An out parameter may not be used within an anonymous method". The `WithReaderLock(Proc action)` method takes a `delegate void Proc()`.
```
public Boolean TryGetValue(TKey key, out TValue value)
{
Boolean got = false;
WithReaderLock(delegate
{
... | ```
public bool TryGetValue(TKey key, out TValue value)
{
bool got = false;
TValue tmp = default(TValue); // for definite assignment
WithReaderLock(delegate
{
got = dictionary.TryGetValue(key, out tmp);
});
value = tmp;
return got;
}
```
(edited - small bug)
For info, ... |
384,923 | <p>I have the below query, which basically it retrieves the 5 top most books sold:</p>
<pre><code> select top 5 count(id_book_orddetails) 'books_sold', bk.*
from orderdetails_orddetails ord inner join books_book bk
on ord.id_book_orddetails = bk.id_book
group by id_book, name_book,author_book,desc_book,... | [
{
"answer_id": 384951,
"author": "Jonas Lincoln",
"author_id": 17436,
"author_profile": "https://Stackoverflow.com/users/17436",
"pm_score": 0,
"selected": false,
"text": "<p>First of all, don't use bk.*, use the full column list of the columns you actually need.</p>\n\n<p>I can't answer... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44084/"
] | I have the below query, which basically it retrieves the 5 top most books sold:
```
select top 5 count(id_book_orddetails) 'books_sold', bk.*
from orderdetails_orddetails ord inner join books_book bk
on ord.id_book_orddetails = bk.id_book
group by id_book, name_book,author_book,desc_book,id_ctg_book,qt... | The old PHP "mssql" extension only supports VARCHAR up to 255 bytes in size. This is a known limitation, and it's why Microsoft has been developing a new PHP extension to support modern SQL Server releases.
One workaround is to declare the storage of that column as NVARCHAR, but when you query it from PHP, use CAST to... |
384,927 | <p>So I'm trying to setup a subversion server using mod_dav with apache2 but when I try to connect it gives me a 403 FORBIDDEN error. Here's my default virtual host file</p>
<pre>
NameVirtualHost *:443
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName hcs-dev
DocumentRo... | [
{
"answer_id": 384977,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 1,
"selected": false,
"text": "<p>Check the error log, for every error displayed on your browser there is a matching entry in the log that usually ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29291/"
] | So I'm trying to setup a subversion server using mod\_dav with apache2 but when I try to connect it gives me a 403 FORBIDDEN error. Here's my default virtual host file
```
NameVirtualHost *:443
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName hcs-dev
DocumentRoot /var/ww... | In your follow-up message to Vinko, you state that the error isn't 403, but 401. Most likely, the user entered the incorrect password, or isn't listed in the password file itself, or the password file is missing in the first place. Notice that you use /dig-pw as the password file for non-ssl, and /svn-pw.pw for the ssl... |
384,931 | <p>I'm creating an WPF app, so I'm mostly working with the ImageSource class for icons. However, the system tray icon has to be of type <code>System.Drawing.Icon</code>. Is it possible to create such an object from a png image?</p>
<p>I have tried the following:</p>
<pre><code>private static System.Drawing.Icon _pngI... | [
{
"answer_id": 384989,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 0,
"selected": false,
"text": "<p>You could try a small command line app called <a href=\"http://winterdrache.de/freeware/png2ico/\" rel=\"nofollow no... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4055/"
] | I'm creating an WPF app, so I'm mostly working with the ImageSource class for icons. However, the system tray icon has to be of type `System.Drawing.Icon`. Is it possible to create such an object from a png image?
I have tried the following:
```
private static System.Drawing.Icon _pngIcon;
public static System.Drawin... | I think you can try something like this before convert your image to .ico:
```
var bitmap = new Bitmap("Untitled.png"); // or get it from resource
var iconHandle = bitmap.GetHicon();
var icon = System.Drawing.Icon.FromHandle(iconHandle);
```
Where `icon` will contain the icon which you need. |
384,939 | <p>In Javascript, I want my onmouseout event to sleep/pause/wait/ (not sure of the proper terminology here) for three seconds before taking effect. How is that accomplished?</p>
<p>thanks</p>
| [
{
"answer_id": 384946,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 3,
"selected": true,
"text": "<pre><code>function outfunction(event) {\n var that = this; // to be able to use this later.\n window.setTimeou... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45429/"
] | In Javascript, I want my onmouseout event to sleep/pause/wait/ (not sure of the proper terminology here) for three seconds before taking effect. How is that accomplished?
thanks | ```
function outfunction(event) {
var that = this; // to be able to use this later.
window.setTimeout(function() {
…
/* you can use 'that' here to refer to the element
event is also available in this scope */
}, 3000);
}
``` |
384,974 | <p>Folks,</p>
<p>I have a webservice that returns data in ISO-8859-1 encoding - since it's not mine, I can't change that :-(</p>
<p>For auditing purposes, I'd like to store the resulting XML from these calls into a SQL Server 2005 table, in which I have a field of type "XML NULL".</p>
<p>From my C# code, I try to st... | [
{
"answer_id": 384985,
"author": "Nathan Koop",
"author_id": 18821,
"author_profile": "https://Stackoverflow.com/users/18821",
"pm_score": 1,
"selected": false,
"text": "<p>I found this on google. <a href=\"http://social.msdn.microsoft.com/forums/en-US/sqlxml/thread/d40ef582-4ffe-4f4b-b6... | 2008/12/21 | [
"https://Stackoverflow.com/questions/384974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13302/"
] | Folks,
I have a webservice that returns data in ISO-8859-1 encoding - since it's not mine, I can't change that :-(
For auditing purposes, I'd like to store the resulting XML from these calls into a SQL Server 2005 table, in which I have a field of type "XML NULL".
From my C# code, I try to store this XML content int... | [You need to convert to utf-16](http://blog.stevehorn.cc/2007/07/sql-2005-xml-column-unable-to-switcth.html)
I'm not an expert on XML in SQL Server even though I use it, but we had the same problem last year and it was mis-match of the string datatype declared in SQL compared to the xml being sent. |
385,023 | <p>I haven't written any C++ in years and now I'm trying to get back into it. I then ran across this and thought about giving up:</p>
<pre><code>typedef enum TokenType
{
blah1 = 0x00000000,
blah2 = 0X01000000,
blah3 = 0X02000000
} TokenType;
</code></pre>
<p>What is this? Why is the <code>typedef</c... | [
{
"answer_id": 385029,
"author": "Tim",
"author_id": 10755,
"author_profile": "https://Stackoverflow.com/users/10755",
"pm_score": 3,
"selected": false,
"text": "<p>Holdover from C.</p>\n"
},
{
"answer_id": 385033,
"author": "Ryan Fox",
"author_id": 55,
"author_profil... | 2008/12/21 | [
"https://Stackoverflow.com/questions/385023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36706/"
] | I haven't written any C++ in years and now I'm trying to get back into it. I then ran across this and thought about giving up:
```
typedef enum TokenType
{
blah1 = 0x00000000,
blah2 = 0X01000000,
blah3 = 0X02000000
} TokenType;
```
What is this? Why is the `typedef` keyword used here? Why does the ... | In C, declaring your enum the first way allows you to use it like so:
```
TokenType my_type;
```
If you use the second style, you'll be forced to declare your variable like this:
```
enum TokenType my_type;
```
As mentioned by others, this doesn't make a difference in C++. My guess is that either the person who w... |
385,039 | <p>Bjarne Stroustrup writes in his <a href="http://www.research.att.com/~bs/bs_faq2.html#finally" rel="nofollow noreferrer">C++ Style and Technique FAQ</a>, emphasis mine:</p>
<blockquote>
<p>Because C++ supports an alternative that is <strong><em>almost always better</em></strong>: The "resource acquisition is init... | [
{
"answer_id": 385063,
"author": "Chris Jefferson",
"author_id": 27074,
"author_profile": "https://Stackoverflow.com/users/27074",
"pm_score": 3,
"selected": false,
"text": "<p>Finally would be better when connecting with C code. It can be a pain to have to wrap existing C functionality ... | 2008/12/21 | [
"https://Stackoverflow.com/questions/385039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19100/"
] | Bjarne Stroustrup writes in his [C++ Style and Technique FAQ](http://www.research.att.com/~bs/bs_faq2.html#finally), emphasis mine:
>
> Because C++ supports an alternative that is ***almost always better***: The "resource acquisition is initialization" technique (TC++PL3 section 14.4). The basic idea is to represent ... | The only reason I can think of that a finally block would be "better" is when it takes less code to accomplish the same thing. For example, if you have a resource that, for some reason doesn't use RAII, you would either need to write a class to wrap the resource and free it in the destructor, or use a finally block (if... |
385,042 | <p>I'm a MySQL guy working on a SQL Server project, trying to get a datetime field to show the current time. In MySQL I'd use NOW() but it isn't accepting that.</p>
<pre><code>INSERT INTO timelog (datetime_filed) VALUES (NOW())
</code></pre>
| [
{
"answer_id": 385051,
"author": "Daniel Schaffer",
"author_id": 2596,
"author_profile": "https://Stackoverflow.com/users/2596",
"pm_score": 9,
"selected": true,
"text": "<p><code>getdate()</code> or <code>getutcdate()</code>.</p>\n"
},
{
"answer_id": 385133,
"author": "Ian V... | 2008/12/21 | [
"https://Stackoverflow.com/questions/385042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | I'm a MySQL guy working on a SQL Server project, trying to get a datetime field to show the current time. In MySQL I'd use NOW() but it isn't accepting that.
```
INSERT INTO timelog (datetime_filed) VALUES (NOW())
``` | `getdate()` or `getutcdate()`. |
385,052 | <p>Hi I need some help with the following scenario in php. I have a db with users every user has an ID, have_card and want_card. I know how to make a direct match (one user trades with another user). But if there is no direct match but there is a circular swap like:</p>
<p>User #1 has card A wants card B</p>
<p>User ... | [
{
"answer_id": 385062,
"author": "Alex Renz",
"author_id": 48188,
"author_profile": "https://Stackoverflow.com/users/48188",
"pm_score": 1,
"selected": false,
"text": "<p>This is how I would do it: \nCreate a recursive algorithm like this:</p>\n\n<p>1 take one user, see what he wants</p>... | 2008/12/21 | [
"https://Stackoverflow.com/questions/385052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Hi I need some help with the following scenario in php. I have a db with users every user has an ID, have\_card and want\_card. I know how to make a direct match (one user trades with another user). But if there is no direct match but there is a circular swap like:
User #1 has card A wants card B
User #2 has card B w... | This is a challenging scenario. I had to build this for a book swapping application a while back and using a white board I was able to more easily visual and solve the problem.
What I did was use the same table inside the query multiple times, just using a different name.
In my scenario, the books that were needed w... |
385,061 | <p>I have an NSAttributedString <code>s</code> and an integer <code>i</code> and I'd like a function that takes <code>s</code> and <code>i</code> and returns a new NSAttributedString that has a (stringified) <code>i</code> prepended to <code>s</code>.</p>
<p>It looks like some combination of <code>-stringWithFormat:</... | [
{
"answer_id": 385097,
"author": "jm.",
"author_id": 48199,
"author_profile": "https://Stackoverflow.com/users/48199",
"pm_score": 2,
"selected": false,
"text": "<p>Pointers here: <a href=\"http://developer.apple.com/documentation/Cocoa/Conceptual/AttributedStrings/AttributedStrings.html... | 2008/12/21 | [
"https://Stackoverflow.com/questions/385061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | I have an NSAttributedString `s` and an integer `i` and I'd like a function that takes `s` and `i` and returns a new NSAttributedString that has a (stringified) `i` prepended to `s`.
It looks like some combination of `-stringWithFormat:`, `-initWithString:`, and `-insertAttributedString:` would do it but I'm having tr... | Here's a one-liner for it, thanks to the friendly people on the adium developers' IRC channel. It takes an `NSAttributedString s` and an integer `i`.
```
return [[[NSMutableAttributedString alloc]
initWithString:[NSString stringWithFormat:@"%i %@", i, [s string]]]
autorelease];
``` |
385,082 | <p>I was working on a project that missbehaved, for some reasons no exception was thrown even when it should have. Deep down I have found this kind of error handling:</p>
<pre><code>try {
m.invoke(parentObject, paramObj);
} catch (IllegalArgumentException e) {
new CaseLibException(e);
} catch (IllegalAccessExc... | [
{
"answer_id": 385085,
"author": "Joshua",
"author_id": 14768,
"author_profile": "https://Stackoverflow.com/users/14768",
"pm_score": 2,
"selected": false,
"text": "<p>Not actually initializing some stack variable near the start of main. The thing would get zeroed automatically, well <I>... | 2008/12/21 | [
"https://Stackoverflow.com/questions/385082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48181/"
] | I was working on a project that missbehaved, for some reasons no exception was thrown even when it should have. Deep down I have found this kind of error handling:
```
try {
m.invoke(parentObject, paramObj);
} catch (IllegalArgumentException e) {
new CaseLibException(e);
} catch (IllegalAccessException e) {
... | I fixed a bug once where the application crashed every day at 6:12pm.
Turned out that someone had stored the number of seconds since the start of the day in a 16bit int. |
385,095 | <p>I have a samba network share on a FreeBSD box that I use for development.</p>
<p>I have it set up as a shared drive on my WinXP box, and it works fine.</p>
<p>However, if I reboot the xp box, the shared drive will not be accessible until I click on it and enter the password, even though I have set it to use the co... | [
{
"answer_id": 386212,
"author": "Grey Panther",
"author_id": 1265,
"author_profile": "https://Stackoverflow.com/users/1265",
"pm_score": 2,
"selected": false,
"text": "<p>To force authentication on startup, run \"net use\" (by putting a link in the startup folder for example). Ie:</p>\n... | 2008/12/21 | [
"https://Stackoverflow.com/questions/385095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27580/"
] | I have a samba network share on a FreeBSD box that I use for development.
I have it set up as a shared drive on my WinXP box, and it works fine.
However, if I reboot the xp box, the shared drive will not be accessible until I click on it and enter the password, even though I have set it to use the correct username an... | to get it to map on startup, you can put this in a batch file
```
@echo off
NET USE \\computer\share "password" /USER:user
```
hide it somewhere... I couldn't find a way to get the literal credentials out of the net use string either..
then go into Start->Run->Regedit and find this key
```
\HKEY_CURRENT_USER\Softw... |
385,098 | <p>I am trying to read CSS selectors in my stylesheets with the <code>document.styleSheets</code> array. It works fine with <code><link></code> and <code><style></code> tags, but when I use <code>@import</code> inside a <code><style></code> it doesn't show up in the array - only as a cssRule (style is... | [
{
"answer_id": 385104,
"author": "Christoph",
"author_id": 48015,
"author_profile": "https://Stackoverflow.com/users/48015",
"pm_score": 5,
"selected": true,
"text": "<p>Assuming that our document contains an @import-rule as first rule in the first stylesheet, here's the code for standar... | 2008/12/21 | [
"https://Stackoverflow.com/questions/385098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27741/"
] | I am trying to read CSS selectors in my stylesheets with the `document.styleSheets` array. It works fine with `<link>` and `<style>` tags, but when I use `@import` inside a `<style>` it doesn't show up in the array - only as a cssRule (style is "Undefined" in Safari 3 and FF 3).
So: How can I parse the css in an @impo... | Assuming that our document contains an @import-rule as first rule in the first stylesheet, here's the code for standards compliant browsers
```
document.styleSheets[0].cssRules[0].styleSheet.cssRules;
```
and the special case for our all-beloved IE
```
document.styleSheets[0].imports[0].rules;
```
You could have ... |