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 |
|---|---|---|---|---|---|---|
3,856 | <p>I wrote a component that displays a filename, a thumbnail and has a button to load/play the file. The component is databound to a repeater. How can I make it so that the button event fires to the main application and tells it which file to play?</p>
| [
{
"answer_id": 3852,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 2,
"selected": false,
"text": "<p>Can you do it as a subselect, something like</p>\n\n<pre><code>SELECT * FROM (\n SELECT A,B,C FROM table WHERE field... | 2008/08/06 | [
"https://Stackoverflow.com/questions/3856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | I wrote a component that displays a filename, a thumbnail and has a button to load/play the file. The component is databound to a repeater. How can I make it so that the button event fires to the main application and tells it which file to play? | Maybe you should try including a fourth column, stating the table it came from, and then order and group by it:
```
SELECT A,B,C, "query 1" as origin FROM table WHERE field LIKE 'query%'
UNION
SELECT A,B,C, "query 2" as origin FROM table WHERE field LIKE '%query'
UNION
SELECT A,B,C, "query 3" as origin FROM table WHER... |
3,894 | <p>Given the constraint of only using T-Sql in Sql Server 2005, is there a better way to remove the decimal point from a money datatype than a conversion to a varchar (here implicitly) and then a replace of the decimal point?</p>
<p>Here is what I have currently.</p>
<pre><code>SELECT REPLACE(1.23, '.', ''), REPLACE(... | [
{
"answer_id": 3897,
"author": "Yaakov Ellis",
"author_id": 51,
"author_profile": "https://Stackoverflow.com/users/51",
"pm_score": 4,
"selected": true,
"text": "<p>Multiply by 100 and then convert to an int.</p>\n"
},
{
"answer_id": 3899,
"author": "Curt Hagenlocher",
"a... | 2008/08/06 | [
"https://Stackoverflow.com/questions/3894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/76/"
] | Given the constraint of only using T-Sql in Sql Server 2005, is there a better way to remove the decimal point from a money datatype than a conversion to a varchar (here implicitly) and then a replace of the decimal point?
Here is what I have currently.
```
SELECT REPLACE(1.23, '.', ''), REPLACE(19.99, '.', '')
```
... | Multiply by 100 and then convert to an int. |
3,903 | <p>Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote up a method using the registry to try and determine whether or not the current system is a 32 or 64bit system.</p>
<pre><code>private Boolean is64BitOperatingSystem()
{
RegistryKey localEnvironment = Registr... | [
{
"answer_id": 3909,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 1,
"selected": false,
"text": "<p>Looking into the registry is perfectly valid, so long as you can be sure that the user of the application will always have... | 2008/08/06 | [
"https://Stackoverflow.com/questions/3903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/560/"
] | Since the WMI class Win32\_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote up a method using the registry to try and determine whether or not the current system is a 32 or 64bit system.
```
private Boolean is64BitOperatingSystem()
{
RegistryKey localEnvironment = Registry.LocalMachin... | Take a look at Raymond Chens solution:
[How to detect programmatically whether you are running on 64-bit Windows](http://blogs.msdn.com/oldnewthing/archive/2005/02/01/364563.aspx)
and here's the PINVOKE for .NET:
[IsWow64Process (kernel32)](http://www.pinvoke.net/default.aspx/kernel32/IsWow64Process.html?diff=y)
**... |
3,976 | <p>I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial . </p>
<p>When i do this everything seems ... | [
{
"answer_id": 4128,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 0,
"selected": false,
"text": "<p>have you tried watching the traffic between the GUI and the serial port to see if there is some kind of special command be... | 2008/08/06 | [
"https://Stackoverflow.com/questions/3976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556/"
] | I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial .
When i do this everything seems to be hunk... | `/dev/cu.xxxxx` is the "callout" device, it's what you use when you establish a connection to the serial device and start talking to it. `/dev/tty.xxxxx` is the "dialin" device, used for monitoring a port for incoming calls for e.g. a fax listener. |
4,046 | <p>I'm trying to convince my providers to use ANT instead of Rational Application Development so anyone can recompile, recheck, redeploy the solution anyplace, anytime, anyhow. :P</p>
<p>I started a build.xml for a project that generates a JAR file but stopped there and I need real examples to compare notes. My good f... | [
{
"answer_id": 4902,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 5,
"selected": true,
"text": "<p>My Environment: Fedora 8; WAS 6.1 (as installed with Rational Application Developer 7)</p>\n\n<p>The documentation is very po... | 2008/08/06 | [
"https://Stackoverflow.com/questions/4046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/527/"
] | I'm trying to convince my providers to use ANT instead of Rational Application Development so anyone can recompile, recheck, redeploy the solution anyplace, anytime, anyhow. :P
I started a build.xml for a project that generates a JAR file but stopped there and I need real examples to compare notes. My good friends! I ... | My Environment: Fedora 8; WAS 6.1 (as installed with Rational Application Developer 7)
The documentation is very poor in this area and there is a dearth of practical examples.
**Using the WebSphere Application Server (WAS) Ant tasks**
To run as described here, you need to run them from your server **profile** bin di... |
4,051 | <p>In <code>C</code> can I <strong>pass a multidimensional array</strong> to a function <strong>as a single argument</strong> when I don't know what the dimensions of the array are going to be?</p>
<p>Besides, my multidimensional array may contain types other than strings.</p>
| [
{
"answer_id": 4192,
"author": "andrewrk",
"author_id": 432,
"author_profile": "https://Stackoverflow.com/users/432",
"pm_score": 6,
"selected": true,
"text": "<p>You can do this with any data type. Simply make it a pointer-to-pointer:</p>\n\n<pre><code>typedef struct {\n int myint;\n ... | 2008/08/06 | [
"https://Stackoverflow.com/questions/4051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/381/"
] | In `C` can I **pass a multidimensional array** to a function **as a single argument** when I don't know what the dimensions of the array are going to be?
Besides, my multidimensional array may contain types other than strings. | You can do this with any data type. Simply make it a pointer-to-pointer:
```
typedef struct {
int myint;
char* mystring;
} data;
data** array;
```
But don't forget you still have to malloc the variable, and it does get a bit complex:
```
//initialize
int x,y,w,h;
w = 10; //width of array
h = 20; //height of ar... |
4,052 | <p>I am trying to enable Full-text indexing in SQL Server 2005 Express. I am running this on my laptop with Vista Ultimate.</p>
<p>I understand that the standard version of SQL Server Express does not have full-text indexing. I have already downloaded and installed "Microsoft SQL Server 2005 Express Edition with Advan... | [
{
"answer_id": 4139,
"author": "csmba",
"author_id": 350,
"author_profile": "https://Stackoverflow.com/users/350",
"pm_score": 5,
"selected": true,
"text": "<pre><code>sp_fulltext_database 'enable'\n\nCREATE FULLTEXT CATALOG [myFullText]\nWITH ACCENT_SENSITIVITY = ON\n\nCREATE FULLTEXT I... | 2008/08/06 | [
"https://Stackoverflow.com/questions/4052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/576/"
] | I am trying to enable Full-text indexing in SQL Server 2005 Express. I am running this on my laptop with Vista Ultimate.
I understand that the standard version of SQL Server Express does not have full-text indexing. I have already downloaded and installed "Microsoft SQL Server 2005 Express Edition with Advanced Servic... | ```
sp_fulltext_database 'enable'
CREATE FULLTEXT CATALOG [myFullText]
WITH ACCENT_SENSITIVITY = ON
CREATE FULLTEXT INDEX ON [dbo].[tblName] KEY INDEX [PK_something] ON [myFullText] WITH CHANGE_TRACKING AUTO
ALTER FULLTEXT INDEX ON [dbo].[otherTable] ADD ([Text])
ALTER FULLTEXT INDEX ON [dbo].[teyOtherTable] ENABLE
... |
4,072 | <p>I just did a merge using something like:</p>
<pre><code>svn merge -r 67212:67213 https://my.svn.repository/trunk .
</code></pre>
<p>I only had 2 files, one of which is a simple <code>ChangeLog</code>. Rather than just merging my <code>ChangeLog</code> changes, it actually pulled mine plus some previous ones that ... | [
{
"answer_id": 4104,
"author": "Ecton",
"author_id": 457,
"author_profile": "https://Stackoverflow.com/users/457",
"pm_score": 0,
"selected": false,
"text": "<p>There's not really enough information to go on here.</p>\n\n<pre><code>svn merge -r 67212:67213 https://my.svn.repository/trunk... | 2008/08/06 | [
"https://Stackoverflow.com/questions/4072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I just did a merge using something like:
```
svn merge -r 67212:67213 https://my.svn.repository/trunk .
```
I only had 2 files, one of which is a simple `ChangeLog`. Rather than just merging my `ChangeLog` changes, it actually pulled mine plus some previous ones that were not in the destination `ChangeLog`. I notice... | This only happens with conflicts - basically svn tried to merge the change in, but (roughly speaking) saw the change as:
Add
```
2008-08-06 Mike Stone <myemail>
* changed_file: Details.
```
before
```
2008-08-06 Someone Else <their_email>
```
And it couldn't find the Someone Else line while doing the merge,... |
4,080 | <p>What code analysis tools do you use on your Java projects?</p>
<p>I am interested in all kinds</p>
<ul>
<li>static code analysis tools (FindBugs, PMD, and any others)</li>
<li>code coverage tools (Cobertura, Emma, and any others)</li>
<li>any other instrumentation-based tools </li>
<li>anything else, if I'm missin... | [
{
"answer_id": 4166,
"author": "ggasp",
"author_id": 527,
"author_profile": "https://Stackoverflow.com/users/527",
"pm_score": 1,
"selected": false,
"text": "<p>We use FindBugs and JDepend integrated with Ant. We use JUnit but we're not using any coverage tool. </p>\n\n<p>I'm not using i... | 2008/08/06 | [
"https://Stackoverflow.com/questions/4080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/235/"
] | What code analysis tools do you use on your Java projects?
I am interested in all kinds
* static code analysis tools (FindBugs, PMD, and any others)
* code coverage tools (Cobertura, Emma, and any others)
* any other instrumentation-based tools
* anything else, if I'm missing something
If applicable, also state what... | For static analysis tools I often use CPD, [PMD](http://pmd.sourceforge.net), [FindBugs](http://findbugs.sourceforge.net), and [Checkstyle](http://checkstyle.sourceforge.net).
CPD is the PMD "Copy/Paste Detector" tool. I was using PMD for a little while before I noticed the ["Finding Duplicated Code" link](http://pmd.... |
4,138 | <p>What is the best SVN Ignore Pattern should TortoiseSVN have for a VB.NET solution?</p>
| [
{
"answer_id": 4140,
"author": "Karl Seguin",
"author_id": 34,
"author_profile": "https://Stackoverflow.com/users/34",
"pm_score": 5,
"selected": true,
"text": "<p>this is what I use for C# w/resharper, should work just the same with vb.net:</p>\n\n<pre><code>build deploy */bin */bin/* ... | 2008/08/06 | [
"https://Stackoverflow.com/questions/4138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | What is the best SVN Ignore Pattern should TortoiseSVN have for a VB.NET solution? | this is what I use for C# w/resharper, should work just the same with vb.net:
```
build deploy */bin */bin/* obj *.dll *.pdb *.user *.suo _ReSharper* *.resharper* bin
``` |
4,149 | <p>I have an application that writes information to file. This information is used post-execution to determine pass/failure/correctness of the application. I'd like to be able to read the file as it is being written so that I can do these pass/failure/correctness checks in real time.</p>
<p>I assume it is possible to ... | [
{
"answer_id": 4188,
"author": "Matthew Schinckel",
"author_id": 188,
"author_profile": "https://Stackoverflow.com/users/188",
"pm_score": 1,
"selected": false,
"text": "<p>Not Java per-se, but you may run into issues where you have written something to a file, but it hasn't been actuall... | 2008/08/06 | [
"https://Stackoverflow.com/questions/4149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/488/"
] | I have an application that writes information to file. This information is used post-execution to determine pass/failure/correctness of the application. I'd like to be able to read the file as it is being written so that I can do these pass/failure/correctness checks in real time.
I assume it is possible to do this, b... | Could not get the example to work using `FileChannel.read(ByteBuffer)` because it isn't a blocking read. Did however get the code below to work:
```
boolean running = true;
BufferedInputStream reader = new BufferedInputStream(new FileInputStream( "out.txt" ) );
public void run() {
while( running ) {
if( r... |
4,168 | <p>I'm looking for a simple algorithm to 'serialize' a directed graph. In particular I've got a set of files with interdependencies on their execution order, and I want to find the correct order at compile time. I know it must be a fairly common thing to do - compilers do it all the time - but my google-fu has been wea... | [
{
"answer_id": 4177,
"author": "Lily Ballard",
"author_id": 582,
"author_profile": "https://Stackoverflow.com/users/582",
"pm_score": 1,
"selected": false,
"text": "<p>I would expect tools that need this simply walk the tree in a depth-first manner and when they hit a leaf, just process ... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/588/"
] | I'm looking for a simple algorithm to 'serialize' a directed graph. In particular I've got a set of files with interdependencies on their execution order, and I want to find the correct order at compile time. I know it must be a fairly common thing to do - compilers do it all the time - but my google-fu has been weak t... | [Topological Sort](http://en.wikipedia.org/wiki/Topological_sorting) (From Wikipedia):
>
> In graph theory, a topological sort or
> topological ordering of a directed
> acyclic graph (DAG) is a linear
> ordering of its nodes in which each
> node comes before all nodes to which
> it has outbound edges. Every DAG ... |
4,170 | <p>I need to learn ADO.NET to build applications based on MS Office. I have read a good deal about ADO.NET in the MSDN Library, but everything seems rather messy to me.</p>
<p>What are the basics one must figure out when using ADO.NET? I think a few key words will suffice to let me organize my learning.</p>
| [
{
"answer_id": 4204,
"author": "Karl Seguin",
"author_id": 34,
"author_profile": "https://Stackoverflow.com/users/34",
"pm_score": 4,
"selected": true,
"text": "<p>There are three key components (assuming ur using SQL server):</p>\n\n<ul>\n<li><code>SQLConnection</code></li>\n<li><code>S... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to learn ADO.NET to build applications based on MS Office. I have read a good deal about ADO.NET in the MSDN Library, but everything seems rather messy to me.
What are the basics one must figure out when using ADO.NET? I think a few key words will suffice to let me organize my learning. | There are three key components (assuming ur using SQL server):
* `SQLConnection`
* `SqlCommand`
* `SqlDataReader`
(if you're using something else, replace `Sql` with "Something", like `MySqlConnection`, `OracleCommand`)
Everything else is just built on top of that.
**Example 1:**
```
using (SqlConnection connectio... |
4,208 | <p>Is there a Windows equivalent of the Unix command, <em>nice</em>?</p>
<p>I'm specifically looking for something I can use at the command line, and <strong>not</strong> the "Set Priority" menu from the task manager.</p>
<p>My attempts at finding this on Google have been thwarted by those who can't come up with bett... | [
{
"answer_id": 4262,
"author": "ggasp",
"author_id": 527,
"author_profile": "https://Stackoverflow.com/users/527",
"pm_score": 3,
"selected": false,
"text": "<p>Maybe you want to consider using <a href=\"http://www.donationcoder.com/Software/Mouser/proctamer/index.html\" rel=\"noreferrer... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55/"
] | Is there a Windows equivalent of the Unix command, *nice*?
I'm specifically looking for something I can use at the command line, and **not** the "Set Priority" menu from the task manager.
My attempts at finding this on Google have been thwarted by those who can't come up with better adjectives. | If you want to set priority when launching a process you could use the built-in [START](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/start) command:
```batch
START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | ... |
4,221 | <p>I'd like to use a <code>LinqDataSource</code> control on a page and limit the amount of records returned. I know if I use code behind I could do something like this:</p>
<pre><code>IEnumerable<int> values = Enumerable.Range(0, 10);
IEnumerable<int> take3 = values.Take(3);
</code></pre>
<p>Does anyone ... | [
{
"answer_id": 4231,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 2,
"selected": false,
"text": "<p>I know that if you use a paging repeater or gridview with the linqdatasource it will automatically optimize the number of resu... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/519/"
] | I'd like to use a `LinqDataSource` control on a page and limit the amount of records returned. I know if I use code behind I could do something like this:
```
IEnumerable<int> values = Enumerable.Range(0, 10);
IEnumerable<int> take3 = values.Take(3);
```
Does anyone know if something like this is possible with a `Li... | I had this same issue. The way I got round this was to use the Selecting event on the LinqDataSource and return the result manually.
e.g.
```
protected void lnqRecentOrder_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
DataClassesDataContext dx = new DataClassesDataContext();
e.Result = (from o i... |
4,227 | <p>I'm using a <code>Dictionary<string, int></code> where the <code>int</code> is a count of the key.</p>
<p>Now, I need to access the last-inserted Key inside the Dictionary, but I do not know the name of it. The obvious attempt:</p>
<pre><code>int LastCount = mydict[mydict.keys[mydict.keys.Count]];
</code></p... | [
{
"answer_id": 4252,
"author": "Patrick",
"author_id": 429,
"author_profile": "https://Stackoverflow.com/users/429",
"pm_score": 3,
"selected": false,
"text": "<p>You could always do this:</p>\n\n<pre><code>string[] temp = new string[mydict.count];\nmydict.Keys.CopyTo(temp, 0)\nint LastC... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | I'm using a `Dictionary<string, int>` where the `int` is a count of the key.
Now, I need to access the last-inserted Key inside the Dictionary, but I do not know the name of it. The obvious attempt:
```
int LastCount = mydict[mydict.keys[mydict.keys.Count]];
```
does not work, because `Dictionary.Keys` does not imp... | As @Falanwe points out in a comment, doing something like this is ***incorrect***:
```
int LastCount = mydict.Keys.ElementAt(mydict.Count -1);
```
You **should not** depend on the order of keys in a Dictionary. If you need ordering, you should use an [OrderedDictionary](https://learn.microsoft.com/en-us/dotnet/api/s... |
4,242 | <p>I want to convert a primitive to a string, and I tried:</p>
<pre><code>myInt.toString();
</code></pre>
<p>This fails with the error:</p>
<pre><code>int cannot be dereferenced
</code></pre>
<p>Now, I get that primitives are not reference types (ie, not an Object) and so cannot have methods. However, Java 5 intro... | [
{
"answer_id": 4247,
"author": "Justin Standard",
"author_id": 92,
"author_profile": "https://Stackoverflow.com/users/92",
"pm_score": 7,
"selected": true,
"text": "<p>Java autoboxing/unboxing doesn't go to the extent to allow you to dereference a primitive, so your compiler prevents it.... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I want to convert a primitive to a string, and I tried:
```
myInt.toString();
```
This fails with the error:
```
int cannot be dereferenced
```
Now, I get that primitives are not reference types (ie, not an Object) and so cannot have methods. However, Java 5 introduced autoboxing and unboxing (a la C#... which I ... | Java autoboxing/unboxing doesn't go to the extent to allow you to dereference a primitive, so your compiler prevents it. Your compiler still knows `myInt` as a primitive. There's a paper about this issue at [jcp.org](http://jcp.org/aboutJava/communityprocess/jsr/tiger/autoboxing.html).
Autoboxing is mainly useful duri... |
4,246 | <p>What is the best method for executing FTP commands from a SQL Server stored procedure? we currently use something like this:</p>
<pre><code>EXEC master..xp_cmdshell 'ftp -n -s:d:\ftp\ftpscript.xmt 172.1.1.1'
</code></pre>
<p>The problem is that the command seems to succeed even if the FTP ended in error. Also, the... | [
{
"answer_id": 4271,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 4,
"selected": true,
"text": "<p>If you're running SQL 2005 you could do this in a CLR integration assembly and use the FTP classes in the System.Net namespace to ... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162/"
] | What is the best method for executing FTP commands from a SQL Server stored procedure? we currently use something like this:
```
EXEC master..xp_cmdshell 'ftp -n -s:d:\ftp\ftpscript.xmt 172.1.1.1'
```
The problem is that the command seems to succeed even if the FTP ended in error. Also, the use of `xp_cmdshell` requ... | If you're running SQL 2005 you could do this in a CLR integration assembly and use the FTP classes in the System.Net namespace to build a simple FTP client.
You'd benefit from being able to trap and handle exceptions and reduce the security risk of having to use xp\_cmdshell.
Just some thoughts. |
4,287 | <p>I have a process in erlang that is supposed to do something immediately after spawn, then send the result back to the parent when it is finished. How do I figure out the PID of the process that spawned it?</p>
| [
{
"answer_id": 4304,
"author": "Lily Ballard",
"author_id": 582,
"author_profile": "https://Stackoverflow.com/users/582",
"pm_score": 5,
"selected": true,
"text": "<p>You should pass self() to the child as one of the arguments to the entry function.</p>\n\n<pre><code>spawn_link(?MODULE, ... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/121/"
] | I have a process in erlang that is supposed to do something immediately after spawn, then send the result back to the parent when it is finished. How do I figure out the PID of the process that spawned it? | You should pass self() to the child as one of the arguments to the entry function.
```
spawn_link(?MODULE, child, [self()]).
``` |
4,306 | <p>I am working on a project that requires the manipulation of enormous matrices, specifically pyramidal summation for a copula calculation. </p>
<p>In short, I need to keep track of a relatively small number of values (usually a value of 1, and in rare cases more than 1) in a sea of zeros in the matrix (multidimensi... | [
{
"answer_id": 4311,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 6,
"selected": true,
"text": "<p>For C++, a map works well. Several million objects won't be a problem. 10 million items took about 4.4 seconds and abo... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/522/"
] | I am working on a project that requires the manipulation of enormous matrices, specifically pyramidal summation for a copula calculation.
In short, I need to keep track of a relatively small number of values (usually a value of 1, and in rare cases more than 1) in a sea of zeros in the matrix (multidimensional array)... | For C++, a map works well. Several million objects won't be a problem. 10 million items took about 4.4 seconds and about 57 meg on my computer.
My test application is as follows:
```
#include <stdio.h>
#include <stdlib.h>
#include <map>
class triple {
public:
int x;
int y;
int z;
bool operator<(const... |
4,369 | <p>I have a directory structure like the following;</p>
<blockquote>
<p>script.php</p>
<p>inc/include1.php<br/>
inc/include2.php</p>
<p>objects/object1.php<br/>
objects/object2.php</p>
<p>soap/soap.php</p>
</blockquote>
<p>Now, I use those objects in both <code>script.php</code> and <code>/soap/s... | [
{
"answer_id": 4378,
"author": "Ryan Fox",
"author_id": 55,
"author_profile": "https://Stackoverflow.com/users/55",
"pm_score": 3,
"selected": false,
"text": "<p>You could define a constant with the path to the root directory of your project, and then put that at the beginning of the pat... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264/"
] | I have a directory structure like the following;
>
> script.php
>
>
> inc/include1.php
>
> inc/include2.php
>
>
> objects/object1.php
>
> objects/object2.php
>
>
> soap/soap.php
>
>
>
Now, I use those objects in both `script.php` and `/soap/soap.php`, I could move them, but I want the directory stru... | This should work
```
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
include "$root/inc/include1.php";
```
---
**Edit:** added imporvement by [aussieviking](https://stackoverflow.com/questions/4369/include-files-requiring-an-absolute-path#4388) |
4,371 | <p>I lost my MySQL username and password. How do I retrieve it?</p>
| [
{
"answer_id": 4376,
"author": "Xenph Yan",
"author_id": 264,
"author_profile": "https://Stackoverflow.com/users/264",
"pm_score": 9,
"selected": true,
"text": "<blockquote>\n<p>Stop the MySQL process.</p>\n<p>Start the MySQL process with the --skip-grant-tables option.</p>\n<p>Start the... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131/"
] | I lost my MySQL username and password. How do I retrieve it? | >
> Stop the MySQL process.
>
>
> Start the MySQL process with the --skip-grant-tables option.
>
>
> Start the MySQL console client with the -u root option.
>
>
>
List all the users;
```
SELECT * FROM mysql.user;
```
Reset password;
```
UPDATE mysql.user SET Password=PASSWORD('[password]') WHERE User='[use... |
4,393 | <p>How can I drop all tables whose names begin with a given string? </p>
<p>I think this can be done with some dynamic SQL and the <code>INFORMATION_SCHEMA</code> tables.</p>
| [
{
"answer_id": 4394,
"author": "Xenph Yan",
"author_id": 264,
"author_profile": "https://Stackoverflow.com/users/264",
"pm_score": 7,
"selected": false,
"text": "<pre><code>SELECT 'DROP TABLE \"' + TABLE_NAME + '\"' \nFROM INFORMATION_SCHEMA.TABLES \nWHERE TABLE_NAME LIKE '[prefix]%'\n</... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/369/"
] | How can I drop all tables whose names begin with a given string?
I think this can be done with some dynamic SQL and the `INFORMATION_SCHEMA` tables. | You may need to modify the query to include the owner if there's more than one in the database.
```sql
DECLARE @cmd varchar(4000)
DECLARE cmds CURSOR FOR
SELECT 'drop table [' + Table_Name + ']'
FROM INFORMATION_SCHEMA.TABLES
WHERE Table_Name LIKE 'prefix%'
OPEN cmds
WHILE 1 = 1
BEGIN
FETCH cmds INTO @cmd
IF ... |
4,416 | <p>I am walking through the MS Press Windows Workflow Step-by-Step book and in chapter 8 it mentions a tool with the filename "wca.exe". This is supposed to be able to generate workflow communication helper classes based on an interface you provide it. I can't find that file. I thought it would be in the latest .NET... | [
{
"answer_id": 4394,
"author": "Xenph Yan",
"author_id": 264,
"author_profile": "https://Stackoverflow.com/users/264",
"pm_score": 7,
"selected": false,
"text": "<pre><code>SELECT 'DROP TABLE \"' + TABLE_NAME + '\"' \nFROM INFORMATION_SCHEMA.TABLES \nWHERE TABLE_NAME LIKE '[prefix]%'\n</... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] | I am walking through the MS Press Windows Workflow Step-by-Step book and in chapter 8 it mentions a tool with the filename "wca.exe". This is supposed to be able to generate workflow communication helper classes based on an interface you provide it. I can't find that file. I thought it would be in the latest .NET 3.5 S... | You may need to modify the query to include the owner if there's more than one in the database.
```sql
DECLARE @cmd varchar(4000)
DECLARE cmds CURSOR FOR
SELECT 'drop table [' + Table_Name + ']'
FROM INFORMATION_SCHEMA.TABLES
WHERE Table_Name LIKE 'prefix%'
OPEN cmds
WHILE 1 = 1
BEGIN
FETCH cmds INTO @cmd
IF ... |
4,418 | <p>The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?</p>
<p>... or am I just being lazy?</p>
<p>Note: rubysspi-1.2.4 does not work.</p>
<p>This also works for "igem", part of the IronRuby pr... | [
{
"answer_id": 4420,
"author": "Jarin Udom",
"author_id": 574,
"author_profile": "https://Stackoverflow.com/users/574",
"pm_score": 3,
"selected": false,
"text": "<p>A workaround is to install <a href=\"http://web.archive.org/web/20060913093359/http://apserver.sourceforge.net:80/\" rel=\... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/307/"
] | The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?
... or am I just being lazy?
Note: rubysspi-1.2.4 does not work.
This also works for "igem", part of the IronRuby project | I wasn't able to get mine working from the command-line switch but I have been able to do it just by setting my `HTTP_PROXY` environment variable. (Note that case seems to be important). I have a batch file that has a line like this in it:
```
SET HTTP_PROXY=http://%USER%:%PASSWORD%@%SERVER%:%PORT%
```
I set the fou... |
4,432 | <p>Typical way of creating a <a href="http://en.wikipedia.org/wiki/Comma-separated_values" rel="noreferrer">CSV</a> string (pseudocode):</p>
<ol>
<li>Create a CSV container object (like a StringBuilder in C#).</li>
<li>Loop through the strings you want to add appending a comma after each one.</li>
<li>After the loop, ... | [
{
"answer_id": 4437,
"author": "Chris Farmer",
"author_id": 404,
"author_profile": "https://Stackoverflow.com/users/404",
"pm_score": 2,
"selected": false,
"text": "<p>You could instead add the comma as the first thing inside your foreach.</p>\n\n<p><code>if (sb.Length > 0) sb.Append(... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/202/"
] | Typical way of creating a [CSV](http://en.wikipedia.org/wiki/Comma-separated_values) string (pseudocode):
1. Create a CSV container object (like a StringBuilder in C#).
2. Loop through the strings you want to add appending a comma after each one.
3. After the loop, remove that last superfluous comma.
Code sample:
``... | You could use [LINQ to Objects](http://en.wikipedia.org/wiki/Language_Integrated_Query#LINQ_to_Objects):
```
string [] strings = contactList.Select(c => c.Name).ToArray();
string csv = string.Join(",", strings);
```
Obviously that could all be done in one line, but it's a bit clearer on two. |
4,506 | <p>I'm writing a resource handling method where I control access to various files, and I'd like to be able to make use of the browser's cache. My question is two-fold:</p>
<ol>
<li><p>Which are the definitive HTTP headers that I need to check in order to know for sure whether I should send a 304 response, and what am... | [
{
"answer_id": 4509,
"author": "Ishmaeel",
"author_id": 227,
"author_profile": "https://Stackoverflow.com/users/227",
"pm_score": 2,
"selected": false,
"text": "<p>You should send a 304 if the client has explicitly stated that it may already have the page in its cache. This is called a c... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | I'm writing a resource handling method where I control access to various files, and I'd like to be able to make use of the browser's cache. My question is two-fold:
1. Which are the definitive HTTP headers that I need to check in order to know for sure whether I should send a 304 response, and what am I looking for wh... | Here's how I implemented it. The code has been working for a bit more than a year and with multiple browsers, so I think it's pretty reliable. This is based on [RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) and by observing what and when the various browsers were sending.
Here's the pseudocode:
``... |
4,533 | <p>How do I generate an ETag HTTP header for a resource file?</p>
| [
{
"answer_id": 4540,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 5,
"selected": true,
"text": "<p>An etag is an arbitrary string that the server sends to the client that the client will send back to the server the next... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | How do I generate an ETag HTTP header for a resource file? | An etag is an arbitrary string that the server sends to the client that the client will send back to the server the next time the file is requested.
The etag should be computable on the server based on the file. Sort of like a checksum, but you might not want to checksum every file sending it out.
```
server ... |
4,544 | <p>I'm trying to create a bookmarklet for posting del.icio.us bookmarks to a separate account.</p>
<p>I tested it from the command line like:</p>
<pre><code>wget -O - --no-check-certificate \
"https://seconduser:thepassword@api.del.icio.us/v1/posts/add?url=http://seet.dk&description=test"
</code></pre>
<p>This w... | [
{
"answer_id": 4546,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": 1,
"selected": false,
"text": "<p>Does calling the method twice work?</p>\n\n<p>Seems to me that your authentication is being approved after the content arr... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/86/"
] | I'm trying to create a bookmarklet for posting del.icio.us bookmarks to a separate account.
I tested it from the command line like:
```
wget -O - --no-check-certificate \
"https://seconduser:thepassword@api.del.icio.us/v1/posts/add?url=http://seet.dk&description=test"
```
This works great.
I then wanted to create ... | Can you sniff the traffic to find what's actually being sent? Is it sending any auth data at all and it's incorrect or being presented in a form the server doesn't like, or is it never being sent by firefox at all? |
4,582 | <p>I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following URL:</p>
<p><a href="http://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html" rel="noreferrer"><a href="... | [
{
"answer_id": 4584,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 1,
"selected": false,
"text": "<p>If I remember correctly, this matrix allows you to save the data to a file with compression.</p>\n\n<p>If you read f... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/609/"
] | I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following URL:
[<http://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html>](http://vsr.informatik.tu-chemnitz.de/~jan/MP... | The result of a DCT is a transformation of the original source into the frequency domain. The top left entry stores the "amplitude" the "base" frequency and frequency increases both along the horizontal and vertical axes. The outcome of the DCT is usually a collection of amplitudes at the more usual lower frequencies (... |
4,610 | <p>How is it possible to make prototype methods in C#.Net?</p>
<p>In JavaScript, I can do the following to create a trim method for the string object:</p>
<pre><code>String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
</code></pre>
<p>How can I go about doing this in C#.Net?</p>
| [
{
"answer_id": 4614,
"author": "David Wengier",
"author_id": 489,
"author_profile": "https://Stackoverflow.com/users/489",
"pm_score": 0,
"selected": false,
"text": "<p>You need to create an extension method, which requires .NET 3.5. The method needs to be static, in a static class. The ... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] | How is it possible to make prototype methods in C#.Net?
In JavaScript, I can do the following to create a trim method for the string object:
```
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
```
How can I go about doing this in C#.Net? | You can't dynamically add methods to existing objects or classes in .NET, except by changing the source for that class.
You can, however, in C# 3.0, use extension methods, which *look* like new methods, but are compile-time magic.
To do this for your code:
```
public static class StringExtensions
{
public static... |
4,612 | <p>Is <em>CompileAssemblyFromDom</em> faster than <em>CompileAssemblyFromSource</em>?</p>
<p>It <em>should</em> be as it presumably bypasses the compiler front-end.</p>
| [
{
"answer_id": 4659,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "<p>I've tried finding the ultimate compiler call earlier and I gave up. There's quite a number of layers of interfaces ... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/608/"
] | Is *CompileAssemblyFromDom* faster than *CompileAssemblyFromSource*?
It *should* be as it presumably bypasses the compiler front-end. | CompileAssemblyFromDom compiles to a .cs file which is then run through the normal C# compiler.
Example:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CSharp;
using System.CodeDom;
using System.IO;
using System.CodeDom.Compiler;
using System.Reflection;
nam... |
4,622 | <p>What is the <strong>complete</strong> and correct syntax for the SQL Case expression?</p>
| [
{
"answer_id": 4626,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 7,
"selected": true,
"text": "<p>The <strong>complete</strong> syntax depends on the database engine you're working with:</p>\n\n<p>For SQL Server:</p... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] | What is the **complete** and correct syntax for the SQL Case expression? | The **complete** syntax depends on the database engine you're working with:
For SQL Server:
```
CASE case-expression
WHEN when-expression-1 THEN value-1
[ WHEN when-expression-n THEN value-n ... ]
[ ELSE else-value ]
END
```
or:
```
CASE
WHEN boolean-when-expression-1 THEN value-1
[ WHEN boolean-when... |
4,629 | <p>I can do an <code>eval("something()");</code> to execute the code dynamically in JavaScript. Is there a way for me to do the same thing in C#?</p>
<p>An example of what I am trying to do is: I have an integer variable (say <code>i</code>) and I have multiple properties by the names: "Property1", "Property2", "Prope... | [
{
"answer_id": 4633,
"author": "David Wengier",
"author_id": 489,
"author_profile": "https://Stackoverflow.com/users/489",
"pm_score": 2,
"selected": false,
"text": "<p>You can use reflection to get the property and invoke it. Something like this:</p>\n\n<pre><code>object result = theObj... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/384/"
] | I can do an `eval("something()");` to execute the code dynamically in JavaScript. Is there a way for me to do the same thing in C#?
An example of what I am trying to do is: I have an integer variable (say `i`) and I have multiple properties by the names: "Property1", "Property2", "Property3", etc.
Now, I want to perfo... | **DISCLAIMER:** This answer was written back in 2008. The landscape has changed drastically since then.
Look at the other answers on this page, especially the one detailing `Microsoft.CodeAnalysis.CSharp.Scripting`.
Rest of answer will be left as it was originally posted but is no longer accurate.
---
Unfortunately... |
4,661 | <p>I have more than one OpenID as I have tried out numerous. As people take up OpenID different suppliers are going to emerge I may want to switch provinders. As all IDs are me, and all are authenticated against the same email address, shouldn't I be able to log into stack overflow with any of them and be able to hit... | [
{
"answer_id": 4777,
"author": "Otto",
"author_id": 519,
"author_profile": "https://Stackoverflow.com/users/519",
"pm_score": 6,
"selected": true,
"text": "<p>I think each site that implements OpenID would have to build their software to allow multiple entries for your OpenID credentials... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/274/"
] | I have more than one OpenID as I have tried out numerous. As people take up OpenID different suppliers are going to emerge I may want to switch provinders. As all IDs are me, and all are authenticated against the same email address, shouldn't I be able to log into stack overflow with any of them and be able to hit the ... | I think each site that implements OpenID would have to build their software to allow multiple entries for your OpenID credentials. However, just because a site doesn't allow you to create multiple entries doesn't mean you can't swap out OpenID suppliers.
How to turn your blog into an OpenID
---------------------------... |
4,677 | <p>The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object instance. Although I know how to code the singleton pattern in C++ and Java, I was wondering if anyone know how to implement it in Ruby?</p>
| [
{
"answer_id": 4686,
"author": "cynicalman",
"author_id": 410,
"author_profile": "https://Stackoverflow.com/users/410",
"pm_score": 3,
"selected": false,
"text": "<p>Use the singleton module:</p>\n\n<pre><code>class Clazz\n include Singleton\nend\n</code></pre>\n\n<p>See <a href=\"http:... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25/"
] | The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object instance. Although I know how to code the singleton pattern in C++ and Java, I was wondering if anyone know how to implement it in Ruby? | Actually, the above answer was not completely correct.
```
require 'singleton'
class Example
include Singleton
end
```
You also need to include the require 'singleton' statement. |
4,738 | <p>I'm developing a data access component that will be used in a website that contains a mix of classic ASP and ASP.NET pages, and need a good way to manage its configuration settings.</p>
<p>I'd like to use a custom <code>ConfigurationSection</code>, and for the ASP.NET pages this works great. But when the component... | [
{
"answer_id": 4746,
"author": "Ishmaeel",
"author_id": 227,
"author_profile": "https://Stackoverflow.com/users/227",
"pm_score": 8,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(strConfigPath); //Pa... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/205/"
] | I'm developing a data access component that will be used in a website that contains a mix of classic ASP and ASP.NET pages, and need a good way to manage its configuration settings.
I'd like to use a custom `ConfigurationSection`, and for the ASP.NET pages this works great. But when the component is called via COM int... | Try this:
```
System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(strConfigPath); //Path to your config file
System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap);
``` |
4,752 | <p>We've been having some issues with a SharePoint instance in a test
environment. Thankfully this is not production ;) The problems started
when the disk with the SQL Server databases and search index ran out
of space. Following this, the search service would not run and search
settings in the SSP were not accessible.... | [
{
"answer_id": 5475,
"author": "Daniel O",
"author_id": 697,
"author_profile": "https://Stackoverflow.com/users/697",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried removing the SSP using the command line? I found this worked once when we had a broken an SSP and just wanted... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636/"
] | We've been having some issues with a SharePoint instance in a test
environment. Thankfully this is not production ;) The problems started
when the disk with the SQL Server databases and search index ran out
of space. Following this, the search service would not run and search
settings in the SSP were not accessible. Re... | As Daniel McPherson said, this is caused when SSPs are deleted but the associated
job are not and attempt to communicate with the deleted database.
If the SSP
database has been deleted or a problem occurred when deleting an SSP, the job may
not be deleted. When the job attempts to run, it will fail since the data... |
4,816 | <p>How do you resolve a domain name to an IP address with .NET/C#?</p>
| [
{
"answer_id": 4821,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 5,
"selected": true,
"text": "<pre><code>using System.Net;\n\nforeach (IPAddress address in Dns.GetHostAddresses(\"www.google.com\"))\n{\n Console.WriteL... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390/"
] | How do you resolve a domain name to an IP address with .NET/C#? | ```
using System.Net;
foreach (IPAddress address in Dns.GetHostAddresses("www.google.com"))
{
Console.WriteLine(address.ToString());
}
``` |
4,824 | <p>Is there a C library function that will return the index of a character in a string?</p>
<p>So far, all I've found are functions like strstr that will return the found char *, not it's location in the original string.</p>
| [
{
"answer_id": 4829,
"author": "Adam Haile",
"author_id": 194,
"author_profile": "https://Stackoverflow.com/users/194",
"pm_score": 0,
"selected": false,
"text": "<p>If you are not totally tied to pure C and can use string.h there is strchr()\n<a href=\"http://www.cplusplus.com/reference... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/75/"
] | Is there a C library function that will return the index of a character in a string?
So far, all I've found are functions like strstr that will return the found char \*, not it's location in the original string. | I think that
>
> size\_t strcspn ( const char \* str1, const char \* str2 );
>
>
>
is what you want. Here is an example pulled from [here](http://www.cplusplus.com/reference/clibrary/cstring/strcspn.html):
```
/* strcspn example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] = "fcba73";
... |
4,839 | <p>My dream IDE does full code hints, explains and completes PHP, Javascript, HTML and CSS. I know it exists!</p>
<p>so far, <a href="http://www.zend.com/en/products/studio/features" rel="noreferrer">Zend studio 6</a>, under the Eclipse IDE does a great job at hinting PHP, some Javascript and HTML, any way I can expan... | [
{
"answer_id": 4852,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 0,
"selected": false,
"text": "<p>The default CSS and HTML editors for Eclipse are really good. The default javascript editor does an OK job, but ... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/547/"
] | My dream IDE does full code hints, explains and completes PHP, Javascript, HTML and CSS. I know it exists!
so far, [Zend studio 6](http://www.zend.com/en/products/studio/features), under the Eclipse IDE does a great job at hinting PHP, some Javascript and HTML, any way I can expand this?
edit: a bit more information:... | I think the JavaScript and CSS need to be in separate files for this to work.
Example of CSS autocomplete in Eclipse:
Starting to type `border`
>
> 
>
>
>
Then setting thickness
>
>  will change dependant on the key pressed and any modifier keys, so, for example, pressing the left arrow will return code 37, shift-left will return 65573, ctrl-left 131109 and alt-left ... |
4,860 | <p>We have a question with regards to XML-sig and need detail about the optional elements as well as some of the canonicalization and transform stuff. We're writing a spec for a very small XML-syntax payload that will go into the metadata of media files and it needs to by cryptographically signed. Rather than re-inve... | [
{
"answer_id": 5026,
"author": "Tokabi",
"author_id": 315,
"author_profile": "https://Stackoverflow.com/users/315",
"pm_score": 5,
"selected": true,
"text": "<p>Within your overridden ProcessCmdKey how are you determining which key has been pressed?</p>\n\n<p>The value of keyData (the se... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/661/"
] | We have a question with regards to XML-sig and need detail about the optional elements as well as some of the canonicalization and transform stuff. We're writing a spec for a very small XML-syntax payload that will go into the metadata of media files and it needs to by cryptographically signed. Rather than re-invent th... | Within your overridden ProcessCmdKey how are you determining which key has been pressed?
The value of keyData (the second parameter) will change dependant on the key pressed and any modifier keys, so, for example, pressing the left arrow will return code 37, shift-left will return 65573, ctrl-left 131109 and alt-left ... |
4,870 | <p>I'm writing a Telnet client of sorts in C# and part of what I have to parse are ANSI/VT100 escape sequences, specifically, just those used for colour and formatting (detailed <a href="http://www.termsys.demon.co.uk/vtansi.htm#colors" rel="noreferrer">here</a>).</p>
<p>One method I have is one to find all the codes ... | [
{
"answer_id": 4883,
"author": "Ryan Fox",
"author_id": 55,
"author_profile": "https://Stackoverflow.com/users/55",
"pm_score": 1,
"selected": false,
"text": "<p>Without doing detailed analysis, I'd guess that it's faster because of the question marks. These allow the regular expression ... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/483/"
] | I'm writing a Telnet client of sorts in C# and part of what I have to parse are ANSI/VT100 escape sequences, specifically, just those used for colour and formatting (detailed [here](http://www.termsys.demon.co.uk/vtansi.htm#colors)).
One method I have is one to find all the codes and remove them, so I can render the t... | The reason why #1 is slower is that [\d;]+ is a greedy quantifier. Using +? or \*? is going to do lazy quantifing. See [MSDN - Quantifiers](http://msdn.microsoft.com/en-us/library/3206d374(VS.80).aspx) for more info.
You may want to try:
```
"(\e\[(\d{1,2};)*?[mz]?)?"
```
That may be faster for you. |
4,884 | <p>I have a custom built ajax [div] based dynamic dropdown. </p>
<p>I have an [input] box which; <code>onkeyup</code>, runs an Ajax search which returns results in <code>div</code>s and are drawn back in using <code>innerHTML</code>. These <code>div</code>s all have highlights <code>onmouseover</code> so, a typical su... | [
{
"answer_id": 4897,
"author": "Tom",
"author_id": 20,
"author_profile": "https://Stackoverflow.com/users/20",
"pm_score": 1,
"selected": false,
"text": "<p>Off the top of my head, I would think that you'd need to maintain some form of a data structure in the JavaScript that reflects the... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/547/"
] | I have a custom built ajax [div] based dynamic dropdown.
I have an [input] box which; `onkeyup`, runs an Ajax search which returns results in `div`s and are drawn back in using `innerHTML`. These `div`s all have highlights `onmouseover` so, a typical successful search yields the following structure (pardon the semi-c... | What you need to do is attach event listeners to the `div` with `id="results"`. You can do this by adding `onkeyup`, `onkeydown`, etc. attributes to the `div` when you create it or you can attach these using JavaScript.
My recommendation would be that you use an AJAX library like [YUI](http://developer.yahoo.com/yui/)... |
4,922 | <p>I saw this in <a href="https://stackoverflow.com/a/4384/697449">an answer to another question</a>, in reference to shortcomings of the Java spec:</p>
<blockquote>
<p>There are more shortcomings and this is a subtle topic. Check <a href="http://kiranthakkar.blogspot.com/2007/05/method-overloading-with-new-features-of... | [
{
"answer_id": 4932,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 3,
"selected": false,
"text": "<p>Yes it is, try it out in a test. You will see \"long\" printed. It is widening because Java will choose to widen the int... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/670/"
] | I saw this in [an answer to another question](https://stackoverflow.com/a/4384/697449), in reference to shortcomings of the Java spec:
>
> There are more shortcomings and this is a subtle topic. Check [this](http://kiranthakkar.blogspot.com/2007/05/method-overloading-with-new-features-of.html) out:
>
>
>
> ```
> p... | In the first case, you have a widening conversion happening. This can be see when runinng the "javap" utility program (included w/ the JDK), on the compiled class:
```
public static void main(java.lang.String[]);
Code:
0: iconst_ 5
1: istore_ 1
2: iload_ 1
3: i2l
4: invokestatic #6; //Met... |
4,954 | <p>I have worked for 5 years mainly in java desktop applications accessing Oracle databases and I have never used regular expressions. Now I enter Stack Overflow and I see a lot of questions about them; I feel like I missed something. </p>
<p>For what do you use regular expressions?</p>
<p>P.S. sorry for my bad engli... | [
{
"answer_id": 4959,
"author": "Matt MacLean",
"author_id": 22,
"author_profile": "https://Stackoverflow.com/users/22",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>A regular expression (regex or regexp for short) is a special text string for describing a search pattern.... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518/"
] | I have worked for 5 years mainly in java desktop applications accessing Oracle databases and I have never used regular expressions. Now I enter Stack Overflow and I see a lot of questions about them; I feel like I missed something.
For what do you use regular expressions?
P.S. sorry for my bad english | Consider an example in Ruby:
```
puts "Matched!" unless /\d{3}-\d{4}/.match("555-1234").nil?
puts "Didn't match!" if /\d{3}-\d{4}/.match("Not phone number").nil?
```
The "/\d{3}-\d{4}/" is the regular expression, and as you can see it is a VERY concise way of finding a match in a string.
Furthermore, using groups y... |
4,973 | <p>I am trying to lay out a table-like page with two columns. I want the rightmost column to dock to the right of the page, and this column should have a distinct background color. The content in the right side is almost always going to be smaller than that on the left. I would like the div on the right to always be... | [
{
"answer_id": 4979,
"author": "Teifion",
"author_id": 1384652,
"author_profile": "https://Stackoverflow.com/users/1384652",
"pm_score": 2,
"selected": false,
"text": "<p>I had the same problem on my site (<a href=\"http://woarl.com\" rel=\"nofollow noreferrer\">shameless plug</a>).</p>\... | 2008/08/07 | [
"https://Stackoverflow.com/questions/4973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] | I am trying to lay out a table-like page with two columns. I want the rightmost column to dock to the right of the page, and this column should have a distinct background color. The content in the right side is almost always going to be smaller than that on the left. I would like the div on the right to always be tall ... | Ahem...
>
> The short answer to your question is that you must set the height of 100% to the body and html tag, then set the height to 100% on each div element you want to make 100% the height of the page.
>
>
>
Actually, 100% height will not work in most design situations - this may be short but it is not a good... |
5,017 | <p>I have written an AIR Application that downloads videos and documents from a server. The videos play inside of the application, but I would like the user to be able to open the documents in their native applications.</p>
<p>I am looking for a way to prompt the user to Open / Save As on a local file stored in the Ap... | [
{
"answer_id": 5266,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 3,
"selected": true,
"text": "<p>Only way I could figure out how to do it without just moving the file and telling the user was to pass it off to the browser.</p>\... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | I have written an AIR Application that downloads videos and documents from a server. The videos play inside of the application, but I would like the user to be able to open the documents in their native applications.
I am looking for a way to prompt the user to Open / Save As on a local file stored in the Application ... | Only way I could figure out how to do it without just moving the file and telling the user was to pass it off to the browser.
```
navigateToURL(new URLRequest(File.applicationStorageDirectory.nativePath + "/courses/" + fileName));
``` |
5,071 | <p>I've played with CVS a little bit and am not the most familiar with all of its capabilities, but a huge annoyance for me is trying to add new directories that contain more directories in them. Running "<code>cvs add</code>" only adds the contents of the current directory, and using "<code>cvs import</code>" didn't l... | [
{
"answer_id": 5076,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": -1,
"selected": false,
"text": "<p>SVN definitely makes this trivial task, using a GUI like Tortoise is even easier, however.</p>\n\n<p>This might be a good... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] | I've played with CVS a little bit and am not the most familiar with all of its capabilities, but a huge annoyance for me is trying to add new directories that contain more directories in them. Running "`cvs add`" only adds the contents of the current directory, and using "`cvs import`" didn't look like the right thing ... | Ah, spaces. This will work with spaces:
```
find . -type f -print0| xargs -0 cvs add
``` |
5,118 | <p>I'm working on a website that will switch to a new style on a set date. The site's built-in semantic HTML and CSS, so the change should just require a CSS reference change. I'm working with a designer who will need to be able to see how it's looking, as well as a client who will need to be able to review content upd... | [
{
"answer_id": 5151,
"author": "palmsey",
"author_id": 521,
"author_profile": "https://Stackoverflow.com/users/521",
"pm_score": 2,
"selected": false,
"text": "<p>I would suggest storing the stylesheet selection in the session so you don't have to rely on the querystring key being presen... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5/"
] | I'm working on a website that will switch to a new style on a set date. The site's built-in semantic HTML and CSS, so the change should just require a CSS reference change. I'm working with a designer who will need to be able to see how it's looking, as well as a client who will need to be able to review content update... | In Asp.net 3.5, you should be able to set up the Link tag in the header as a server tag. Then in the codebehind you can set the href property for the link element, based on a cookie value, querystring, date, etc.
In your aspx file:
```
<head>
<link id="linkStyles" rel="stylesheet" type="text/css" runat="server" />
... |
5,134 | <p>What is the best approach to write <strong>hooks</strong> for <strong>Subversion</strong> in <strong>Windows</strong>? As far as I know, only executable files can be used. So what is the best choice? </p>
<ul>
<li>Plain batch files (very limited but perhaps OK for very simple solutions)</li>
<li>Dedicated compiled ... | [
{
"answer_id": 5144,
"author": "Tanerax",
"author_id": 567,
"author_profile": "https://Stackoverflow.com/users/567",
"pm_score": 1,
"selected": false,
"text": "<p>Depending on the complexity, each situation is different, If I am just simply moving files around, I'll write a quick batch f... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/563/"
] | What is the best approach to write **hooks** for **Subversion** in **Windows**? As far as I know, only executable files can be used. So what is the best choice?
* Plain batch files (very limited but perhaps OK for very simple solutions)
* Dedicated compiled executable applications (sledgehammer to crack a nutshell?)
... | I’ve just spent several days procrastinating about exactly this question. There are third party products available and plenty of PERL and Python scripts but I wanted something simple and a language I was familiar with so ended up just writing hooks in a C# console app. It’s very straight forward:
```
public void Main(... |
5,142 | <p>I created a view on a machine using the <em>substring</em> function from Firebird, and it worked. When I copied the database to a different machine, the view was broken. This is the way I used it:</p>
<pre><code>SELECT SUBSTRING(field FROM 5 FOR 15) FROM table;
</code></pre>
<p>And this is the output on the mach... | [
{
"answer_id": 5148,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "<p>Different engine versions?</p>\n\n<p>Have you tried naming that expression in the result?</p>\n\n<pre><code>SELECT S... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/431/"
] | I created a view on a machine using the *substring* function from Firebird, and it worked. When I copied the database to a different machine, the view was broken. This is the way I used it:
```
SELECT SUBSTRING(field FROM 5 FOR 15) FROM table;
```
And this is the output on the machine that does not accept the functi... | 1. Make sure Firebird engine is 1.5 and there's no InterBase server running on this same box on the port you expected Firebird 1.5.
2. Make sure you don't have any UDF called 'substring' registered inside this DB so that Firebird is expecting different parameters. |
5,179 | <p>ASP.NET server-side controls postback to their own page. This makes cases where you want to redirect a user to an external page, but need to post to that page for some reason (for authentication, for instance) a pain.</p>
<p>An <code>HttpWebRequest</code> works great if you don't want to redirect, and JavaScript i... | [
{
"answer_id": 5185,
"author": "Mike Powell",
"author_id": 205,
"author_profile": "https://Stackoverflow.com/users/205",
"pm_score": 2,
"selected": false,
"text": "<p>If you're using ASP.NET 2.0, you can do this with <a href=\"http://msdn.microsoft.com/en-us/library/ms178139.aspx\" rel=\... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/111/"
] | ASP.NET server-side controls postback to their own page. This makes cases where you want to redirect a user to an external page, but need to post to that page for some reason (for authentication, for instance) a pain.
An `HttpWebRequest` works great if you don't want to redirect, and JavaScript is fine in some cases, ... | Here's how I solved this problem today. I started from [this article](http://www.c-sharpcorner.com/UploadFile/desaijm/ASP.NetPostURL11282005005516AM/ASP.NetPostURL.aspx) on C# Corner, but found the example - while technically sound - a little incomplete. Everything he said was right, but I needed to hit a few external ... |
5,188 | <p>I have a web reference for our report server embedded in our application. The server that the reports live on could change though, and I'd like to be able to change it "on the fly" if necessary.</p>
<p>I know I've done this before, but can't seem to remember how. Thanks for your help.</p>
<p>I've manually driven a... | [
{
"answer_id": 5192,
"author": "brendan",
"author_id": 225,
"author_profile": "https://Stackoverflow.com/users/225",
"pm_score": 3,
"selected": true,
"text": "<p>In the properties window change the \"behavior\" to Dynamic.</p>\n\n<p>See: <a href=\"http://www.codeproject.com/KB/XML/wsdldy... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/326/"
] | I have a web reference for our report server embedded in our application. The server that the reports live on could change though, and I'd like to be able to change it "on the fly" if necessary.
I know I've done this before, but can't seem to remember how. Thanks for your help.
I've manually driven around this for th... | In the properties window change the "behavior" to Dynamic.
See: <http://www.codeproject.com/KB/XML/wsdldynamicurl.aspx> |
5,194 | <p>I am prototyping some C# 3 collection filters and came across this.
I have a collection of products:</p>
<pre><code>public class MyProduct
{
public string Name { get; set; }
public Double Price { get; set; }
public string Description { get; set; }
}
var MyProducts = new List<MyProduct>
{ ... | [
{
"answer_id": 5199,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 4,
"selected": true,
"text": "<p>LINQ turns into method calls like the code you have.</p>\n\n<p>In other words, there should be no difference.</p>\n\n... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439/"
] | I am prototyping some C# 3 collection filters and came across this.
I have a collection of products:
```
public class MyProduct
{
public string Name { get; set; }
public Double Price { get; set; }
public string Description { get; set; }
}
var MyProducts = new List<MyProduct>
{
new MyProd... | LINQ turns into method calls like the code you have.
In other words, there should be no difference.
However, in your two pieces of code you are not calling .ToList in the first, so the first piece of code will produce an enumerable data source, but if you call .ToList on it, the two should be the same. |
5,223 | <p>I have a JavaScript object. Is there a built-in or accepted best practice way to get the length of this object?</p>
<pre><code>const myObject = new Object();
myObject["firstname"] = "Gareth";
myObject["lastname"] = "Simpson";
myObject["age"] = 21;
</code></pre>
| [
{
"answer_id": 5232,
"author": "jj33",
"author_id": 430,
"author_profile": "https://Stackoverflow.com/users/430",
"pm_score": 5,
"selected": false,
"text": "<p>I'm not a JavaScript expert, but it looks like you would have to loop through the elements and count them since Object doesn't h... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147/"
] | I have a JavaScript object. Is there a built-in or accepted best practice way to get the length of this object?
```
const myObject = new Object();
myObject["firstname"] = "Gareth";
myObject["lastname"] = "Simpson";
myObject["age"] = 21;
``` | Updated answer
--------------
**Here's an update as of 2016 and [widespread deployment of ES5](http://kangax.github.io/compat-table/es5/) and beyond.** For IE9+ and all other modern ES5+ capable browsers, you can use [`Object.keys()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Obj... |
5,260 | <p>I have a situation where I want to add hours to a date and have the new date wrap around the work-day. I cobbled up a function to determine this new date, but want to make sure that I'm not forgetting anything.</p>
<p>The hours to be added is called "delay". It could easily be a parameter to the function instead.</... | [
{
"answer_id": 5303,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 2,
"selected": false,
"text": "<p>You should probably write some automated tests for each condition you can think of, and then just start brainstorming more... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106/"
] | I have a situation where I want to add hours to a date and have the new date wrap around the work-day. I cobbled up a function to determine this new date, but want to make sure that I'm not forgetting anything.
The hours to be added is called "delay". It could easily be a parameter to the function instead.
Please pos... | You should probably write some automated tests for each condition you can think of, and then just start brainstorming more, writing the tests as you think of them. This way, you can see for sure it will work, and will continue to work if you make further changes. Look up Test Driven Development if you like the results. |
5,263 | <p>I have a self-referential Role table that represents a tree structure </p>
<pre><code>ID [INT] AUTO INCREMENT
Name [VARCHAR]
ParentID [INT]
</code></pre>
<p>I am using an ADO.NET DataTable and DataAdapter to load and save values to this table. This works if I only create children of existing rows. If I make a chil... | [
{
"answer_id": 5497,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 0,
"selected": false,
"text": "<p>Does it make any difference if you go</p>\n\n<pre><code>newRow.SetParentRow(parentRow, RoleTable.Relations(\"RoleToRole\"))\n<... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173/"
] | I have a self-referential Role table that represents a tree structure
```
ID [INT] AUTO INCREMENT
Name [VARCHAR]
ParentID [INT]
```
I am using an ADO.NET DataTable and DataAdapter to load and save values to this table. This works if I only create children of existing rows. If I make a child row, then make a child o... | I don't know ADO.net in particular, but most ORMs won't automatically insert the ID of a new record in a relationship. You'll have to resort to the 2-step process:
1. build and save parent
2. build and save child with relationship to parent
The reason that this is difficult for ORMs is because you might have circular... |
5,269 | <p>In C#, (and feel free to answer for other languages), what order does the runtime evaluate a logic statement?</p>
<p>Example:</p>
<pre><code>DataTable myDt = new DataTable();
if (myDt != null && myDt.Rows.Count > 0)
{
//do some stuff with myDt
}
</code></pre>
<p>Which statement does the runtime eva... | [
{
"answer_id": 5272,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 2,
"selected": false,
"text": "<p>The left one, then stops if it is null.</p>\n\n<p>Edit: In vb.net it will evaluate both and possibly throw an error, unless you u... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] | In C#, (and feel free to answer for other languages), what order does the runtime evaluate a logic statement?
Example:
```
DataTable myDt = new DataTable();
if (myDt != null && myDt.Rows.Count > 0)
{
//do some stuff with myDt
}
```
Which statement does the runtime evaluate first -
```
myDt != null
```
or:
... | C# : Left to right, and processing stops if a non-match (evaluates to false) is found. |
5,323 | <p>It seems like every time I try to create a pure CSS layout it takes me much longer than if I'd use a table or two. Getting three columns to be equal lengths with different amounts of data seems to require particular fancy hacks, especially when dealing with cross-browser issues.</p>
<p>My Question:</p>
<p>Who are ... | [
{
"answer_id": 5331,
"author": "Seibar",
"author_id": 357,
"author_profile": "https://Stackoverflow.com/users/357",
"pm_score": 3,
"selected": false,
"text": "<p>I'm of the thought that CSS layout with as few tables as possible is cleaner and better, but I agree that sometimes you just g... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556/"
] | It seems like every time I try to create a pure CSS layout it takes me much longer than if I'd use a table or two. Getting three columns to be equal lengths with different amounts of data seems to require particular fancy hacks, especially when dealing with cross-browser issues.
My Question:
Who are these few tables ... | Since this is stack**overflow**, I'll give you my *programmer's answer*
semantics 101
First take a look at this code and think about what's wrong here...
```
class car {
int wheels = 4;
string engine;
}
car mybike = new car();
mybike.wheels = 2;
mybike.engine = null;
```
The problem, of course, is that a b... |
5,328 | <p>So, in Java, the first line of your constructor HAS to be a call to super... be it implicitly calling super(), or explicitly calling another constructor. What I want to know is, why can't I put a try block around that?</p>
<p>My specific case is that I have a mock class for a test. There is no default constructor... | [
{
"answer_id": 5351,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 5,
"selected": true,
"text": "<p>Unfortunately, compilers can't work on theoretical principles, and even though you may know that it is safe in your c... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | So, in Java, the first line of your constructor HAS to be a call to super... be it implicitly calling super(), or explicitly calling another constructor. What I want to know is, why can't I put a try block around that?
My specific case is that I have a mock class for a test. There is no default constructor, but I want... | Unfortunately, compilers can't work on theoretical principles, and even though you may know that it is safe in your case, if they allowed it, it would have to be safe for all cases.
In other words, the compiler isn't stopping just you, it's stopping everyone, including all those that don't know that it is unsafe and n... |
5,374 | <p>I would have thought this would be an easy one to Google, but I've been unsucessful.</p>
<p>I want to assign a variable the value out of an attribute (easy so far) then use that variable to select another node based on the value of that attribute.</p>
<p>Example:</p>
<pre><code><xsl:variable name="myId" select... | [
{
"answer_id": 5469,
"author": "palehorse",
"author_id": 312,
"author_profile": "https://Stackoverflow.com/users/312",
"pm_score": 5,
"selected": true,
"text": "<p>Ok, I finally figured it out. Silly problem really, I simply needed to leave out the quotes and the braces. One of those t... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/312/"
] | I would have thought this would be an easy one to Google, but I've been unsucessful.
I want to assign a variable the value out of an attribute (easy so far) then use that variable to select another node based on the value of that attribute.
Example:
```
<xsl:variable name="myId" select="@id" />
<xsl value-of select=... | Ok, I finally figured it out. Silly problem really, I simply needed to leave out the quotes and the braces. One of those times when I *thought* that I'd already tried that. :D Oh, and I mistyped @myId in the first example, the code was actually $myId.
```
<xsl:variable name="myId" select="@id" />
<xsl value-of select=... |
5,415 | <p>I have a binary file that I have to parse and I'm using Python. Is there a way to take 4 bytes and convert it to a single precision floating point number?</p>
| [
{
"answer_id": 73281,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 8,
"selected": true,
"text": "<pre><code>>>> import struct\n>>> struct.pack('f', 3.141592654)\nb'\\xdb\\x0fI@'\n>>> struct.unpack('f... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680/"
] | I have a binary file that I have to parse and I'm using Python. Is there a way to take 4 bytes and convert it to a single precision floating point number? | ```
>>> import struct
>>> struct.pack('f', 3.141592654)
b'\xdb\x0fI@'
>>> struct.unpack('f', b'\xdb\x0fI@')
(3.1415927410125732,)
>>> struct.pack('4f', 1.0, 2.0, 3.0, 4.0)
'\x00\x00\x80?\x00\x00\x00@\x00\x00@@\x00\x00\x80@'
``` |
5,419 | <p>When I try to print a Unicode string in a Windows console, I get an error .</p>
<p><code>UnicodeEncodeError: 'charmap' codec can't encode character ....</code></p>
<p>I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this?
Is there any way I can make Pyt... | [
{
"answer_id": 5430,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 6,
"selected": true,
"text": "<p><strong>Note:</strong> This answer is sort of outdated (from 2008). Please use the solution below with care!!</p>\n\n... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/207/"
] | When I try to print a Unicode string in a Windows console, I get an error .
`UnicodeEncodeError: 'charmap' codec can't encode character ....`
I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this?
Is there any way I can make Python automatically print a ... | **Note:** This answer is sort of outdated (from 2008). Please use the solution below with care!!
---
Here is a page that details the problem and a solution (search the page for the text *Wrapping sys.stdout into an instance*):
[PrintFails - Python Wiki](http://wiki.python.org/moin/PrintFails)
Here's a code excerpt ... |
5,425 | <p>I have a page that is generated which inserts an HTML comment near the top of the page. Inside the comment is a *nix-style command.</p>
<pre><code><!-- command --option value --option2 value2 --option3 -->
</code></pre>
<p>This comment breaks the page completely. What is wrong with the comment to cause thi... | [
{
"answer_id": 5441,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 6,
"selected": true,
"text": "<p>Comments in the <a href=\"http://www.w3.org/TR/REC-xml/#sec-comments\" rel=\"noreferrer\">XML Spec from the w3.org</a> :</p>\... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219/"
] | I have a page that is generated which inserts an HTML comment near the top of the page. Inside the comment is a \*nix-style command.
```
<!-- command --option value --option2 value2 --option3 -->
```
This comment breaks the page completely. What is wrong with the comment to cause this to happen, and why is this the ... | Comments in the [XML Spec from the w3.org](http://www.w3.org/TR/REC-xml/#sec-comments) :
>
> For compatibility, the string "--"
> (double-hyphen) MUST NOT occur within
> comments.
>
>
> |
5,428 | <p>Is it worth learning the convention or is it a bane to readability and maintainability?</p>
| [
{
"answer_id": 5439,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 7,
"selected": true,
"text": "<p>Considering that most people that use <em>Hungarian Notation</em> is following the misunderstood version of it, I'd s... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/659/"
] | Is it worth learning the convention or is it a bane to readability and maintainability? | Considering that most people that use *Hungarian Notation* is following the misunderstood version of it, I'd say it's pretty pointless.
If you want to use the original definition of it, it might make more sense, but other than that it is mostly syntactic sugar.
If you read the [Wikipedia article](http://en.wikipedia.... |
5,459 | <p>This is how I wanted to do it which would work in PHP 5.3.0+</p>
<pre><code><?php
class MyClass
{
const CONSTANT = 'Const var';
}
$classname = 'MyClass';
echo $classname::CONSTANT; // As of PHP 5.3.0
?>
</code></pre>
<p>But I'm restricted to using PHP 5.2.6. Can anyone th... | [
{
"answer_id": 5472,
"author": "Juan",
"author_id": 550,
"author_profile": "https://Stackoverflow.com/users/550",
"pm_score": -1,
"selected": false,
"text": "<p>If you absolutly need to access a constant like that, you can do this:</p>\n\n<pre><code><?php\nclass MyClass\n{\n co... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117/"
] | This is how I wanted to do it which would work in PHP 5.3.0+
```
<?php
class MyClass
{
const CONSTANT = 'Const var';
}
$classname = 'MyClass';
echo $classname::CONSTANT; // As of PHP 5.3.0
?>
```
But I'm restricted to using PHP 5.2.6. Can anyone think of a simple way to simulate ... | You can accomplish this without using [`eval`](http://php.net/manual/en/function.eval.php) in pre-5.3 code. Just use the [`constant`](http://php.net/manual/en/function.constant.php) function:
```
<?php
class MyClass
{
const CONSTANT = 'Const var';
}
$classname = 'MyClass';
echo constant("$classname::CONSTANT");
... |
5,473 | <p>Is it possible to undo the changes caused by the following command? If so, how?</p>
<pre><code>git reset --hard HEAD~1
</code></pre>
| [
{
"answer_id": 6636,
"author": "Pat Notz",
"author_id": 825,
"author_profile": "https://Stackoverflow.com/users/825",
"pm_score": 9,
"selected": false,
"text": "<p>What you want to do is to specify the sha1 of the commit you want to restore to. You can get the sha1 by examining the refl... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | Is it possible to undo the changes caused by the following command? If so, how?
```
git reset --hard HEAD~1
``` | Pat Notz is correct. You can get the commit back so long as it's been within a few days. git only garbage collects after about a month or so unless you explicitly tell it to remove newer blobs.
```
$ git init
Initialized empty Git repository in .git/
$ echo "testing reset" > file1
$ git add file1
$ git commit -m 'add... |
5,482 | <p>The ASP.NET AJAX <strong>ModalPopupExtender</strong> has <code>OnCancelScript</code> and <code>OnOkScript</code> properties, but it doesn't seem to have an <code>OnShowScript</code> property. I'd like to specify a javascript function to run each time the popup is shown.</p>
<p>In past situations, I set the <code>T... | [
{
"answer_id": 5488,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 2,
"selected": false,
"text": "<p>If you are using a button or hyperlink or something to trigger the popup to show, could you also add an additional handler to ... | 2008/08/07 | [
"https://Stackoverflow.com/questions/5482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/698/"
] | The ASP.NET AJAX **ModalPopupExtender** has `OnCancelScript` and `OnOkScript` properties, but it doesn't seem to have an `OnShowScript` property. I'd like to specify a javascript function to run each time the popup is shown.
In past situations, I set the `TargetControlID` to a dummy control and provide my own control ... | hmmm... I'm *pretty sure* that there's a shown event for the MPE... this is off the top of my head, but I think you can add an event handler to the shown event on page\_load
```
function pageLoad()
{
var popup = $find('ModalPopupClientID');
popup.add_shown(SetFocus);
}
function SetFocus()
{
$get('TriggerC... |
5,511 | <p>How are you handling the entry of numeric values in WPF applications?</p>
<p>Without a NumericUpDown control, I've been using a TextBox and handling its PreviewKeyDown event with the code below, but it's pretty ugly.</p>
<p>Has anyone found a more graceful way to get numeric data from the user without relying on a... | [
{
"answer_id": 6174,
"author": "tags2k",
"author_id": 192,
"author_profile": "https://Stackoverflow.com/users/192",
"pm_score": 1,
"selected": false,
"text": "<p>Call me crazy, but why not put plus and minus buttons at either side of the TextBox control and simply prevent the TextBox fro... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615/"
] | How are you handling the entry of numeric values in WPF applications?
Without a NumericUpDown control, I've been using a TextBox and handling its PreviewKeyDown event with the code below, but it's pretty ugly.
Has anyone found a more graceful way to get numeric data from the user without relying on a third-party cont... | How about:
```
protected override void OnPreviewTextInput(System.Windows.Input.TextCompositionEventArgs e)
{
e.Handled = !AreAllValidNumericChars(e.Text);
base.OnPreviewTextInput(e);
}
private bool AreAllValidNumericChars(string str)
{
foreach(char c in str)
{
if(!Char.IsNumber(c)) return fals... |
5,611 | <p>I know that just using <code>rand()</code> is predictable, if you know what you're doing, and have access to the server.</p>
<p>I have a project that is <strong>highly</strong> dependent upon choosing a random number that is as unpredictable as possible. So I'm looking for suggestions, either other built-in functio... | [
{
"answer_id": 5679,
"author": "Justin Yost",
"author_id": 657,
"author_profile": "https://Stackoverflow.com/users/657",
"pm_score": 1,
"selected": false,
"text": "<p>Variation on @KG, using the milliseconds since EPOCH as the seed for rand?</p>\n"
},
{
"answer_id": 5820,
"au... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] | I know that just using `rand()` is predictable, if you know what you're doing, and have access to the server.
I have a project that is **highly** dependent upon choosing a random number that is as unpredictable as possible. So I'm looking for suggestions, either other built-in functions or user functions, that can gen... | Adding, multiplying, or truncating a poor random source will give you a poor random result. See [Introduction to Randomness and Random Numbers](http://random.org/randomness/) for an explanation.
You're right about PHP rand() function. See the second figure on [Statistical Analysis](http://random.org/analysis/) for a s... |
5,694 | <p>I got this error today when trying to open a Visual Studio 2008 <strong>project</strong> in Visual Studio 2005:</p>
<blockquote>
<p>The imported project "C:\Microsoft.CSharp.targets" was not found.</p>
</blockquote>
| [
{
"answer_id": 5695,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 8,
"selected": true,
"text": "<p>Open your csproj file in notepad (or notepad++)\nFind the line: </p>\n\n<pre><code><Import Project=\"$(MSBuildToolsPath)\\Mi... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] | I got this error today when trying to open a Visual Studio 2008 **project** in Visual Studio 2005:
>
> The imported project "C:\Microsoft.CSharp.targets" was not found.
>
>
> | Open your csproj file in notepad (or notepad++)
Find the line:
```
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
```
and change it to
```
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
``` |
5,727 | <p>Why are pointers such a leading factor of confusion for many new, and even old, college level students in C or C++? Are there any tools or thought processes that helped you understand how pointers work at the variable, function, and beyond level?</p>
<p>What are some good practice things that can be done to bring ... | [
{
"answer_id": 5728,
"author": "Josh",
"author_id": 257,
"author_profile": "https://Stackoverflow.com/users/257",
"pm_score": 5,
"selected": false,
"text": "<blockquote>\n <p>Why are pointers such a leading factor of confusion for many new, and even old, college level students in the C/... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/568/"
] | Why are pointers such a leading factor of confusion for many new, and even old, college level students in C or C++? Are there any tools or thought processes that helped you understand how pointers work at the variable, function, and beyond level?
What are some good practice things that can be done to bring somebody to... | Pointers is a concept that for many can be confusing at first, in particular when it comes to copying pointer values around and still referencing the same memory block.
I've found that the best analogy is to consider the pointer as a piece of paper with a house address on it, and the memory block it references as the ... |
5,821 | <p>How do I escape the underscore character?</p>
<p>I am writing something like the following where clause and want to be able to find actual entries with _d at the end.</p>
<pre><code>Where Username Like '%_d'
</code></pre>
| [
{
"answer_id": 5822,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 10,
"selected": true,
"text": "<p><a href=\"https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?view=sql-server-ver15#usin... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] | How do I escape the underscore character?
I am writing something like the following where clause and want to be able to find actual entries with \_d at the end.
```
Where Username Like '%_d'
``` | [T-SQL Reference for LIKE](https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?view=sql-server-ver15#using-wildcard-characters-as-literals):
>
> You can use the wildcard pattern matching characters as literal characters. To use a wildcard character as a literal character, enclose the wildc... |
5,846 | <p>How do I turn the following 2 queries into 1 query</p>
<pre><code>$sql = "SELECT level FROM skills WHERE id = $id LIMIT 1;";
$result = $db->sql_query($sql);
$level = (int) $db->sql_fetchfield('level');
$db->sql_freeresult($result);
++$level;
$sql = "UPDATE skills SET level = $level WHERE id = $id;... | [
{
"answer_id": 5848,
"author": "Josh",
"author_id": 257,
"author_profile": "https://Stackoverflow.com/users/257",
"pm_score": 6,
"selected": true,
"text": "<p>I get downmodded for this?</p>\n\n<pre><code>$sql = \"UPDATE skills SET level = level+1 WHERE id = $id\";\n$result = $db->sql_... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | How do I turn the following 2 queries into 1 query
```
$sql = "SELECT level FROM skills WHERE id = $id LIMIT 1;";
$result = $db->sql_query($sql);
$level = (int) $db->sql_fetchfield('level');
$db->sql_freeresult($result);
++$level;
$sql = "UPDATE skills SET level = $level WHERE id = $id;";
$result = $db->sql_q... | I get downmodded for this?
```
$sql = "UPDATE skills SET level = level+1 WHERE id = $id";
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
```
In Teifion's specific case, the phpBB DDL lists that particular field as NOT NULL, so there's no danger of incrementing NULL.
In the general case, you should no... |
5,857 | <p>I have a page upon which a user can choose up to many different paragraphs. When the link is clicked (or button), an email will open up and put all those paragraphs into the body of the email, address it, and fill in the subject. However, the text can be too long for a mailto link.</p>
<p>Any way around this?</p>... | [
{
"answer_id": 5860,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 5,
"selected": true,
"text": "<p>By putting the data into a form, I was able to make the body around 1800 characters long before the form stopped work... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730/"
] | I have a page upon which a user can choose up to many different paragraphs. When the link is clicked (or button), an email will open up and put all those paragraphs into the body of the email, address it, and fill in the subject. However, the text can be too long for a mailto link.
Any way around this?
---
We were t... | By putting the data into a form, I was able to make the body around 1800 characters long before the form stopped working.
The code looked like this:
```
<form action="mailto:youremail@domain.com">
<input type="hidden" name="Subject" value="Email subject">
<input type="hidden" name="Body" value="Email body">
... |
5,863 | <p>I'm just getting into creating some WCF services, but I have a requirement to make them backward compatible for legacy (.NET 1.1 and 2.0) client applications. </p>
<p>I've managed to get the services to run correctly for 3.0 and greater clients, but when I publish the services using a basicHttpBinding endpoint (wh... | [
{
"answer_id": 6997,
"author": "Esteban Araya",
"author_id": 781,
"author_profile": "https://Stackoverflow.com/users/781",
"pm_score": 2,
"selected": false,
"text": "<p>Ah, this is killing me! I did this at work about 3 months ago, and now I can't remember all the details.</p>\n\n<p>I do... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/377/"
] | I'm just getting into creating some WCF services, but I have a requirement to make them backward compatible for legacy (.NET 1.1 and 2.0) client applications.
I've managed to get the services to run correctly for 3.0 and greater clients, but when I publish the services using a basicHttpBinding endpoint (which I belie... | OK, we needed to resolve this issue in the short term, and so we came up with the idea of a "interop", or compatibility layer.
Baiscally, all we did was added a traditional ASMX web service to the project, and called the WCF service from that using native WCF calls. We were then able to return the appropriate types ba... |
5,876 | <p>I use <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html" rel="nofollow noreferrer">dnsmasq</a> to resolve DNS queries on my home network. Unfortunately, if a domain name is not known, it will append my own domain name to the request which means that I always end up viewing my own site in a browser.</p>
<p>For ... | [
{
"answer_id": 5912,
"author": "saint_groceon",
"author_id": 59,
"author_profile": "https://Stackoverflow.com/users/59",
"pm_score": 0,
"selected": false,
"text": "<p>I tried removing <em>domain-needed</em> from my own configuration to replicate your issue and it did not produce this beh... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/726/"
] | I use [dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html) to resolve DNS queries on my home network. Unfortunately, if a domain name is not known, it will append my own domain name to the request which means that I always end up viewing my own site in a browser.
For example, if I enter <http://dlksfhoiahdsfiuhsdf... | try querying with a trailing dot to explicitly set the root:
```
host dlksfhoiahdsfiuhsdf.com.
``` |
5,909 | <p>I'm downloading an entire directory from a web server. It works OK, but I can't figure how to get the file size before download to compare if it was updated on the server or not. Can this be done as if I was downloading the file from a FTP server?</p>
<pre><code>import urllib
import re
url = "http://www.someurl.co... | [
{
"answer_id": 5927,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 3,
"selected": false,
"text": "<p>The size of the file is sent as the Content-Length header. Here is how to get it with urllib:</p>\n\n<pre><code>... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/394/"
] | I'm downloading an entire directory from a web server. It works OK, but I can't figure how to get the file size before download to compare if it was updated on the server or not. Can this be done as if I was downloading the file from a FTP server?
```
import urllib
import re
url = "http://www.someurl.com"
# Download... | I have reproduced what you are seeing:
```
import urllib, os
link = "http://python.org"
print "opening url:", link
site = urllib.urlopen(link)
meta = site.info()
print "Content-Length:", meta.getheaders("Content-Length")[0]
f = open("out.txt", "r")
print "File on disk:",len(f.read())
f.close()
f = open("out.txt", "w... |
5,913 | <p>This gets the value of whatever is selected in my dropdown menu.</p>
<pre><code>document.getElementById('newSkill').value
</code></pre>
<p>I cannot however find out what property to go after for the text that's currently displayed by the drop down menu. I tried "text" then looked at <a href="http://w3schools.com/"... | [
{
"answer_id": 5921,
"author": "Brian Childress",
"author_id": 721,
"author_profile": "https://Stackoverflow.com/users/721",
"pm_score": 1,
"selected": false,
"text": "<p>Does this get the correct answer? </p>\n\n<pre><code>document.getElementById(\"newSkill\").innerHTML\n</code></pre>\n... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | This gets the value of whatever is selected in my dropdown menu.
```
document.getElementById('newSkill').value
```
I cannot however find out what property to go after for the text that's currently displayed by the drop down menu. I tried "text" then looked at [W3Schools](http://w3schools.com/) but that didn't have t... | Based on your example HTML code, here's one way to get the displayed text of the currently selected option:
```
var skillsSelect = document.getElementById("newSkill");
var selectedText = skillsSelect.options[skillsSelect.selectedIndex].text;
``` |
5,916 | <p>For those of you in the Visual Studio environment, how do you feel about wrapping any of your code in #regions? (or if any other IDE has something similar...)</p>
| [
{
"answer_id": 5923,
"author": "Teifion",
"author_id": 1384652,
"author_profile": "https://Stackoverflow.com/users/1384652",
"pm_score": 2,
"selected": false,
"text": "<p>I use <a href=\"http://macromates.com/\" rel=\"nofollow noreferrer\">Textmate</a> (Mac only) which has Code folding a... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396/"
] | For those of you in the Visual Studio environment, how do you feel about wrapping any of your code in #regions? (or if any other IDE has something similar...) | 9 out of 10 times, code folding means that you have failed to use the [SoC principle](http://en.wikipedia.org/wiki/Separation_of_concerns) for what its worth.
I more or less feel the same thing about partial classes. If you have a piece of code you think is too big you need to chop it up in manageable (and reusable)... |
5,949 | <p>I've always preferred to use long integers as primary keys in databases, for simplicity and (assumed) speed. But when using a <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" rel="noreferrer">REST</a> or Rails-like URL scheme for object instances, I'd then end up with URLs like this:</p>
<pre>... | [
{
"answer_id": 5958,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": 2,
"selected": false,
"text": "<p>I work with a student management system which uses UUID's in the form of an integer. They have a table which hold the next... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/726/"
] | I've always preferred to use long integers as primary keys in databases, for simplicity and (assumed) speed. But when using a [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer) or Rails-like URL scheme for object instances, I'd then end up with URLs like this:
```
http://example.com/user/783
```
An... | I can't say about the web side of your question. But uuids are great for n-tier applications. PK generation can be decentralized: each client generates it's own pk without risk of collision.
And the speed difference is generally small.
Make sure your database supports an efficient storage datatype (16 bytes, 128 bits... |
5,966 | <p>Basically, I've written an API to www.thetvdb.com in Python. The current code can be found <a href="http://github.com/dbr/tvdb_api/tree/master/tvdb_api.py" rel="noreferrer">here</a>.</p>
<p>It grabs data from the API as requested, and has to store the data somehow, and make it available by doing:</p>
<pre><code>pr... | [
{
"answer_id": 6125,
"author": "Jonathan Works",
"author_id": 309844,
"author_profile": "https://Stackoverflow.com/users/309844",
"pm_score": 2,
"selected": false,
"text": "<p>Why not use SQLite? There is good support in Python and you can write SQL queries to get the data out. Here is t... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] | Basically, I've written an API to www.thetvdb.com in Python. The current code can be found [here](http://github.com/dbr/tvdb_api/tree/master/tvdb_api.py).
It grabs data from the API as requested, and has to store the data somehow, and make it available by doing:
```
print tvdbinstance[1][23]['episodename'] # get the ... | OK, what you need is `classobj` from new module. That would allow you to construct exception classes dynamically (`classobj` takes a string as an argument for the class name).
```
import new
myexc=new.classobj("ExcName",(Exception,),{})
i=myexc("This is the exc msg!")
raise i
```
this gives you:
```
Traceback (mos... |
5,982 | <p>Does anyone know why when using BindingUtils on the selectedItem property of a ComboBox you get the following warning? Any ideas how to resolve the issue?</p>
<p>The binding still works properly, but it would be nice to get rid of the warning.</p>
<pre><code>warning: multiple describeType entries for 'selectedItem... | [
{
"answer_id": 14237,
"author": "Matt MacLean",
"author_id": 22,
"author_profile": "https://Stackoverflow.com/users/22",
"pm_score": 0,
"selected": false,
"text": "<p>Here is the code. It is basically a copy of BindingUtils.bindProperty that is setup for a ComboBox so that both the combo... | 2008/08/08 | [
"https://Stackoverflow.com/questions/5982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22/"
] | Does anyone know why when using BindingUtils on the selectedItem property of a ComboBox you get the following warning? Any ideas how to resolve the issue?
The binding still works properly, but it would be nice to get rid of the warning.
```
warning: multiple describeType entries for 'selectedItem' on type 'mx.control... | It is better to override the property in question and declare it final. |
6,007 | <p>How do I make <a href="http://logging.apache.org/log4net/index.html" rel="noreferrer">Log4net</a> only log Info level logs? Is that even possible? Can you only set a threshold? </p>
<p>This is what I have, and it logs Info and above as I would expect. Is there anything i can do to make it only log info?</p>
<pre c... | [
{
"answer_id": 10383,
"author": "Brandon Wood",
"author_id": 423,
"author_profile": "https://Stackoverflow.com/users/423",
"pm_score": 8,
"selected": true,
"text": "<p>Within the definition of the appender, I believe you can do something like this:</p>\n\n<pre class=\"lang-xml prettyprin... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/230/"
] | How do I make [Log4net](http://logging.apache.org/log4net/index.html) only log Info level logs? Is that even possible? Can you only set a threshold?
This is what I have, and it logs Info and above as I would expect. Is there anything i can do to make it only log info?
```xml
<logger name="BrokerCollection.Model.XmlD... | Within the definition of the appender, I believe you can do something like this:
```xml
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<filter type="log4net.Filter.LevelRangeFilter">
<param name="LevelMin" value="INFO"/>
<param name="LevelMax" value="INFO"/>
</filter>
... |
6,076 | <p>I am building a server control that will search our db and return results. The server control is contains an ASP:Panel. I have set the default button on the panel equal to my button id and have set the form default button equal to my button id.</p>
<p>On the Panel:</p>
<pre><code> MyPanel.DefaultButton = SearchBut... | [
{
"answer_id": 6096,
"author": "Otto",
"author_id": 519,
"author_profile": "https://Stackoverflow.com/users/519",
"pm_score": 2,
"selected": false,
"text": "<p>Is SearchButton a LinkButton? If so, the javascript that is written to the browser doesn't work properly.</p>\n\n<p>Here is a g... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225/"
] | I am building a server control that will search our db and return results. The server control is contains an ASP:Panel. I have set the default button on the panel equal to my button id and have set the form default button equal to my button id.
On the Panel:
```
MyPanel.DefaultButton = SearchButton.ID
```
On the Co... | Ends up this resolved my issue:
```
SearchButton.UseSubmitBehavior = False
``` |
6,110 | <p>I've been handed a table with about 18000 rows. Each record describes the location of one customer. The issue is, that when the person created the table, they did not add a field for "Company Name", only "Location Name," and one company can have many locations.</p>
<p>For example, here are some records that describ... | [
{
"answer_id": 6119,
"author": "Neall",
"author_id": 619,
"author_profile": "https://Stackoverflow.com/users/619",
"pm_score": 1,
"selected": false,
"text": "<p>I've had to do this before. The only real way to do it is to manually match up the various locations. Use your database's conso... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/754/"
] | I've been handed a table with about 18000 rows. Each record describes the location of one customer. The issue is, that when the person created the table, they did not add a field for "Company Name", only "Location Name," and one company can have many locations.
For example, here are some records that describe the same... | Please update the question, do you have a list of CompanyNames available to you? I ask because you maybe able to use Levenshtein algo to find a relationship between your list of CompanyNames and LocationNames.
---
**Update**
>
> There is not a list of Company Names, I will have to generate the company name from the... |
6,126 | <p>It's something that's bugged me in every language I've used, I have an if statement but the conditional part has so many checks that I have to split it over multiple lines, use a nested if statement or just accept that it's ugly and move on with my life.</p>
<p>Are there any other methods that you've found that mig... | [
{
"answer_id": 6131,
"author": "abyx",
"author_id": 573,
"author_profile": "https://Stackoverflow.com/users/573",
"pm_score": 3,
"selected": false,
"text": "<p>First, I'd remove all the <code>== true</code> parts, that would make it 50% shorter ;)</p>\n\n<p>When I have big condition I se... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | It's something that's bugged me in every language I've used, I have an if statement but the conditional part has so many checks that I have to split it over multiple lines, use a nested if statement or just accept that it's ugly and move on with my life.
Are there any other methods that you've found that might be of u... | Separate the condition in several booleans and then use a master boolean as the condition.
```
bool isOpaque = object.Alpha == 1.0f;
bool isDrawable = object.CanDraw && object.Layer == currentLayer;
bool isHidden = hideList.Find(object);
bool isVisible = isOpaque && isDrawable && ! isHidden;
if(isVisible)
{
// .... |
6,134 | <p>I have a problem with some zombie-like processes on a certain server that need to be killed every now and then. How can I best identify the ones that have run for longer than an hour or so?</p>
| [
{
"answer_id": 6141,
"author": "abyx",
"author_id": 573,
"author_profile": "https://Stackoverflow.com/users/573",
"pm_score": 0,
"selected": false,
"text": "<p>Using ps is the right way. I've already done something similar before but don't have the source handy.\nGenerally - ps has an op... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/726/"
] | I have a problem with some zombie-like processes on a certain server that need to be killed every now and then. How can I best identify the ones that have run for longer than an hour or so? | If they just need to be killed:
```
if [[ "$(uname)" = "Linux" ]];then killall --older-than 1h someprocessname;fi
```
If you want to see what it's matching
```
if [[ "$(uname)" = "Linux" ]];then killall -i --older-than 1h someprocessname;fi
```
The `-i` flag will prompt you with yes/no for each process match. |
6,155 | <p>What kinds of hook scripts are people using for Subversion? Just general ideas but code would be great too!</p>
| [
{
"answer_id": 6165,
"author": "Mark Renouf",
"author_id": 758,
"author_profile": "https://Stackoverflow.com/users/758",
"pm_score": 0,
"selected": false,
"text": "<p>The most common one I think is to allow people to change revision comments after comitting. </p>\n\n<p>You need to enable... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/204/"
] | What kinds of hook scripts are people using for Subversion? Just general ideas but code would be great too! | I am using the `pre-revprop-change` hook that allows me to actually go back and edit comments and such information after the commit has been performed. This is very useful if there is missing/erroneous information in the commit comments.
Here I post a `pre-revprop-change.bat` batch file for Windows NT or later. You
ca... |
6,173 | <p>I'm looking for a .NET regular expression extract all the URLs from a webpage but haven't found one to be comprehensive enough to cover all the different ways you can specify a link. </p>
<p>And a side question:</p>
<p>Is there <strong>one regex to rule them all</strong>? Or am I better off using a series of less ... | [
{
"answer_id": 6177,
"author": "Vagmi Mudumbai",
"author_id": 617,
"author_profile": "https://Stackoverflow.com/users/617",
"pm_score": 1,
"selected": false,
"text": "<p>Look at the URI specification. That could help you a lot. And as far as performance goes, you can pretty much extract ... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/322/"
] | I'm looking for a .NET regular expression extract all the URLs from a webpage but haven't found one to be comprehensive enough to cover all the different ways you can specify a link.
And a side question:
Is there **one regex to rule them all**? Or am I better off using a series of less complicated regular expression... | ```
((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+)
```
I took this from [regexlib.com](http://regexlib.com/Search.aspx?k=URL)
[editor's note: the {1} has no real function in this regex; [see this post](https://stackoverflow.com/questions/13470/question-about-specific-regular-expression)] |
6,184 | <p>When you subscribe to an event on an object from within a form, you are essentially handing over control of your callback method to the event source. You have no idea whether that event source will choose to trigger the event on a different thread.</p>
<p>The problem is that when the callback is invoked, you cannot... | [
{
"answer_id": 6189,
"author": "Simon Gillbee",
"author_id": 756,
"author_profile": "https://Stackoverflow.com/users/756",
"pm_score": 4,
"selected": false,
"text": "<p>Here are the salient points:</p>\n\n<ol>\n<li>You can't make UI control calls from a different thread than the one they... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756/"
] | When you subscribe to an event on an object from within a form, you are essentially handing over control of your callback method to the event source. You have no idea whether that event source will choose to trigger the event on a different thread.
The problem is that when the callback is invoked, you cannot assume th... | To simplify Simon's code a bit, you could use the built in generic Action delegate. It saves peppering your code with a bunch of delegate types you don't really need. Also, in .NET 3.5 they added a params parameter to the Invoke method so you don't have to define a temporary array.
```
void SomethingHappened(object se... |
6,326 | <p>I have the following html.erb code that I'm looking to move to Haml:</p>
<pre><code><span class="<%= item.dashboardstatus.cssclass %>" ><%= item.dashboardstatus.status %></span>
</code></pre>
<p>What it does is associate the CSS class of the currently assigned status to the span.</p>
<p>Ho... | [
{
"answer_id": 6355,
"author": "Christian Lescuyer",
"author_id": 341,
"author_profile": "https://Stackoverflow.com/users/341",
"pm_score": 5,
"selected": true,
"text": "<p>Not sure. Maybe:</p>\n\n<pre><code>%span{:class => item.dashboardstatus.cssclass }= item.dashboardstatus.status\... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/722/"
] | I have the following html.erb code that I'm looking to move to Haml:
```
<span class="<%= item.dashboardstatus.cssclass %>" ><%= item.dashboardstatus.status %></span>
```
What it does is associate the CSS class of the currently assigned status to the span.
How is this done in Haml? I'm sure I'm missing something re... | Not sure. Maybe:
```
%span{:class => item.dashboardstatus.cssclass }= item.dashboardstatus.status
``` |
6,340 | <p>I've got a table that is supposed to track days and costs for shipping product from one vendor to another. We (brilliantly :p) stored both the shipping vendors (FedEx, UPS) with the product handling vendors (Think... Dunder Mifflin) in a "VENDOR" table. So, I have three columns in my SHIPPING_DETAILS table that all ... | [
{
"answer_id": 6349,
"author": "Christian Lescuyer",
"author_id": 341,
"author_profile": "https://Stackoverflow.com/users/341",
"pm_score": 5,
"selected": true,
"text": "<p>You defined the primary key twice. Try:</p>\n\n<pre><code>CREATE TABLE SHIPPING_GRID( \n id INT NOT NULL AUTO_I... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58/"
] | I've got a table that is supposed to track days and costs for shipping product from one vendor to another. We (brilliantly :p) stored both the shipping vendors (FedEx, UPS) with the product handling vendors (Think... Dunder Mifflin) in a "VENDOR" table. So, I have three columns in my SHIPPING\_DETAILS table that all re... | You defined the primary key twice. Try:
```
CREATE TABLE SHIPPING_GRID(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique ID for each row',
shipping_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the shipping vendor (vendors_type must be 3)',
start_vendor_no INT(6) NOT NULL ... |
6,369 | <p>So I have a Sybase stored proc that takes 1 parameter that's a comma separated list of strings and runs a query with in in an IN() clause:</p>
<pre><code>CREATE PROCEDURE getSomething @keyList varchar(4096)
AS
SELECT * FROM mytbl WHERE name IN (@keyList)
</code></pre>
<p>How do I call my stored proc with more than... | [
{
"answer_id": 6377,
"author": "Brian Childress",
"author_id": 721,
"author_profile": "https://Stackoverflow.com/users/721",
"pm_score": 0,
"selected": false,
"text": "<p>Do you need to use a comma separated list? The last couple of years, I've been taking this type of idea and passing i... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/779/"
] | So I have a Sybase stored proc that takes 1 parameter that's a comma separated list of strings and runs a query with in in an IN() clause:
```
CREATE PROCEDURE getSomething @keyList varchar(4096)
AS
SELECT * FROM mytbl WHERE name IN (@keyList)
```
How do I call my stored proc with more than 1 value in the list?
So f... | If you're using Sybase 12.5 or earlier then you can't use functions. A workaround might be to populate a temporary table with the values and read them from there. |
6,373 | <p>There are two popular closure styles in javascript. The first I call <em>anonymous constructor</em>:</p>
<pre><code>new function() {
var code...
}
</code></pre>
<p>and the <em>inline executed function</em>:</p>
<pre><code>(function() {
var code...
})();
</code></pre>
<p>are there differences in behaviour be... | [
{
"answer_id": 6387,
"author": "doekman",
"author_id": 56,
"author_profile": "https://Stackoverflow.com/users/56",
"pm_score": 3,
"selected": false,
"text": "<p>@Lance: the first one is also executing. Compare it with a named constructor:</p>\n\n<pre><code>function Blah() {\n alert('b... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56/"
] | There are two popular closure styles in javascript. The first I call *anonymous constructor*:
```
new function() {
var code...
}
```
and the *inline executed function*:
```
(function() {
var code...
})();
```
are there differences in behaviour between those two? Is one "better" over the other? | Both cases will execute the function, the only real difference is what the return value of the expression may be, and what the value of "this" will be inside the function.
Basically behaviour of
```
new expression
```
Is effectively equivalent to
```
var tempObject = {};
var result = expression.call(tempObject);
i... |
6,392 | <p>I am running a Tomcat application, and I need to display some time values. Unfortunately, the time is coming up an hour off. I looked into it and discovered that my default TimeZone is being set to:</p>
<pre><code>sun.util.calendar.ZoneInfo[id="GMT-08:00",
offset=-28800000,
... | [
{
"answer_id": 6496,
"author": "Jason Day",
"author_id": 737,
"author_profile": "https://Stackoverflow.com/users/737",
"pm_score": 6,
"selected": true,
"text": "<p>It's a \"quirk\" in the way the JVM looks up the zoneinfo file. See <a href=\"http://bugs.sun.com/bugdatabase/view_bug.do?b... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I am running a Tomcat application, and I need to display some time values. Unfortunately, the time is coming up an hour off. I looked into it and discovered that my default TimeZone is being set to:
```
sun.util.calendar.ZoneInfo[id="GMT-08:00",
offset=-28800000,
d... | It's a "quirk" in the way the JVM looks up the zoneinfo file. See [Bug ID 6456628](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6456628).
The easiest workaround is to make /etc/localtime a symlink to the correct zoneinfo file. For Pacific time, the following commands should work:
```
# sudo cp /etc/localtime /e... |
6,406 | <p>Is it possible to access an element on a Master page from the page loaded within the <code>ContentPlaceHolder</code> for the master?</p>
<p>I have a ListView that lists people's names in a navigation area on the Master page. I would like to update the ListView after a person has been added to the table that the Lis... | [
{
"answer_id": 6411,
"author": "Brandon Wood",
"author_id": 423,
"author_profile": "https://Stackoverflow.com/users/423",
"pm_score": -1,
"selected": false,
"text": "<p>Assuming your master page was named MyMaster:</p>\n\n<pre><code>(Master as MyMaster).PeopleListView.DataBind();\n</code... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/576/"
] | Is it possible to access an element on a Master page from the page loaded within the `ContentPlaceHolder` for the master?
I have a ListView that lists people's names in a navigation area on the Master page. I would like to update the ListView after a person has been added to the table that the ListView is data bound t... | I believe you *could* do this by using this.Master.FindControl or something similar, but you probably shouldn't - it requires the content page to know too much about the structure of the master page.
I would suggest another method, such as firing an event in the content area that the master could listen for and re-bin... |
6,414 | <p>In a C# (feel free to answer for other languages) loop, what's the difference between <code>break</code> and <code>continue</code> as a means to leave the structure of the loop, and go to the next iteration?</p>
<p>Example:</p>
<pre><code>foreach (DataRow row in myTable.Rows)
{
if (someConditionEvalsToTrue)
... | [
{
"answer_id": 6415,
"author": "palmsey",
"author_id": 521,
"author_profile": "https://Stackoverflow.com/users/521",
"pm_score": 5,
"selected": false,
"text": "<p><code>break</code> would stop the <code>foreach</code> loop completely, <code>continue</code> would skip to the next <code>Da... | 2008/08/08 | [
"https://Stackoverflow.com/questions/6414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] | In a C# (feel free to answer for other languages) loop, what's the difference between `break` and `continue` as a means to leave the structure of the loop, and go to the next iteration?
Example:
```
foreach (DataRow row in myTable.Rows)
{
if (someConditionEvalsToTrue)
{
break; //what's the difference ... | `break` will exit the loop completely, `continue` will just **skip** the current iteration.
For example:
```
for (int i = 0; i < 10; i++) {
if (i == 0) {
break;
}
DoSomeThingWith(i);
}
```
The break will cause the loop to exit on the first iteration - `DoSomeThingWith` will never be executed. T... |