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 |
|---|---|---|---|---|---|---|
493,345 | <p>How do I make a control fill the whole cell in a ListView (with a GridView)? I've played around with various properties, but the control is always it's minimum size.</p>
<p>Here's my xaml.</p>
<pre><code><Window x:Class="ListViewUserControlTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/pres... | [
{
"answer_id": 493381,
"author": "mjfgates",
"author_id": 21434,
"author_profile": "https://Stackoverflow.com/users/21434",
"pm_score": 2,
"selected": false,
"text": "<p>Your user control specifies the values for the \"Height\" and \"Width\" properties. Nothing is allowed to override pro... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233/"
] | How do I make a control fill the whole cell in a ListView (with a GridView)? I've played around with various properties, but the control is always it's minimum size.
Here's my xaml.
```
<Window x:Class="ListViewUserControlTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="htt... | After narrowing down my question I was about to Google and find an [answer here](http://www.interact-sw.co.uk/iangblog/2007/05/30/fill-wpf-listview-columns).
Basically for some reason the ListViewItems are set to align to the Left. Setting them to Stretch fixes this problem. This is done through a style like so:
```
... |
493,367 | <p>Given <code>[1,2,3,4,5]</code>, how can I do something like </p>
<pre><code>1/1, 1/2, 1/3,1/4,1/5, ...., 3/1,3/2,3/3,3/4,3/5,.... 5/1,5/2,5/3,5/4,5/5
</code></pre>
<p>I would like to store all the results, find the minimum, and return the two numbers used to find the minimum. So in the case I've described above I ... | [
{
"answer_id": 493423,
"author": "Kiv",
"author_id": 49559,
"author_profile": "https://Stackoverflow.com/users/49559",
"pm_score": 6,
"selected": true,
"text": "<p>You can do this using <a href=\"http://docs.python.org/tutorial/datastructures.html#list-comprehensions\" rel=\"noreferrer\"... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Given `[1,2,3,4,5]`, how can I do something like
```
1/1, 1/2, 1/3,1/4,1/5, ...., 3/1,3/2,3/3,3/4,3/5,.... 5/1,5/2,5/3,5/4,5/5
```
I would like to store all the results, find the minimum, and return the two numbers used to find the minimum. So in the case I've described above I would like to return `(1,5)`.
So bas... | You can do this using [list comprehensions](http://docs.python.org/tutorial/datastructures.html#list-comprehensions) and [min()](http://docs.python.org/library/functions.html) (Python 3.0 code):
```
>>> nums = [1,2,3,4,5]
>>> [(x,y) for x in nums for y in nums]
[(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), ... |
493,369 | <p>All of a sudden in this MVC site I have no views that can be found.</p>
<pre><code>The view 'LoginUltraMind' or its master could not be found. The following locations were searched:
~/Views/MyAccount/LoginUltraMind.aspx
~/Views/MyAccount/LoginUltraMind.ascx
~/Views/Shared/LoginUltraMind.aspx
~/Views/Shared/LoginUlt... | [
{
"answer_id": 493435,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 0,
"selected": false,
"text": "<p>Use fiddler to see exactly what is being requested. It is probably an issue resolving your web application base ad... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34548/"
] | All of a sudden in this MVC site I have no views that can be found.
```
The view 'LoginUltraMind' or its master could not be found. The following locations were searched:
~/Views/MyAccount/LoginUltraMind.aspx
~/Views/MyAccount/LoginUltraMind.ascx
~/Views/Shared/LoginUltraMind.aspx
~/Views/Shared/LoginUltraMind.ascx
~/... | Ended up I had 2 Pages sections in my web.config located in the views directory. I guess when I upgraded I wasn't paying attention and didn't see the previous section. Totally idiot maneuver on my part, but I do wish the error thrown would have told me that instead of a list of files it couldn't find. |
493,372 | <p>When compiling a makefile with the BCB5 commandline tools, the linker gives me this error:</p>
<pre><code> [exec] D:\PROGRA~1\Borland\CBUILD~1\Bin\..\BIN\ilink32 @MAKE0000.@@@
[exec] Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
[exec] Fatal: Unable to open file 'CONSTS.OBJ'
[exec] ** error 2 ** ... | [
{
"answer_id": 493471,
"author": "Kluge",
"author_id": 8752,
"author_profile": "https://Stackoverflow.com/users/8752",
"pm_score": 0,
"selected": false,
"text": "<p>Do you have a consts.dcu in the C:\\Program Files\\Borland\\CBuilder5\\Lib\\Obj folder?</p>\n\n<p>I don't know exactly what... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54790/"
] | When compiling a makefile with the BCB5 commandline tools, the linker gives me this error:
```
[exec] D:\PROGRA~1\Borland\CBUILD~1\Bin\..\BIN\ilink32 @MAKE0000.@@@
[exec] Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
[exec] Fatal: Unable to open file 'CONSTS.OBJ'
[exec] ** error 2 ** deleting lib\p... | I suspect that one of the headers included in the source code has a line like this in it:
```
#pragma link "consts"
```
preprocess the .cpp files and you should be able to find where this is coming from.
There are other possibilities, but I think this is the most likely one. |
493,376 | <p>I am returning a List from my WCF method. In my client code, it's return type shows as MyObject[]. I have to either use MyObject[], or IList, or IEnumerable... </p>
<pre><code>WCFClient myClient = new WCFClient();
MyObject[] list = myClient.GetMyStuff();
or
IList<MyObject> list = myClient.GetMyStuf... | [
{
"answer_id": 493390,
"author": "Jason Punyon",
"author_id": 6212,
"author_profile": "https://Stackoverflow.com/users/6212",
"pm_score": 2,
"selected": false,
"text": "<p>When you add the service reference to the client project click the advanced button and change collection type from a... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | I am returning a List from my WCF method. In my client code, it's return type shows as MyObject[]. I have to either use MyObject[], or IList, or IEnumerable...
```
WCFClient myClient = new WCFClient();
MyObject[] list = myClient.GetMyStuff();
or
IList<MyObject> list = myClient.GetMyStuff();
or
IEnumerabl... | You can specify that you want to use a generic list instead of an array by clicking the advanced button when you add a reference, or you can right click on the service reference and choose configure to change it in place.
The reason is that WCF serializes Generic lists as arrays to send across the wire. The configurat... |
493,386 | <p>Example in C:</p>
<pre class="lang-cpp prettyprint-override"><code>for (int i = 0; i < 4; i++)
printf(".");
</code></pre>
<p>Output:</p>
<pre><code>....
</code></pre>
<p>In Python:</p>
<pre class="lang-py prettyprint-override"><code>>>> for i in range(4): print('.')
.
.
.
.
>>> pri... | [
{
"answer_id": 493399,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 13,
"selected": true,
"text": "<p>In Python 3, you can use the <code>sep=</code> and <code>end=</code> parameters of the <a href=\"https://docs.python.... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21384/"
] | Example in C:
```cpp
for (int i = 0; i < 4; i++)
printf(".");
```
Output:
```
....
```
In Python:
```py
>>> for i in range(4): print('.')
.
.
.
.
>>> print('.', '.', '.', '.')
. . . .
```
In Python, `print` will add a `\n` or space. How can I avoid that? I'd like to know how to "append" strings to `stdout`... | In Python 3, you can use the `sep=` and `end=` parameters of the [`print`](https://docs.python.org/library/functions.html#print) function:
To not add a newline to the end of the string:
```
print('.', end='')
```
To not add a space between all the function arguments you want to print:
```
print('a', 'b', 'c', sep=... |
493,388 | <p>Is the memory from primitive data types (int, char,etc) immediately released once they leave scope, or added to garbage collection for later release?</p>
<p>consider:</p>
<pre><code>For x as integer=0 to 1000
dim y as integer
Next
</code></pre>
<p>If this doesn't add 1000 integers to the garbage collector for cle... | [
{
"answer_id": 493400,
"author": "foson",
"author_id": 22539,
"author_profile": "https://Stackoverflow.com/users/22539",
"pm_score": 2,
"selected": false,
"text": "<p>Primitive data types (except string) are value types and are created on the stack and not the heap. They are popped off ... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57883/"
] | Is the memory from primitive data types (int, char,etc) immediately released once they leave scope, or added to garbage collection for later release?
consider:
```
For x as integer=0 to 1000
dim y as integer
Next
```
If this doesn't add 1000 integers to the garbage collector for clean up later,
how does it treat st... | Okay, with only two answers there's already misinformation...
* String isn't a primitive type
* String isn't a value type
* Value type values *aren't* always created on the stack - it depends on where the variable is. If it's part of a class, it's stored on the heap with the rest of the data for that object.
* Even *l... |
493,401 | <p>mmm, I have just a little confusion about multiple auto declarations in the upcoming C++0x standard.</p>
<pre><code>auto a = 10, b = 3.f , * c = new Class();
</code></pre>
<p>somewhere I read it is not allowed.
The reason was(?) because it was not clear if the consecutive declarations should have the same type of... | [
{
"answer_id": 493404,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 0,
"selected": false,
"text": "<p>The first one would kind of line up with how type inference works in the return type of the ?: operator.</p>\n"
},
{
... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60373/"
] | mmm, I have just a little confusion about multiple auto declarations in the upcoming C++0x standard.
```
auto a = 10, b = 3.f , * c = new Class();
```
somewhere I read it is not allowed.
The reason was(?) because it was not clear if the consecutive declarations should have the same type of the first one , (int in t... | It's probably not the latest, but my C++0x draft standard from June 2008 says you can do the following:
```
auto x = 5; // OK: x has type int
const auto *v = &x, u = 6; // OK: v has type const int*, u has type const int
```
So unless something has changed from June this is (or will be) permitted in a limited form wi... |
493,440 | <p>I'm working on a C-brain teaser: Write the standard Hello-World program, without semi-colons.</p>
<p>My best answer so far is:</p>
<pre><code>int main(void)
{
if (printf("Hello World!\n"), exit(0), 0)
{
/* do nothing */
}
}
</code></pre>
<p>But I don't understand why I don't get compiler erro... | [
{
"answer_id": 493451,
"author": "ggf31416",
"author_id": 38561,
"author_profile": "https://Stackoverflow.com/users/38561",
"pm_score": 3,
"selected": false,
"text": "<p>if you don't return anything the program will return 0.\nSee <a href=\"http://www.research.att.com/~bs/bs_faq2.html#vo... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34824/"
] | I'm working on a C-brain teaser: Write the standard Hello-World program, without semi-colons.
My best answer so far is:
```
int main(void)
{
if (printf("Hello World!\n"), exit(0), 0)
{
/* do nothing */
}
}
```
But I don't understand why I don't get compiler error (Visual Studio):
```
error C471... | As Jens pointed out in a comment, the posted code does not exhibit undefined behavior. The original answer here isn't correct and doesn't even really seem to answer the question anyway (on re-reading everything a few years later).
The question can be summed up as, "why doesn't MSVC issue warning C4716 for `main()` in ... |
493,447 | <p>Wonder what the difference between:</p>
<pre><code>static PROCESSWALK pProcess32First=(PROCESSWALK)GetProcAddress(hKernel,"Process32First");
...
pProcess32First(...);
</code></pre>
<p>what is hKernel? Look in <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212%28v=vs.85%29.aspx" rel="nofollow... | [
{
"answer_id": 493496,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 4,
"selected": true,
"text": "<p>NOTE: my answer assumes that the function is available either way, there are other things to consider if you are afte... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17675/"
] | Wonder what the difference between:
```
static PROCESSWALK pProcess32First=(PROCESSWALK)GetProcAddress(hKernel,"Process32First");
...
pProcess32First(...);
```
what is hKernel? Look in [here](http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212%28v=vs.85%29.aspx). You can replace with `GetModuleHandle()`... | NOTE: my answer assumes that the function is available either way, there are other things to consider if you are after non-exported functions.
If you use LoadLibrary and GetProcAddress, then you have the option running with reduced functionality if the required library isn't there. if you use the include and link dire... |
493,455 | <p>In .NET remoting what is the difference between RemotingConfiguration.RegisterWellKnownServiceType and RemotingServices.Marshal?</p>
<p>What I want to do is create an object in a Windows Service, then put it in as a remoting object and have the Windows Service and the Client both act on the remoting object.</p>
<p... | [
{
"answer_id": 493594,
"author": "David Basarab",
"author_id": 2469,
"author_profile": "https://Stackoverflow.com/users/2469",
"pm_score": 5,
"selected": true,
"text": "<p>This is what I found.</p>\n\n<pre><code>RemotingConfiguration.RegisterWellKnownServiceType(typeof(FooRemoting), \n ... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2469/"
] | In .NET remoting what is the difference between RemotingConfiguration.RegisterWellKnownServiceType and RemotingServices.Marshal?
What I want to do is create an object in a Windows Service, then put it in as a remoting object and have the Windows Service and the Client both act on the remoting object.
I thought the be... | This is what I found.
```
RemotingConfiguration.RegisterWellKnownServiceType(typeof(FooRemoting),
serverName, WellKnownObjectMode.Singleton);
```
RegisterWellKnownServiceType will create the object and make it a Singleton to any client that consumes it, but a reference by the server is not created. The ob... |
493,484 | <pre><code>########################################
# some comment
# other comment
########################################
block1 {
value=data
some_value=some other kind of data
othervalue=032423432
}
block2 {
value=data
some_value=some other kind of data
othervalue=032423432
}
</code... | [
{
"answer_id": 493546,
"author": "John Fouhy",
"author_id": 15154,
"author_profile": "https://Stackoverflow.com/users/15154",
"pm_score": 2,
"selected": false,
"text": "<p>Well, the data looks pretty regular. So you could do something like this (untested):</p>\n\n<pre><code>class Block(... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789/"
] | ```
########################################
# some comment
# other comment
########################################
block1 {
value=data
some_value=some other kind of data
othervalue=032423432
}
block2 {
value=data
some_value=some other kind of data
othervalue=032423432
}
``` | The best way would be to use an existing format such as JSON.
Here's an example parser for your format:
```
from lepl import (AnyBut, Digit, Drop, Eos, Integer, Letter,
NON_GREEDY, Regexp, Space, Separator, Word)
# EBNF
# name = ( letter | "_" ) , { letter | "_" | digit } ;
name = Word(Letter() | '... |
493,487 | <p>I am receiving packets sent to my server through UDP. I am using socket_read to read the data and it is coming along just fine. I have run into an error however. The length parameter to socket_read in my case is NOT always the same. The length of the data can range anywhere from 50-150 bytes. One thing that remains ... | [
{
"answer_id": 493569,
"author": "Sean",
"author_id": 5446,
"author_profile": "https://Stackoverflow.com/users/5446",
"pm_score": 0,
"selected": false,
"text": "<p>Application dealing with the read payload will need to recognize when you have reached \"end of record\" for whatever applic... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60020/"
] | I am receiving packets sent to my server through UDP. I am using socket\_read to read the data and it is coming along just fine. I have run into an error however. The length parameter to socket\_read in my case is NOT always the same. The length of the data can range anywhere from 50-150 bytes. One thing that remains c... | If I understand correctly, you want to read data from a socket until there is no more data to read, with the problem being that the amount of data is variable and you don't know when to stop.
According to the relevant manual page (<http://php.net/socket_read>):
>
> Note: socket\_read() returns a zero
> length strin... |
493,490 | <p>I have a string variable that represents the name of a custom class. Example: </p>
<pre><code>string s = "Customer";
</code></pre>
<p>I will need to create an arraylist of customers. So, the syntax needed is:</p>
<pre><code>List<Customer> cust = new ..
</code></pre>
<p>How do I convert the string s to be ... | [
{
"answer_id": 493517,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "<p>Well, for one thing <code>ArrayList</code> isn't generic... did you mean <code>List<Customer></code>?</p>\n\n<p>... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58348/"
] | I have a string variable that represents the name of a custom class. Example:
```
string s = "Customer";
```
I will need to create an arraylist of customers. So, the syntax needed is:
```
List<Customer> cust = new ..
```
How do I convert the string s to be able to create this arraylist on runtime? | Well, for one thing `ArrayList` isn't generic... did you mean `List<Customer>`?
You can use `Type.GetType(string)` to get the `Type` object associated with a type by its name. If the assembly isn't either mscorlib or the currently executing type, you'll need to include the assembly name. Either way you'll need the nam... |
493,494 | <p>I have a Java method in which I'm summing a set of numbers. However, I want any negatives numbers to be treated as positives. So (1)+(2)+(1)+(-1) should equal 5. </p>
<p>I'm sure there is very easy way of doing this - I just don't know how.</p>
| [
{
"answer_id": 493501,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 10,
"selected": true,
"text": "<p>Just call <a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#abs-int-\" rel=\"noreferrer\">Math.... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58433/"
] | I have a Java method in which I'm summing a set of numbers. However, I want any negatives numbers to be treated as positives. So (1)+(2)+(1)+(-1) should equal 5.
I'm sure there is very easy way of doing this - I just don't know how. | Just call [Math.abs](https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#abs-int-). For example:
```
int x = Math.abs(-5);
```
Which will set `x` to `5`.
Note that if you pass `Integer.MIN_VALUE`, the same value (still negative) will be returned, as the range of `int` does not allow the positive equivalen... |
493,495 | <p>how to set iPhone device to stay active ( to not lock ) while my app is running ?
Any idea </p>
| [
{
"answer_id": 493518,
"author": "wulfovitch",
"author_id": 60384,
"author_profile": "https://Stackoverflow.com/users/60384",
"pm_score": 7,
"selected": true,
"text": "<p>This code will prevent your iPhone from going to sleep while your app is running</p>\n\n<pre><code>// avoid sleeping ... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32034/"
] | how to set iPhone device to stay active ( to not lock ) while my app is running ?
Any idea | This code will prevent your iPhone from going to sleep while your app is running
```
// avoid sleeping when this application is running
UIApplication *application = [UIApplication sharedApplication];
application.idleTimerDisabled = YES;
// Or simpler
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
``` |
493,498 | <p>I am using master pages and am having trouble setting page titles from the @ Page directive. All of my classes inherit from a class <em>myPage</em> which inherits from the ASP.NET <em>System.Web.UI.Page</em> class. <strong>Please Note:</strong> I have <strong>runat="server"</strong> set in my master page's head tag... | [
{
"answer_id": 493549,
"author": "Dan Appleyard",
"author_id": 58375,
"author_profile": "https://Stackoverflow.com/users/58375",
"pm_score": 0,
"selected": false,
"text": "<p>I have a very similar set up to you. I have content pages inheriting from a custom base page which is itself inh... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60366/"
] | I am using master pages and am having trouble setting page titles from the @ Page directive. All of my classes inherit from a class *myPage* which inherits from the ASP.NET *System.Web.UI.Page* class. **Please Note:** I have **runat="server"** set in my master page's head tag.
Here's what my @ Page directives look lik... | I thank everyone for their help; I have found a solution. The problem was that the *myPage* class had a property for Title, but in the Set part of the property was not passing the changes on to *Page.Title* as it should have been.
A one line change fixed my problem :) |
493,531 | <pre>
/* define page path */
define("PAGE_DIR", "pages/");
if (file_exists(PAGE_DIR."$_GET[page].php")) include(PAGE_DIR."$_GET[page].php");
</pre>
<p>How safe is this? Could you for example include a page on another webserver if the page is in a folder called pages?</p>
<p>Thanks</p>
| [
{
"answer_id": 493551,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": false,
"text": "<p>This isn't safe at all - Think about what happens if <code>$_GET[page]</code> contains <code>../../../somewhere/else/</cod... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
/* define page path */
define("PAGE_DIR", "pages/");
if (file_exists(PAGE_DIR."$_GET[page].php")) include(PAGE_DIR."$_GET[page].php");
```
How safe is this? Could you for example include a page on another webserver if the page is in a folder called pages?
Thanks | This isn't safe at all - Think about what happens if `$_GET[page]` contains `../../../somewhere/else/`
You should explicitly have a list of allowed pages.
Edit: I don't think it could include a file from a different server, but it's still not a good thing to be doing. |
493,534 | <p>A client is running my company's program and it is halting before it gets anywhere. They sent this information from the Windows Event Log:</p>
<pre><code>faulting module program.exe, version 1.2.3.4, fault address 0x00054321.
</code></pre>
<p>We don't have much else to go on so as a last ditch effort I've been try... | [
{
"answer_id": 493555,
"author": "QbProg",
"author_id": 60373,
"author_profile": "https://Stackoverflow.com/users/60373",
"pm_score": 3,
"selected": true,
"text": "<p>The fault address could also be caused from a stack corruption problem, ie. the return address could be compromised and j... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4790/"
] | A client is running my company's program and it is halting before it gets anywhere. They sent this information from the Windows Event Log:
```
faulting module program.exe, version 1.2.3.4, fault address 0x00054321.
```
We don't have much else to go on so as a last ditch effort I've been trying to see if I can find w... | The fault address could also be caused from a stack corruption problem, ie. the return address could be compromised and jumped back to the wrong address @ 0x54321.
Also, depending on the tecnology used (Java, .NET) the code could change it's position between runs.
Visual studio makes a disassembly of the whole process... |
493,557 | <p>The UltraEdit text editor includes a Perl and Unix compatible regular expression engine for searching.</p>
<p>I want to be able to match a string line this:</p>
<pre><code><branch id="attribute">
<leaf id="attribute"/>
<leaf id="attribute"/>
<leaf id="attribute"/>
</branch>... | [
{
"answer_id": 493587,
"author": "codybartfast",
"author_id": 53252,
"author_profile": "https://Stackoverflow.com/users/53252",
"pm_score": 2,
"selected": false,
"text": "<p>If you put (?s) at the start of pattern it'll enable single line mode so \\r\\n will not be excluded from matching... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28991/"
] | The UltraEdit text editor includes a Perl and Unix compatible regular expression engine for searching.
I want to be able to match a string line this:
```
<branch id="attribute">
<leaf id="attribute"/>
<leaf id="attribute"/>
<leaf id="attribute"/>
</branch>
```
With something like this:
```
/<branch id=... | If you have Perl regular expressions selected, you can do something like:
```
<branch id="attribute">[\s\S]*</branch>
```
where \s is any whitespace character, including newline and return and \S is any other character. Note that this is greedy by default, so if you have the following string:
```
<branch id="attrib... |
493,565 | <p>This has happened repeatedly on various machines in VS2008 and Visual C# 2008.</p>
<p>I create an XBAP appliation.</p>
<p>I click the green arrow and it works.</p>
<p>I click Build/Publish and publish it to either a website or folder, it works.</p>
<p>I make some changes, publish again, and I just get a white sc... | [
{
"answer_id": 493587,
"author": "codybartfast",
"author_id": 53252,
"author_profile": "https://Stackoverflow.com/users/53252",
"pm_score": 2,
"selected": false,
"text": "<p>If you put (?s) at the start of pattern it'll enable single line mode so \\r\\n will not be excluded from matching... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | This has happened repeatedly on various machines in VS2008 and Visual C# 2008.
I create an XBAP appliation.
I click the green arrow and it works.
I click Build/Publish and publish it to either a website or folder, it works.
I make some changes, publish again, and I just get a white screen. Both browsers, can restar... | If you have Perl regular expressions selected, you can do something like:
```
<branch id="attribute">[\s\S]*</branch>
```
where \s is any whitespace character, including newline and return and \S is any other character. Note that this is greedy by default, so if you have the following string:
```
<branch id="attrib... |
493,580 | <p>I've seen similar questions and answers regarding conversions from virtual to absolute and url, but how can I convert a url to a virtual path without manual string parsing?</p>
<p>Example: </p>
<p>I want "<a href="http://myserver/home.aspx" rel="nofollow noreferrer">http://myserver/home.aspx</a>" converted to: "~/... | [
{
"answer_id": 493604,
"author": "Daniel Schaffer",
"author_id": 2596,
"author_profile": "https://Stackoverflow.com/users/2596",
"pm_score": 4,
"selected": true,
"text": "<p>You can get most of it from the Uri class:</p>\n\n<pre><code>new Uri(\"http://myserver.com/home.aspx\").AbsolutePa... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5469/"
] | I've seen similar questions and answers regarding conversions from virtual to absolute and url, but how can I convert a url to a virtual path without manual string parsing?
Example:
I want "<http://myserver/home.aspx>" converted to: "~/home.aspx"
I realize the above example would be an easy string parsing routine, ... | You can get most of it from the Uri class:
```
new Uri("http://myserver.com/home.aspx").AbsolutePath
```
Then you just have to prepend the ~
Though, that will might break if you host in a subdirectory - I don't think there's a way to do it specifically in the context of the application you're running.
EDIT: This m... |
493,603 | <p>They both do the same thing. Is one way better? Obviously if I write the code I'll know what I did, but how about someone else reading it?</p>
<pre><code>if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
return RedirectToAction("Open", "ServiceCall");
</code></pre>
<p>OR </p>
<pre><code... | [
{
"answer_id": 493617,
"author": "Scott Evernden",
"author_id": 11397,
"author_profile": "https://Stackoverflow.com/users/11397",
"pm_score": 3,
"selected": false,
"text": "<p>the second way is better, no confusion about what you mean...</p>\n"
},
{
"answer_id": 493618,
"auth... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9938/"
] | They both do the same thing. Is one way better? Obviously if I write the code I'll know what I did, but how about someone else reading it?
```
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
return RedirectToAction("Open", "ServiceCall");
```
OR
```
if (!String.IsNullOrEmpty(returnUrl))
{... | ```
return String.IsNullOrEmpty(returnUrl) ?
RedirectToAction("Open", "ServiceCall") :
Redirect(returnUrl);
```
I prefer that.
Or the alternative:
```
return String.IsNullOrEmpty(returnUrl)
? RedirectToAction("Open", "ServiceCall")
: Redirect(returnUrl);
``` |
493,634 | <p>User model has three keys: <code>is_master</code>, <code>is_standard</code>, <code>is_guest</code> because I originally wanted to use <a href="https://rubygems.org/gems/activerecord" rel="nofollow noreferrer">activerecord</a>'s boolean methods like <code>is_master</code>? or <code>is_power</code>?.</p>
<p>However, ... | [
{
"answer_id": 493651,
"author": "womble",
"author_id": 60003,
"author_profile": "https://Stackoverflow.com/users/60003",
"pm_score": 2,
"selected": false,
"text": "<p>If the master/standard/guest relationship is mutually exclusive (that is, you can only ever be one of them) then a field... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | User model has three keys: `is_master`, `is_standard`, `is_guest` because I originally wanted to use [activerecord](https://rubygems.org/gems/activerecord)'s boolean methods like `is_master`? or `is_power`?.
However, if it would be better to create a UserType relationship and create my own methods like this:
```
def ... | If the master/standard/guest relationship is mutually exclusive (that is, you can only ever be one of them) then a field that stores the type (in a human-readable form, please -- no opaque numbers) is better. You can always reimplement `is_foo?` trivially.
On the other hand, if you could have an account that be more t... |
493,646 | <p><b>Here's the quick version of my question:</b><br></p>
<p>Is it possible to set a cookie somehow into a client's browser when the cookie is for use with a different server (in this case an Exchange mail server)? In this scenario the server trying to set the cookie is at "intranet.myschool.edu" and the exchange ser... | [
{
"answer_id": 493666,
"author": "Scott Evernden",
"author_id": 11397,
"author_profile": "https://Stackoverflow.com/users/11397",
"pm_score": 1,
"selected": false,
"text": "<p>I think this would be a serious security loophole if it were possible...</p>\n"
},
{
"answer_id": 493697... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54446/"
] | **Here's the quick version of my question:**
Is it possible to set a cookie somehow into a client's browser when the cookie is for use with a different server (in this case an Exchange mail server)? In this scenario the server trying to set the cookie is at "intranet.myschool.edu" and the exchange server is at "owa\... | From [RFC 2965](http://www.ietf.org/rfc/rfc2965.txt) (NB HDN = "host domain name)
>
> Host A's name domain-matches host B's
> if
>
>
>
> ```
> * their host name strings string-compare equal; or
>
> * A is a HDN string and has the form NB, where N is a non-empty
> name string, B has the form .B', and B'... |
493,649 | <p>How would you go about calling several methods in the data access layer from one method in the business logic layer so that all of the SQL commands lived in one SQL transaction? </p>
<p>Each one of the DAL methods may be called individually from other places in the BLL, so there is no guarantee that the data layer ... | [
{
"answer_id": 493715,
"author": "user60400",
"author_id": 60400,
"author_profile": "https://Stackoverflow.com/users/60400",
"pm_score": 2,
"selected": false,
"text": "<p>What you describe is the very 'definition' of a long transaction.</p>\n\n<p>Each DAL method could simply provide oper... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10104/"
] | How would you go about calling several methods in the data access layer from one method in the business logic layer so that all of the SQL commands lived in one SQL transaction?
Each one of the DAL methods may be called individually from other places in the BLL, so there is no guarantee that the data layer methods ar... | well, firstly, you'll have to adhere to an atomic Unit of Work that you specify as a single method in your BLL. This would (for example) create the customer, the order and the order items. you'd then wrap this all neatly up inside a TransactionScope using statement. TransactionScope is the secret weapon here. below is ... |
493,650 | <p>I often use the website www.cplusplus.com as a reference when writing C code.</p>
<p>I was reading the example cited on the page for <a href="http://www.cplusplus.com/reference/clibrary/cstdio/fread.html" rel="nofollow noreferrer">fread</a> and had a question.</p>
<p>As an example they post:</p>
<pre><code>/* fre... | [
{
"answer_id": 493657,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 0,
"selected": false,
"text": "<p>The operating system cleans up any unfreed memory by a process when that process closes. At least, <em>modern</em> ope... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35767/"
] | I often use the website www.cplusplus.com as a reference when writing C code.
I was reading the example cited on the page for [fread](http://www.cplusplus.com/reference/clibrary/cstdio/fread.html) and had a question.
As an example they post:
```
/* fread example: read a complete file */
#include <stdio.h>
#include <... | It wouldn't be a memory leak *in this example*, because terminating the program (by calling `exit()`) frees all memory associated with it.
However, it would be a memory leak if you used this piece of code as a subroutine and called something like `return 1;` in place of `exit()`. |
493,660 | <p>I have a list of 10 data objects that I want to insert/update to the database using NHibernate. If one throws an exception (say a primary key violation) I want to still insert/update the other 9. I rolled each object operation into its own atomic transaction, and roll back the transaction if there is an exception. P... | [
{
"answer_id": 501727,
"author": "Sean Carpenter",
"author_id": 729,
"author_profile": "https://Stackoverflow.com/users/729",
"pm_score": 4,
"selected": true,
"text": "<p>It's not possible to re-use an NHibernate session after an exception is thrown. <a href=\"http://nhforge.org/doc/nh/... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a list of 10 data objects that I want to insert/update to the database using NHibernate. If one throws an exception (say a primary key violation) I want to still insert/update the other 9. I rolled each object operation into its own atomic transaction, and roll back the transaction if there is an exception. Prob... | It's not possible to re-use an NHibernate session after an exception is thrown. [Quoting the documentation](http://nhforge.org/doc/nh/en/index.html#manipulatingdata-exceptions):
```
If the ISession throws an exception you should immediately rollback the
transaction, call ISession.Close() and discard the ISession insta... |
493,663 | <p>I'm investigating the possiblity of creating PDF files from an embedded system, specifially an ARM9 using the IAR tools. Open-souce or licensing is fine - I'm finding it difficult to search for online, and I'm hoping someone here has used a package. C or C++ is preferred, we will be creating fairly simple reports wi... | [
{
"answer_id": 501727,
"author": "Sean Carpenter",
"author_id": 729,
"author_profile": "https://Stackoverflow.com/users/729",
"pm_score": 4,
"selected": true,
"text": "<p>It's not possible to re-use an NHibernate session after an exception is thrown. <a href=\"http://nhforge.org/doc/nh/... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15797/"
] | I'm investigating the possiblity of creating PDF files from an embedded system, specifially an ARM9 using the IAR tools. Open-souce or licensing is fine - I'm finding it difficult to search for online, and I'm hoping someone here has used a package. C or C++ is preferred, we will be creating fairly simple reports with ... | It's not possible to re-use an NHibernate session after an exception is thrown. [Quoting the documentation](http://nhforge.org/doc/nh/en/index.html#manipulatingdata-exceptions):
```
If the ISession throws an exception you should immediately rollback the
transaction, call ISession.Close() and discard the ISession insta... |
493,673 | <p>I have a List<> of objects in C# and I need a way to return those objects that are considered duplicates within the list. I do not need the Distinct resultset, I need a list of those items that I will be deleting from my repository.</p>
<p>For the sake of this example, lets say I have a list of "Car" types and ... | [
{
"answer_id": 493690,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<pre><code>IEnumerable<Car> GetDuplicateColors(List<Car> cars)\n{\n return cars.Where(c => cars.Any(... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7215/"
] | I have a List<> of objects in C# and I need a way to return those objects that are considered duplicates within the list. I do not need the Distinct resultset, I need a list of those items that I will be deleting from my repository.
For the sake of this example, lets say I have a list of "Car" types and I need to know... | I inadvertently coded this yesterday, when I was trying to write a "distinct by a projection". I included a ! when I shouldn't have, but this time it's just right:
```
public static IEnumerable<TSource> DuplicatesBy<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TK... |
493,718 | <p>I've got a C++ gui project exhibiting some strange behavior. On my machine, the code compiles and runs just fine. However, on another machine, The code compiles but ends up running in MTA somehow. Obviously, being in MTA causes all sorts of runtime problems for the GUI. Here is my main:</p>
<pre><code> [... | [
{
"answer_id": 518088,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "<p>Figured it out. Our project was making calls to a dll from openCV, and that dll had been compiled for multiple threads. Vi... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got a C++ gui project exhibiting some strange behavior. On my machine, the code compiles and runs just fine. However, on another machine, The code compiles but ends up running in MTA somehow. Obviously, being in MTA causes all sorts of runtime problems for the GUI. Here is my main:
```
[STAThreadAttribute... | Figured it out. Our project was making calls to a dll from openCV, and that dll had been compiled for multiple threads. Visual studio noticed this and forced the app to compile for multiple threads as well. Differing versions of the dll from one machine to another were responsible for the irregularity of the problem. |
493,726 | <p>I have two UIScrollViews that I move images between. The user can drag and forth between the scroll views. I am trying to animate the movement of the image from one scroll view to another. In <code>-touchesMoved</code> (handled in my UIViewController which has two custom UIScrollViews that intercept touch and sends ... | [
{
"answer_id": 493749,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 2,
"selected": false,
"text": "<p>You should look into Comet:</p>\n\n<p><a href=\"http://ajaxian.com/archives/comet-a-new-approach-to-ajax-applicati... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have two UIScrollViews that I move images between. The user can drag and forth between the scroll views. I am trying to animate the movement of the image from one scroll view to another. In `-touchesMoved` (handled in my UIViewController which has two custom UIScrollViews that intercept touch and sends to my UIViewCo... | See [Comet](http://en.wikipedia.org/wiki/Comet_%28programming%29) - it's like ajax, but it holds a connection open so the server can push information to the client.
Note that compliant browsers will only hold 2 connections (note: [most modern browsers no longer comply](https://stackoverflow.com/questions/5751515/offic... |
493,747 | <p>I have setup a property and implement INotifyPropertyChanged</p>
<p>like so...</p>
<pre><code>public event PropertyChangedEventHandler PropertyChanged;
public FlowProcess LastSelectedFlowProcess
{
get { return _lastSelectedFlowProcess; }
set
{
_lastSelectedFlowProcess = value;
Notify("... | [
{
"answer_id": 493786,
"author": "Stu Mackellar",
"author_id": 28591,
"author_profile": "https://Stackoverflow.com/users/28591",
"pm_score": 4,
"selected": true,
"text": "<p>Whether the delegate is null or not depends on whether anything has subscribed to the event.</p>\n"
},
{
"... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6161/"
] | I have setup a property and implement INotifyPropertyChanged
like so...
```
public event PropertyChangedEventHandler PropertyChanged;
public FlowProcess LastSelectedFlowProcess
{
get { return _lastSelectedFlowProcess; }
set
{
_lastSelectedFlowProcess = value;
Notify("LastSelectedFlowProce... | Whether the delegate is null or not depends on whether anything has subscribed to the event. |
493,765 | <p>I have a table called PROJECT_CATEGORY and it contains two fields</p>
<p>cat_id and cat_title</p>
<p>I am storing the cat_id in another table called PROJECTS so:</p>
<pre><code>project_category.cat_id = projects.cat_id
</code></pre>
<p>What is the best way using MySQL to run a query to show the <code>cat_title</... | [
{
"answer_id": 493779,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>If <em>every</em> project has a valid cat_id and cat_id is unique, than INNER JOIN is fine.</p>\n\n<p>If any projec... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a table called PROJECT\_CATEGORY and it contains two fields
cat\_id and cat\_title
I am storing the cat\_id in another table called PROJECTS so:
```
project_category.cat_id = projects.cat_id
```
What is the best way using MySQL to run a query to show the `cat_title`. In other words I want to display the nam... | If *every* project has a valid cat\_id and cat\_id is unique, than INNER JOIN is fine.
If any project has a NULL cat\_id, you want a LEFT JOIN.
If cat\_id is not a unique field (primary key), you may want to use a subquery to limit yourself to one result per project. |
493,774 | <p>Does anyone know why std::queue, std::stack, and std::priority_queue don't provide a <code>clear()</code> member function? I have to fake one like this:</p>
<pre><code>std::queue<int> q;
// time passes...
q = std::queue<int>(); // equivalent to clear()
</code></pre>
<p>IIRC, <code>clear()</code> is p... | [
{
"answer_id": 493821,
"author": "gbjbaanb",
"author_id": 13744,
"author_profile": "https://Stackoverflow.com/users/13744",
"pm_score": -1,
"selected": false,
"text": "<p>I think it depends on the implementation - until recently Microsoft STL didn't have clear on several containers. (it ... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46821/"
] | Does anyone know why std::queue, std::stack, and std::priority\_queue don't provide a `clear()` member function? I have to fake one like this:
```
std::queue<int> q;
// time passes...
q = std::queue<int>(); // equivalent to clear()
```
IIRC, `clear()` is provided by everything that could serve as the underlying con... | Well, I think this is because `clear` was not considered a valid operation on a queue, a priority\_queue or a stack (by the way, deque is not and adaptor but a container).
>
> The only reason to use the container
> adaptor queue instead of the container
> deque is to make it clear that you are
> performing only q... |
493,777 | <p>I have the following Rails migration which works perfectly (irrelevant pieces removed):</p>
<pre><code>create_table :comments do |t|
t.text :body
t.references :post
end
</code></pre>
<p>Now I'd like to add an <code>author</code> column to my <code>comments</code> table (which is the userid of a user), but I ha... | [
{
"answer_id": 493793,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You could add the column by <code>add_column(:table, :column_name, :type, :options)</code> in a new Migration.</p>\n"
},
... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] | I have the following Rails migration which works perfectly (irrelevant pieces removed):
```
create_table :comments do |t|
t.text :body
t.references :post
end
```
Now I'd like to add an `author` column to my `comments` table (which is the userid of a user), but I have no idea how to do it (I'm tempted to just wri... | While it's too late to get any points out of this, I thought I'd post the best way for posterity :)
use `change_table` instead of `create_table` to add columns to a table that already exists, with all the TableDefinition goodness:
```
self.up do
change_table :comments do |t|
t.references :author
end
end
```
... |
493,801 | <p>How can I use the <code><label></code> tag within an ASP.NET application? I want it to be valid, accessible, and usable.</p>
<p>I understand the optimal HTML way is this:</p>
<pre><code><label for="Username">Username:</label>
<input type="text" id="Username" runat="server" />
</code></pre>
... | [
{
"answer_id": 493806,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 7,
"selected": true,
"text": "<p>I use <code><asp:Label ... AssociatedControlID=\"Username\" ...></code> controls for this. They get rendered ... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35064/"
] | How can I use the `<label>` tag within an ASP.NET application? I want it to be valid, accessible, and usable.
I understand the optimal HTML way is this:
```
<label for="Username">Username:</label>
<input type="text" id="Username" runat="server" />
```
But if the above code is in an ASP.NET user control, the input I... | I use `<asp:Label ... AssociatedControlID="Username" ...>` controls for this. They get rendered as `<label>` tags and set the `for` attribute appropriately.
Note that you can also nest other tags within the Label control if you wish:
```
<asp:Label ID="UsernameLabel"
Text="Username:"
AssociatedC... |
493,816 | <p>How to print the following code to a .txt file</p>
<pre><code>y = '10.1.1.' # /24 network,
for x in range(255):
x += 1
print y + str(x) # not happy that it's in string, but how to print it into a.txt
</code></pre>
<p>There's copy paste, but would rather try something more interesting. </p>
| [
{
"answer_id": 493822,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 4,
"selected": true,
"text": "<pre><code>f = open('myfile.txt', 'w')\nfor x in range(255):\n ip = \"10.1.1.%s\\n\" % str(x)\n f.write(ip)\nf.... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57854/"
] | How to print the following code to a .txt file
```
y = '10.1.1.' # /24 network,
for x in range(255):
x += 1
print y + str(x) # not happy that it's in string, but how to print it into a.txt
```
There's copy paste, but would rather try something more interesting. | ```
f = open('myfile.txt', 'w')
for x in range(255):
ip = "10.1.1.%s\n" % str(x)
f.write(ip)
f.close()
``` |
493,817 | <p>I'm new to Objective-C and iPhone development, and I'm trying to store floating-point values in an NSMutableArray, but when I do I get an error saying "incompatible type for argument 1 of 'addObject". What am I doing wrong? I'm trying to create an array of doubles that I can perform math calculations with.</p>
| [
{
"answer_id": 493848,
"author": "Sijmen Mulder",
"author_id": 59527,
"author_profile": "https://Stackoverflow.com/users/59527",
"pm_score": 4,
"selected": false,
"text": "<p>Use an NSNumber to wrap your float, because the dictionary needs an object:</p>\n\n<pre><code>[myDictionary setOb... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60418/"
] | I'm new to Objective-C and iPhone development, and I'm trying to store floating-point values in an NSMutableArray, but when I do I get an error saying "incompatible type for argument 1 of 'addObject". What am I doing wrong? I'm trying to create an array of doubles that I can perform math calculations with. | NSMutableArray only holds objects, so you want an array to be loaded with NSNumber objects.
Create each NSNumber to hold your double then add it to your array. Perhaps something like this.
```
NSMutableArray *array = [[NSMutableArray alloc] init];
NSNumber *num = [NSNumber numberWithFloat:10.0f];
[array addObject:num... |
493,819 | <p>This has always confused me. It seems like this would be nicer:</p>
<pre><code>["Hello", "world"].join("-")
</code></pre>
<p>Than this:</p>
<pre><code>"-".join(["Hello", "world"])
</code></pre>
<p>Is there a specific reason it is like this?</p>
| [
{
"answer_id": 493831,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 8,
"selected": false,
"text": "<p>Because the <code>join()</code> method is in the string class, instead of the list class?</p>\n<p>I agree it looks ... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49701/"
] | This has always confused me. It seems like this would be nicer:
```
["Hello", "world"].join("-")
```
Than this:
```
"-".join(["Hello", "world"])
```
Is there a specific reason it is like this? | It's because any iterable can be joined (e.g, list, tuple, dict, set), but its contents and the "joiner" *must be* strings.
For example:
```
'_'.join(['welcome', 'to', 'stack', 'overflow'])
'_'.join(('welcome', 'to', 'stack', 'overflow'))
```
```
'welcome_to_stack_overflow'
```
Using something other than strings ... |
493,827 | <p>For what reason(s) should WCF return me a "empty" instantiated object when it was clearly populated on my WCF service return before it went over the wire?</p>
<p>For instance a simple <code>OperationContract</code> method:</p>
<pre><code>response.Client = new Client();
response.Client.ID = 99;
return response;
</c... | [
{
"answer_id": 493844,
"author": "Tad Donaghe",
"author_id": 1572436,
"author_profile": "https://Stackoverflow.com/users/1572436",
"pm_score": 2,
"selected": false,
"text": "<p>Is your object marked as [Serializable] or is it a [DataContract]? You need to mark your object as one or the ... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41211/"
] | For what reason(s) should WCF return me a "empty" instantiated object when it was clearly populated on my WCF service return before it went over the wire?
For instance a simple `OperationContract` method:
```
response.Client = new Client();
response.Client.ID = 99;
return response;
```
returns an "empty" Client obj... | If anyone encounters this problem, I have found the fix. Due to business requirements I had marked my custom class with both `[Serializable]` and `[DataContract]`, this appears to be illegal possibly as of .NET 3.5 SP1?
I have a friend who is sending WCF objects with both these attributes pre .NET 3.5 SP1 and it is wo... |
493,833 | <p>Is it possible to get a list of the user defined functions in JavaScript?</p>
<p>I'm currently using this, but it returns functions which aren't user defined:</p>
<pre><code>var functionNames = [];
for (var f in window) {
if (window.hasOwnProperty(f) && typeof window[f] === 'function') {
funct... | [
{
"answer_id": 493899,
"author": "Chetan S",
"author_id": 31284,
"author_profile": "https://Stackoverflow.com/users/31284",
"pm_score": 5,
"selected": true,
"text": "<p>I'm assuming you want to filter out native functions. In Firefox, <code>Function.toString()</code> returns the function... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2118/"
] | Is it possible to get a list of the user defined functions in JavaScript?
I'm currently using this, but it returns functions which aren't user defined:
```
var functionNames = [];
for (var f in window) {
if (window.hasOwnProperty(f) && typeof window[f] === 'function') {
functionNames.push(f);
}
}
``... | I'm assuming you want to filter out native functions. In Firefox, `Function.toString()` returns the function body, which for native functions, will be in the form:
```
function addEventListener() {
[native code]
}
```
You could match the pattern `/\[native code\]/` in your loop and omit the functions that matc... |
493,837 | <p>I've got a series of tabs on a page. The tabs are set to relative position. They are then moved 15px to the left. The resulting style looks like this:</p>
<pre><code>style="position:relative;left:-15px"
</code></pre>
<p>(note that each tab's left is going to be -15 * tab number - so #2 will be -15, #3 is -30, etc.... | [
{
"answer_id": 493858,
"author": "Ulf",
"author_id": 51208,
"author_profile": "https://Stackoverflow.com/users/51208",
"pm_score": 0,
"selected": false,
"text": "<p>maybe you could add a padding element to the left side. width: #tabs * 15</p>\n"
},
{
"answer_id": 493862,
"aut... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36620/"
] | I've got a series of tabs on a page. The tabs are set to relative position. They are then moved 15px to the left. The resulting style looks like this:
```
style="position:relative;left:-15px"
```
(note that each tab's left is going to be -15 \* tab number - so #2 will be -15, #3 is -30, etc.)
This gives the tabs a ... | Instead of nudging the `<li>`s with 'position: relative', you could apply this to each tab (except for the first tab):
```
margin-left: -15px;
```
**EDIT:**
Example of the concept...
```
<div style="text-align:center;">
<img src="http://www.google.com/intl/en_ALL/images/logo.gif" />
<img style="margin-left: -54px;"... |
493,841 | <p>I am doing the exact same thing in two classes, and in one the compiler is allowing it just fine, but the other one is giving me an error. Why the double standard? There's 15 classes using this same pattern, but only one refuses to compile, saying the following error:</p>
<blockquote>
<p>'AWWAInvoicingXML.AwwaTra... | [
{
"answer_id": 493860,
"author": "Andy",
"author_id": 45062,
"author_profile": "https://Stackoverflow.com/users/45062",
"pm_score": 1,
"selected": false,
"text": "<p><code>AwwaTransmissionInfo.fromXml</code> needs to be returning an <code>IXmlSerializable</code> type, not an <code>AwwaTr... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5255/"
] | I am doing the exact same thing in two classes, and in one the compiler is allowing it just fine, but the other one is giving me an error. Why the double standard? There's 15 classes using this same pattern, but only one refuses to compile, saying the following error:
>
> 'AWWAInvoicingXML.AwwaTransmissionInfo'
> do... | The reason the CEmail class was compiling fine is because it was not marked as implementing the interface. When I marked it as such, I got the same error as the other class. The following is how it has to be... I am pretty stupid for not noticing that. We are under a lot of pressure here right now and I can't believe I... |
493,853 | <p>I have a sequence of x, y and z -coordinates, which I need to manipulate. They are in one list of three tuples, like {(x1, y1, z1), (x2, y2, z2), ...}.</p>
<p>I need addition, multiplication and logarithm to manipulate my data.</p>
<p>I would like to study a module, which is as powerful as Awk -language.</p>
| [
{
"answer_id": 494034,
"author": "John Fouhy",
"author_id": 15154,
"author_profile": "https://Stackoverflow.com/users/15154",
"pm_score": 3,
"selected": false,
"text": "<p>I'm not sure exactly what you're after. You can do a lot with list comprehensions. For example, if you want to tur... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54964/"
] | I have a sequence of x, y and z -coordinates, which I need to manipulate. They are in one list of three tuples, like {(x1, y1, z1), (x2, y2, z2), ...}.
I need addition, multiplication and logarithm to manipulate my data.
I would like to study a module, which is as powerful as Awk -language. | If you need many array manipulation, then numpy is the best choice in python
```
>>> import numpy
>>> data = numpy.array([(2, 4, 8), (3, 6, 5), (7, 5, 2)])
>>> data
array([[2, 4, 8],
[3, 6, 5],
[7, 5, 2]])
>>> data.sum() # product of all elements
42
>>> data.sum(axis=1) # sum of elements in rows
arra... |
493,883 | <p>I have a Silverlight application in which I would like to call a WCF service. When calling the service I receive the following response from the server:</p>
<blockquote>
<p>415 Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=u... | [
{
"answer_id": 493897,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>Well, you could try using the \"Silverlight-enabled WCF Service\" template in VS2008, and comparing the differences... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2723/"
] | I have a Silverlight application in which I would like to call a WCF service. When calling the service I receive the following response from the server:
>
> 415 Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8
>
>
>
Has an... | Well, you could try using the "Silverlight-enabled WCF Service" template in VS2008, and comparing the differences? I expect that you need to use the `basicHttpBinding` and are using something more exotic.
For info, here is the web.config section for a default Silverlight/WCF service:
```
<system.serviceModel>
<beh... |
493,893 | <p>Today we faced a quite simple problem that were made even simpler by the dear predicates. We had a kind of event log and wanted to filter it client side (Windows Forms) using a list of criterias. We began by implementing to filter by a number of categories.</p>
<pre><code>private List<Events> FilterEventsByCa... | [
{
"answer_id": 493911,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>re \"so no LINQ\" - have you looked at <a href=\"http://www.albahari.com/nutshell/linqbridge.aspx\" rel=\"nofollow... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44620/"
] | Today we faced a quite simple problem that were made even simpler by the dear predicates. We had a kind of event log and wanted to filter it client side (Windows Forms) using a list of criterias. We began by implementing to filter by a number of categories.
```
private List<Events> FilterEventsByCategory(List<Events> ... | Here's a very rudimentary sample of where I would start.
```
internal class Program
{
private static void Main()
{
var ms = new Category(1, "Microsoft");
var sun = new Category(2, "Sun");
var events = new List<Event>
{
new Event(ms,... |
493,924 | <p>This may be a little confusing but I having some trouble. My goal is to take an input HTML document and then process that document and use the HTML data to output a image document. For example, a user will request a URL, with some action=png in the querystring and then the filter will get invoked for the URL and o... | [
{
"answer_id": 494809,
"author": "Volker Stolz",
"author_id": 60462,
"author_profile": "https://Stackoverflow.com/users/60462",
"pm_score": 0,
"selected": false,
"text": "<p>I have no experience with Websphere, but one common problem is that you try to manipulate the HTTP header after yo... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10522/"
] | This may be a little confusing but I having some trouble. My goal is to take an input HTML document and then process that document and use the HTML data to output a image document. For example, a user will request a URL, with some action=png in the querystring and then the filter will get invoked for the URL and output... | The issue does appear to be that you are opening the response Writer prior to wrapping the response.
It looks like you should be able to do:
```
this.setFilterChain(filterChain);
CaptureContent capContent = new CaptureResponse(response);
doFilter()
process();
response.setContentType("image/png");
response.getOutputS... |
493,926 | <p>I'm writing a small webapp in Grails, and to make sure all users are authenticated I'm using the following filter:</p>
<pre><code>class LoginFilters {
static filters = {
loginCheck(controller:'*', action:'*') {
before = {
if (session.user_id) {
request.user = User.get(session.user_id)
... | [
{
"answer_id": 498160,
"author": "chanwit",
"author_id": 60903,
"author_profile": "https://Stackoverflow.com/users/60903",
"pm_score": 2,
"selected": true,
"text": "<p>Using the beforeInterceptor in a controller may help:</p>\n\n<pre><code>class LoginController {\n\n def user\n\n d... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58394/"
] | I'm writing a small webapp in Grails, and to make sure all users are authenticated I'm using the following filter:
```
class LoginFilters {
static filters = {
loginCheck(controller:'*', action:'*') {
before = {
if (session.user_id) {
request.user = User.get(session.user_id)
} else... | Using the beforeInterceptor in a controller may help:
```
class LoginController {
def user
def beforeInterceptor = {
user = request.user
}
def index = {
render text:"index: ${user}"
}
def test = {
render text:"test: ${user}"
}
}
``` |
493,940 | <p>I've recently switched from storing session data in a cookie to storing it in the database.</p>
<p>Now every POST request causes an <b>ActionController::InvalidAuthenticityToken</b> error. It only happens in Firefox, and only on my home machine (I tried it out at work today in the same version of FF and everything... | [
{
"answer_id": 494072,
"author": "Otto",
"author_id": 9594,
"author_profile": "https://Stackoverflow.com/users/9594",
"pm_score": 3,
"selected": true,
"text": "<p>The exact same thing happened to me when I switched one of my sites. Delete the Rails session cookie for that site in your h... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56712/"
] | I've recently switched from storing session data in a cookie to storing it in the database.
Now every POST request causes an **ActionController::InvalidAuthenticityToken** error. It only happens in Firefox, and only on my home machine (I tried it out at work today in the same version of FF and everything was fine). Th... | The exact same thing happened to me when I switched one of my sites. Delete the Rails session cookie for that site in your home Firefox Browser.
It only happens if you had a pre-existing session that used the cookie store. So, hopefully, only you and your browser will ever see the issue. After you've deleted the cooki... |
493,978 | <p>I want to know what is the current url of active tab in running firefox instance from python module. Does FireFox have any API for this and does python know to work with it?</p>
| [
{
"answer_id": 494063,
"author": "chews",
"author_id": 33966,
"author_profile": "https://Stackoverflow.com/users/33966",
"pm_score": 1,
"selected": false,
"text": "<p>If on windows you can use win32com</p>\n\n<pre><code>import win32clipboard\nimport win32com.client\nshell = win32com.clie... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20955/"
] | I want to know what is the current url of active tab in running firefox instance from python module. Does FireFox have any API for this and does python know to work with it? | The most convenient way maybe insatll a firefox extension to open up a tcp service, then you can exchange info with firefox.
[mozrepl](http://wiki.github.com/bard/mozrepl) can set up a telnet service, you can call js-like command to get info.
With telnetscript (http: //code.activestate.com/recipes/152043/), you can w... |
493,981 | <p>Background:</p>
<p>I working on an application on Google App Engine. Its been going really well until I hit one of their limitations in file size -- 1MB. One of the components of my application resizes images, which have been uploaded by users. The files are directly uploaded to S3 (<a href="http://developer.amazon... | [
{
"answer_id": 494063,
"author": "chews",
"author_id": 33966,
"author_profile": "https://Stackoverflow.com/users/33966",
"pm_score": 1,
"selected": false,
"text": "<p>If on windows you can use win32com</p>\n\n<pre><code>import win32clipboard\nimport win32com.client\nshell = win32com.clie... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60436/"
] | Background:
I working on an application on Google App Engine. Its been going really well until I hit one of their limitations in file size -- 1MB. One of the components of my application resizes images, which have been uploaded by users. The files are directly uploaded to S3 (<http://developer.amazonwebservices.com/co... | The most convenient way maybe insatll a firefox extension to open up a tcp service, then you can exchange info with firefox.
[mozrepl](http://wiki.github.com/bard/mozrepl) can set up a telnet service, you can call js-like command to get info.
With telnetscript (http: //code.activestate.com/recipes/152043/), you can w... |
493,985 | <p>I'm working in Visual Studio 2008 on a C++ programming assignment. We were supplied with files that define the following namespace hierarchy (the names are just for the sake of this post, I know "namespace XYZ-NAMESPACE" is redundant): </p>
<pre><code>(MAIN-NAMESPACE){
a bunch of functions/classes I need to ... | [
{
"answer_id": 494057,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 0,
"selected": false,
"text": "<p>Try calling the function explicitly?</p>\n\n<pre><code>::operator<<( cout, myObj );\n</code></pre>\n"
},
{
... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46811/"
] | I'm working in Visual Studio 2008 on a C++ programming assignment. We were supplied with files that define the following namespace hierarchy (the names are just for the sake of this post, I know "namespace XYZ-NAMESPACE" is redundant):
```
(MAIN-NAMESPACE){
a bunch of functions/classes I need to implement...
... | OK I figured this out.
jpalecek's intuition about there existing another operator<< in the namespace was correct (apparently I forgot to comment it out).
The lookup rules for namespaces first start the search in the function call's namespace and search up the enclosing namespaces, right up to the global namespace (t... |
493,986 | <p>I'm using databinding to set the visible property on a control as such:</p>
<p>Control on Page:</p>
<pre>
<asp:LinkButton ID="ApproveTimeLink" runat="server" Visible="<%# CanApprove() %>"> Approve Time</asp:LinkButton>
</pre>
<p>Code on CodeBehind:</p>
<pre>
Protected bool CanApprove()
{
ret... | [
{
"answer_id": 494669,
"author": "ssmith",
"author_id": 13729,
"author_profile": "https://Stackoverflow.com/users/13729",
"pm_score": 0,
"selected": false,
"text": "<p>Sometimes you cannot set control properties with <%# %> and you have to resort to using OnItemDataBound(...) to get a... | 2009/01/29 | [
"https://Stackoverflow.com/questions/493986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60301/"
] | I'm using databinding to set the visible property on a control as such:
Control on Page:
```
<asp:LinkButton ID="ApproveTimeLink" runat="server" Visible="<%# CanApprove() %>"> Approve Time</asp:LinkButton>
```
Code on CodeBehind:
```
Protected bool CanApprove()
{
return false;
}
```
As you can see the contr... | all you have to this is the following
```
protected void Page_Load(object sender, EventArgs e)
{
this.DataBind();
}
public bool CanApprove()
{
return false;
}
```
then you can use this method on the asp-control as you mentioned before!
but be we aware! Every property of the page has to be **not null**, othe... |
494,002 | <p>Now this must be easy, but how can sum two <code>NSNumber</code>? Is like:</p>
<pre><code>[one floatValue] + [two floatValue]
</code></pre>
<p>or exist a better way?</p>
| [
{
"answer_id": 494017,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 8,
"selected": true,
"text": "<p>There is not really a better way, but you really should not be doing this if you can avoid it. <code>NSNumber</cod... | 2009/01/29 | [
"https://Stackoverflow.com/questions/494002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53185/"
] | Now this must be easy, but how can sum two `NSNumber`? Is like:
```
[one floatValue] + [two floatValue]
```
or exist a better way? | There is not really a better way, but you really should not be doing this if you can avoid it. `NSNumber` exists as a wrapper to scalar numbers so you can store them in collections and pass them polymorphically with other `NSObjects`. They are not really used to store numbers in actual math. If you do math on them it i... |
494,006 | <p>The <code>User.Identity.Name</code> property returns the domain login id.</p>
<p>Which class/property exposes the actual user name?</p>
<p>For user "John Doe" who logs into the web application supplying my_domain\jdoe</p>
<pre><code>**User.Identity.Name -**
Returns : *my_domain\jdoe*
**System.Environment.UserNa... | [
{
"answer_id": 494024,
"author": "Ken Browning",
"author_id": 53162,
"author_profile": "https://Stackoverflow.com/users/53162",
"pm_score": 1,
"selected": false,
"text": "<p>The IIdentity interface is that which provides the Name property on User.Identity. The IIdentity interface can be... | 2009/01/29 | [
"https://Stackoverflow.com/questions/494006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The `User.Identity.Name` property returns the domain login id.
Which class/property exposes the actual user name?
For user "John Doe" who logs into the web application supplying my\_domain\jdoe
```
**User.Identity.Name -**
Returns : *my_domain\jdoe*
**System.Environment.UserName**
Returns: *jdoe*
```
Which class... | If you are thinking Active Directory, you'll need to find the UserPrincipal that corresponds to the given samAccountName and get the DisplayName property from it. Note that it may not be set.
```
string fullName = null;
using (PrincipalContext context = new PrincipalContext( ContextType.Domain ))
{
using (UserPrin... |
494,016 | <p>I have a personal project that's been online for sometime now. I've been keeping a tally of downloads by doing this:</p>
<ul>
<li>When the user clicks the download link, it hits a PHP script that writes some information to a table.</li>
<li>Once the data is written, the script returns the path to the actual file.</... | [
{
"answer_id": 494027,
"author": "alxp",
"author_id": 19513,
"author_profile": "https://Stackoverflow.com/users/19513",
"pm_score": 1,
"selected": false,
"text": "<p>This is the reason a lot of sites use a download link that will take you to another page, which will start a download auto... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20/"
] | I have a personal project that's been online for sometime now. I've been keeping a tally of downloads by doing this:
* When the user clicks the download link, it hits a PHP script that writes some information to a table.
* Once the data is written, the script returns the path to the actual file.
* The user then has th... | This is taken from the [php-documentation](http://www.php.net/header), but is also possible using different script languages:
```
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// Th... |
494,035 | <p>I would like to create a <code>String.replaceAll()</code> method in JavaScript and I'm thinking that using a regex would be most terse way to do it. However, I can't figure out how to pass a variable in to a regex. I can do this already which will replace all the instances of <code>"B"</code> with <code>"A"</code>... | [
{
"answer_id": 494046,
"author": "Eric Wendelin",
"author_id": 25066,
"author_profile": "https://Stackoverflow.com/users/25066",
"pm_score": 12,
"selected": true,
"text": "<p>Instead of using the <code>/regex\\d/g</code> syntax, you can construct a new <a href=\"https://developer.mozilla... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] | I would like to create a `String.replaceAll()` method in JavaScript and I'm thinking that using a regex would be most terse way to do it. However, I can't figure out how to pass a variable in to a regex. I can do this already which will replace all the instances of `"B"` with `"A"`.
```
"ABABAB".replace(/B/g, "A");
`... | Instead of using the `/regex\d/g` syntax, you can construct a new [RegExp](https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Regular_Expressions) object:
```
var replace = "regex\\d";
var re = new RegExp(replace,"g");
```
You can dynamically create regex objects this way. Then you will do:
```
"mystring1".r... |
494,036 | <p>I believe that I have successfully impersonated my own user account while running an ASP.NET page on my local machine. </p>
<p>Using the method described <a href="http://www.west-wind.com/WebLog/posts/1572.aspx" rel="nofollow noreferrer">here</a>, I have successfully changed the <code>WindowsIdentity.GetCurrent().... | [
{
"answer_id": 494049,
"author": "Daniel Schaffer",
"author_id": 2596,
"author_profile": "https://Stackoverflow.com/users/2596",
"pm_score": 1,
"selected": false,
"text": "<p>You do indeed need to be an admin in order to add or remove performance counters.</p>\n\n<p>I'm not sure why you'... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13100/"
] | I believe that I have successfully impersonated my own user account while running an ASP.NET page on my local machine.
Using the method described [here](http://www.west-wind.com/WebLog/posts/1572.aspx), I have successfully changed the `WindowsIdentity.GetCurrent().Name` from ASPNET to my domain account.
I can succes... | You could run your application on its own application pool (always a good thing) and assign it a service user the appropriate rights, that way you don't need to mess with impersonation. |
494,054 | <p>I am writing a Python utility that needs to parse a large, regularly-updated CSV file I don't control. The utility must run on a server with only Python 2.4 available. The CSV file does not quote field values at all, but the <a href="http://www.python.org/doc/2.4.3/lib/csv-fmt-params.html#csv-fmt-params" rel="nofo... | [
{
"answer_id": 494126,
"author": "Tanj",
"author_id": 4275,
"author_profile": "https://Stackoverflow.com/users/4275",
"pm_score": 5,
"selected": true,
"text": "<p>I don't know if python would like/allow it but could you use a non-printable ascii code such as BEL or BS (backspace) These I... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3207/"
] | I am writing a Python utility that needs to parse a large, regularly-updated CSV file I don't control. The utility must run on a server with only Python 2.4 available. The CSV file does not quote field values at all, but the [Python 2.4 version of the csv library](http://www.python.org/doc/2.4.3/lib/csv-fmt-params.html... | I don't know if python would like/allow it but could you use a non-printable ascii code such as BEL or BS (backspace) These I would think to be extremely rare. |
494,064 | <p>I get the following compilation error</p>
<p>fatal error C1189: #error : ERROR: Use of C runtime library internal header file.</p>
<p>I absolutely have no idea about it. can anyone throw some light on it?</p>
<p>The complete error:</p>
<p>C:\Program Files\Microsoft Visual Studio 8\VC\ce\include\crtdefs.h(100) :... | [
{
"answer_id": 494077,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 5,
"selected": true,
"text": "<p>You've probably got <code>crt/src</code> in your include directory search path. The headers in there are used to b... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I get the following compilation error
fatal error C1189: #error : ERROR: Use of C runtime library internal header file.
I absolutely have no idea about it. can anyone throw some light on it?
The complete error:
C:\Program Files\Microsoft Visual Studio 8\VC\ce\include\crtdefs.h(100) : fatal error C1189: #error : ERR... | You've probably got `crt/src` in your include directory search path. The headers in there are used to build the C Runtime - they aren't intended for use in user programs (even though they may have the same names as files that are intended to be included).
If you look in the header that's causing the problem, you'll pr... |
494,076 | <p>I have a ASP.NET page which has a form on it. It also has a search form on it. The search is in the top-right of the page, so the button for the search is the first added to the control hierachy.</p>
<p>When you're working on the other form and press enter it will click on the search button. I don't want this, I wo... | [
{
"answer_id": 494087,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": true,
"text": "<p>Try this instead.</p>\n\n<pre><code>$('#textBoxId').keydown(function(e) {\n if(e.keyCode === 13) {\n e.preventDef... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11388/"
] | I have a ASP.NET page which has a form on it. It also has a search form on it. The search is in the top-right of the page, so the button for the search is the first added to the control hierachy.
When you're working on the other form and press enter it will click on the search button. I don't want this, I would prefer... | Try this instead.
```
$('#textBoxId').keydown(function(e) {
if(e.keyCode === 13) {
e.preventDefault();
$('#buttonId').trigger('click');
}
});
``` |
494,083 | <p>I'm currently looking into unit testing for a new application I have to create. I've got the basic testing going nicely (testing the ActionResult classes is pretty nice). One thing I do want to make sure though, is that a viewpage exists in my solution. I'm not 100% sure my test is correct, so if anyone had suggesti... | [
{
"answer_id": 494699,
"author": "ajma",
"author_id": 60117,
"author_profile": "https://Stackoverflow.com/users/60117",
"pm_score": 0,
"selected": false,
"text": "<p>If you're using beta, your code-behind file will create a class for the View which you can check for using reflection.</p>... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/909/"
] | I'm currently looking into unit testing for a new application I have to create. I've got the basic testing going nicely (testing the ActionResult classes is pretty nice). One thing I do want to make sure though, is that a viewpage exists in my solution. I'm not 100% sure my test is correct, so if anyone had suggestions... | * No, I don't think you should split the test up as long as its just mainly a third assert and not very much more code.
* Yes, I think a more descriptive name would be helpful.
* Since you've verified it has the correct view name already, wouldn't simply successfully rendering the view verify its existence?
I think th... |
494,084 | <p>I'm trying to create a dynamic popup window that is able to be re-sized. However, since I'm not able to use static widths, I'm running into issues with using floats and percentages for the widths.</p>
<p>When I specify a percentage for the width of a floating div, it assumes I mean the <code>100%</code> of the wid... | [
{
"answer_id": 494103,
"author": "dylanfm",
"author_id": 38795,
"author_profile": "https://Stackoverflow.com/users/38795",
"pm_score": 3,
"selected": true,
"text": "<p>You could try something like this:</p>\n\n<pre><code><div style=\"width:100px;height:25px;position:relative\">\n ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23869/"
] | I'm trying to create a dynamic popup window that is able to be re-sized. However, since I'm not able to use static widths, I'm running into issues with using floats and percentages for the widths.
When I specify a percentage for the width of a floating div, it assumes I mean the `100%` of the width of the containing d... | You could try something like this:
```
<div style="width:100px;height:25px;position:relative">
<div style="width:20px;height:100%;position:absolute;background:red"> </div>
<div style="width:20px;height:100%;position:absolute;right:0;background:black"> </div>
<div style="height:100%;background:blue;padd... |
494,085 | <p>I'm trying to work out the "correct" way to handle populating an array with key-value coding for an iPhone app. I've come up with something that works, but it's fairly hackish. Basically I'm parsing an XML document into a set of code-generated models. Let's assume the XML is of this format:</p>
<pre><code><fo... | [
{
"answer_id": 494255,
"author": "Martin Pilkington",
"author_id": 50185,
"author_profile": "https://Stackoverflow.com/users/50185",
"pm_score": 0,
"selected": false,
"text": "<p>Well, there's 2 ways you can go about it:</p>\n\n<ol>\n<li>Add an \"Add Item\" method to your Bar class where... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60442/"
] | I'm trying to work out the "correct" way to handle populating an array with key-value coding for an iPhone app. I've come up with something that works, but it's fairly hackish. Basically I'm parsing an XML document into a set of code-generated models. Let's assume the XML is of this format:
```
<foo>
<bar>
... | If you want to use KVC properties for an array you should look into the documentation for `mutableArrayValueForKey:`
Basically with your class:
```
@interface Bar : NSObject {
NSMutableArray *items;
}
@end
```
You would define these methods as a minimum, assuming you initialized your array elsewhere:
```
- (vo... |
494,104 | <p>please, can someone explain to me, why the red div isn't expanding to the right? It stops where the screen ends. What do I have to do, to make it expand?</p>
<p>One thing that works is to "display: table-cell" the red div but I was wondering if there's another way and why this happens...?</p>
<pre><code><?xml v... | [
{
"answer_id": 494108,
"author": "Hexagon Theory",
"author_id": 59107,
"author_profile": "https://Stackoverflow.com/users/59107",
"pm_score": 0,
"selected": false,
"text": "<p>Depending on what you're using this for, I'm assuming the div element is going to be the main focus of the page;... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | please, can someone explain to me, why the red div isn't expanding to the right? It stops where the screen ends. What do I have to do, to make it expand?
One thing that works is to "display: table-cell" the red div but I was wondering if there's another way and why this happens...?
```
<?xml version="1.0" encoding="U... | The div that it's contained in is smaller than 2000px. You need to do something like this:
```
<div style="background-color: #f00; width: 2000px;">
<div style="width: 2000px; height: 100px; " />
</div>
```
Of course, now the inner div's width doesn't need to be specified unless it is different than the outer... |
494,109 | <p>I have a project where we use screen DTO's to encapsulate the data between the <strong>Service Layer</strong> and the <strong>Presentation Layer</strong>. In our case, the presentation layer is ASP.Net.</p>
<p>The only classes that know about the DTO's are the service layer classes and the Pages/Controls that call ... | [
{
"answer_id": 494142,
"author": "ssmith",
"author_id": 13729,
"author_profile": "https://Stackoverflow.com/users/13729",
"pm_score": 2,
"selected": false,
"text": "<p>Are you using actual services (web or WCF)? If so, then define the DTOs in the service layer and the proxy created when... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1894/"
] | I have a project where we use screen DTO's to encapsulate the data between the **Service Layer** and the **Presentation Layer**. In our case, the presentation layer is ASP.Net.
The only classes that know about the DTO's are the service layer classes and the Pages/Controls that call these services and display the DTO's... | Even thought the canonical use-case for the 'DTO' is more "serializable object that can be passed over the wire", in this case you are really referring more to 'presentation-transfer-objects' or 'view-models'.
Typically for our projects the answer to where these live is where the 'translation' code is that maps the DD... |
494,120 | <p>I have a Perl app that runs some perforce operations, in the end I would like it to upload the results to SharePoint website. </p>
<ul>
<li>What is the simplest Perl script that can accomplish a task of adding a document to SharePoint? </li>
</ul>
<p>The script would need to run on Solaris and use as few as possib... | [
{
"answer_id": 494152,
"author": "Nat",
"author_id": 13813,
"author_profile": "https://Stackoverflow.com/users/13813",
"pm_score": 1,
"selected": false,
"text": "<p>Can you use the <a href=\"http://webdav.org/perldav/\" rel=\"nofollow noreferrer\">Webdav</a> interface?\nEach SharePoint l... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35203/"
] | I have a Perl app that runs some perforce operations, in the end I would like it to upload the results to SharePoint website.
* What is the simplest Perl script that can accomplish a task of adding a document to SharePoint?
The script would need to run on Solaris and use as few as possible external libraries as poss... | Just found an easy way on windows from perlmonks forum:
```
http://www.perlmonks.org/?node_id=527182
under Windows, you can access a sharepoint site via a UNC name. The URL:
sharepoint.domain.dom/sites/Roboticus/Test
is accessible via:
\\sharepoint.domain.com\sites\Roboticus\Test
```
just adding as answer to myself,... |
494,135 | <p>I use GORM to generate my database's DDL from groovy classes. Which is great. However, the order of fields in the generated SQL is not the same as the order of fields in the class. For example, if I create the class</p>
<pre><code>class Person
{
String firstName
String lastName
String address
String emai... | [
{
"answer_id": 496490,
"author": "elbicho",
"author_id": 58328,
"author_profile": "https://Stackoverflow.com/users/58328",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not absolutely sure about this, but the constraints closure defines the order of the fields in the views, maybe tha... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45939/"
] | I use GORM to generate my database's DDL from groovy classes. Which is great. However, the order of fields in the generated SQL is not the same as the order of fields in the class. For example, if I create the class
```
class Person
{
String firstName
String lastName
String address
String email
}
```
the fol... | There doesn't appear to be a way to specify the ordering, but you could always create your own tables as you want them and provide name mappings in your domain classes.
You could also let GORM create the tables, and then recreate the tables in the right order, and turn off the automatic DDL stuff in GORM after that. If... |
494,140 | <p>I'm working on a .NET-powered questionnaire which contains several repeater controls, each row of which contains three radiobuttons. I'm trying to write a simple Javascript function to check all the controls on the page which contain the word "chkGreen" in the control name/id.</p>
<p>The page looks something like t... | [
{
"answer_id": 496490,
"author": "elbicho",
"author_id": 58328,
"author_profile": "https://Stackoverflow.com/users/58328",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not absolutely sure about this, but the constraints closure defines the order of the fields in the views, maybe tha... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60447/"
] | I'm working on a .NET-powered questionnaire which contains several repeater controls, each row of which contains three radiobuttons. I'm trying to write a simple Javascript function to check all the controls on the page which contain the word "chkGreen" in the control name/id.
The page looks something like this:
```
... | There doesn't appear to be a way to specify the ordering, but you could always create your own tables as you want them and provide name mappings in your domain classes.
You could also let GORM create the tables, and then recreate the tables in the right order, and turn off the automatic DDL stuff in GORM after that. If... |
494,143 | <p>I have an HTML string representing an element: <code>'<li>text</li>'</code>. I'd like to append it to an element in the DOM (a <code>ul</code> in my case). How can I do this with Prototype or with DOM methods?</p>
<p>(I know i could do this easily in jQuery, but unfortunately we're not using jQuery.)</p... | [
{
"answer_id": 494348,
"author": "Crescent Fresh",
"author_id": 45433,
"author_profile": "https://Stackoverflow.com/users/45433",
"pm_score": 11,
"selected": true,
"text": "<p><strong>Note:</strong> most current browsers support HTML <code><template></code> elements, which provide ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56829/"
] | I have an HTML string representing an element: `'<li>text</li>'`. I'd like to append it to an element in the DOM (a `ul` in my case). How can I do this with Prototype or with DOM methods?
(I know i could do this easily in jQuery, but unfortunately we're not using jQuery.) | **Note:** most current browsers support HTML `<template>` elements, which provide a more reliable way of turning creating elements from strings. See [Mark Amery's answer below for details](https://stackoverflow.com/a/35385518/1709587).
**For older browsers, and node/jsdom**: (which doesn't yet support `<template>` ele... |
494,156 | <p>Trying to create a list to return some JSON data to a view. Following a few tutorials on the web that were created during the beta but it seems in the RC the code does work.</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplic... | [
{
"answer_id": 494232,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": true,
"text": "<p>ListItem is in the System.Web.UI.WebControls...you probably don't want to use this. You could use SelectListItem whi... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/648/"
] | Trying to create a list to return some JSON data to a view. Following a few tutorials on the web that were created during the beta but it seems in the RC the code does work.
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplication6.Control... | ListItem is in the System.Web.UI.WebControls...you probably don't want to use this. You could use SelectListItem which is in the System.Web.Mvc namespace, but you'll have to change the property names (you'd have to do this for ListItem as well).
```
public JsonResult list()
{
List<SelectListItem> list ... |
494,161 | <p>I have a series of divs in a pattern of header/body, where a click on the header will show the body in question.</p>
<p>This all happens with .click initialized on page ready...</p>
<p>Rather than doing this (which works fine, but is a pain):</p>
<pre><code>$('#show_fold_ping').click(function(){ ShowArea('#fold_p... | [
{
"answer_id": 494176,
"author": "typeoneerror",
"author_id": 53653,
"author_profile": "https://Stackoverflow.com/users/53653",
"pm_score": 2,
"selected": false,
"text": "<p>Check the scope of your \"Area\" variable. You're basically assigning a global variable so on the last iteration \... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27580/"
] | I have a series of divs in a pattern of header/body, where a click on the header will show the body in question.
This all happens with .click initialized on page ready...
Rather than doing this (which works fine, but is a pain):
```
$('#show_fold_ping').click(function(){ ShowArea('#fold_ping') });
$('#show_fold_http... | Yes, I have run into this problem all too often. `Area` is a global variable since it does not have `var` before it. Also, don't use a for...in construct.
But you might still run into a similar problem. God knows how many scripts I've debugged because of a similar bug. Doing the following guarantees proper scoping:
`... |
494,163 | <p>Can someone explain what <code>PVOID</code> is and how it is used in a function like:</p>
<pre><code>BOOL DoSomething(PVOID pMemPhy)
</code></pre>
| [
{
"answer_id": 494168,
"author": "geofftnz",
"author_id": 20122,
"author_profile": "https://Stackoverflow.com/users/20122",
"pm_score": 5,
"selected": false,
"text": "<p>void pointer, same as </p>\n\n<pre><code>void *pMemPhy\n</code></pre>\n\n<p>aka \"Pointer to something, but it's up to... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can someone explain what `PVOID` is and how it is used in a function like:
```
BOOL DoSomething(PVOID pMemPhy)
``` | void pointer, same as
```
void *pMemPhy
```
aka "Pointer to something, but it's up to you to figure it out".
```
BOOL DoSomething ( PVOID pMemPhy )
{
strcpy((char *)pMemPhy, "I love buffer overflows!");
return TRUE;
}
``` |
494,180 | <p>I have a series of ranges with start dates and end dates. I want to check to see if a date is within that range.</p>
<p>Date.before() and Date.after() seem to be a little awkward to use. What I really need is something like this pseudocode:</p>
<pre><code>boolean isWithinRange(Date testDate) {
return testDate &g... | [
{
"answer_id": 494200,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 9,
"selected": true,
"text": "<pre><code>boolean isWithinRange(Date testDate) {\n return !(testDate.before(startDate) || testDate.after(endDate));\n... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16534/"
] | I have a series of ranges with start dates and end dates. I want to check to see if a date is within that range.
Date.before() and Date.after() seem to be a little awkward to use. What I really need is something like this pseudocode:
```
boolean isWithinRange(Date testDate) {
return testDate >= startDate && testD... | ```
boolean isWithinRange(Date testDate) {
return !(testDate.before(startDate) || testDate.after(endDate));
}
```
Doesn't seem that awkward to me. Note that I wrote it that way instead of
```
return testDate.after(startDate) && testDate.before(endDate);
```
so it would work even if testDate was exactly equal t... |
494,187 | <p>I already have a test setup up for this function but I would like to know if it's the best way to go about it. I have a method like this:</p>
<pre><code>public static string RunTableInfoCommand(IMapinfoWrapper wrapper,
TableInfoEnum infoToReturn)
{
//pass the int value of... | [
{
"answer_id": 494234,
"author": "moffdub",
"author_id": 10759,
"author_profile": "https://Stackoverflow.com/users/10759",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand you correctly, your method under test is supposed to pass the enum value to the COM object and return t... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] | I already have a test setup up for this function but I would like to know if it's the best way to go about it. I have a method like this:
```
public static string RunTableInfoCommand(IMapinfoWrapper wrapper,
TableInfoEnum infoToReturn)
{
//pass the int value of infoToReturn t... | If I understand you correctly, your method under test is supposed to pass the enum value to the COM object and return the string that the COM object returns. So the goal of the test is to make sure that the method is talking to the COM object correctly.
I would mock out the COM object to return the expected string for... |
494,209 | <p>How to order Controls at runtime in ASP.NET
for instance I have three text boxes in my web page in the following order</p>
<ul>
<li>textbox1</li>
<li>textbox2</li>
<li>textbox3</li>
</ul>
<p>I want the order of these controls to be changed depending on the user preferences</p>
<ul>
<li>textbox3</li>
<li>textbox2<... | [
{
"answer_id": 494323,
"author": "Rex M",
"author_id": 67,
"author_profile": "https://Stackoverflow.com/users/67",
"pm_score": -1,
"selected": false,
"text": "<p>For a very simple proof-of-concept, you would need some kind of backing store like a database table that stores UserID, Ordina... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459737/"
] | How to order Controls at runtime in ASP.NET
for instance I have three text boxes in my web page in the following order
* textbox1
* textbox2
* textbox3
I want the order of these controls to be changed depending on the user preferences
* textbox3
* textbox2
* textbox1
that is just an example, any idea? | Finally I have found a solution and I will explain it in detail
create a "panel control" and called it "myPanel" and put in this all controls you want to resort
```
<asp:Panel ID="myPanel" runat="server">
<asp:Panel ID="dock1" runat="server">this is first module</asp:Panel>
<asp:Panel ID="dock2" runat... |
494,224 | <p>I am trying to determine if two <code>HashSet</code> objects in .NET 3.5 (C#) are equal sets, <em>i.e.</em> contain the same values. This seems like something one would obviously want to do but none of the provided functions seem to give you this information.</p>
<p>The way I can think to do this is by checking if ... | [
{
"answer_id": 494240,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 8,
"selected": true,
"text": "<p>Look at the method <a href=\"https://msdn.microsoft.com/en-us/library/dd412096(v=vs.110).aspx\" rel=\"noreferrer\">... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60067/"
] | I am trying to determine if two `HashSet` objects in .NET 3.5 (C#) are equal sets, *i.e.* contain the same values. This seems like something one would obviously want to do but none of the provided functions seem to give you this information.
The way I can think to do this is by checking if the count of the two sets ar... | Look at the method [SetEquals](https://msdn.microsoft.com/en-us/library/dd412096(v=vs.110).aspx).
```
my_hashset.SetEquals(other);
``` |
494,235 | <p><strong>What's a reliable way in JavaScript to determine the media type (e.g. screen, print, handheld) of the page?</strong> I've seen references to <code>document.styleSheets[0].media</code>, but I've had no luck using this, either because of browser support issues or because I'm not understanding something.</p>
<p... | [
{
"answer_id": 494251,
"author": "geowa4",
"author_id": 50214,
"author_profile": "https://Stackoverflow.com/users/50214",
"pm_score": 0,
"selected": false,
"text": "<pre><code>document.getElementsByTagName('link').each(function( link )\n{\n //do something with link.media\n //hide whate... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52530/"
] | **What's a reliable way in JavaScript to determine the media type (e.g. screen, print, handheld) of the page?** I've seen references to `document.styleSheets[0].media`, but I've had no luck using this, either because of browser support issues or because I'm not understanding something.
I'm asking because I want someth... | >
> [..], Prototype won't allow an element to be switched to visible if it was declared invisible (`display: none`) with non-inline CSS. This is something that I haven't understood and am constantly irritated by.
>
>
>
You probably already seen this but the documentation for e.g. [`show`](http://www.prototypejs.or... |
494,250 | <p>I have a Director project with 3 scripts (2 behaviors and 1 movie script). I have the following code in my movie script:</p>
<pre><code>on startRecording ()
--do stuff
_movie.script["script2"].passGrade(75, 3, 4)
end
</code></pre>
<p>and in one of my behavior scripts, I have the following:</p>
<pre><code>on p... | [
{
"answer_id": 755624,
"author": "Eliram",
"author_id": 18790,
"author_profile": "https://Stackoverflow.com/users/18790",
"pm_score": 0,
"selected": false,
"text": "<p>A movie script can't call a behavior script since the bahavior script can be attached to more than one object, and then ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] | I have a Director project with 3 scripts (2 behaviors and 1 movie script). I have the following code in my movie script:
```
on startRecording ()
--do stuff
_movie.script["script2"].passGrade(75, 3, 4)
end
```
and in one of my behavior scripts, I have the following:
```
on passGrade (acc, dur, tim)
member("As... | The syntax for calling the behavior script should rather be:
script("script2").passGrade(75, 3, 4)
Alternatively you could attach your behavior to the flash sprite (the instance of your flash on the stage), and send the call to the sprite:
sendSprite (flashSpriteNumOrNameOrRef, #passGrade, 75, 3, 4)
About calling a... |
494,260 | <p>Call me a 'n00b', but I am new to creating Script Controls. I want to create a simple control with 3 text boxes. I have a .cs file that looks like this:</p>
<pre><code> public class SmokingCalc : ScriptControl
{
public SmokingCalc()
{
Render(htmlWriter);
}
protecte... | [
{
"answer_id": 755624,
"author": "Eliram",
"author_id": 18790,
"author_profile": "https://Stackoverflow.com/users/18790",
"pm_score": 0,
"selected": false,
"text": "<p>A movie script can't call a behavior script since the bahavior script can be attached to more than one object, and then ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53599/"
] | Call me a 'n00b', but I am new to creating Script Controls. I want to create a simple control with 3 text boxes. I have a .cs file that looks like this:
```
public class SmokingCalc : ScriptControl
{
public SmokingCalc()
{
Render(htmlWriter);
}
protected override voi... | The syntax for calling the behavior script should rather be:
script("script2").passGrade(75, 3, 4)
Alternatively you could attach your behavior to the flash sprite (the instance of your flash on the stage), and send the call to the sprite:
sendSprite (flashSpriteNumOrNameOrRef, #passGrade, 75, 3, 4)
About calling a... |
494,297 | <pre><code>if (isset($_POST['login'])) {
$query = mysql_query("
SELECT id FROM users
WHERE username = '".mysql_real_escape_string($_POST['username'])."'
AND password = '".mysql_real_escape_string($_POST['password'])."'
");
/* wrong login information? output a m... | [
{
"answer_id": 494306,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 1,
"selected": false,
"text": "<p>Are you remembering to call <code>session_start()</code> in each and every PHP page that needs to access <code>$_SESSION<... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
if (isset($_POST['login'])) {
$query = mysql_query("
SELECT id FROM users
WHERE username = '".mysql_real_escape_string($_POST['username'])."'
AND password = '".mysql_real_escape_string($_POST['password'])."'
");
/* wrong login information? output a message and terminate the script */
if... | Have you definitely called [session\_start](http://uk.php.net/manual/en/session.examples.basic.php)? |
494,302 | <p>I have to be missing something obvious here. I don't get why this cast of the results of a linq query returns null and not the typed list I'm requesting.</p>
<pre><code>IList<IMyDataInterface> list = query.ToList() as IList<IMyDataInterface>;
</code></pre>
<p>The complete code to run this is below. Thi... | [
{
"answer_id": 494330,
"author": "Randolpho",
"author_id": 12716,
"author_profile": "https://Stackoverflow.com/users/12716",
"pm_score": 3,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>var query = from n in names\n where n.Contains(\"a\")\n select new ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16426/"
] | I have to be missing something obvious here. I don't get why this cast of the results of a linq query returns null and not the typed list I'm requesting.
```
IList<IMyDataInterface> list = query.ToList() as IList<IMyDataInterface>;
```
The complete code to run this is below. This is a knowledge gap I need to bridge.... | The problem here is one of **covariance**.
First, your example is a bit too complicated. I have removed some fluff. Also, I've added some diagnostics that illuminate the problem.
```
class Program
{
static void Main(string[] args)
{
var names = new[] { "Tom", "Dick", "Harry", "Mary", "Jay" };
... |
494,324 | <p>Last night I decided to add HTML fragment links in my computer listing page. However, no matter the pattern of linking, or whichever browser I use, those fragment links are simply not navigatable.</p>
<p><a href="http://icelava.net/mycomputers.aspx#SEPHIROTH" rel="nofollow noreferrer">http://icelava.net/mycomputers... | [
{
"answer_id": 494338,
"author": "assplecake",
"author_id": 57198,
"author_profile": "https://Stackoverflow.com/users/57198",
"pm_score": 3,
"selected": true,
"text": "<p>In order for those urls to navigate to your intended target, you need named anchors instead of the linked anchors tha... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2663/"
] | Last night I decided to add HTML fragment links in my computer listing page. However, no matter the pattern of linking, or whichever browser I use, those fragment links are simply not navigatable.
<http://icelava.net/mycomputers.aspx#SEPHIROTH>
<http://icelava.net/mycomputers.aspx#DIABLO>
*UPDATE on Answer: the link... | In order for those urls to navigate to your intended target, you need named anchors instead of the linked anchors that you have in your page. Example:
```
<a name="SEPHIROTH" />
```
(without the hashmark)
instead of:
```
<a href="#SEPHIROTH"> #1</a>
```
Preferably, instead of using named anchors, you could also j... |
494,325 | <p>How does one map the function below to java?<br></p>
<p><b>VOID WriteToStruct(BOOL *Status, STRUCT_MSG RecBuff)</b></p>
<p>What this function does: <br>
1) Populates the struct RecBuff<br>
2) Updates status<br></p>
<p>How do I map to a boolean pointer in Java and access the struct data updated by the function?</p... | [
{
"answer_id": 534697,
"author": "Brian",
"author_id": 725,
"author_profile": "https://Stackoverflow.com/users/725",
"pm_score": 3,
"selected": false,
"text": "<p>I was searching for another issue concerning JNA and structs, and Google redirected me here. I hope this helps.</p>\n\n<p>Fr... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How does one map the function below to java?
**VOID WriteToStruct(BOOL \*Status, STRUCT\_MSG RecBuff)**
What this function does:
1) Populates the struct RecBuff
2) Updates status
How do I map to a boolean pointer in Java and access the struct data updated by the function? | I was searching for another issue concerning JNA and structs, and Google redirected me here. I hope this helps.
From [JNA API](https://jna.dev.java.net/javadoc/overview-summary.html#byvalue "JNA API")
>
> To pass a structure by value, first
> define the structure, then define an
> empty class from that which imple... |
494,332 | <p>Hi I am trying to return a collection of building domain.</p>
<pre><code>private long _id;
private string _buildingName;
private IList<BasicRoom> _rooms;
</code></pre>
<p>I am using NHibernate and this mapping for the rooms</p>
<pre><code><bag name="rooms" table="tb_rooms" lazy="false">
<key column... | [
{
"answer_id": 494349,
"author": "Randolpho",
"author_id": 12716,
"author_profile": "https://Stackoverflow.com/users/12716",
"pm_score": 3,
"selected": false,
"text": "<p>Why do you need a concrete <code>List</code> object, when you can do everything you want with an <code>IList</code>? ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17510/"
] | Hi I am trying to return a collection of building domain.
```
private long _id;
private string _buildingName;
private IList<BasicRoom> _rooms;
```
I am using NHibernate and this mapping for the rooms
```
<bag name="rooms" table="tb_rooms" lazy="false">
<key column="buildingID"/>
<one-to-many class="Room"/>
</bag>
... | That's not how NHibernate works. You don't get to tell it what the concrete types of your domain model objects are. You only get to tell it what the base types and interfaces are. Then it gets to choose how to implement the domain types efficiently.
For example, NHibernate uses its own internal implementation of `ILis... |
494,337 | <p>I am using ADO.Net Data Services and have a Service Operation that ends up returning the results of some linq to entities statements. As a part of those Linq statements there is a .Include("NavProp") to include a sub-object. When running this service operation it doesn't appear to return that expanded Include. Do... | [
{
"answer_id": 494349,
"author": "Randolpho",
"author_id": 12716,
"author_profile": "https://Stackoverflow.com/users/12716",
"pm_score": 3,
"selected": false,
"text": "<p>Why do you need a concrete <code>List</code> object, when you can do everything you want with an <code>IList</code>? ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25719/"
] | I am using ADO.Net Data Services and have a Service Operation that ends up returning the results of some linq to entities statements. As a part of those Linq statements there is a .Include("NavProp") to include a sub-object. When running this service operation it doesn't appear to return that expanded Include. Does any... | That's not how NHibernate works. You don't get to tell it what the concrete types of your domain model objects are. You only get to tell it what the base types and interfaces are. Then it gets to choose how to implement the domain types efficiently.
For example, NHibernate uses its own internal implementation of `ILis... |
494,345 | <p>I am writing my own HtmlHelper extenstion for ASP.NET MVC:</p>
<pre><code>public static string CreateDialogLink (this HtmlHelper htmlHelper, string linkText,
string contentPath)
{
// fix up content path if the user supplied a path beginning with '~'
... | [
{
"answer_id": 494353,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 0,
"selected": false,
"text": "<p>Well, you can always pass the instance of the page to the extension method. I think that is a much better way of doi... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I am writing my own HtmlHelper extenstion for ASP.NET MVC:
```
public static string CreateDialogLink (this HtmlHelper htmlHelper, string linkText,
string contentPath)
{
// fix up content path if the user supplied a path beginning with '~'
contentPa... | Before asking this question I had looked at some of the MVC source code, but evidently I missed this, which is how they do it for the Image helper.
```
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#", Justification = "The return value is n... |
494,362 | <p>I have a table and I am highlighting alternate columns in the table using jquery</p>
<pre><code>$("table.Table22 tr td:nth-child(even)").css("background","blue");
</code></pre>
<p>However I have another <code><table></code> inside a <code><tr></code> as the last row. How can I avoid highlighting column... | [
{
"answer_id": 494373,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Untested but perhaps: <a href=\"http://docs.jquery.com/Traversing/not#expr\" rel=\"nofollow noreferrer\">http://docs.jquery... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55428/"
] | I have a table and I am highlighting alternate columns in the table using jquery
```
$("table.Table22 tr td:nth-child(even)").css("background","blue");
```
However I have another `<table>` inside a `<tr>` as the last row. How can I avoid highlighting columns of tables that are inside `<tr>` ? | Qualify it with the `>` descendant selector:
```
$("table.Table22 > tbody > tr > td:nth-child(even)").css("background","blue");
```
You need the `tbody` qualifier too, as browsers automatically insert a `tbody` **whether you have it in your markup or not**.
*Edit*: woops. Thanks Annan.
*Edit 2*: stressed tbody. |
494,371 | <p>I have a weird problem with images in visual web developer, </p>
<p>I cant change my images properties from properties panel (my changes don't take effect) and all images in my website have gotten the same size </p>
<p>when I resize one image (by dragging the border), all images get that new size?</p>
<p>any idea... | [
{
"answer_id": 494373,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Untested but perhaps: <a href=\"http://docs.jquery.com/Traversing/not#expr\" rel=\"nofollow noreferrer\">http://docs.jquery... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459737/"
] | I have a weird problem with images in visual web developer,
I cant change my images properties from properties panel (my changes don't take effect) and all images in my website have gotten the same size
when I resize one image (by dragging the border), all images get that new size?
any idea? | Qualify it with the `>` descendant selector:
```
$("table.Table22 > tbody > tr > td:nth-child(even)").css("background","blue");
```
You need the `tbody` qualifier too, as browsers automatically insert a `tbody` **whether you have it in your markup or not**.
*Edit*: woops. Thanks Annan.
*Edit 2*: stressed tbody. |
494,376 | <p>I have a legacy DLL written in C that I'd like to call from a C# .NET application. The problem is that the DLL interface for the C DLL is fairly complicated. It's something like this:</p>
<pre><code>__declspec(dllexport) void __stdcall ProcessChunk(
void *p_prochdl,
const BIG_INPUT_STRC *p_inparams,
B... | [
{
"answer_id": 494436,
"author": "Tim",
"author_id": 60469,
"author_profile": "https://Stackoverflow.com/users/60469",
"pm_score": 3,
"selected": true,
"text": "<p>Its quite straight forward to do this soft of thing in C# using P/Invoke.</p>\n\n<p>I belive you are going to have to define... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10505/"
] | I have a legacy DLL written in C that I'd like to call from a C# .NET application. The problem is that the DLL interface for the C DLL is fairly complicated. It's something like this:
```
__declspec(dllexport) void __stdcall ProcessChunk(
void *p_prochdl,
const BIG_INPUT_STRC *p_inparams,
BIG_OUTPUT_STRC *... | Its quite straight forward to do this soft of thing in C# using P/Invoke.
I belive you are going to have to define the data structures in C# manually.
I would reccomend you take a look at this [MSDN article](http://msdn.microsoft.com/en-us/library/aa288468.aspx) on the subject |
494,397 | <p>Since SQLite does not support RIGHT OUTER JOINS I pose the following challenge (read: invitation to do my work for me):</p>
<p>Refactor this query so it no longer utilises SQLite-unsupported constructs like RIGHT/FULL OUTER JOINs.</p>
<pre><code>SELECT strings.*, translations.text
FROM translations INN... | [
{
"answer_id": 494421,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>The following is untested.</p>\n\n<pre><code>select strings.*, translations.text\nfrom strings left outer join transl... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60475/"
] | Since SQLite does not support RIGHT OUTER JOINS I pose the following challenge (read: invitation to do my work for me):
Refactor this query so it no longer utilises SQLite-unsupported constructs like RIGHT/FULL OUTER JOINs.
```
SELECT strings.*, translations.text
FROM translations INNER JOIN
... | The following is untested.
```
select strings.*, translations.text
from strings left outer join translations
on translations.string_id = strings.id
and translations.language_id = (select id
from language
where languag... |
494,412 | <p>I am thinking of keeping data in a DataSet in a WCF hosted service and other apps (on same box) can access the data via Named Pipes (exposed through the WCF service). The apps then keep a copy of dataSet inside them so as to not re-fetch the data from the WCF unless it gets changed.</p>
<p>Data is retrieved from th... | [
{
"answer_id": 494421,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>The following is untested.</p>\n\n<pre><code>select strings.*, translations.text\nfrom strings left outer join transl... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60477/"
] | I am thinking of keeping data in a DataSet in a WCF hosted service and other apps (on same box) can access the data via Named Pipes (exposed through the WCF service). The apps then keep a copy of dataSet inside them so as to not re-fetch the data from the WCF unless it gets changed.
Data is retrieved from the server i... | The following is untested.
```
select strings.*, translations.text
from strings left outer join translations
on translations.string_id = strings.id
and translations.language_id = (select id
from language
where languag... |
494,414 | <p>I have been asked to pull in columns for use in a web app.I am using asp.net and C#. I was using a dataReader to populate the class variables. The problem is that the dbf file can change. Sometimes rows are added or deleted so my class would have to change every time the data source file changes to represent the col... | [
{
"answer_id": 494421,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>The following is untested.</p>\n\n<pre><code>select strings.*, translations.text\nfrom strings left outer join transl... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45429/"
] | I have been asked to pull in columns for use in a web app.I am using asp.net and C#. I was using a dataReader to populate the class variables. The problem is that the dbf file can change. Sometimes rows are added or deleted so my class would have to change every time the data source file changes to represent the column... | The following is untested.
```
select strings.*, translations.text
from strings left outer join translations
on translations.string_id = strings.id
and translations.language_id = (select id
from language
where languag... |
494,442 | <p>I have a Java program using AWT which I would like to run on a headless system. The display for the program does nothing other than display stats. When the program finishes, it exits. There is no user interaction on the display. The program creates an output file which I use in my build system.</p>
<p>Is there a wa... | [
{
"answer_id": 494456,
"author": "Peter B. Bock",
"author_id": 56832,
"author_profile": "https://Stackoverflow.com/users/56832",
"pm_score": 4,
"selected": false,
"text": "<p>Xvfb can do what you ask for. I've not used it myself, but here is a link to wikipedia: <a href=\"http://en.wikip... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22306/"
] | I have a Java program using AWT which I would like to run on a headless system. The display for the program does nothing other than display stats. When the program finishes, it exits. There is no user interaction on the display. The program creates an output file which I use in my build system.
Is there a way to get t... | The underlying question here is how to run Java applications without an X server; providing a "fake" X server is only one option. In Java 1.4 and up, you can do the following:
```
java -Djava.awt.headless=true
```
This allows applications which use AWT to run on headless systems even without an X server. |
494,463 | <p>I'm learning how to use the CCR (Concurrency and Coordination Runtime) in conjunction with a Asynchronous WCF Web Service.</p>
<p>This is the Test WCF Service:</p>
<pre><code> public class Service : IService
{
private Accounts.Manager accountManager = new Accounts.Manager();
public IAsyncRes... | [
{
"answer_id": 509267,
"author": "Andrew Harry",
"author_id": 30576,
"author_profile": "https://Stackoverflow.com/users/30576",
"pm_score": 2,
"selected": true,
"text": "<p>OK i finally got somewhere with all of this!</p>\n\n<p>First up: You need a custom AsyncResult Class</p>\n\n<pre><c... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30576/"
] | I'm learning how to use the CCR (Concurrency and Coordination Runtime) in conjunction with a Asynchronous WCF Web Service.
This is the Test WCF Service:
```
public class Service : IService
{
private Accounts.Manager accountManager = new Accounts.Manager();
public IAsyncResult BeginGetAccount(i... | OK i finally got somewhere with all of this!
First up: You need a custom AsyncResult Class
```
class AsyncResult : IAsyncResult , IDisposable
{
object _state;
ManualResetEvent _waitHandle = new ManualResetEvent(false);
bool _isCompleted;
#region IAsyncResult Members
public... |
494,465 | <p>Short of parsing the output of <code>ipconfig</code>, does anyone have a 100% pure java way of doing this?</p>
| [
{
"answer_id": 494480,
"author": "Eddie",
"author_id": 57752,
"author_profile": "https://Stackoverflow.com/users/57752",
"pm_score": 7,
"selected": true,
"text": "<p>This is pretty easy:</p>\n\n<pre><code>try {\n InetAddress localhost = InetAddress.getLocalHost();\n LOG.info(\" IP Addr... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | Short of parsing the output of `ipconfig`, does anyone have a 100% pure java way of doing this? | This is pretty easy:
```
try {
InetAddress localhost = InetAddress.getLocalHost();
LOG.info(" IP Addr: " + localhost.getHostAddress());
// Just in case this host has multiple IP addresses....
InetAddress[] allMyIps = InetAddress.getAllByName(localhost.getCanonicalHostName());
if (allMyIps != null && allMyIps... |
494,501 | <p>I am wondering whats the best practices regarding functions and objects. For example I want to perform an action called tidy. It will take my data as input and tidy it and return it.</p>
<p>Now I can do this in two ways. One using a simple function and the other using a class.</p>
<pre><code>Function: $data = tidy... | [
{
"answer_id": 494532,
"author": "Adam Hawes",
"author_id": 54415,
"author_profile": "https://Stackoverflow.com/users/54415",
"pm_score": 2,
"selected": true,
"text": "<p>I'd personally make a 'data' object that handles data then have a tidy method under it. </p>\n\n<p>This pattern will... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426996/"
] | I am wondering whats the best practices regarding functions and objects. For example I want to perform an action called tidy. It will take my data as input and tidy it and return it.
Now I can do this in two ways. One using a simple function and the other using a class.
```
Function: $data = tidy($data);
Class:
$tidy... | I'd personally make a 'data' object that handles data then have a tidy method under it.
This pattern will allow the number of tasks you do on data to expand while containing it all in a nice little self-contained chunk. |
494,506 | <p>Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements?</p>
<p>I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though</p>
| [
{
"answer_id": 494513,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 4,
"selected": true,
"text": "<p>You want to use a refactoring that replaces a conditional using a polymorphic class. For <a href=\"http://www.refactor... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22039/"
] | Are there any design patterns/methods/ways to remove nested if then else conditions/switch statements?
I remember coming across some methods used by the Google folks listed in a Google code blog post. Can’t seem to find it now though | You want to use a refactoring that replaces a conditional using a polymorphic class. For [example](http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html).
Or here's another [example](http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism)
Essentially the ideal is very simple y... |
494,550 | <p>I'm writing an integration test where I will be inserting a number of objects into a database and then checking to make sure whether my method retrieves those objects.</p>
<p>My connection to the database is through NHibernate...and my usual method of creating such a test would be to do the following:</p>
<pre><co... | [
{
"answer_id": 494593,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 8,
"selected": true,
"text": "<p>Essentially TransactionScope doesn't track your Adapter's, what it does is it tracks database connections. When you op... | 2009/01/30 | [
"https://Stackoverflow.com/questions/494550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39532/"
] | I'm writing an integration test where I will be inserting a number of objects into a database and then checking to make sure whether my method retrieves those objects.
My connection to the database is through NHibernate...and my usual method of creating such a test would be to do the following:
```
NHibernateSession.... | Essentially TransactionScope doesn't track your Adapter's, what it does is it tracks database connections. When you open a DB connection the connections will looks if there is an ambient transaction (Transaction Scope) and if so enlist with it. Caution if there are more the one connection to the same SQL server this wi... |