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 |
|---|---|---|---|---|---|---|
134,127 | <p>I've created a VB 2008 program to track work requests. It all works perfectly on a VISTA box, but I am having an issue with the program on an XP environment with adding new records.</p>
<p>Basically I've got 2 tabs: TAB 1 holds a datagridview with limited info and a calendar. Selecting dates on the calendar chan... | [
{
"answer_id": 146849,
"author": "alexmac",
"author_id": 23066,
"author_profile": "https://Stackoverflow.com/users/23066",
"pm_score": 0,
"selected": false,
"text": "<p>If the code is exactly the same I wonder if it is an environment issue e.g. something like different international opti... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've created a VB 2008 program to track work requests. It all works perfectly on a VISTA box, but I am having an issue with the program on an XP environment with adding new records.
Basically I've got 2 tabs: TAB 1 holds a datagridview with limited info and a calendar. Selecting dates on the calendar change the info i... | This is definitely an environmental issue. To solve the problem I would need to know which browsers you are using on each machine and some of the settings on each.
It **sounds** like the XP machine is refreshing the page after a timeout period and therefore munging the new record. I have seen that happen before and i... |
134,131 | <p>I've recently installed the MVC CTP5 and VS is now crashing on me when I try to open an aspx, I get the following error in event viewer:</p>
<pre><code>.NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (7A035E00) (80131506)
</code></pre>
<p>I was able to find <a href="http://forums.asp.net/t/1313452... | [
{
"answer_id": 134143,
"author": "alex",
"author_id": 19268,
"author_profile": "https://Stackoverflow.com/users/19268",
"pm_score": 2,
"selected": false,
"text": "<p>Here are a steps to work around from <strong>the post</strong> that work for me:</p>\n\n<p>1.Open project based on CTP5</p... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12707/"
] | I've recently installed the MVC CTP5 and VS is now crashing on me when I try to open an aspx, I get the following error in event viewer:
```
.NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (7A035E00) (80131506)
```
I was able to find [This](http://forums.asp.net/t/1313452.aspx) post on the asp.net... | I had a problem with Power Commands and Preview 5. If you have Power Commands installed, try updating or uninstalling it to fix the issue. |
134,161 | <p>I want to create a class which implements IEnumerable<T> but, using reflection, generates T's and returns them via IEnumerable<T>, where T' is a entirely constructed subclass of T with some properties hidden and others read-only. </p>
<p>Okay., that might not be very clear. Let me explain this via the... | [
{
"answer_id": 134318,
"author": "Gilligan",
"author_id": 12356,
"author_profile": "https://Stackoverflow.com/users/12356",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://www.castleproject.org/dynamicproxy/index.html\" rel=\"nofollow noreferrer\">Castle.DynamicProxy</a> w... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] | I want to create a class which implements IEnumerable<T> but, using reflection, generates T's and returns them via IEnumerable<T>, where T' is a entirely constructed subclass of T with some properties hidden and others read-only.
Okay., that might not be very clear. Let me explain this via the medium of code - I'd li... | [Castle.DynamicProxy](http://www.castleproject.org/dynamicproxy/index.html) will help you accomplish this.
What you would do is create an interceptor that inherits T. You would store the collection of hidden and read-only properties. When a getter or setter is called, the interceptor would check to see if the property... |
134,182 | <p>Here's the code that I'm attempting to do:</p>
<pre><code>public IList<IOperator> GetAll()
{
using (var c = new MyDataContext())
{
return c.Operators.ToList();
}
}
</code></pre>
<p>Operator implements IOperator, but I'm getting the following compilation error:</p>
<pre><code>Cann... | [
{
"answer_id": 134268,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 3,
"selected": false,
"text": "<p>Try the <code>Cast<>()</code> method:</p>\n\n<pre><code>return c.Operators.Cast<IOperator>().ToList();\n</code>... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11097/"
] | Here's the code that I'm attempting to do:
```
public IList<IOperator> GetAll()
{
using (var c = new MyDataContext())
{
return c.Operators.ToList();
}
}
```
Operator implements IOperator, but I'm getting the following compilation error:
```
Cannot implicitly convert type 'System.Collecti... | Try the `Cast<>()` method:
```
return c.Operators.Cast<IOperator>().ToList();
``` |
134,214 | <p>Right now, I have code that looks something like this:</p>
<pre><code>Private Sub ShowReport(ByVal reportName As String)
Select Case reportName
Case "Security"
Me.ShowSecurityReport()
Case "Configuration"
Me.ShowConfigurationReport()
Case "RoleUsers"
M... | [
{
"answer_id": 134225,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 2,
"selected": false,
"text": "<p>You could use reflection to do this but to be honest I think it's overcomplicating things for your particular scenario i.e. cod... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/681/"
] | Right now, I have code that looks something like this:
```
Private Sub ShowReport(ByVal reportName As String)
Select Case reportName
Case "Security"
Me.ShowSecurityReport()
Case "Configuration"
Me.ShowConfigurationReport()
Case "RoleUsers"
Me.ShowRoleUser... | ```
Type type = GetType();
MethodInfo method = type.GetMethod("Show"+reportName+"Report");
if (method != null)
{
method.Invoke(this, null);
}
```
This is C#, should be easy enough to turn it into VB. If you need to pass parameter into the method, they can be added in the 2nd argument to Invoke. |
134,224 | <p>This code produces a FileNotFoundException, but ultimately runs without issue:</p>
<pre><code>void ReadXml()
{
XmlSerializer serializer = new XmlSerializer(typeof(MyClass));
//...
}
</code></pre>
<p>Here is the exception:</p>
<hr>
<p>A first chance exception of type 'System.IO.FileNotFoundException' occu... | [
{
"answer_id": 134273,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 1,
"selected": false,
"text": "<p>Look in the properties on the solution. On the build tab at the bottom there is a dropdown called \"Generate Serializatio... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] | This code produces a FileNotFoundException, but ultimately runs without issue:
```
void ReadXml()
{
XmlSerializer serializer = new XmlSerializer(typeof(MyClass));
//...
}
```
Here is the exception:
---
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional i... | This is how I managed to do it by modifying the MSBUILD script in my .CSPROJ file:
First, open your .CSPROJ file as a file rather than as a project. Scroll to the bottom of the file until you find this commented out code, just before the close of the Project tag:
```
<!-- To modify your build process, add your task ... |
134,251 | <p>I have a basic C# console application that reads a text file (CSV format) line by line and puts the data into a HashTable. The first CSV item in the line is the key (id num) and the rest of the line is the value. However I've discovered that my import file has a few duplicate keys that it shouldn't have. When I try ... | [
{
"answer_id": 134283,
"author": "Dror Helper",
"author_id": 11361,
"author_profile": "https://Stackoverflow.com/users/11361",
"pm_score": 2,
"selected": false,
"text": "<p>A better solution is to call ContainsKey to check if the key exist before adding it to the hash table instead. Thro... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8664/"
] | I have a basic C# console application that reads a text file (CSV format) line by line and puts the data into a HashTable. The first CSV item in the line is the key (id num) and the rest of the line is the value. However I've discovered that my import file has a few duplicate keys that it shouldn't have. When I try to ... | ```
if (myHashtable.ContainsKey(key))
duplicates.Add(key);
else
myHashtable.Add(key, value);
``` |
134,344 | <p>Is there a way to retrieve the time zone choices in Windows Mobile in order to display them in a GUI? It would be much better not to have to show every 15 minutes just to be
able to display GMT+5:45 for Kathmandu.</p>
| [
{
"answer_id": 135540,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 0,
"selected": false,
"text": "<p>Windows Mobile stores timezone info in a <a href=\"http://msdn.microsoft.com/en-us/library/aa458853.aspx\" rel=\"nofollo... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a way to retrieve the time zone choices in Windows Mobile in order to display them in a GUI? It would be much better not to have to show every 15 minutes just to be
able to display GMT+5:45 for Kathmandu. | As per [MSDN:City List and Time Zone Data Files](http://msdn.microsoft.com/en-us/library/aa458853.aspx),
>
> You can add or remove content to these
> files. You can redistribute these
> files as is or repackage this data by
> including it in source code, a
> database, or another format. You are
> permitted to u... |
134,374 | <p>I would like to listen to method calls.</p>
<p>For example, when an element is appended by anything to the document, I would like to be passed that element to act on it, like:</p>
<p>//somewhere</p>
<pre><code>aParent.appendChild(aChild);
</code></pre>
<p>//when the former, a function I defined as listener is ca... | [
{
"answer_id": 134420,
"author": "Filini",
"author_id": 21162,
"author_profile": "https://Stackoverflow.com/users/21162",
"pm_score": 1,
"selected": false,
"text": "<p>don't know if that's possible with the core functions, but you could always create your own functions, for the actions y... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to listen to method calls.
For example, when an element is appended by anything to the document, I would like to be passed that element to act on it, like:
//somewhere
```
aParent.appendChild(aChild);
```
//when the former, a function I defined as listener is called with the `aChild` as argument
Does... | don't know if that's possible with the core functions, but you could always create your own functions, for the actions you want to monitor:
```
function AppendChild(oParent, oChild) {
// your stuff on oParent
// append oChild
oParent.appendChild(oChild)
}
```
or, maybe, modify the actual appendChild(), b... |
134,379 | <p>Is it possible to do a <code>SELECT</code> statement with a predetermined order, ie. selecting IDs 7,2,5,9 and 8 <strong>and returning them in that order</strong>, based on nothing more than the ID field?</p>
<p>Both these statements return them in the same order: </p>
<pre><code>SELECT id FROM table WHERE id in (... | [
{
"answer_id": 134391,
"author": "Teifion",
"author_id": 1384652,
"author_profile": "https://Stackoverflow.com/users/1384652",
"pm_score": 0,
"selected": false,
"text": "<p>All ordering is done by the ORDER BY keywords, you can only however sort ascending and descending. If you are using... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21716/"
] | Is it possible to do a `SELECT` statement with a predetermined order, ie. selecting IDs 7,2,5,9 and 8 **and returning them in that order**, based on nothing more than the ID field?
Both these statements return them in the same order:
```
SELECT id FROM table WHERE id in (7,2,5,9,8)
```
```
SELECT id FROM table WH... | I didn't think this was possible, but found a [blog entry here](http://www.handgestrickt.biz/item/21/) that seems to do the type of thing you're after:
```
SELECT id FROM table WHERE id in (7,2,5,9,8)
ORDER BY FIND_IN_SET(id,"7,2,5,9,8");
```
will give different results to
```
SELECT id FROM table WHERE id in (7,2... |
134,387 | <p>I have a Pylons app where I would like to move some of the logic to a separate batch process. I've been running it under the main app for testing, but it is going to be doing a lot of work in the database, and I'd like it to be a separate process that will be running in the background constantly. The main pylons... | [
{
"answer_id": 135290,
"author": "Douglas Mayle",
"author_id": 8458,
"author_profile": "https://Stackoverflow.com/users/8458",
"pm_score": 2,
"selected": true,
"text": "<p>I'm redacting my response and upvoting the other answer by Ben Bangert, as it's the correct one. I answered and hav... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1566663/"
] | I have a Pylons app where I would like to move some of the logic to a separate batch process. I've been running it under the main app for testing, but it is going to be doing a lot of work in the database, and I'd like it to be a separate process that will be running in the background constantly. The main pylons app wi... | I'm redacting my response and upvoting the other answer by Ben Bangert, as it's the correct one. I answered and have since learned the correct way (mentioned below). If you really want to, check out the history of this answer to see the wrong (but working) solution I originally proposed. |
134,392 | <p>I have a form in which people will be entering dollar values.</p>
<p>Possible inputs:<br>
$999,999,999.99<br>
999,999,999.99<br>
999999999<br>
99,999<br>
$99,999<br></p>
<p>The user can enter a dollar value however they wish. I want to read the inputs as doubles so I can total them.</p>
<p>I tried just typecastin... | [
{
"answer_id": 134402,
"author": "tim_yates",
"author_id": 6509,
"author_profile": "https://Stackoverflow.com/users/6509",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://p2p.wrox.com/topic.asp?TOPIC_ID=3099\" rel=\"nofollow noreferrer\">http://p2p.wrox.com/topic.asp?TOPIC... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16292/"
] | I have a form in which people will be entering dollar values.
Possible inputs:
$999,999,999.99
999,999,999.99
999999999
99,999
$99,999
The user can enter a dollar value however they wish. I want to read the inputs as doubles so I can total them.
I tried just typecasting the strings to doubles but th... | A regex won't convert your string into a number. I would suggest that you use a regex to validate the field (confirm that it fits one of your allowed formats), and then just loop over the string, discarding all non-digit and non-period characters. If you don't care about validation, you could skip the first step. The s... |
134,453 | <p>Are there any tools available to log the page load time for a php site?</p>
<p>Mainly looking for something that I can see trends of load times over time, I was considering dumping them into a file using error_log(), but I don't know what I could use to parse it and display graphs</p>
| [
{
"answer_id": 134491,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 2,
"selected": false,
"text": "<p>Use the Firebug extension for Firefox, it has a Net panel that shows you load times. </p>\n\n<p>If you want t... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Are there any tools available to log the page load time for a php site?
Mainly looking for something that I can see trends of load times over time, I was considering dumping them into a file using error\_log(), but I don't know what I could use to parse it and display graphs | You can record the microtime at the start of execution, hold that variable until the end, check the time, subtract them, and there you have your execution time. Output buffering will be required to make this work in most cases, unless it's a situation in which a particular thing always runs last (like `footer()`).
```... |
134,456 | <p>This</p>
<pre><code>SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE '%some_value%';
</code></pre>
<p>is slower than this</p>
<pre><code>SELECT * FROM SOME_TABLE WHERE SOME_FIELD = 'some_value';
</code></pre>
<p>but what about this?</p>
<pre><code>SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE 'some_value';
</cod... | [
{
"answer_id": 134472,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 3,
"selected": false,
"text": "<p>Check out the <a href=\"http://www.adp-gmbh.ch/ora/explainplan.html\" rel=\"nofollow noreferrer\">EXPLAIN PLAN</a> for both... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | This
```
SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE '%some_value%';
```
is slower than this
```
SELECT * FROM SOME_TABLE WHERE SOME_FIELD = 'some_value';
```
but what about this?
```
SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE 'some_value';
```
My testing indicates the second and third examples are exac... | There is a clear difference when you use bind variables, which you should be using in Oracle for anything other than data warehousing or other bulk data operations.
Take the case of:
```
SELECT * FROM SOME_TABLE WHERE SOME_FIELD LIKE :b1
```
Oracle cannot know that the value of :b1 is '%some\_value%', or 'some\_val... |
134,463 | <p>I am using a popup menu in Delphi. I want to use it in a "radio group" fashion where if the user selects an item it is checked and the other items are not checked. I tried using the AutoCheck property, but this allows multiple items to be checked. Is there a way to set the popup menu so that only one item can be ... | [
{
"answer_id": 134583,
"author": "JosephStyons",
"author_id": 672,
"author_profile": "https://Stackoverflow.com/users/672",
"pm_score": 4,
"selected": true,
"text": "<p>Zartog is right, but if you want to keep the checkbox, assign this event to every item in the popup menu.</p>\n\n<p>Not... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12833/"
] | I am using a popup menu in Delphi. I want to use it in a "radio group" fashion where if the user selects an item it is checked and the other items are not checked. I tried using the AutoCheck property, but this allows multiple items to be checked. Is there a way to set the popup menu so that only one item can be checke... | Zartog is right, but if you want to keep the checkbox, assign this event to every item in the popup menu.
Note that this code is a little hairy looking because it does not depend on knowing the name of your popup menu (hence, looking it up with "GetParentComponent").
```
procedure TForm2.OnPopupItemClick(Sender: TObj... |
134,470 | <p>I have two controllers which share most of their code (but must be, nonetheless, different controllers). The obvious solution (to me, at least) is to create a class, and make the two controllers inherit from it. The thing is... where to put it? Now I have it in app_controller.php, but it's kind of messy there.</p>
| [
{
"answer_id": 134504,
"author": "tyshock",
"author_id": 16448,
"author_profile": "https://Stackoverflow.com/users/16448",
"pm_score": 4,
"selected": true,
"text": "<p>In cake, components are used to store logic that can be used by multiple controllers. The directory is /app/controllers... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18396/"
] | I have two controllers which share most of their code (but must be, nonetheless, different controllers). The obvious solution (to me, at least) is to create a class, and make the two controllers inherit from it. The thing is... where to put it? Now I have it in app\_controller.php, but it's kind of messy there. | In cake, components are used to store logic that can be used by multiple controllers. The directory is /app/controllers/components. For instance, if you had some sharable utility logic, you would have an object called UtilComponent and a file in /app/controlers/components called UtilComponent.php.
```
<?php
class Uti... |
134,481 | <p>What I have now (which successfully loads the plug-in) is this:</p>
<pre><code>Assembly myDLL = Assembly.LoadFrom("my.dll");
IMyClass myPluginObject = myDLL.CreateInstance("MyCorp.IMyClass") as IMyClass;
</code></pre>
<p>This only works for a class that has a constructor with no arguments. How do I pass in an argu... | [
{
"answer_id": 134484,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 2,
"selected": false,
"text": "<p>You can with <a href=\"http://msdn.microsoft.com/en-us/library/wcxyzt4d.aspx\" rel=\"nofollow noreferrer\">Activator.Crea... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22252/"
] | What I have now (which successfully loads the plug-in) is this:
```
Assembly myDLL = Assembly.LoadFrom("my.dll");
IMyClass myPluginObject = myDLL.CreateInstance("MyCorp.IMyClass") as IMyClass;
```
This only works for a class that has a constructor with no arguments. How do I pass in an argument to a constructor? | You cannot. Instead use [Activator.CreateInstance](http://msdn.microsoft.com/en-us/library/wcxyzt4d.aspx) as shown in the example below (note that the Client namespace is in one DLL and the Host in another. Both must be found in the same directory for code to work.)
However, if you want to create a truly pluggable int... |
134,492 | <p>I am able to serialize an object into a file and then restore it again as is shown in the next code snippet. I would like to serialize the object into a string and store into a database instead. Can anyone help me?</p>
<pre><code>LinkedList<Diff_match_patch.Patch> patches = // whatever...
FileOutputStream fil... | [
{
"answer_id": 134525,
"author": "Tim Frey",
"author_id": 1471,
"author_profile": "https://Stackoverflow.com/users/1471",
"pm_score": 4,
"selected": false,
"text": "<p>How about writing the data to a ByteArrayOutputStream instead of a FileOutputStream?</p>\n\n<p>Otherwise, you could seri... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | I am able to serialize an object into a file and then restore it again as is shown in the next code snippet. I would like to serialize the object into a string and store into a database instead. Can anyone help me?
```
LinkedList<Diff_match_patch.Patch> patches = // whatever...
FileOutputStream fileStream = new FileOu... | Sergio:
You should use [BLOB](http://docs.oracle.com/javase/6/docs/api/java/sql/Blob.html). It is pretty straighforward with JDBC.
The problem with the second code you posted is the encoding. You should additionally encode the bytes to make sure none of them fails.
If you still want to write it down into a String y... |
134,501 | <p>Usually when I need to fork in C, I do something like this:</p>
<pre><code>pid_t p = fork();
if(p == 0) { /* do child stuff */ }
else { /* do parent stuff and pray there wasn't an error */ }
</code></pre>
<p>It occured to me that I could ditch the extra variable and use:</p>
<pre><code>if(fork() == 0) { /* child ... | [
{
"answer_id": 134528,
"author": "jj33",
"author_id": 430,
"author_profile": "https://Stackoverflow.com/users/430",
"pm_score": 2,
"selected": false,
"text": "<p>You lose the child process ID in the parent, which is what is returned to the parent. I think you could recover that informat... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12926/"
] | Usually when I need to fork in C, I do something like this:
```
pid_t p = fork();
if(p == 0) { /* do child stuff */ }
else { /* do parent stuff and pray there wasn't an error */ }
```
It occured to me that I could ditch the extra variable and use:
```
if(fork() == 0) { /* child */ }
else { /* parent/pray */ }
```
... | What you are suggesting will certainly work. However, error handling is not optional in any well-behaved application. The following implementation pattern is similarly succinct and also handles errors. Furthermore, it saves the fork() return value in the pid variable, in case you want to use it later in the parent to, ... |
134,505 | <p>I've found mention of a data application block existing for ODBC, but can't seem to find it anywhere. If i didn't have a copy of the Access DB application block I wouldn't believe it ever existed either.</p>
<p>Anyone know where to download either the DLL or the code-base from?</p>
<p>--UPDATE: It is NOT include... | [
{
"answer_id": 134521,
"author": "ScaleOvenStove",
"author_id": 12268,
"author_profile": "https://Stackoverflow.com/users/12268",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://www.microsoft.com/downloads/details.aspx?FamilyId=F63D1F0A-9877-4A7B-88EC-0426B48DF275&disp... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1795/"
] | I've found mention of a data application block existing for ODBC, but can't seem to find it anywhere. If i didn't have a copy of the Access DB application block I wouldn't believe it ever existed either.
Anyone know where to download either the DLL or the code-base from?
--UPDATE: It is NOT included in either the v1,... | Which version of .net are you interested in using the ODBC block on?
The Enterprise library has a Data Access component. It is useful on SQL, Oracle, and ODBC. Just set a different provider name in the .config file
EX:
<add name="MyConnection" connectionString="Dsn=Datasource;uid=UserID;pwd=Password"
providerName=... |
134,520 | <p>Okay, this is just a crazy idea I have. Stack Overflow looks very structured and integrable into development applications. So would it be possible, even useful, to have a Stack Overflow plugin for, say, Eclipse? </p>
<p>Which features of Stack Overflow would you like to have directly integrated into your IDE so you... | [
{
"answer_id": 134534,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 0,
"selected": false,
"text": "<p>You could just set it as your Start Page in Visual Studio.</p>\n\n<p>Not sure what benefit this would provide... but to e... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19734/"
] | Okay, this is just a crazy idea I have. Stack Overflow looks very structured and integrable into development applications. So would it be possible, even useful, to have a Stack Overflow plugin for, say, Eclipse?
Which features of Stack Overflow would you like to have directly integrated into your IDE so you can use i... | Following up on Josh's answer. This VS Macro will search StackOverflow for highlighted text in the Visual Studio IDE. Just highlight and press Alt+F1
```
Public Sub SearchStackOverflowForSelectedText()
Dim s As String = ActiveWindowSelection().Trim()
If s.Length > 0 Then
DTE.ItemOperations.Navigate("ht... |
134,569 | <p>I would like to throw an exception when my C++ methods encounter something weird and can't recover. Is it OK to throw a <code>std::string</code> pointer?</p>
<p>Here's what I was looking forward to doing:</p>
<pre><code>void Foo::Bar() {
if(!QueryPerformanceTimer(&m_baz)) {
throw new std::string("i... | [
{
"answer_id": 134596,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 3,
"selected": false,
"text": "<p>It works, but I wouldn't do it if I were you. You don't seem to be deleting that heap data when you're done, whic... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22187/"
] | I would like to throw an exception when my C++ methods encounter something weird and can't recover. Is it OK to throw a `std::string` pointer?
Here's what I was looking forward to doing:
```
void Foo::Bar() {
if(!QueryPerformanceTimer(&m_baz)) {
throw new std::string("it's the end of the world!");
}
}... | Yes. [`std::exception`](http://en.cppreference.com/w/cpp/error/exception) is the base exception class in the C++ standard library. You may want to avoid using strings as exception classes because they themselves can throw an exception during use. If that happens, then where will you be?
boost has an excellent [documen... |
134,572 | <p>I am using the jQuery AutoComplete plugin in an html page where I also have an accordion menu which uses prototype.</p>
<p>They both work perfectly separately but when I tried to implement both components in a single page I get an error that I have not been able to understand.</p>
<blockquote>
<p>uncaught except... | [
{
"answer_id": 134635,
"author": "Tahir Akhtar",
"author_id": 18027,
"author_profile": "https://Stackoverflow.com/users/18027",
"pm_score": 3,
"selected": false,
"text": "<p>jQuery lets you rename the jQuery function from <code>$</code> to something else to avoid namespace conflicts with... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using the jQuery AutoComplete plugin in an html page where I also have an accordion menu which uses prototype.
They both work perfectly separately but when I tried to implement both components in a single page I get an error that I have not been able to understand.
>
> uncaught exception: [Exception... "Compone... | There are two possible solutions: There was a conflict with an older version of Scriptaculous and jQuery (Scriptaculous was attempting to extend the native Array prototype incorrectly) - first try upgrading your copy of Scriptaculous.
If that does not work you will need to use `noConflict()` (as alluded to above). How... |
134,581 | <p>This is a follow-up to <a href="https://stackoverflow.com/questions/43778/sqlite3-ruby-gem-failed-to-build-gem-native-extension">this question</a>.</p>
<p>When I issue the <strong><code>gem update</code></strong> command on Windows, whenever it gets to a
gem whose latest version DOESN'T have Windows binaries, it'll... | [
{
"answer_id": 136226,
"author": "hectorsq",
"author_id": 14755,
"author_profile": "https://Stackoverflow.com/users/14755",
"pm_score": 2,
"selected": false,
"text": "<p>It seems that we are stuck. I have found <a href=\"http://rubyforge.org/frs/?group_id=254\" rel=\"nofollow noreferrer\... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1944/"
] | This is a follow-up to [this question](https://stackoverflow.com/questions/43778/sqlite3-ruby-gem-failed-to-build-gem-native-extension).
When I issue the **`gem update`** command on Windows, whenever it gets to a
gem whose latest version DOESN'T have Windows binaries, it'll attempt to
build the native extension which ... | Gems, as of [version 1.3.2](http://blog.segment7.net/articles/2009/04/15/rubygems-1-3-2), will now skip gems that fail to build, so update Rubygems to the latest version and the problem discussed here should be solved.
```
gem update --system
```
***The following solution is now deprecated, but I leave it here for t... |
134,626 | <p>I mostly use lambda functions but sometimes use nested functions that seem to provide the same behavior.</p>
<p>Here are some trivial examples where they functionally do the same thing if either were found within another function:</p>
<p><strong>Lambda function</strong></p>
<pre><code>>>> a = lambda x : 1 +... | [
{
"answer_id": 134638,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 8,
"selected": true,
"text": "<p>If you need to assign the <code>lambda</code> to a name, use a <code>def</code> instead. <code>def</code>s are just synta... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | I mostly use lambda functions but sometimes use nested functions that seem to provide the same behavior.
Here are some trivial examples where they functionally do the same thing if either were found within another function:
**Lambda function**
```
>>> a = lambda x : 1 + x
>>> a(5)
6
```
**Nested function**
```
>>... | If you need to assign the `lambda` to a name, use a `def` instead. `def`s are just syntactic sugar for an assignment, so the result is the same, and they are a lot more flexible and readable.
`lambda`s can be used for *use once, throw away* functions which won't have a name.
However, this use case is very rare. You r... |
134,629 | <p>In my <code>urls.py</code> file, I have:</p>
<pre><code>from myapp import views
...
(r'^categories/$', views.categories)
</code></pre>
<p>Where <code>categories</code> is a view function inside <code>myapp/views.py</code>. No other URLconf lines reference <code>views.categories</code>.</p>
<p>In a unit test file,... | [
{
"answer_id": 134651,
"author": "Jack M.",
"author_id": 3421,
"author_profile": "https://Stackoverflow.com/users/3421",
"pm_score": -1,
"selected": false,
"text": "<p>The reverse function actually uses the \"name\" of the URL. This is defined like so:</p>\n\n<pre><code>urlpatterns = pa... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20578/"
] | In my `urls.py` file, I have:
```
from myapp import views
...
(r'^categories/$', views.categories)
```
Where `categories` is a view function inside `myapp/views.py`. No other URLconf lines reference `views.categories`.
In a unit test file, I’m trying to grab this URL using `django.core.urlresolvers.reverse()`, inst... | After futher investigation, turns out it was an issue with how I was importing the views module:
[How do I successfully pass a function reference to Django’s reverse() function?](https://stackoverflow.com/questions/146522/how-do-i-successfully-pass-a-function-reference-to-djangos-reverse-function)
Thanks for the help... |
134,644 | <p>Suppose you have a collection of <code>Foo</code> classes:</p>
<pre><code>class Foo
{
public string Bar;
public string Baz;
}
List<Foo> foolist;
</code></pre>
<p>And you want to check this collection to see if another entry has a matching <code>Bar</code>.</p>
<pre><code>bool isDuplicate = false;
f... | [
{
"answer_id": 134662,
"author": "Karg",
"author_id": 12685,
"author_profile": "https://Stackoverflow.com/users/12685",
"pm_score": 0,
"selected": false,
"text": "<p>fooList.Exists(item => item.Bar == SomeBar)</p>\n\n<p>or with anonymous delegate</p>\n\n<p>fooList.Exists(delegate(Foo ite... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | Suppose you have a collection of `Foo` classes:
```
class Foo
{
public string Bar;
public string Baz;
}
List<Foo> foolist;
```
And you want to check this collection to see if another entry has a matching `Bar`.
```
bool isDuplicate = false;
foreach (Foo f in foolist)
{
if (f.Bar == SomeBar)
{
... | ```
fooList.Exists(item => item.Bar == SomeBar)
```
That's not LINQ, but a Lambda expression, but nevertheless, it uses a v3.5 feature. No problem:
```
fooList.Exists(delegate(Foo Item) { return item.Bar == SomeBar});
```
That should work in 2.0. |
134,653 | <p><b>Summary:</b> C#/.NET is supposed to be garbage collected. C# has a destructor, used to clean resources. What happen when an object A is garbage collected the same line I try to clone one of its variable members? Apparently, on multiprocessors, sometimes, the garbage collector wins...</p>
<p><b>The problem</b></p>... | [
{
"answer_id": 134687,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 0,
"selected": false,
"text": "<h2>The Full Code</h2>\n<p>You'll find below the full code, copy/pasted from a Visual C++ 2008 .cs file. As I'm now on L... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14089/"
] | **Summary:** C#/.NET is supposed to be garbage collected. C# has a destructor, used to clean resources. What happen when an object A is garbage collected the same line I try to clone one of its variable members? Apparently, on multiprocessors, sometimes, the garbage collector wins...
**The problem**
Today, on a train... | It's simply a bug in your code: finalizers should not be accessing managed objects.
The only reason to implement a finalizer is to release unmanaged resources. And in this case, you should carefully implement [the standard IDisposable pattern](http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx).
With this pattern,... |
134,656 | <p>Where can I find a Perl module for converting a Perl data structure into a JavaScript one?</p>
<p>e.g. this is my code (Mason):</p>
<pre><code>% # convert our @cti data structure into a javascript one
var cti = [
% foreach my $cti_category (@cti) {
{
label: "<% $cti_category->... | [
{
"answer_id": 134672,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 3,
"selected": false,
"text": "<p>Check out <a href=\"http://search.cpan.org/perldoc?JSON\" rel=\"noreferrer\">JSON</a> or <a href=\"http://search.cpan.or... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8913/"
] | Where can I find a Perl module for converting a Perl data structure into a JavaScript one?
e.g. this is my code (Mason):
```
% # convert our @cti data structure into a javascript one
var cti = [
% foreach my $cti_category (@cti) {
{
label: "<% $cti_category->{'label'} %>",
... | JSON stands for JavaScript Object Notation, which is the format you're looking for.
Unfortunately, none of the modules you're looking for are in the Perl core, but they are available on CPAN, as a quick [search](http://search.cpan.org/search?query=JSON&mode=all) will reveal.
I'd actually recommend installing [JSON::A... |
134,658 | <p>I am trying to encrypt the "system.web.membership" element within the Web.Config of our .Net application to secure username and password to Active Directory. I am using the aspnet_regiis command to encrypt, and have tried several different strings for the value of the "pe" option with no success. I have successfully... | [
{
"answer_id": 134733,
"author": "Paul Lalonde",
"author_id": 5782,
"author_profile": "https://Stackoverflow.com/users/5782",
"pm_score": 4,
"selected": true,
"text": "<p>The configuration section is identified by \"<code>system.web/membership</code>\", not \"<code>membership</code>\" no... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/576/"
] | I am trying to encrypt the "system.web.membership" element within the Web.Config of our .Net application to secure username and password to Active Directory. I am using the aspnet\_regiis command to encrypt, and have tried several different strings for the value of the "pe" option with no success. I have successfully e... | The configuration section is identified by "`system.web/membership`", not "`membership`" nor "`system.web.membership`". |
134,673 | <p>I've got a VS2008 deployment project that builds an installer for a couple of Windows services.</p>
<p>Each service references several different projects:</p>
<pre>
CustomerName.MailSendingService
-> CustomerName.Network
-> CustomerName.Data
-> CustomerName.Security
CustomerName.ProductIntegrationService
-> C... | [
{
"answer_id": 134759,
"author": "hectorsq",
"author_id": 14755,
"author_profile": "https://Stackoverflow.com/users/14755",
"pm_score": 0,
"selected": false,
"text": "<p>I have not used Visual Studio 2008 yet, however in 2005 you have to verify that the missing reference on the project h... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18102/"
] | I've got a VS2008 deployment project that builds an installer for a couple of Windows services.
Each service references several different projects:
```
CustomerName.MailSendingService
-> CustomerName.Network
-> CustomerName.Data
-> CustomerName.Security
CustomerName.ProductIntegrationService
-> CustomerName.Cor... | I have a couple more things to add after reproducing the same suspected msi defect.
1) When I added the second project output sharing the same detected dependency to the installer it did not automatically add the dependency. I removed both project output's and added them back in reverse order. The second project outpu... |
134,683 | <p>This might be a stupid question but if there's a better or proper way to do this, I'd love to learn it.</p>
<p>I have run across this a few times, including recently, where small spaces show up in the rendered version of my HTML page. Intuitively I think these should not be there because outside of text or entities... | [
{
"answer_id": 134701,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 5,
"selected": true,
"text": "<p>The whitespace (carriage return included) is usually rendered as space in all browsers.</p>\n\n<p>You need to put the ele... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2577/"
] | This might be a stupid question but if there's a better or proper way to do this, I'd love to learn it.
I have run across this a few times, including recently, where small spaces show up in the rendered version of my HTML page. Intuitively I think these should not be there because outside of text or entities the forma... | The whitespace (carriage return included) is usually rendered as space in all browsers.
You need to put the elements one after another, but you can use a trick:
```
<a href="page1.html"><img src="image1.png"
/></a><a href="page2.html"><img src="image2.png"
/></a><a href="page3.html"><img src="image3.png"
/></a>
`... |
134,691 | <p>I am trying to create a jar file which includes some class and java files needed, but I also would like to include some extra xml, xsl, html, txt (README) files.</p>
<p>I am using Eclipse on Windows XP.</p>
<p>Is there an easy way for me to set up a directory structure and package all my files into a jar?</p>
| [
{
"answer_id": 134716,
"author": "Roman Plášil",
"author_id": 16590,
"author_profile": "https://Stackoverflow.com/users/16590",
"pm_score": 1,
"selected": false,
"text": "<p>A .jar is nothing but a ZIP archive, so you can use any program capable of creating ZIPs. Just make sure that you ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to create a jar file which includes some class and java files needed, but I also would like to include some extra xml, xsl, html, txt (README) files.
I am using Eclipse on Windows XP.
Is there an easy way for me to set up a directory structure and package all my files into a jar? | Add the files to a source folder and they can be included in the jar.
One common way is to have, at the root of your project, a src folder. Within that, folders for java files, and others. something like:
```
src/
css/
java/
html/
images/
```
Then you can make each of those subfolders a source folder... |
134,712 | <p>I would like to sort a matrix according to a particular column. There is a <code>sort</code> function, but it sorts all columns independently.</p>
<p>For example, if my matrix <code>data</code> is:</p>
<pre><code> 1 3
5 7
-1 4
</code></pre>
<p>Then the desired output (sorting by the first column) wou... | [
{
"answer_id": 135115,
"author": "Kena",
"author_id": 8027,
"author_profile": "https://Stackoverflow.com/users/8027",
"pm_score": 7,
"selected": true,
"text": "<p>I think the <a href=\"http://www.mathworks.com/help/matlab/ref/sortrows.html\" rel=\"noreferrer\">sortrows</a> function is wh... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9425/"
] | I would like to sort a matrix according to a particular column. There is a `sort` function, but it sorts all columns independently.
For example, if my matrix `data` is:
```
1 3
5 7
-1 4
```
Then the desired output (sorting by the first column) would be:
```
-1 4
1 3
5 7
```
But the ou... | I think the [sortrows](http://www.mathworks.com/help/matlab/ref/sortrows.html) function is what you're looking for.
```
>> sortrows(data,1)
ans =
-1 4
1 3
5 7
``` |
134,728 | <p>I have a class declared as follows:</p>
<pre><code>Public MustInherit Container(Of T As {New, BaseClass}) Inherits ArrayList(Of T)
</code></pre>
<p>I have classes that inherit this class.</p>
<p>I have another class that I must pass instances in this method:</p>
<pre><code>Public Sub LoadCollection(Of T As {Base... | [
{
"answer_id": 134811,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 0,
"selected": false,
"text": "<p>It cannot be a global variable. Container is an idea, not a thing.</p>\n\n<p>As you have it designed, that idea i... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4770/"
] | I have a class declared as follows:
```
Public MustInherit Container(Of T As {New, BaseClass}) Inherits ArrayList(Of T)
```
I have classes that inherit this class.
I have another class that I must pass instances in this method:
```
Public Sub LoadCollection(Of T As {BaseClass, New})(ByRef Collection As Container(O... | Sorry haven't got time to expand on this right now, but I think [this link](http://rasor.wordpress.com/2008/08/19/cast-a-generic-list-c/) describes your underlying problem and a solution.
(You might also find [this](http://blogs.msdn.com/lucian/archive/2008/10/02/co-and-contra-variance-how-do-i-convert-a-list-of-apple... |
134,731 | <p>Whilst refactoring some code I came across some getter methods that returns a std::string. Something like this for example:</p>
<pre><code>class foo
{
private:
std::string name_;
public:
std::string name()
{
return name_;
}
};
</code></pre>
<p>Surely the getter would be better returning a ... | [
{
"answer_id": 134743,
"author": "Kristopher Johnson",
"author_id": 1175,
"author_profile": "https://Stackoverflow.com/users/1175",
"pm_score": 2,
"selected": false,
"text": "<p>I'd change it to return const std::string&. The caller will probably make a copy of the result anyway if ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | Whilst refactoring some code I came across some getter methods that returns a std::string. Something like this for example:
```
class foo
{
private:
std::string name_;
public:
std::string name()
{
return name_;
}
};
```
Surely the getter would be better returning a `const std::string&`? The c... | The only way this can cause a problem is if the caller stores the reference, rather than copy the string, and tries to use it after the object is destroyed. Like this:
```
foo *pFoo = new foo;
const std::string &myName = pFoo->getName();
delete pFoo;
cout << myName; // error! dangling reference
```
However, since y... |
134,742 | <p>I have a data table with a variable number of columns and a data scroller. How can I enable server side sorting? I prefer that it be fired by the user clicking the column header.</p>
<pre><code><rich:datascroller for="instanceList" actionListener="#{pageDataModel.pageChange}"/>
<rich:dataTable id="instance... | [
{
"answer_id": 135958,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 4,
"selected": true,
"text": "<p>I ended up doing it manually. I adding a support tag to the header text tag, like so.</p>\n\n<pre><code><h:outputText v... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4893/"
] | I have a data table with a variable number of columns and a data scroller. How can I enable server side sorting? I prefer that it be fired by the user clicking the column header.
```
<rich:datascroller for="instanceList" actionListener="#{pageDataModel.pageChange}"/>
<rich:dataTable id="instanceList" rows="10" value="... | I ended up doing it manually. I adding a support tag to the header text tag, like so.
```
<h:outputText value="#{column}">
<a4j:support event="onclick" action="#{pageDataModel.sort(idx)}"
eventsQueue="instancesQueue"
reRender="instanceList,instanceListScroller"/>
</h:outputText>
```
T... |
134,796 | <p>I know I can compile individual source files, but sometimes -- say, when editing a header file used by many <code>.cpp</code> files -- multiple source files need to be recompiled. That's what Build is for.</p>
<p>Default behavior of the "Build" command in VC9 (Visual C++ 2008) is to attempt to compile all files th... | [
{
"answer_id": 134929,
"author": "Martin Beckett",
"author_id": 10897,
"author_profile": "https://Stackoverflow.com/users/10897",
"pm_score": 1,
"selected": false,
"text": "<p>There is <a href=\"http://old.stevenharman.net/blog/archive/2008/01/17/visual-studio-tip-kill-that-build.aspx\" ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10559/"
] | I know I can compile individual source files, but sometimes -- say, when editing a header file used by many `.cpp` files -- multiple source files need to be recompiled. That's what Build is for.
Default behavior of the "Build" command in VC9 (Visual C++ 2008) is to attempt to compile all files that need it. Sometimes ... | I came up with a better macro guys. It stops immediately after the first error/s (soon as build window is updated).
Visual Studio -> Tools -> Macros -> Macro IDE... (or ALT+F11)
```
Private Sub OutputWindowEvents_OnPaneUpdated(ByVal pPane As OutputWindowPane) Handles OutputWindowEvents.PaneUpdated
If Not (pPane.N... |
134,815 | <p>Is there a way to listen for a javascript function to exit? A trigger that could be setup when a function has completed?</p>
<p>I am attempting to use a user interface obfuscation technique (BlockUI) while an AJAX object is retrieving data from the DB, but the function doesn't necessarily execute last, even if you ... | [
{
"answer_id": 134828,
"author": "jgreep",
"author_id": 16345,
"author_profile": "https://Stackoverflow.com/users/16345",
"pm_score": 1,
"selected": false,
"text": "<p>Your AJAX call should specify a callback function. You can call the unblockUI from within the callback.</p>\n\n<p><a hr... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5405/"
] | Is there a way to listen for a javascript function to exit? A trigger that could be setup when a function has completed?
I am attempting to use a user interface obfuscation technique (BlockUI) while an AJAX object is retrieving data from the DB, but the function doesn't necessarily execute last, even if you put it at ... | However you're accomplishing your Ajax routines, what you need is a "callback" function that will run once it's complete:
```
function ajaxCall(callback){
//do ajax stuff...
callback();
}
```
Then:
```
function doStuff(){
blockUI();
ajaxCall(unblockUI);
}
``` |
134,833 | <p>I have an <em>index.php</em> file which has to process many different file types. How do I guess the filetype based on the <code>REQUEST_URI</code>?</p>
<p>If I request <code>http://site/image.jpg</code>, and all requests redirect through <em>index.php</em>, which looks like this</p>
<pre><code><?php
include('... | [
{
"answer_id": 134893,
"author": "leek",
"author_id": 3765,
"author_profile": "https://Stackoverflow.com/users/3765",
"pm_score": 7,
"selected": true,
"text": "<p>If you are sure you're only ever working with images, you can check out the <a href=\"http://us3.php.net/manual/en/function.e... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144/"
] | I have an *index.php* file which has to process many different file types. How do I guess the filetype based on the `REQUEST_URI`?
If I request `http://site/image.jpg`, and all requests redirect through *index.php*, which looks like this
```
<?php
include('/www/site'.$_SERVER['REQUEST_URI']);
?>
```
How would I ... | If you are sure you're only ever working with images, you can check out the [exif\_imagetype()](http://us3.php.net/manual/en/function.exif-imagetype.php) PHP function, which attempts to return the image MIME type.
If you don't mind external dependencies, you can also check out the excellent [getID3](http://getid3.sour... |
134,834 | <p>This is really the first thing that I have written in python. I come from Java background. I don't want to just learn how to program java code with Python syntax. I want to learn how to program in a pythonic paradigm.</p>
<p>Could you guys please comment on how I can make the following code more pythonic?</p>
<... | [
{
"answer_id": 134946,
"author": "mbac32768",
"author_id": 18446,
"author_profile": "https://Stackoverflow.com/users/18446",
"pm_score": 2,
"selected": false,
"text": "<p>Here's what jumps out at me:</p>\n\n<pre><code>def transformFactorList(factorList):\n oldsize = len(factorList)\n ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2598/"
] | This is really the first thing that I have written in python. I come from Java background. I don't want to just learn how to program java code with Python syntax. I want to learn how to program in a pythonic paradigm.
Could you guys please comment on how I can make the following code more pythonic?
```
from math impo... | There is an excellent primer by David Goodger called "Code Like a Pythonista" [here](http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html). A couple of things from that text re naming (quoting):
* `joined_lower` for functions, methods,
attributes
* `joined_lower` or ALL\_CAPS for
constants
* `StudlyCa... |
134,845 | <p>The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-co... | [
{
"answer_id": 134853,
"author": "Adam Tuttle",
"author_id": 751,
"author_profile": "https://Stackoverflow.com/users/751",
"pm_score": 8,
"selected": false,
"text": "<p><code>'#'</code> will take the user back to the top of the page, so I usually go with <code>void(0)</code>.</p>\n\n<p><... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8018/"
] | The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.?
```js
function myJsFunc() {
alert("myJsFunc");
}
```
```html
<a href="#" onclick="myJsFunc();">Run JavaScript Code</a>
``... | I use `javascript:void(0)`.
Three reasons. Encouraging the use of `#` amongst a team of developers inevitably leads to some using the return value of the function called like this:
```
function doSomething() {
//Some code
return false;
}
```
But then they forget to use `return doSomething()` in the onclick ... |
134,858 | <p>I have some code I've written in PHP for consuming our simple webservice, which I'd also like to provide in Perl for users who may prefer that language. What's the simplest method of making a HTTP request to do that? In PHP I can do it in one line with <code>file_get_contents()</code>.</p>
<p>Here's the entire code... | [
{
"answer_id": 134884,
"author": "bmdhacks",
"author_id": 14032,
"author_profile": "https://Stackoverflow.com/users/14032",
"pm_score": 3,
"selected": false,
"text": "<p>Take a look at <a href=\"http://search.cpan.org/perldoc?LWP::Simple\" rel=\"noreferrer\">LWP::Simple</a>.\nFor more in... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14569/"
] | I have some code I've written in PHP for consuming our simple webservice, which I'd also like to provide in Perl for users who may prefer that language. What's the simplest method of making a HTTP request to do that? In PHP I can do it in one line with `file_get_contents()`.
Here's the entire code I want to port to Pe... | LWP::Simple:
```
use LWP::Simple;
$contents = get("http://YOUR_URL_HERE");
``` |
134,866 | <p>I have a mindmp file from a target's application crash. Is it possible for me to rebuild the dll/pdb files for a version of software and have windbg load symbols correctly? </p>
<p>My problem is that our pdb files are only kept for major releases (unfortunately). This is a daily build, which I can rebuild myself, b... | [
{
"answer_id": 134928,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 4,
"selected": true,
"text": "<p>In my experience probably not.</p>\n\n<p>If you have the exact build directory and build with the <strong>exact same</s... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8123/"
] | I have a mindmp file from a target's application crash. Is it possible for me to rebuild the dll/pdb files for a version of software and have windbg load symbols correctly?
My problem is that our pdb files are only kept for major releases (unfortunately). This is a daily build, which I can rebuild myself, but I'm get... | In my experience probably not.
If you have the exact build directory and build with the **exact same** compiler settings then this might work. You definitely will not be able to load symbols from a debug build against a release crash dump.
You will need to turn on the 'load anything' options: .symopt+0x40 to get wind... |
134,882 | <p>How do I easily undo a git rebase? A lengthy manual method is:</p>
<ol>
<li>checkout the commit parent to both of the branches</li>
<li>create and checkout a temporary branch</li>
<li>cherry-pick all commits by hand</li>
<li>reset the faulty rebased branch to point to the temporary branch</li>
</ol>
<p>In my current... | [
{
"answer_id": 135614,
"author": "CB Bailey",
"author_id": 19563,
"author_profile": "https://Stackoverflow.com/users/19563",
"pm_score": 13,
"selected": true,
"text": "<p>The easiest way would be to find the head commit of the branch as it was immediately before the rebase started in the... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6349/"
] | How do I easily undo a git rebase? A lengthy manual method is:
1. checkout the commit parent to both of the branches
2. create and checkout a temporary branch
3. cherry-pick all commits by hand
4. reset the faulty rebased branch to point to the temporary branch
In my current situation, this works because I can easily... | The easiest way would be to find the head commit of the branch as it was immediately before the rebase started in the [reflog](https://git-scm.com/docs/git-reflog)...
```
git reflog
```
and to reset the current branch to it (with the usual caveats about being absolutely sure before reseting with the `--hard` option)... |
134,885 | <p>I'm looking to use a VBScript variable within a reference to a DOM element for a web-app I'm building. Here's a brief excerpt of the affected area of code:</p>
<pre><code>dim num
num = CInt(document.myform.i.value)
dim x
x = 0
dim orders(num)
For x = 0 To num
orders(x) = document.getElementById("order" & x... | [
{
"answer_id": 134927,
"author": "Dan Williams",
"author_id": 4230,
"author_profile": "https://Stackoverflow.com/users/4230",
"pm_score": 0,
"selected": false,
"text": "<p>I can only assume that this is client side VBScript as document.getElementById() isn't accessible from the server.</... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm looking to use a VBScript variable within a reference to a DOM element for a web-app I'm building. Here's a brief excerpt of the affected area of code:
```
dim num
num = CInt(document.myform.i.value)
dim x
x = 0
dim orders(num)
For x = 0 To num
orders(x) = document.getElementById("order" & x).value
objFile... | I was able to get this working. Thanks to both of you for your time and input. Here is what solved it for me:
Rather than using
```
document.getElementById("order" & x).value
```
I set the entire ID as a variable:
```
temp = "order" & x
document.getElementById(temp).value
```
It seems to be working as expected. ... |
134,887 | <p>After making it through the major parts of an introductory Lisp book, I still couldn't understand what the special operator <code>(quote)</code> (or equivalent <code>'</code>) function does, yet this has been all over Lisp code that I've seen. </p>
<p>What does it do?</p>
| [
{
"answer_id": 134908,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 6,
"selected": false,
"text": "<p>It says \"don't evaluate me\". For example, if you wanted to use a list as data, and not as code, you'd put a qu... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1256/"
] | After making it through the major parts of an introductory Lisp book, I still couldn't understand what the special operator `(quote)` (or equivalent `'`) function does, yet this has been all over Lisp code that I've seen.
What does it do? | **Short answer**
Bypass the default evaluation rules and do *not* evaluate the expression (symbol or s-exp), passing it along to the function exactly as typed.
**Long Answer: The Default Evaluation Rule**
When a regular (I'll come to that later) function is invoked, all arguments passed to it are evaluated. This mean... |
134,905 | <p>What is the best way to return XML from a controller's action in ASP.NET MVC? There is a nice way to return JSON, but not for XML. Do I really need to route the XML through a View, or should I do the not-best-practice way of Response.Write-ing it?</p>
| [
{
"answer_id": 134982,
"author": "Luke Smith",
"author_id": 5556,
"author_profile": "https://Stackoverflow.com/users/5556",
"pm_score": 8,
"selected": true,
"text": "<p>Use <a href=\"http://www.codeplex.com/MVCContrib\" rel=\"noreferrer\">MVCContrib</a>'s XmlResult Action.</p>\n\n<p>For ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22299/"
] | What is the best way to return XML from a controller's action in ASP.NET MVC? There is a nice way to return JSON, but not for XML. Do I really need to route the XML through a View, or should I do the not-best-practice way of Response.Write-ing it? | Use [MVCContrib](http://www.codeplex.com/MVCContrib)'s XmlResult Action.
For reference here is their code:
>
>
> ```
> public class XmlResult : ActionResult
> {
> private object objectToSerialize;
>
> /// <summary>
> /// Initializes a new instance of the <see cref="XmlResult"/> class.
> /// </summa... |
134,906 | <p>Is there a command or an existing script that will let me view all of a *NIX system's scheduled cron jobs at once? I'd like it to include all of the user crontabs, as well as <code>/etc/crontab</code>, and whatever's in <code>/etc/cron.d</code>. It would also be nice to see the specific commands run by <code>run-par... | [
{
"answer_id": 134944,
"author": "Kyle Burton",
"author_id": 19784,
"author_profile": "https://Stackoverflow.com/users/19784",
"pm_score": 10,
"selected": false,
"text": "<p>You would have to run this as root, but:</p>\n\n<pre><code>for user in $(cut -f1 -d: /etc/passwd); do crontab -u $... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/726/"
] | Is there a command or an existing script that will let me view all of a \*NIX system's scheduled cron jobs at once? I'd like it to include all of the user crontabs, as well as `/etc/crontab`, and whatever's in `/etc/cron.d`. It would also be nice to see the specific commands run by `run-parts` in `/etc/crontab`.
Ideal... | I ended up writing a script (I'm trying to teach myself the finer points of bash scripting, so that's why you don't see something like Perl here). It's not exactly a simple affair, but it does most of what I need. It uses Kyle's suggestion for looking up individual users' crontabs, but also deals with `/etc/crontab` (i... |
134,917 | <p>We will need to call out to a 3rd party to retrieve a value using REST, however if we do not receive a response within 10ms, I want to use a default value and continue processing.</p>
<p>I'm leaning towards using an asynchronous WebRequest do to this, but I was wondering if there was a trick to doing it using a syn... | [
{
"answer_id": 135004,
"author": "Philip Rieck",
"author_id": 12643,
"author_profile": "https://Stackoverflow.com/users/12643",
"pm_score": 2,
"selected": false,
"text": "<p>If you are doing a request and waiting on it to return I'd say stay synchronous - there's no reason to do an async... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | We will need to call out to a 3rd party to retrieve a value using REST, however if we do not receive a response within 10ms, I want to use a default value and continue processing.
I'm leaning towards using an asynchronous WebRequest do to this, but I was wondering if there was a trick to doing it using a synchronous r... | If you are doing a request and waiting on it to return I'd say stay synchronous - there's no reason to do an async request if you're not going to do anything or stay responsive while waiting.
For a sync call:
```
WebRequest request = WebRequest.Create("http://something.somewhere/url");
WebResponse response = null;
re... |
134,934 | <p>How do I display a leading zero for all numbers with less than two digits?</p>
<pre class="lang-none prettyprint-override"><code>1 → 01
10 → 10
100 → 100
</code></pre>
| [
{
"answer_id": 134942,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 6,
"selected": false,
"text": "<pre><code>x = [1, 10, 100]\nfor i in x:\n print '%02d' % i\n</code></pre>\n<p>results in:</p>\n<pre class=\"lang-none p... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22306/"
] | How do I display a leading zero for all numbers with less than two digits?
```none
1 → 01
10 → 10
100 → 100
``` | In Python 2 (and Python 3) you can do:
```
number = 1
print("%02d" % (number,))
```
Basically **%** is like `printf` or `sprintf` (see [docs](https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting)).
---
For Python 3.+, the same behavior can also be achieved with [`format`](https://docs.pyt... |
134,958 | <p>How would I be able to get N results for several groups in
an oracle query.</p>
<p>For example, given the following table:</p>
<pre><code>|--------+------------+------------|
| emp_id | name | occupation |
|--------+------------+------------|
| 1 | John Smith | Accountant |
| 2 | Jane Doe | Engin... | [
{
"answer_id": 135046,
"author": "billjamesdev",
"author_id": 13824,
"author_profile": "https://Stackoverflow.com/users/13824",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure this is very efficient, but maybe a starting place?</p>\n\n<pre><code>select *\nfrom people p1\n j... | 2008/09/25 | [
"https://Stackoverflow.com/questions/134958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9435/"
] | How would I be able to get N results for several groups in
an oracle query.
For example, given the following table:
```
|--------+------------+------------|
| emp_id | name | occupation |
|--------+------------+------------|
| 1 | John Smith | Accountant |
| 2 | Jane Doe | Engineer |
| 3 | Ja... | This produces what you want, and it uses no vendor-specific SQL features like TOP N or RANK().
```
SELECT MAX(e.name) AS name, MAX(e.occupation) AS occupation
FROM emp e
LEFT OUTER JOIN emp e2
ON (e.occupation = e2.occupation AND e.emp_id <= e2.emp_id)
GROUP BY e.emp_id
HAVING COUNT(*) <= 3
ORDER BY occup... |
135,000 | <p>When generating XML from XmlDocument in .NET, a blank <code>xmlns</code> attribute appears the first time an element <em>without</em> an associated namespace is inserted; how can this be prevented?</p>
<p>Example:</p>
<pre><code>XmlDocument xml = new XmlDocument();
xml.AppendChild(xml.CreateElement("root",
"wh... | [
{
"answer_id": 135027,
"author": "JeniT",
"author_id": 6739,
"author_profile": "https://Stackoverflow.com/users/6739",
"pm_score": 4,
"selected": false,
"text": "<p>If the <code><loner></code> element in your sample XML didn't have the <code>xmlns</code> default namespace declarati... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9642/"
] | When generating XML from XmlDocument in .NET, a blank `xmlns` attribute appears the first time an element *without* an associated namespace is inserted; how can this be prevented?
Example:
```
XmlDocument xml = new XmlDocument();
xml.AppendChild(xml.CreateElement("root",
"whatever:name-space-1.0"));
xml.DocumentE... | Thanks to Jeremy Lew's answer and a bit more playing around, I figured out how to remove blank `xmlns` attributes: pass in the root node's namespace when creating any child node you want *not* to have a prefix on. Using a namespace without a prefix at the root means that you need to use that same namespace on child ele... |
135,010 | <p>I have a problem with stopping a service and starting it again and want to be notified when the process runs and let me know what the result is. </p>
<p>Here's the scenario,
I have a text file output of an "sc" command. I want to send that file but not as an attachment. Also, I want to see the initial status quic... | [
{
"answer_id": 135027,
"author": "JeniT",
"author_id": 6739,
"author_profile": "https://Stackoverflow.com/users/6739",
"pm_score": 4,
"selected": false,
"text": "<p>If the <code><loner></code> element in your sample XML didn't have the <code>xmlns</code> default namespace declarati... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730/"
] | I have a problem with stopping a service and starting it again and want to be notified when the process runs and let me know what the result is.
Here's the scenario,
I have a text file output of an "sc" command. I want to send that file but not as an attachment. Also, I want to see the initial status quickly in the s... | Thanks to Jeremy Lew's answer and a bit more playing around, I figured out how to remove blank `xmlns` attributes: pass in the root node's namespace when creating any child node you want *not* to have a prefix on. Using a namespace without a prefix at the root means that you need to use that same namespace on child ele... |
135,020 | <p>When creating a class that has internal private methods, usually to reduce code duplication, that don't require the use of any instance fields, are there performance or memory advantages to declaring the method as static?</p>
<p>Example:</p>
<pre><code>foreach (XmlElement element in xmlDoc.DocumentElement.SelectNo... | [
{
"answer_id": 135023,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 4,
"selected": false,
"text": "<p>Yes, the compiler does not need to pass the implicit <code>this</code> pointer to <code>static</code> methods. Even... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6146/"
] | When creating a class that has internal private methods, usually to reduce code duplication, that don't require the use of any instance fields, are there performance or memory advantages to declaring the method as static?
Example:
```
foreach (XmlElement element in xmlDoc.DocumentElement.SelectNodes("sample"))
{
... | From the [FxCop rule page](http://msdn.microsoft.com/en-us/library/ms245046.aspx) on this:
>
> After you mark the methods as static, the compiler will emit non-virtual call sites to these members. Emitting non-virtual call sites will prevent a check at runtime for each call that ensures that the current object pointe... |
135,035 | <p>In ruby the library path is provided in <code>$:</code>, in perl it's in <code>@INC</code> - how do you get the list of paths that Python searches for modules when you do an import?</p>
| [
{
"answer_id": 135050,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": false,
"text": "<pre><code>import sys\nsys.path\n</code></pre>\n"
},
{
"answer_id": 135051,
"author": "Jack M.",
"auth... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19784/"
] | In ruby the library path is provided in `$:`, in perl it's in `@INC` - how do you get the list of paths that Python searches for modules when you do an import? | I think you're looking for [sys.path](https://docs.python.org/3/library/sys.html#sys.path)
```
import sys
print (sys.path)
``` |
135,041 | <p>Why or why not?</p>
| [
{
"answer_id": 135070,
"author": "Dan Udey",
"author_id": 21450,
"author_profile": "https://Stackoverflow.com/users/21450",
"pm_score": 4,
"selected": false,
"text": "<p><code>xrange()</code> is more efficient because instead of generating a list of objects, it just generates one object ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18446/"
] | Why or why not? | For performance, especially when you're iterating over a large range, `xrange()` is usually better. However, there are still a few cases why you might prefer `range()`:
* In python 3, `range()` does what `xrange()` used to do and `xrange()` does not exist. If you want to write code that will run on both Python 2 and P... |
135,069 | <p>This may be a matter of style, but there's a bit of a divide in our dev team and I wondered if anyone else had any ideas on the matter...</p>
<p>Basically, we have some debug print statements which we turn off during normal development. Personally I prefer to do the following:</p>
<pre><code>//---- SomeSourceFile.... | [
{
"answer_id": 135077,
"author": "Martin Beckett",
"author_id": 10897,
"author_profile": "https://Stackoverflow.com/users/10897",
"pm_score": 3,
"selected": false,
"text": "<p><code>#if</code> gives you the option of setting it to 0 to turn off the functionality, while still detecting th... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15369/"
] | This may be a matter of style, but there's a bit of a divide in our dev team and I wondered if anyone else had any ideas on the matter...
Basically, we have some debug print statements which we turn off during normal development. Personally I prefer to do the following:
```
//---- SomeSourceFile.cpp ----
#define DEB... | My initial reaction was *`#ifdef`, of course*, but I think `#if` actually has some significant advantages for this - here's why:
First, you can use `DEBUG_ENABLED` in preprocessor *and* compiled tests. Example - Often, I want longer timeouts when debug is enabled, so using `#if`, I can write this
```
DoSomethingSlo... |
135,076 | <p>I am <strong>losing hair</strong> on this one ... it seems that when I fix width an HTML SELECT control it renders its width differently depending on the browser. </p>
<p>Any idea how to to standardize this without having to turn to multiple style sheets?</p>
<p>Here is what I am working with:</p>
<pre><code>.co... | [
{
"answer_id": 135083,
"author": "Steve Paulo",
"author_id": 9414,
"author_profile": "https://Stackoverflow.com/users/9414",
"pm_score": 1,
"selected": false,
"text": "<p>Make sure you remove all default margins and padding, and define them explicitly. Make sure you're using a proper DOC... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] | I am **losing hair** on this one ... it seems that when I fix width an HTML SELECT control it renders its width differently depending on the browser.
Any idea how to to standardize this without having to turn to multiple style sheets?
Here is what I am working with:
```
.combo
{
padding: 2px;
width: 200px;
... | Form controls will always be less obedient to styling attempts,in particular selects and file inputs, so the only way to reliably style them cross-browser and with future-proofing in mind, is to replace them with JavaScript or Flash and mimic their functionality |
135,105 | <p>We'd like to override DataGridView's default behavior when using a mouse wheel with this control. By default, the DataGridView scrolls a number of rows equal the SystemInformation.MouseWheelScrollLines setting. What we'd like to do is scroll just one item at a time. </p>
<p>(We display images in the DataGridView... | [
{
"answer_id": 135516,
"author": "ZeroBugBounce",
"author_id": 11314,
"author_profile": "https://Stackoverflow.com/users/11314",
"pm_score": 1,
"selected": false,
"text": "<p>I would subclass the DataGridView into my own custom control (you know, add a new Windows Forms --> Custom Contro... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7357/"
] | We'd like to override DataGridView's default behavior when using a mouse wheel with this control. By default, the DataGridView scrolls a number of rows equal the SystemInformation.MouseWheelScrollLines setting. What we'd like to do is scroll just one item at a time.
(We display images in the DataGridView, which are s... | I just did a little scrounging and testing of my own. I used [Reflector](http://www.red-gate.com/products/reflector/) to investigate and discovered a couple things. The `MouseWheel` event provides a `MouseEventArgs` parameter, but the `OnMouseWheel()` override in `DataGridView` casts it to **`Handled`**`MouseEventArgs`... |
135,121 | <p>So in my documentation it says:</p>
<blockquote>
<p>public event TreeViewPlusNodeCheckedEventHandler NodeChecked()</p>
<p>You can use this event to run cause a method to run whenever the
check-box for a node is checked on the tree.</p>
</blockquote>
<p>So how do I add a method to my code behind file that ... | [
{
"answer_id": 135137,
"author": "DaveK",
"author_id": 4244,
"author_profile": "https://Stackoverflow.com/users/4244",
"pm_score": 4,
"selected": true,
"text": "<p>You need to assign a delegate to the event and have it run the method you want. Something like :</p>\n\n<p>TreeViewControl.N... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5234/"
] | So in my documentation it says:
>
> public event TreeViewPlusNodeCheckedEventHandler NodeChecked()
>
>
> You can use this event to run cause a method to run whenever the
> check-box for a node is checked on the tree.
>
>
>
So how do I add a method to my code behind file that will run when a node is checked? Th... | You need to assign a delegate to the event and have it run the method you want. Something like :
TreeViewControl.NodeChecked += new TreeViewPlusNodeCheckedEventHandler(TOCNodeCheckedServer) |
135,132 | <p>I'm really baffled by this - I know how to do this in VB, unmanaged C++ and C# but for some reason I can't accept a ref variable of a managed type in C++. I'm sure there's a simple answer, really - but here's the C# equivalent:</p>
<pre><code>myClass.myFunction(ref variableChangedByfunction);
</code></pre>
<p>I've... | [
{
"answer_id": 135135,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>Use a ^ instead of a *</p>\n"
},
{
"answer_id": 135404,
"author": "Community",
"author_id": -1,
... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm really baffled by this - I know how to do this in VB, unmanaged C++ and C# but for some reason I can't accept a ref variable of a managed type in C++. I'm sure there's a simple answer, really - but here's the C# equivalent:
```
myClass.myFunction(ref variableChangedByfunction);
```
I've tried C++ pointers - no d... | Turns out in the function declaration you need to use a % after the parameter name:
bool Importer::GetBodyChunk(String^% BodyText, String^% ChunkText)
And then you pass in the variable per usual. |
135,151 | <p>The .NET web system I'm working on allows the end user to input HTML formatted text in some situations. In some of those places, we want to leave all the tags, but strip off any trailing break tags (but leave any breaks inside the body of the text.)</p>
<p>What's the best way to do this? (I can think of ways to d... | [
{
"answer_id": 135161,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 2,
"selected": false,
"text": "<p>You can use a regex to find and remove the text with the regex match set to anchor at the end of the string.</p... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19074/"
] | The .NET web system I'm working on allows the end user to input HTML formatted text in some situations. In some of those places, we want to leave all the tags, but strip off any trailing break tags (but leave any breaks inside the body of the text.)
What's the best way to do this? (I can think of ways to do this, but ... | As @[Mitch](https://stackoverflow.com/questions/135151#135161) said,
```
// using System.Text.RegularExpressions;
/// <summary>
/// Regular expression built for C# on: Thu, Sep 25, 2008, 02:01:36 PM
/// Using Expresso Version: 2.1.2150, http://www.ultrapico.com
///
/// A description of the regular expression:
... |
135,173 | <p>I have a table that holds only two columns - a ListID and PersonID. When a person is merged with another in the system, I was to update all references from the "source" person to be references to the "destination" person.</p>
<p>Ideally, I would like to call something simple like</p>
<pre><code>UPDATE MailingList... | [
{
"answer_id": 135252,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 3,
"selected": true,
"text": "<pre><code>--out with the bad\nDELETE\nFROM MailingListSubscription\nWHERE PersonId = @SourcePerson\n and ListID in (SELECT Li... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3259/"
] | I have a table that holds only two columns - a ListID and PersonID. When a person is merged with another in the system, I was to update all references from the "source" person to be references to the "destination" person.
Ideally, I would like to call something simple like
```
UPDATE MailingListSubscription
SET Perso... | ```
--out with the bad
DELETE
FROM MailingListSubscription
WHERE PersonId = @SourcePerson
and ListID in (SELECT ListID FROM MailingListSubscription WHERE PersonID = @DestPerson)
--update the rest (good)
UPDATE MailingListSubscription
SET PersonId = @DestPerson
WHERE PersonId = @SourcePerson
``` |
135,186 | <p>I have a project at work the requires me to be able to enter information into a web page, read the next page I get redirected to and then take further action. A simplified real-world example would be something like going to google.com, entering "Coding tricks" as search criteria, and reading the resulting page.</p>... | [
{
"answer_id": 135231,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>What you need to do is keep retrieving and analyzing the html source for each page in the chain. For each page, yo... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a project at work the requires me to be able to enter information into a web page, read the next page I get redirected to and then take further action. A simplified real-world example would be something like going to google.com, entering "Coding tricks" as search criteria, and reading the resulting page.
Small ... | You can programmatically create an Http request and retrieve the response:
```
string uri = "http://www.google.com/search";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
// encode th... |
135,234 | <p>What is the difference between <code>ref</code> and <code>out</code> parameters in .NET? What are the situations where one can be more useful than the other? What would be a code snippet where one can be used and another can't?</p>
| [
{
"answer_id": 135241,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>ref will probably choke on null since it presumably expects to be modifying an existing object. out expects null, ... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1909/"
] | What is the difference between `ref` and `out` parameters in .NET? What are the situations where one can be more useful than the other? What would be a code snippet where one can be used and another can't? | They're pretty much the same - the only difference is that a variable you pass as an `out` parameter doesn't need to be initialized but passing it as a `ref` parameter it has to be set to something.
```
int x;
Foo(out x); // OK
int y;
Foo(ref y); // Error: y should be initialized before calling the method
```
`Ref`... |
135,246 | <p>I'm attempting to write a Python C extension that reads packed binary data (it is stored as structs of structs) and then parses it out into Python objects. Everything works as expected on a 32 bit machine (the binary files are always written on 32bit architecture), but not on a 64 bit box. Is there a "preferred" ... | [
{
"answer_id": 135267,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 1,
"selected": false,
"text": "<p>What's your code for reading the binary data? Make sure you're copying the data into properly-sized types like <cod... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16363/"
] | I'm attempting to write a Python C extension that reads packed binary data (it is stored as structs of structs) and then parses it out into Python objects. Everything works as expected on a 32 bit machine (the binary files are always written on 32bit architecture), but not on a 64 bit box. Is there a "preferred" way of... | Explicitly specify that your data types (e.g. integers) are 32-bit. Otherwise if you have two integers next to each other when you read them they will be read as one 64-bit integer.
When you are dealing with cross-platform issues, the two main things to watch out for are:
1. Bitness. If your packed data is written wi... |
135,254 | <p>I have a number of panels in a single window in C# application and I created 2 scrollbars, one for horizontal and one vertical. This is what I currently have:</p>
<p><a href="http://www.simnet.is/elinnils52/scrollbar.jpg" rel="nofollow noreferrer">picture with 2 scroolbars http://www.simnet.is/elinnils52/scrollbar.... | [
{
"answer_id": 193350,
"author": "Robert C. Barth",
"author_id": 9209,
"author_profile": "https://Stackoverflow.com/users/9209",
"pm_score": 1,
"selected": false,
"text": "<p>Why not just make the maximum value of the scrollbar the overflow (visible area height - panel height)? Then just... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a number of panels in a single window in C# application and I created 2 scrollbars, one for horizontal and one vertical. This is what I currently have:
[picture with 2 scroolbars http://www.simnet.is/elinnils52/scrollbar.jpg](http://www.simnet.is/elinnils52/scrollbar.jpg)
I have 1 variable and that is the tota... | Why not just make the maximum value of the scrollbar the overflow (visible area height - panel height)? Then just set the top of the panel to the value of the scrollbar \* -1. |
135,303 | <p>In C# I could easily write the following:</p>
<pre><code>string stringValue = string.IsNullOrEmpty( otherString ) ? defaultString : otherString;
</code></pre>
<p>Is there a quick way of doing the same thing in Python or am I stuck with an 'if' statement?</p>
| [
{
"answer_id": 135318,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 6,
"selected": true,
"text": "<p>In Python 2.5, there is</p>\n\n<pre><code>A if C else B\n</code></pre>\n\n<p>which behaves a lot like ?: in C. Ho... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20133/"
] | In C# I could easily write the following:
```
string stringValue = string.IsNullOrEmpty( otherString ) ? defaultString : otherString;
```
Is there a quick way of doing the same thing in Python or am I stuck with an 'if' statement? | In Python 2.5, there is
```
A if C else B
```
which behaves a lot like ?: in C. However, it's frowned upon for two reasons: readability, and the fact that there's usually a simpler way to approach the problem. For instance, in your case:
```
stringValue = otherString or defaultString
``` |
135,317 | <p>When running a CherryPy app it will send server name tag something like CherryPy/version.
Is it possible to rename/overwrite that from the app without modifying CherryPy so it will show something else? </p>
<p>Maybe something like MyAppName/version (CherryPy/version) </p>
| [
{
"answer_id": 135644,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 2,
"selected": false,
"text": "<p>This string appears to be being set in the CherrPy <a href=\"http://www.cherrypy.org/browser/trunk/cherrypy/_cprequest.py\"... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789/"
] | When running a CherryPy app it will send server name tag something like CherryPy/version.
Is it possible to rename/overwrite that from the app without modifying CherryPy so it will show something else?
Maybe something like MyAppName/version (CherryPy/version) | Actually asking on IRC on their official channel fumanchu gived me a more clean way to do this (using latest svn):
```
import cherrypy
from cherrypy import _cpwsgi_server
class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True
serverTag = "MyApp/%s (CherryPy/%s)" % ("1.2... |
135,330 | <p>Does anybody know if there is a built-in function in Mathematica for getting the lhs of downvalue rules (without any holding)? I know how to write the code to do it, but it seems basic enough for a built-in</p>
<p>For example:</p>
<pre><code>a[1]=2;
a[2]=3;
</code></pre>
<p><code>BuiltInIDoNotKnowOf[a]</code> re... | [
{
"answer_id": 138033,
"author": "Will Robertson",
"author_id": 4161,
"author_profile": "https://Stackoverflow.com/users/4161",
"pm_score": 4,
"selected": true,
"text": "<p>This seems to work; not sure how useful it is, though:</p>\n\n<pre><code>a[1] = 2\na[2] = 3\na[3] = 5\na[6] = 8\nPa... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/279/"
] | Does anybody know if there is a built-in function in Mathematica for getting the lhs of downvalue rules (without any holding)? I know how to write the code to do it, but it seems basic enough for a built-in
For example:
```
a[1]=2;
a[2]=3;
```
`BuiltInIDoNotKnowOf[a]` returns `{1,2}` | This seems to work; not sure how useful it is, though:
```
a[1] = 2
a[2] = 3
a[3] = 5
a[6] = 8
Part[DownValues[a], All, 1, 1, 1]
``` |
135,339 | <p>Within an n-tier app that makes use of a WCF service to interact with the database, what is the best practice way of making use of LinqToSql classes throughout the app?</p>
<p>I've seen it done a couple of different ways but they seemed like they burned a lot of hours creating extra interfaces, message classes, and... | [
{
"answer_id": 138033,
"author": "Will Robertson",
"author_id": 4161,
"author_profile": "https://Stackoverflow.com/users/4161",
"pm_score": 4,
"selected": true,
"text": "<p>This seems to work; not sure how useful it is, though:</p>\n\n<pre><code>a[1] = 2\na[2] = 3\na[3] = 5\na[6] = 8\nPa... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1860358/"
] | Within an n-tier app that makes use of a WCF service to interact with the database, what is the best practice way of making use of LinqToSql classes throughout the app?
I've seen it done a couple of different ways but they seemed like they burned a lot of hours creating extra interfaces, message classes, and the like ... | This seems to work; not sure how useful it is, though:
```
a[1] = 2
a[2] = 3
a[3] = 5
a[6] = 8
Part[DownValues[a], All, 1, 1, 1]
``` |
135,375 | <p>I have a <code>ListBox</code> <code>DataTemplate</code> in WPF. I want one item to be tight against the left side of the <code>ListBox</code> and another item to be tight against the right side, but I can't figure out how to do this.</p>
<p>So far I have a <code>Grid</code> with three columns, the left and right on... | [
{
"answer_id": 135741,
"author": "Joel B Fant",
"author_id": 22211,
"author_profile": "https://Stackoverflow.com/users/22211",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>Grid</code> should by default take up the whole width of the <code>ListBox</code> because the default <co... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/100/"
] | I have a `ListBox` `DataTemplate` in WPF. I want one item to be tight against the left side of the `ListBox` and another item to be tight against the right side, but I can't figure out how to do this.
So far I have a `Grid` with three columns, the left and right ones have content and the center is a placeholder with i... | I also had to set:
```
HorizontalContentAlignment="Stretch"
```
on the containing `ListBox`. |
135,443 | <p>There are a group of private methods in my class, and I need to call one dynamically based on an input value. Both the invoking code and the target methods are in the same instance. The code looks like this:</p>
<pre><code>MethodInfo dynMethod = this.GetType().GetMethod("Draw_" + itemType);
dynMethod.Invoke(this, n... | [
{
"answer_id": 135455,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 2,
"selected": false,
"text": "<p>I think you can pass it <code>BindingFlags.NonPublic</code> where <em>it</em> is the <code>GetMethod</code> meth... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8223/"
] | There are a group of private methods in my class, and I need to call one dynamically based on an input value. Both the invoking code and the target methods are in the same instance. The code looks like this:
```
MethodInfo dynMethod = this.GetType().GetMethod("Draw_" + itemType);
dynMethod.Invoke(this, new object[] { ... | Simply change your code to use the overloaded [version of `GetMethod`](http://msdn.microsoft.com/en-us/library/system.type.getmethod.aspx) that accepts BindingFlags:
```
MethodInfo dynMethod = this.GetType().GetMethod("Draw_" + itemType,
BindingFlags.NonPublic | BindingFlags.Instance);
dynMethod.Invoke(this, new ... |
135,445 | <p>I tried to use DriveInfo.IsReady, but it returns false if an unformatted floppy is in the drive.</p>
| [
{
"answer_id": 135479,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 1,
"selected": false,
"text": "<p>Simply speaking: you can't. Floppy drives don't support that.</p>\n"
},
{
"answer_id": 135597,
"aut... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I tried to use DriveInfo.IsReady, but it returns false if an unformatted floppy is in the drive. | You can always try to read a sector from the floppy and see if it succeeds or not.
I have no clue how to do it in .NET, but here is the C/C++ equivalent.
```
SetLastError(0);
HANDLE h = CreateFile("\\\\.\\A:", ...);
if (!ReadFile(h, buf, 512, &bytes_read, 0))
{
DWORD err = GetLastError();
}
```
[CreateFile](http:... |
135,448 | <p>How do I check if an object has a specific property in JavaScript?</p>
<p>Consider:</p>
<pre><code>x = {'key': 1};
if ( x.hasOwnProperty('key') ) {
//Do this
}
</code></pre>
<p>Is that the best way to do it?</p>
| [
{
"answer_id": 135466,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 4,
"selected": false,
"text": "<p>Yes it is :) I think you can also do <code>Object.prototype.hasOwnProperty.call(x, 'key')</code> which should a... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4915/"
] | How do I check if an object has a specific property in JavaScript?
Consider:
```
x = {'key': 1};
if ( x.hasOwnProperty('key') ) {
//Do this
}
```
Is that the best way to do it? | 2022 UPDATE
-----------
[`Object.hasOwn()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn)
-------------------------------------------------------------------------------------------------------------------
>
> `Object.hasOwn()` is recommended over `Object.hasOwnPrope... |
135,451 | <p>I want to create a list of methods to execute. Each method has the same signature.
I thought about putting delegates in a generic collection, but I keep getting this error:</p>
<blockquote>
<p>'method' is a 'variable' but is used like a 'method'</p>
</blockquote>
<p>In theory, here is what I would like to do:</... | [
{
"answer_id": 135453,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>Have them all implement of common interface, say IExecuteable, and then have a List<IExecutable></p>\n\n<p>Also,... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8797/"
] | I want to create a list of methods to execute. Each method has the same signature.
I thought about putting delegates in a generic collection, but I keep getting this error:
>
> 'method' is a 'variable' but is used like a 'method'
>
>
>
In theory, here is what I would like to do:
```
List<object> methodsToExecute... | You need to cast the `object` in the list to a `BinaryOp`, or, better, use a more specific type parameter for the list:
```
delegate int BinaryOp(int x, int y);
List<BinaryOp> methodsToExecute = new List<BinaryOp>();
methodsToExecute.add(Add);
methodsToExecute.add(Subtract);
foreach(BinaryOp method in methodsToExec... |
135,458 | <p>Suppose I have the following code:</p>
<pre><code>while(TRUE) {
pthread_t *thread = (pthread_t *) malloc(sizeof(pthread_t));
pthread_create(thread, NULL, someFunction, someArgument);
pthread_detach(*thread);
sleep(10);
}
</code></pre>
<p>Will the detached thread free the memory allocated by malloc, or is t... | [
{
"answer_id": 135922,
"author": "Commodore Jaeger",
"author_id": 4659,
"author_profile": "https://Stackoverflow.com/users/4659",
"pm_score": 4,
"selected": true,
"text": "<p>No. <strong>pthread_create()</strong> has no way of knowing that the <strong>thread</strong> pointer passed to it... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/542226/"
] | Suppose I have the following code:
```
while(TRUE) {
pthread_t *thread = (pthread_t *) malloc(sizeof(pthread_t));
pthread_create(thread, NULL, someFunction, someArgument);
pthread_detach(*thread);
sleep(10);
}
```
Will the detached thread free the memory allocated by malloc, or is that something I now have t... | No. **pthread\_create()** has no way of knowing that the **thread** pointer passed to it was dynamically allocated. pthreads doesn't use this value internally; it simply returns the new thread id to the caller. You don't need to dynamically allocate that value; you can pass the address of a local variable instead:
```... |
135,474 | <p>For example:</p>
<pre><code>char * myString = malloc(sizeof(char)*STRING_BUFFER_SIZE);
free(myString);
free(myString);
</code></pre>
<p>Are there any adverse side effects of doing this? </p>
| [
{
"answer_id": 135483,
"author": "jbleners",
"author_id": 542226,
"author_profile": "https://Stackoverflow.com/users/542226",
"pm_score": 4,
"selected": false,
"text": "<p>Yes, you can get a double free error that causes your program to crash. It has to do with malloc's internal data str... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2064/"
] | For example:
```
char * myString = malloc(sizeof(char)*STRING_BUFFER_SIZE);
free(myString);
free(myString);
```
Are there any adverse side effects of doing this? | Here's the chapter and verse.
>
> If the argument [to the `free` function] does not match a pointer earlier returned by the `calloc`, `malloc`, or
> `realloc` function, or if the space has been deallocated by a call to `free` or `realloc`,
> the behavior is undefined. ([ISO 9899:1999 - *Programming languages — C*](... |
135,518 | <p>In WPF, we are creating custom controls that inherit from button with completely drawn-from-scratch xaml graphics. We have a border around the entire button xaml and we'd like to use that as the location for updating the background when MouseOver=True in a trigger. What we need to know is how do we update the back... | [
{
"answer_id": 135638,
"author": "Joel B Fant",
"author_id": 22211,
"author_profile": "https://Stackoverflow.com/users/22211",
"pm_score": 3,
"selected": true,
"text": "<p>In your <code>ControlTemplate</code>, give the <code>Border</code> a <code>Name</code> and you can then reference th... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21096/"
] | In WPF, we are creating custom controls that inherit from button with completely drawn-from-scratch xaml graphics. We have a border around the entire button xaml and we'd like to use that as the location for updating the background when MouseOver=True in a trigger. What we need to know is how do we update the backgroun... | In your `ControlTemplate`, give the `Border` a `Name` and you can then reference that part of its visual tree in the triggers. Here's a very brief example of restyling a normal `Button`:
```
<Style
TargetType="{x:Type Button}">
<Setter
Property="Template">
<Setter.Value>
<ControlTem... |
135,534 | <p>I need to validate this simple pick list:</p>
<pre><code><select name="<%= key %>">
<option value="ETC" SELECTED>Select an option...</option>
<option value="ONE">Lorem ipsum</option>
<option value="TWO">dolor sit amet</option>
</select>
</code></pre>... | [
{
"answer_id": 135795,
"author": "Peter",
"author_id": 17123,
"author_profile": "https://Stackoverflow.com/users/17123",
"pm_score": 3,
"selected": true,
"text": "<p>You can never really satisfy the condition 'never submit a given value' because you don't have control over the client sid... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6992/"
] | I need to validate this simple pick list:
```
<select name="<%= key %>">
<option value="ETC" SELECTED>Select an option...</option>
<option value="ONE">Lorem ipsum</option>
<option value="TWO">dolor sit amet</option>
</select>
```
So the user would never submit the form with the, excuse the repetition, "S... | You can never really satisfy the condition 'never submit a given value' because you don't have control over the client side. The user can always manipulate HTML to submit whatever they want.
It is a good approach is to use JavaScript to do client-side validation and give the user quick feedback and catch 99%+ of the c... |
135,591 | <p>I've seen several products that will track the sales rank of an item on Amazon. Does Amazon have any web-services published that I can use to get the sales rank of a particular item? </p>
<p>I've looked through the AWS and didn't see anything of that nature.</p>
| [
{
"answer_id": 135627,
"author": "Adam Hughes",
"author_id": 3863,
"author_profile": "https://Stackoverflow.com/users/3863",
"pm_score": 4,
"selected": true,
"text": "<p>You should be able to determine the Sales Rank by querying for the SalesRank response group when doing an ItemLookup w... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4244/"
] | I've seen several products that will track the sales rank of an item on Amazon. Does Amazon have any web-services published that I can use to get the sales rank of a particular item?
I've looked through the AWS and didn't see anything of that nature. | You should be able to determine the Sales Rank by querying for the SalesRank response group when doing an ItemLookup with the Amazon Associates Web Service.
Example query:
```
http://ecs.amazonaws.com/onca/xml?
Service=AWSECommerceService&
AWSAccessKeyId=[AWS Access Key ID]&
Operation=ItemLookup&
ItemId=0976925524&
R... |
135,600 | <p>When I download my program from my website to my windows 2003 machine, it has a block on it and you have to right click on the exe, then properties, then select the button "Unblock".</p>
<p>I would like to add detection in my installer for when the file is blocked and hence doesn't have enough permissions. </p>
<... | [
{
"answer_id": 135924,
"author": "HitScan",
"author_id": 9490,
"author_profile": "https://Stackoverflow.com/users/9490",
"pm_score": 5,
"selected": true,
"text": "<p>This is done using NTFS File Streams. There is a stream named \"Zone.Identifier\" added to downloaded files. When IE7 down... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | When I download my program from my website to my windows 2003 machine, it has a block on it and you have to right click on the exe, then properties, then select the button "Unblock".
I would like to add detection in my installer for when the file is blocked and hence doesn't have enough permissions.
But I can't eais... | This is done using NTFS File Streams. There is a stream named "Zone.Identifier" added to downloaded files. When IE7 downloads certain types of file that stream contains:
```
[ZoneTransfer]
ZoneId=3
```
The simplest way to set it is to create a text file with those contents in it, and use more to add it to the altern... |
135,664 | <p>For example, how much memory is required to store a list of one million (32-bit) integers?</p>
<pre><code>alist = range(1000000) # or list(range(1000000)) in Python 3.0
</code></pre>
| [
{
"answer_id": 135718,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 5,
"selected": false,
"text": "<p>\"It depends.\" Python allocates space for lists in such a way as to achieve <a href=\"http://effbot.org/zone/pytho... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4279/"
] | For example, how much memory is required to store a list of one million (32-bit) integers?
```
alist = range(1000000) # or list(range(1000000)) in Python 3.0
``` | Useful links:
[How to get memory size/usage of python object](http://bytes.com/forum/thread757255.html)
[Memory sizes of python objects?](http://mail.python.org/pipermail/python-list/2002-March/135223.html)
[if you put data into dictionary, how do we calculate the data size?](http://groups.google.com/group/comp.lang... |
135,670 | <p>This post is similar to <a href="https://stackoverflow.com/questions/16829/structure-of-projects-in-version-control">this previously asked question.</a> I really want to set up my SVN repository in TTB format, but when creating a project in Visual Studio 2008 (ASP.NET/VB.NET), the structure created tends to be inco... | [
{
"answer_id": 135719,
"author": "Lev",
"author_id": 7224,
"author_profile": "https://Stackoverflow.com/users/7224",
"pm_score": 0,
"selected": false,
"text": "<p>If your TTB are common rather than per project, there is no problem with it. Or am I missing something?</p>\n"
},
{
"... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18009/"
] | This post is similar to [this previously asked question.](https://stackoverflow.com/questions/16829/structure-of-projects-in-version-control) I really want to set up my SVN repository in TTB format, but when creating a project in Visual Studio 2008 (ASP.NET/VB.NET), the structure created tends to be incompatible when c... | We went with a very simplistic approach:
**File Structure:**
* Solution Folder (contains solution file, build scripts, maybe more?)
+ Project Folder
+ Project Folder 2
+ References (contains shared assemblies for the solution).
Then we just check the entire solution folder's contents into our repository. We use o... |
135,688 | <p>What is the proper way to modify environment variables like PATH in OS X?</p>
<p>I've looked on Google a little bit and found three different files to edit:</p>
<ul>
<li>/etc/paths</li>
<li>~/.profile</li>
<li>~/.tcshrc</li>
</ul>
<p>I don't even have some of these files, and I'm pretty sure that <em>.tcshrc... | [
{
"answer_id": 135697,
"author": "tim_yates",
"author_id": 6509,
"author_profile": "https://Stackoverflow.com/users/6509",
"pm_score": 7,
"selected": false,
"text": "<p><strong><em>Up to and including <a href=\"http://en.wikipedia.org/wiki/Mac_OS_X_Lion\" rel=\"noreferrer\">OS X&nbs... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | What is the proper way to modify environment variables like PATH in OS X?
I've looked on Google a little bit and found three different files to edit:
* /etc/paths
* ~/.profile
* ~/.tcshrc
I don't even have some of these files, and I'm pretty sure that *.tcshrc* is wrong, since OS X uses bash now. Where are these var... | Bruno is right on track. I've done extensive research and if you want to set variables that are available in all GUI applications, your only option is `/etc/launchd.conf`.
Please note that [environment.plist does not work for applications launched via Spotlight. This is documented by Steve Sexton here](https://web.arc... |
135,734 | <p>I am trying to learn Emacs and trying to find best keyboard layout for me. One thing is really annoying me. I have added following lines to .emacs</p>
<pre class="lang-lisp prettyprint-override"><code>(global-set-key "\C-y" 'scroll-up)
(global-set-key "\M-y" 'scroll-down)
</code></pre>
<p>When I hold <kbd>Control<... | [
{
"answer_id": 136427,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 3,
"selected": true,
"text": "<p>Could this be a side affect of using the Windows key as Meta? I'm thinking this because in a non-Emacs situation if you press... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/438025/"
] | I am trying to learn Emacs and trying to find best keyboard layout for me. One thing is really annoying me. I have added following lines to .emacs
```lisp
(global-set-key "\C-y" 'scroll-up)
(global-set-key "\M-y" 'scroll-down)
```
When I hold `Control` and press `y` a few times, it will page down on every press of `... | Could this be a side affect of using the Windows key as Meta? I'm thinking this because in a non-Emacs situation if you press and hold the Windows key and another key for a short cut (Win+E for Explorer, Win+R for Run dialog, etc.) the desired action only triggers once, not multiple times if you keep holding it down.
... |
135,745 | <p>I have a simple web service, it takes 2 parameters one is a simple xml security token, the other is usually a long xml string. It works with short strings but longer strings give a 400 error message. maxMessageLength did nothing to allow for longer strings.</p>
| [
{
"answer_id": 135809,
"author": "Yuval Peled",
"author_id": 20257,
"author_profile": "https://Stackoverflow.com/users/20257",
"pm_score": 2,
"selected": false,
"text": "<p>You should remove the quotas limitations as well.\nHere is how you can do it in code with Tcp binding. \nI have add... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22367/"
] | I have a simple web service, it takes 2 parameters one is a simple xml security token, the other is usually a long xml string. It works with short strings but longer strings give a 400 error message. maxMessageLength did nothing to allow for longer strings. | You should remove the quotas limitations as well.
Here is how you can do it in code with Tcp binding.
I have added some code that shows removal of timeout problems because usually sending very big arguments causes timeout issues. So use the code wisely...
Of course, you can set these parameters in the config file as w... |
135,754 | <p>It is typical to have something like this in your cshrc file for setting the path:</p>
<pre><code>set path = ( . $otherpath $path )
</code></pre>
<p>but, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication?</p>
<p>EDIT: This is one unclean way of doing it:</... | [
{
"answer_id": 135783,
"author": "Andrew Stein",
"author_id": 13029,
"author_profile": "https://Stackoverflow.com/users/13029",
"pm_score": 0,
"selected": false,
"text": "<p>I always set my path from scratch in .cshrc.\nThat is I start off with a basic path, something like:</p>\n\n<pre><... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18415/"
] | It is typical to have something like this in your cshrc file for setting the path:
```
set path = ( . $otherpath $path )
```
but, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication?
EDIT: This is one unclean way of doing it:
```
set localpaths = ( . $otherpa... | you can use the following Perl script to prune paths of duplicates.
---
```
#!/usr/bin/perl
#
# ^^ ensure this is pointing to the correct location.
#
# Title: SLimPath
# Author: David "Shoe Lace" Pyke <eselle@users.sourceforge.net >
# : Tim Nelson
# Purpose: To create a slim version of my envirnoment path s... |
135,755 | <p>How do you find the version of an installed Perl module?</p>
<p>This is in an answer down at the bottom, but I figure it important enough to live up here. With these suggestions, I create a function in my <code>.bashrc</code></p>
<pre><code>function perlmodver {
perl -M$1 -e 'print "Version " . $ARGV[0]->V... | [
{
"answer_id": 135760,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 6,
"selected": false,
"text": "<p>Most modules (especially ones from The CPAN) have a $VERSION variable:</p>\n\n<pre><code>perl -MSome::Module -le 'print $S... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17339/"
] | How do you find the version of an installed Perl module?
This is in an answer down at the bottom, but I figure it important enough to live up here. With these suggestions, I create a function in my `.bashrc`
```
function perlmodver {
perl -M$1 -e 'print "Version " . $ARGV[0]->VERSION . " of " . $ARGV[0] . \
"... | Why are you trying to get the version of the module? Do you need this from within a program, do you just need the number to pass to another operation, or are you just trying to find out what you have?
I have this built into the `cpan` (which comes with perl) with the `-D` switch so you can see the version that you hav... |
135,759 | <p>Why can't I create a <code>class</code> in <code>VB.NET</code> that <code>inherits</code> <code>System.IO.Directory</code>? According to Lutz Roeder, it is <em>not</em> declared as <code>NotInheritable</code>!</p>
<p>I want to create a <code>utility class</code> that adds functionality to the <code>Directory class... | [
{
"answer_id": 135766,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 3,
"selected": false,
"text": "<p>Are you using <s>C# 3.0</s> VB.NET 2008 -- then you could add an <a href=\"http://msdn.microsoft.com/en-us/library/bb3... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54420/"
] | Why can't I create a `class` in `VB.NET` that `inherits` `System.IO.Directory`? According to Lutz Roeder, it is *not* declared as `NotInheritable`!
I want to create a `utility class` that adds functionality to the `Directory class`. For instance, I want to add a `Directory.Move` function.
Please advise and I will sen... | From the Meta Data of .NET
```
namespace System.IO
{
// Summary:
// Exposes static methods for creating, moving, and enumerating through directories
// and subdirectories. This class cannot be inherited.
[ComVisible(true)]
public static class Directory
```
You cannot inherit from a Static... |
135,775 | <p>Any ideas on how i get MVP working with Silverlight? How Do I get around the fact there is no load event raised?</p>
<p>This the view I have:</p>
<pre><code> public partial class Person: IPersonView
{
public event RoutedEventHandler Loaded;
public Person()
{
new PersonP... | [
{
"answer_id": 135964,
"author": "Santiago Palladino",
"author_id": 12791,
"author_profile": "https://Stackoverflow.com/users/12791",
"pm_score": 1,
"selected": false,
"text": "<p>I believe the loaded event gets called when the control has been initialized, loaded, rendered and ready for... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/230/"
] | Any ideas on how i get MVP working with Silverlight? How Do I get around the fact there is no load event raised?
This the view I have:
```
public partial class Person: IPersonView
{
public event RoutedEventHandler Loaded;
public Person()
{
new PersonPresenter(this);
... | [Tim Ross](http://timross.wordpress.com/2008/03/16/implementing-the-mvp-pattern-in-silverlight/) has a good introduction to Silverlight MVP implementation, with source code. |
135,777 | <h2>Seeking a method to:</h2>
<h2>Take whitespace separated tokens in a String; return a suggested Word</h2>
<p><br>
<strong>ie:</strong><br>
Google Search can take <em>"fonetic wrd nterpreterr"</em>,<br>
and atop of the result page it shows <em>"Did you mean: phonetic word interpreter"</em></p>
<p><em>A solution in... | [
{
"answer_id": 135791,
"author": "jeannicolas",
"author_id": 14981,
"author_profile": "https://Stackoverflow.com/users/14981",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the yahoo web service here:\n<a href=\"http://developer.yahoo.com/search/web/V1/spellingSuggestion.html... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] | Seeking a method to:
--------------------
Take whitespace separated tokens in a String; return a suggested Word
---------------------------------------------------------------------
**ie:**
Google Search can take *"fonetic wrd nterpreterr"*,
and atop of the result page it shows *"Did you mean: phonetic word int... | In his article [How to Write a Spelling Corrector](http://norvig.com/spell-correct.html), Peter Norvig discusses how a Google-like spellchecker could be implemented. The article contains a 20-line implementation in Python, as well as links to several reimplementations in C, C++, C# and Java. Here is an excerpt:
>
> T... |
135,782 | <p>A lot of my C# code follows this pattern:</p>
<pre><code>void foo(string param1, string param2, string param3)
{
try
{
// do something...
}
catch(Exception ex)
{
LogError(String.Format("Error in foo(param1={0}, param2={1}, param3={2}), exception={3}", param1, param2, param3, ex.... | [
{
"answer_id": 135813,
"author": "David Basarab",
"author_id": 2469,
"author_profile": "https://Stackoverflow.com/users/2469",
"pm_score": 1,
"selected": false,
"text": "<p>When I have done this I just created a generic dictionary for the logging.</p>\n\n<p>I have this LogArgs class. An... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | A lot of my C# code follows this pattern:
```
void foo(string param1, string param2, string param3)
{
try
{
// do something...
}
catch(Exception ex)
{
LogError(String.Format("Error in foo(param1={0}, param2={1}, param3={2}), exception={3}", param1, param2, param3, ex.Message));
... | You could use Reflection and the convention that you must pass the parameters to the LogError with the right order:
```
private static void MyMethod(string s, int x, int y)
{
try
{
throw new NotImplementedException();
}
catch (Exception ex)
{
LogError(MethodBase.GetCurrentMethod(), ... |
135,801 | <p>I am using prototype and I can't find any built in extensions to set or retrieve cookies. After googling for a little bit, I see a few different ways to go about it. I was wondering what you think is the best approach for getting a cookie in JavaScript?</p>
| [
{
"answer_id": 135855,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": -1,
"selected": false,
"text": "<p>I use this. It has been dependable:</p>\n\n<pre><code>function getCookie(c_name) {\nif (document.co... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6350/"
] | I am using prototype and I can't find any built in extensions to set or retrieve cookies. After googling for a little bit, I see a few different ways to go about it. I was wondering what you think is the best approach for getting a cookie in JavaScript? | I use this routine:
```
function ReadCookie(name)
{
name += '=';
var parts = document.cookie.split(/;\s*/);
for (var i = 0; i < parts.length; i++)
{
var part = parts[i];
if (part.indexOf(name) == 0)
return part.substring(name.length)
}
return null;
}
```
Works quite well. |
135,802 | <p>I'm looking for the concept to <strong>spawn a process</strong> such that:</p>
<ul>
<li>it has only access to certain libraries/APIs</li>
<li>it cannot acess the file system or only specific parts</li>
<li>it can <strong>do least harm should malicious code run in it</strong></li>
</ul>
<p>This concept is known as ... | [
{
"answer_id": 135836,
"author": "Dan Udey",
"author_id": 21450,
"author_profile": "https://Stackoverflow.com/users/21450",
"pm_score": 2,
"selected": false,
"text": "<p>FreeBSD has specific concepts of <a href=\"http://en.wikipedia.org/wiki/FreeBSD_jail\" rel=\"nofollow noreferrer\">jai... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19435/"
] | I'm looking for the concept to **spawn a process** such that:
* it has only access to certain libraries/APIs
* it cannot acess the file system or only specific parts
* it can **do least harm should malicious code run in it**
This concept is known as sandbox or jail.
It is required to do this **for each major Operati... | Mac OS X has a sandbox facility code-named Seatbelt. The public API for it is documented in the sandbox(7), sandbox\_init(3), and related manual pages. The public API is somewhat limited, but the facility itself is very powerful. While the public API only lets you choose from some pre-defined sandboxes (e.g. “All socke... |
135,803 | <blockquote>
<p>System.InvalidOperationException: DragDrop registration did not
succeed. ---> System.Threading.ThreadStateException:</p>
</blockquote>
<p>What does this exception mean? I get it at this line trying to add a panel to a panel at runtime...</p>
<pre><code>splitReport.Panel1.Controls.Add(ChartPanel);... | [
{
"answer_id": 160867,
"author": "Charlie",
"author_id": 18529,
"author_profile": "https://Stackoverflow.com/users/18529",
"pm_score": 5,
"selected": false,
"text": "<p>This exception means that the thread that owns the Panel (the Panel being added) has been initialized using the MTA thr... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> System.InvalidOperationException: DragDrop registration did not
> succeed. ---> System.Threading.ThreadStateException:
>
>
>
What does this exception mean? I get it at this line trying to add a panel to a panel at runtime...
```
splitReport.Panel1.Controls.Add(ChartPanel);
```
Working in VS2008 C# | This exception means that the thread that owns the Panel (the Panel being added) has been initialized using the MTA threading model. The drag/drop system requires that the calling thread use the STA thread model (particularly it requires that COM be initialized via OleInitialize). Threading models are an unfortunate ve... |
135,835 | <p>I am trying to load a small sample of records from a large database into a test database.</p>
<p>How do you tell mysqldump to only give you n records out of 8 million?</p>
<p>Thanks</p>
| [
{
"answer_id": 135843,
"author": "skaffman",
"author_id": 21234,
"author_profile": "https://Stackoverflow.com/users/21234",
"pm_score": 3,
"selected": false,
"text": "<p>mysqldump can be given a SQL query to execute, from which it will take the data for the dump. You can then use the \"l... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to load a small sample of records from a large database into a test database.
How do you tell mysqldump to only give you n records out of 8 million?
Thanks | As skaffman says, use the **--where** option:
```
mysqldump --opt --where="1 limit 1000000" database
```
Of course, that would give you the first million rows from every table. |
135,845 | <p>A colleague of mine states that <strong>booleans as method arguments are not acceptable</strong>. They shall be replaced by enumerations. At first I did not see any benefit, but he gave me an example.</p>
<p>What's easier to understand?</p>
<pre><code>file.writeData( data, true );
</code></pre>
<p>Or</p>
<pre><c... | [
{
"answer_id": 135865,
"author": "simon",
"author_id": 6040,
"author_profile": "https://Stackoverflow.com/users/6040",
"pm_score": 6,
"selected": false,
"text": "<p>Enums also allow for future modifications, where you now want a third choice (or more).</p>\n"
},
{
"answer_id": 13... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2012356/"
] | A colleague of mine states that **booleans as method arguments are not acceptable**. They shall be replaced by enumerations. At first I did not see any benefit, but he gave me an example.
What's easier to understand?
```
file.writeData( data, true );
```
Or
```
enum WriteMode {
Append,
Overwrite
};
file.write... | Boolean's represent "yes/no" choices. If you want to represent a "yes/no", then use a boolean, it should be self-explanatory.
But if it's a choice between two options, neither of which is clearly yes or no, then an enum can sometimes be more readable. |
135,849 | <p>I'm trying to host a python script using an apache web server, but the server tries to run the script instead of just offering it for download.</p>
<p>I do not have direct access to server, and adding the line</p>
<pre><code>AddType text/plain .py
</code></pre>
<p>to .htaccess in the root folder does not appear t... | [
{
"answer_id": 135869,
"author": "Jeremy Bourque",
"author_id": 2192597,
"author_profile": "https://Stackoverflow.com/users/2192597",
"pm_score": 2,
"selected": false,
"text": "<p>If you can't change the Apache config and you can't override it with an htaccess file, then it seems to me t... | 2008/09/25 | [
"https://Stackoverflow.com/questions/135849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30/"
] | I'm trying to host a python script using an apache web server, but the server tries to run the script instead of just offering it for download.
I do not have direct access to server, and adding the line
```
AddType text/plain .py
```
to .htaccess in the root folder does not appear to work, though I could be doing s... | In your .htaccess:
>
> RemoveHandler .py
>
>
> |