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 |
|---|---|---|---|---|---|---|
116,432 | <p>Suppose we have a stylesheet which pulls in metadata using the key() function. In other words we have instance documents like this:</p>
<pre><code><items>
<item type="some_type"/>
<item type="another_type"/>
</items>
</code></pre>
<p>and a table of additional data we would like to assoc... | [
{
"answer_id": 117423,
"author": "TToni",
"author_id": 20703,
"author_profile": "https://Stackoverflow.com/users/20703",
"pm_score": 1,
"selected": false,
"text": "<p>Selectors in key/keyref allow only a very restricted xpath syntax. Short, but not completely accurate: The selector must ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Suppose we have a stylesheet which pulls in metadata using the key() function. In other words we have instance documents like this:
```
<items>
<item type="some_type"/>
<item type="another_type"/>
</items>
```
and a table of additional data we would like to associate with items during processing:
```
<item-meta>... | Selectors in key/keyref allow only a very restricted xpath syntax. Short, but not completely accurate: The selector must point to a subnode of the element declared.
The full definition of the restricted syntax is [-> here](http://www.w3.org/TR/xmlschema-1/#coss-identity-constraint).
So, no I don't see a better way, s... |
116,444 | <p>By default netbeans stores it's settings in a directory called .netbeans under the user's home directory. Is it possible to change the location of this directory (especially under Windows)?</p>
<p>Thanks to James Schek I now know the answer (change the path in netbeans.conf) but that leads me to another question:
... | [
{
"answer_id": 116662,
"author": "James Schek",
"author_id": 17871,
"author_profile": "https://Stackoverflow.com/users/17871",
"pm_score": 5,
"selected": true,
"text": "<p>yes, edit the netbeans.conf file under %NETBEANS_HOME%\\etc.</p>\n\n<p>Edit the line with:\nnetbeans_default_userdir... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4497/"
] | By default netbeans stores it's settings in a directory called .netbeans under the user's home directory. Is it possible to change the location of this directory (especially under Windows)?
Thanks to James Schek I now know the answer (change the path in netbeans.conf) but that leads me to another question:
Is there a... | yes, edit the netbeans.conf file under %NETBEANS\_HOME%\etc.
Edit the line with:
netbeans\_default\_userdir="${HOME}/.netbeans/6.0"
If you need different "profiles"--i.e. want to run different copies of Netbeans with different home directories, you can pass a new home directory to the launcher. Run "netbeans.exe --us... |
116,469 | <p>Ok so before I even ask my question I want to make one thing clear. I am currently a student at NIU for Computer Science and this does relate to one of my assignments for a class there. So if anyone has a problem read no further and just go on about your business. </p>
<p>Now for anyone who is willing to help heres... | [
{
"answer_id": 116510,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 4,
"selected": true,
"text": "<p>The problem with empty entries is in your while loop. If you get an empty string, you clean the next one, and add... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/924/"
] | Ok so before I even ask my question I want to make one thing clear. I am currently a student at NIU for Computer Science and this does relate to one of my assignments for a class there. So if anyone has a problem read no further and just go on about your business.
Now for anyone who is willing to help heres the situa... | The problem with empty entries is in your while loop. If you get an empty string, you clean the next one, and add it without checking. Try changing:
```
not_s = "";
clean_entry(s, not_s);
if((int)not_s.length() == 0)
{
input >> s;
clean_entry(s, not_s);
}
mapz[not_s]++; //increment occurence
... |
116,485 | <p>I have 2 arrays of 16 elements (chars) that I need to "compare" and see how many elements are equal between the two.</p>
<p>This routine is going to be used millions of times (a usual run is about 60 or 70 million times), so I need it to be as fast as possible. I'm working on C++ (C++Builder 2007, for the record)</... | [
{
"answer_id": 116504,
"author": "Joe Skora",
"author_id": 14057,
"author_profile": "https://Stackoverflow.com/users/14057",
"pm_score": 0,
"selected": false,
"text": "<p>Is it faster as one statement?</p>\n\n<pre><code>matches += (array1[0] == array2[0]) + (array1[1] == array2[1]) + ...... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16772/"
] | I have 2 arrays of 16 elements (chars) that I need to "compare" and see how many elements are equal between the two.
This routine is going to be used millions of times (a usual run is about 60 or 70 million times), so I need it to be as fast as possible. I'm working on C++ (C++Builder 2007, for the record)
Right now,... | UPDATE: This answer has been modified to make my comments match the source code provided below.
There is an optimization available if you have the capability to use SSE2 and popcnt instructions.
16 bytes happens to fit nicely in an SSE register. Using c++ and assembly/intrinsics, load the two 16 byte arrays into xmm ... |
116,494 | <p>How would one write a regular expression to use in Python to split paragraphs?</p>
<p>A paragraph is defined by two line breaks (\n). But one can have any amount of spaces/tabs together with the line breaks, and it still should be considered as a paragraph.</p>
<p>I am using Python, so the solution can use Python's ... | [
{
"answer_id": 116557,
"author": "Joseph Bui",
"author_id": 3275,
"author_profile": "https://Stackoverflow.com/users/3275",
"pm_score": 0,
"selected": false,
"text": "<p>Almost the same, but using non-greedy quantifiers and taking advantage of the whitespace sequence.</p>\n\n<pre><code>\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17160/"
] | How would one write a regular expression to use in Python to split paragraphs?
A paragraph is defined by two line breaks (\n). But one can have any amount of spaces/tabs together with the line breaks, and it still should be considered as a paragraph.
I am using Python, so the solution can use Python's [regular expres... | Unfortunately there's no nice way to write "space but not a newline".
I think the best you can do is add some space with the `x` modifier and try to factor out the ugliness a bit, but that's questionable: `(?x) (?: [ \t\r\f\v]*? \n ){2} [ \t\r\f\v]*?`
You could also try creating a subrule just for the character class... |
116,560 | <p>I like to use Emacs' shell mode, but it has a few deficiencies. One of those is that it's not smart enough to open a new buffer when a shell command tries to invoke an editor. For example with the environment variable <code>VISUAL</code> set to <code>vim</code> I get the following from <code>svn propedit</code>:</p>... | [
{
"answer_id": 116570,
"author": "Rich",
"author_id": 20640,
"author_profile": "https://Stackoverflow.com/users/20640",
"pm_score": 5,
"selected": true,
"text": "<p>You can attach to an Emacs session through <code>emacsclient</code>. First, start the emacs server with </p>\n\n<pre><code>... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | I like to use Emacs' shell mode, but it has a few deficiencies. One of those is that it's not smart enough to open a new buffer when a shell command tries to invoke an editor. For example with the environment variable `VISUAL` set to `vim` I get the following from `svn propedit`:
```
$ svn propedit svn:externals .
"... | You can attach to an Emacs session through `emacsclient`. First, start the emacs server with
```
M-x server-start
```
or add `(server-start)` to your `.emacs`. Then,
```
export VISUAL=emacsclient
```
Edit away.
Note:
* The versions of `emacs` and `emacsclient` must agree. If you have multiple versions of Emacs... |
116,574 | <p>While googling, I see that using <a href="http://docs.oracle.com/javase/6/docs/api/java/io/File.html#length%28%29" rel="noreferrer"><code>java.io.File#length()</code></a> can be slow.
<a href="http://docs.oracle.com/javase/6/docs/api/java/nio/channels/FileChannel.html" rel="noreferrer"><code>FileChannel</code></a> h... | [
{
"answer_id": 116916,
"author": "GHad",
"author_id": 11705,
"author_profile": "https://Stackoverflow.com/users/11705",
"pm_score": 8,
"selected": true,
"text": "<p>Well, I tried to measure it up with the code below:</p>\n\n<p>For runs = 1 and iterations = 1 the URL method is fastest mos... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20641/"
] | While googling, I see that using [`java.io.File#length()`](http://docs.oracle.com/javase/6/docs/api/java/io/File.html#length%28%29) can be slow.
[`FileChannel`](http://docs.oracle.com/javase/6/docs/api/java/nio/channels/FileChannel.html) has a [`size()`](http://docs.oracle.com/javase/6/docs/api/java/nio/channels/FileCh... | Well, I tried to measure it up with the code below:
For runs = 1 and iterations = 1 the URL method is fastest most times followed by channel. I run this with some pause fresh about 10 times. So for one time access, using the URL is the fastest way I can think of:
```
LENGTH sum: 10626, per Iteration: 10626.0
CHANNEL... |
116,587 | <p>I need to determine if a Class object representing an interface extends another interface, ie:</p>
<pre><code> package a.b.c.d;
public Interface IMyInterface extends a.b.d.c.ISomeOtherInterface{
}
</code></pre>
<p>according to <a href="http://web.archive.org/web/20100705124350/http://java.sun.com:80/j2se/1... | [
{
"answer_id": 116615,
"author": "Andreas Holstenson",
"author_id": 16351,
"author_profile": "https://Stackoverflow.com/users/16351",
"pm_score": 5,
"selected": true,
"text": "<p>Use Class.getInterfaces such as:</p>\n\n<pre><code>Class<?> c; // Your class\nfor(Class<?> i : c.... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/292/"
] | I need to determine if a Class object representing an interface extends another interface, ie:
```
package a.b.c.d;
public Interface IMyInterface extends a.b.d.c.ISomeOtherInterface{
}
```
according to [the spec](http://web.archive.org/web/20100705124350/http://java.sun.com:80/j2se/1.4.2/docs/api/java/lang/... | Use Class.getInterfaces such as:
```
Class<?> c; // Your class
for(Class<?> i : c.getInterfaces()) {
// test if i is your interface
}
```
Also the following code might be of help, it will give you a set with all super-classes and interfaces of a certain class:
```
public static Set<Class<?>> getInheritance(Cla... |
116,626 | <p>I'm trying to polish up my Ruby by re writing Kent Beck's xUnit Python example from "Test Driven Development: By Example". I've got quite far but now I get the following error when I run which I don't grok.</p>
<pre><code>C:\Documents and Settings\aharmel\My Documents\My Workspace\TDD_Book\TDDBook_xUnit_RubyVersio... | [
{
"answer_id": 116688,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 0,
"selected": false,
"text": "<p>One thing that leaps out is that the <code>send</code> method expects a symbol identifying the method name, but you'r... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2455/"
] | I'm trying to polish up my Ruby by re writing Kent Beck's xUnit Python example from "Test Driven Development: By Example". I've got quite far but now I get the following error when I run which I don't grok.
```
C:\Documents and Settings\aharmel\My Documents\My Workspace\TDD_Book\TDDBook_xUnit_RubyVersion\lib\main.rb:2... | It's your print statement:
```
puts "test was run? (true expected): #{test.wasRun}"
```
should be
```
puts "test was run? (true expected): #{@test.wasRun}"
```
without the '@' you are calling Kernel#test, which expects 2 variables. |
116,635 | <p>(I've asked the same question of the jmeter-user mailing list, but I wanted to try here as well - so at the least I can update this with the answer once I find it).</p>
<p>I'm having trouble using <a href="http://jakarta.apache.org/jmeter/" rel="noreferrer">JMeter</a> to test a Tomcat webapp using a self-signed SSL... | [
{
"answer_id": 117424,
"author": "Alexander",
"author_id": 16724,
"author_profile": "https://Stackoverflow.com/users/16724",
"pm_score": 2,
"selected": false,
"text": "<p>This is a hint rather than a proper answer: A cursory glance at Google results seems to suggest that the exception is... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4249/"
] | (I've asked the same question of the jmeter-user mailing list, but I wanted to try here as well - so at the least I can update this with the answer once I find it).
I'm having trouble using [JMeter](http://jakarta.apache.org/jmeter/) to test a Tomcat webapp using a self-signed SSL cert. JMeter throws a SocketException... | Most `javax.net.SocketFactory` implementations define all `createSocket()` methods **that have parameters** as abstract. But have a `createSocket()` method without parameters that looks like this:
```
public Socket createSocket() throws IOException {
throw new SocketException("Unconnected sockets not implemented");... |
116,640 | <p>I'm experiencing an issue on a test machine running Red Hat Linux (kernel version is 2.4.21-37.ELsmp) using Java 1.6 (1.6.0_02 or 1.6.0_04). The problem is, once a certain number of threads are created in a single thread group, the operating system is unwilling or unable to create any more.</p>
<p>This seems to be ... | [
{
"answer_id": 116696,
"author": "plinth",
"author_id": 20481,
"author_profile": "https://Stackoverflow.com/users/20481",
"pm_score": 2,
"selected": false,
"text": "<p>Have you looked at <a href=\"http://people.redhat.com/alikins/system_tuning.html#threads\" rel=\"nofollow noreferrer\">t... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13792/"
] | I'm experiencing an issue on a test machine running Red Hat Linux (kernel version is 2.4.21-37.ELsmp) using Java 1.6 (1.6.0\_02 or 1.6.0\_04). The problem is, once a certain number of threads are created in a single thread group, the operating system is unwilling or unable to create any more.
This seems to be specific... | Updating the kernel to a newer version (2.6.something) with NPTL threading fixed this. |
116,646 | <p>I would like to implement a data access object pattern in C++, but preferably without using multiple inheritance and/or boost (which my client does not like). </p>
<p>Do you have any suggestions?</p>
| [
{
"answer_id": 116714,
"author": "JeffFoster",
"author_id": 9853,
"author_profile": "https://Stackoverflow.com/users/9853",
"pm_score": 4,
"selected": true,
"text": "<p>OTL (otl.sourceforge.net) is an excellent C++ database library. It's a single include file so doesn't have all the com... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19863/"
] | I would like to implement a data access object pattern in C++, but preferably without using multiple inheritance and/or boost (which my client does not like).
Do you have any suggestions? | OTL (otl.sourceforge.net) is an excellent C++ database library. It's a single include file so doesn't have all the complexity associated (rightly or wrongly!) with Boost.
In terms of the DAO itself, you have many options. The simplest that hides the database implementation is just to use C++ style interfaces and imple... |
116,650 | <p>I am tasked with writing an authentication component for an open source <code>JAVA</code> app. We have an in-house authentication widget that uses <code>https</code>. I have some example <code>php</code> code that accesses the <code>widget</code> which uses <code>cURL</code> to handle the transfer. </p>
<p>My qu... | [
{
"answer_id": 116670,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 1,
"selected": false,
"text": "<p>Try <a href=\"http://commons.apache.org/net/\" rel=\"nofollow noreferrer\">Apache Commons Net</a> for network protoco... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16253/"
] | I am tasked with writing an authentication component for an open source `JAVA` app. We have an in-house authentication widget that uses `https`. I have some example `php` code that accesses the `widget` which uses `cURL` to handle the transfer.
My question is whether or not there is a port of `cURL` to `JAVA`, or bet... | Exception handling omitted:
```
HttpURLConnection con = (HttpURLConnection) new URL("https://www.example.com").openConnection();
con.setRequestMethod("POST");
con.getOutputStream().write("LOGIN".getBytes("UTF-8"));
con.getInputStream();
``` |
116,682 | <p>I have a URI here in which a simple document.cookie query through the console is resulting in three cookies being displayed. I verified this with trivial code such as the following as well:</p>
<pre><code>var cookies = document.cookie.split(';');
console.log(cookies.length);
</code></pre>
<p>The variable cookies ... | [
{
"answer_id": 116660,
"author": "Ben Collins",
"author_id": 3279,
"author_profile": "https://Stackoverflow.com/users/3279",
"pm_score": 1,
"selected": false,
"text": "<p>Lisp supports a form of \"metaprogramming\", although not in the same sense as C++ template metaprogramming. Also, y... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a URI here in which a simple document.cookie query through the console is resulting in three cookies being displayed. I verified this with trivial code such as the following as well:
```
var cookies = document.cookie.split(';');
console.log(cookies.length);
```
The variable cookies does indeed come out to th... | The alternative to template style meta-programming is Macro-style that you see in various Lisp implementations. I would suggest downloading [Paul Graham's *On Lisp*](http://www.paulgraham.com/onlisp.html) and also taking a look at [Clojure](http://clojure.org) if you're interested in a Lisp with macros that runs on the... |
116,687 | <p>I want to call a few "static" methods of a CPP class defined in a different file but I'm having linking problems. I created a test-case that recreates my problem and the code for it is below.</p>
<p>(I'm completely new to C++, I come from a Java background and I'm a little familiar with C.)</p>
<pre><code>// CppCl... | [
{
"answer_id": 116708,
"author": "Jon",
"author_id": 12261,
"author_profile": "https://Stackoverflow.com/users/12261",
"pm_score": 2,
"selected": false,
"text": "<p>I think you want to do something like:</p>\n\n<p>g++ -c CppClass.cpp\ng++ -c main.cpp\ng++ -o go main.o CppClass.o</p>\n\n<... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7205/"
] | I want to call a few "static" methods of a CPP class defined in a different file but I'm having linking problems. I created a test-case that recreates my problem and the code for it is below.
(I'm completely new to C++, I come from a Java background and I'm a little familiar with C.)
```
// CppClass.cpp
#include <ios... | It's obvious you come from a Java background because you haven't yet grasped the concept of header files. In Java the process of defining something is usually in one piece. You declare and define at the same time. In C/C++ it's a two-step process. **Declaring** something tells the compiler "something exists with this t... |
116,690 | <p>SVN keyword substition gives is not pretty. E.g.,</p>
<blockquote>
<p>Last updated: $Date$ by $Author$</p>
</blockquote>
<p>yields</p>
<blockquote>
<p>Last updated: $Date: 2008-09-22
14:38:43 -0400 (Mon, 22 Sep 2008) $ by
$Author: cconway $"</p>
</blockquote>
<p>Does anybody have a Javascript snippet tha... | [
{
"answer_id": 116777,
"author": "Chris MacDonald",
"author_id": 18146,
"author_profile": "https://Stackoverflow.com/users/18146",
"pm_score": 0,
"selected": false,
"text": "<p>Some JavaScript libraries provide templating functionality.</p>\n\n<p>Prototype - <a href=\"http://www.prototyp... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | SVN keyword substition gives is not pretty. E.g.,
>
> Last updated: $Date$ by $Author$
>
>
>
yields
>
> Last updated: $Date: 2008-09-22
> 14:38:43 -0400 (Mon, 22 Sep 2008) $ by
> $Author: cconway $"
>
>
>
Does anybody have a Javascript snippet that prettifies things and outputs some HTML? The result shoul... | Errr.. This feels a bit like me doing your job for you :), but here goes:
```
function formatSvnString(string){
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
var re = /\$Date: (\d{4})-(\d\d)-(\d\d).*?\$Author: (\S+) \$/
return string.replace(re, function... |
116,701 | <p>What's the best way for a running C or C++ program that's been launched from the command line to put itself into the background, equivalent to if the user had launched from the unix shell with '&' at the end of the command? (But the user didn't.) It's a GUI app and doesn't need any shell I/O, so there's no rea... | [
{
"answer_id": 116709,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 3,
"selected": false,
"text": "<p>The way it's typically done on Unix-like OSes is to fork() at the beginning and exit from the parent. This won... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3832/"
] | What's the best way for a running C or C++ program that's been launched from the command line to put itself into the background, equivalent to if the user had launched from the unix shell with '&' at the end of the command? (But the user didn't.) It's a GUI app and doesn't need any shell I/O, so there's no reason to ti... | My advice: **don't do this**, at least not under Linux/UNIX.
GUI programs under Linux/UNIX traditionally do *not* auto-background themselves. While this may occasionally be annoying to newbies, it has a number of advantages:
* Makes it easy to capture standard error in case of core dumps / other problems that need de... |
116,760 | <p>I have a rather weak understanding of any of oracle's more advanced functionality but this should I think be possible.</p>
<p>Say I have a table with the following schema:</p>
<pre><code>MyTable
Id INTEGER,
Col1 VARCHAR2(100),
Col2 VARCHAR2(100)
</code></pre>
<p>I would like to write an sproc with the follo... | [
{
"answer_id": 116795,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": true,
"text": "<p>Using MERGE and COALESCE? <a href=\"http://blogs.oracle.com/cmar/entry/using_merge_to_do_an\" rel=\"nofollow noreferr... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I have a rather weak understanding of any of oracle's more advanced functionality but this should I think be possible.
Say I have a table with the following schema:
```
MyTable
Id INTEGER,
Col1 VARCHAR2(100),
Col2 VARCHAR2(100)
```
I would like to write an sproc with the following
```
PROCEDURE InsertOrUpda... | Using MERGE and COALESCE? [Try this link for an example](http://blogs.oracle.com/cmar/entry/using_merge_to_do_an)
with
```
SET a.Col1 = COALESCE(incoming.Col1, a.Col1)
,a.Col2 = COALESCE(incoming.Col2, a.Col2)
``` |
116,775 | <p>I am adding custom controls to a FlowLayoutPanel. Each control has a date property. I would like to sort the controls in the flowlayoutpanel based on the date property. I can't presort the controls before I add them because it is possible for the user to add more.</p>
<p>My current thought is when the ControlAdded ... | [
{
"answer_id": 117227,
"author": "Andrew Queisser",
"author_id": 18321,
"author_profile": "https://Stackoverflow.com/users/18321",
"pm_score": 0,
"selected": false,
"text": "<p>BringToFront affects the z-order not the x/y position, I suspect you want to sort the FlowLayoutPanel.Controls ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] | I am adding custom controls to a FlowLayoutPanel. Each control has a date property. I would like to sort the controls in the flowlayoutpanel based on the date property. I can't presort the controls before I add them because it is possible for the user to add more.
My current thought is when the ControlAdded event for ... | I doubt this is the best but is what I have so far:
```
SortedList<DateTime,Control> sl = new SortedList<DateTime,Control>();
foreach (Control i in mainContent.Controls)
{
if (i.GetType().BaseType == typeof(MyBaseType))
{
MyBaseType iTyped = (MyBaseType)i... |
116,797 | <p>I have an int array as a property of a Web User Control. I'd like to set that property inline if possible using the following syntax:</p>
<pre><code><uc1:mycontrol runat="server" myintarray="1,2,3" />
</code></pre>
<p>This will fail at runtime because it will be expecting an actual int array, but a string is... | [
{
"answer_id": 116940,
"author": "Rob",
"author_id": 7872,
"author_profile": "https://Stackoverflow.com/users/7872",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried looking into Type Converters? This page looks worth a look: <a href=\"http://www.codeguru.com/columns/VB/artic... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5609/"
] | I have an int array as a property of a Web User Control. I'd like to set that property inline if possible using the following syntax:
```
<uc1:mycontrol runat="server" myintarray="1,2,3" />
```
This will fail at runtime because it will be expecting an actual int array, but a string is being passed instead. I can mak... | Implement a type converter, here is one, warning : quick&dirty, not for production use, etc :
```
public class IntArrayConverter : System.ComponentModel.TypeConverter
{
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, Type sourceType)
{
return sourceType == type... |
116,810 | <p>I'm auditing our existing web application, which makes heavy use of <a href="http://www.w3schools.com/HTML/html_frames.asp" rel="nofollow noreferrer">HTML frames</a>. I would like to download all of the HTML in each frame, is there a method of doing this with <a href="http://www.gnu.org/software/wget/" rel="nofollow... | [
{
"answer_id": 116849,
"author": "Steve Moyer",
"author_id": 17008,
"author_profile": "https://Stackoverflow.com/users/17008",
"pm_score": 1,
"selected": false,
"text": "<pre><code>wget --recursive --domains=www.mysite.com http://www.mysite.com\n</code></pre>\n\n<p>Which indicates a recu... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/302/"
] | I'm auditing our existing web application, which makes heavy use of [HTML frames](http://www.w3schools.com/HTML/html_frames.asp). I would like to download all of the HTML in each frame, is there a method of doing this with [wget](http://www.gnu.org/software/wget/) or a little bit of scripting? | as an addition to Steve's answer:
Span to any host—‘-H’
The ‘-H’ option turns on host spanning, thus allowing Wget's recursive run to visit any host referenced by a link. Unless sufficient recursion-limiting criteria are applied depth, these foreign hosts will typically link to yet more hosts, and so on until Wget en... |
116,819 | <p>I want an expression that will fail when it encounters words such as "boon.ini" and "http". The goal would be to take this expression and be able to construct for any set of keywords.</p>
| [
{
"answer_id": 116862,
"author": "Justin Poliey",
"author_id": 6967,
"author_profile": "https://Stackoverflow.com/users/6967",
"pm_score": 4,
"selected": false,
"text": "<p>Rather than negating the result within the expression, you should do it in your code. That way, the expression beco... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19161/"
] | I want an expression that will fail when it encounters words such as "boon.ini" and "http". The goal would be to take this expression and be able to construct for any set of keywords. | ```
^(?:(?!boon\.ini|http).)*$\r?\n?
```
(taken from [RegexBuddy](http://www.regexbuddy.com)'s library) will match any line that does not contain boon.ini and/or http. Is that what you wanted? |
116,824 | <p>Whats the most efficient way of selecting total number of records from a large table? Currently, Im simply doing</p>
<pre><code>$result = mysql_query("SELECT id FROM table");
$total = mysql_num_rows($result)
</code></pre>
<p>I was told this was not very efficient or fast, if you have a lot of records in the table.... | [
{
"answer_id": 116829,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 3,
"selected": false,
"text": "<p>You should use <a href=\"http://dev.mysql.com/doc/refman/5.0/en/counting-rows.html\" rel=\"nofollow noreferrer\">SQL's buil... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Whats the most efficient way of selecting total number of records from a large table? Currently, Im simply doing
```
$result = mysql_query("SELECT id FROM table");
$total = mysql_num_rows($result)
```
I was told this was not very efficient or fast, if you have a lot of records in the table. | You were told correctly. mysql can do this count for you which is much more efficient.
```
$result = mysql_query( "select count(id) as num_rows from table" );
$row = mysql_fetch_object( $result );
$total = $row->num_rows;
``` |
116,830 | <p>In Java, one can declare a variable parameterised by an "unknown" generic type, which looks like this:</p>
<pre><code>Foo<?> x;
</code></pre>
<p>Is there an equivalent construct to this question-mark, in C#?</p>
| [
{
"answer_id": 116870,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 2,
"selected": false,
"text": "<p>No, there isn't really the same concept in C#. You would need to refer to a base class of Foo (maybe a non-generic Foo), ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14113/"
] | In Java, one can declare a variable parameterised by an "unknown" generic type, which looks like this:
```
Foo<?> x;
```
Is there an equivalent construct to this question-mark, in C#? | The short answer is no. There isn't an equivalent feature in C#.
A workaround, from [C# from a Java developer's perspective](http://www.25hoursaday.com/CsharpVsJava.html#generics) by Dare Obasanjo:
In certain cases, one may need create a method that can operate on data structures containing any type as opposed to tho... |
116,869 | <p>I know this is a dumb question. For some reason my mind is blank on this. Any ideas?</p>
<p>Sorry should have been more clear. </p>
<p>Using a <code>HtmlGenericControl</code> to pull in link description as well as image. </p>
<pre><code> private void InternalCreateChildControls()
{
if (this.DataItem !... | [
{
"answer_id": 116884,
"author": "Wes P",
"author_id": 13611,
"author_profile": "https://Stackoverflow.com/users/13611",
"pm_score": -1,
"selected": false,
"text": "<p>This is kind of a horrible question. I mean, .NET has an image control where you can set the source to anything you wan... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7911/"
] | I know this is a dumb question. For some reason my mind is blank on this. Any ideas?
Sorry should have been more clear.
Using a `HtmlGenericControl` to pull in link description as well as image.
```
private void InternalCreateChildControls()
{
if (this.DataItem != null && this.Relationships.Count > 0)... | I'm assuming you want to generate an image dynamicly based upon an url.
What I typically do is a create a very lightweight HTTPHandler to serve the images:
```
using System;
using System.Web;
namespace Example
{
public class GetImage : IHttpHandler
{
public void ProcessRequest(HttpContext context)... |
116,876 | <p>I'm trying to build a Windows installer using Nullsoft Install System that requires installation by an Administrator. The installer makes a "logs" directory. Since regular users can run this application, that directory needs to be writable by regular users. How do I specify that all users should have permission to... | [
{
"answer_id": 116914,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 3,
"selected": false,
"text": "<p>One way: call the shell, and use <a href=\"http://technet.microsoft.com/en-us/library/bb490872.aspx\" rel=\"noreferr... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5074/"
] | I'm trying to build a Windows installer using Nullsoft Install System that requires installation by an Administrator. The installer makes a "logs" directory. Since regular users can run this application, that directory needs to be writable by regular users. How do I specify that all users should have permission to have... | Use the [AccessControl](http://nsis.sourceforge.net/AccessControl_plug-in) plugin and then add this to the script, where the "logs" directory is in the install directory.
```
AccessControl::GrantOnFile "$INSTDIR\logs" "(BU)" "FullAccess"
```
That gives full access to the folder for all users. |
116,887 | <p>I seem to be getting a strange error when I run my tests in rails, they are all failing for the same reason and none of the online documentation seems particularly helpful in regards to this particular error:</p>
<pre><code>SQLite3::SQLException: cannot rollback - no transaction is active
</code></pre>
<p>This err... | [
{
"answer_id": 117289,
"author": "David Medinets",
"author_id": 219658,
"author_profile": "https://Stackoverflow.com/users/219658",
"pm_score": 2,
"selected": true,
"text": "<p>Check <a href=\"http://dev.rubyonrails.org/ticket/4403\" rel=\"nofollow noreferrer\">http://dev.rubyonrails.org... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2594/"
] | I seem to be getting a strange error when I run my tests in rails, they are all failing for the same reason and none of the online documentation seems particularly helpful in regards to this particular error:
```
SQLite3::SQLException: cannot rollback - no transaction is active
```
This error is crippling my ability... | Check <http://dev.rubyonrails.org/ticket/4403> which shows a workaround. Could that be the problem you are encountering? |
116,888 | <p>Given this data:</p>
<pre><code>CREATE TABLE tmpTable(
fldField varchar(10) null);
INSERT INTO tmpTable
SELECT 'XXX'
UNION ALL
SELECT 'XXX'
UNION ALL
SELECT 'ZZZ'
UNION ALL
SELECT 'ZZZ'
UNION ALL
SELECT 'YYY'
SELECT
CASE WHEN fldField like 'YYY' THEN 'OTH' ELSE 'XXX' END AS newField
FROM tmpTable
</code></pre... | [
{
"answer_id": 116924,
"author": "curtisk",
"author_id": 17651,
"author_profile": "https://Stackoverflow.com/users/17651",
"pm_score": -1,
"selected": false,
"text": "<p>You aren't specifying what you are selecting and checking the CASE against...</p>\n\n<pre><code>SELECT CASE fldField ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12470/"
] | Given this data:
```
CREATE TABLE tmpTable(
fldField varchar(10) null);
INSERT INTO tmpTable
SELECT 'XXX'
UNION ALL
SELECT 'XXX'
UNION ALL
SELECT 'ZZZ'
UNION ALL
SELECT 'ZZZ'
UNION ALL
SELECT 'YYY'
SELECT
CASE WHEN fldField like 'YYY' THEN 'OTH' ELSE 'XXX' END AS newField
FROM tmpTable
```
The expected results... | Check your service pack. After upgrading my SQL 2000 box to SP4 I now get the correct values for your situation.
I'm still getting the swapped data that I reported in my earlier post though :(
If you do `SELECT @@version` you should get 8.00.2039. Any version number less than that and you should install SP4. |
116,894 | <p>I am writing a simple Python web application that consists of several pages of business data formatted for the iPhone. I'm comfortable programming Python, but I'm not very familiar with Python "idiom," especially regarding classes and objects. Python's object oriented design differs somewhat from other languages I'v... | [
{
"answer_id": 116974,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 1,
"selected": false,
"text": "<p>Have you considered using an ORM? <a href=\"http://www.sqlalchemy.org/features.html\" rel=\"nofollow noreferrer\" title=... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19031/"
] | I am writing a simple Python web application that consists of several pages of business data formatted for the iPhone. I'm comfortable programming Python, but I'm not very familiar with Python "idiom," especially regarding classes and objects. Python's object oriented design differs somewhat from other languages I've w... | The empty Record class and the free-floating function that (generally) applies to an individual Record is a hint that you haven't designed your class properly.
```
class Record( object ):
"""Assuming rtda and pnl must exist."""
def __init__( self ):
self.da= 0
self.rt= 0
self.rtda= 0 # ... |
116,896 | <p>I would like Visual Studio to break when a handled exception happens (i.e. I don't just want to see a "First chance" message, I want to debug the actual exception).</p>
<p>e.g. I want the debugger to break at the exception:</p>
<pre><code>try
{
System.IO.File.Delete(someFilename);
}
catch (Exception)
{
//we ... | [
{
"answer_id": 116913,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 6,
"selected": false,
"text": "<p>There is an 'exceptions' window in VS2005 ... try <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>E</kbd> when debugging and click... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] | I would like Visual Studio to break when a handled exception happens (i.e. I don't just want to see a "First chance" message, I want to debug the actual exception).
e.g. I want the debugger to break at the exception:
```
try
{
System.IO.File.Delete(someFilename);
}
catch (Exception)
{
//we really don't care at ... | With a solution open, go to the Debug - Windows - Exception Settings (`Ctrl`+`Alt`+`E`) menu option. From there you can choose to break on *Thrown* or *User-unhandled* exceptions.
EDIT: My instance is set up with the C# "profile" perhaps it isn't there for other profiles? |
116,905 | <p>I would like to use my laptop as a web development (PHP, Python, etc.) machine, but I'm hesitant to do this unless I can ensure that it can not be accessed by the outside world.</p>
<p>I'm guessing that something more than a firewall is necessary, such as configurations to the Apache configuration files, but I'm no... | [
{
"answer_id": 116920,
"author": "Steve Moyer",
"author_id": 17008,
"author_profile": "https://Stackoverflow.com/users/17008",
"pm_score": 3,
"selected": true,
"text": "<p>You need to configure the server daemon to only bind to localhost using the Listen directive like this:</p>\n\n<pre>... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] | I would like to use my laptop as a web development (PHP, Python, etc.) machine, but I'm hesitant to do this unless I can ensure that it can not be accessed by the outside world.
I'm guessing that something more than a firewall is necessary, such as configurations to the Apache configuration files, but I'm not sure wha... | You need to configure the server daemon to only bind to localhost using the Listen directive like this:
```
Listen 127.0.0.1
```
An alternative is to configure access control for the main server like this
```
<Directory "/var/www/localhost/htdocs">
AllowOverride None
Deny from all
Allow from 127.0.0.1/255.0.0.0
</D... |
116,951 | <p>I wanted to use <code>fstream</code> to read a txt file.</p>
<p>I am using <code>inFile >> characterToConvert</code>, but the problem is that this omits any spaces and newline.</p>
<p>I am writing an encryption program so I need to include the spaces and newlines.</p>
<p>What would be the proper way to go a... | [
{
"answer_id": 116980,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 2,
"selected": false,
"text": "<p>The following c++ code will read an entire file...</p>\n\n<pre>\n<code>\n#include <iostream>\n#include <fstream&... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I wanted to use `fstream` to read a txt file.
I am using `inFile >> characterToConvert`, but the problem is that this omits any spaces and newline.
I am writing an encryption program so I need to include the spaces and newlines.
What would be the proper way to go about accomplishing this? | Probably the best way is to read the entire file's contents into a string, which can be done very easily using ifstream's [`rdbuf()`](http://en.cppreference.com/w/cpp/io/basic_ios/rdbuf) method:
```
std::ifstream in("myfile");
std::stringstream buffer;
buffer << in.rdbuf();
std::string contents(buffer.str());
```
... |
116,967 | <p>Is it possible to call a JavaScript function from the IMG SRC tag to get an image url?</p>
<p>Like this:</p>
<pre><code><IMG SRC="GetImage()" />
<script language="javascript">
function GetImage() {return "imageName/imagePath.jpg"}
</script>
</code></pre>
<p>This is using .NET 2.0.</p>
| [
{
"answer_id": 116979,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": -1,
"selected": false,
"text": "<p>No. The Img's SRC attribute is not an event, therefore the inline JS will never fire.</p>\n"
},
{
"ans... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20682/"
] | Is it possible to call a JavaScript function from the IMG SRC tag to get an image url?
Like this:
```
<IMG SRC="GetImage()" />
<script language="javascript">
function GetImage() {return "imageName/imagePath.jpg"}
</script>
```
This is using .NET 2.0. | Nope. It's not possible, at least not in all browsers. You can do something like this instead:
```
<img src="blank.png" id="image" alt="just nothing">
<script type="text/javascript">
document.getElementById('image').src = "yourpicture.png";
</script>
```
Your favourite JavaScript framework will provide nicer way... |
116,968 | <p>I have a database full of customer data. It's so big that it's really cumbersome to operate on, and I'd rather just slim it down to 10% of the customers, which is plenty for development. I have an awful lot of tables and I don't want to alter them all with "ON DELETE CASCADE", especially because this is a one-time... | [
{
"answer_id": 117044,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 2,
"selected": false,
"text": "<p>I usually just hand write the queries to delete the records I don't want and save that as a .sql file for future reference.... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10906/"
] | I have a database full of customer data. It's so big that it's really cumbersome to operate on, and I'd rather just slim it down to 10% of the customers, which is plenty for development. I have an awful lot of tables and I don't want to alter them all with "ON DELETE CASCADE", especially because this is a one-time deal... | Combining your advice and a script I found online, I made a procedure that will produce SQL you can run to perform a cascaded delete regardless of `ON DELETE CASCADE`. It was probably a big waste of time, but I had a good time writing it. An advantage of doing it this way is, you can put a `GO` statement between each l... |
117,006 | <p>In git, it is up to each user to specify the correct author in their local git config file. When they push to a centralized bare repository, the commit messages on the repository will have the author names that they used when committing to their own repository.</p>
<p>Is there a way enforce that a set of known aut... | [
{
"answer_id": 117026,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 0,
"selected": false,
"text": "<p>What you could do is create a bunch of different user accounts, put them all in the same group and give that gro... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | In git, it is up to each user to specify the correct author in their local git config file. When they push to a centralized bare repository, the commit messages on the repository will have the author names that they used when committing to their own repository.
Is there a way enforce that a set of known authors for co... | We use the following to prevent accidental unknown-author commits (for example when doing a fast commit from a customer's server or something). It should be placed in .git/hooks/pre-receive and made executable.
```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
from itertools import islice, izip
impor... |
117,007 | <p>I have some WCF methods that are used to transmit information from a server application to a website frontend for use in binding. I'm sending the result as an XElement that is a root of an XML tree containing the data I want to bind against.</p>
<p>I'd like to create some tests that examine the data and ensure it ... | [
{
"answer_id": 117217,
"author": "user19264",
"author_id": 19264,
"author_profile": "https://Stackoverflow.com/users/19264",
"pm_score": 5,
"selected": true,
"text": "<p>Id say validating xml with a xsd schema is a good idea.<br/>\n<br/>\nHow to validate a XElement with the loaded schema... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have some WCF methods that are used to transmit information from a server application to a website frontend for use in binding. I'm sending the result as an XElement that is a root of an XML tree containing the data I want to bind against.
I'd like to create some tests that examine the data and ensure it comes acros... | Id say validating xml with a xsd schema is a good idea.
How to validate a XElement with the loaded schema:
As you see in this example you need to validate the XDocument first to get populate the "post-schema-validation infoset" (There might be a solution to do this without using the Validate method on the XDOcument ... |
117,014 | <p>How can I retrieve the name of the currently logged in user, using a python script? The function should work regardless of whether it is a domain/ad user or a local user.</p>
| [
{
"answer_id": 117047,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>import os;\nprint os.environ.get( \"USERNAME\" )\n</code></pre>\n\n<p>That should do the job.</... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I retrieve the name of the currently logged in user, using a python script? The function should work regardless of whether it is a domain/ad user or a local user. | Try this:
```
import os;
print os.environ.get( "USERNAME" )
```
That should do the job. |
117,127 | <p>Please excuse the vague title. If anyone has a suggestion, please let me know! Also please retag with more appropriate tags!</p>
<p><strong>The Problem</strong></p>
<p>I want to have an instance of an imported class be able to view things in the scope (globals, locals) of the importer. Since I'm not sure of the... | [
{
"answer_id": 117174,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 1,
"selected": false,
"text": "<p>Functions are always executed in the scope they are defined in, as are methods and class bodies. They are never ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15842/"
] | Please excuse the vague title. If anyone has a suggestion, please let me know! Also please retag with more appropriate tags!
**The Problem**
I want to have an instance of an imported class be able to view things in the scope (globals, locals) of the importer. Since I'm not sure of the exact mechanism at work here, I ... | In this example, you can simply hand over functions as objects to the methods in `C1`:
```
>>> class C1(object):
>>> def eval(self, x):
>>> x()
>>>
>>> def f2(): print "go f2"
>>> c = C1()
>>> c.eval(f2)
go f2
```
In Python, you can pass functions and classes to other methods and invoke/create them there.
... |
117,135 | <p>What resources have to be manually cleaned up in <em>C#</em> and what are the consequences of not doing so?</p>
<p>For example, say I have the following code:</p>
<pre><code>myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
// Use Brush
</code></pre>
<p>If I don't clean up the brush using the d... | [
{
"answer_id": 117164,
"author": "Orion Adrian",
"author_id": 7756,
"author_profile": "https://Stackoverflow.com/users/7756",
"pm_score": 3,
"selected": false,
"text": "<ul>\n<li>Handles to internal windows data structures.</li>\n<li>Database connections.</li>\n<li>File handles.</li>\n<l... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13227/"
] | What resources have to be manually cleaned up in *C#* and what are the consequences of not doing so?
For example, say I have the following code:
```
myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
// Use Brush
```
If I don't clean up the brush using the dispose method, I'm assuming the garbage ... | Technically anything that inherits from IDisposable should be proactively disposed. You can use the 'using' statement to make things easier.
<http://msdn.microsoft.com/en-us/library/yh598w02.aspx>
Sometimes you will see inconsistent use of IDisposable derived objects in documentation sample code as well as code that ... |
117,150 | <p>I love vim and the speed it gives me. But sometimes, my fingers are too speedy and I find myself typing <code>:WQ</code> instead of <code>:wq</code>. (On a German keyboard, you have to press <kbd>Shift</kbd> to get the colon <code>:</code>.) Vim will then complain that <code>WQ</code> is <code>Not an editor command<... | [
{
"answer_id": 117221,
"author": "WMR",
"author_id": 2844,
"author_profile": "https://Stackoverflow.com/users/2844",
"pm_score": 7,
"selected": true,
"text": "<p>Try </p>\n\n<pre><code> :command WQ wq\n :command Wq wq\n :command W w\n :command Q q\n</code></pre>\n\n<p>This way you can de... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7498/"
] | I love vim and the speed it gives me. But sometimes, my fingers are too speedy and I find myself typing `:WQ` instead of `:wq`. (On a German keyboard, you have to press `Shift` to get the colon `:`.) Vim will then complain that `WQ` is `Not an editor command`.
Is there some way to make `W` and `Q` editor commands? | Try
```
:command WQ wq
:command Wq wq
:command W w
:command Q q
```
This way you can define your own commands. See `:help command` for more information. |
117,173 | <p><strong>I do not currently have this issue</strong>, but you never know, and thought experiments are always fun.</p>
<p><strong>Ignoring the obvious problems that you would have to have with your architecture to even be attempting this</strong>, let's assume that you had some horribly-written code of someone else's... | [
{
"answer_id": 117202,
"author": "Orion Adrian",
"author_id": 7756,
"author_profile": "https://Stackoverflow.com/users/7756",
"pm_score": 3,
"selected": false,
"text": "<p><code>On Error Resume Next</code> is a really bad idea in the C# world. Nor would adding the equivalent to <code>On ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | **I do not currently have this issue**, but you never know, and thought experiments are always fun.
**Ignoring the obvious problems that you would have to have with your architecture to even be attempting this**, let's assume that you had some horribly-written code of someone else's design, and you needed to do a bunc... | It's pretty obvious that you'd write the code in VB.NET, which actually does have [On Error Resume Next](http://msdn.microsoft.com/en-us/library/5hsw66as.aspx), and export it in a DLL to C#. Anything else is just being a glutton
for punishment. |
117,189 | <p>I have a search form with a query builder. The builder is activated by a button. Something like this</p>
<pre><code><h:form id="search_form">
<h:outputLabel for="expression" value="Expression"/>
<h:inputText id="expression" required="true" value="#{searcher.expression}"/>
<button onclick=... | [
{
"answer_id": 117246,
"author": "noah",
"author_id": 12034,
"author_profile": "https://Stackoverflow.com/users/12034",
"pm_score": 3,
"selected": true,
"text": "<p>A button in an HTML form is assumed to be used to submit the form. Change button to input type=\"button\" and that should f... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4893/"
] | I have a search form with a query builder. The builder is activated by a button. Something like this
```
<h:form id="search_form">
<h:outputLabel for="expression" value="Expression"/>
<h:inputText id="expression" required="true" value="#{searcher.expression}"/>
<button onclick="openBuilder(); return false;">Open... | A button in an HTML form is assumed to be used to submit the form. Change button to input type="button" and that should fix it.
Alternatively, add type="button" to the button element. |
117,211 | <p>I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update?</p>
<p>Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. Let's say the combo box text fi... | [
{
"answer_id": 117384,
"author": "Moe",
"author_id": 3051,
"author_profile": "https://Stackoverflow.com/users/3051",
"pm_score": 4,
"selected": true,
"text": "<p>woo!\nsolved it on my own.</p>\n\n<p>Use </p>\n\n<pre><code>self.combo['selection']\n</code></pre>\n\n<p>instead of</p>\n\n<pr... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3051/"
] | I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update?
Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. Let's say the combo box text field curren... | woo!
solved it on my own.
Use
```
self.combo['selection']
```
instead of
```
self.combo['value']
``` |
117,226 | <p>I have a <code>PHP</code> script that listens on a queue. Theoretically, it's never supposed to die. Is there something to check if it's still running? Something like <code>Ruby's God ( http://god.rubyforge.org/ )</code> for <code>PHP</code>?</p>
<p>God is language agnostic but it would be nice to have a solution t... | [
{
"answer_id": 117287,
"author": "Mez",
"author_id": 20010,
"author_profile": "https://Stackoverflow.com/users/20010",
"pm_score": 2,
"selected": false,
"text": "<p>Simple bash script</p>\n\n<pre><code>#!/bin/bash\nwhile [true]; do\n if ! pidof -x script.php;\n then\n php sc... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a `PHP` script that listens on a queue. Theoretically, it's never supposed to die. Is there something to check if it's still running? Something like `Ruby's God ( http://god.rubyforge.org/ )` for `PHP`?
God is language agnostic but it would be nice to have a solution that works on windows as well. | I had the same issue - wanting to check if a script is running. So I came up with this and I run it as a cron job. It grabs the running processes as an array and cycles though each line and checks for the file name. Seems to work fine. Replace #user# with your script user.
```
exec("ps -U #user# -u #user# u", $output,... |
117,248 | <p>I have a number of tables that use the trigger/sequence column to simulate auto_increment on their primary keys which has worked great for some time.</p>
<p>In order to speed the time necessary to perform regression testing against software that uses the db, I create control files using some sample data, and added ... | [
{
"answer_id": 117295,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 0,
"selected": false,
"text": "<p>As part of your schema rebuild, why not drop and recreate the sequence? </p>\n"
},
{
"answer_id": 117360,
"auth... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9940/"
] | I have a number of tables that use the trigger/sequence column to simulate auto\_increment on their primary keys which has worked great for some time.
In order to speed the time necessary to perform regression testing against software that uses the db, I create control files using some sample data, and added running o... | You can generate a script to create the sequences with the start values you need (based on their existing values)....
```
SELECT 'CREATE SEQUENCE '||sequence_name||' START WITH '||last_number||';'
FROM ALL_SEQUENCES
WHERE OWNER = your_schema
```
(If I understand the question correctly) |
117,250 | <p>For example, the standard division symbol '/' rounds to zero:</p>
<pre><code>>>> 4 / 100
0
</code></pre>
<p>However, I want it to return 0.04. What do I use?</p>
| [
{
"answer_id": 117256,
"author": "Martin Cote",
"author_id": 9936,
"author_profile": "https://Stackoverflow.com/users/9936",
"pm_score": 0,
"selected": false,
"text": "<p>Try 4.0/100</p>\n"
},
{
"answer_id": 117257,
"author": "torial",
"author_id": 13990,
"author_prof... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | For example, the standard division symbol '/' rounds to zero:
```
>>> 4 / 100
0
```
However, I want it to return 0.04. What do I use? | There are three options:
```
>>> 4 / float(100)
0.04
>>> 4 / 100.0
0.04
```
which is the same behavior as the C, C++, Java etc, or
```
>>> from __future__ import division
>>> 4 / 100
0.04
```
You can also activate this behavior by passing the argument `-Qnew` to the Python interpreter:
```
$ python -Qnew
>>> 4 ... |
117,293 | <p>How far do you go with <code>const</code>? Do you just make functions <code>const</code> when necessary or do you go the whole hog and use it everywhere? For example, imagine a simple mutator that takes a single boolean parameter:</p>
<pre><code>void SetValue(const bool b) { my_val_ = b; }
</code></pre>
<p>Is th... | [
{
"answer_id": 117308,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 9,
"selected": true,
"text": "<p>The reason is that <code>const</code> for the parameter only applies locally within the function, since it is working ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | How far do you go with `const`? Do you just make functions `const` when necessary or do you go the whole hog and use it everywhere? For example, imagine a simple mutator that takes a single boolean parameter:
```
void SetValue(const bool b) { my_val_ = b; }
```
Is that `const` actually useful? Personally I opt to us... | The reason is that `const` for the parameter only applies locally within the function, since it is working on a copy of the data. This means the function signature is really the same anyways. It's probably bad style to do this a lot though.
I personally tend to not use `const` except for reference and pointer paramete... |
117,312 | <p>I work with a bunch of sets in order to generate constrained random traffic, but I want to be able to call a Specman macro that computes the complement of a set with syntax like:</p>
<pre><code>COMPLEMENT begin
domain=[0..10,24..30],
complementing_set=[2..3,27..30]
end
</code></pre>
<p>and have it generate... | [
{
"answer_id": 146590,
"author": "Nathan Fellman",
"author_id": 1084,
"author_profile": "https://Stackoverflow.com/users/1084",
"pm_score": 2,
"selected": false,
"text": "<p>You can try this:</p>\n\n<pre><code>var domain: list of int = {0..10, 24..30}; \nvar complementing_set: list of in... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20712/"
] | I work with a bunch of sets in order to generate constrained random traffic, but I want to be able to call a Specman macro that computes the complement of a set with syntax like:
```
COMPLEMENT begin
domain=[0..10,24..30],
complementing_set=[2..3,27..30]
end
```
and have it generate:
```
[0..1,4..10,24..26]... | You can try this:
```
var domain: list of int = {0..10, 24..30};
var complementing_set: list of int = {2..3, 27..30};
var complement: list of int = domain.all(it in complementing set);
```
The `all` pseudo-method generates a sublist of the parent list of all the elements in the parent list for which the condition i... |
117,318 | <p>Consider this code...</p>
<pre><code>using System.Threading;
//...
Timer someWork = new Timer(
delegate(object state) {
//Do some work here...
},
null, 0, 60000);
HttpContext.Current.Application["SomeWorkItem"] = someWork;
</code></pre>
<p>Could this be dangerous? Caching a timer in the Applic... | [
{
"answer_id": 117342,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 2,
"selected": false,
"text": "<p>The problem with this is that you are not guaranteed the process still being alive. IIS will reclaim the process... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17091/"
] | Consider this code...
```
using System.Threading;
//...
Timer someWork = new Timer(
delegate(object state) {
//Do some work here...
},
null, 0, 60000);
HttpContext.Current.Application["SomeWorkItem"] = someWork;
```
Could this be dangerous? Caching a timer in the Application to perform some work... | This would generally be a bad idea, as System.Threading.Timer uses threads from the ThreadPool, the same as ASP.Net.
If for what ever reason your timer delegate blocks or stops, the timer will simply begin a new Thread after the timeout period, which eats in to the Threads available for ASP.net.
If they all begin blo... |
117,337 | <p>Let's assume that some developer in my team shelved his changes that he did in branch A. And I am working on branch B. Can I unshelve his changes into branch B? (By GUI or command prompt) </p>
| [
{
"answer_id": 117371,
"author": "Herms",
"author_id": 1409,
"author_profile": "https://Stackoverflow.com/users/1409",
"pm_score": 1,
"selected": false,
"text": "<p>The shelf information includes the specific path it goes to. Unfortunately I don't know of any automatic way to unshelve t... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11374/"
] | Let's assume that some developer in my team shelved his changes that he did in branch A. And I am working on branch B. Can I unshelve his changes into branch B? (By GUI or command prompt) | The [Visual Studio Power Tools](http://msdn.microsoft.com/en-us/vstudio/bb980963.aspx) should let you do this.
```
C:\src\2\Merlin\Main>tfpt unshelve /?
tfpt unshelve - Unshelve into workspace with pending changes
Allows a shelveset to be unshelved into a workspace with pending changes.
Merges content between local a... |
117,346 | <p>I'm working on a C++ application that needs detailed timing information, down to the millisecond level. </p>
<p>We intend to gather the time to second accuracy using the standard <code>time()</code> function in <code><ctime></code>. We would like to additionally gather the milliseconds elapsed since the las... | [
{
"answer_id": 117359,
"author": "neuroguy123",
"author_id": 12529,
"author_profile": "https://Stackoverflow.com/users/12529",
"pm_score": -1,
"selected": false,
"text": "<p>Look into the QueryPerformanceCounter methods if this is for Windows.</p>\n"
},
{
"answer_id": 117369,
... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20716/"
] | I'm working on a C++ application that needs detailed timing information, down to the millisecond level.
We intend to gather the time to second accuracy using the standard `time()` function in `<ctime>`. We would like to additionally gather the milliseconds elapsed since the last second given by `time()`.
Does anyon... | Boost.DateTime has millisecond and nanosecond representations **IF** the underlying platform supports them. While it is using platform specific code, it is keeping those details out of your code.
If that is a big deal, they do have another way of doing platform independent subsecond resolution. [This page](http://www... |
117,348 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/506368/how-do-i-serialize-an-enum-value-as-an-int">How do I serialize an enum value as an int?</a> </p>
</blockquote>
<p>Hi, all!</p>
<p>I'm wondering if there's a way to force the serialization of an enum val... | [
{
"answer_id": 117374,
"author": "Matt Howells",
"author_id": 16881,
"author_profile": "https://Stackoverflow.com/users/16881",
"pm_score": 4,
"selected": true,
"text": "<p>Enums do serialize to ints. But generally, if you don't like the way one of your properties gets serialized to XML,... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3403/"
] | >
> **Possible Duplicate:**
>
> [How do I serialize an enum value as an int?](https://stackoverflow.com/questions/506368/how-do-i-serialize-an-enum-value-as-an-int)
>
>
>
Hi, all!
I'm wondering if there's a way to force the serialization of an enum value into its integer value, instead of its string represent... | Enums do serialize to ints. But generally, if you don't like the way one of your properties gets serialized to XML, you can just do this:
```
[XmlIgnore]
public MyThing MyThing { get; set; }
[XmlElement("MyThing")]
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public string MyThingForSerialization
{... |
117,352 | <p>I have this C-code to do multiplications over GF(8):</p>
<pre><code>int32_t GaloisMultiply (int32_t a, int32_t b)
{
int32_t i;
int32_t mask = 0x100;
int32_t y = 0;
for(i=0;i<8;i++)
{
if(b & mask)
{
y ^= a;
}
mask >>= 1;
y <&... | [
{
"answer_id": 117388,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 0,
"selected": false,
"text": "<p>You could probably write some assembly to do a slightly better job. However, I'd be pretty surprised if this was... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15955/"
] | I have this C-code to do multiplications over GF(8):
```
int32_t GaloisMultiply (int32_t a, int32_t b)
{
int32_t i;
int32_t mask = 0x100;
int32_t y = 0;
for(i=0;i<8;i++)
{
if(b & mask)
{
y ^= a;
}
mask >>= 1;
y <<= 1;
}
if(b & 0x1)
... | Table-based? [link](http://www.samiam.org/galois.html)
And when you are limited to x\*x, it's a sparse matrix.
Here's another [good paper (and a library)](http://www.cs.utk.edu/~plank/plank/papers/CS-07-593/) |
117,355 | <p>I'm trying to find the most reusable, yet elegant, piece of code possible for determining if an IEnumerable. In the ideal, this should be a function I can call absolutely any time I need to tell if an IEnumerable is empty.</p>
<p>While I have developed an answer for .NET 3.5 that has worked well for me so far, my ... | [
{
"answer_id": 117367,
"author": "Guvante",
"author_id": 16800,
"author_profile": "https://Stackoverflow.com/users/16800",
"pm_score": 6,
"selected": true,
"text": "<pre><code>!enumerable.Any()\n</code></pre>\n\n<p>Will attempt to grab the first element only.</p>\n\n<p>To expand on how/w... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2729/"
] | I'm trying to find the most reusable, yet elegant, piece of code possible for determining if an IEnumerable. In the ideal, this should be a function I can call absolutely any time I need to tell if an IEnumerable is empty.
While I have developed an answer for .NET 3.5 that has worked well for me so far, my current tho... | ```
!enumerable.Any()
```
Will attempt to grab the first element only.
To expand on how/why this works, any determines if any of the components of an `IEnumerable` match a given function, if none is given, then any component will succeed, meaning the function will return true if an element exists in the enumerable. |
117,356 | <p>I've currently got multiple select's on a page that are added dynamically with <code>ajax</code> calls using jquery.</p>
<p>The problem I've had is I could not get the change event to work on the added select unless I use the <code>onchange</code> inside the tag e.g. </p>
<pre><code><select id="Size" size="1" o... | [
{
"answer_id": 117392,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 3,
"selected": false,
"text": "<blockquote>\n <p>$('select').change(onChange($(this));</p>\n</blockquote>\n\n<p>You need to understand the difference between ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've currently got multiple select's on a page that are added dynamically with `ajax` calls using jquery.
The problem I've had is I could not get the change event to work on the added select unless I use the `onchange` inside the tag e.g.
```
<select id="Size" size="1" onchange="onChange(this);">
```
This works, b... | I had a similar problem and found this solution [here](http://groups.google.com/group/jquery-en/browse_thread/thread/9b79d65b47952583?pli=1):
>
> When you do something like this:
>
>
>
> ```
> $('p').click( function() { alert('blah'); } )
>
> ```
>
> All the *currently existing* 'p'
> elements will have a cli... |
117,361 | <p>I am trying to bind an event to a "method" of a particular instance of a Javascript "class" using jQuery. The requirement is that I in the event handler should be able to use the "this" keyword to refer to the instance I originally bound the event to.</p>
<p>In more detail, say I have a "class" as follows:</p>
<pr... | [
{
"answer_id": 117456,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 3,
"selected": true,
"text": "<p>Just use an anonymous function:</p>\n\n<pre><code>$(\"#myButton\").click(function() { myCar.drive(); });\n</code></pre>\n"
}... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2105/"
] | I am trying to bind an event to a "method" of a particular instance of a Javascript "class" using jQuery. The requirement is that I in the event handler should be able to use the "this" keyword to refer to the instance I originally bound the event to.
In more detail, say I have a "class" as follows:
```
function Car(... | Just use an anonymous function:
```
$("#myButton").click(function() { myCar.drive(); });
``` |
117,372 | <p>I have an script that receives an encrypted url and from that generates a download, the most critic par of the script is this:</p>
<pre><code>$MimeType = new MimeType();
$mimetype = $MimeType->getType($filename);
$basename = basename($filename);
header("Content-type: $mimetype");
header("Content-Disposition: att... | [
{
"answer_id": 117428,
"author": "Grant Wagner",
"author_id": 9254,
"author_profile": "https://Stackoverflow.com/users/9254",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://bytes.com/forum/thread554529.html\" rel=\"nofollow noreferrer\">This site</a> has a problem similar ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7946/"
] | I have an script that receives an encrypted url and from that generates a download, the most critic par of the script is this:
```
$MimeType = new MimeType();
$mimetype = $MimeType->getType($filename);
$basename = basename($filename);
header("Content-type: $mimetype");
header("Content-Disposition: attachment; filename... | [This site](http://bytes.com/forum/thread554529.html) has a problem similar to yours in IE6. To summarize:
>
> session\_start() by default sends a cache control header including "no-store".
> Internet Explorer takes this a bit too literally, but doesn't have appropriate
> error handling for the case, and as a resul... |
117,378 | <p><strong>The situation</strong><br>
I have a Git repo and an SVN repo that both hold the same source code but different commit histories. The Git repo has a lot of small well commented submits... while the SVN repo has a few huge commits with comments like "Lots of stuff".
Both series of commits follow the same chang... | [
{
"answer_id": 117593,
"author": "davetron5000",
"author_id": 3029,
"author_profile": "https://Stackoverflow.com/users/3029",
"pm_score": 2,
"selected": false,
"text": "<p>That could be tough to do what you want. You can import a git repo into svn via something like this: <a href=\"http... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | **The situation**
I have a Git repo and an SVN repo that both hold the same source code but different commit histories. The Git repo has a lot of small well commented submits... while the SVN repo has a few huge commits with comments like "Lots of stuff".
Both series of commits follow the same changes made in the co... | That could be tough to do what you want. You can import a git repo into svn via something like this: <http://code.google.com/p/support/wiki/ImportingFromGit>, but I think you will have conflicts. You could just recreate your SVN repo from scratch based on your git repo.
For future reference, it probably would've been ... |
117,379 | <p>I'm successfully using VBScript within WScript to remotely read and write IIS configurations from the server. When I attempt to run these same scripts from my desk box they fail, though. Example:</p>
<pre><code>Dim vdir
Set vdir = GetObject("IIS://servername/w3svc/226/root")
</code></pre>
<p>Error = "Invalid synta... | [
{
"answer_id": 117593,
"author": "davetron5000",
"author_id": 3029,
"author_profile": "https://Stackoverflow.com/users/3029",
"pm_score": 2,
"selected": false,
"text": "<p>That could be tough to do what you want. You can import a git repo into svn via something like this: <a href=\"http... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14127/"
] | I'm successfully using VBScript within WScript to remotely read and write IIS configurations from the server. When I attempt to run these same scripts from my desk box they fail, though. Example:
```
Dim vdir
Set vdir = GetObject("IIS://servername/w3svc/226/root")
```
Error = "Invalid syntax"
The code works perfect... | That could be tough to do what you want. You can import a git repo into svn via something like this: <http://code.google.com/p/support/wiki/ImportingFromGit>, but I think you will have conflicts. You could just recreate your SVN repo from scratch based on your git repo.
For future reference, it probably would've been ... |
117,401 | <h2>experimenting with Cockburn use cases in code</h2>
<p>I was writing some complicated UI code. I decided to employ Cockburn use cases with fish,kite,and sea levels (discussed by Martin Fowler in his book 'UML Distilled'). I wrapped Cockburn use cases in static C# objects so that I could test logical conditions a... | [
{
"answer_id": 120551,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 1,
"selected": false,
"text": "<p>I think this is a variation on the Mediator Pattern from <em>Design Patterns</em> (Gang of Four) -- so I would say tha... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20714/"
] | experimenting with Cockburn use cases in code
---------------------------------------------
I was writing some complicated UI code. I decided to employ Cockburn use cases with fish,kite,and sea levels (discussed by Martin Fowler in his book 'UML Distilled'). I wrapped Cockburn use cases in static C# objects so that I ... | I've never done it, but I've often thought about writing code in UC style, with main success path first and extensions put in as exceptions caught down below. Have not found the excuse to do it - would love to see someone try it and code, even if after the experiment we conclude it's awful, it will still be interesting... |
117,407 | <ul>
<li>You can use App.config; but it only supports key/value pairs.</li>
<li>You can use .Net configuration, configuration sections; but it can be really complex.</li>
<li>You can use Xml Serialization/Deserialization by yourself; your classes-your way.</li>
<li>You can use some other method; what can they be? ...</... | [
{
"answer_id": 117417,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 4,
"selected": false,
"text": "<p>If I can get away with it I will just use the App.Config, however, if I need something more complex I will use ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11374/"
] | * You can use App.config; but it only supports key/value pairs.
* You can use .Net configuration, configuration sections; but it can be really complex.
* You can use Xml Serialization/Deserialization by yourself; your classes-your way.
* You can use some other method; what can they be? ...
Which of these or other meth... | When key value pairs are not enough I use Configuration Sections as they are not complex to use (unless you need a complex section):
Define your custom section:
```
public class CustomSection : ConfigurationSection
{
[ConfigurationProperty("LastName", IsRequired = true,
Default... |
117,415 | <p>The subversion concept of branching appears to be focused on creating an [un]stable fork of the entire repository on which to do development. Is there a mechanism for creating branches of individual files?</p>
<p>For a use case, think of a common header (*.h) file that has multiple platform-specific source (*.c) im... | [
{
"answer_id": 117442,
"author": "Matt",
"author_id": 2338,
"author_profile": "https://Stackoverflow.com/users/2338",
"pm_score": 1,
"selected": false,
"text": "<p>A Subversion \"branch\" is just a copy of something in your repository. So if you wanted to branch a file you'd just do:</p... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8233/"
] | The subversion concept of branching appears to be focused on creating an [un]stable fork of the entire repository on which to do development. Is there a mechanism for creating branches of individual files?
For a use case, think of a common header (\*.h) file that has multiple platform-specific source (\*.c) implementa... | Sadly, I think the real answer here is that ClearCase handles this situation a lot better than Subversion. With subversion, you have to branch *everything*, but ClearCase allows a kind of "lazy branch" idea that means only a certain group of files are branched, the rest of them still follow the trunk (or whichever bran... |
117,461 | <p>I want alwaysPositive to be assigned a positive number with all possible values for lareValue1 and largeValue2 (these are at least 1).</p>
<p>The following statement causes a buffer overflow:</p>
<pre><code>int alwaysPositive = (largeValue1 + largeValue2) / 2;
</code></pre>
<p>I know I can prevent it by substract... | [
{
"answer_id": 117519,
"author": "Khoth",
"author_id": 20686,
"author_profile": "https://Stackoverflow.com/users/20686",
"pm_score": 0,
"selected": false,
"text": "<p>You could use uints:</p>\n\n<pre><code>uint alwaysPositive = (uint)(largeValue1 + largeValue2) / 2;\n</code></pre>\n"
}... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13376/"
] | I want alwaysPositive to be assigned a positive number with all possible values for lareValue1 and largeValue2 (these are at least 1).
The following statement causes a buffer overflow:
```
int alwaysPositive = (largeValue1 + largeValue2) / 2;
```
I know I can prevent it by substracting and adding:
```
int alwaysPo... | You can do it this way:
```
x = largeValue1;
y = largeValue2;
return (x&y)+((x^y)/2);
```
That's a bit-twiddling way to get the average of two integers without overflow.
If you want you can replace the division by two with a bit-shift, but the compiler will do that for you anyways. |
117,471 | <p>I have a database issue that i currently cannot wrap my head around with an easy solution. In my db I have a table that stores event values.. 0's and 1's with a timestamp. Issue being that it is possible for there to be the same event to occur twice as a business rule. Like below</p>
<ul>
<li>'2008-09-22 16:28:14.1... | [
{
"answer_id": 117575,
"author": "tyshock",
"author_id": 16448,
"author_profile": "https://Stackoverflow.com/users/16448",
"pm_score": 1,
"selected": false,
"text": "<p>(preface.......i've only done this in oracle, but I'm pretty sure if the db supports triggers it's all possible)</p>\n\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20737/"
] | I have a database issue that i currently cannot wrap my head around with an easy solution. In my db I have a table that stores event values.. 0's and 1's with a timestamp. Issue being that it is possible for there to be the same event to occur twice as a business rule. Like below
* '2008-09-22 16:28:14.133', 0
* '2008... | This uses a SQL Server Common Table Expression, but it can be inlined, with table t with columns dt and cyclestate:
```
;WITH Firsts AS (
SELECT t1.dt
,MIN(t2.dt) AS Prevdt
FROM t AS t1
INNER JOIN t AS t2
ON t1.dt < t2.dt
AND t2.cyclestate <> t1.cyclestate
GROUP BY t1.dt
)
SELEC... |
117,512 | <p>Given a simple (id, description) table t1, such as</p>
<pre><code>id description
-- -----------
1 Alice
2 Bob
3 Carol
4 David
5 Erica
6 Fred
</code></pre>
<p>And a parent-child relationship table t2, such as</p>
<pre><code>parent child
------ -----
1 2
1 3
4 5
5 6
</code></... | [
{
"answer_id": 117578,
"author": "Mike McAllister",
"author_id": 16247,
"author_profile": "https://Stackoverflow.com/users/16247",
"pm_score": 4,
"selected": true,
"text": "<p>In your query, replace T2 with a subquery that joins T1 and T2, and returns parent, child and child description.... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18625/"
] | Given a simple (id, description) table t1, such as
```
id description
-- -----------
1 Alice
2 Bob
3 Carol
4 David
5 Erica
6 Fred
```
And a parent-child relationship table t2, such as
```
parent child
------ -----
1 2
1 3
4 5
5 6
```
Oracle offers a way of traversing this a... | In your query, replace T2 with a subquery that joins T1 and T2, and returns parent, child and child description. Then in the sys\_connect\_by\_path function, reference the child description from your subquery. |
117,514 | <p>How do I properly represent a different timezone in my timezone? The below example only works because I know that EDT is one hour ahead of me, so I can uncomment the subtraction of myTimeZone()</p>
<pre><code>import datetime, re
from datetime import tzinfo
class myTimeZone(tzinfo):
"""docstring for myTimeZone"... | [
{
"answer_id": 117523,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 4,
"selected": false,
"text": "<p>The Python standard library doesn't contain timezone information, because unfortunately timezone data changes a ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9338/"
] | How do I properly represent a different timezone in my timezone? The below example only works because I know that EDT is one hour ahead of me, so I can uncomment the subtraction of myTimeZone()
```
import datetime, re
from datetime import tzinfo
class myTimeZone(tzinfo):
"""docstring for myTimeZone"""
def utf... | I recommend `babel` and `pytz` when working with timezones. Keep your internal datetime objects naive and in UTC and convert to your timezone for formatting only. The reason why you probably want naive objects (objects without timezone information) is that many libraries and database adapters have no idea about timezon... |
117,536 | <p>I've tried restarting apache and the cached pages still appear, so there must be a folder someplace. I don't have a 'public/cache', so what other places should I look? Is there a URL flag that could trigger this effect as well?</p>
| [
{
"answer_id": 117775,
"author": "user19898",
"author_id": 19898,
"author_profile": "https://Stackoverflow.com/users/19898",
"pm_score": 0,
"selected": false,
"text": "<p>First, have you cleared your browsers cache? You can do this through the browser menus, in options somewhere.</p>\n\n... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13320/"
] | I've tried restarting apache and the cached pages still appear, so there must be a folder someplace. I don't have a 'public/cache', so what other places should I look? Is there a URL flag that could trigger this effect as well? | You need to touch a file to have phusion clear out, like:
```
touch /webapps/mycook/tmp/restart.txt
```
See the [docs](http://www.modrails.com/documentation/Users%20guide.html#_redeploying_restarting_the_ruby_on_rails_application) |
117,547 | <p>Documentation can be found <a href="http://github.com/madrobby/scriptaculous/wikis/droppables" rel="nofollow noreferrer">here</a></p>
<p>It says in the example:</p>
<p><strong>onDrop:
Called whenever a Draggable is released over the Droppable and the Droppable is accepts it. The callback gets three parameters: the... | [
{
"answer_id": 117583,
"author": "tags2k",
"author_id": 192,
"author_profile": "https://Stackoverflow.com/users/192",
"pm_score": 3,
"selected": true,
"text": "<p>Going by the example further down the page, the callback function can take as many of the parameters as you need:</p>\n\n<pre... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Documentation can be found [here](http://github.com/madrobby/scriptaculous/wikis/droppables)
It says in the example:
**onDrop:
Called whenever a Draggable is released over the Droppable and the Droppable is accepts it. The callback gets three parameters: the Draggable element, the Droppable element and the Event. You... | Going by the example further down the page, the callback function can take as many of the parameters as you need:
```
onDrop: function() { $('droppable_demo').highlight(); }
```
In this case, they have used none of the callback parameters. To this end, presumably to access all three as mentioned in the paragraph you... |
117,570 | <p>On our web application, the search results are displayed in sortable tables. The user can click on any column and sort the result. The problem is some times, the user does a broad search and gets a lot of data returned. To make the sortable part work, you probably need all the results, which takes a long time. O... | [
{
"answer_id": 117586,
"author": "Orion Adrian",
"author_id": 7756,
"author_profile": "https://Stackoverflow.com/users/7756",
"pm_score": 2,
"selected": false,
"text": "<p>You should be doing paging back on the database server. E.g. on SQL 2005 and SQL 2008 there are paging techniques. I... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20460/"
] | On our web application, the search results are displayed in sortable tables. The user can click on any column and sort the result. The problem is some times, the user does a broad search and gets a lot of data returned. To make the sortable part work, you probably need all the results, which takes a long time. Or I can... | Using sorting paging at the database level is the correct answer. If your query returns 1000 rows, but you're only going to show the user 10 of them, there is no need for the other 990 to be sent across the network.
Here is a mysql example. Say you need 10 rows, 21-30, from the 'people' table:
```
SELECT * FROM peo... |
117,623 | <p>Backstory: I'm using <a href="http://logging.apache.org/log4net/index.html" rel="noreferrer">log4net</a> to handle all logging for a project I'm working on. One particular method can be called under several different circumstances -- some that warrant the log messages to be errors and others that warrant the log me... | [
{
"answer_id": 117646,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 0,
"selected": false,
"text": "<pre><code>Public Delegate errorCall(ByVal error As String, Params objs As Objects())\nCheckDifference(10, 0, AddressOf log... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108/"
] | Backstory: I'm using [log4net](http://logging.apache.org/log4net/index.html) to handle all logging for a project I'm working on. One particular method can be called under several different circumstances -- some that warrant the log messages to be errors and others that warrant the log messages to be warnings.
So, as a... | Declare your delegate signature:
```
Public Delegate Sub Format(ByVal value As String)
```
Define your Test function:
```
Public Sub CheckDifference(ByVal A As Integer, _
ByVal B As Integer, _
ByVal format As Format)
If (B - A) > 5 Then
format.Invoke... |
117,665 | <p>I got this bad feeling about how I insert larger amounts of HTML.
Lets assume we got:</p>
<p><code>var html="<table>..<a-lot-of-other-tags />..</table>"</code></p>
<p>and I want to put this into</p>
<p><code>$("#mydiv")</code></p>
<p>previously I did something like</p>
<p><code>var html_obj = ... | [
{
"answer_id": 117700,
"author": "Kev",
"author_id": 16777,
"author_profile": "https://Stackoverflow.com/users/16777",
"pm_score": 1,
"selected": false,
"text": "<p>For starters, write a script that times how long it takes to do it 100 or 1,000 times with each method.</p>\n\n<p>To make s... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20711/"
] | I got this bad feeling about how I insert larger amounts of HTML.
Lets assume we got:
`var html="<table>..<a-lot-of-other-tags />..</table>"`
and I want to put this into
`$("#mydiv")`
previously I did something like
`var html_obj = $(html);`
`$("#mydiv").append(html_obj);`
Is it correct that jQuery is parsing `ht... | innerHTML is remarkably fast, and in many cases you will get the best results just setting that (I would just use append).
**However, if there is much already in "mydiv" then you are forcing the browser to parse and render all of that content again (everything that was there before, plus all of your new content).** Yo... |
117,667 | <p>I know this is probably the dumbest question ever, however I am a total beginner when it comes to CSS; how do you hyperlink an image on a webpage using an image which is sourced from CSS? I am trying to set the title image on my website linkable to the frontpage. Thanks!</p>
<p><strong>Edit:</strong> Just to make i... | [
{
"answer_id": 117675,
"author": "John Rudy",
"author_id": 14048,
"author_profile": "https://Stackoverflow.com/users/14048",
"pm_score": 2,
"selected": false,
"text": "<p>That's really not a CSS thing. You still need your A tag to make that work. (But use CSS to make sure the image borde... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] | I know this is probably the dumbest question ever, however I am a total beginner when it comes to CSS; how do you hyperlink an image on a webpage using an image which is sourced from CSS? I am trying to set the title image on my website linkable to the frontpage. Thanks!
**Edit:** Just to make it clear, I'm sourcing m... | You control design and styles with CSS, not the behavior of your content.
You're going to have to use something like `<a id="header" href="[your link]">Logo</a>` and then have a CSS block such as:
```
a#header {
background-image: url(...);
display: block;
width: ..;
height: ...;
}
```
You cannot nest a `di... |
117,690 | <p>I have few asynchronous tasks running and I need to wait until at least one of them is finished (in the future probably I'll need to wait util M out of N tasks are finished).
Currently they are presented as Future, so I need something like</p>
<pre><code>/**
* Blocks current thread until one of specified futures i... | [
{
"answer_id": 117711,
"author": "jdmichal",
"author_id": 12275,
"author_profile": "https://Stackoverflow.com/users/12275",
"pm_score": 3,
"selected": true,
"text": "<p>As far as I know, Java has no analogous structure to the <code>WaitHandle.WaitAny</code> method.</p>\n\n<p>It seems to ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5507/"
] | I have few asynchronous tasks running and I need to wait until at least one of them is finished (in the future probably I'll need to wait util M out of N tasks are finished).
Currently they are presented as Future, so I need something like
```
/**
* Blocks current thread until one of specified futures is done and ret... | As far as I know, Java has no analogous structure to the `WaitHandle.WaitAny` method.
It seems to me that this could be achieved through a "WaitableFuture" decorator:
```
public WaitableFuture<T>
extends Future<T>
{
private CountDownLatch countDownLatch;
WaitableFuture(CountDownLatch countDownLatch)
... |
117,691 | <p>Given an array of integers, what is the simplest way to iterate over it and figure out all the ranges it covers? for example, for an array such as:</p>
<pre><code>$numbers = array(1,3,4,5,6,8,11,12,14,15,16);
</code></pre>
<p>The ranges would be:</p>
<pre><code> 1,3-6,8,11-12,14-16
</code></pre>
| [
{
"answer_id": 117722,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "<p>Here's a python implementation, it should be easy enough to follow</p>\n\n<pre><code>numbers = [1,3,4,5,6,8,11,12,... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10585/"
] | Given an array of integers, what is the simplest way to iterate over it and figure out all the ranges it covers? for example, for an array such as:
```
$numbers = array(1,3,4,5,6,8,11,12,14,15,16);
```
The ranges would be:
```
1,3-6,8,11-12,14-16
``` | If the array is sorted in ascending order, then the problem is easy. Define a `Range` structure or class, which has a beginning and an end. Then go through the array. If the current element is one more than the previous, update `Range.end`, otherwise create a new range with this element as `Range.begin`. Store the rang... |
117,708 | <p>The non-virtual interface idiom describes how the virtual methods are nonpublic customisation points, and public methods are nonvirtual to allow the base class to control at all times how the customisation points are called. </p>
<p>This is an elegant idiom and I like to use it, but how does it work if the derived ... | [
{
"answer_id": 117744,
"author": "Mike Elkins",
"author_id": 19193,
"author_profile": "https://Stackoverflow.com/users/19193",
"pm_score": 1,
"selected": false,
"text": "<p>The derived class can decide for itself:</p>\n\n<p>You can just override the method completely by implementing the ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19863/"
] | The non-virtual interface idiom describes how the virtual methods are nonpublic customisation points, and public methods are nonvirtual to allow the base class to control at all times how the customisation points are called.
This is an elegant idiom and I like to use it, but how does it work if the derived class is a... | It works, because the derived class can override a private virtual function of a base class, even if the base class function overrides its base class function.
This is perfectly legal:
```
class Parent
{
public:
int foo() {return bar();} // the non-virtual public interface
private
virtual int bar();
};
class Ch... |
117,732 | <p>Take this simple <em>C# LINQ</em> query, and imagine that <code>db.Numbers</code> is an <em>SQL</em> table with one column <code>Number</code>:</p>
<pre><code>var result =
from n in db.Numbers
where n.Number < 5
select n.Number;
</code></pre>
<p>This will run very efficiently in <em>C#</em>... | [
{
"answer_id": 117794,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": false,
"text": "<p>Look closely at <a href=\"http://www.sqlalchemy.org/\" rel=\"nofollow noreferrer\">SQLAlchemy</a>. This can probably do... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42219/"
] | Take this simple *C# LINQ* query, and imagine that `db.Numbers` is an *SQL* table with one column `Number`:
```
var result =
from n in db.Numbers
where n.Number < 5
select n.Number;
```
This will run very efficiently in *C#*, because it generates an *SQL* query something like
```
select Number ... | I believe that when IronPython 2.0 is complete, it will have LINQ support (see [this thread](http://groups.google.com/group/ironpy/browse_thread/thread/eb6b9eb2241cc68e) for some example discussion). Right now you should be able to write something like:
```
Queryable.Select(Queryable.Where(someInputSequence, somePredi... |
117,751 | <p>I have a web application using JPA and JTA with Spring. I would like to support both JBoss and Tomcat. When running on JBoss, I'd like to use JBoss' own TransactionManager, and when running on Tomcat, I'd like to use JOTM.</p>
<p>I have both scenarios working, but I now find that I seem to need two separate Spring ... | [
{
"answer_id": 117871,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 2,
"selected": false,
"text": "<p>You can use PropertyConfigurerPlaceholder to inject bean references as well as simple values.</p>\n\n<p>For example if yo... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7034/"
] | I have a web application using JPA and JTA with Spring. I would like to support both JBoss and Tomcat. When running on JBoss, I'd like to use JBoss' own TransactionManager, and when running on Tomcat, I'd like to use JOTM.
I have both scenarios working, but I now find that I seem to need two separate Spring configurat... | I think you have missed the point of JNDI. JNDI was pretty much written to solve the problem you have!
I think you can take it up a level, so instead of using the "userTransaction" or "transactionManager from JNDI" depending on your situation. Why not add the "JtaTransactionManager" to JNDI. That way you push the conf... |
117,755 | <p>Here's the code I want to speed up. It's getting a value from an ADO recordset and converting it to a char*. But this is slow. Can I skip the creation of the _bstr_t?</p>
<pre><code> _variant_t var = pRs->Fields->GetItem(i)->GetValue();
if (V_VT(&var) == VT_BSTR)
... | [
{
"answer_id": 117780,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 2,
"selected": false,
"text": "<p>This creates a temporary on the stack:</p>\n\n<pre><code>USES_CONVERSION;\nchar *p=W2A(var.bstrVal);\n</code></p... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] | Here's the code I want to speed up. It's getting a value from an ADO recordset and converting it to a char\*. But this is slow. Can I skip the creation of the \_bstr\_t?
```
_variant_t var = pRs->Fields->GetItem(i)->GetValue();
if (V_VT(&var) == VT_BSTR)
{
... | The first 4 bytes of the BSTR contain the length. You can loop through and get every other character if unicode or every character if multibyte. Some sort of memcpy or other method would work too. IIRC, this can be faster than `W2A` or casting `(LPCSTR)(_bstr_t)` |
117,772 | <p>I'm trying to use the page-break-inside CSS directive, the class of which is to be attached to a div tag or a table tag (I think this may only work on block elements, in which case it would have to be the table).</p>
<p>I've tried all the tutorials that supposedly describe exactly how to do this, but nothing works.... | [
{
"answer_id": 117834,
"author": "phloopy",
"author_id": 8507,
"author_profile": "https://Stackoverflow.com/users/8507",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://developer.apple.com/documentation/AppleApplications/Reference/SafariCSSRef/Articles/StandardCSSPropertie... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20762/"
] | I'm trying to use the page-break-inside CSS directive, the class of which is to be attached to a div tag or a table tag (I think this may only work on block elements, in which case it would have to be the table).
I've tried all the tutorials that supposedly describe exactly how to do this, but nothing works. Is this a... | Safari 1.3 and later (don't know about 4) do **not** support page-break-inside (try it, or see here: <http://reference.sitepoint.com/css/page-break-inside>). Neither do Firefox 3 or IE7 (don't know about 8).
In a practical sense, support for this attribute is SO spotty, it doesn't make sense to use it at all at this p... |
117,792 | <p>I'm interested to know the best / common way of storing a <code>this</code> pointer for use in the <code>WndProc</code>. I know of several approaches, but each as I understand it have their own drawbacks. My questions are:</p>
<p>What different ways are there of producing this kind of code:</p>
<pre><code>CWindow:... | [
{
"answer_id": 117828,
"author": "Head Geek",
"author_id": 12193,
"author_profile": "https://Stackoverflow.com/users/12193",
"pm_score": 3,
"selected": false,
"text": "<p>I've used SetProp/GetProp to store a pointer to data with the window itself. I'm not sure how it stacks up to the oth... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] | I'm interested to know the best / common way of storing a `this` pointer for use in the `WndProc`. I know of several approaches, but each as I understand it have their own drawbacks. My questions are:
What different ways are there of producing this kind of code:
```
CWindow::WndProc(UINT msg, WPARAM wParam, LPARAM)
{... | In your constructor, call **CreateWindowEx** with "this" as the lpParam argument.
Then, on WM\_NCCREATE, call the following code:
```
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) ((CREATESTRUCT*)lParam)->lpCreateParams);
SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
```
Then, at the... |
117,844 | <p>I'm trying to convert an incoming sting of 1s and 0s from stdin into their respective binary values (where a string such as "11110111" would be converted to 0xF7). This seems pretty trivial but I don't want to reinvent the wheel so I'm wondering if there's anything in the C/C++ standard libs that can already perform... | [
{
"answer_id": 117862,
"author": "Torlack",
"author_id": 5243,
"author_profile": "https://Stackoverflow.com/users/5243",
"pm_score": 3,
"selected": false,
"text": "<p>You can use strtol</p>\n\n<pre><code>char string[] = \"1101110100110100100000\";\nchar * end;\nlong int value = strtol (s... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1582/"
] | I'm trying to convert an incoming sting of 1s and 0s from stdin into their respective binary values (where a string such as "11110111" would be converted to 0xF7). This seems pretty trivial but I don't want to reinvent the wheel so I'm wondering if there's anything in the C/C++ standard libs that can already perform su... | ```
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char * ptr;
long parsed = strtol("11110111", & ptr, 2);
printf("%lX\n", parsed);
return EXIT_SUCCESS;
}
```
For larger numbers, there as a `long long` version, `strtoll`. |
117,851 | <p>For example if I'm working on Visual Studio 2008, I want the values devenv and 2008 or 9.</p>
<p>The version number is very important...</p>
| [
{
"answer_id": 117971,
"author": "Nescio",
"author_id": 14484,
"author_profile": "https://Stackoverflow.com/users/14484",
"pm_score": 0,
"selected": false,
"text": "<p>This <a href=\"http://www.codeproject.com/KB/cs/windowhider.aspx\" rel=\"nofollow noreferrer\">project</a> demonstrates ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44972/"
] | For example if I'm working on Visual Studio 2008, I want the values devenv and 2008 or 9.
The version number is very important... | This is going to be PInvoke city...
You'll need to PInvoke the following API's in User32.dll
Win32::GetForegroundWindow() in returns the HWND of the currently active window.
```
/// <summary>
/// The GetForegroundWindow function returns a handle to the foreground window.
/// </summary>
[DllImport("user32.dll")]
stat... |
117,900 | <p>I have an application that loads external SWF files and plays them inside a Adobe Flex / Air application via the <a href="http://livedocs.adobe.com/flex/3/html/controls_15.html" rel="nofollow noreferrer">SWFLoader Flex component</a>. I have been trying to find a way to unload them from a button click event. I have G... | [
{
"answer_id": 118026,
"author": "user19264",
"author_id": 19264,
"author_profile": "https://Stackoverflow.com/users/19264",
"pm_score": 1,
"selected": false,
"text": "<p>The problem resides in the loaded swf, it simply does not clean up the audio after itself.\nTry attaching an unload e... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | I have an application that loads external SWF files and plays them inside a Adobe Flex / Air application via the [SWFLoader Flex component](http://livedocs.adobe.com/flex/3/html/controls_15.html). I have been trying to find a way to unload them from a button click event. I have Google'd far and wide and no one seems to... | >
> ... isn't that a problem with the Flex architecture?
>
>
>
Yes it is, and it also affects Flash in general. Until you can take advantage of the [Loader.unloadAndStop()](http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Loader.html) method in FP10 (AIR 1.5), you can't guarantee that externally loaded ... |
117,931 | <p>I'm building a fairly large website and my .htaccess is starting to feel a bit bloated, is there a way of replacing my current system of - one rule for each of the possibile number of vars that could be passed, to one catch all expression that can account for varying numbers of inputs ?</p>
<p>for example I current... | [
{
"answer_id": 117968,
"author": "daniels",
"author_id": 9789,
"author_profile": "https://Stackoverflow.com/users/9789",
"pm_score": 4,
"selected": true,
"text": "<p>Do like Drupal:</p>\n\n<pre><code> RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteR... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2083/"
] | I'm building a fairly large website and my .htaccess is starting to feel a bit bloated, is there a way of replacing my current system of - one rule for each of the possibile number of vars that could be passed, to one catch all expression that can account for varying numbers of inputs ?
for example I currently have:
... | Do like Drupal:
```
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
```
And then handle all the stuff in your script using php code something like this
```
$pathmap = ();
if ($_GET["q"]){
$path = split("/", $_GET["q"]);
for ($i=0; $i+1<... |
117,952 | <p>I have two tables containing Tasks and Notes, and want to retrieve a list of tasks with the number of associated notes for each one. These two queries do the job:</p>
<pre>select t.TaskId,
(select count(n.TaskNoteId) from TaskNote n where n.TaskId = t.TaskId) 'Notes'
from Task t
-- or
select t.TaskId,
... | [
{
"answer_id": 117981,
"author": "Sean Reilly",
"author_id": 8313,
"author_profile": "https://Stackoverflow.com/users/8313",
"pm_score": 0,
"selected": false,
"text": "<p>You can use either, and they are semantically identical. In general, the rule of thumb is to use whichever form is ea... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14072/"
] | I have two tables containing Tasks and Notes, and want to retrieve a list of tasks with the number of associated notes for each one. These two queries do the job:
```
select t.TaskId,
(select count(n.TaskNoteId) from TaskNote n where n.TaskId = t.TaskId) 'Notes'
from Task t
-- or
select t.TaskId,
coun... | On small datasets they are wash when it comes to performance. When indexed, the LOJ is a little better.
I've found on large datasets that an inner join (an inner join will work too.) will outperform the subquery by a very large factor (sorry, no numbers). |
117,962 | <p>I have two tables, both with start time and end time fields. I need to find, for each row in the first table, all of the rows in the second table where the time intervals intersect.</p>
<p>For example:</p>
<pre><code> <-----row 1 interval------->
<---find this--> <--and this--> <--an... | [
{
"answer_id": 117977,
"author": "Khoth",
"author_id": 20686,
"author_profile": "https://Stackoverflow.com/users/20686",
"pm_score": 7,
"selected": true,
"text": "<pre><code>SELECT * \nFROM table1,table2 \nWHERE table2.start <= table1.end \nAND (table2.end IS NULL OR table2.end >= ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9345/"
] | I have two tables, both with start time and end time fields. I need to find, for each row in the first table, all of the rows in the second table where the time intervals intersect.
For example:
```
<-----row 1 interval------->
<---find this--> <--and this--> <--and this-->
```
Please phrase your answer ... | ```
SELECT *
FROM table1,table2
WHERE table2.start <= table1.end
AND (table2.end IS NULL OR table2.end >= table1.start)
``` |
117,986 | <p>I'm searching a wsgi middleware which I can warp around a wsgi applications and which lets me monitor incoming and outgoing http requests and header fields.</p>
<p>Something like firefox live headers, but for the server side.</p>
| [
{
"answer_id": 118037,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 2,
"selected": false,
"text": "<p>That shouldn't be too hard to write yourself as long as you only need the headers. Try that:</p>\n\n<pre><code>... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/720/"
] | I'm searching a wsgi middleware which I can warp around a wsgi applications and which lets me monitor incoming and outgoing http requests and header fields.
Something like firefox live headers, but for the server side. | The middleware
```
from wsgiref.util import request_uri
import sys
def logging_middleware(application, stream=sys.stdout):
def _logger(environ, start_response):
stream.write('REQUEST\n')
stream.write('%s %s\n' %(
environ['REQUEST_METHOD'],
request_uri(environ),
))
... |
118,040 | <p>I had this questions since the time I learnt about object-oriented programming. Now, I have got a wonderful forum I thought of asking this.</p>
<p>Lets say we are implementing an employee management application using EJB.</p>
<p>Now, there are 2 ways of doing this.</p>
<ol>
<li><p>Normally, we create entities (PO... | [
{
"answer_id": 118057,
"author": "Smashery",
"author_id": 14902,
"author_profile": "https://Stackoverflow.com/users/14902",
"pm_score": 2,
"selected": false,
"text": "<p>The first one is certainly clearer, and clarity should certainly be an aim of your code. However, in terms of the firs... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19034/"
] | I had this questions since the time I learnt about object-oriented programming. Now, I have got a wonderful forum I thought of asking this.
Lets say we are implementing an employee management application using EJB.
Now, there are 2 ways of doing this.
1. Normally, we create entities (POJOs) which represent an employ... | The first one is certainly clearer, and clarity should certainly be an aim of your code. However, in terms of the first one, I'll direct you [here](http://www.codinghorror.com/blog/archives/000553.html): Jeff Atwood's take on calling things "SomethingManager" - not recommended. |
118,051 | <p>I have a grid that is binded to a collection. For some reason that I do not know, now when I do some action in the grid, the grid doesn't update.</p>
<p>Situation : When I click a button in the grid, it increase a value that is in the same line. When I click, I can debug and see the value increment but the value do... | [
{
"answer_id": 118121,
"author": "µBio",
"author_id": 9796,
"author_profile": "https://Stackoverflow.com/users/9796",
"pm_score": 0,
"selected": false,
"text": "<p>It sounds like you need to call DataBind in your update code.</p>\n"
},
{
"answer_id": 118156,
"author": "Patric... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] | I have a grid that is binded to a collection. For some reason that I do not know, now when I do some action in the grid, the grid doesn't update.
Situation : When I click a button in the grid, it increase a value that is in the same line. When I click, I can debug and see the value increment but the value doesn't chan... | In order for the binding to be bidirectional, from control to datasource and from datasource to control the datasource must implement property changing notification events, in one of the 2 possible ways:
* Implement the [INotifyPropertyChanged](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.inotify... |
118,091 | <p>I am trying to learn how to use MSBuild so we can use it to build our project. There's what seems to be a very big hole in the documentation, and I find the hole everywhere I look, the hole being how do you name or otherwise designate the MSBuild project file? </p>
<p>For example, the tutorial on MSBuild that can... | [
{
"answer_id": 118118,
"author": "palehorse",
"author_id": 312,
"author_profile": "https://Stackoverflow.com/users/312",
"pm_score": 4,
"selected": true,
"text": "<p>You can name the file as you see fit. From the help for MSBuild</p>\n\n<pre><code>msbuild.exe /?\n\nMicrosoft (R) Build E... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16964/"
] | I am trying to learn how to use MSBuild so we can use it to build our project. There's what seems to be a very big hole in the documentation, and I find the hole everywhere I look, the hole being how do you name or otherwise designate the MSBuild project file?
For example, the tutorial on MSBuild that can be download... | You can name the file as you see fit. From the help for MSBuild
```
msbuild.exe /?
Microsoft (R) Build Engine Version 2.0.50727.3053
[Microsoft .NET Framework, Version 2.0.50727.3053]
Copyright (C) Microsoft Corporation 2005. All rights reserved.
Syntax: MSBuild.exe [options] [project file]
```
So if ... |
118,092 | <p>In PHP, replace one URL with another within a string e.g. </p>
<pre><code>New post on the site <a href="http://stackoverflow.com/xyz1">http://stackoverflow.com/xyz1</a></p>
</code></pre>
<p>becomes:</p>
<pre><code>New post on the site <a href="http://yahoo.com/abc1">http://yahoo.com/abc1&l... | [
{
"answer_id": 118099,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 1,
"selected": false,
"text": "<p>Use <a href=\"http://php.net/str_replace\" rel=\"nofollow noreferrer\">str_replace()</a>:</p>\n\n<pre><code>$text = str... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In PHP, replace one URL with another within a string e.g.
```
New post on the site <a href="http://stackoverflow.com/xyz1">http://stackoverflow.com/xyz1</a></p>
```
becomes:
```
New post on the site <a href="http://yahoo.com/abc1">http://yahoo.com/abc1</a></p>
```
Must work for repeating strings as above. Apprec... | ```
function replace_url($text, $newurl) {
$text = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $newurl, $text);
return $text;
}
```
Should work.
Regex stolen from [here](http://snipplr.com/view/2371/regex-regular-expression-to-match-a-url/). This will replace all URLs in the string... |
118,096 | <p>I need to be able to take a string like:</p>
<pre><code>'''foo, bar, "one, two", three four'''
</code></pre>
<p>into:</p>
<pre><code>['foo', 'bar', 'one, two', 'three four']
</code></pre>
<p>I have an feeling (with hints from #python) that the solution is going to involve the shlex module.</p>
| [
{
"answer_id": 118110,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>You may also want to consider the <a href=\"http://docs.python.org/lib/module-csv.html\" rel=\"noreferrer\">csv</a> mo... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18866/"
] | I need to be able to take a string like:
```
'''foo, bar, "one, two", three four'''
```
into:
```
['foo', 'bar', 'one, two', 'three four']
```
I have an feeling (with hints from #python) that the solution is going to involve the shlex module. | The shlex module solution allows escaped quotes, one quote escape another, and all fancy stuff shell supports.
```
>>> import shlex
>>> my_splitter = shlex.shlex('''foo, bar, "one, two", three four''', posix=True)
>>> my_splitter.whitespace += ','
>>> my_splitter.whitespace_split = True
>>> print list(my_splitter)
['f... |
118,100 | <p>do you use a tool? or just manually make them?</p>
| [
{
"answer_id": 118106,
"author": "David Leonard",
"author_id": 19502,
"author_profile": "https://Stackoverflow.com/users/19502",
"pm_score": 0,
"selected": false,
"text": "<p>We use something locally based on <a href=\"http://opentcdb.org/\" rel=\"nofollow noreferrer\">http://opentcdb.or... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10431/"
] | do you use a tool? or just manually make them? | [Google charts api/server](http://code.google.com/apis/chart/basics.html) can make one fairly easily
 it'll pull of the appl... | [
{
"answer_id": 118155,
"author": "jdmichal",
"author_id": 12275,
"author_profile": "https://Stackoverflow.com/users/12275",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I know, the taskbar is either above or below windows based on the \"Keep the taskbar on top of other windows... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13713/"
] | I'm using Windows Vista and C#.net 3.5, but I had my friend run the program on XP and has the same problem.
So I have a C# program that I have running in the background with an icon in the SystemTray. I have a low level keyboard hook so when I press two keys (Ctr+windows in this case) it'll pull of the application's m... | Try this (where `this` is your form):
```
this.Bounds = Screen.PrimaryScreen.Bounds;
this.TopMost = true;
```
That'll set the form to fullscreen, and it'll cover the taskbar. |
118,143 | <p>Not a competition, it is instead me trying to find why a certain regex works in one but not the other.</p>
<pre><code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
</code></pre>
<p>That's my Regex and I... | [
{
"answer_id": 118163,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 4,
"selected": true,
"text": "<p>It works for me. You must be doing something wrong.</p>\n\n<pre><code>>>> re.match(r'(25[0-5]|2[0-4][0-9]|[01]?[... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | Not a competition, it is instead me trying to find why a certain regex works in one but not the other.
```
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
```
That's my Regex and I'm trying to run it on
``... | It works for me. You must be doing something wrong.
```
>>> re.match(r'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)', '127.255.0.0').groups()
('127', '255', '0', '0')
```
Don't forget to escape the regex... |
118,144 | <p>What's the most efficient way to select the last n number of rows in a table using mySQL? The table contains millions of rows, and at any given time I don't know how large the table is (it is constantly growing). The table does have a column that is automatically incremented and used as a unique identifier for each ... | [
{
"answer_id": 118169,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 7,
"selected": true,
"text": "<pre class=\"lang-sql prettyprint-override\"><code>SELECT * FROM table_name ORDER BY auto_incremented_id DESC LIMIT n... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9076/"
] | What's the most efficient way to select the last n number of rows in a table using mySQL? The table contains millions of rows, and at any given time I don't know how large the table is (it is constantly growing). The table does have a column that is automatically incremented and used as a unique identifier for each row... | ```sql
SELECT * FROM table_name ORDER BY auto_incremented_id DESC LIMIT n
``` |
118,190 | <p>I have a SQL script that creates a package with a comment containing an ampersand (&). When I run the script from SQL Plus, I am prompted to enter a substitute value for the string starting with &. How do I disable this feature so that SQL Plus ignores the ampersand?</p>
| [
{
"answer_id": 118210,
"author": "Austin Salonen",
"author_id": 4068,
"author_profile": "https://Stackoverflow.com/users/4068",
"pm_score": 9,
"selected": true,
"text": "<p>This may work for you:</p>\n\n<pre><code>set define off\n</code></pre>\n\n<p>Otherwise the ampersand needs to be at... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20625/"
] | I have a SQL script that creates a package with a comment containing an ampersand (&). When I run the script from SQL Plus, I am prompted to enter a substitute value for the string starting with &. How do I disable this feature so that SQL Plus ignores the ampersand? | This may work for you:
```
set define off
```
Otherwise the ampersand needs to be at the end of a string,
```
'StackOverflow &' || ' you'
```
EDIT: I was click-happy when saving... This was referenced from a [blog](http://blog.andrewbeacock.com/2008/09/using-ampersands-without-variable_15.html). |
118,199 | <p>I have an application where 2 threads are running... Is there any certanty that when I change a global variable from one thread, the other will notice this change?
I don't have any syncronization or Mutual exclusion system in place... but should this code work all the time (imagine a global <strong>bool</strong> na... | [
{
"answer_id": 118204,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 2,
"selected": false,
"text": "<p>Use the <strong>volatile</strong> keyword to hint to the compiler that the value can change at any time.</p>\n\n<pre>... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2731698/"
] | I have an application where 2 threads are running... Is there any certanty that when I change a global variable from one thread, the other will notice this change?
I don't have any syncronization or Mutual exclusion system in place... but should this code work all the time (imagine a global **bool** named **dataUpdate... | Yes. No. Maybe.
First, as others have mentioned you need to make dataUpdated volatile; otherwise the compiler may be free to lift reading it out of the loop (depending on whether or not it can see that doSomethingElse doesn't touch it).
Secondly, depending on your processor and ordering needs, you may need memory bar... |
118,205 | <p>At work, we have a windows server 2003 with IIS and Subversion installed. We use it to publish and test locally
our ASP.NET websites. Every programmer has Tortoise installed on his PC and can update/commit content to the server. Hosting the repositories is working fine.
But the files kept in those repositories need... | [
{
"answer_id": 118229,
"author": "Aeon",
"author_id": 13289,
"author_profile": "https://Stackoverflow.com/users/13289",
"pm_score": 3,
"selected": false,
"text": "<p>SVN doesn't support IIS; you can however <a href=\"http://svn.collab.net/repos/svn/trunk/notes/windows-service.txt\" rel=\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296/"
] | At work, we have a windows server 2003 with IIS and Subversion installed. We use it to publish and test locally
our ASP.NET websites. Every programmer has Tortoise installed on his PC and can update/commit content to the server. Hosting the repositories is working fine.
But the files kept in those repositories needs t... | 1. Just keep the web server's file area as a working copy, and perform an svn up in it whenever you want to "publish". Configure it to hide the contents of the .svn folders if they seem untidy to you (I don't specifically know how to do this, but I assume it can be done). They will already have the filesystem hidden bi... |
118,241 | <p>I'd like to use JavaScript to calculate the width of a string. Is this possible without having to use a monospace typeface?</p>
<p>If it's not built-in, my only idea is to create a table of widths for each character, but this is pretty unreasonable especially supporting <a href="http://en.wikipedia.org/wiki/Unicode... | [
{
"answer_id": 118251,
"author": "CMPalmer",
"author_id": 14894,
"author_profile": "https://Stackoverflow.com/users/14894",
"pm_score": 10,
"selected": true,
"text": "<p>Create a DIV styled with the following styles. In your JavaScript, set the font size and attributes that you are tryin... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8119/"
] | I'd like to use JavaScript to calculate the width of a string. Is this possible without having to use a monospace typeface?
If it's not built-in, my only idea is to create a table of widths for each character, but this is pretty unreasonable especially supporting [Unicode](http://en.wikipedia.org/wiki/Unicode) and dif... | Create a DIV styled with the following styles. In your JavaScript, set the font size and attributes that you are trying to measure, put your string in the DIV, then read the current width and height of the DIV. It will stretch to fit the contents and the size will be within a few pixels of the string rendered size.
``... |