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 |
|---|---|---|---|---|---|---|
183,950 | <p>I am developing a WebPart (it will be used in a SharePoint environment, although it does not use the Object Model) that I want to expose AJAX functionality in. Because of the nature of the environment, Adding the Script Manager directly to the page is not an option, and so must be added programmatically. I have at... | [
{
"answer_id": 184262,
"author": "Kyle Trauberman",
"author_id": 21461,
"author_profile": "https://Stackoverflow.com/users/21461",
"pm_score": 6,
"selected": true,
"text": "<p>I was able to get this to work by using the Page's Init event:</p>\n\n<pre><code>protected override void OnInit(... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21461/"
] | I am developing a WebPart (it will be used in a SharePoint environment, although it does not use the Object Model) that I want to expose AJAX functionality in. Because of the nature of the environment, Adding the Script Manager directly to the page is not an option, and so must be added programmatically. I have attempt... | I was able to get this to work by using the Page's Init event:
```
protected override void OnInit(EventArgs e)
{
Page.Init += delegate(object sender, EventArgs e_Init)
{
if (ScriptManager.GetCurrent(Page) == null)
{
ScriptManager s... |
183,991 | <p>I wonder if there's a way to do the following: I have a structure containing a member which is a pointer to a block of memory allocated by the kernel when I pass the structure to an API function (the structure is a WAVEHDR, the member is the <em>reserved</em> field.)</p>
<p>I can set a data breakpoint on the value ... | [
{
"answer_id": 184460,
"author": "Nicholas Mancuso",
"author_id": 8945,
"author_profile": "https://Stackoverflow.com/users/8945",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure if thats possible. I know that there are conditional breakpoints, but that would require knowing th... | 2008/10/08 | [
"https://Stackoverflow.com/questions/183991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9047/"
] | I wonder if there's a way to do the following: I have a structure containing a member which is a pointer to a block of memory allocated by the kernel when I pass the structure to an API function (the structure is a WAVEHDR, the member is the *reserved* field.)
I can set a data breakpoint on the value of the reserved m... | A macro can evaluate anything that you can in the watch window:
```
Dim e As EnvDTE.Expression
e = DTE.Debugger.GetExpression("<my expression>", True)
If e.IsValidValue Then
... use e.Value to do something
End If
```
The value you get back in e.Value is exactly the string you would see in t... |
184,002 | <p>In the following piece of code (taken from the <a href="http://groovy-lang.org/semantics.html#_while_loop" rel="noreferrer">Groovy Semantics Manual page</a>), why prefix the assignment with the keyword <code>def</code>?</p>
<pre><code>def x = 0
def y = 5
while ( y-- > 0 ) {
println "" + x + " " + y
x++
... | [
{
"answer_id": 184019,
"author": "billjamesdev",
"author_id": 13824,
"author_profile": "https://Stackoverflow.com/users/13824",
"pm_score": 3,
"selected": false,
"text": "<p>Actually, I <strong>don't</strong> think it would behave the same... </p>\n\n<p>variables in Groovy still require... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15649/"
] | In the following piece of code (taken from the [Groovy Semantics Manual page](http://groovy-lang.org/semantics.html#_while_loop)), why prefix the assignment with the keyword `def`?
```
def x = 0
def y = 5
while ( y-- > 0 ) {
println "" + x + " " + y
x++
}
assert x == 5
```
The `def` keyword can be removed,... | It's syntactic sugar for basic scripts. Omitting the "def" keyword puts the variable in the bindings for the current script and groovy treats it (mostly) like a globally scoped variable:
```
x = 1
assert x == 1
assert this.binding.getVariable("x") == 1
```
Using the def keyword instead does not put the variable in t... |
184,009 | <p>I can't find this anywhere in the Domino Designer help. It seems so straightforward!</p>
<p>All I need to do is find the position of a character in a string.</p>
| [
{
"answer_id": 195251,
"author": "molasses",
"author_id": 11293,
"author_profile": "https://Stackoverflow.com/users/11293",
"pm_score": 1,
"selected": true,
"text": "<p>(edited) Please see the answer from charles ross instead.\n<a href=\"https://stackoverflow.com/a/19437044/11293\">https... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2273/"
] | I can't find this anywhere in the Domino Designer help. It seems so straightforward!
All I need to do is find the position of a character in a string. | (edited) Please see the answer from charles ross instead.
<https://stackoverflow.com/a/19437044/11293>
My less efficient method is below.
---
If you really need the character position though you could do this:
```
REM {
S Source string
F Character to find
R Location of character in string or 0
};
S ... |
184,014 | <p>Can an XML attribute be the empty string?</p>
<p>In other words, is</p>
<pre><code><element att="" />
</code></pre>
<p>valid XML?</p>
| [
{
"answer_id": 184024,
"author": "Bradley Grainger",
"author_id": 23633,
"author_profile": "https://Stackoverflow.com/users/23633",
"pm_score": 4,
"selected": false,
"text": "<p>Yes, this is well-formed XML.</p>\n\n<p>An easy way to test this (on Windows) is to save the sample in a <code... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1447/"
] | Can an XML attribute be the empty string?
In other words, is
```
<element att="" />
```
valid XML? | You can create an empty attribute via
attname=""
You can create an empty element via
```
<elementName></elementName>
```
or
```
<elementName/>
``` |
184,027 | <p>I am looking hard at the basic principles of storing the state of an executing program to disk, and bringing it back in again. In the current design that we have, each object (which is a C-level thingy with function pointer lists, kind of low-level home-made object-orientation -- and there are very good reasons for... | [
{
"answer_id": 184124,
"author": "mstrobl",
"author_id": 25965,
"author_profile": "https://Stackoverflow.com/users/25965",
"pm_score": 0,
"selected": false,
"text": "<p>You should NOT try to serialize a state that your program has to disk. Because your program <strong>will never have ful... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23054/"
] | I am looking hard at the basic principles of storing the state of an executing program to disk, and bringing it back in again. In the current design that we have, each object (which is a C-level thingy with function pointer lists, kind of low-level home-made object-orientation -- and there are very good reasons for doi... | I don't think serializing only "some threads" of a program can work, since you will run into problems with synchronization (some of the problems are described here <http://java.sun.com/j2se/1.3/docs/guide/misc/threadPrimitiveDeprecation.html> ).
So persisting your whole program is the only viable way to get a consisten... |
184,034 | <p>What do you do to pass information between forms? Forward is straight forward (sorry) using Properties or maybe parameters in a New() or DoStuff() method, but what about sending something <strong><em>back</em></strong> when the user is done with the second form? (IE. ID of the item selected) We have used all these... | [
{
"answer_id": 184067,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 0,
"selected": false,
"text": "<p>Do you want to access the UI elements of the second form? I think a cleaner way is to using a shared object for pass... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24991/"
] | What do you do to pass information between forms? Forward is straight forward (sorry) using Properties or maybe parameters in a New() or DoStuff() method, but what about sending something ***back*** when the user is done with the second form? (IE. ID of the item selected) We have used all these:
* **Passed the calling... | Create public properties for the form, then wait for the form to close and check the properties before disposing the new form.
```
NewForm myForm = new NewForm();
myForm.ShowDialog();
string x = myform.MyProperty;
``` |
184,074 | <p>When I debug locally in fire fox 2.0x many times my page won't have the styles added properly or the page will not completely render (the end is seemingly cut off). Sometimes it takes multiple refreshes or shift-refreshes to fix this. Is this a common issue or is it just me? Any solutions?</p>
<p>I want to add that... | [
{
"answer_id": 485740,
"author": "cdeszaq",
"author_id": 20770,
"author_profile": "https://Stackoverflow.com/users/20770",
"pm_score": 0,
"selected": false,
"text": "<p>One thing to do would be to check the source of the page(s) in question. My guess would be that the local server that V... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18926/"
] | When I debug locally in fire fox 2.0x many times my page won't have the styles added properly or the page will not completely render (the end is seemingly cut off). Sometimes it takes multiple refreshes or shift-refreshes to fix this. Is this a common issue or is it just me? Any solutions?
I want to add that this is h... | This could be a **problem with IPv6 and DNS** of the Firefox browser. This issue is known to *slow down* Firefox on localhost:SOMEPORT. The effect would be that some external files won't load (css, js etc.) resulting in a partially rendered page.
You can solve this issue by simply deactivating IPv6 in Firefox:
1. Ins... |
184,084 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application">What is the correct way to create a single instance application?</a> </p>
</blockquote>
<p>How to force C# .net app to run only one instanc... | [
{
"answer_id": 184143,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 7,
"selected": false,
"text": "<p>I prefer a mutex solution similar to the following. As this way it re-focuses on the app if it is already load... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316/"
] | >
> **Possible Duplicate:**
>
> [What is the correct way to create a single instance application?](https://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application)
>
>
>
How to force C# .net app to run only one instance in Windows? | I prefer a mutex solution similar to the following. As this way it re-focuses on the app if it is already loaded
```
using System.Threading;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
/// <summary>
/// The main entry point for the applicatio... |
184,096 | <p>Suppose there is a fully populated array of data String[n][3] myData.</p>
<p>I want to do this:</p>
<pre><code>for (String[] row : myData)
{
SQL = "update mytable set col3 = row[2]
where col1 = row[0] and col2=row[1];"
}
</code></pre>
<p>Obviously I've left a lot out, but I want to express the idea as succ... | [
{
"answer_id": 184123,
"author": "fmsf",
"author_id": 26004,
"author_profile": "https://Stackoverflow.com/users/26004",
"pm_score": 1,
"selected": false,
"text": "<p>You can make a big string like:</p>\n\n<pre><code>for (String[] row : myData)\n{\n SQL += \"update mytable set col3 = ro... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18907/"
] | Suppose there is a fully populated array of data String[n][3] myData.
I want to do this:
```
for (String[] row : myData)
{
SQL = "update mytable set col3 = row[2]
where col1 = row[0] and col2=row[1];"
}
```
Obviously I've left a lot out, but I want to express the idea as succinctly as possible.
Is there a s... | If you are using Sql Server you can use SqlBulkCopy. You would first have to put your data in a DataTable, which would be pretty easy since you already have it in a string array.
<http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx> |
184,099 | <p>I want to have a reusable button which can be registered for one of many different callbacks, determined by an external source. When a new callback is set, I want to remove the old. I also want to be able to clear the callback externally at any time.</p>
<pre><code>public function registerButtonCallback(function:Fu... | [
{
"answer_id": 184331,
"author": "Simon",
"author_id": 24039,
"author_profile": "https://Stackoverflow.com/users/24039",
"pm_score": 3,
"selected": false,
"text": "<p>I am presuming that you want only one callback function at any given time. If that's teh case then why not have a single... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to have a reusable button which can be registered for one of many different callbacks, determined by an external source. When a new callback is set, I want to remove the old. I also want to be able to clear the callback externally at any time.
```
public function registerButtonCallback(function:Function):void
{... | I am presuming that you want only one callback function at any given time. If that's teh case then why not have a single callback function associated with the click event on the button which itself called a function and have that function be settable...
```
<mx:Button click="doCallback()" .../>
public var onClickFunc... |
184,108 | <p>I have a very simple TCP server written in C. It runs indefinitely, waiting for connections. On Windows, I use <code>select</code> to check for activity on the socket, and if there isn't any, I have the following code to allow me to quit by hitting 'q' on the keyboard:</p>
<pre><code>if( kbhit() ) {
char c = get... | [
{
"answer_id": 184152,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 4,
"selected": true,
"text": "<p>Add stdin to your list of select handles, and if it has data, call read to read one character from it.</p>\n"
},
{
... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1821/"
] | I have a very simple TCP server written in C. It runs indefinitely, waiting for connections. On Windows, I use `select` to check for activity on the socket, and if there isn't any, I have the following code to allow me to quit by hitting 'q' on the keyboard:
```
if( kbhit() ) {
char c = getch();
if( c == 'q' ) b... | Add stdin to your list of select handles, and if it has data, call read to read one character from it. |
184,132 | <p>I need some help from the shell-script gurus out there.</p>
<p>I have a .txt file (log) that traces the IP addresses of clients on several lines, in a format similar to this one:</p>
<pre><code>Line1 - Client IP [192.168.0.1] Other data
Line2 - Client IP [192.168.0.2] Other data
Line3 - Client IP [192.168.0.3] Oth... | [
{
"answer_id": 184154,
"author": "Robert Elwell",
"author_id": 23102,
"author_profile": "https://Stackoverflow.com/users/23102",
"pm_score": 2,
"selected": false,
"text": "<pre><code> cat yourfile.txt | sed 's/*\\[//g' | sed 's/\\]*//g' | sort | uniq > newfile.txt\n</code></pre>\n\n<p... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23034/"
] | I need some help from the shell-script gurus out there.
I have a .txt file (log) that traces the IP addresses of clients on several lines, in a format similar to this one:
```
Line1 - Client IP [192.168.0.1] Other data
Line2 - Client IP [192.168.0.2] Other data
Line3 - Client IP [192.168.0.3] Other data
Line4 - Clien... | In PowerShell:
The Verbose Way -
```
$regex = '(?<IPAddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'
get-content log.txt | where-object {if ($_ -match $regex){$matches.ipaddress}} | group-object -noelement
```
Shorter version
```
gc log.txt | % {if ($_ -match $regex){$matches.ipaddress}} | group -n
``` |
184,147 | <p>Is there any advantage of using</p>
<p><a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html" rel="noreferrer"><strong>java.util.concurrent.CountdownLatch</strong></a> </p>
<p>instead of</p>
<p><a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Semaphore.... | [
{
"answer_id": 184441,
"author": "Spencer Kormos",
"author_id": 8528,
"author_profile": "https://Stackoverflow.com/users/8528",
"pm_score": 0,
"selected": false,
"text": "<p><code>CountdownLatch</code> makes threads wait on the <code>await()</code> method, until such a time as the count ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12048/"
] | Is there any advantage of using
[**java.util.concurrent.CountdownLatch**](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html)
instead of
[**java.util.concurrent.Semaphore**](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Semaphore.html)?
As far as I can tell the fol... | `CountDownLatch` is frequently used for the exact opposite of your example. Generally, you would have many threads blocking on `await()` that would all start simultaneously when the countown reached zero.
```
final CountDownLatch countdown = new CountDownLatch(1);
for (int i = 0; i < 10; ++ i) {
Thread racecar = n... |
184,162 | <p>I'm trying to find the best way to use 'top' as semi-permanent instrumentation in the development of a box running embedded Linux. (The instrumentation will be removed from the final-test and production releases.)</p>
<p>My first pass is to simply add this to init.d:</p>
<pre><code>top -b -d 15 >/tmp/toploop.ou... | [
{
"answer_id": 184183,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 1,
"selected": false,
"text": "<p>You might find that vmstat and iostat with a delay and no repeat counter is a better option.</p>\n"
},
{
"an... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14028/"
] | I'm trying to find the best way to use 'top' as semi-permanent instrumentation in the development of a box running embedded Linux. (The instrumentation will be removed from the final-test and production releases.)
My first pass is to simply add this to init.d:
```
top -b -d 15 >/tmp/toploop.out &
```
This runs top ... | Look at [collectd](http://collectd.org/). It's a very light weight system monitoring framework coded for performance. |
184,178 | <p>I want to do an HTTP POST that looks like an HMTL form posted from a browser. Specifically, post some text fields and a file field.</p>
<p>Posting text fields is straightforward, there's an example right there in the net/http rdocs, but I can't figure out how to post a file along with it.</p>
<p>Net::HTTP doesn't ... | [
{
"answer_id": 184303,
"author": "kch",
"author_id": 13989,
"author_profile": "https://Stackoverflow.com/users/13989",
"pm_score": 3,
"selected": false,
"text": "<p>Ok, here's a simple example using curb.</p>\n\n<pre><code>require 'yaml'\nrequire 'curb'\n\n# prepare post data\npost_data ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13989/"
] | I want to do an HTTP POST that looks like an HMTL form posted from a browser. Specifically, post some text fields and a file field.
Posting text fields is straightforward, there's an example right there in the net/http rdocs, but I can't figure out how to post a file along with it.
Net::HTTP doesn't look like the bes... | I like [RestClient](https://github.com/rest-client/rest-client). It encapsulates net/http with cool features like multipart form data:
```
require 'rest_client'
RestClient.post('http://localhost:3000/foo',
:name_of_file_param => File.new('/path/to/file'))
```
It also supports streaming.
`gem install rest-client`... |
184,187 | <p>I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to build and test first. </p>
| [
{
"answer_id": 184193,
"author": "Matt Price",
"author_id": 852,
"author_profile": "https://Stackoverflow.com/users/852",
"pm_score": 3,
"selected": false,
"text": "<p>Here's what I came up with:</p>\n\n<pre><code>import os\n\ndef CreateNewChangeList(description):\n \"Create a new cha... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/852/"
] | I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to build and test first. | Perforce has Python wrappers around their C/C++ tools, available in binary form for Windows, and source for other platforms:
<http://www.perforce.com/perforce/loadsupp.html#api>
You will find their documentation of the scripting API to be helpful:
<http://www.perforce.com/perforce/doc.current/manuals/p4script/p4scri... |
184,199 | <p>I have a new project that needs a good binary protocol.</p>
<p>I was thinking of using <a href="http://hessian.caucho.com/" rel="nofollow noreferrer">Hessian</a>, unless anyone has any better ideas.</p>
<p>I was reading through some of their documentation and it's not as straightforward as I thought, so I have a c... | [
{
"answer_id": 184576,
"author": "Chris Vest",
"author_id": 13251,
"author_profile": "https://Stackoverflow.com/users/13251",
"pm_score": 2,
"selected": false,
"text": "<p>I have not used Hessian in the past and I don't plan on using it in the future either, and my arguments are these:</... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16584/"
] | I have a new project that needs a good binary protocol.
I was thinking of using [Hessian](http://hessian.caucho.com/), unless anyone has any better ideas.
I was reading through some of their documentation and it's not as straightforward as I thought, so I have a couple of quick questions.
The home page has a section... | Yes, Hessian 2.0 is the one to use. The protocol specifies how a data structure is represented binary, the spec is simple.
The Hessian web service builds on the Hessian protocol, it specifies a number of headers in the Hessian format to describe e.g. the request/response format in the Hessian protocol. It defines the ... |
184,216 | <p>Full disclaimer: I'm a CS student, and this question is related to a recently assigned Java program for Object-Oriented Programming. Although we've done some console stuff, this is the first time we've worked with a GUI and Swing or Awt. We were given some code that created a window with some text and a button that ... | [
{
"answer_id": 184372,
"author": "Patrick Huizinga",
"author_id": 15200,
"author_profile": "https://Stackoverflow.com/users/15200",
"pm_score": 2,
"selected": true,
"text": "<p>Instead of writing this:</p>\n\n<pre><code>resetButton.addActionListener(this);\n</code></pre>\n\n<p>You could ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26237/"
] | Full disclaimer: I'm a CS student, and this question is related to a recently assigned Java program for Object-Oriented Programming. Although we've done some console stuff, this is the first time we've worked with a GUI and Swing or Awt. We were given some code that created a window with some text and a button that rot... | Instead of writing this:
```
resetButton.addActionListener(this);
```
You could also write this:
```
resetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
resetButtonActionPerformed(evt);
}
});
```
And instead of writing one big actionPerformed() for a... |
184,272 | <p>What exactly does the word patch mean when referring to 'submitting a patch'?</p>
<p>I've seen this used a lot, especially in the open source world. What what does it mean and what exactly is involved in submitting a patch?</p>
| [
{
"answer_id": 184277,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 5,
"selected": true,
"text": "<p>It's a file with a list of differences between the code files that have changed. It's usually in the format generated by ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13227/"
] | What exactly does the word patch mean when referring to 'submitting a patch'?
I've seen this used a lot, especially in the open source world. What what does it mean and what exactly is involved in submitting a patch? | It's a file with a list of differences between the code files that have changed. It's usually in the format generated by doing a **diff -u** on the two files. Most version control systems allow the easy creation of patches but it's generally in that same format.
This allows the code change to be easily applied to some... |
184,313 | <p>I have this .NET regex:</p>
<pre><code>^(?<prefix>("[^"]*"))\s(?<attrgroup>(\([^\)]*\)))\s(?<suffix>("[^"]*"))$
</code></pre>
<p>It properly matches the following strings:</p>
<pre><code>"some prefix" ("attribute 1" "value 1") "some suffix"
"some prefix" ("attribute 1" "value 1" "attribute 2" "v... | [
{
"answer_id": 184392,
"author": "hometoast",
"author_id": 2009,
"author_profile": "https://Stackoverflow.com/users/2009",
"pm_score": 1,
"selected": false,
"text": "<pre><code>^(?<prefix>\"[^\"]*\")\\s+(?<attrgroup>\\(.*\\))\\s+(?<suffix>\"[^\"]*\")$\n</code></pre>\n\n... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3447/"
] | I have this .NET regex:
```
^(?<prefix>("[^"]*"))\s(?<attrgroup>(\([^\)]*\)))\s(?<suffix>("[^"]*"))$
```
It properly matches the following strings:
```
"some prefix" ("attribute 1" "value 1") "some suffix"
"some prefix" ("attribute 1" "value 1" "attribute 2" "value 2") "some suffix"
```
It fails on...
```
"some ... | my, untested guess:
```
^(?<prefix>("[^"]*"))\s(?<attrgroup>(\(("[^"]*")(\s("[^"]*")*)**\)))\s(?<suffix>("[^"]*"))$
```
hereby I've replaced
```
[^\)]*
```
with
```
("[^"]*")(\s("[^"]*")*)*
```
I assumed everything within the parenthesis is either between double quotes, or is a whitespace.
If you want to know... |
184,340 | <p>I have an application that manages patient demographic information. Along with this data a user can scan a picture of a patient and assign that picture to a patient. When the user clicks the scan button a separate application is opened as a dialog in order to scan the image. When running this on XP everything worked... | [
{
"answer_id": 184368,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 0,
"selected": false,
"text": "<p>You could iterate through all top level HWNDs and identify the scanning application via its window class, then send... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25511/"
] | I have an application that manages patient demographic information. Along with this data a user can scan a picture of a patient and assign that picture to a patient. When the user clicks the scan button a separate application is opened as a dialog in order to scan the image. When running this on XP everything worked fi... | I think you will have to make changes to your application to allow the imaging application to take the focus. I'm going to assume that your application launches the imaging application through `ShellExecute` or `CreateProcess`. If so, you can get the process handle of the launched process either through `SHELLEXECUTEIN... |
184,414 | <p>I have one action I want to perform when a TSpeedButton is pressed and another I want to perform when the same button is "unpressed". I know there's no onunpress event, but is there any easy way for me to get an action to execute when a different button is pressed? </p>
<pre><code>procedure ActionName.ActionNameEx... | [
{
"answer_id": 184588,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "<p>Yes, you do. You're defining a self-contained piece of work which the NSOperationQueue will execute on \"some\" thread, so y... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1765/"
] | I have one action I want to perform when a TSpeedButton is pressed and another I want to perform when the same button is "unpressed". I know there's no onunpress event, but is there any easy way for me to get an action to execute when a different button is pressed?
```
procedure ActionName.ActionNameExecute(Sender: T... | Yes, you do. You're defining a self-contained piece of work which the NSOperationQueue will execute on "some" thread, so you're responsible for managing memory in that work piece. |
184,431 | <p>I'm trying to convert an XML file into the markup used by dokuwiki, using XSLT. This actually works to some degree, but the indentation in the XSL file is getting inserted into the results. At the moment, I have two choices: abandon this XSLT thing entirely, and find another way to convert from XML to dokuwiki mar... | [
{
"answer_id": 184449,
"author": "Lindsay",
"author_id": 23520,
"author_profile": "https://Stackoverflow.com/users/23520",
"pm_score": 2,
"selected": false,
"text": "<p>Are you using indent=\"no\" in your output tag?</p>\n\n<pre><code><xsl:output method=\"text\" indent=\"no\" />\n<... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26257/"
] | I'm trying to convert an XML file into the markup used by dokuwiki, using XSLT. This actually works to some degree, but the indentation in the XSL file is getting inserted into the results. At the moment, I have two choices: abandon this XSLT thing entirely, and find another way to convert from XML to dokuwiki markup, ... | There are three reasons for getting unwanted whitespace in the result of an XSLT transformation:
1. whitespace that comes from between nodes in the source document
2. whitespace that comes from within nodes in the source document
3. whitespace that comes from the stylesheet
I'm going to talk about all three because i... |
184,436 | <p>I'm working with an old Access database (yes, it's very ugly and I hate it). I need to modify some of the columns from a VB app that I'm creating. I have most the modifications setup correctly, but I'm fighting with the fact that modifying a column to text has it default to "Allow Zero Length" to false.</p>
<p>SO... | [
{
"answer_id": 184552,
"author": "Richard Harrison",
"author_id": 19624,
"author_profile": "https://Stackoverflow.com/users/19624",
"pm_score": 0,
"selected": false,
"text": "<p>Ages ago I wanted to do the same and ISTR that it simply wasn't possible from DDL/SQL - but you can do it from... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10420/"
] | I'm working with an old Access database (yes, it's very ugly and I hate it). I need to modify some of the columns from a VB app that I'm creating. I have most the modifications setup correctly, but I'm fighting with the fact that modifying a column to text has it default to "Allow Zero Length" to false.
SO
ALTER TABL... | This option isn't available with Jet sql. You can do it in the Access gui or with vba code. Example:
```
Public Function setAllowZeroLenStr()
On Error GoTo Proc_Err
Dim db As Database
Dim tbl As TableDef
Dim fld As DAO.Field
Set db = CurrentDb
Set tbl = db.TableDefs![Applicant Table]
... |
184,471 | <p>Replaces Question: <a href="https://stackoverflow.com/questions/184096/update-multiple-rows-into-sql-table">Update multiple rows into SQL table</a></p>
<p>Here's a Code Snippet to update an exam results set.
DB structure is as given, but I can submit Stored Procedures for inclusion (Which are a pain to modify, so I... | [
{
"answer_id": 184503,
"author": "Hafthor",
"author_id": 4489,
"author_profile": "https://Stackoverflow.com/users/4489",
"pm_score": -1,
"selected": false,
"text": "<p>emit a single update that goes against a values table:</p>\n\n<pre><code>UPDATE s SET ANSWER=a FROM dbo.STUDENTAnswers s... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18907/"
] | Replaces Question: [Update multiple rows into SQL table](https://stackoverflow.com/questions/184096/update-multiple-rows-into-sql-table)
Here's a Code Snippet to update an exam results set.
DB structure is as given, but I can submit Stored Procedures for inclusion (Which are a pain to modify, so I save that until the ... | A few things stand out:
* You don't show where the SqlConnection is instantiated, so it's not clear that you're disposing it properly.
* You shouldn't be swallowing exceptions in the loop - better to handle them in a top level exception handler.
* You're instantiating new parameters on each iteration through the loop ... |
184,476 | <p>I have been pushing into the .NET framework in PowerShell, and I have hit something that I don't understand. This works fine:</p>
<pre><code>$foo = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
$foo.Add("FOO", "BAR")
$foo
Key ... | [
{
"answer_id": 185174,
"author": "Steven Murawski",
"author_id": 1233,
"author_profile": "https://Stackoverflow.com/users/1233",
"pm_score": 2,
"selected": false,
"text": "<p>There are some issues with Generics in PowerShell. Lee Holmes, a dev on the PowerShell team posted <a href=\"htt... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1358/"
] | I have been pushing into the .NET framework in PowerShell, and I have hit something that I don't understand. This works fine:
```
$foo = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
$foo.Add("FOO", "BAR")
$foo
Key Value
--- ... | Dictionary<K,V> is not defined in the same assembly as SortedDictionary<K,V>. One is in mscorlib and the other in system.dll.
Therein lies the problem. The current behavior in PowerShell is that when resolving the generic parameters specified, if the types are not fully qualified type names, it sort of assumes that th... |
184,482 | <p>I display data into an html table, w/ a drop down box with a list of venues. Each volunteer will be assigned a venue. I envision being able to go down thru the html table and assigning each volunteer a venue. The drop down box contains all the possible venues that they can be assigned to.</p>
<pre><code><select&... | [
{
"answer_id": 184517,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 0,
"selected": false,
"text": "<p>I can't think of any way. You can put multiple SQL statements into 1 MySQL query:</p>\n\n<pre><code>UPDATE volunteer ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26130/"
] | I display data into an html table, w/ a drop down box with a list of venues. Each volunteer will be assigned a venue. I envision being able to go down thru the html table and assigning each volunteer a venue. The drop down box contains all the possible venues that they can be assigned to.
```
<select>
<option value="1... | Change the name of each select, in a way it includes a volunteer id:
```
<select name="venues[1]">
<option value="1">Setup</option>
etc...
</select>
<select name="venues[2]">
<option value="1">Setup</option>
etc...
</select>
<select name="venues[3]">
<option value="1">Setup</option>
etc...
</select>
```
After subm... |
184,489 | <p>I am trying to retrieve an image stored in an oracle blob and place it in a new System.Drawing.Image instance. I know I can write the stream to a temp.bmp file on the disk and read it from there but thats just not l33t enough for me. How do I convert the blob object directly to an image?</p>
| [
{
"answer_id": 184577,
"author": "osp70",
"author_id": 2357,
"author_profile": "https://Stackoverflow.com/users/2357",
"pm_score": 0,
"selected": false,
"text": "<p>I know this uses sql but it should be similar for your needs</p>\n\n<pre><code>Dim cn As SqlConnection = Nothing\n D... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I am trying to retrieve an image stored in an oracle blob and place it in a new System.Drawing.Image instance. I know I can write the stream to a temp.bmp file on the disk and read it from there but thats just not l33t enough for me. How do I convert the blob object directly to an image? | Assuming :
* you are using the Microsoft client (`System.Data.OracleClient`).
* you have a proper `OracleConnection` instance (`connection`).
* you have an `OracleCommand` ready (`command`, based on `SELECT my_blob FROM my_table WHERE id=xx`).
This should go like this :
```
using (OracleDataReader odr=command.Execut... |
184,491 | <p>We have a Java Applet built using AWT. This applet lets you select pictures from your hard drive and upload them to a server. The applet includes a scrollable list of pictures, which works fine in Windows, Linux and Mac OS X 10.5. We launch this applet via Java Web Start or within a web page. </p>
<p>Our applet doe... | [
{
"answer_id": 184577,
"author": "osp70",
"author_id": 2357,
"author_profile": "https://Stackoverflow.com/users/2357",
"pm_score": 0,
"selected": false,
"text": "<p>I know this uses sql but it should be similar for your needs</p>\n\n<pre><code>Dim cn As SqlConnection = Nothing\n D... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20893/"
] | We have a Java Applet built using AWT. This applet lets you select pictures from your hard drive and upload them to a server. The applet includes a scrollable list of pictures, which works fine in Windows, Linux and Mac OS X 10.5. We launch this applet via Java Web Start or within a web page.
Our applet does not beha... | Assuming :
* you are using the Microsoft client (`System.Data.OracleClient`).
* you have a proper `OracleConnection` instance (`connection`).
* you have an `OracleCommand` ready (`command`, based on `SELECT my_blob FROM my_table WHERE id=xx`).
This should go like this :
```
using (OracleDataReader odr=command.Execut... |
184,537 | <p>I see in C++ there are multiple ways to allocate and free data and I understand that when you call <code>malloc</code> you should call <code>free</code> and when you use the <code>new</code> operator you should pair with <code>delete</code> and it is a mistake to mix the two (e.g. Calling <code>free()</code> on some... | [
{
"answer_id": 184540,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 9,
"selected": false,
"text": "<p>Unless you are forced to use C, you should <strong>never use</strong> <code>malloc</code>. Always use <code>new</... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I see in C++ there are multiple ways to allocate and free data and I understand that when you call `malloc` you should call `free` and when you use the `new` operator you should pair with `delete` and it is a mistake to mix the two (e.g. Calling `free()` on something that was created with the `new` operator), but I'm n... | Unless you are forced to use C, you should **never use** `malloc`. Always use `new`.
If you need a big chunk of data just do something like:
```
char *pBuffer = new char[1024];
```
Be careful though this is not correct:
```
//This is incorrect - may delete only one element, may corrupt the heap, or worse...
delete... |
184,550 | <p>I am currently using Rails 2.1.0 and want to upgrade to Rails 2.1.1. After issuing the following command </p>
<pre><code>gem update rails
</code></pre>
<p>I suppose that I need to change this line </p>
<pre><code>RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
</code></pre>
<p>in environment.rb</p>... | [
{
"answer_id": 184608,
"author": "Adam",
"author_id": 13320,
"author_profile": "https://Stackoverflow.com/users/13320",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I know, that right there defines what version of rails your application as a whole will use. I know for a projec... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14755/"
] | I am currently using Rails 2.1.0 and want to upgrade to Rails 2.1.1. After issuing the following command
```
gem update rails
```
I suppose that I need to change this line
```
RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
```
in environment.rb
What other actions should I take to ensure that my ... | You'll also need to go into your application directory and run the following command:
rake rails:update
Then run your tests and make sure everything works. |
184,560 | <p>I downloaded a VM image of a web application that uses MySQL.</p>
<p>How can I monitor its space consumption and know when additional space must be added?</p>
| [
{
"answer_id": 184726,
"author": "MaxVT",
"author_id": 19530,
"author_profile": "https://Stackoverflow.com/users/19530",
"pm_score": 2,
"selected": false,
"text": "<p>If only MySQL is available, use the SHOW TABLE STATUS command, and look at the Data_length column for each table, which i... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15884/"
] | I downloaded a VM image of a web application that uses MySQL.
How can I monitor its space consumption and know when additional space must be added? | I have some great big queries to share:
Run this to get the Total MySQL Data and Index Usage By Storage Engine
```
SELECT IFNULL(B.engine,'Total') "Storage Engine",
CONCAT(LPAD(REPLACE(FORMAT(B.DSize/POWER(1024,pw),3),',',''),17,' '),' ',
SUBSTR(' KMGTP',pw+1,1),'B') "Data Size", CONCAT(LPAD(REPLACE(
FORMAT(B.ISize/P... |
184,590 | <p>Is there a way to do this in one line?</p>
<pre><code>$x =~ s/^\s+//;
$x =~ s/\s+$//;
</code></pre>
<p>In other words, remove all leading and trailing whitespace from a string.</p>
| [
{
"answer_id": 184610,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 2,
"selected": false,
"text": "<p>Here you go: <code>$x =~ s/\\A\\s*(.*?)\\s*\\z/$1/;\n</code></p>\n"
},
{
"answer_id": 184612,
"author": "Lou... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | Is there a way to do this in one line?
```
$x =~ s/^\s+//;
$x =~ s/\s+$//;
```
In other words, remove all leading and trailing whitespace from a string. | ```
$x =~ s/^\s+|\s+$//g;
```
or
```
s/^\s+//, s/\s+$// for $x;
``` |
184,592 | <p>I have topics(id*) and tags(id*,name) and a linking table topic_tags(topicFk*,tagFk*).</p>
<p>Now I want to select every single topic, that has all of the good tags (a,b,c) but none of the bad tags (d,e,f).</p>
<p>How do I do that?</p>
| [
{
"answer_id": 184614,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 2,
"selected": false,
"text": "<p>Here's a solution that would work, but requires a join for every tag you require. </p>\n\n<blockquote>\n<pre><code>SE... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/407880/"
] | I have topics(id\*) and tags(id\*,name) and a linking table topic\_tags(topicFk\*,tagFk\*).
Now I want to select every single topic, that has all of the good tags (a,b,c) but none of the bad tags (d,e,f).
How do I do that? | My own solution using Pauls and Bills ideas.
The idea is to inner join topics with good tags (to throw out topics with no good tags) and then count the unique tags for each topic (to verify that all the good tags are present).
At the same time an outer join with bad tags should have not a single match (all fields are... |
184,609 | <p>Consider the following two ways of writing a loop in Java to see if a list contains a given value:</p>
<h3>Style 1</h3>
<pre><code>boolean found = false;
for(int i = 0; i < list.length && !found; i++)
{
if(list[i] == testVal)
found = true;
}
</code></pre>
<h3>Style 2</h3>
<pre><code>boolean fo... | [
{
"answer_id": 184623,
"author": "sepang",
"author_id": 25930,
"author_profile": "https://Stackoverflow.com/users/25930",
"pm_score": 1,
"selected": false,
"text": "<p>It depends on what compiler you use since different compilers might do different optimizations.</p>\n"
},
{
"ans... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | Consider the following two ways of writing a loop in Java to see if a list contains a given value:
### Style 1
```
boolean found = false;
for(int i = 0; i < list.length && !found; i++)
{
if(list[i] == testVal)
found = true;
}
```
### Style 2
```
boolean found = false;
for(int i = 0; i < list.length && !fou... | Well, just write a micro benchmark:
```
import java.util.*;
public class Test {
private static int[] list = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9} ;
private static int testVal = 6;
public static boolean version1() {
boolean found = false;
for(int i = 0; i < list.length && !found; i++)
... |
184,618 | <p>What is the best comment in source code you have ever encountered?</p>
| [
{
"answer_id": 184629,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 5,
"selected": false,
"text": "<pre><code>//ALL YOUR BASE ARE BELONG TO US\n</code></pre>\n\n<p>...it made my boss think someone had h... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15985/"
] | What is the best comment in source code you have ever encountered? | I am particularly guilty of this, embedding non-constructive comments, code poetry and little jokes into most of my projects (although I usually have enough sense to remove anything directly offensive before releasing the code). Here's one I'm particulary fond of, placed far, far down a poorly-designed 'God Object':
`... |
184,641 | <p>I have a mysql table with albums. Each album can be a top level album, or a child album of another album. Each album has a foldername which is the name of the folder its pictures are in. Each album also has a field called parent which is the id of the parent album. So, if I have a path to an image like this:</p>
<p... | [
{
"answer_id": 185255,
"author": "BoltBait",
"author_id": 20848,
"author_profile": "https://Stackoverflow.com/users/20848",
"pm_score": 0,
"selected": false,
"text": "<p>Totally untested and typed off the top of my head...</p>\n\n<pre><code>DECLARE @FOLDER VARCHAR(200)\nDECLARE @TOPID AS... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1585/"
] | I have a mysql table with albums. Each album can be a top level album, or a child album of another album. Each album has a foldername which is the name of the folder its pictures are in. Each album also has a field called parent which is the id of the parent album. So, if I have a path to an image like this:
```
root/... | I'm not sure storing a tree in Database is a good idea...
To keep your problem simple maybe just store the full path of an album in a column of your table...
```
id parent path foldername
1 NULL / root
2 1 /root/ album1
3 2 /root/album1/ album2
``` |
184,643 | <p>What is the best way to copy a list? I know the following ways, which one is better? Or is there another way?</p>
<pre><code>lst = ['one', 2, 3]
lst1 = list(lst)
lst2 = lst[:]
import copy
lst3 = copy.copy(lst)
</code></pre>
| [
{
"answer_id": 184660,
"author": "Mark Roddy",
"author_id": 9940,
"author_profile": "https://Stackoverflow.com/users/9940",
"pm_score": 8,
"selected": true,
"text": "<p>If you want a shallow copy (elements aren't copied) use:</p>\n\n<pre><code>lst2=lst1[:]\n</code></pre>\n\n<p>If you wan... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4915/"
] | What is the best way to copy a list? I know the following ways, which one is better? Or is there another way?
```
lst = ['one', 2, 3]
lst1 = list(lst)
lst2 = lst[:]
import copy
lst3 = copy.copy(lst)
``` | If you want a shallow copy (elements aren't copied) use:
```
lst2=lst1[:]
```
If you want to make a deep copy then use the copy module:
```
import copy
lst2=copy.deepcopy(lst1)
``` |
184,662 | <p>In our product we have a big utilities file that we require (with <code>do</code>) at the beginning of a lot of our files. Is there a reason <em>not</em> to turn this into a module? For example, instead of doing this:</p>
<pre><code>do '../dbi_utilities.pl';
our ($db,$user,$pw,$attr);
my $Data = DBI->connect($... | [
{
"answer_id": 184687,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 2,
"selected": false,
"text": "<p>Making a module out of it will make it a lot more robust. Right now a lot of things informally depend on each oth... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] | In our product we have a big utilities file that we require (with `do`) at the beginning of a lot of our files. Is there a reason *not* to turn this into a module? For example, instead of doing this:
```
do '../dbi_utilities.pl';
our ($db,$user,$pw,$attr);
my $Data = DBI->connect($db,$user,$pw,$attr) or die "Could not... | The only reason not to do this is time.
That is, it'll take time to clean up your interface, as well as all calling apps to use the new interface.
What it'll cost you in time now will be more than made up when you start using proper tests ("make test" or "./Build test" or just "prove ...") and be able to check that y... |
184,678 | <p>I'm using SimpleDateFormat with the pattern <code>EEE MM/dd hh:mma</code>, passing in the date String <code>Thu 10/9 08:15PM</code> and it's throwing an Unparseable date exception. Why? I've used various patterns with <code>SimpleDateFormat</code> before so I'm fairly familiar with its usage. Maybe I'm missing som... | [
{
"answer_id": 184694,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>Try this instead for your pattern:</p>\n\n<pre><code>EEE MM/d hh:mma\n</code></pre>\n\n<p>The difference is the sin... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26270/"
] | I'm using SimpleDateFormat with the pattern `EEE MM/dd hh:mma`, passing in the date String `Thu 10/9 08:15PM` and it's throwing an Unparseable date exception. Why? I've used various patterns with `SimpleDateFormat` before so I'm fairly familiar with its usage. Maybe I'm missing something obvious from staring at it too ... | To test if it's the date format, write a test class to prove it out. For these types of things, I like to use bsh (beanshell). Here was my test:
```
sdf = new java.text.SimpleDateFormat("EEE MM/dd hh:mma");
System.out.println(sdf.format(sdf.parse("Thu 10/9 08:15PM")));
```
Which outputted: Fri 10/09 08:15PM
So, at ... |
184,681 | <p>Which of these pieces of code is faster?</p>
<pre><code>if (obj is ClassA) {}
if (obj.GetType() == typeof(ClassA)) {}
</code></pre>
<p>Edit:
I'm aware that they don't do the same thing.</p>
| [
{
"answer_id": 184697,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 8,
"selected": true,
"text": "<p><a href=\"https://learn.microsoft.com/en-us/archive/blogs/vancem/drilling-into-net-runtime-microbenchmarks-typeof-optimiz... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | Which of these pieces of code is faster?
```
if (obj is ClassA) {}
if (obj.GetType() == typeof(ClassA)) {}
```
Edit:
I'm aware that they don't do the same thing. | [This should answer that question, and then some.](https://learn.microsoft.com/en-us/archive/blogs/vancem/drilling-into-net-runtime-microbenchmarks-typeof-optimizations)
The second line, `if (obj.GetType() == typeof(ClassA)) {}`, is faster, for those that don't want to read the article.
*(Be aware that they don't do ... |
184,683 | <p>Is there a way in C# to play audio (for example, MP3) direcly from a <a href="http://msdn.microsoft.com/en-us/library/system.io.stream%28v=vs.110%29.aspx" rel="noreferrer">System.IO.Stream</a> that for instance was returend from a WebRequest without saving the data temporarily to the disk?</p>
<hr>
<h3>Solution wi... | [
{
"answer_id": 184796,
"author": "OwenP",
"author_id": 2547,
"author_profile": "https://Stackoverflow.com/users/2547",
"pm_score": 3,
"selected": false,
"text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/w5bfdtza.aspx\" rel=\"noreferrer\">SoundPlayer</a> class can do this.... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25782/"
] | Is there a way in C# to play audio (for example, MP3) direcly from a [System.IO.Stream](http://msdn.microsoft.com/en-us/library/system.io.stream%28v=vs.110%29.aspx) that for instance was returend from a WebRequest without saving the data temporarily to the disk?
---
### Solution with [NAudio](https://github.com/naudi... | **Edit: Answer updated to reflect changes in recent versions of NAudio**
It's possible using the [NAudio](https://github.com/naudio/NAudio) open source .NET audio library I have written. It looks for an ACM codec on your PC to do the conversion. The Mp3FileReader supplied with NAudio currently expects to be able to re... |
184,703 | <p>I have a form that is sending in sizes of things, and I need to see what the strings are equal to so that I can set the price accordingly. When i try to do this, it says that they are not equal, and i get no prices. This is the code i'm using:</p>
<pre><code>if ($_POST['sizes'] == "Small ($30)"){$total = "30";}
if ... | [
{
"answer_id": 184737,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 1,
"selected": false,
"text": "<p>Try using single quotes</p>\n\n<pre><code>if ($_POST['sizes'] == 'Small ($30)'){$total = \"30\";}\nelseif ($_POST['siz... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50/"
] | I have a form that is sending in sizes of things, and I need to see what the strings are equal to so that I can set the price accordingly. When i try to do this, it says that they are not equal, and i get no prices. This is the code i'm using:
```
if ($_POST['sizes'] == "Small ($30)"){$total = "30";}
if ($_POST['sizes... | What [Paul Dixon said](https://stackoverflow.com/questions/184703/compare-strings-given-in-post-with-php/184737#184737) is correct. Might I also recommend using a switch statement instead of that clunky chunk of if statements (which actually has a logic bug in it, I might add - `$total` will always equal `$_POST['price... |
184,704 | <p>In Java, is there an elegant way to detect if an exception occurred prior to running the finally block? When dealing with "close()" statements, it's common to need exception handling within the finally block. Ideally, we'd want to maintain both exceptions and propagate them up (as both of them may contain useful inf... | [
{
"answer_id": 184715,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>You could always set a boolean flag in your catch(es). I don't know of any \"slick\" way to do it, but then I'm mo... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17871/"
] | In Java, is there an elegant way to detect if an exception occurred prior to running the finally block? When dealing with "close()" statements, it's common to need exception handling within the finally block. Ideally, we'd want to maintain both exceptions and propagate them up (as both of them may contain useful inform... | Your idea about setting a variable outside the scope of the try/catch/finally is correct.
There cannot be more than one exception propagating at once. |
184,721 | <p>I have a windows c# application and I want to display a pdf file, located on a webserver, in an acrobat com object added to my form. </p>
<pre><code>pdf.loadfile(@"http://somewhere.com/nowwhere.pdf")
</code></pre>
<p>As my pdf is large, the application seems to hang till the entire file is loaded. </p>
<p>I want ... | [
{
"answer_id": 184741,
"author": "wax eagle",
"author_id": 1001650,
"author_profile": "https://Stackoverflow.com/users/1001650",
"pm_score": 1,
"selected": false,
"text": "<p>Three suggestions. </p>\n\n<p>the first would be to break it and load a page at a time like some online books do.... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a windows c# application and I want to display a pdf file, located on a webserver, in an acrobat com object added to my form.
```
pdf.loadfile(@"http://somewhere.com/nowwhere.pdf")
```
As my pdf is large, the application seems to hang till the entire file is loaded.
I want to read the large file without th... | I would do the following:
1. Create another thread to import the pdf.
2. Display some kind of a progress bar to the user. perhaps with a cancel button. |
184,729 | <p>After reading Martin Fowler's <a href="http://martinfowler.com/articles/mocksArentStubs.html" rel="nofollow noreferrer">Mocks Aren't Stubs</a>, I've discovered I've been practicing TDD in the "mockist" fashion.</p>
<p>But I'm wondering if even in mockist TDD if one can take mocking too far.</p>
<p>Here's an <stron... | [
{
"answer_id": 184806,
"author": "Mendelt",
"author_id": 3320,
"author_profile": "https://Stackoverflow.com/users/3320",
"pm_score": 1,
"selected": false,
"text": "<p><strong>edited for the new example</strong><br>\nTo me it looks like you're stubbing confirm_or_create_connection, you're... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4766/"
] | After reading Martin Fowler's [Mocks Aren't Stubs](http://martinfowler.com/articles/mocksArentStubs.html), I've discovered I've been practicing TDD in the "mockist" fashion.
But I'm wondering if even in mockist TDD if one can take mocking too far.
Here's an **updated** example in Python-style pseudo-code:
```
def sy... | The technique is called "mock objects", not "mock methods" for a reason. It encourages designs that divide the system into easily composed, collaborating objects and away from procedural code. The aim is to raise the level of abstraction so that you mostly program by composing objects and rarely write low-level control... |
184,766 | <p>I believe the simplest way to request data from a server in XML format is to have a PHP/JSP/ASP.net page which actually generates XML based on HTTP GET params, and to somehow call/load this page from Flex.</p>
<p>How exactly can this be achieved using the Flex library classes?</p>
| [
{
"answer_id": 184787,
"author": "MidnightGun",
"author_id": 13220,
"author_profile": "https://Stackoverflow.com/users/13220",
"pm_score": 1,
"selected": false,
"text": "<p>Never mind, found it: <a href=\"http://livedocs.adobe.com/flex/3/langref/flash/net/URLLoader.html\" rel=\"nofollow ... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13220/"
] | I believe the simplest way to request data from a server in XML format is to have a PHP/JSP/ASP.net page which actually generates XML based on HTTP GET params, and to somehow call/load this page from Flex.
How exactly can this be achieved using the Flex library classes? | I'd like to add that you can also use [mx:HTTPService](http://livedocs.adobe.com/flex/201/langref/mx/rpc/http/mxml/HTTPService.html). If you specify the returnFormat attribute, you would get an XML document as opposed to simple text:
```
<mx:HTTPService resultFormat="e4x" ..../> or <mx:HTTPService resultFormat="xml" ... |
184,782 | <p>I'm a doing some blackbox testing of a ASP.Net website and I need to test different session timeout scenarios. </p>
<p>I'm not sure they fully encapsulated session timeouts. Other then leaving a page open for 20 minutes is there an easier way to force a session timeout?</p>
| [
{
"answer_id": 184784,
"author": "Chris Cudmore",
"author_id": 18907,
"author_profile": "https://Stackoverflow.com/users/18907",
"pm_score": 1,
"selected": false,
"text": "<p>Recycle the app pool on the server.</p>\n"
},
{
"answer_id": 184786,
"author": "John Sheehan",
"a... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6161/"
] | I'm a doing some blackbox testing of a ASP.Net website and I need to test different session timeout scenarios.
I'm not sure they fully encapsulated session timeouts. Other then leaving a page open for 20 minutes is there an easier way to force a session timeout? | **Decrease the timeout**
The easiest and most non-intrusive way to test this is probably to just decrease the timeout to a fairly small number, such as 3 or 5 minutes. This way you can pause for a few minutes to simulate a longer pause without worrying about application restarts or special reset code having any affect... |
184,813 | <p>I have a (Wordpress powered) website, and Google is indexing some of the sub-directories. How can I stop Apache from showing users the directory listing? I know I can edit .htaccess to password-protect a directory, but I would prefer a 403 / custom redirect if possible.</p>
| [
{
"answer_id": 184820,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 2,
"selected": false,
"text": "<p>Look at your robots.txt rules, and make sure apache is not serving-up directory listings.</p>\n\n<p>see <a href=\"http://h... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4812/"
] | I have a (Wordpress powered) website, and Google is indexing some of the sub-directories. How can I stop Apache from showing users the directory listing? I know I can edit .htaccess to password-protect a directory, but I would prefer a 403 / custom redirect if possible. | You need this entry in your `.htaccess` file:
```
Options -Indexes
``` |
184,853 | <p>I swear there used to be a way in X to start capturing all terminal traffic to a file on your host. It may have been a HummingBird extension, but I thought it was standard. Now, I can't find the trick. Am I hallucinating (happens when you get old), or is it possible?<br><br>I'm not talking about 'tee'. I want to be ... | [
{
"answer_id": 184867,
"author": "André",
"author_id": 9683,
"author_profile": "https://Stackoverflow.com/users/9683",
"pm_score": 0,
"selected": false,
"text": "<p>I am a little bit confused by the way you asked your question. First you mention Xterm then X and then terminal, are you si... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14028/"
] | I swear there used to be a way in X to start capturing all terminal traffic to a file on your host. It may have been a HummingBird extension, but I thought it was standard. Now, I can't find the trick. Am I hallucinating (happens when you get old), or is it possible?
I'm not talking about 'tee'. I want to be able to... | This feature is called logging and exists in the source code but is disabled by default for security reasons. Do you really want everyone with the ability to write control sequences to your terminal (*e.g.*, the author of any file you might one day `cat`) to be able to write arbitrary data to arbitrarily-named files un... |
184,858 | <p>I want to make a link call a Javascript function through the onclick event and not do anything else (follow the link). What is the best way to do that? I usually do this:</p>
<pre><code><a href="#" onclick="foo()">Click</a>
</code></pre>
<p>But I'm not sure that is the best way and in this case it is n... | [
{
"answer_id": 184876,
"author": "Chris Cudmore",
"author_id": 18907,
"author_profile": "https://Stackoverflow.com/users/18907",
"pm_score": 0,
"selected": false,
"text": "<pre><code><a href=\"javascript: foo()\" >Click</a>\n</code></pre>\n"
},
{
"answer_id": 184877,
... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4915/"
] | I want to make a link call a Javascript function through the onclick event and not do anything else (follow the link). What is the best way to do that? I usually do this:
```
<a href="#" onclick="foo()">Click</a>
```
But I'm not sure that is the best way and in this case it is navigating to page.html# which isn't go... | Usually, you should always have a fall back link to make sure that clients with JavaScript disabled still has some functionality. This concept is called unobtrusive JavaScript. Example... Let's say you have the following search link:
```
<a href="search.php" id="searchLink">Search</a>
```
You can always do the follo... |
184,863 | <p>To save some typing and clarify my code, is there a standard version of the following method?</p>
<pre><code>public static boolean bothNullOrEqual(Object x, Object y) {
return ( x == null ? y == null : x.equals(y) );
}
</code></pre>
| [
{
"answer_id": 184942,
"author": "Matt",
"author_id": 20630,
"author_profile": "https://Stackoverflow.com/users/20630",
"pm_score": 5,
"selected": false,
"text": "<p>if by some chance you are have access to the Jakarta Commons library there is <a href=\"http://commons.apache.org/lang/api... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | To save some typing and clarify my code, is there a standard version of the following method?
```
public static boolean bothNullOrEqual(Object x, Object y) {
return ( x == null ? y == null : x.equals(y) );
}
``` | With Java 7 you can now directly do a null safe equals:
[Objects.equals(x, y)](http://docs.oracle.com/javase/7/docs/api/java/util/Objects.html)
(The Jakarta Commons library ObjectUtils.equals() has become obsolete with Java 7) |
184,864 | <p>Has anyone had good experiences of talking direct to RPG programs running on a V5R4 iSeries machine from Java? If so, what are the recommendations of the community, and what pitfalls should I try to avoid?</p>
<p>From the various pieces of literature and spike solutions I have attempted it looks as though we can us... | [
{
"answer_id": 185164,
"author": "KC Baltz",
"author_id": 9910,
"author_profile": "https://Stackoverflow.com/users/9910",
"pm_score": 1,
"selected": false,
"text": "<p>We just use JDBC and stored procedures. The stored procedure calls the RPG instead of running SQL. I'm not an RPG prog... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26283/"
] | Has anyone had good experiences of talking direct to RPG programs running on a V5R4 iSeries machine from Java? If so, what are the recommendations of the community, and what pitfalls should I try to avoid?
From the various pieces of literature and spike solutions I have attempted it looks as though we can use ProgramC... | I suggest using IBM's Java Toolbox for Java. Put the JT400.jar into your classpath (or JT400Ntv.jar if the Java is running on the iSeries). I've used both the ProgramCall class and the CommandCall classes.
The com.ibm.as400.access.CommandCall class is easy to use. It has a simple constructor that you pass a com.ibm.as... |
184,878 | <h2>Intro:</h2>
<p>I successfully implemented a WCF Service hosted in a Windows Service a few days ago. The community here at StackOverflow helped me with <a href="https://stackoverflow.com/questions/167852/wsdl-url-for-a-wcf-service-basichttpbinding-hosted-inside-a-windows-service">the WSDL exposure here</a>. I thank... | [
{
"answer_id": 185005,
"author": "James Bender",
"author_id": 22848,
"author_profile": "https://Stackoverflow.com/users/22848",
"pm_score": 5,
"selected": true,
"text": "<p>Your endpoint looks fine, although I'm curious about what's in localBinding...</p>\n\n<p>Sounds like the easiest op... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1796/"
] | Intro:
------
I successfully implemented a WCF Service hosted in a Windows Service a few days ago. The community here at StackOverflow helped me with [the WSDL exposure here](https://stackoverflow.com/questions/167852/wsdl-url-for-a-wcf-service-basichttpbinding-hosted-inside-a-windows-service). I thank you once again.... | Your endpoint looks fine, although I'm curious about what's in localBinding...
Sounds like the easiest option is to just change the endpoint configuration on the named pipes client to match your service endpoint. The client shouldn't care as long as it's the only endpoint in the clients config file. Otherwise you'll h... |
184,927 | <p>I have a webapp which resizes its window to exactly fit its contents:</p>
<pre><code>window.resizeTo(200,300)
</code></pre>
<p>People do like having the page fit its window in this way. However with Firefox the next browser window the user opens comes up at the same size, which is ridiculously small.</p>
<p>Is th... | [
{
"answer_id": 184964,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>People do like having the page fit its window in this way.</p>\n</blockquote>\n\n<p><em>Which</em> people?! I... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4761/"
] | I have a webapp which resizes its window to exactly fit its contents:
```
window.resizeTo(200,300)
```
People do like having the page fit its window in this way. However with Firefox the next browser window the user opens comes up at the same size, which is ridiculously small.
Is there a way to tell Firefox to resi... | Two different questions at work here:
**1. Specifying Window Dimensions-**
Specifying window attributes using **window.open** will not affect the dimensions of other windows.
You are getting the **expected behavior** from Firefox with regards to the resizeTo function.
**2. The User Experience-**
What users value... |
184,970 | <p>I am using partial classes to split some functionality between 2 files, but I am getting an error. What am I doing wrong?</p>
<p>A1.cs:</p>
<pre><code>private partial class A
{
private string SomeProperty { get { return "SomeGeneratedString"; } }
}
</code></pre>
<p>A2.cs:</p>
<pre><code>private parti... | [
{
"answer_id": 184975,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 6,
"selected": true,
"text": "<p>Are the two partial classes in the same namespace? That could be an explanation.</p>\n"
},
{
"answer_id": 184979,
... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] | I am using partial classes to split some functionality between 2 files, but I am getting an error. What am I doing wrong?
A1.cs:
```
private partial class A
{
private string SomeProperty { get { return "SomeGeneratedString"; } }
}
```
A2.cs:
```
private partial class A
{
void SomeFunction()
{
... | Are the two partial classes in the same namespace? That could be an explanation. |
184,985 | <p>I seem to be having an issue with iPhone SDK 2.1 in as far as being
able to establish a relationship between a ViewController and a View
window. In as far as a Cocoa Touch Class, I went forward and added a
<code>UIViewController</code> subclass. I made sure that the target is part of the
existing project. Right afte... | [
{
"answer_id": 184975,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 6,
"selected": true,
"text": "<p>Are the two partial classes in the same namespace? That could be an explanation.</p>\n"
},
{
"answer_id": 184979,
... | 2008/10/08 | [
"https://Stackoverflow.com/questions/184985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I seem to be having an issue with iPhone SDK 2.1 in as far as being
able to establish a relationship between a ViewController and a View
window. In as far as a Cocoa Touch Class, I went forward and added a
`UIViewController` subclass. I made sure that the target is part of the
existing project. Right afterwards I added... | Are the two partial classes in the same namespace? That could be an explanation. |
185,004 | <p>I just noticed that java.beans.Introspector getBeanInfo does not pickup any superinterface's properties. Example:</p>
<pre><code>public interface Person {
String getName();
}
public interface Employee extends Person {
int getSalary();
}
</code></pre>
<p>Introspecting on Employee only yields salary even tho... | [
{
"answer_id": 185959,
"author": "MetroidFan2002",
"author_id": 8026,
"author_profile": "https://Stackoverflow.com/users/8026",
"pm_score": 1,
"selected": false,
"text": "<p>Try using</p>\n\n<pre><code>public static BeanInfo getBeanInfo(Class<?> beanClass, Introspector.USE_ALL_BEAN... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | I just noticed that java.beans.Introspector getBeanInfo does not pickup any superinterface's properties. Example:
```
public interface Person {
String getName();
}
public interface Employee extends Person {
int getSalary();
}
```
Introspecting on Employee only yields salary even though name is inherited from... | This issue is covered in Sun bug
[java.beans.Introspector doesn't work for interfaces](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4275879) |
185,034 | <p>Is there a way to test the type of an element in JavaScript? </p>
<p>The answer may or may not require the prototype library, however the following setup does make use of the library.</p>
<pre><code>function(event) {
var element = event.element();
// if the element is an anchor
...
// if the element is a t... | [
{
"answer_id": 185039,
"author": "bobwienholt",
"author_id": 24257,
"author_profile": "https://Stackoverflow.com/users/24257",
"pm_score": 6,
"selected": false,
"text": "<pre><code>if (element.nodeName == "A") {\n ...\n} else if (element.nodeName == "TD") {\n ...\n}\n... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4682/"
] | Is there a way to test the type of an element in JavaScript?
The answer may or may not require the prototype library, however the following setup does make use of the library.
```
function(event) {
var element = event.element();
// if the element is an anchor
...
// if the element is a td
...
}
``` | You can use `typeof(N)` to get the actual object type, but what you want to do is check the tag, not the type of the DOM element.
In that case, use the `elem.tagName` or `elem.nodeName` property.
if you want to get really creative, you can use a dictionary of tagnames and anonymous closures instead if a switch or if/... |
185,042 | <p><strong>Environment:</strong><br/>
Windows Server 2003 R2 Enterprise 64bit, SP2<br/>
.NET framework is supposedly installed (2.0 SP2, 3.0 SP2, 3.5 SP1)</p>
<p>I say "supposedly" because they are listed as installed under Add/Remove programs. I'm not sure it's <em>properly</em> installed, because the "ASP.NET" tab i... | [
{
"answer_id": 185056,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 4,
"selected": true,
"text": "<p>Have you tried running:</p>\n\n<pre><code>aspnet_regiis -i\n</code></pre>\n\n<p>from the command line?</p>\n"
},
{... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751/"
] | **Environment:**
Windows Server 2003 R2 Enterprise 64bit, SP2
.NET framework is supposedly installed (2.0 SP2, 3.0 SP2, 3.5 SP1)
I say "supposedly" because they are listed as installed under Add/Remove programs. I'm not sure it's *properly* installed, because the "ASP.NET" tab isn't added to any of the sites in ... | Have you tried running:
```
aspnet_regiis -i
```
from the command line? |
185,072 | <p>I took the plunge this afternoon and began studying LINQ, so far just mucking around with LINQ on collections. One of the first things I tried was to implement QSort.</p>
<p>Now -- ignoring the fact that I <em>could</em> just use an ORDERBY and that this is a very silly qsort implementation -- what I came up with ... | [
{
"answer_id": 185128,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 2,
"selected": false,
"text": "<p>How about this? (If I understand well you don't like the .ToList calls)</p>\n\n<pre><code>public static IEnumerable<int&... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7856/"
] | I took the plunge this afternoon and began studying LINQ, so far just mucking around with LINQ on collections. One of the first things I tried was to implement QSort.
Now -- ignoring the fact that I *could* just use an ORDERBY and that this is a very silly qsort implementation -- what I came up with was this:
```
pub... | Just change the type of the parameter to `IEnumerable` and use the `var` construct instead of your `List<int>` for your local variables.
This will make your `QSLinq` method better because it will accept more types of parameters, for example `int[]`, as well as `List<int>`.
See the new method:
```
public static I... |
185,073 | <p>I'm trying to call into a C++ library from Perl on an AIX 5.1 machine. I've created a very simple test project to try to exercise this.</p>
<p>My C++ shared library (<code>test.cpp</code>):</p>
<pre><code>#include <stdio.h>
#include <iostream>
void myfunc()
{
printf("in myfunc()\n");
std::cou... | [
{
"answer_id": 185118,
"author": "Tanktalus",
"author_id": 23512,
"author_profile": "https://Stackoverflow.com/users/23512",
"pm_score": 2,
"selected": false,
"text": "<p>Wouldn't you just add your libstdc++ to your ld command? e.g., <code>-lstdc++</code>?</p>\n\n<p>What I did on Linux,... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26302/"
] | I'm trying to call into a C++ library from Perl on an AIX 5.1 machine. I've created a very simple test project to try to exercise this.
My C++ shared library (`test.cpp`):
```
#include <stdio.h>
#include <iostream>
void myfunc()
{
printf("in myfunc()\n");
std::cout << "in myfunc() also" << std::endl;
}
```
... | Wouldn't you just add your libstdc++ to your ld command? e.g., `-lstdc++`?
What I did on Linux, after replicating your problem was:
```
gcc -g -lstdc++ -shared test*.o -o test.so
```
Then the problem went away.
(Trying to get the exact right list of libraries for ld was too much work, so I just told gcc to do it f... |
185,091 | <p>I got a very similar error to the one below:</p>
<p><a href="https://stackoverflow.com/questions/97800/how-can-i-fix-this-delphi-7-compile-error-duplicate-resources">How can I fix this delphi 7 compile error - "Duplicate resource(s)"</a></p>
<p>However, the error I got is this:</p>
<pre><code> [Error] ... | [
{
"answer_id": 185100,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 3,
"selected": true,
"text": "<p>Try renaming Manufacturing,res to Manufacturing.bak or something. Delphi should recreate the res file.</p>\n\n<p>You w... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26305/"
] | I got a very similar error to the one below:
[How can I fix this delphi 7 compile error - "Duplicate resource(s)"](https://stackoverflow.com/questions/97800/how-can-i-fix-this-delphi-7-compile-error-duplicate-resources)
However, the error I got is this:
```
[Error] WARNING. Duplicate resource(s):
[Error] Type ... | Try renaming Manufacturing,res to Manufacturing.bak or something. Delphi should recreate the res file.
You would of course need to recreate any references, strings etc in the res file in the new one, but worth trying anyway... |
185,101 | <p>I have an XSL stylesheet with content in an <code>xsl:text</code> node like this:</p>
<pre><code><xsl:text>
foo
bar
baz
</xsl:text>
</code></pre>
<p>The stylesheet itself is a text file with "unix-style" newline line terminators. I invoke this stylesheet on Windows as well as unix-like platforms. It wo... | [
{
"answer_id": 185231,
"author": "Jen A",
"author_id": 12979,
"author_profile": "https://Stackoverflow.com/users/12979",
"pm_score": 1,
"selected": false,
"text": "<p>Im not sure how to do the correct newlines automatically (it may depend on the xslt processor you are using), but you may... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13940/"
] | I have an XSL stylesheet with content in an `xsl:text` node like this:
```
<xsl:text>
foo
bar
baz
</xsl:text>
```
The stylesheet itself is a text file with "unix-style" newline line terminators. I invoke this stylesheet on Windows as well as unix-like platforms. It would be nice to have the output conform to the con... | You could define a parameter for the stylesheet like so:
```
<xsl:param name="br">
<xsl:text> </xsl:text>
</xsl:param>
```
and pass in the appropriate end of line character(s) by using a nested param element in your Ant script. The default in this example would be a Unix-style newline, of course. I think to ... |
185,110 | <p>Can you please let me know the SQL to split date ranges when they overlap?</p>
<p>Data (sample data with a date range and possibly other columns):</p>
<pre><code> Col1 FromDate ToDate
1. 1 1/1/2008 31/12/2010
2. 1 1/1/2009 31/12/2012
3. 1 1/1/2009 31/12/2014
</code></pre>
<p>Output:</p>
<pre><code... | [
{
"answer_id": 185305,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 3,
"selected": false,
"text": "<p>This should do the trick (MySQL dialect, but easily adaptable)</p>\n\n<p>Initial setup</p>\n\n<pre><code>SQL query: SELEC... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26309/"
] | Can you please let me know the SQL to split date ranges when they overlap?
Data (sample data with a date range and possibly other columns):
```
Col1 FromDate ToDate
1. 1 1/1/2008 31/12/2010
2. 1 1/1/2009 31/12/2012
3. 1 1/1/2009 31/12/2014
```
Output:
```
Col1 From Date ToDate
1. 1 1/1/2008... | This should do the trick (MySQL dialect, but easily adaptable)
Initial setup
```
SQL query: SELECT * FROM `test` LIMIT 0, 30 ;
Rows: 3
start end
2008-01-01 2010-12-31
2009-01-01 2012-12-31
2009-01-01 2014-12-31
```
Query
```
SELECT
`start` , min( `end` )
FROM (
SELECT t1.start, t2.end
FROM test t1,... |
185,112 | <p>I have a bit of html like so:</p>
<pre><code><a href="#somthing" id="a1"><img src="something" /></a>
<a href="#somthing" id="a2"><img src="something" /></a>
</code></pre>
<p>I need to strip off the links so I'm just left with a couple of image tags. What would be the most effici... | [
{
"answer_id": 185140,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 4,
"selected": true,
"text": "<pre><code>$(\"a > img\").parent() // match all <a><img></a>, select <a> parents\n .each( function... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6007/"
] | I have a bit of html like so:
```
<a href="#somthing" id="a1"><img src="something" /></a>
<a href="#somthing" id="a2"><img src="something" /></a>
```
I need to strip off the links so I'm just left with a couple of image tags. What would be the most efficient way to do this with jQuery? | ```
$("a > img").parent() // match all <a><img></a>, select <a> parents
.each( function() // for each link
{
$(this).replaceWith( // replace the <a>
$(this).children().remove() ); // with its detached children.
});
``` |
185,114 | <p>I have a module in the parent directory of my script and I would like to 'use' it.</p>
<p>If I do</p>
<pre><code>use '../Foo.pm';
</code></pre>
<p>I get syntax errors.</p>
<p>I tried to do:</p>
<pre><code>push @INC, '..';
use EPMS;
</code></pre>
<p>and .. apparently doesn't show up in @INC</p>
<p>I'm going cr... | [
{
"answer_id": 185120,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 2,
"selected": false,
"text": "<p>You have to have the <code>push</code> processed before the <code>use</code> is -- and <code>use</code> is pro... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] | I have a module in the parent directory of my script and I would like to 'use' it.
If I do
```
use '../Foo.pm';
```
I get syntax errors.
I tried to do:
```
push @INC, '..';
use EPMS;
```
and .. apparently doesn't show up in @INC
I'm going crazy! What's wrong here? | `use` takes place at compile-time, so this would work:
```
BEGIN {push @INC, '..'}
use EPMS;
```
But the better solution is to `use lib`, which is a nicer way of writing the above:
```
use lib '..';
use EPMS;
```
In case you are running from a different directory, though, the use of `FindBin` is recommended:
```... |
185,124 | <p>Say if I have a dropdown in a form and I have another nested class inside of this class .
Now what's the best way to access this dropdown from the nested class? </p>
| [
{
"answer_id": 185144,
"author": "Ray Hayes",
"author_id": 7093,
"author_profile": "https://Stackoverflow.com/users/7093",
"pm_score": 7,
"selected": false,
"text": "<p>Unlike Java, a nested class isn't a special \"inner class\" so you'd need to pass a reference. Raymond Chen has an exa... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Say if I have a dropdown in a form and I have another nested class inside of this class .
Now what's the best way to access this dropdown from the nested class? | Unlike Java, a nested class isn't a special "inner class" so you'd need to pass a reference. Raymond Chen has an example describing the differences here : [C# nested classes are like C++ nested classes, not Java inner classes](https://devblogs.microsoft.com/oldnewthing/?p=30273).
Here is an example where the construct... |
185,141 | <p>I have a simple panel that is used as a drawing surface. The goal here is to draw a 4 pixel wide outline around a child ListView under certain circumstances. I would like to make the outline pulsate when something can be dragged into it. </p>
<p>I am just drawing a simple rectangle around the ListView and updati... | [
{
"answer_id": 185168,
"author": "rice",
"author_id": 23933,
"author_profile": "https://Stackoverflow.com/users/23933",
"pm_score": 1,
"selected": false,
"text": "<p>I don't have a strong answer, but since you have none, I'll post anyway:</p>\n\n<p>First, I have never used the System.Dra... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1053/"
] | I have a simple panel that is used as a drawing surface. The goal here is to draw a 4 pixel wide outline around a child ListView under certain circumstances. I would like to make the outline pulsate when something can be dragged into it.
I am just drawing a simple rectangle around the ListView and updating the opacit... | I stumbled on a solution for this if anyone is interested. It turns out that the flashing is caused by the painting of the background. I used SetStyle to tell the control that I will be handling all of the painting.
```
SetStyle(ControlStyles.SupportsTransparentBackColor |
ControlStyles.Opaque |
Con... |
185,149 | <p>Please take a look at the html listed below and let me know why IE6 freezes when trying to load the remote script (located at '<a href="http://code.katzenbach.com/Default.aspx" rel="nofollow noreferrer">http://code.katzenbach.com/Default.aspx</a>'). The script returns JSONP and executes the 'callbackFunction' liste... | [
{
"answer_id": 185188,
"author": "cllpse",
"author_id": 20946,
"author_profile": "https://Stackoverflow.com/users/20946",
"pm_score": 0,
"selected": false,
"text": "<p>The return is of the external script is:</p>\n\n<pre><code>callbackFunction([\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21832/"
] | Please take a look at the html listed below and let me know why IE6 freezes when trying to load the remote script (located at '<http://code.katzenbach.com/Default.aspx>'). The script returns JSONP and executes the 'callbackFunction' listed in the header. When it runs correctly, you'll see a pop-up alert showing numbers... | If you go directly to the script (<http://code.katzenbach.com/Default.aspx?callback=callbackFunction&test=true&c=500>), you'll see the file (unknown mime type) is not being processed. This is likely due to a problem with your server setup. It doesn't seem to know how to process .aspx and in instead trying to stream out... |
185,187 | <p>I have created a common library at work, and it is installed in the GAC on our test server. I've recently updated it and I want all of our applications to be using the update. I created a publisher policy assembly and installed it in the GAC along with the update, but when a web app loads Leggett.Common, 1.0.0.0, it... | [
{
"answer_id": 185202,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 0,
"selected": false,
"text": "<p>Absolutely not. Utility modules over time turn into large collections of cruddy code.</p>\n"
},
{
"answe... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3226/"
] | I have created a common library at work, and it is installed in the GAC on our test server. I've recently updated it and I want all of our applications to be using the update. I created a publisher policy assembly and installed it in the GAC along with the update, but when a web app loads Leggett.Common, 1.0.0.0, it is... | You're talking about code that would be shared library stuff. Static methods do have a place in shared libs. Check out System.Linq.Enumerable
I'd follow these guidelines:
* These aren't static methods by default. They should only be static methods because they are naturally stateless (behavior only depend on paramete... |
185,203 | <p>I'm mostly familiar with Java, C and C++ in which there are ways to control that only one thread is accessing a resource at any given time. Now I'm in search for something similar but in PHP 5.x.</p>
<p>To formulate my problem with one example:</p>
<p>I have an ASCII-file which only stores a number, the value of a... | [
{
"answer_id": 185218,
"author": "terson",
"author_id": 22974,
"author_profile": "https://Stackoverflow.com/users/22974",
"pm_score": 4,
"selected": true,
"text": "<p>You could try php's variant of flock (<a href=\"http://www.php.net/flock\" rel=\"noreferrer\">http://www.php.net/flock</a... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm mostly familiar with Java, C and C++ in which there are ways to control that only one thread is accessing a resource at any given time. Now I'm in search for something similar but in PHP 5.x.
To formulate my problem with one example:
I have an ASCII-file which only stores a number, the value of a page load counte... | You could try php's variant of flock (<http://www.php.net/flock>)
I would envision something similar to (this assumes that the file /tmp/counter.txt already exists and has a counter in the file):
```
<?php
$fp = fopen("/tmp/counter.txt", "r+");
echo "Attempt to lock\n";
if (flock($fp, LOCK_EX)) {
echo "Locked\n";... |
185,208 | <p>How can I get Environnment variables and if something is missing, set the value?</p>
| [
{
"answer_id": 185214,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 9,
"selected": true,
"text": "<p>Use the <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.environment\" rel=\"noreferrer\">System... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14441/"
] | How can I get Environnment variables and if something is missing, set the value? | Use the [System.Environment](https://learn.microsoft.com/en-us/dotnet/api/system.environment) class.
The methods
```
var value = System.Environment.GetEnvironmentVariable(variable [, Target])
```
and
```
System.Environment.SetEnvironmentVariable(variable, value [, Target])
```
will do the job for you.
The opt... |
185,235 | <p>I've previously used <a href="https://jqueryui.com/tabs/" rel="nofollow noreferrer"><code>jquery-ui tabs</code></a> extension to load page fragments via <code>ajax</code>, and to conceal or reveal hidden <code>div</code>s within a page. Both of these methods are well documented, and I've had no problems there.</p>... | [
{
"answer_id": 185257,
"author": "imjoevasquez",
"author_id": 24630,
"author_profile": "https://Stackoverflow.com/users/24630",
"pm_score": 6,
"selected": true,
"text": "<p>I would take a look at the <a href=\"http://docs.jquery.com/UI/Tabs#Events\" rel=\"noreferrer\">events</a> for Tabs... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2554901/"
] | I've previously used [`jquery-ui tabs`](https://jqueryui.com/tabs/) extension to load page fragments via `ajax`, and to conceal or reveal hidden `div`s within a page. Both of these methods are well documented, and I've had no problems there.
Now, however, I want to do something different with tabs. When the user selec... | I would take a look at the [events](http://docs.jquery.com/UI/Tabs#Events) for Tabs. The following is taken from the jQuery docs:
```
$('.ui-tabs-nav').bind('tabsselect', function(event, ui) {
ui.options // options used to intialize this widget
ui.tab // anchor element of the selected (clicked) tab
ui.... |
185,240 | <p>I have an import-from-excel script as part of a CMS that previously ran without issue.</p>
<p>My shared-hosting provider has recently upgraded their infrastructure, including PHP from 5.1 to 5.2.6, and the script now returns "Uninitialized string offset: -XXX in /path/scriptname.php on line 27" (XXX being a decreas... | [
{
"answer_id": 189625,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>Uninitialized string offset:</p>\n</blockquote>\n\n<p>... means that <code>$data</code> is not an array.</p>\... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14979/"
] | I have an import-from-excel script as part of a CMS that previously ran without issue.
My shared-hosting provider has recently upgraded their infrastructure, including PHP from 5.1 to 5.2.6, and the script now returns "Uninitialized string offset: -XXX in /path/scriptname.php on line 27" (XXX being a decreasing number... | >
> Uninitialized string offset:
>
>
>
... means that `$data` is not an array. |
185,252 | <p>I have a Flex application where load time is extremely important (consumer site). i want to be able to get something up on screen and then allow additional modules to be loaded as necessary.</p>
<p>The issue I'm facing is that the sum total of all the modules is much larger than if i were to include all the compone... | [
{
"answer_id": 188095,
"author": "defmeta",
"author_id": 10875,
"author_profile": "https://Stackoverflow.com/users/10875",
"pm_score": 0,
"selected": false,
"text": "<p>You could look into the <a href=\"http://livedocs.adobe.com/flex/3/html/help.html?content=modular_5.html#171081\" rel=\... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24727/"
] | I have a Flex application where load time is extremely important (consumer site). i want to be able to get something up on screen and then allow additional modules to be loaded as necessary.
The issue I'm facing is that the sum total of all the modules is much larger than if i were to include all the components in a s... | I know this was awhile ago, but I figured I'd post another response in case anyone is still looking for an answer on this.
I've been looking into optimizing Flex apps and, after some checking into it, have decided to use Modules. Primarily 'cause they have such good options for optimization.
The two mxmlc commands yo... |
185,291 | <p>This is kinda a general question, open for opinions. I've been trying to come up with a good way to design for localization of string resources for a Windows MFC application and related utilities. My wishlist is:</p>
<ul>
<li>Must preserve string literals in code (as opposed to replacing with macro #define resource... | [
{
"answer_id": 185318,
"author": "BoltBait",
"author_id": 20848,
"author_profile": "https://Stackoverflow.com/users/20848",
"pm_score": 0,
"selected": false,
"text": "<p>On one project I had localized into 10+ languages, I put everything that was to be localized into a single resource-on... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26240/"
] | This is kinda a general question, open for opinions. I've been trying to come up with a good way to design for localization of string resources for a Windows MFC application and related utilities. My wishlist is:
* Must preserve string literals in code (as opposed to replacing with macro #define resource ID's), so tha... | We use the English string as the ID.
If it fails the look up from the international resource object (loaded from the I18N dll installed) then we default to the ID string.
Code looks like:
```
doAction(I18N.get("Press OK to continue"));
```
As part of the build processes we have a perl script that parses all source... |
185,314 | <p>I have a C# app which uses a System.Diagnostics.Process to run another exe. I ran into some example code where the process is started in a try block and closed in a finally block. I also saw example code where the process is not closed.</p>
<p>What happens when the process is not closed? </p>
<p>Are the resourc... | [
{
"answer_id": 185325,
"author": "mannu",
"author_id": 15858,
"author_profile": "https://Stackoverflow.com/users/15858",
"pm_score": 1,
"selected": false,
"text": "<p>They will continue to run as if you started them yourself.</p>\n"
},
{
"answer_id": 185336,
"author": "Declan... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] | I have a C# app which uses a System.Diagnostics.Process to run another exe. I ran into some example code where the process is started in a try block and closed in a finally block. I also saw example code where the process is not closed.
What happens when the process is not closed?
Are the resources used by the proce... | When the other process *exits*, all of *its* resources are freed up, but you will still be holding onto a process handle (which is a pointer to a block of information about the process) unless you call `Close()` on your `Process` reference. I doubt there would be much of an issue, but **you may as well**.`Process` impl... |
185,327 | <p>I knew stackoverflow would help me for other than know what is the "favorite programming cartoon" :P </p>
<p>This was the accepted answer by:
<a href="https://stackoverflow.com/questions/185327/oracle-joins-left-outer-right-etc-s#185439">Bill Karwin</a></p>
<p>Thanks to all for the help ( I would like to double vo... | [
{
"answer_id": 185375,
"author": "Andy Lester",
"author_id": 8454,
"author_profile": "https://Stackoverflow.com/users/8454",
"pm_score": 2,
"selected": false,
"text": "<p>Typically the better way to write those is with EXISTS. The first one would be:</p>\n\n<pre><code>select * from perf... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20654/"
] | I knew stackoverflow would help me for other than know what is the "favorite programming cartoon" :P
This was the accepted answer by:
[Bill Karwin](https://stackoverflow.com/questions/185327/oracle-joins-left-outer-right-etc-s#185439)
Thanks to all for the help ( I would like to double vote you all )
My query ende... | Try something like this (I haven't tested it):
```
SELECT p_new.identifier, COALESCE(p_inprog.activity, p_new.activity) AS activity,
p_inprog.participant, COALESCE(p_inprog.closedate, p_new.closedate) AS closedate
FROM performance p_new
LEFT OUTER JOIN performance p_inprog
ON (p_new.identifier = p_inprog.iden... |
185,349 | <p>In XAML I can declare a DataTemplate so that the template is used whenever a specific type is displayed. For example, this DataTemplate will use a TextBlock to display the name of a customer:</p>
<pre><code><DataTemplate DataType="{x:Type my:Customer}">
<TextBlock Text="{Binding Name}" />
</DataT... | [
{
"answer_id": 185589,
"author": "ageektrapped",
"author_id": 631,
"author_profile": "https://Stackoverflow.com/users/631",
"pm_score": 6,
"selected": true,
"text": "<p>Not out of the box, no; but there are enterprising developers out there who have done so.</p>\n<p>Mike Hillberg at Micr... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615/"
] | In XAML I can declare a DataTemplate so that the template is used whenever a specific type is displayed. For example, this DataTemplate will use a TextBlock to display the name of a customer:
```
<DataTemplate DataType="{x:Type my:Customer}">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
```
I'm wondering ... | Not out of the box, no; but there are enterprising developers out there who have done so.
Mike Hillberg at Microsoft played with it in [this post](https://learn.microsoft.com/en-us/archive/blogs/mikehillberg/limited-generics-support-in-xaml), for example. Google has others of course. |
185,378 | <p>What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'?</p>
<p>The regular expression should match any of the following:</p>
<pre><code>RunFoo.py
RunBar.py
Run42.py
</code></pre>
<p>It should not match:</p>
<pre><code>myRunFoo.py
Ru... | [
{
"answer_id": 185387,
"author": "moo",
"author_id": 23107,
"author_profile": "https://Stackoverflow.com/users/23107",
"pm_score": 0,
"selected": false,
"text": "<p>This probably doesn't fully comply with file-naming standards, but here it goes:</p>\n\n<pre><code>/^Run[\\w]*?\\.py$/\n</c... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | What is the regular expression to match strings (in this case, file names) that start with 'Run' and have a filename extension of '.py'?
The regular expression should match any of the following:
```
RunFoo.py
RunBar.py
Run42.py
```
It should not match:
```
myRunFoo.py
RunBar.py1
Run42.txt
```
The SQL equivalent ... | For a regular expression, you would use:
```
re.match(r'Run.*\.py$')
```
A quick explanation:
* . means match any character.
* \* means match any repetition of the previous character (hence .\* means any sequence of chars)
* \ is an escape to escape the explicit dot
* $ indicates "end of the string", so we don't ma... |
185,381 | <p>I have some System.Diagnotics.Processes to run. I'd like to call the close method on them automatically. Apparently the "using" keyword does this for me.</p>
<p>Is this the way to use the using keyword?</p>
<pre><code>foreach(string command in S) // command is something like "c:\a.exe"
{
try
{
us... | [
{
"answer_id": 185419,
"author": "JB King",
"author_id": 8745,
"author_profile": "https://Stackoverflow.com/users/8745",
"pm_score": 0,
"selected": false,
"text": "<pre><code>try\n{\n foreach(string command in S) // command is something like \"c:\\a.exe\"\n {\n using(p = Process... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] | I have some System.Diagnotics.Processes to run. I'd like to call the close method on them automatically. Apparently the "using" keyword does this for me.
Is this the way to use the using keyword?
```
foreach(string command in S) // command is something like "c:\a.exe"
{
try
{
using(p = Process.Start(c... | ```
using(p = Process.Start(command))
```
This will compile, as the `Process` class implements `IDisposable`, however you actually want to call the `Close` method.
Logic would have it that the `Dispose` method would call `Close` for you, and by digging into the CLR using reflector, we can see that it does in fact ... |
185,384 | <p>While working on a C# app I just noticed that in several places static initializers have dependencies on each other like this:</p>
<pre><code>static private List<int> a = new List<int>() { 0 };
static private List<int> b = new List<int>() { a[0] };
</code></pre>
<p>Without doing anything sp... | [
{
"answer_id": 185409,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 5,
"selected": true,
"text": "<p>It seems to depend on the sequence of lines. This code works:</p>\n\n<pre><code>static private List<int> a = new List&... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | While working on a C# app I just noticed that in several places static initializers have dependencies on each other like this:
```
static private List<int> a = new List<int>() { 0 };
static private List<int> b = new List<int>() { a[0] };
```
Without doing anything special that worked. Is that just luck? Does C# have... | It seems to depend on the sequence of lines. This code works:
```
static private List<int> a = new List<int>() { 1 };
static private List<int> b = new List<int>() { a[0] };
```
while this code does not work (it throws a `NullReferenceException`)
```
static private List<int> a = new List<int>() { b[0] };
static priv... |
185,423 | <p>I'm working on an application that is implemented as an HTA. I have a series of links that I would like to have open in the system's default web browser. Using <code><a href="url" target="_blank"></code> opens the link in IE regardless of the default browser.</p>
<p>Is there a way to use the default browser? ... | [
{
"answer_id": 185528,
"author": "Mark",
"author_id": 26310,
"author_profile": "https://Stackoverflow.com/users/26310",
"pm_score": -1,
"selected": false,
"text": "<p>Nope, sadly I believe this is a browser specific implementation that will open new links with target=\"_blank\" within th... | 2008/10/08 | [
"https://Stackoverflow.com/questions/185423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7441/"
] | I'm working on an application that is implemented as an HTA. I have a series of links that I would like to have open in the system's default web browser. Using `<a href="url" target="_blank">` opens the link in IE regardless of the default browser.
Is there a way to use the default browser? Using JavaScript is an opti... | Create a shell and attempt to run a URL.
This works for me (save as whatever.hta and execute it) on my system. Clicking on the button opens Google in Firefox:
```
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>HTA Test</title>
<hta:applica... |
185,429 | <p>I know how to use JSON to create objects, but there doesn't seem to be away to use JSON to create an object that is of a specific object type.</p>
<p>Here's an example of an Object and creating an instance of it:</p>
<pre><code>Person = function() { };
Person.prototype = {
FirstName: null,
GetFirstName: fu... | [
{
"answer_id": 185438,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 5,
"selected": true,
"text": "<p>I don't imagine so. I'd create a function on the Person class to initialise from a JSON object if I were you.</p>\n\n<pre><c... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7831/"
] | I know how to use JSON to create objects, but there doesn't seem to be away to use JSON to create an object that is of a specific object type.
Here's an example of an Object and creating an instance of it:
```
Person = function() { };
Person.prototype = {
FirstName: null,
GetFirstName: function() {
re... | I don't imagine so. I'd create a function on the Person class to initialise from a JSON object if I were you.
```
function Person() {
this.loadFromJSON = function(json) {
this.FirstName = json.FirstName;
};
}
```
If you didn't know what class the JSON object was representing beforehand, perhaps add a... |
185,448 | <p>Imagine in the Global.asax.cs file I had an instance class as a private field. Let's say like this:</p>
<pre><code>private MyClass _myClass = new MyClass();
</code></pre>
<p>And I had a static method on Global called GetMyClass() that gets the current HttpApplication and returns that instance.</p>
<pre><code>publ... | [
{
"answer_id": 185456,
"author": "Cowan",
"author_id": 17041,
"author_profile": "https://Stackoverflow.com/users/17041",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not a .NET person so I'll refrain from commenting on this, except for this part:</p>\n\n<blockquote>\n <p>Would you ... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14642/"
] | Imagine in the Global.asax.cs file I had an instance class as a private field. Let's say like this:
```
private MyClass _myClass = new MyClass();
```
And I had a static method on Global called GetMyClass() that gets the current HttpApplication and returns that instance.
```
public static MyClass GetMyClass()
{
... | Whether or not this fits the cookie-cutter pattern of a Singleton, it still suffers from the same problems as Singleton:
* It is a static, concrete reference and cannot be substituted for separate behavior or stubbed/mocked during a test
* You cannot subclass this and preserve this behavior, so it's quite easy to circ... |
185,451 | <p>What's a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time?</p>
| [
{
"answer_id": 169969,
"author": "Alex B",
"author_id": 23643,
"author_profile": "https://Stackoverflow.com/users/23643",
"pm_score": 8,
"selected": false,
"text": "<p>Use <a href=\"http://linux.die.net/man/1/flock\" rel=\"noreferrer\"><code>flock(1)</code></a> to make an exclusive scope... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | What's a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time? | Here's an implementation that uses a *lockfile* and echoes a PID into it. This serves as a protection if the process is killed before removing the *pidfile*:
```
LOCKFILE=/tmp/lock.txt
if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
echo "already running"
exit
fi
# make sure the lockfile is removed w... |
185,461 | <p>I would like MATLAB to tell me if I have an input file (.m file) that contains some variables with their numbers (i.e., <code>a = 5</code>, <code>b = 6</code>, <code>c = 7</code>) so that I can then use that .m file in another program (main .m file) that uses these variables to calculate <code>S = a + b + c</code>. ... | [
{
"answer_id": 185469,
"author": "Scottie T",
"author_id": 6688,
"author_profile": "https://Stackoverflow.com/users/6688",
"pm_score": 2,
"selected": false,
"text": "<p>If your \"input\" file is an m-file, just use the name of the file in your \"main\" m-file. For example you might have... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like MATLAB to tell me if I have an input file (.m file) that contains some variables with their numbers (i.e., `a = 5`, `b = 6`, `c = 7`) so that I can then use that .m file in another program (main .m file) that uses these variables to calculate `S = a + b + c`. How can I then read the input file from the mai... | This is typically not good practice in MATLAB. The file containing the input variables would, in your example, be a script. As would your main file. MATLAB does not error when running one script from another, as suggested by ScottieT812, but under certain circumstances strange errors can arise. (Run time compiling has ... |
185,474 | <p>I have a connection string being passed to a function, and I need to create a DbConnection based object (i.e. SQLConnection, OracleConnection, OLEDbConnection etc) based on this string.</p>
<p>Is there any inbuilt functionality to do this, or any 3rd party libraries to assist. We are not necessarily building this ... | [
{
"answer_id": 185481,
"author": "DamienG",
"author_id": 5720,
"author_profile": "https://Stackoverflow.com/users/5720",
"pm_score": 1,
"selected": false,
"text": "<p>You should be able to parse out the Provider section and pass it into DbProviderFactories.GetFactory which will return a ... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] | I have a connection string being passed to a function, and I need to create a DbConnection based object (i.e. SQLConnection, OracleConnection, OLEDbConnection etc) based on this string.
Is there any inbuilt functionality to do this, or any 3rd party libraries to assist. We are not necessarily building this connection ... | ```
DbConnection GetConnection(string connStr)
{
string providerName = null;
var csb = new DbConnectionStringBuilder { ConnectionString = connStr };
if (csb.ContainsKey("provider"))
{
providerName = csb["provider"].ToString();
}
else
{
var css = ConfigurationMa... |
185,483 | <p>How do I prevent my users from accessing directly pages meant for ajax calls only?</p>
<p>Passing a key during ajax call seems like a solution, whereas access without the key will not be processed. But it is also easy to fabricate the key, no? Curse of View Source...</p>
<p>p/s: Using Apache as webserver.</p>
<p>... | [
{
"answer_id": 185508,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 5,
"selected": false,
"text": "<p>There is no way of guaranteeing that they're accessing it through AJAX. Both direct access and AJAX access come from th... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15345/"
] | How do I prevent my users from accessing directly pages meant for ajax calls only?
Passing a key during ajax call seems like a solution, whereas access without the key will not be processed. But it is also easy to fabricate the key, no? Curse of View Source...
p/s: Using Apache as webserver.
EDIT: To answer why, I h... | As others have said, Ajax request can be emulated be creating the proper headers.
If you want to have a basic check to see if the request is an Ajax request you can use:
```
if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
//Request identified as ajax request
}
```
However you should never base you... |
185,487 | <p>Assuming I have three tables :
TableA (key, value)
TableB (key, value)
TableC (key, value)</p>
<p>and I want to return a value for all keys. If the key exists in TableC return that value else if the key exists in B return that value else return the value from table A</p>
<p>The best I have come up with so far is</... | [
{
"answer_id": 185506,
"author": "Mark",
"author_id": 26310,
"author_profile": "https://Stackoverflow.com/users/26310",
"pm_score": 0,
"selected": false,
"text": "<p>If you have a number of tables that you want data from, then you are going to have to select from them, there is no other ... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6819/"
] | Assuming I have three tables :
TableA (key, value)
TableB (key, value)
TableC (key, value)
and I want to return a value for all keys. If the key exists in TableC return that value else if the key exists in B return that value else return the value from table A
The best I have come up with so far is
```
SELECT key,Va... | OK, using your concrete example as a basis, I came up with a solution different from the others posted (although I think I like your solution better). This was tested on MS SQL Server 2005 - changes may be needed for your SQL dialect.
First, some DDL to set the stage:
```
CREATE TABLE [dbo].[StandardSchedule](
[s... |
185,510 | <p>Is it possible to do something like this?</p>
<pre><code>var pattern = /some regex segment/ + /* comment here */
/another segment/;
</code></pre>
<p>Or do I have to use new <code>RegExp()</code> syntax and concatenate a string? I'd prefer to use the literal as the code is both more self-evident and concise.</p... | [
{
"answer_id": 185529,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 9,
"selected": true,
"text": "<p>Here is how to create a regular expression without using the regular expression literal syntax. This lets you do arbitary ... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17964/"
] | Is it possible to do something like this?
```
var pattern = /some regex segment/ + /* comment here */
/another segment/;
```
Or do I have to use new `RegExp()` syntax and concatenate a string? I'd prefer to use the literal as the code is both more self-evident and concise. | Here is how to create a regular expression without using the regular expression literal syntax. This lets you do arbitary string manipulation before it becomes a regular expression object:
```
var segment_part = "some bit of the regexp";
var pattern = new RegExp("some regex segment" + /*comment here */
s... |
185,520 | <p>I have months stored in SQL Server as 1,2,3,4,...12. I would like to display them as January,February etc. Is there a function in SQL Server like MonthName(1) = January? I am trying to avoid a CASE statement, if possible.</p>
| [
{
"answer_id": 185548,
"author": "Alexander Kojevnikov",
"author_id": 712,
"author_profile": "https://Stackoverflow.com/users/712",
"pm_score": 8,
"selected": true,
"text": "<p>A little hacky but should work:</p>\n\n<pre><code>SELECT DATENAME(month, DATEADD(month, @mydate-1, CAST('2008-0... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] | I have months stored in SQL Server as 1,2,3,4,...12. I would like to display them as January,February etc. Is there a function in SQL Server like MonthName(1) = January? I am trying to avoid a CASE statement, if possible. | A little hacky but should work:
```
SELECT DATENAME(month, DATEADD(month, @mydate-1, CAST('2008-01-01' AS datetime)))
``` |
185,521 | <p>I run into similar codes like this all the time in aspx pages:</p>
<pre><code><asp:CheckBox Runat="server" ID="myid" Checked='<%# DataBinder.Eval(Container.DataItem, "column").Equals(1) %>'>
</code></pre>
<p>I was wondering what other objects I have access to inside of that <%# %> tag. How come Data... | [
{
"answer_id": 185570,
"author": "ckramer",
"author_id": 20504,
"author_profile": "https://Stackoverflow.com/users/20504",
"pm_score": 1,
"selected": false,
"text": "<p>I believe you have access to anything within scope of the page class, though the results of the expression are converte... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10088/"
] | I run into similar codes like this all the time in aspx pages:
```
<asp:CheckBox Runat="server" ID="myid" Checked='<%# DataBinder.Eval(Container.DataItem, "column").Equals(1) %>'>
```
I was wondering what other objects I have access to inside of that <%# %> tag. How come DataBinder.Eval() and Container.DataItem are ... | Within <%# %> tags you have access to
1. Anything that is visible in your code-behind class (including protected methods and properties).
2. Anything declared on the aspx page using <@import @>.
3. Anything passed in as the event arguments when the ItemDataBound event is fired (e.g. RepeaterItemEventArgs, DataListIte... |
185,522 | <p>When working with CSS inside of XML such as</p>
<pre><code><span class="IwuvAS3"></span>
</code></pre>
<p>when parsed in flash, if I don't use CDATA like the following:</p>
<pre><code><![CDATA[<span class="IwuvAS3"></span>]]>
</code></pre>
<p>then the parsed data drops down a line f... | [
{
"answer_id": 185537,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>You could escape the \"<\" characters (and &, \", >, ', among others) as entities instead.</p>\n"
},
{
... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20628/"
] | When working with CSS inside of XML such as
```
<span class="IwuvAS3"></span>
```
when parsed in flash, if I don't use CDATA like the following:
```
<![CDATA[<span class="IwuvAS3"></span>]]>
```
then the parsed data drops down a line for every "<" character it sees.
When parsing the data into a single-line text ... | Set the TextField's **condenseWhite** property to true - so only < br/> tags will generate linebreaks. |
185,524 | <p>I'm trying to build the example described at <a href="http://support.microsoft.com/kb/178749/EN-US/" rel="nofollow noreferrer">http://support.microsoft.com/kb/178749/EN-US/</a> in order to build an application that programatically accesses Excel using Automation. I have Visual C++ 2005/Visual Studio 2005. Some of... | [
{
"answer_id": 186009,
"author": "Nick",
"author_id": 26240,
"author_profile": "https://Stackoverflow.com/users/26240",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not familiar with the ClassWizard wrapper generator, but it looks like it may have #imported the Excel COM type librar... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965047/"
] | I'm trying to build the example described at <http://support.microsoft.com/kb/178749/EN-US/> in order to build an application that programatically accesses Excel using Automation. I have Visual C++ 2005/Visual Studio 2005. Some of the instructions don't exactly match up (classwizard, mostly), but the general idea seems... | I'm not familiar with the ClassWizard wrapper generator, but it looks like it may have #imported the Excel COM type library without a namespace, and you're getting conflicts with the SDK header files. Check the `.tlh` file and ensure there's a namespace around the definitions. If not, I'd look at importing it the more ... |
185,536 | <p>By default it seems that objects are drawn front to back. I am drawing a 2-D UI object and would like to create it back to front. For example I could create a white square first then create a slightly smaller black square on top of it thus creating a black pane with a white border. <a href="http://gpwiki.org/index... | [
{
"answer_id": 185551,
"author": "MrValdez",
"author_id": 1599,
"author_profile": "https://Stackoverflow.com/users/1599",
"pm_score": 2,
"selected": false,
"text": "<p>Drawing order is hard. There is no easy solution. The painter's alogorithm (sort objects by their distance in relation t... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8761/"
] | By default it seems that objects are drawn front to back. I am drawing a 2-D UI object and would like to create it back to front. For example I could create a white square first then create a slightly smaller black square on top of it thus creating a black pane with a white border. [This post](http://gpwiki.org/index.p... | The following call will turn off depth testing causing objects to be drawn in the order created. This will in effect cause objects to draw back to front.
```
glDepthFunc(GL_NEVER); // Ignore depth values (Z) to cause drawing bottom to top
```
Be sure you do not call this:
```
glEnable (GL_DEPTH_TEST); // Ena... |
185,559 | <p>I would like to remove the domain/computer information from a login id in C#. So, I would like to make either "Domain\me" or "Domain\me" just "me". I could always check for the existence of either, and use that as the index to start the substring...but I am looking for something more elegant and compact.</p>
<p>W... | [
{
"answer_id": 185572,
"author": "BoltBait",
"author_id": 20848,
"author_profile": "https://Stackoverflow.com/users/20848",
"pm_score": 2,
"selected": false,
"text": "<p>I always do it this way:</p>\n\n<pre><code> string[] domainuser;\n string Auth_User = Request.ServerVariables[\"... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18449/"
] | I would like to remove the domain/computer information from a login id in C#. So, I would like to make either "Domain\me" or "Domain\me" just "me". I could always check for the existence of either, and use that as the index to start the substring...but I am looking for something more elegant and compact.
Worse case sc... | when all you have is a hammer, everything looks like a nail.....
use a razor blade ----
```
using System;
using System.Text.RegularExpressions;
public class MyClass
{
public static void Main()
{
string domainUser = Regex.Replace("domain\\user",".*\\\\(.*)", "$1",RegexOptions.None);
Console.Wri... |
185,569 | <p>This is an age-old question where given a table with attributes 'type', 'variety' and 'price', that you fetch the record with the minimum price for each type there is.</p>
<p>In SQL, we can do <a href="http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/" rel="noreferrer">this<... | [
{
"answer_id": 185647,
"author": "Avdi",
"author_id": 20487,
"author_profile": "https://Stackoverflow.com/users/20487",
"pm_score": 4,
"selected": false,
"text": "<pre><code>Table.minimum(:price, :group => :type)\n</code></pre>\n\n<p>See <a href=\"http://api.rubyonrails.org/classes/Ac... | 2008/10/09 | [
"https://Stackoverflow.com/questions/185569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This is an age-old question where given a table with attributes 'type', 'variety' and 'price', that you fetch the record with the minimum price for each type there is.
In SQL, we can do [this](http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/) by:
```
select f.type, f.variety,... | ```
Table.minimum(:price, :group => :type)
```
See <http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-minimum> for more. |