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 |
|---|---|---|---|---|---|---|
169,610 | <p>I'm writing a function that gets the path environment variable of a system, splits up each path, then concats on some other extra characters onto the end of each path.</p>
<p>Everything works fine until I use the <code>strcat()</code> function (see code below).</p>
<pre><code>char* prependPath( char* exeName )
{
... | [
{
"answer_id": 169614,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "<p>strtok() tokenizes in place. When you start appending characters to the tokens, you're overwriting the next token... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm writing a function that gets the path environment variable of a system, splits up each path, then concats on some other extra characters onto the end of each path.
Everything works fine until I use the `strcat()` function (see code below).
```
char* prependPath( char* exeName )
{
char* path = getenv("PATH"); ... | strtok() does not give you a new string.
It mutilates the input string by inserting the char '\0' where the split character was.
So your use of strcat(token[j],"/") will put the '/' character where the '\0' was.
Also the last token will start appending 'which' past the end of your allocated memory into uncharted... |
169,624 | <p>I was looking into sorting tables by a column designated given some input, and from what I've found, there is no easy way to do this. The best I've found is a switch statement: </p>
<pre><code>SELECT Column1, Column2, Column3, Column4
FROM Table
ORDER BY CASE WHEN @OrderBY = 'Column1' THEN Column1
WH... | [
{
"answer_id": 169632,
"author": "Ron Savage",
"author_id": 12476,
"author_profile": "https://Stackoverflow.com/users/12476",
"pm_score": 1,
"selected": false,
"text": "<p>I generally convert the stored procedure to a function that returns a table ( so you can select FROM it ... and add ... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | I was looking into sorting tables by a column designated given some input, and from what I've found, there is no easy way to do this. The best I've found is a switch statement:
```
SELECT Column1, Column2, Column3, Column4
FROM Table
ORDER BY CASE WHEN @OrderBY = 'Column1' THEN Column1
WHEN @OrderBY = '... | You have two choices:
1. As you have implemented above
2. Or generate dynamic sql and execute
using `sp_executesql` |
169,625 | <p>I would like users to submit a URL that is valid but also is an image, ending with .jpg, .png, or .gif.</p>
| [
{
"answer_id": 169631,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 6,
"selected": false,
"text": "<pre>(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*\\.(?:jpg|gif|png))(?:\\?([^#]*))?(?:#(.*))?</pre>\n\n<p>That's a (slightly modifi... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like users to submit a URL that is valid but also is an image, ending with .jpg, .png, or .gif. | ```
(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*\.(?:jpg|gif|png))(?:\?([^#]*))?(?:#(.*))?
```
That's a (slightly modified) version of the official URI parsing regexp from [RFC 2396](http://www.ietf.org/rfc/rfc2396.txt). It allows for `#fragments` and `?querystrings` to appear after the filename, which may or may not be wh... |
169,662 | <p>Is it possible, in Java, to enforce that a class have a specific set of subclasses and no others? For example:</p>
<pre><code>public abstract class A {}
public final class B extends A {}
public final class C extends A {}
public final class D extends A {}
</code></pre>
<p>Can I somehow enforce that no other subclas... | [
{
"answer_id": 169671,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": false,
"text": "<p>Give class <strong><code>A</code></strong> a constructor with package-level accessibility (and no other constructors)... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3434/"
] | Is it possible, in Java, to enforce that a class have a specific set of subclasses and no others? For example:
```
public abstract class A {}
public final class B extends A {}
public final class C extends A {}
public final class D extends A {}
```
Can I somehow enforce that no other subclasses of A can ever be creat... | Church encoding to the rescue:
```
public abstract class A {
public abstract <R> R fold(R b, R c, R d);
}
```
There are only three implementations possible:
```
public final class B extends A {
public <R> R fold(R b, R c, R d) {
return b;
}
}
public final class C extends A {
public <R> R fold(R b, R c,... |
169,731 | <p>In Javascript, I have an object:</p>
<pre><code>obj = { one: "foo", two: "bar" };
</code></pre>
<p>Now, I want do do this</p>
<pre><code>var a = 'two';
if(confirm('Do you want One'))
{
a = 'one';
}
alert(obj.a);
</code></pre>
<p>But of course it doesn't work. What would be the correct way of referencing this... | [
{
"answer_id": 169737,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 3,
"selected": false,
"text": "<p>Like this:</p>\n\n<pre><code>obj[a]\n</code></pre>\n"
},
{
"answer_id": 169740,
"author": "Javier",
"... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144/"
] | In Javascript, I have an object:
```
obj = { one: "foo", two: "bar" };
```
Now, I want do do this
```
var a = 'two';
if(confirm('Do you want One'))
{
a = 'one';
}
alert(obj.a);
```
But of course it doesn't work. What would be the correct way of referencing this object dynamically? | short answer: `obj[a]`
long answer: `obj.field` is just a shorthand for `obj["field"]`, for the special case where the key is a constant string without spaces, dots, or other nasty things. in your question, the key wasn't a constant, so simply use the full syntax. |
169,784 | <p>I am totally new to <code>SQL</code>. I have a simple select query similar to this:</p>
<pre><code>SELECT COUNT(col1) FROM table1
</code></pre>
<p>There are some 120 records in the table and shown on the <code>GUI</code>.
For some reason, this query always returns a number which is less than the actual count.</p>
... | [
{
"answer_id": 169785,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 4,
"selected": false,
"text": "<p>Try </p>\n\n<pre><code>select count(*) from table1\n</code></pre>\n\n<p><strong>Edit:</strong> To explain further, <code... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25065/"
] | I am totally new to `SQL`. I have a simple select query similar to this:
```
SELECT COUNT(col1) FROM table1
```
There are some 120 records in the table and shown on the `GUI`.
For some reason, this query always returns a number which is less than the actual count.
Can somebody please help me? | You might have some null values in col1 column. Aggregate functions ignore nulls.
try this
```
SELECT COUNT(ISNULL(col1,0)) FROM table1
``` |
169,799 | <p>I'm trying to get into java again (it's been a few years). I never really did any GUI coding in java. I've been using Netbeans to get started with this.</p>
<p>When using winforms in C# at work I use a usercontrols to build parts of my UI and add them to forms dynamically. </p>
<p>I've been trying to use <code>JPa... | [
{
"answer_id": 169805,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": -1,
"selected": false,
"text": "<p>Try <code>mainPanel.invalidate()</code> and then if necessary, <code>mainPanel.validate()</code>. It also might ... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21811/"
] | I'm trying to get into java again (it's been a few years). I never really did any GUI coding in java. I've been using Netbeans to get started with this.
When using winforms in C# at work I use a usercontrols to build parts of my UI and add them to forms dynamically.
I've been trying to use `JPanels` like usercontrol... | I figured it out. The comments under the accepted answer here explain it:
[Dynamically added JTable not displaying](https://stackoverflow.com/questions/121715/dynamically-added-jtable-not-displaying)
Basically I just added the following before the mainPanel.add()
```
mainPanel.setLayout(new java.awt.BorderLayout());
... |
169,814 | <p>I'm working through previous years ACM Programming Competition problems trying to get better at solving Graph problems. </p>
<p>The one I'm working on now is I'm given an arbitrary number of undirected graph nodes, their neighbors and the distances for the edges connecting the nodes. What I NEED is the distance b... | [
{
"answer_id": 169845,
"author": "DanJ",
"author_id": 4697,
"author_profile": "https://Stackoverflow.com/users/4697",
"pm_score": 0,
"selected": false,
"text": "<p>You can use your Dijkstra's implementation as follows:</p>\n\n<ol>\n<li>Pick a random node,(a), run Dijkstra from node a, an... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] | I'm working through previous years ACM Programming Competition problems trying to get better at solving Graph problems.
The one I'm working on now is I'm given an arbitrary number of undirected graph nodes, their neighbors and the distances for the edges connecting the nodes. What I NEED is the distance between the t... | It looks like you can use either of:
* [Floyd Warshall algorithm](http://en.wikipedia.org/wiki/Floyd_Warshall)
* [Johnson's algorithm](http://en.wikipedia.org/wiki/Johnson's_algorithm).
I can't give you much guidance about them though - I'm no expert. |
169,818 | <h2>What should happen when I call <code>$user->get_email_address()</code>?</h2>
<h3>Option 1: Pull the email address from the database on demand</h3>
<pre><code>public function get_email_address() {
if (!$this->email_address) {
$this->read_from_database('email_address');
}
return $this-&... | [
{
"answer_id": 169821,
"author": "Aaron Jensen",
"author_id": 11229,
"author_profile": "https://Stackoverflow.com/users/11229",
"pm_score": 3,
"selected": false,
"text": "<p>Minimize the number of queries. The optimal # of queries is 0, but if you must query because it's not cached, it's... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25068/"
] | What should happen when I call `$user->get_email_address()`?
------------------------------------------------------------
### Option 1: Pull the email address from the database on demand
```
public function get_email_address() {
if (!$this->email_address) {
$this->read_from_database('email_address');
... | There really isn't a correct answer for this. Depends on how many users you're loading at once, how many text/blob fields are in your User table, whether your user table loads any associated child objects. As aaronjensen says, this pattern is called **lazy loading** - and the opposite behaviour (loading *everything* up... |
169,829 | <p>INotifyPropertyChanged is fairly self explanatory and I think I'm clear on when to raise that one (i.e. when I've finished updating the values).<br>
If I implement INotifyPropertyChanging I'm tending to raise the event as soon as I enter the setter or other method that changes the objects state and then continue wit... | [
{
"answer_id": 169849,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 5,
"selected": true,
"text": "<p>If your object is given a value that is invalid for the property and you throw an exception then you shouldn't raise t... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15572/"
] | INotifyPropertyChanged is fairly self explanatory and I think I'm clear on when to raise that one (i.e. when I've finished updating the values).
If I implement INotifyPropertyChanging I'm tending to raise the event as soon as I enter the setter or other method that changes the objects state and then continue with an... | If your object is given a value that is invalid for the property and you throw an exception then you shouldn't raise the `PropertyChanging` event. You should only raise the event when you've decided that the value *will* change. The typical usage scenario is for changing a simple field:
```
public T Foo
{ get
{ r... |
169,833 | <p>I've opened a new window with window.open() and I want to use the reference from the window.open() call to then write content to the new window. I've tried copying HTML from the old window to the new window by using myWindow.document.body.innerHTML = oldWindowDiv.innerHTML; but that's doesn't work. Any ideas?</p>
| [
{
"answer_id": 169840,
"author": "Giao",
"author_id": 14099,
"author_profile": "https://Stackoverflow.com/users/14099",
"pm_score": -1,
"selected": false,
"text": "<pre><code>myWindow.document.writeln(documentString)\n</code></pre>\n"
},
{
"answer_id": 169843,
"author": "Vije... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2484/"
] | I've opened a new window with window.open() and I want to use the reference from the window.open() call to then write content to the new window. I've tried copying HTML from the old window to the new window by using myWindow.document.body.innerHTML = oldWindowDiv.innerHTML; but that's doesn't work. Any ideas? | The reference returned by `window.open()` is to the child window's `window` object. So you can do anything you would normally do, here's an example:
```
var myWindow = window.open('...')
myWindow.document.getElementById('foo').style.backgroundColor = 'red'
```
Bear in mind that this will only work if the parent and ... |
169,866 | <p>How to export pictures in Microsoft Word to TIFF file using Visual Studio Tools for Office? I can obtain a reference to the pictures as InlineShape object collection, the hard part now is how to save them as TIFF images.</p>
| [
{
"answer_id": 169881,
"author": "Vaibhav",
"author_id": 380,
"author_profile": "https://Stackoverflow.com/users/380",
"pm_score": 0,
"selected": false,
"text": "<p>Well. not sure if this is helpful, but you if you are okay with jpegs, then one really cool technique for extracting images... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | How to export pictures in Microsoft Word to TIFF file using Visual Studio Tools for Office? I can obtain a reference to the pictures as InlineShape object collection, the hard part now is how to save them as TIFF images. | OK guys, I got the problem solved. Here's the code snippet:
```
private void SaveToImage(Word.InlineShape picShape, string filePath)
{
picShape.Select();
theApp.Selection.CopyAsPicture();
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(typeof(Bitmap)))
... |
169,877 | <p>Being new to test based development, this question has been bugging me. How much is too much? What should be tested, how should it be tested, and why should it be tested? The examples given are in C# with NUnit, but I assume the question itself is language agnostic.</p>
<p>Here are two current examples of my own, t... | [
{
"answer_id": 169886,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 1,
"selected": false,
"text": "<p>Is <code>_list</code> an instance of a class you wrote? If so, I'd say testing it is reasonable. Though in that cas... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] | Being new to test based development, this question has been bugging me. How much is too much? What should be tested, how should it be tested, and why should it be tested? The examples given are in C# with NUnit, but I assume the question itself is language agnostic.
Here are two current examples of my own, tests on a ... | I would say that what you're actually testing are equivalence classes. In my view, there is no difference between a adding to a list that has 3 items or 7 items. However, there is a difference between 0 items, 1 item and >1 items. I would probably have 3 tests each for Add/Remove methods for these cases initially.
Onc... |
169,894 | <p>The <a href="http://flot.googlecode.com/svn/trunk/API.txt" rel="nofollow noreferrer">Flot API documentation</a> describes the library's extensive hooks for customizing the axes of a graph. You can set the number of ticks, their color, etc. separately for each axis. However, I can not figure out how to prevent Flot f... | [
{
"answer_id": 174004,
"author": "Alex Gyoshev",
"author_id": 25427,
"author_profile": "https://Stackoverflow.com/users/25427",
"pm_score": 3,
"selected": false,
"text": "<p>After some digging around, I'm quite sure that it is not possible through the Flot API. Nevertheless, if you get r... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10419/"
] | The [Flot API documentation](http://flot.googlecode.com/svn/trunk/API.txt) describes the library's extensive hooks for customizing the axes of a graph. You can set the number of ticks, their color, etc. separately for each axis. However, I can not figure out how to prevent Flot from drawing the vertical grid lines with... | As Laurimann noted, Flot continues to evolve. The ability to control this has been added to the API (as noted in the flot issue Nelson linked to).
If you download the latest version (which is still labeled 0.6), you can disable lines on an axis with "tickLength", like so:
```
xaxis: {
tickLength: 0
}
```
Rather a... |
169,897 | <p>I tried to package a Twisted program with py2exe, but once I run the exe file I built, I got a "No module named resource" error. </p>
<p>And I found the py2exe said:</p>
<blockquote>
<p>The following modules appear to be missing ['FCNTL', 'OpenSSL', 'email.Generator', 'email.Iterators', 'email.Utils', 'pkg_resou... | [
{
"answer_id": 169913,
"author": "teratorn",
"author_id": 14739,
"author_profile": "https://Stackoverflow.com/users/14739",
"pm_score": 5,
"selected": true,
"text": "<p>I've seen this before... py2exe, for some reason, is not detecting that these modules are needed inside the ZIP archive... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25077/"
] | I tried to package a Twisted program with py2exe, but once I run the exe file I built, I got a "No module named resource" error.
And I found the py2exe said:
>
> The following modules appear to be missing ['FCNTL', 'OpenSSL', 'email.Generator', 'email.Iterators', 'email.Utils', 'pkg\_resources', 'pywintypes', 'reso... | I've seen this before... py2exe, for some reason, is not detecting that these modules are needed inside the ZIP archive and is leaving them out.
You can explicitly specify modules to include on the py2exe command line:
```
python setup.py py2exe -p win32com -i twisted.web.resource
```
Something like that. Read up o... |
169,902 | <p>Given two image buffers (assume it's an array of ints of size width * height, with each element a color value), how can I map an area defined by a quadrilateral from one image buffer into the other (always square) image buffer? I'm led to understand this is called "projective transformation".</p>
<p>I'm also lookin... | [
{
"answer_id": 169993,
"author": "SmacL",
"author_id": 22564,
"author_profile": "https://Stackoverflow.com/users/22564",
"pm_score": 2,
"selected": false,
"text": "<p>There is a <a href=\"http://www.codeproject.com/KB/graphics/CBitmapEx.aspx\" rel=\"nofollow noreferrer\">C++ project on C... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173449/"
] | Given two image buffers (assume it's an array of ints of size width \* height, with each element a color value), how can I map an area defined by a quadrilateral from one image buffer into the other (always square) image buffer? I'm led to understand this is called "projective transformation".
I'm also looking for a g... | **EDIT**
The assumption below of the invariance of angle ratios is incorrect. Projective transformations instead preserve cross-ratios and incidence. A solution then is:
1. Find the point C' at the intersection of the lines defined by the segments AD and CP.
2. Find the point B' at the intersection of the lines defin... |
169,907 | <p>I need to encode a 100KB+ string as base64 in VBA. Are there any built-in functions or COM objects available which will do this as a pure VBA approach is either complex or doesn't scale well at these volumes (see links from <a href="http://www.vbforums.com/showthread.php?t=379072" rel="noreferrer">dbb</a> and <a hre... | [
{
"answer_id": 169945,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 7,
"selected": true,
"text": "<p>You can use the MSXML Base64 encoding functionality as described at <a href=\"http://web.archive.org/web/2006052709453... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4023/"
] | I need to encode a 100KB+ string as base64 in VBA. Are there any built-in functions or COM objects available which will do this as a pure VBA approach is either complex or doesn't scale well at these volumes (see links from [dbb](http://www.vbforums.com/showthread.php?t=379072) and [marxidad](http://www.motobit.com/tip... | You can use the MSXML Base64 encoding functionality as described at [www.nonhostile.com/howto-encode-decode-base64-vb6.asp](http://web.archive.org/web/20060527094535/http://www.nonhostile.com/howto-encode-decode-base64-vb6.asp):
```
Function EncodeBase64(text As String) As String
Dim arrData() As Byte
arrData = St... |
169,925 | <p>I want to convert a string into a double and after doing some math on it, convert it back to a string.</p>
<p>How do I do this in Objective-C?</p>
<p>Is there a way to round a double to the nearest integer too?</p>
| [
{
"answer_id": 169932,
"author": "olliej",
"author_id": 784,
"author_profile": "https://Stackoverflow.com/users/784",
"pm_score": 9,
"selected": true,
"text": "<p>You can convert an NSString into a double with </p>\n\n<pre><code>double myDouble = [myString doubleValue];\n</code></pre>\n\... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] | I want to convert a string into a double and after doing some math on it, convert it back to a string.
How do I do this in Objective-C?
Is there a way to round a double to the nearest integer too? | You can convert an NSString into a double with
```
double myDouble = [myString doubleValue];
```
Rounding to the nearest int can then be done as
```
int myInt = (int)(myDouble + (myDouble>0 ? 0.5 : -0.5))
```
I'm honestly not sure if there's a more streamlined way to convert back into a string than
```
NSString... |
169,973 | <p>When is it better to use a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1" rel="noreferrer">List</a> vs a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.linkedlist-1" rel="noreferrer">LinkedList</a>?</p>
| [
{
"answer_id": 169979,
"author": "Michael Damatov",
"author_id": 23372,
"author_profile": "https://Stackoverflow.com/users/23372",
"pm_score": 2,
"selected": false,
"text": "<p>When you need built-in indexed access, sorting (and after this binary searching), and \"ToArray()\" method, you... | 2008/10/04 | [
"https://Stackoverflow.com/questions/169973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5274/"
] | When is it better to use a [List](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1) vs a [LinkedList](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.linkedlist-1)? | Edit
----
>
> Please read the comments to this answer. People claim I did not do
> proper tests. I agree this should not be an accepted answer. As I was
> learning I did some tests and felt like sharing them.
>
>
>
Original answer...
------------------
I found interesting results:
```
// Temporary class to sh... |
170,004 | <p>Let's say:</p>
<pre><code><div>
pre text
<div class="remove-just-this">
<p>child foo</p>
<p>child bar</p>
nested text
</div>
post text
</div>
</code></pre>
<p>to this:</p>
<pre><code><div>
pre text
<p>child foo</p>
<p&g... | [
{
"answer_id": 170056,
"author": "jk.",
"author_id": 21284,
"author_profile": "https://Stackoverflow.com/users/21284",
"pm_score": 8,
"selected": true,
"text": "<p>Using <a href=\"http://jquery.com/\" rel=\"noreferrer\">jQuery</a> you can do this:</p>\n\n<pre><code>var cnt = $(\".remove-... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20838/"
] | Let's say:
```
<div>
pre text
<div class="remove-just-this">
<p>child foo</p>
<p>child bar</p>
nested text
</div>
post text
</div>
```
to this:
```
<div>
pre text
<p>child foo</p>
<p>child bar</p>
nested text
post text
</div>
```
I've been figuring out using Mootools, jQuery and even... | Using [jQuery](http://jquery.com/) you can do this:
```
var cnt = $(".remove-just-this").contents();
$(".remove-just-this").replaceWith(cnt);
```
Quick links to the documentation:
* [contents](http://docs.jquery.com/Traversing/contents)( ) : *jQuery*
* [replaceWith](http://docs.jquery.com/Manipulation/replaceWith)(... |
170,019 | <p>I have an API that is dependent on certain state information between requests. As an easy first version of the code, I am simply using PHP session's to store the state information instead of something more advanced (APC, memcache, DB). Throughout my initial testing in a web browser, everything worked perfectly. Howe... | [
{
"answer_id": 170031,
"author": "keparo",
"author_id": 19468,
"author_profile": "https://Stackoverflow.com/users/19468",
"pm_score": 5,
"selected": true,
"text": "<p><strong>Session Cookies</strong></p>\n\n<p>Remember that HTTP is <strong>stateless</strong>, so sessions are tracked on y... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8880/"
] | I have an API that is dependent on certain state information between requests. As an easy first version of the code, I am simply using PHP session's to store the state information instead of something more advanced (APC, memcache, DB). Throughout my initial testing in a web browser, everything worked perfectly. However... | **Session Cookies**
Remember that HTTP is **stateless**, so sessions are tracked on your server, but the **client** has to identify itself with each request. When you declare session\_start(), **your browser is usually setting a cookie** (the "PHP Session Id"), and then identifying itself by sending the cookie value w... |
170,021 | <p>We are currently running a SQL Job that archives data daily at every 10PM. However, the end users complains that from 10PM to 12, the page shows a time out error.</p>
<p>Here's the pseudocode of the job</p>
<pre><code>while @jobArchive = 1 and @countProcecessedItem < @maxItem
exec ArchiveItems @countProcec... | [
{
"answer_id": 170031,
"author": "keparo",
"author_id": 19468,
"author_profile": "https://Stackoverflow.com/users/19468",
"pm_score": 5,
"selected": true,
"text": "<p><strong>Session Cookies</strong></p>\n\n<p>Remember that HTTP is <strong>stateless</strong>, so sessions are tracked on y... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24755/"
] | We are currently running a SQL Job that archives data daily at every 10PM. However, the end users complains that from 10PM to 12, the page shows a time out error.
Here's the pseudocode of the job
```
while @jobArchive = 1 and @countProcecessedItem < @maxItem
exec ArchiveItems @countProcecessedItem out
if er... | **Session Cookies**
Remember that HTTP is **stateless**, so sessions are tracked on your server, but the **client** has to identify itself with each request. When you declare session\_start(), **your browser is usually setting a cookie** (the "PHP Session Id"), and then identifying itself by sending the cookie value w... |
170,028 | <p>This seems very noisy to me. Five lines of overhead is just too much.</p>
<pre><code>m_Lock.EnterReadLock()
Try
Return m_List.Count
Finally
m_Lock.ExitReadLock()
End Try
</code></pre>
<p>So how would you simply this?</p>
| [
{
"answer_id": 170032,
"author": "Jonathan Allen",
"author_id": 5274,
"author_profile": "https://Stackoverflow.com/users/5274",
"pm_score": 0,
"selected": false,
"text": "<p>I ended up doing this, but I'm still open to better ways or flaws in my design.</p>\n\n<pre><code>Using m_Lock.Rea... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5274/"
] | This seems very noisy to me. Five lines of overhead is just too much.
```
m_Lock.EnterReadLock()
Try
Return m_List.Count
Finally
m_Lock.ExitReadLock()
End Try
```
So how would you simply this? | I was thinking the same, but in C# ;-p
```
using System;
using System.Threading;
class Program
{
static void Main()
{
ReaderWriterLockSlim sync = new ReaderWriterLockSlim();
using (sync.Read())
{
// etc
}
}
}
public static class ReaderWriterExt
{
sealed... |
170,051 | <p>I'm trying to make things simpler. Here is my code:</p>
<pre><code> If Threading.Monitor.TryEnter(syncRoot) Then
Try
'do something
Finally
Threading.Monitor.Exit(syncRoot)
End Try
Else
'do something else
End If
</code></pre>
<p>This is even worse t... | [
{
"answer_id": 170055,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>This is very similar to your <a href=\"https://stackoverflow.com/questions/170028/how-would-you-simplfy-entering-a... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5274/"
] | I'm trying to make things simpler. Here is my code:
```
If Threading.Monitor.TryEnter(syncRoot) Then
Try
'do something
Finally
Threading.Monitor.Exit(syncRoot)
End Try
Else
'do something else
End If
```
This is even worse than the ReaderWriterLock i... | Use a delegate?
E.g.
```
public bool TryEnter(object lockObject, Action work)
{
if (Monitor.TryEnter(lockObject))
{
try
{
work();
}
finally
{
Monitor.Exit(lockObject);
}
return true;
}
return false;
}
``` |
170,061 | <pre><code> <DataTemplate x:Key="Genre_DataTemplate">
<RadioButton GroupName="One" Content="{Binding...
</DataTemplate>
</code></pre>
<p>Above code is the ItemTemplate of my ItemsControl, I want all the Radiobuttons instantiated should behave as if it is in a group, I know the reason because th... | [
{
"answer_id": 170643,
"author": "ligaz",
"author_id": 6409,
"author_profile": "https://Stackoverflow.com/users/6409",
"pm_score": 2,
"selected": false,
"text": "<p>I think the problem is somewhere else in the control tree. Can you post more details?</p>\n\n<p>Here is a sample xaml code ... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8091/"
] | ```
<DataTemplate x:Key="Genre_DataTemplate">
<RadioButton GroupName="One" Content="{Binding...
</DataTemplate>
```
Above code is the ItemTemplate of my ItemsControl, I want all the Radiobuttons instantiated should behave as if it is in a group, I know the reason because the generated RadioButtons are not a... | The problem is that the RadioButton.GroupName behavior depends on the logical tree to find a common ancestor and effectively scope it's use to that part of the tree, but silverlight's ItemsControl doesn't maintain the logical tree. This means, in your example, the RadioButton's Parent property is always null
I built a... |
170,070 | <p>What criteria should I use to decide whether I write VBA code like this:</p>
<pre><code>Set xmlDocument = New MSXML2.DOMDocument
</code></pre>
<p>or like this:</p>
<pre><code>Set xmlDocument = CreateObject("MSXML2.DOMDocument")
</code></pre>
<p>?</p>
| [
{
"answer_id": 170075,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 2,
"selected": false,
"text": "<p>For the former you need to have a reference to the type library in your application. It will typically use early binding (... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4023/"
] | What criteria should I use to decide whether I write VBA code like this:
```
Set xmlDocument = New MSXML2.DOMDocument
```
or like this:
```
Set xmlDocument = CreateObject("MSXML2.DOMDocument")
```
? | As long as the variable is not typed as object
```
Dim xmlDocument as MSXML2.DOMDocument
Set xmlDocument = CreateObject("MSXML2.DOMDocument")
```
is the same as
```
Dim xmlDocument as MSXML2.DOMDocument
Set xmlDocument = New MSXML2.DOMDocument
```
both use early binding. Whereas
```
Dim xmlDocument as Object
Set... |
170,078 | <p>How do I set a variable to the result of select query without using a stored procedure? </p>
<hr>
<p>I want to do something like:
OOdate DATETIME</p>
<pre><code>SET OOdate = Select OO.Date
FROM OLAP.OutageHours as OO
WHERE OO.OutageID = 1
</code></pre>
<p>Then I want to use OOdate in this query:</p>
<pre><code... | [
{
"answer_id": 170082,
"author": "Luk",
"author_id": 5789,
"author_profile": "https://Stackoverflow.com/users/5789",
"pm_score": 1,
"selected": false,
"text": "<p>What do you mean exactly? Do you want to reuse the result of your query for an other query? </p>\n\n<p>In that case, why don'... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21004/"
] | How do I set a variable to the result of select query without using a stored procedure?
---
I want to do something like:
OOdate DATETIME
```
SET OOdate = Select OO.Date
FROM OLAP.OutageHours as OO
WHERE OO.OutageID = 1
```
Then I want to use OOdate in this query:
```
SELECT COUNT(FF.HALID) from Outages.FaultsIn... | You can use something like
```
SET @cnt = (SELECT COUNT(*) FROM User)
```
or
```
SELECT @cnt = (COUNT(*) FROM User)
```
For this to work the SELECT must return a single column and a single result and the SELECT statement must be in parenthesis.
**Edit**: Have you tried something like this?
```
DECLARE @OOdate D... |
170,115 | <p>I have a scenario where I'm not really sure my approach is the best one, and I would appreciate feedback / suggestions.</p>
<p>scenario:
I have a bunch of flash based (swf) 'modules' which are hosted in my aspnet application. Each flash has it's own directory on the filesystem, which contains assets for the flash. ... | [
{
"answer_id": 170128,
"author": "Noah Goodrich",
"author_id": 20178,
"author_profile": "https://Stackoverflow.com/users/20178",
"pm_score": 1,
"selected": false,
"text": "<p>Have you considered simply validating resource access through an HTTP request to the server after the swf loads?<... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12756/"
] | I have a scenario where I'm not really sure my approach is the best one, and I would appreciate feedback / suggestions.
scenario:
I have a bunch of flash based (swf) 'modules' which are hosted in my aspnet application. Each flash has it's own directory on the filesystem, which contains assets for the flash. Consider t... | Have you considered simply validating resource access through an HTTP request to the server after the swf loads?
Where I work we provide online trainings to users through flash but rather than verify the HTTP request itself, we allow the swf's to load first and then make a request to the server to verify that the user... |
170,140 | <p>How do I add the Swedish interactive user, </p>
<pre><code>NT INSTANS\INTERAKTIV
</code></pre>
<p>or the English interactive user, </p>
<pre><code>NT AUTHORITY\INTERACTIVE
</code></pre>
<p>or any other localised user group with <strong>write</strong> permissions to a program folder's ACL?</p>
<p>Is this q... | [
{
"answer_id": 170206,
"author": "Mihai Limbășan",
"author_id": 14444,
"author_profile": "https://Stackoverflow.com/users/14444",
"pm_score": 2,
"selected": false,
"text": "<p>There is no way <em>as such</em> to add both account names to an ACL since they are one and the same. The name y... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25092/"
] | How do I add the Swedish interactive user,
```
NT INSTANS\INTERAKTIV
```
or the English interactive user,
```
NT AUTHORITY\INTERACTIVE
```
or any other localised user group with **write** permissions to a program folder's ACL?
Is this question actually "How do I use **secureObject**"? I cannot use the **Lo... | With recent releases of Wix, you can retrieve the localized names of often-used built-in user and group names via a property. For example, `WIX_ACCOUNT_NETWORKSERVICE` contains the localized name of the Network Service account. Unfortunately, as of 3.0.4513 `NT AUTHORITY\INTERACTIVE` is not among them.
There exists a ... |
170,144 | <p>Newbie WiX question: How do I<br>
1. Copy a single-use shell script to temp along with the installer<br>
e.g. </p>
<pre><code> <Binary Id='permissions.cmd' src='permissions.cmd'/>
</code></pre>
<p>2. Find and run that script at the end of the install.<br>
e.g. </p>
<pre><code><CustomAction Id='SetFo... | [
{
"answer_id": 170417,
"author": "CheGueVerra",
"author_id": 17787,
"author_profile": "https://Stackoverflow.com/users/17787",
"pm_score": 3,
"selected": false,
"text": "<p>I found the blog post <em><a href=\"http://blogs.technet.com/alexshev/archive/2008/02/21/from-msi-to-wix-part-5-cus... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25092/"
] | Newbie WiX question: How do I
1. Copy a single-use shell script to temp along with the installer
e.g.
```
<Binary Id='permissions.cmd' src='permissions.cmd'/>
```
2. Find and run that script at the end of the install.
e.g.
```
<CustomAction Id='SetFolderPermissions' BinaryKey='permissions.cmd'
E... | I found the blog post *[From MSI to WiX, Part 5 - Custom actions: Introduction](http://blogs.technet.com/alexshev/archive/2008/02/21/from-msi-to-wix-part-5-custom-actions.aspx)* helpful when I wanted to understand CustomActions in WiX.
You can also find the definition of CustomAction and its attributes in *[CustomActi... |
170,180 | <p>I want to loop over the elements of an HTML form, and store the values of the <input> fields in an object. The following code doesn't work, though:</p>
<pre><code>function config() {
$("#frmMain").children().map(function() {
var child = $("this");
if (child.is(":checkbox"))
thi... | [
{
"answer_id": 170197,
"author": "imjoevasquez",
"author_id": 24630,
"author_profile": "https://Stackoverflow.com/users/24630",
"pm_score": 5,
"selected": false,
"text": "<p>jQuery has an excellent function for looping through a set of elements: <a href=\"http://docs.jquery.com/Core/eac... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25097/"
] | I want to loop over the elements of an HTML form, and store the values of the <input> fields in an object. The following code doesn't work, though:
```
function config() {
$("#frmMain").children().map(function() {
var child = $("this");
if (child.is(":checkbox"))
this[child.attr("name")... | don't think you need quotations on this:
```
var child = $("this");
```
try:
```
var child = $(this);
``` |
170,186 | <p>I was previously taught today how to set parameters in a SQL query in .NET in this answer (<a href="https://stackoverflow.com/questions/169359/improving-code-readability-for-sql-commands#169369">click</a>).</p>
<p>Using parameters with values are fine, but when I try to set a field in the database to null I'm unsuc... | [
{
"answer_id": 170193,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 2,
"selected": false,
"text": "<p>Try setting it to <code>DbNull.Value</code>.</p>\n"
},
{
"answer_id": 170205,
"author": "Marc Gravell",
"... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20900/"
] | I was previously taught today how to set parameters in a SQL query in .NET in this answer ([click](https://stackoverflow.com/questions/169359/improving-code-readability-for-sql-commands#169369)).
Using parameters with values are fine, but when I try to set a field in the database to null I'm unsuccessful. Either the m... | you want [DBNull](http://msdn.microsoft.com/en-us/library/system.dbnull.aspx).Value.
In my shared DAL code, I use a helper method that just does:
```
foreach (IDataParameter param in cmd.Parameters)
{
if (param.Value == null) param.Value = DBNull.Value;
}
``` |
170,223 | <p>Creating hashes of hashes in Ruby allows for convenient two (or more) dimensional lookups. However, when inserting one must always check if the first index already exists in the hash. For example:</p>
<pre><code>h = Hash.new
h['x'] = Hash.new if not h.key?('x')
h['x']['y'] = value_to_insert
</code></pre>
<p>It wo... | [
{
"answer_id": 170240,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 7,
"selected": true,
"text": "<p>You can pass the <a href=\"http://www.ruby-doc.org/core/classes/Hash.html#M002868\" rel=\"nofollow noreferrer\"><co... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3533/"
] | Creating hashes of hashes in Ruby allows for convenient two (or more) dimensional lookups. However, when inserting one must always check if the first index already exists in the hash. For example:
```
h = Hash.new
h['x'] = Hash.new if not h.key?('x')
h['x']['y'] = value_to_insert
```
It would be preferable to do the... | You can pass the [`Hash.new`](http://www.ruby-doc.org/core/classes/Hash.html#M002868) function a block that is executed to yield a default value in case the queried value doesn't exist yet:
```
h = Hash.new { |h, k| h[k] = Hash.new }
```
Of course, this can be done recursively. There's [an article explaining the det... |
170,272 | <p>I have a class like the following:</p>
<pre><code>public class DropDownControl<T, Key, Value> : BaseControl
where Key: IComparable
{
private IEnumerable<T> mEnumerator;
private Func<T, Key> mGetKey;
private Func<T, Value> mGetValue;
private Func<Key, bool> mIsKeyInC... | [
{
"answer_id": 170279,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>No, basically. The static method in a non-generic class (such as DropDownControl [no <>]) is the best approac... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21566/"
] | I have a class like the following:
```
public class DropDownControl<T, Key, Value> : BaseControl
where Key: IComparable
{
private IEnumerable<T> mEnumerator;
private Func<T, Key> mGetKey;
private Func<T, Value> mGetValue;
private Func<Key, bool> mIsKeyInCollection;
public DropDownControl(strin... | No, basically. The static method in a non-generic class (such as DropDownControl [no <>]) is the best approach, as you should be able to use type-inference when you call Create() - i.e.
```
var control = DropDownControl.Create(name, dictionary);
```
C# 3.0 helps here both via "var" (very welcome here) and by the muc... |
170,297 | <p>Converting my current code project to TDD, I've noticed something.</p>
<pre><code>class Foo {
public event EventHandler Test;
public void SomeFunction() {
//snip...
Test(this, new EventArgs());
}
}
</code></pre>
<p>There are two dangers I can see when testing this code and relying on a... | [
{
"answer_id": 170302,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Should we take the coverage reported by such a tool with a grain of salt when writing tests? </p>... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] | Converting my current code project to TDD, I've noticed something.
```
class Foo {
public event EventHandler Test;
public void SomeFunction() {
//snip...
Test(this, new EventArgs());
}
}
```
There are two dangers I can see when testing this code and relying on a code coverage tool to det... | I wouldn't say "take it with a grain of salt" (there is a lot of utility to code coverage), but to quote myself
>
> TDD and code coverage are not a
> panacea:
>
>
> · Even with 100% block
> coverage, there still will be errors
> in the conditions that choose which
> blocks to execute.
>
>
> · Even with 100% b... |
170,328 | <p>I would like to execute a stored procedure within a stored procedure, e.g. </p>
<pre><code>EXEC SP1
BEGIN
EXEC SP2
END
</code></pre>
<p>But I only want <code>SP1</code> to finish after <code>SP2</code> has finished running so I need to find a way for <code>SP1</code> to wait for <code>SP2</code> to finish before... | [
{
"answer_id": 170333,
"author": "PeteT",
"author_id": 16989,
"author_profile": "https://Stackoverflow.com/users/16989",
"pm_score": 2,
"selected": false,
"text": "<p>Thats how it works stored procedures run in order, you don't need begin just something like</p>\n\n<pre><code>exec dbo.sp... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21004/"
] | I would like to execute a stored procedure within a stored procedure, e.g.
```
EXEC SP1
BEGIN
EXEC SP2
END
```
But I only want `SP1` to finish after `SP2` has finished running so I need to find a way for `SP1` to wait for `SP2` to finish before `SP1` ends.
`SP2` is being executed as part of `SP1` so I have somet... | T-SQL is not asynchronous, so you really have no choice but to wait until SP2 ends. Luckily, that's what you want.
```
CREATE PROCEDURE SP1 AS
EXEC SP2
PRINT 'Done'
``` |
170,337 | <p>I'm having trouble wrapping my head around this. Right now I have some models that looks kind of like this:</p>
<pre><code> def Review(models.Model)
...fields...
overall_score = models.FloatField(blank=True)
def Score(models.Model)
review = models.ForeignKey(Review)
question = models.TextField()
... | [
{
"answer_id": 170369,
"author": "Dmitry Shevchenko",
"author_id": 7437,
"author_profile": "https://Stackoverflow.com/users/7437",
"pm_score": 2,
"selected": false,
"text": "<p>If you'll use signals you'd be able to update Review score each time related score model gets saved. But if don... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24630/"
] | I'm having trouble wrapping my head around this. Right now I have some models that looks kind of like this:
```
def Review(models.Model)
...fields...
overall_score = models.FloatField(blank=True)
def Score(models.Model)
review = models.ForeignKey(Review)
question = models.TextField()
grade = mode... | Save/delete signals are generally favourable in situations where you need to make changes which aren't completely specific to the model in question, or could be applied to models which have something in common, or could be configured for use across models.
One common task in overridden `save` methods is automated gene... |
170,346 | <p>Has someone ever measured performance of Sequential Guid vs. Standard Guid when used as Primary Keys inside a database?</p>
<hr>
<p>I do not see the need for unique keys to be guessable or not, passing them from a web UI or in some other part seems a bad practice by itself and I do not see, if you have security co... | [
{
"answer_id": 170363,
"author": "massimogentilini",
"author_id": 11673,
"author_profile": "https://Stackoverflow.com/users/11673",
"pm_score": 8,
"selected": true,
"text": "<p><strong>GUID vs.Sequential GUID</strong></p>\n\n<p><br/><br/>\nA typical pattern it's to use Guid as PK for tab... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11673/"
] | Has someone ever measured performance of Sequential Guid vs. Standard Guid when used as Primary Keys inside a database?
---
I do not see the need for unique keys to be guessable or not, passing them from a web UI or in some other part seems a bad practice by itself and I do not see, if you have security concerns, how... | **GUID vs.Sequential GUID**
A typical pattern it's to use Guid as PK for tables, but, as referred in other discussions (see [Advantages and disadvantages of GUID / UUID database keys](https://stackoverflow.com/questions/45399/advantages-and-disadvantages-of-guid-uuid-database-keys))
there are some performance issues.
... |
170,355 | <p>I want to take an action in an Excel workbook macro after a period of inactivity (hide/protect some worksheets). What is the best/simplest way to achieve this?</p>
<p>Í'm assuming I'll use <code>Application.OnTime</code> to periodically check if the user has been active. But what events should I handle to see if ... | [
{
"answer_id": 170374,
"author": "Martin08",
"author_id": 8203,
"author_profile": "https://Stackoverflow.com/users/8203",
"pm_score": 0,
"selected": false,
"text": "<p>One simple way is to compare the content of the workbook with that of the last time you check. I believe combining this ... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13087/"
] | I want to take an action in an Excel workbook macro after a period of inactivity (hide/protect some worksheets). What is the best/simplest way to achieve this?
Í'm assuming I'll use `Application.OnTime` to periodically check if the user has been active. But what events should I handle to see if the user was "active" (... | I have implemented this by handling Workbook\_SheetActivate, Workbook\_SheetSelectionChange and Workbook\_WindowActivate. Realistically this is probably enough. |
170,377 | <p>I'm working on a java web-application, trying to be xml-friendly and writing my jsp files using the jspx/xml syntax. It took me hours of dissecting examples and configuration files to find out that with tomcat 5.5 files using the new syntax should end in .jspx, or tomcat won't translate tag libraries and stuff.</p>
... | [
{
"answer_id": 176853,
"author": "Mads Hansen",
"author_id": 14419,
"author_profile": "https://Stackoverflow.com/users/14419",
"pm_score": 3,
"selected": true,
"text": "<p>There are additional configurations for servlets that can affect behavior. I haven't tried it, but would assume tha... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6069/"
] | I'm working on a java web-application, trying to be xml-friendly and writing my jsp files using the jspx/xml syntax. It took me hours of dissecting examples and configuration files to find out that with tomcat 5.5 files using the new syntax should end in .jspx, or tomcat won't translate tag libraries and stuff.
Both f... | There are additional configurations for servlets that can affect behavior. I haven't tried it, but would assume that you could just override some of the default configurations for \*.jsp to use that of \*.jspx.
Try adding a **jsp-property-group** definition for **\*.jsp** with **is-xml** set to true:
```
<jsp-propert... |
170,380 | <p>Sample code that shows how to create threads using MFC declares the thread function as both static and <code>__cdecl</code>. Why is the latter required? Boost threads don't bother with this convention, so is it just an anachronism?</p>
<p>For example (MFC):</p>
<pre><code>static __cdecl UINT MyFunc(LPVOID pParam... | [
{
"answer_id": 170388,
"author": "Tim Farley",
"author_id": 4425,
"author_profile": "https://Stackoverflow.com/users/4425",
"pm_score": 1,
"selected": false,
"text": "<p>Because your thread is going to be called by a runtime function that manages this for you, and that function expects i... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | Sample code that shows how to create threads using MFC declares the thread function as both static and `__cdecl`. Why is the latter required? Boost threads don't bother with this convention, so is it just an anachronism?
For example (MFC):
```
static __cdecl UINT MyFunc(LPVOID pParam)
{
...
}
CWinThread* pThread = A... | \_\_cdecl tells the compiler to use the C calling convention (as opposed to the stdcall, fastcall or whatever other calling convention your compiler supports). I believe, VC++ uses stdcall by default.
The calling convention affects things such as how arguments are pushed onto the stack (or registers, in the case of fa... |
170,405 | <p>This might be a similar problem to my earlier two questions - see <a href="https://stackoverflow.com/questions/169934/any-scrubyt-command-that-clicks-a-link-returns-a-403-forbidden-error">here</a> and <a href="https://stackoverflow.com/questions/168868/how-to-get-next-page-link-with-scrubyt">here</a> but I'm trying ... | [
{
"answer_id": 171145,
"author": "user6325",
"author_id": 6325,
"author_profile": "https://Stackoverflow.com/users/6325",
"pm_score": 1,
"selected": false,
"text": "<pre><code> sudo gem install ruby-debug\n\nThis will give you access to a nice ruby debugger, start the debugger by alte... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1912/"
] | This might be a similar problem to my earlier two questions - see [here](https://stackoverflow.com/questions/169934/any-scrubyt-command-that-clicks-a-link-returns-a-403-forbidden-error) and [here](https://stackoverflow.com/questions/168868/how-to-get-next-page-link-with-scrubyt) but I'm trying to use the \_detail comma... | I had the same issue with relative links and fixed it like this... you have to set the :resolve param to the correct base url
```
event do
title 'The Coast of Mayo'
link_url
event_detail :resolve => 'http://www.nuffieldtheatre.co.uk/cn/events' do
dates "1-4 October"
times "7:30pm"
end
e... |
170,440 | <p>I have found that SP2 doesn't execute from within SP1 when SP1 is executed.</p>
<p>Below is the structure of SP1:</p>
<pre><code>ALTER PROCEDURE SP1 AS BEGIN
Declare c1 cursor....
open c1 fetch next from c1 ...
while @@fetch_status = 0 Begin
...
Fetch Next from c1 end
close c1
deallocate c1
exec sp2
end
<... | [
{
"answer_id": 170449,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 2,
"selected": false,
"text": "<p>What happens if you run the Stored Procedure code as a single query? If you put a <code>PRINT</code> statement before and... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21004/"
] | I have found that SP2 doesn't execute from within SP1 when SP1 is executed.
Below is the structure of SP1:
```
ALTER PROCEDURE SP1 AS BEGIN
Declare c1 cursor....
open c1 fetch next from c1 ...
while @@fetch_status = 0 Begin
...
Fetch Next from c1 end
close c1
deallocate c1
exec sp2
end
```
---
I see non o... | What happens if you run the Stored Procedure code as a single query? If you put a `PRINT` statement before and after the exec, do you see both outputs?
* If you do, then the stored procedure must have been executed. Probably it's not doing what you would like.
* If you don't see any print output, then there's somethin... |
170,452 | <p><strong>I am using the term "Lexical Encoding" for my lack of a better one.</strong></p>
<p>A Word is arguably the fundamental unit of communication as opposed to a Letter. Unicode tries to assign a numeric value to each Letter of all known Alphabets. What is a Letter to one language, is a Glyph to another. Unic... | [
{
"answer_id": 170469,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 3,
"selected": false,
"text": "<p>This question impinges on linguistics more than programming, but for languages which are highly synthetic (having... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] | **I am using the term "Lexical Encoding" for my lack of a better one.**
A Word is arguably the fundamental unit of communication as opposed to a Letter. Unicode tries to assign a numeric value to each Letter of all known Alphabets. What is a Letter to one language, is a Glyph to another. Unicode 5.1 assigns more than ... | Their are several major problems with this idea. In most languages, the meaning of a word, and the word associated with a meaning change very swiftly.
No sooner would you have a number assigned to a word, before the meaning of the word would change. For instance, the word "gay" used to only mean "happy" or "merry", bu... |
170,455 | <p>I have a stored procedure that returns multiple tables. How can I execute and read both tables?</p>
<p>I have something like this:</p>
<pre>
<code>
SqlConnection conn = new SqlConnection(CONNECTION_STRING);
SqlCommand cmd = new SqlCommand("sp_mult_tables",conn);
cmd.CommandType = CommandType.StoredProcedure);
IDa... | [
{
"answer_id": 170457,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to read the results into a DataSet, you'd be better using a DataAdapter.</p>\n\n<p>But with a DataReader, first... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have a stored procedure that returns multiple tables. How can I execute and read both tables?
I have something like this:
```
SqlConnection conn = new SqlConnection(CONNECTION_STRING);
SqlCommand cmd = new SqlCommand("sp_mult_tables",conn);
cmd.CommandType = CommandType.StoredProcedure);
IDataReader rdr = cmd.Exe... | Adapted from [MSDN](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter(VS.71).aspx):
```
using (SqlConnection conn = new SqlConnection(connection))
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(query, conn);
adapter.Fill(dataset);
retu... |
170,458 | <p>In some asp tutorials, like <a href="https://web.archive.org/web/20211020111619/https://www.4guysfromrolla.com/webtech/050900-1.shtml" rel="nofollow noreferrer">this</a>, i observe the following pattern:</p>
<blockquote>
<p>Application.Lock</p>
<p>'do some things with the application object</p>
<p>Application.Unlock... | [
{
"answer_id": 170468,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 1,
"selected": false,
"text": "<p>If one page tries to lock the Application object while it is already locked, it will wait until the page holding the lock h... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24461/"
] | In some asp tutorials, like [this](https://web.archive.org/web/20211020111619/https://www.4guysfromrolla.com/webtech/050900-1.shtml), i observe the following pattern:
>
> Application.Lock
>
>
> 'do some things with the application object
>
>
> Application.Unlock
>
>
>
However, since web pages can have multipl... | From the [MSDN documentation](http://msdn.microsoft.com/en-us/library/ms525184.aspx):
The `Lock` method **blocks other clients** from modifying the variables stored in the Application object, ensuring that **only one client at a time** can alter or access the Application variables.
If you **do not call** the `Applica... |
170,466 | <p>I need a programmatic way of creating a SQL Server ODBC Data Source. I can do this by directly accessing the Registry. It would be better if this could be done via an available (SQL Server/Windows) API to protect against changes in the registry keys or values with updated SQL Server drivers.</p>
<p><strong>Accepted... | [
{
"answer_id": 170480,
"author": "Bravax",
"author_id": 13911,
"author_profile": "https://Stackoverflow.com/users/13911",
"pm_score": 0,
"selected": false,
"text": "<p>I'd use odbcad32.exe which is located in your system32 folder.</p>\n\n<p>This will add your odbc data sources to the cor... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4023/"
] | I need a programmatic way of creating a SQL Server ODBC Data Source. I can do this by directly accessing the Registry. It would be better if this could be done via an available (SQL Server/Windows) API to protect against changes in the registry keys or values with updated SQL Server drivers.
**Accepted Answer Note:** ... | SQLConfigDataSource() does the job.
[MSDN article](http://msdn.microsoft.com/en-us/library/ck4z6wwt.aspx?ppud=4)
Just in case here is a VB6 example:
```
Const ODBC_ADD_DSN = 1 'user data source
Const ODBC_ADD_SYS_DSN = 4 'system data source
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal
hwnd... |
170,467 | <p>I want to experiment with GCC whole program optimizations. To do so I have to pass all C-files at once to the compiler frontend. However, I use makefiles to automate my build process, and I'm not an expert when it comes to makefile magic.</p>
<p>How should I modify the makefile if I want to compile (maybe even link... | [
{
"answer_id": 170472,
"author": "Alex B",
"author_id": 23643,
"author_profile": "https://Stackoverflow.com/users/23643",
"pm_score": 7,
"selected": true,
"text": "<pre><code>LIBS = -lkernel32 -luser32 -lgdi32 -lopengl32\nCFLAGS = -Wall\n\n# Should be equivalent to your list of C files,... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15955/"
] | I want to experiment with GCC whole program optimizations. To do so I have to pass all C-files at once to the compiler frontend. However, I use makefiles to automate my build process, and I'm not an expert when it comes to makefile magic.
How should I modify the makefile if I want to compile (maybe even link) using ju... | ```
LIBS = -lkernel32 -luser32 -lgdi32 -lopengl32
CFLAGS = -Wall
# Should be equivalent to your list of C files, if you don't build selectively
SRC=$(wildcard *.c)
test: $(SRC)
gcc -o $@ $^ $(CFLAGS) $(LIBS)
``` |
170,479 | <p>The problem is you can't tell the user how many characters are allowed in the field because the escaped value has more characters than the unescaped one.</p>
<p>I see a few solutions, but none looks very good:</p>
<ul>
<li>One whitelist for each field <em>(too much work and doesn't quite solve the problem)</em></l... | [
{
"answer_id": 170498,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 2,
"selected": false,
"text": "<p>making some wild assumptions about the context here:</p>\n\n<ul>\n<li>if the field can hold 32 characters, that is... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13211/"
] | The problem is you can't tell the user how many characters are allowed in the field because the escaped value has more characters than the unescaped one.
I see a few solutions, but none looks very good:
* One whitelist for each field *(too much work and doesn't quite solve the problem)*
* One blacklist for each field... | Don't build your application around the database - build the database for the application!
Design how you want the interface to work for the user first, work out the longest acceptable field length, and use that.
In general, don't escape before storing in the database - store raw data in the database and format it fo... |
170,492 | <p>What's the best way to create a non-NULL constraint in MySQL such that fieldA and fieldB can't both be NULL. I don't care if either one is NULL by itself, just as long as the other field has a non-NULL value. And if they both have non-NULL values, then it's even better.</p>
| [
{
"answer_id": 170525,
"author": "Miquella",
"author_id": 16313,
"author_profile": "https://Stackoverflow.com/users/16313",
"pm_score": 2,
"selected": false,
"text": "<p>I've done something similar in SQL Server, I'm not sure if it will work directly in MySQL, but:</p>\n\n<pre><code>ALTE... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12094/"
] | What's the best way to create a non-NULL constraint in MySQL such that fieldA and fieldB can't both be NULL. I don't care if either one is NULL by itself, just as long as the other field has a non-NULL value. And if they both have non-NULL values, then it's even better. | MySQL 5.5 introduced [SIGNAL](http://dev.mysql.com/doc/refman/5.5/en/signal.html), so we don't need the extra column in Bill Karwin's answer any more. Bill pointed out you also need a trigger for update so I've included that too.
```
CREATE TABLE foo (
FieldA INT,
FieldB INT
);
DELIMITER //
CREATE TRIGGER InsertF... |
170,500 | <p>I've been trying to encode a relational algebra in Scala (which to my knowlege has one of the most advanced type systems) and just don't seem to find a way to get where I want.</p>
<p>As I'm not that experienced with the academic field of programming language design I don't really know what feature to look for.</p>... | [
{
"answer_id": 170648,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 3,
"selected": false,
"text": "<p>What your asking for is to be able to structurally define a type as the <em>difference</em> of two other types (th... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24243/"
] | I've been trying to encode a relational algebra in Scala (which to my knowlege has one of the most advanced type systems) and just don't seem to find a way to get where I want.
As I'm not that experienced with the academic field of programming language design I don't really know what feature to look for.
So what lang... | What your asking for is to be able to structurally define a type as the *difference* of two other types (the original relation and the projection definition). I honestly can't think of any language which would allow you to do that. Types can be structurally cumulative (`A with B`) since `A with B` is a structural sub-t... |
170,536 | <p>How can I reset the <code>@@FETCH_STATUS</code> variable or set it to 0 in a stored procedure?</p>
<p>Also, can you bind FETCH_STATUS to a particular cursor?</p>
| [
{
"answer_id": 170539,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 1,
"selected": false,
"text": "<p>You can reset it by reading a cursor which is not at the end of a table.</p>\n"
},
{
"answer_id": 170573,
"au... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21004/"
] | How can I reset the `@@FETCH_STATUS` variable or set it to 0 in a stored procedure?
Also, can you bind FETCH\_STATUS to a particular cursor? | I am able to reproduce the [`@@FETCH_STATUS`](http://msdn.microsoft.com/en-us/library/ms187308.aspx) issue you describe, this is once you `DECLARE` a `CURSOR` and iterate through the rows by calling `FETCH NEXT` until your `@@FETCH_STATUS = -1`.
Then even if you `CLOSE` and `DEALLOCATE` your cursor, if you call that... |
170,556 | <p>This is related to the accepted answer for <a href="https://stackoverflow.com/questions/168486/whats-your-1-way-to-be-careful-with-a-live-database">What’s your #1 way to be careful with a live database</a>?</p>
<p>Suppose you create a temp table for backup purpose and make your changes in the original. The changes ... | [
{
"answer_id": 170588,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": true,
"text": "<p>I don't think that's desirable, I'd test harder before putting the table in production, but supposing it happened ... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9425/"
] | This is related to the accepted answer for [What’s your #1 way to be careful with a live database](https://stackoverflow.com/questions/168486/whats-your-1-way-to-be-careful-with-a-live-database)?
Suppose you create a temp table for backup purpose and make your changes in the original. The changes break the system and ... | I don't think that's desirable, I'd test harder before putting the table in production, but supposing it happened anyway, you'd have two options:
1.- Create an ON INSERT trigger which updates the temporary backup table with the rows inserted into the new table, massaging the data to fit into the old table
or
2.- Fin... |
170,578 | <p>On some Microsoft Access queries, I get the following message: Operation must use an updatable query. (Error 3073). I work around it by using temporary tables, but I'm wondering if there's a better way. All the tables involved have a primary key. Here's the code:</p>
<pre><code>UPDATE CLOG SET CLOG.NEXTDUE = (
... | [
{
"answer_id": 171008,
"author": "David-W-Fenton",
"author_id": 9787,
"author_profile": "https://Stackoverflow.com/users/9787",
"pm_score": 6,
"selected": true,
"text": "<p>Since Jet 4, all queries that have a join to a SQL statement that summarizes data will be non-updatable. You aren't... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4873/"
] | On some Microsoft Access queries, I get the following message: Operation must use an updatable query. (Error 3073). I work around it by using temporary tables, but I'm wondering if there's a better way. All the tables involved have a primary key. Here's the code:
```
UPDATE CLOG SET CLOG.NEXTDUE = (
SELECT H1.paid... | Since Jet 4, all queries that have a join to a SQL statement that summarizes data will be non-updatable. You aren't using a JOIN, but the WHERE clause is exactly equivalent to a join, and thus, the Jet query optimizer treats it the same way it treats a join.
I'm afraid you're out of luck without a temp table, though m... |
170,606 | <p>Publishing and/or collaborative applications often involve the sharing of access to resources. In a portal a user may be granted access to certain content as a member of a group or because of explicit access. The complete set of content could include public content, group membership content, and private user content... | [
{
"answer_id": 170620,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 0,
"selected": false,
"text": "<p>I generally have a schema like this</p>\n\n<p>Users −−∈ UserDocuments ∋−− Documents</p>\n... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Publishing and/or collaborative applications often involve the sharing of access to resources. In a portal a user may be granted access to certain content as a member of a group or because of explicit access. The complete set of content could include public content, group membership content, and private user content. O... | You may be interested in reading [this article by Steffen Bartsch](http://steffenbartsch.com/blog/2008/08/rails-authorization-plugins/ "Rails authorization plugins"). It summarizes all authorization plugins for Ruby on Rails, and I am sure it will help you find your solution (although this article is about Rails plugin... |
170,617 | <p>This might sound like a little bit of a crazy question, but how can I find out (hopefully via an API/registry key) the install time and date of Windows?</p>
<p>The best I can come up with so far is to look at various files in C:\Windows and try to guess... but that's not exactly a nice solution.</p>
| [
{
"answer_id": 170630,
"author": "Tommy",
"author_id": 20451,
"author_profile": "https://Stackoverflow.com/users/20451",
"pm_score": 8,
"selected": true,
"text": "<p>In <code>regedit.exe</code> go to:</p>\n\n<pre><code>HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849/"
] | This might sound like a little bit of a crazy question, but how can I find out (hopefully via an API/registry key) the install time and date of Windows?
The best I can come up with so far is to look at various files in C:\Windows and try to guess... but that's not exactly a nice solution. | In `regedit.exe` go to:
```
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate
```
It's given as the number of seconds since January 1, 1970. (Note: for Windows 10, this date will be when the last feature update was installed, not the original install date.)
To convert that number into a re... |
170,624 | <p>Does anyone know how to resize images proportionally using JavaScript?</p>
<p>I have tried to modify the DOM by adding attributes <code>height</code> and <code>width</code> on the fly, but seems did not work on IE6.</p>
| [
{
"answer_id": 170632,
"author": "Neall",
"author_id": 619,
"author_profile": "https://Stackoverflow.com/users/619",
"pm_score": 3,
"selected": false,
"text": "<p>Instead of modifying the height and width attributes of the image, try modifying the CSS height and width.</p>\n\n<pre><code>... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19463/"
] | Does anyone know how to resize images proportionally using JavaScript?
I have tried to modify the DOM by adding attributes `height` and `width` on the fly, but seems did not work on IE6. | To modify an image proportionally, simply only alter one of the width/height css properties, leave the other set to auto.
```
image.style.width = '50%'
image.style.height = 'auto'
```
This will ensure that its aspect ratio remains the same.
Bear in mind that browsers tend to *suck* at resizing images nicely - you'l... |
170,665 | <p>Back in VB6, I wrote a few functions that would let me code without having to care about the difference between null and '' for strings, null and 0 for numbers, etc. Nothing kills my productivity more when coding than having to add special case code for dealing with data that might cause some irrelevant error; 9999... | [
{
"answer_id": 170718,
"author": "Santiago Palladino",
"author_id": 12791,
"author_profile": "https://Stackoverflow.com/users/12791",
"pm_score": 3,
"selected": false,
"text": "<p>In C# most data types are not nullable (numbers, dates, etc), only strings are nullables. If you are getting... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/232/"
] | Back in VB6, I wrote a few functions that would let me code without having to care about the difference between null and '' for strings, null and 0 for numbers, etc. Nothing kills my productivity more when coding than having to add special case code for dealing with data that might cause some irrelevant error; 9999/100... | There are scads of conversion functions built-in. But... i'm not sure any of them do exactly what you want. Generally, .NET methods err on the side of caution when passed invalid input, and throw an exception.
Fortunately, you can easily write a utility method to convert a string representation of a numeric value, an... |
170,697 | <p>I'm changing my site to show friendly URLs like this:</p>
<pre><code>www.example.com/folder/topic
</code></pre>
<p>Works fine!</p>
<p>But when I add a parameter to the URL:</p>
<pre><code>www.example.com/folder/topic?page=2
</code></pre>
<p><code>$_GET</code> stops working. It doesn't recognise the parameter at... | [
{
"answer_id": 170707,
"author": "Robert K",
"author_id": 24950,
"author_profile": "https://Stackoverflow.com/users/24950",
"pm_score": 2,
"selected": false,
"text": "<p>If you are using mod_rewrite then it is your rules that are broken. Either the query string is not being passed, or t... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm changing my site to show friendly URLs like this:
```
www.example.com/folder/topic
```
Works fine!
But when I add a parameter to the URL:
```
www.example.com/folder/topic?page=2
```
`$_GET` stops working. It doesn't recognise the parameter at all. Am I missing something? The parameter worked fine before usin... | If it's a mod\_rewrite problem, which it sounds like, you could add the `[QSA]` flag to your mod\_rewrite rule, to append the query string to the rewritten URL instead of throwing it away.
Your rule will end up looking like:
`RewriteRule from to [QSA]` |
170,787 | <p>From <a href="http://support.microsoft.com/kb/317277" rel="nofollow noreferrer">http://support.microsoft.com/kb/317277</a>:
If Windows XP restarts because of a serious error, the Windows Error Reporting tool prompts you...</p>
<p>How can <em>my</em> app know that "Windows XP has restarted because of a serious error... | [
{
"answer_id": 170793,
"author": "Mihai Limbășan",
"author_id": 14444,
"author_profile": "https://Stackoverflow.com/users/14444",
"pm_score": 2,
"selected": false,
"text": "<p>You can look for a memory or kernel dump file with a recent creation time, if dump file generation has been enab... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1047/"
] | From <http://support.microsoft.com/kb/317277>:
If Windows XP restarts because of a serious error, the Windows Error Reporting tool prompts you...
How can *my* app know that "Windows XP has restarted because of a serious error"? | Note: this is a good question for a **[code-challenge](https://stackoverflow.com/questions/172184)**
Here are some executable codes, but feel free to add other solutions, in other languages:
---
The uptime might be a good indication:
```
net stats workstation | find /i "since"
```
Now link that information with a... |
170,791 | <p>I'm creating a .net custom control and it should be able to load multiple text files. I have a public property named ListFiles with those properties set : </p>
<pre><code>
[Browsable(true), Category("Configuration"), Description("List of Files to Load")]
public string ListFiles
{
get { return m_oList; }
... | [
{
"answer_id": 170810,
"author": "Cory",
"author_id": 11870,
"author_profile": "https://Stackoverflow.com/users/11870",
"pm_score": 5,
"selected": true,
"text": "<p>You can do this by adding a <a href=\"http://msdn.microsoft.com/en-us/library/ms171839.aspx\" rel=\"noreferrer\">UITypeEdit... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25152/"
] | I'm creating a .net custom control and it should be able to load multiple text files. I have a public property named ListFiles with those properties set :
```
[Browsable(true), Category("Configuration"), Description("List of Files to Load")]
public string ListFiles
{
get { return m_oList; }
set { m_oList... | You can do this by adding a [UITypeEditor](http://msdn.microsoft.com/en-us/library/ms171839.aspx).
[Here is an example](http://web.archive.org/web/20090218231316/http://www.winterdom.com/weblog/2006/08/23/ACustomUITypeEditorForActivityProperties.aspx) of a UITypeEditor that gives you the OpenFileDialog for chossing a ... |
170,800 | <p>I'm trying to embed a window from my process into the window of an external process using the <strong>SetParent</strong> function and have encountered a few problems that I'm hoping someone can help me out with. First off, here is an outline of what I am currently doing to embed my window into the application:</p>
... | [
{
"answer_id": 335724,
"author": "flashk",
"author_id": 25149,
"author_profile": "https://Stackoverflow.com/users/25149",
"pm_score": 5,
"selected": true,
"text": "<p>Well, I finally found the answer to my question.</p>\n\n<p>To fix the issue with the main app losing focus you need to us... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25149/"
] | I'm trying to embed a window from my process into the window of an external process using the **SetParent** function and have encountered a few problems that I'm hoping someone can help me out with. First off, here is an outline of what I am currently doing to embed my window into the application:
```
HWND myWindow; /... | Well, I finally found the answer to my question.
To fix the issue with the main app losing focus you need to use the **AttachThreadInput** function to attach the embedded window thread to the main app thread.
Also, one can use the **TranslateAccelerator** function in response to WM\_KEYDOWN messages to ensure acceler... |
170,825 | <p>I need to serialize the System.Configuration.SettingsProperty and System.Configuration.SettingsPropertyValue class object through WCF.</p>
| [
{
"answer_id": 170847,
"author": "sebagomez",
"author_id": 23893,
"author_profile": "https://Stackoverflow.com/users/23893",
"pm_score": 0,
"selected": false,
"text": "<p>I guess you're asking because you can't return a list of SettingProperty. \nI would create a serializable class mysel... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16439/"
] | I need to serialize the System.Configuration.SettingsProperty and System.Configuration.SettingsPropertyValue class object through WCF. | Using your own class is reasonable option. You can also use the VS designer settings if you want.
The VS designer keeps property settings in the [ApplicationSettingsBase](http://msdn.microsoft.com/en-us/library/system.configuration.applicationsettingsbase.aspx) class. By default, these properties are serialized/deser... |
170,850 | <p>The application I am currently working on generates a lot of SQL inline queries. All generated SQL is then handed off to a database execution class. I want to write a parsing service for the data execution class that will take a query like this:</p>
<pre><code>SELECT field1, field2, field3 FROM tablename WHERE foo=... | [
{
"answer_id": 170869,
"author": "Pittsburgh DBA",
"author_id": 10224,
"author_profile": "https://Stackoverflow.com/users/10224",
"pm_score": 2,
"selected": false,
"text": "<p>Don't do this. This is way too much work. Plus, there are loads of security risks with this approach.</p>\n\n<p>... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303/"
] | The application I am currently working on generates a lot of SQL inline queries. All generated SQL is then handed off to a database execution class. I want to write a parsing service for the data execution class that will take a query like this:
```
SELECT field1, field2, field3 FROM tablename WHERE foo=1 AND bar="baz... | Refactor now.
You're fooling yourself if you think this one abstraction layer is going to be able to come in quicker and easier. Deep down, you know it increases risk and uncertainty on the project, but you want to kill the SQL injection problem or whatever problem you are fighting with a magic bullet.
The time you w... |
170,854 | <p>I'm writing a game in Java, and I want the user to be able to provide input from both the command line and my GUI. Currently, I use this method to get input:<br></p>
<pre><code> static String getInput(){
System.out.println("Your move:");
Scanner sc = new Scanner(System.in);
return sc.next... | [
{
"answer_id": 170868,
"author": "Richard Walton",
"author_id": 15075,
"author_profile": "https://Stackoverflow.com/users/15075",
"pm_score": 0,
"selected": false,
"text": "<p>I made an application once that could run via the command line or using a GUI.\n<br>The way I did this was to de... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10601/"
] | I'm writing a game in Java, and I want the user to be able to provide input from both the command line and my GUI. Currently, I use this method to get input:
```
static String getInput(){
System.out.println("Your move:");
Scanner sc = new Scanner(System.in);
return sc.nextLine();
}
`... | This is possible - the easiest substitution for *System.in* would be a [PipedInputStream](http://java.sun.com/javase/6/docs/api/java/io/PipedInputStream.html). This must be hooked up to a [PipedOutputStream](http://java.sun.com/javase/6/docs/api/java/io/PipedOutputStream.html) that writes from another thread (in this c... |
170,900 | <blockquote>
<p><strong>Edit</strong>: Now I need to solve this problem for real, I did a little more
investigation and came up with a
number of things to reduce duplicate
content. I posted detailed code
samples on my blog: <a href="http://blog.dantup.me.uk/2009/04/reducing-duplicate-content-with-aspnet.html" rel="nofo... | [
{
"answer_id": 170955,
"author": "Danny Tuppeny",
"author_id": 25124,
"author_profile": "https://Stackoverflow.com/users/25124",
"pm_score": 3,
"selected": false,
"text": "<p>As well as posting here, I emailed ScottGu to see if he had a good response. He gave a sample for adding constrai... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25124/"
] | >
> **Edit**: Now I need to solve this problem for real, I did a little more
> investigation and came up with a
> number of things to reduce duplicate
> content. I posted detailed code
> samples on my blog: [Reducing
> Duplicate Content with ASP.NET MVC](http://blog.dantup.me.uk/2009/04/reducing-duplicate-content-with... | Bump!
**MVC 5** Now Supports producing only lowercase URLs and common trailing slash policy.
```
public static void RegisterRoutes(RouteCollection routes)
{
routes.LowercaseUrls = true;
routes.AppendTrailingSlash = false;
}
```
Also on my application to avoid duplicate content on differ... |
170,907 | <p>I have seen a few mentions of this idiom (including <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c#9282">on SO</a>):</p>
<pre><code>// Deliberately empty subscriber
public event EventHandler AskQuestion = delegate {};
</code></pre>
<p>The upside is clear - it avoids the need to check for nu... | [
{
"answer_id": 170915,
"author": "Maurice",
"author_id": 19676,
"author_profile": "https://Stackoverflow.com/users/19676",
"pm_score": 6,
"selected": true,
"text": "<p>The only downside is a very slight performance penalty as you are calling extra empty delegate. Other than that there is... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1853/"
] | I have seen a few mentions of this idiom (including [on SO](https://stackoverflow.com/questions/9033/hidden-features-of-c#9282)):
```
// Deliberately empty subscriber
public event EventHandler AskQuestion = delegate {};
```
The upside is clear - it avoids the need to check for null before raising the event.
**Howev... | The only downside is a very slight performance penalty as you are calling extra empty delegate. Other than that there is no maintenance penalty or other drawback. |
170,909 | <p>In C/C++, how would I turn a blocking socket into a non blocking socket in both WinSocks and *nix; so that select() would work correctly. You can use the pre-processor for the platform specific code.</p>
| [
{
"answer_id": 170929,
"author": "hazzen",
"author_id": 5066,
"author_profile": "https://Stackoverflow.com/users/5066",
"pm_score": 4,
"selected": true,
"text": "<p>On linux:</p>\n\n<pre><code>fcntl(fd, F_SETFL, O_NONBLOCK);\n</code></pre>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9418/"
] | In C/C++, how would I turn a blocking socket into a non blocking socket in both WinSocks and \*nix; so that select() would work correctly. You can use the pre-processor for the platform specific code. | On linux:
```
fcntl(fd, F_SETFL, O_NONBLOCK);
```
[Windows](http://msdn.microsoft.com/en-us/library/ms738573.aspx):
```
u_long on = 1;
ioctlsocket(fd, FIONBIO, &on);
``` |
170,931 | <p>I have a list of things (I'll call it L), an index(N) and a new thing(NEW). If I want to replace the thing in L at N with NEW, what is the best way to do this? Should I get the sublist up to N and from N to the end of the list and then glue together a new list from the first part, NEW, and the last part using list? ... | [
{
"answer_id": 170947,
"author": "David Plumpton",
"author_id": 16709,
"author_profile": "https://Stackoverflow.com/users/16709",
"pm_score": 1,
"selected": false,
"text": "<p>Sounds like you want either rplaca or replace. See <a href=\"http://www.lispworks.com/documentation/HyperSpec/Bo... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | I have a list of things (I'll call it L), an index(N) and a new thing(NEW). If I want to replace the thing in L at N with NEW, what is the best way to do this? Should I get the sublist up to N and from N to the end of the list and then glue together a new list from the first part, NEW, and the last part using list? Or ... | ```
(setf (nth N L) NEW)
```
should do the trick. |
170,937 | <p>I am thinking about making a website with some fairly intense JavaScript/canvas usage and I have been looking at <a href="http://ejohn.org/blog/processingjs/" rel="nofollow noreferrer">Processing.js</a> and it seems to me that it would make manipulating the canvas significantly easier. Does anyone know any reasons ... | [
{
"answer_id": 170951,
"author": "a7drew",
"author_id": 4239,
"author_profile": "https://Stackoverflow.com/users/4239",
"pm_score": 2,
"selected": false,
"text": "<p>If you're OK with it not working in IE7, then go for it. I've had it working in Firefox 3. It's a slick way to bring Silve... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] | I am thinking about making a website with some fairly intense JavaScript/canvas usage and I have been looking at [Processing.js](http://ejohn.org/blog/processingjs/) and it seems to me that it would make manipulating the canvas significantly easier. Does anyone know any reasons why I **shouldn't** use Processing.js? I ... | As mentioned, IE is not supported by Processing.js (including IE8 beta). I've also found processing.js to be a bit slow in terms of performance, compared to just using canvas (especially if you're parsing a string with Processing language, instead of using the javascript API).
I personally prefer the canvas API over t... |
170,956 | <p>I want my Ruby program to do different things on a Mac than on Windows. How can I find out on which system my program is running?</p>
| [
{
"answer_id": 170967,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": false,
"text": "<p>Either</p>\n\n<pre><code>irb(main):002:0> require 'rbconfig'\n=> true\nirb(main):003:0> Config::CONFIG[\... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want my Ruby program to do different things on a Mac than on Windows. How can I find out on which system my program is running? | Use the `RUBY_PLATFORM` constant, and optionally wrap it in a module to make it more friendly:
```
module OS
def OS.windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
def OS.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def OS.unix?
!OS.windows?
end
def OS.linux?
... |
170,961 | <p>I tried committing files with CRLF-ending lines, but it failed.</p>
<p>I spent a whole work day on my Windows computer trying different strategies and was almost drawn to stop trying to use Git and instead try <a href="http://en.wikipedia.org/wiki/Mercurial" rel="noreferrer">Mercurial</a>.</p>
<p>How to properly han... | [
{
"answer_id": 170968,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 7,
"selected": false,
"text": "<p>Don't convert line endings. It's not the VCS's job to interpret data -- just store and version it. Every modern tex... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25167/"
] | I tried committing files with CRLF-ending lines, but it failed.
I spent a whole work day on my Windows computer trying different strategies and was almost drawn to stop trying to use Git and instead try [Mercurial](http://en.wikipedia.org/wiki/Mercurial).
How to properly handle CRLF line endings? | Almost four years after asking this question, I have finally
found **an answer that completely satisfies me**!
See the details in **github:help**'s guide to
[Dealing with line endings](https://help.github.com/articles/dealing-with-line-endings/).
>
> Git allows you to set the line ending properties for a
> repo dir... |
170,986 | <p>What is the best method for adding options to a <code><select></code> from a JavaScript object using jQuery?</p>
<p>I'm looking for something that I don't need a plugin to do, but I would also be interested in the plugins that are out there.</p>
<p>This is what I did:</p>
<pre><code>selectValues = { "1": "t... | [
{
"answer_id": 171007,
"author": "matdumsa",
"author_id": 1775,
"author_profile": "https://Stackoverflow.com/users/1775",
"pm_score": 12,
"selected": true,
"text": "<p>The same as other answers, in a jQuery fashion:</p>\n\n<pre><code>$.each(selectValues, function(key, value) { \n $... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | What is the best method for adding options to a `<select>` from a JavaScript object using jQuery?
I'm looking for something that I don't need a plugin to do, but I would also be interested in the plugins that are out there.
This is what I did:
```
selectValues = { "1": "test 1", "2": "test 2" };
for (key in selectV... | The same as other answers, in a jQuery fashion:
```
$.each(selectValues, function(key, value) {
$('#mySelect')
.append($("<option></option>")
.attr("value", key)
.text(value));
});
``` |
170,997 | <p>What is the best method for removing a table row with jQuery?</p>
| [
{
"answer_id": 170998,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 3,
"selected": false,
"text": "<p>Is the following acceptable:</p>\n\n<pre><code>$('#myTableRow').remove();\n</code></pre>\n"
},
{
"answer_id":... | 2008/10/04 | [
"https://Stackoverflow.com/questions/170997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | What is the best method for removing a table row with jQuery? | You're right:
```
$('#myTableRow').remove();
```
This works fine if your row has an `id`, such as:
```
<tr id="myTableRow"><td>blah</td></tr>
```
If you don't have an `id`, you can use any of jQuery's [plethora of selectors](http://docs.jquery.com/Selectors). |
171,000 | <p>I want to recreate the the update panel postback without using an update panel to do the postback. What is the generic method for doing this?</p>
<p>For example, on Stackoverflow, when you vote up or down on a question it does a postback to update the database and I would bet they didn't use an update panel.</p>
... | [
{
"answer_id": 171014,
"author": "AaronSieb",
"author_id": 16911,
"author_profile": "https://Stackoverflow.com/users/16911",
"pm_score": 2,
"selected": false,
"text": "<p>You can just use a standard AJAX call to accomplish this. Create a .aspx page which updates the database in its Page... | 2008/10/04 | [
"https://Stackoverflow.com/questions/171000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7644/"
] | I want to recreate the the update panel postback without using an update panel to do the postback. What is the generic method for doing this?
For example, on Stackoverflow, when you vote up or down on a question it does a postback to update the database and I would bet they didn't use an update panel.
What do I have?... | The way that Stack Overflow works differs in two important ways from that CodeProject article.
* Stack Overflow is making its AJAX request against an ASP.NET MVC controller action, not a standalone ASPX page. You might consider this as the MVC analogue of an ASP.NET AJAX page method. In both cases, the ASPX method wil... |
171,027 | <p>I'm using jQuery to add an additional row to a table as the last row.</p>
<p>I have done it this way:</p>
<pre><code>$('#myTable').append('<tr><td>my data</td><td>more data</td></tr>');
</code></pre>
<p>Are there limitations to what you can add to a table like this (such as inputs... | [
{
"answer_id": 171049,
"author": "Luke Bennett",
"author_id": 17602,
"author_profile": "https://Stackoverflow.com/users/17602",
"pm_score": 12,
"selected": true,
"text": "<p>The approach you suggest is not guaranteed to give you the result you're looking for - what if you had a <code>tbo... | 2008/10/04 | [
"https://Stackoverflow.com/questions/171027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | I'm using jQuery to add an additional row to a table as the last row.
I have done it this way:
```
$('#myTable').append('<tr><td>my data</td><td>more data</td></tr>');
```
Are there limitations to what you can add to a table like this (such as inputs, selects, number of rows)? Is there a different way to do it? | The approach you suggest is not guaranteed to give you the result you're looking for - what if you had a `tbody` for example:
```
<table id="myTable">
<tbody>
<tr>...</tr>
<tr>...</tr>
</tbody>
</table>
```
You would end up with the following:
```
<table id="myTable">
<tbody>
<tr>...</tr>
<tr>... |
171,044 | <p>I currently use my local web server to allow costumers to preview some applications and also to allow downloads of "nightly builds" of my open source library.</p>
<p>Problem is I changed my ISP and now my port 80 is blocked. </p>
<p>Altough I know I could easily change the port on the Apache server, I'd like to av... | [
{
"answer_id": 171069,
"author": "Asaf R",
"author_id": 6827,
"author_profile": "https://Stackoverflow.com/users/6827",
"pm_score": 0,
"selected": false,
"text": "<p>I think most DynamicDNS services allow port-forwarding.</p>\n"
},
{
"answer_id": 171071,
"author": "Rolf",
... | 2008/10/04 | [
"https://Stackoverflow.com/questions/171044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14540/"
] | I currently use my local web server to allow costumers to preview some applications and also to allow downloads of "nightly builds" of my open source library.
Problem is I changed my ISP and now my port 80 is blocked.
Altough I know I could easily change the port on the Apache server, I'd like to avoid that unless t... | >
> What I'd like is for the costumer to
> type
> <http://myaddress.com/hello/there?a=1&b=2>
> and it get translated to
> <http://mylocalserver.com:8080/hello/there?a=1&b=2>
> and back again to the costumer on a
> transparent way.
>
>
>
I believe this is the Apache RewriteRule you're looking for to redirect ... |
171,097 | <p>I am attempting to use Ant's XMLValidate task to validate an XML document against a DTD. The problem is not that it doesn't work, but that it works too well. My DTD contains an xref element with an "@linkend" attribute of type IDREF. Most of these reference IDs outside of the current document. Because of this, m... | [
{
"answer_id": 174035,
"author": "mindas",
"author_id": 7345,
"author_profile": "https://Stackoverflow.com/users/7345",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if this helps, but could you try this workaround?\nCreate a temporary file, merge all your XMLs, and do the valid... | 2008/10/04 | [
"https://Stackoverflow.com/questions/171097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/207/"
] | I am attempting to use Ant's XMLValidate task to validate an XML document against a DTD. The problem is not that it doesn't work, but that it works too well. My DTD contains an xref element with an "@linkend" attribute of type IDREF. Most of these reference IDs outside of the current document. Because of this, my build... | Your problem derives from the difference between two interpretations of the DTD: yours, and the [spec's](http://www.w3.org/TR/REC-xml/#idref) :-). IDREFs must refer to ids in the same document, whereas yours refer to elements across documents.
My suggestion is to create your own version of the DTD that specifies NMTOK... |
171,130 | <p>So is there a way to initialize and start a command line Spring app without writing a main method. It seems like all such main methods have the same form</p>
<pre><code>public static void main(final String[] args) throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", Boot... | [
{
"answer_id": 171198,
"author": "SaM",
"author_id": 883,
"author_profile": "https://Stackoverflow.com/users/883",
"pm_score": 3,
"selected": false,
"text": "<p>I'll try to answer the question as I understand it: </p>\n\n<blockquote>\n <p>How to package a jar containing a spring configu... | 2008/10/04 | [
"https://Stackoverflow.com/questions/171130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4893/"
] | So is there a way to initialize and start a command line Spring app without writing a main method. It seems like all such main methods have the same form
```
public static void main(final String[] args) throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", Boot.class);
F... | I'll try to answer the question as I understand it:
>
> How to package a jar containing a spring configuration such as I just need to use `java -jar myjar.jar`?
>
>
>
The code snippet you have in your question simply works. You don't have to parameterise the `context.xml`. You just need to bundle your code and i... |
171,173 | <p>I'm trying to perform a bitwise NOT in SQL Server. I'd like to do something like this:</p>
<pre><code>update foo
set Sync = NOT @IsNew
</code></pre>
<p>Note: I started writing this and found out the answer to my own question before I finished. I still wanted to share with the community, since this piece of documen... | [
{
"answer_id": 171175,
"author": "Even Mien",
"author_id": 73794,
"author_profile": "https://Stackoverflow.com/users/73794",
"pm_score": 5,
"selected": false,
"text": "<p><strong>Bitwise NOT: ~</strong></p>\n\n<p>Bitwise AND: &</p>\n\n<p>Bitwise OR: |</p>\n\n<p>Bitwise XOR: ^</p>\n"... | 2008/10/04 | [
"https://Stackoverflow.com/questions/171173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/73794/"
] | I'm trying to perform a bitwise NOT in SQL Server. I'd like to do something like this:
```
update foo
set Sync = NOT @IsNew
```
Note: I started writing this and found out the answer to my own question before I finished. I still wanted to share with the community, since this piece of documentation was lacking on MSDN... | Yes, the ~ operator will work.
```
update foo
set Sync = ~@IsNew
``` |
171,196 | <p>I've implemented a basic search for a research project. I'm trying to make the search more efficient by building a <a href="http://en.wikipedia.org/wiki/Suffix_tree" rel="noreferrer">suffix tree</a>. I'm interested in a C# implementation of the <a href="http://en.wikipedia.org/wiki/Ukkonen%27s_algorithm" rel="norefe... | [
{
"answer_id": 193696,
"author": "torial",
"author_id": 13990,
"author_profile": "https://Stackoverflow.com/users/13990",
"pm_score": 4,
"selected": false,
"text": "<p>Hard question. Here's the closest to match I could find: <a href=\"http://www.codeproject.com/KB/recipes/ahocorasick.as... | 2008/10/04 | [
"https://Stackoverflow.com/questions/171196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23164/"
] | I've implemented a basic search for a research project. I'm trying to make the search more efficient by building a [suffix tree](http://en.wikipedia.org/wiki/Suffix_tree). I'm interested in a C# implementation of the [Ukkonen](http://en.wikipedia.org/wiki/Ukkonen%27s_algorithm) algorith. I don't want to waste time roll... | Hei, just finished implementing .NET (c#) library containing different trie implementations. Among them:
* Classical trie
* Patricia trie
* Suffix trie
* A trie using **Ukkonen's** algorithm
I tried to make source code easy readable. Usage is also very straight forward:
```
using Gma.DataStructures.StringSearch;
..... |
171,205 | <p>I've always been able to allocate 1400 megabytes for Java SE running on 32-bit Windows XP (Java 1.4, 1.5 and 1.6).</p>
<pre><code>java -Xmx1400m ...
</code></pre>
<p>Today I tried the same option on a new Windows XP machine using Java 1.5_16 and 1.6.0_07 and got the error:</p>
<pre><code>Error occurred during ini... | [
{
"answer_id": 171485,
"author": "James A. N. Stauffer",
"author_id": 6770,
"author_profile": "https://Stackoverflow.com/users/6770",
"pm_score": 3,
"selected": false,
"text": "<p>The JVM needs contiguous memory and depending on what else is running, what was running before, and how wind... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | I've always been able to allocate 1400 megabytes for Java SE running on 32-bit Windows XP (Java 1.4, 1.5 and 1.6).
```
java -Xmx1400m ...
```
Today I tried the same option on a new Windows XP machine using Java 1.5\_16 and 1.6.0\_07 and got the error:
```
Error occurred during initialization of VM
Could not reserve... | Keep in mind that Windows has virtual memory management and the JVM only needs memory that is contiguous *in its address space*. So, other programs running on the system shouldn't necessarily impact your heap size. What will get in your way are DLL's that get loaded in to your address space. Unfortunately optimizations... |
171,213 | <p>I need to make sure that user can run only one instance of my program at a time.<br>
Which means, that I have to check programatically, whether the same program is already running, and quit in such case.</p>
<p>The first thing that came to my mind was to create a file somewhere, when the program starts. Then, each ... | [
{
"answer_id": 171218,
"author": "SquareCog",
"author_id": 15962,
"author_profile": "https://Stackoverflow.com/users/15962",
"pm_score": 2,
"selected": false,
"text": "<p>I actually use exactly the process you describe, and it works fine except for the edge case that happens when you sud... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2239/"
] | I need to make sure that user can run only one instance of my program at a time.
Which means, that I have to check programatically, whether the same program is already running, and quit in such case.
The first thing that came to my mind was to create a file somewhere, when the program starts. Then, each other insta... | There are several methods you can use to accomplish only allowing one instance of your application:
**Method 1: Global synchronization object or memory**
It's usually done by creating a named global mutex or event. If it is already created, then you know the program is already running.
For example in windows you cou... |
171,230 | <p>I need to get access to the iTunes tags in an RSS feed using PHP. I've used simplepie before for podcast feeds, but I'm not sure how to get the iTunes tags using it. Is there a way to use simplepie to do it or is there a better way?</p>
<hr>
<p>Okay I tried Simple XML.</p>
<p>All this (the code below) seems to wo... | [
{
"answer_id": 171239,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": -1,
"selected": false,
"text": "<p>If you have PHP5, using Simple XML can help in parsing the info you need.</p>\n"
},
{
"answer_id": 171378... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/457918/"
] | I need to get access to the iTunes tags in an RSS feed using PHP. I've used simplepie before for podcast feeds, but I'm not sure how to get the iTunes tags using it. Is there a way to use simplepie to do it or is there a better way?
---
Okay I tried Simple XML.
All this (the code below) seems to work
```
$feed = si... | This code works for me:
```
//$pie is a SimplePie object
$iTunesCategories=$pie->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES,'category');
if ($iTunesCategories) {
foreach ($iTunesCategories as $iTunesCategory) {
$category=$iTunesCategory['attribs']['']['text'];
$subcat=$iTunesCategory['child']["http://www.it... |
171,251 | <p>I need to be able to merge two (very simple) JavaScript objects at runtime. For example I'd like to:</p>
<pre><code>var obj1 = { food: 'pizza', car: 'ford' }
var obj2 = { animal: 'dog' }
obj1.merge(obj2);
//obj1 now has three properties: food, car, and animal
</code></pre>
<p>Is there a built in way to do this? ... | [
{
"answer_id": 171256,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 13,
"selected": true,
"text": "<p><strong>ECMAScript 2018 Standard Method</strong></p>\n<p>You would use <a href=\"https://github.com/tc39/proposal-o... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] | I need to be able to merge two (very simple) JavaScript objects at runtime. For example I'd like to:
```
var obj1 = { food: 'pizza', car: 'ford' }
var obj2 = { animal: 'dog' }
obj1.merge(obj2);
//obj1 now has three properties: food, car, and animal
```
Is there a built in way to do this? I do not need recursion, a... | **ECMAScript 2018 Standard Method**
You would use [object spread](https://github.com/tc39/proposal-object-rest-spread):
```
let merged = {...obj1, ...obj2};
```
`merged` is now the union of `obj1` and `obj2`. Properties in `obj2` will overwrite those in `obj1`.
```
/** There's no limit to the number of objects you... |
171,279 | <p>How to I get the Fixnum returned by the following:</p>
<pre><code>"abc"[2]
</code></pre>
<p>Back into a character?</p>
| [
{
"answer_id": 171282,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": true,
"text": "<p>This will do it (if n is an integer):</p>\n\n<pre><code>n.chr\n</code></pre>\n"
},
{
"answer_id": 171410,
"... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117/"
] | How to I get the Fixnum returned by the following:
```
"abc"[2]
```
Back into a character? | This will do it (if n is an integer):
```
n.chr
``` |
171,289 | <p>I'm writing a php script where I call </p>
<pre><code>$lines = file('base_list.txt');
</code></pre>
<p>to break a file up into an array. The file has over 100,000 lines in it, which should be 100,000 elements in the array, but when I run </p>
<pre><code>print_r($lines);
exit;
</code></pre>
<p>the array only cont... | [
{
"answer_id": 171296,
"author": "Cory",
"author_id": 11870,
"author_profile": "https://Stackoverflow.com/users/11870",
"pm_score": 1,
"selected": false,
"text": "<p>I believe it is based on the amount of available memory as set in the php.ini file.</p>\n"
},
{
"answer_id": 17131... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/538/"
] | I'm writing a php script where I call
```
$lines = file('base_list.txt');
```
to break a file up into an array. The file has over 100,000 lines in it, which should be 100,000 elements in the array, but when I run
```
print_r($lines);
exit;
```
the array only contains 7280 elements.
So I'm curious, WTF? Is the... | Darryl Hein,
Yeah, there isn't anything in the error logs. I even increased error reporting and still nothing relevant to print\_r().
In response to Jay:
I ran
```
echo count($lines);
```
and I get a result of 105,546 but still print\_r() only displays 7280.
Taking Rob Walker's advice I looped over all the elem... |
171,292 | <p>I just fell in love with NHibernate and the fluent interface. The latter enables very nice mappings with refactoring support (no more need for xml files).</p>
<p>But nobody is perfect, so I am missing the many-to-any mapping in fluent. Does anybody know if it is already there? If so, a simple line of code would be ... | [
{
"answer_id": 171296,
"author": "Cory",
"author_id": 11870,
"author_profile": "https://Stackoverflow.com/users/11870",
"pm_score": 1,
"selected": false,
"text": "<p>I believe it is based on the amount of available memory as set in the php.ini file.</p>\n"
},
{
"answer_id": 17131... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25206/"
] | I just fell in love with NHibernate and the fluent interface. The latter enables very nice mappings with refactoring support (no more need for xml files).
But nobody is perfect, so I am missing the many-to-any mapping in fluent. Does anybody know if it is already there? If so, a simple line of code would be nice.
But... | Darryl Hein,
Yeah, there isn't anything in the error logs. I even increased error reporting and still nothing relevant to print\_r().
In response to Jay:
I ran
```
echo count($lines);
```
and I get a result of 105,546 but still print\_r() only displays 7280.
Taking Rob Walker's advice I looped over all the elem... |
171,301 | <pre><code>int x = n / 3; // <-- make this faster
// for instance
int a = n * 3; // <-- normal integer multiplication
int b = (n << 1) + n; // <-- potentially faster multiplication
</code></pre>
| [
{
"answer_id": 171309,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know if it's faster but if you want to use a bitwise operator to perform binary division you can use the shif... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1200558/"
] | ```
int x = n / 3; // <-- make this faster
// for instance
int a = n * 3; // <-- normal integer multiplication
int b = (n << 1) + n; // <-- potentially faster multiplication
``` | This is the fastest as the compiler will optimize it if it can depending on the output processor.
```
int a;
int b;
a = some value;
b = a / 3;
``` |
171,318 | <p>I'm generating a ton of XML that is to be passed to an API as a post variable when a user click on a form button. I also want to be able to show the user the XML before hand.</p>
<p>The code is sorta like the following in structure:</p>
<pre><code><?php
$lots of = "php";
?>
<xml>
<morexml&g... | [
{
"answer_id": 171324,
"author": "Robert K",
"author_id": 24950,
"author_profile": "https://Stackoverflow.com/users/24950",
"pm_score": 6,
"selected": false,
"text": "<p>Put this at your start:</p>\n\n<pre>ob_start();</pre>\n\n<p>And to get the buffer back:</p>\n\n<pre>$value = ob_get_co... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/319/"
] | I'm generating a ton of XML that is to be passed to an API as a post variable when a user click on a form button. I also want to be able to show the user the XML before hand.
The code is sorta like the following in structure:
```
<?php
$lots of = "php";
?>
<xml>
<morexml>
<?php
while(){
?>
<somegene... | ```
<?php ob_start(); ?>
<xml/>
<?php $xml = ob_get_clean(); ?>
<input value="<?php echo $xml ?>" />͏͏͏͏͏͏
``` |
171,326 | <p>I have a bad habit of using the cursor keys of my keyboard to navigate source code. It's something I've done for 15 years and this of course means that my navigating speed is limited by the speed of the keyboard. On both Vista and OS X (I dual boot a MacBook), I have my key repeat rate turned all the way up. But in ... | [
{
"answer_id": 171330,
"author": "Robert K",
"author_id": 24950,
"author_profile": "https://Stackoverflow.com/users/24950",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know how to accelerate beyond the limit, but I know how to skip further in a single press. My knowledge is on... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] | I have a bad habit of using the cursor keys of my keyboard to navigate source code. It's something I've done for 15 years and this of course means that my navigating speed is limited by the speed of the keyboard. On both Vista and OS X (I dual boot a MacBook), I have my key repeat rate turned all the way up. But in Vis... | On Mac OS X, open the Global Preferences plist
```
open ~/Library/Preferences/.GlobalPreferences.plist
```
Then change the KeyRepeat field. Smaller numbers will speed up your cursor rate. The settings dialog will only set it to a minimum of 2, so if you go to 0 or 1, you'll get a faster cursor.
I had to reboot for ... |
171,332 | <p>I'm trying to Unit Test a class that has many internal functions. These obviously need testing too, but my Tests project is seperate, mainly because it covers many small, related projects. What I have so far is:</p>
<pre><code>FieldInfo[] _fields =
typeof(ButtonedForm.TitleButton).GetFields(
BindingFla... | [
{
"answer_id": 171337,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 6,
"selected": true,
"text": "<p>It would be more appropriate to use the <a href=\"http://msdn.microsoft.com/en-us/library/system.runtime.compilers... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] | I'm trying to Unit Test a class that has many internal functions. These obviously need testing too, but my Tests project is seperate, mainly because it covers many small, related projects. What I have so far is:
```
FieldInfo[] _fields =
typeof(ButtonedForm.TitleButton).GetFields(
BindingFlags.NonPublic |... | It would be more appropriate to use the [`InternalsVisibleTo`](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx) attribute to grant access to the internal members of the assembly to your unit test assembly.
Here is a link with some helpful additional info and a w... |
171,343 | <p>I'm writing a quick Rails app and was wondering how I can validate the success an exec'd command. The two commands I'm running are and SVN update, and a cp from one directory to another.</p>
| [
{
"answer_id": 171359,
"author": "Unixmonkey",
"author_id": 23915,
"author_profile": "https://Stackoverflow.com/users/23915",
"pm_score": -1,
"selected": false,
"text": "<p>For SVN update, check the version number before and after the update.</p>\n\n<pre><code>svn_start_version = IO.pope... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15846/"
] | I'm writing a quick Rails app and was wondering how I can validate the success an exec'd command. The two commands I'm running are and SVN update, and a cp from one directory to another. | If you use the [Kernel.system()](http://www.ruby-doc.org/core/classes/Kernel.html#M005982) method it will return a boolean indicating the success of the command.
```
result = system("cp -r dir1 dir2")
if(result)
#do the next thing
else
# handle the error
```
There is a good comparison of different ruby system comman... |
171,352 | <p>Is there an easy method to store a person's user settings in a sql 2000 database. Ideally all settings in one field so I don't keep having to edit the table every time I add a setting. I am thinking along the lines of serialize a settings class if anyone has an example.</p>
<p>The reason I don't want to use the bui... | [
{
"answer_id": 171354,
"author": "Joel Martinez",
"author_id": 5416,
"author_profile": "https://Stackoverflow.com/users/5416",
"pm_score": 1,
"selected": false,
"text": "<p>you can easily serialize classes in C#: <a href=\"http://www.google.com/search?q=c%23+serializer\" rel=\"nofollow n... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16989/"
] | Is there an easy method to store a person's user settings in a sql 2000 database. Ideally all settings in one field so I don't keep having to edit the table every time I add a setting. I am thinking along the lines of serialize a settings class if anyone has an example.
The reason I don't want to use the built in .NET... | The VS designer keeps property settings in the [ApplicationSettingsBase](http://msdn.microsoft.com/en-us/library/system.configuration.applicationsettingsbase.aspx) class. By default, these properties are serialized/deserialized into a per user XML file. You can override this behavior by using a custom [SettingsProvider... |
171,366 | <p>I am VERY new to ASP.NET. I come from a VB6 / ASP (classic) / SQL Server 2000 background. I am reading a lot about Visual Studio 2008 (have installed it and am poking around). I have read about "reflection" and would like someone to explain, as best as you can to an older developer of the technologies I've writte... | [
{
"answer_id": 171375,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 3,
"selected": false,
"text": "<p>Reflection is how you can explore the internals of different Types, without normally having access (ie. privat... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am VERY new to ASP.NET. I come from a VB6 / ASP (classic) / SQL Server 2000 background. I am reading a lot about Visual Studio 2008 (have installed it and am poking around). I have read about "reflection" and would like someone to explain, as best as you can to an older developer of the technologies I've written abov... | Reflection lets you programmatically load an assembly, get a list of all the types in an assembly, get a list of all the properties and methods in these types, etc.
As an example:
```
myobject.GetType().GetProperty("MyProperty").SetValue(myobject, "wicked!", null)
``` |
171,452 | <p>I've got an app that my client wants to open a kiosk window to ie on startup that goes to their corporate internet. Vb isn't my thing but they wanted it integrated into their current program and I figured it would be easy so I've got</p>
<pre><code>Shell ("explorer.exe http://www.corporateintranet.com")
</code></p... | [
{
"answer_id": 171459,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>If you would like to use -k, you will probably want to call <code>iexplore.exe</code> instead of <code>explorer.exe</c... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got an app that my client wants to open a kiosk window to ie on startup that goes to their corporate internet. Vb isn't my thing but they wanted it integrated into their current program and I figured it would be easy so I've got
```
Shell ("explorer.exe http://www.corporateintranet.com")
```
and command line th... | If you would like to use -k, you will probably want to call `iexplore.exe` instead of `explorer.exe`. |
171,480 | <p>I have a value like this:</p>
<pre class="lang-none prettyprint-override"><code>"Foo Bar" "Another Value" something else
</code></pre>
<p>What regex will return the values enclosed in the quotation marks (e.g. <code>Foo Bar</code> and <code>Another Value</code>)?</p>
| [
{
"answer_id": 171483,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 9,
"selected": false,
"text": "<p>In general, the following regular expression fragment is what you are looking for:</p>\n\n<pre><code>\"(.*?)\"\n</code... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4646/"
] | I have a value like this:
```none
"Foo Bar" "Another Value" something else
```
What regex will return the values enclosed in the quotation marks (e.g. `Foo Bar` and `Another Value`)? | I've been using the following with great success:
```
(["'])(?:(?=(\\?))\2.)*?\1
```
It supports nested quotes as well.
For those who want a deeper explanation of how this works, here's an explanation from user [ephemient](https://stackoverflow.com/users/20713/ephemient):
>
> `([""'])` match a quote; `((?=(\\?))\... |
171,512 | <p>I wish to implement a 2d bit map class in Python. The class would have the following requirements:</p>
<ol>
<li><p>Allow the creating of arbitrarily sized 2d bitmaps. i.e. to create an 8 x 8 bitmap (8 bytes), something like:</p>
<pre><code>bitmap = Bitmap(8,8)
</code></pre></li>
<li><p>provide an API to access the... | [
{
"answer_id": 171611,
"author": "Ber",
"author_id": 11527,
"author_profile": "https://Stackoverflow.com/users/11527",
"pm_score": 2,
"selected": false,
"text": "<p>No need to create this yourself.</p>\n\n<p>Use the very good <a href=\"http://www.pythonware.com/products/pil/\" rel=\"nofo... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10942/"
] | I wish to implement a 2d bit map class in Python. The class would have the following requirements:
1. Allow the creating of arbitrarily sized 2d bitmaps. i.e. to create an 8 x 8 bitmap (8 bytes), something like:
```
bitmap = Bitmap(8,8)
```
2. provide an API to access the bits in this 2d map as boolean or even integ... | [Bit-Packing](http://mentat.za.net/numpy/refguide/routines.bitwise.xhtml#bit-packing) numpy ( [SciPY](http://www.scipy.org/) ) arrays does what you are looking for.
The example shows 4x3 bit (Boolean) array packed into 4 8-bit bytes. *unpackbits* unpacks uint8 arrays into a Boolean output array that you can use in comp... |
171,516 | <p>In my ASP.NET application using InProc sessions, Session_End calls a static method in another object to do session-specific clean up. This clean up uses a shared database connection that I am storing in application state.</p>
<p>The problem is that I cannot see how to access the application state without passing i... | [
{
"answer_id": 171538,
"author": "Greg Dean",
"author_id": 1200558,
"author_profile": "https://Stackoverflow.com/users/1200558",
"pm_score": 1,
"selected": false,
"text": "<p>You should be able to access the SessionState object using the Session property from inside Session_End.</p>\n\n<... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6234/"
] | In my ASP.NET application using InProc sessions, Session\_End calls a static method in another object to do session-specific clean up. This clean up uses a shared database connection that I am storing in application state.
The problem is that I cannot see how to access the application state without passing it (or rath... | Where are you creating the "NeedsCleanup" instances? If it's in Session\_Start, it makes sense that your global class would know how/when to both create and destroy these instance.
I understand you'd like to decouple the cleanup of NeedsCleanup from its caller. Perhaps a cleaner way would to pass in the "HttpApplicat... |
171,519 | <p>I'm looking for a way to authenticate users through LDAP with PHP (with Active Directory being the provider). Ideally, it should be able to run on IIS 7 (<a href="http://adldap.sourceforge.net/" rel="noreferrer">adLDAP</a> does it on Apache). Anyone had done anything similar, with success?</p>
<ul>
<li>Edit: I'd pr... | [
{
"answer_id": 171523,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 3,
"selected": false,
"text": "<p>PHP has libraries: <a href=\"http://ca.php.net/ldap\" rel=\"noreferrer\">http://ca.php.net/ldap</a></p>\n\n<p>PEAR al... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18406/"
] | I'm looking for a way to authenticate users through LDAP with PHP (with Active Directory being the provider). Ideally, it should be able to run on IIS 7 ([adLDAP](http://adldap.sourceforge.net/) does it on Apache). Anyone had done anything similar, with success?
* Edit: I'd prefer a library/class with code that's read... | Importing a whole library seems inefficient when all you need is essentially two lines of code...
```
$ldap = ldap_connect("ldap.example.com");
if ($bind = ldap_bind($ldap, $_POST['username'], $_POST['password'])) {
// log them in!
} else {
// error message
}
``` |