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 |
|---|---|---|---|---|---|---|
363,944 | <p>I'm calling a bunch of methods that return a list. The list may be empty. If the list is non-empty, I want to return the first item; otherwise, I want to return <code>None</code>. This code works:</p>
<pre class="lang-py prettyprint-override"><code>def main():
my_list = get_list()
if len(my_list) > 0:
... | [
{
"answer_id": 363955,
"author": "recursive",
"author_id": 44743,
"author_profile": "https://Stackoverflow.com/users/44743",
"pm_score": 7,
"selected": false,
"text": "<pre><code>(get_list() or [None])[0]\n</code></pre>\n\n<p>That should work.</p>\n\n<p>BTW I didn't use the variable <cod... | 2008/12/12 | [
"https://Stackoverflow.com/questions/363944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19403/"
] | I'm calling a bunch of methods that return a list. The list may be empty. If the list is non-empty, I want to return the first item; otherwise, I want to return `None`. This code works:
```py
def main():
my_list = get_list()
if len(my_list) > 0:
return my_list[0]
return None
```
but it seems to m... | Python 2.6+
-----------
```
next(iter(your_list), None)
```
If `your_list` can be `None`:
```
next(iter(your_list or []), None)
```
Python 2.4
----------
```
def get_first(iterable, default=None):
if iterable:
for item in iterable:
return item
return default
```
Example:
```
x = ge... |
363,969 | <p>I have the following code</p>
<pre><code>Try
'Some code that causes exception
Catch ex as ExceptionType1
'Handle Section - 1
Catch ex as ExceptionType2
'Handle section - 2
Catch ex as ExceptionType3
'Handle section - 3
Finally
' Clean up
End Try
</code></pre>
<p>Suppose ExceptionType1 is th... | [
{
"answer_id": 363978,
"author": "kemiller2002",
"author_id": 1942,
"author_profile": "https://Stackoverflow.com/users/1942",
"pm_score": 3,
"selected": false,
"text": "<p>Change the code to catch all the exceptions in one block and determine the type and execution path from there. </p>\... | 2008/12/12 | [
"https://Stackoverflow.com/questions/363969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38997/"
] | I have the following code
```
Try
'Some code that causes exception
Catch ex as ExceptionType1
'Handle Section - 1
Catch ex as ExceptionType2
'Handle section - 2
Catch ex as ExceptionType3
'Handle section - 3
Finally
' Clean up
End Try
```
Suppose ExceptionType1 is thrown by the code which is ... | Change the code to catch all the exceptions in one block and determine the type and execution path from there. |
363,998 | <p>I have this:</p>
<pre><code>template <typename T>
class myList
{
...
class myIterator
{
...
T& operator*();
}
}
...
template<typename T>
T& myList<T>::myIterator::operator*()
{
...
}
</code></pre>
<p>That is giving me the following error: "expected init... | [
{
"answer_id": 364013,
"author": "David Norman",
"author_id": 34502,
"author_profile": "https://Stackoverflow.com/users/34502",
"pm_score": 2,
"selected": false,
"text": "<p>How about some semicolons and publics:</p>\n\n<pre><code>template <typename T>\nclass myList\n{\npublic:\n ... | 2008/12/12 | [
"https://Stackoverflow.com/questions/363998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have this:
```
template <typename T>
class myList
{
...
class myIterator
{
...
T& operator*();
}
}
...
template<typename T>
T& myList<T>::myIterator::operator*()
{
...
}
```
That is giving me the following error: "expected initializer before '&' token". What exactly am I suppose... | How about some semicolons and publics:
```
template <typename T>
class myList
{
public:
class myIterator
{
public:
T& operator*();
};
};
``` |
364,007 | <p>I'm learning WPF, and seem to have found something a little odd, which I can't find the reason to anywhere I've searched.</p>
<p>I have a window with one checkbox on it called "chkTest". I have it set to be true by default.</p>
<p>The following code is what I don't understand. Basically I'm trying to set the "ch... | [
{
"answer_id": 364079,
"author": "Sailing Judo",
"author_id": 42620,
"author_profile": "https://Stackoverflow.com/users/42620",
"pm_score": 3,
"selected": true,
"text": "<p>Bah... I think I know what to do now. I should be making my own control rather than modifying a Button. This woul... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm learning WPF, and seem to have found something a little odd, which I can't find the reason to anywhere I've searched.
I have a window with one checkbox on it called "chkTest". I have it set to be true by default.
The following code is what I don't understand. Basically I'm trying to set the "chkTest" control to a... | Bah... I think I know what to do now. I should be making my own control rather than modifying a Button. This would have been obvious to me had I been working in WinForms, but for some reason all this Xaml is making me stupid. |
364,009 | <pre><code>Regex.IsMatch( "foo", "[\U00010000-\U0010FFFF]" )
</code></pre>
<p>Throws: System.ArgumentException: parsing "[-]" - [x-y] range in reverse order.</p>
<p>Looking at the hex values for \U00010000 and \U0010FFF I get: 0xd800 0xdc00 for the first character and 0xdbff 0xdfff for the second.</p>
<p>So I gues... | [
{
"answer_id": 364024,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>They're <a href=\"http://en.wikipedia.org/wiki/UTF-16\" rel=\"noreferrer\">surrogate pairs</a>. Look at the values - t... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1455/"
] | ```
Regex.IsMatch( "foo", "[\U00010000-\U0010FFFF]" )
```
Throws: System.ArgumentException: parsing "[-]" - [x-y] range in reverse order.
Looking at the hex values for \U00010000 and \U0010FFF I get: 0xd800 0xdc00 for the first character and 0xdbff 0xdfff for the second.
So I guess I have really have one problem. ... | They're [surrogate pairs](http://en.wikipedia.org/wiki/UTF-16). Look at the values - they're over 65535. A char is only a 16 bit value. How would you expression 65536 in only 16 bits?
Unfortunately it's not clear from the documentation how (or whether) the regular expression engine in .NET copes with characters which ... |
364,014 | <p>I wonder if there is a way to use ungreedy matching in JavaScript? I tried the U modifer, but it doesn't seem to work.</p>
<p>I want to write a small BBCode parser in JavaScript, but without ungreedy matching it isn't possible (at least as far as I see it) to do something like this:</p>
<pre><code>'[b]one[/b] two ... | [
{
"answer_id": 364029,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 7,
"selected": true,
"text": "<p>You can use <code>?</code> after <code>*</code> or <code>+</code> to make it ungreedy, e.g. <code>(.*?)</code></p>\n"
},
... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35903/"
] | I wonder if there is a way to use ungreedy matching in JavaScript? I tried the U modifer, but it doesn't seem to work.
I want to write a small BBCode parser in JavaScript, but without ungreedy matching it isn't possible (at least as far as I see it) to do something like this:
```
'[b]one[/b] two [b]three[/b]'.replace... | You can use `?` after `*` or `+` to make it ungreedy, e.g. `(.*?)` |
364,019 | <p>I'd like to have revision number of source code to Delphi's source code and exe version. What is the best way to do this automatically?</p>
<p>I'd like to display the revision number in "About" screen and in the version info of the project.</p>
<p>I'm using currently Delphi IDE (2006/2007) and Tortoise SVN.</p>
| [
{
"answer_id": 364037,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 1,
"selected": false,
"text": "<p>Suggestion: modify your build scripts to change some version file that gets compiled in afterwards. It's difficult to sug... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7735/"
] | I'd like to have revision number of source code to Delphi's source code and exe version. What is the best way to do this automatically?
I'd like to display the revision number in "About" screen and in the version info of the project.
I'm using currently Delphi IDE (2006/2007) and Tortoise SVN. | I agree with the comments about *$Revision$* not being the right tool for the job. Using a tool to extract the revision number from the output of *svn* *info* is indeed the correct thing to do.
There are however two more things to note:
1. *svn* *info* will only return the correct information if *svn* *update* has be... |
364,055 | <p>Using NUnit 2.2 on .NET 3.5, the following test fails when using DateTime.Equals. Why?</p>
<pre><code>[TestFixture]
public class AttributeValueModelTest
{
public class HasDate
{
public DateTime? DateValue
{
get
{
DateTime value;
return ... | [
{
"answer_id": 364063,
"author": "Stephane Grenier",
"author_id": 39371,
"author_profile": "https://Stackoverflow.com/users/39371",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know if this is the same in .NET, but in Java the equals often will only compare if the instances are ... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/470/"
] | Using NUnit 2.2 on .NET 3.5, the following test fails when using DateTime.Equals. Why?
```
[TestFixture]
public class AttributeValueModelTest
{
public class HasDate
{
public DateTime? DateValue
{
get
{
DateTime value;
return DateTime.TryPa... | The dates aren't equal. TryParse drops some ticks. Compare the Tick values.
For one test run:
```
Console.WriteLine(date.DateValue.Value.Ticks);
Console.WriteLine(actual.Ticks);
```
Yields:
```
633646934930000000
633646934936763185
``` |
364,066 | <p>When Internet Explorers AutoComplete is turned on for Forms the entries for each field in the HTML form should be cached and displayed as a prompt when the user starts entering content into the form the second time around. </p>
<p>On my website the AutoComplete feature is never displayed for any forms that exist o... | [
{
"answer_id": 364076,
"author": "cLFlaVA",
"author_id": 45109,
"author_profile": "https://Stackoverflow.com/users/45109",
"pm_score": 1,
"selected": false,
"text": "<p>Do you have <code>autocomplete=\"off\"</code> as an attribute in your form elements?</p>\n"
},
{
"answer_id": 3... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10350/"
] | When Internet Explorers AutoComplete is turned on for Forms the entries for each field in the HTML form should be cached and displayed as a prompt when the user starts entering content into the form the second time around.
On my website the AutoComplete feature is never displayed for any forms that exist on that site... | I have determined that the problem is related to the Cache-Headers PHP sends out when the start\_session() command is issued and the site is running SSL.
I have been able to get a hold of a person on the IE security team at Microsoft and they have confirmed that this is how IE is supposed to work. Here is a direct quo... |
364,101 | <pre><code>Imports System.Data.OleDb
Public Class Log
Private mConnectionString As String = "Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx)(PORT=1521)))(CONNECT_DATA=(SID=xxx)(SERVER=DEDICATED)));User Id=xxx;Password=xxx;"
Dim ds As New DataSet
... | [
{
"answer_id": 364119,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 0,
"selected": false,
"text": "<p>I'm pretty certain you have to install the Oracle provider in order for this to work. OleDb can easily connect to ... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1340/"
] | ```
Imports System.Data.OleDb
Public Class Log
Private mConnectionString As String = "Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx)(PORT=1521)))(CONNECT_DATA=(SID=xxx)(SERVER=DEDICATED)));User Id=xxx;Password=xxx;"
Dim ds As New DataSet
Dim ... | I've had fairly good luck with the [Oracle Instant Client](http://www.oracle.com/technology/tech/oci/instantclient/index.html) and [ODP.NET](http://www.oracle.com/technology/tech/windows/odpnet/index.html), which is pretty much a straight XCOPY deploy (if you don't need ODBC).
IIRC, you do need to modify the PATH envi... |
364,105 | <p>I'm trying to use grep with -v for invert-match along with -e for regular expression. I'm having trouble getting the syntax right. </p>
<p>I'm trying something like</p>
<pre><code>tail -f logFile | grep -ve "string one|string two"
</code></pre>
<p>If I do it this way it doesn't filter
If I change it to</p>
<pre... | [
{
"answer_id": 364113,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 8,
"selected": true,
"text": "<p>The problem is that by default, you need to escape your |'s to get proper alternation. That is, grep interprets \... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16584/"
] | I'm trying to use grep with -v for invert-match along with -e for regular expression. I'm having trouble getting the syntax right.
I'm trying something like
```
tail -f logFile | grep -ve "string one|string two"
```
If I do it this way it doesn't filter
If I change it to
```
tail -f logFile | grep -ev "string one... | The problem is that by default, you need to escape your |'s to get proper alternation. That is, grep interprets "foo|bar" as matching the literal string "foo|bar" only, whereas the pattern "foo\|bar" (with an escaped |) matches either "foo" or "bar".
To change this behavior, use the -E flag:
```
tail -f logFile | gre... |
364,114 | <p>Maven 2 is driving me crazy during the experimentation / quick and dirty mock-up phase of development.</p>
<p>I have a <code>pom.xml</code> file that defines the dependencies for the web-app framework I want to use, and I can quickly generate starter projects from that file. However, sometimes I want to link to a 3r... | [
{
"answer_id": 364139,
"author": "javamonkey79",
"author_id": 27657,
"author_profile": "https://Stackoverflow.com/users/27657",
"pm_score": 0,
"selected": false,
"text": "<p>This doesn't answer how to add them to your POM, and may be a no brainer, but would just adding the lib dir to you... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Maven 2 is driving me crazy during the experimentation / quick and dirty mock-up phase of development.
I have a `pom.xml` file that defines the dependencies for the web-app framework I want to use, and I can quickly generate starter projects from that file. However, sometimes I want to link to a 3rd party library that... | **For throw away code only**
set scope == system and just make up a groupId, artifactId, and version
```xml
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swingx</artifactId>
<version>0.9.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/swingx-0.9.3.jar</systemPath>
... |
364,141 | <p>If I have, say, a table of films which amongs other things has a int FilmTypeId field and a table of film types, with the id and a meaningful description along the lines of:</p>
<ul>
<li>1 - horror</li>
<li>2 - comedy</li>
<li>...</li>
</ul>
<p>Whats the best way of using that information in a C# class?</p>
<p>cu... | [
{
"answer_id": 364154,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>Is the list of types fixed or does it change?</p>\n\n<p>If fixed, I would encapsulate it in an enum:</p>\n\n<pre><c... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39643/"
] | If I have, say, a table of films which amongs other things has a int FilmTypeId field and a table of film types, with the id and a meaningful description along the lines of:
* 1 - horror
* 2 - comedy
* ...
Whats the best way of using that information in a C# class?
currently I would have them as Constants in a helpe... | Is the list of types fixed or does it change?
If fixed, I would encapsulate it in an enum:
```
public enum FilmType {
Horror = 1,
Comedy = 2
}
```
Then just cast. You can use attributes (and a few lines of bespoke code) to store an extra description per enum item.
If the list changes I would probably read it... |
364,148 | <p>I'm trying to use the Kowalski graph algorithm for resolution theorem
proving. The description of the algorithm at
<a href="http://www.doc.ic.ac.uk/~rak/" rel="nofollow noreferrer">http://www.doc.ic.ac.uk/~rak/</a> is silent on what to do about the large
number of duplicate clauses it generates. I'm wondering if the... | [
{
"answer_id": 364154,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>Is the list of types fixed or does it change?</p>\n\n<p>If fixed, I would encapsulate it in an enum:</p>\n\n<pre><c... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45843/"
] | I'm trying to use the Kowalski graph algorithm for resolution theorem
proving. The description of the algorithm at
<http://www.doc.ic.ac.uk/~rak/> is silent on what to do about the large
number of duplicate clauses it generates. I'm wondering if there's a
well-known technique for dealing with them?
In particular, you ... | Is the list of types fixed or does it change?
If fixed, I would encapsulate it in an enum:
```
public enum FilmType {
Horror = 1,
Comedy = 2
}
```
Then just cast. You can use attributes (and a few lines of bespoke code) to store an extra description per enum item.
If the list changes I would probably read it... |
364,159 | <p>I have a table with 3 columns. I want to write a formula that, given a structured reference, returns the index of the column. This will help me write VLookup formulas using the structured reference.</p>
<p>So, for example, for the table <code>MyTable</code> with columns <code>A</code>, <code>B</code>, <code>C</code... | [
{
"answer_id": 364264,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 0,
"selected": false,
"text": "<p>You could use: <code>=COLUMN(MyTable[<code>*</code>]) - COLUMN(MyTable[A]) + 1</code>, where <code>*</code> is the colu... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946/"
] | I have a table with 3 columns. I want to write a formula that, given a structured reference, returns the index of the column. This will help me write VLookup formulas using the structured reference.
So, for example, for the table `MyTable` with columns `A`, `B`, `C` I'd like to be able to write:
```
=GetIndex(MyTable... | A suitable formula based on your example would be
```
=COLUMN(MyTable[C])-COLUMN(MyTable)+1
```
The first part of the forumla `COLUMN(MyTable[C])` will return the column number of the referenced column.
The second part of the formula *COLUMN(MyTable)* will always return the column number of the first column of the ... |
364,172 | <p>I decided to use the GC for memory management for my latest Cocoa project, and I discovered something interesting--if I create a brand new Cocoa app project in Xcode, turn GC to supported or required (I tried both), build, and run it it leaks, it shows memory leaks!</p>
<p>Mostly large numbers of tiny leaks of obje... | [
{
"answer_id": 364217,
"author": "Ashley Clark",
"author_id": 4556,
"author_profile": "https://Stackoverflow.com/users/4556",
"pm_score": 1,
"selected": false,
"text": "<p>Those log messages are telling you that the Inquisitor.bundle and the SaftLoader.bundle are not built to run under G... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | I decided to use the GC for memory management for my latest Cocoa project, and I discovered something interesting--if I create a brand new Cocoa app project in Xcode, turn GC to supported or required (I tried both), build, and run it it leaks, it shows memory leaks!
Mostly large numbers of tiny leaks of objects of typ... | The `leaks` tool isn't accurate under Objective-C garbage collection in Leopard, because it doesn't know enough about the runtime structures of the garbage collector to actually determine what objects are still extant but ready to be reclaimed.
Also, you're a bit mistaken in your interpretation of the results of `leak... |
364,178 | <p>I have ANOTHER serialization question, but this time it is in regards to Java's native serialization import when serializing to binary. I have to serialize a random tree that is generated in another java file. I know how serialization and deserialization works, but the example I followed when using binary serializ... | [
{
"answer_id": 364190,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 2,
"selected": false,
"text": "<p>At a guess, GeneralTree doesn't implement the <a href=\"http://java.sun.com/javase/6/docs/api/java/io/Serializable.ht... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36268/"
] | I have ANOTHER serialization question, but this time it is in regards to Java's native serialization import when serializing to binary. I have to serialize a random tree that is generated in another java file. I know how serialization and deserialization works, but the example I followed when using binary serialization... | At a guess, GeneralTree doesn't implement the [Serializable](http://java.sun.com/javase/6/docs/api/java/io/Serializable.html) marker interface, as documented [here](http://java.sun.com/javase/6/docs/api/java/io/ObjectOutputStream.html#writeObject(java.lang.Object)).
Actually, it could also be the objects you're storin... |
364,184 | <p>In my Delphi7 this code</p>
<pre><code>var MStr: TMemoryStream;
...
FreeAndNil(MStr);
MStr.Size:=0;
</code></pre>
<p>generates an AV: Access violation at address 0041D6D1 in module 'Project1.exe'. Read of address 00000000.
But somebody insists that it should not raise any exception, no matter what. He also says t... | [
{
"answer_id": 364226,
"author": "Scott W",
"author_id": 3032,
"author_profile": "https://Stackoverflow.com/users/3032",
"pm_score": 3,
"selected": false,
"text": "<p>From what I am seeing, this code should always result in an error. FreeAndNil explicitly sets that passed value to Nil (... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In my Delphi7 this code
```
var MStr: TMemoryStream;
...
FreeAndNil(MStr);
MStr.Size:=0;
```
generates an AV: Access violation at address 0041D6D1 in module 'Project1.exe'. Read of address 00000000.
But somebody insists that it should not raise any exception, no matter what. He also says that his Delphi 5 indeed ra... | It's always wrong to use methods or properties of a null reference, even if it appears to work sometimes.
`FreeAndNil` indeed cannot be used to detect double frees. It is safe to call `FreeAndNil` on an already-nil variable. Since it's safe, it doesn't help you detect anything.
This is not a stale-pointer bug. This i... |
364,193 | <p>Erm - what the question said. It's something I keep hearing about, but I've not got round to looking into it yet.</p>
<hr>
<p>(updated) I could look up the definition... but why not (as pointed out by @erikson) get insight into your real experiences and anecdotes. Community Wiki'd incase that helps folks vote up t... | [
{
"answer_id": 364202,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Yes! You could look it up!</p>\n\n<p><a href=\"http://en.wikipedia.org/wiki/Finite_state_machine\" rel=\"nofollow noreferre... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2362/"
] | Erm - what the question said. It's something I keep hearing about, but I've not got round to looking into it yet.
---
(updated) I could look up the definition... but why not (as pointed out by @erikson) get insight into your real experiences and anecdotes. Community Wiki'd incase that helps folks vote up the most ins... | Short answer, it is a technique that you can use to express systems with concrete states (as opposed to quantum states / probability distributions).
Quoting the [Wikipedia article](http://en.wikipedia.org/wiki/Finite_state_machine):
>
> A finite state machine (FSM) or finite
> state automaton (plural: automata) or
... |
364,194 | <p>We currently have an application that works with Outlook 2003. In order to get the owner of a shared contact folder, we simply call:
Redemption.RDOSessionClass.GetFolderFromID() and then took that folder and got the RDOFolder.Store.Name property.</p>
<p>However, when trying this with a shared contact folder in Outl... | [
{
"answer_id": 364202,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Yes! You could look it up!</p>\n\n<p><a href=\"http://en.wikipedia.org/wiki/Finite_state_machine\" rel=\"nofollow noreferre... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32518/"
] | We currently have an application that works with Outlook 2003. In order to get the owner of a shared contact folder, we simply call:
Redemption.RDOSessionClass.GetFolderFromID() and then took that folder and got the RDOFolder.Store.Name property.
However, when trying this with a shared contact folder in Outlook 2007, ... | Short answer, it is a technique that you can use to express systems with concrete states (as opposed to quantum states / probability distributions).
Quoting the [Wikipedia article](http://en.wikipedia.org/wiki/Finite_state_machine):
>
> A finite state machine (FSM) or finite
> state automaton (plural: automata) or
... |
364,209 | <p>I have a function called:</p>
<pre><code>void initializeJSP(string Experiment)
</code></pre>
<p>And in my MyJSP.h file I have:</p>
<pre><code>2: void initializeJSP(string Experiment);
</code></pre>
<p>And when I compile I get this error:</p>
<blockquote>
<p>MyJSP.h:2 error: variable or field initializeJSP dec... | [
{
"answer_id": 364224,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 7,
"selected": true,
"text": "<p>It for example happens in this case here:</p>\n\n<pre><code>void initializeJSP(unknownType Experiment);\n... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39160/"
] | I have a function called:
```
void initializeJSP(string Experiment)
```
And in my MyJSP.h file I have:
```
2: void initializeJSP(string Experiment);
```
And when I compile I get this error:
>
> MyJSP.h:2 error: variable or field initializeJSP declared void
>
>
>
Where is the problem? | It for example happens in this case here:
```
void initializeJSP(unknownType Experiment);
```
Try using `std::string` instead of just `string` (and include the `<string>` header). C++ Standard library classes are within the namespace `std::`. |
364,230 | <p>I have three tables. This query will write down the right answer (x-lines for btv.id_user with appropriate btv.cas and race.id_zavod</p>
<pre><code>SELECT `btv.id_user`, `btv.id_zavod`,`btv.cas`
FROM `btv`
JOIN `btu` ON `btv.id_user` = `btu.id_user`
JOIN `race` ON 'btv.id_zavod' = `race.id_zavod`
WHERE `race.type` ... | [
{
"answer_id": 364260,
"author": "user12861",
"author_id": 12861,
"author_profile": "https://Stackoverflow.com/users/12861",
"pm_score": 1,
"selected": false,
"text": "<p>The query you have written:</p>\n\n<pre><code>SELECT `btv.id_user`, `btv.id_zavod`, MIN( `btv.cas` )\nFROM `btv`\nJOI... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45846/"
] | I have three tables. This query will write down the right answer (x-lines for btv.id\_user with appropriate btv.cas and race.id\_zavod
```
SELECT `btv.id_user`, `btv.id_zavod`,`btv.cas`
FROM `btv`
JOIN `btu` ON `btv.id_user` = `btu.id_user`
JOIN `race` ON 'btv.id_zavod' = `race.id_zavod`
WHERE `race.type` = '8' AND `b... | When you use GROUP BY, the columns in the select-list must satisfy one of the following:
* Column is named in the GROUP BY (e.g. `btv.id_user` in your example)
* Column is inside an aggregate function (e.g. `MIN( btv.cas )` )
* Column is a *functional dependency* of the column(s) you named in the GROUP BY.
This is th... |
364,240 | <p>How do YOU reduce compile time, and linking time for VC++ projects (native C++)?</p>
<p>Please specify if each suggestion applies to debug, release, or both.</p>
| [
{
"answer_id": 364257,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 7,
"selected": true,
"text": "<p>It may sound obvious to you, but we try to use forward declarations as much as possible, even if it requi... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | How do YOU reduce compile time, and linking time for VC++ projects (native C++)?
Please specify if each suggestion applies to debug, release, or both. | It may sound obvious to you, but we try to use forward declarations as much as possible, even if it requires to write out long namespace names the type(s) is/are in:
```
// Forward declaration stuff
namespace plotter { namespace logic { class Plotter; } }
// Real stuff
namespace plotter {
namespace samples {
... |
364,253 | <p>How do I Deserialize this XML document:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<Cars>
<Car>
<StockNumber>1020</StockNumber>
<Make>Nissan</Make>
<Model>Sentra</Model>
</Car>
<Car>
<StockNumber>1010</StockN... | [
{
"answer_id": 364325,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 5,
"selected": false,
"text": "<p>See if this helps:</p>\n\n<pre><code>[Serializable()]\n[System.Xml.Serialization.XmlRootAttribute(\"Cars\", Namespa... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41508/"
] | How do I Deserialize this XML document:
```
<?xml version="1.0" encoding="utf-8"?>
<Cars>
<Car>
<StockNumber>1020</StockNumber>
<Make>Nissan</Make>
<Model>Sentra</Model>
</Car>
<Car>
<StockNumber>1010</StockNumber>
<Make>Toyota</Make>
<Model>Corolla</Model>
</Car>
<Car>
<StockNumb... | Here's a working version. I changed the `XmlElementAttribute` labels to `XmlElement` because in the xml the StockNumber, Make and Model values are elements, not attributes. Also I removed the `reader.ReadToEnd();` (that [function](http://msdn.microsoft.com/en-us/library/system.io.streamreader.readtoend.aspx) reads the ... |
364,292 | <p>I have a table for which I want to select top the 5 rows by some column A. I also want to have a 6th row titled 'Other' which sums the values in column A for all but the top 5 rows.</p>
<p>Is there an easy way to do this? I'm starting with:</p>
<pre><code>select top 5
columnB, columnA
from
someTable t
o... | [
{
"answer_id": 364310,
"author": "D'Arcy Rittich",
"author_id": 39430,
"author_profile": "https://Stackoverflow.com/users/39430",
"pm_score": 3,
"selected": true,
"text": "<p>Not tested, but try something like this:</p>\n\n<pre><code>select * from (\n select top 5 \n columnB, c... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34942/"
] | I have a table for which I want to select top the 5 rows by some column A. I also want to have a 6th row titled 'Other' which sums the values in column A for all but the top 5 rows.
Is there an easy way to do this? I'm starting with:
```
select top 5
columnB, columnA
from
someTable t
order by
columnA d... | Not tested, but try something like this:
```
select * from (
select top 5
columnB, columnA
from
someTable t
order by
columnA desc
union all
select
null, sum(columnA)
from
someTable t
where primaryKey not in (
select top 5
... |
364,301 | <p>I posted this message to the Solr mailing list, but I'm trying here too in case there's a Solr expert lurking around.</p>
<p>I am trying to use the regex fragmenter and am having a hard time getting the results I want. I am trying to get fragments that start on a word character and end on punctuation, but for some ... | [
{
"answer_id": 364342,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": true,
"text": "<p>Try:</p>\n\n<pre><code>\\w[^\\.!\\?]{400,600}[\\.!\\?]\n</code></pre>\n\n<p>You should not need the first square brackets aro... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45856/"
] | I posted this message to the Solr mailing list, but I'm trying here too in case there's a Solr expert lurking around.
I am trying to use the regex fragmenter and am having a hard time getting the results I want. I am trying to get fragments that start on a word character and end on punctuation, but for some reason the... | Try:
```
\w[^\.!\?]{400,600}[\.!\?]
```
You should not need the first square brackets around `\w`
And you should escape the final dot.
And I do not think `.*` just before another quantifier (`{400,600}`)is a good idea, hence the `.{400,600}`
Since `?` is a special character in regex, you should also escape it.
A... |
364,347 | <p>One example is described <strong><a href="http://sujitmanolikar.blogspot.com/2007/07/generic-statemanagedcollection.html" rel="nofollow noreferrer">here</a></strong>. But the author apparently forgot to include the code for download.</p>
<p>Another example is shown <strong><a href="http://blog.spontaneouspublicity... | [
{
"answer_id": 500077,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 2,
"selected": false,
"text": "<p>The <strong><a href=\"http://blog.spontaneouspublicity.com/post/2007/05/Child-Collections-in-AspNet-Custom-Controls.asp... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] | One example is described **[here](http://sujitmanolikar.blogspot.com/2007/07/generic-statemanagedcollection.html)**. But the author apparently forgot to include the code for download.
Another example is shown **[here](http://blog.spontaneouspublicity.com/child-collections-in-asp-net-custom-controls)**. However, this o... | DanHerbert got it. Darn, I spent hours on this too! In the process of trying to answer this question I came up with a simplified generic StateManagedCollection that inherits from the framework's built-in StateManagedCollection, based on the version [here](http://blog.spontaneouspublicity.com/post/2007/05/Child-Collecti... |
364,360 | <pre><code>test[_nObjectives].pool[j].feedbackCorrect =
oQuestions[j].getElementsByTagName("feedbackCorrect")[0].firstChild.data;
</code></pre>
<p>and the XML in this case contains this: </p>
<pre><code> <feedbackCorrect>
</feedbackCorrect>
</code></pre>
<p>When executing that line of code the follow... | [
{
"answer_id": 364366,
"author": "FallenAvatar",
"author_id": 36965,
"author_profile": "https://Stackoverflow.com/users/36965",
"pm_score": 1,
"selected": false,
"text": "<p>you are getting the error because</p>\n\n<pre><code>oQuestions[j].getElementsByTagName(\"feedbackCorrect\")[0]\n</... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
test[_nObjectives].pool[j].feedbackCorrect =
oQuestions[j].getElementsByTagName("feedbackCorrect")[0].firstChild.data;
```
and the XML in this case contains this:
```
<feedbackCorrect>
</feedbackCorrect>
```
When executing that line of code the following error occurs: Message: Object required
I don't ge... | you are getting the error because
```
oQuestions[j].getElementsByTagName("feedbackCorrect")[0]
```
is returning that tag, and the .firstChild is returning null, because it has no children...
Are you sure you dont want
```
oQuestions[j].getElementsByTagName("feedbackCorrect")[0].data
```
? |
364,412 | <p>In a previous life, I might have done something like this:</p>
<pre><code><a href="#" onclick="f(311);return false;">Click</a><br/>
<a href="#" onclick="f(412);return false;">Click</a><br/>
<a href="#" onclick="f(583);return false;">Click</a><br/>
<a href="#"... | [
{
"answer_id": 364418,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 2,
"selected": false,
"text": "<p>You could use an id attribute like \"clicker-123\" then parse out the number. I usually do that or use the 'rel' att... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3420/"
] | In a previous life, I might have done something like this:
```
<a href="#" onclick="f(311);return false;">Click</a><br/>
<a href="#" onclick="f(412);return false;">Click</a><br/>
<a href="#" onclick="f(583);return false;">Click</a><br/>
<a href="#" onclick="f(624);return false;">Click</a><br/>
```
Now with jQuery, I... | [JQuery.data](http://docs.jquery.com/Core/data#name) lets you associate a dictionary to a DOM element. This data can be set via jQuery:
```
<a class="clicker">Click</a><br/>
<a class="clicker">Click</a><br/>
<a class="clicker">Click</a><br/>
<a class="clicker">Click</a><br/>
<script language="javascript" type="text/j... |
364,428 | <p>The project I am working on were are trying to come up with a solution for having the database and code be agile and be able to be built and deployed together.</p>
<p>Since the application is a combination of code plus the database schema, and database code tables, you can not truly have a full build of the applica... | [
{
"answer_id": 364449,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 1,
"selected": false,
"text": "<p>Make sure that your O/R-Mapping tool is able to build the necessary tables out of the default configuration it ha... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45365/"
] | The project I am working on were are trying to come up with a solution for having the database and code be agile and be able to be built and deployed together.
Since the application is a combination of code plus the database schema, and database code tables, you can not truly have a full build of the application unles... | You need a build process that constructs the database schema and adds any necessary bootstrapping data. If you're using an O/R tool that supports schema generation, most of that work is done for you. Whatever is not tool-generated, keep in scripts.
For continuous integration, ideally a "build" should include a complet... |
364,429 | <p>I've generated a certificate request, submitted it to the Microsoft Certificate Services program. It issues the certificate. I downloaded it to conf/ssl/server.cert</p>
<p>I configured it in apache to using </p>
<pre><code>SSLCertificateFile conf/ssl/server.cert
SSLCertificateKeyFile conf/ssl/server.key
</code></p... | [
{
"answer_id": 364480,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 3,
"selected": true,
"text": "<p>Sounds like your cert isn't allowed to be used for a server. IIRC, you can view the certificate in a browser and loo... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1310/"
] | I've generated a certificate request, submitted it to the Microsoft Certificate Services program. It issues the certificate. I downloaded it to conf/ssl/server.cert
I configured it in apache to using
```
SSLCertificateFile conf/ssl/server.cert
SSLCertificateKeyFile conf/ssl/server.key
```
When I start the server w... | Sounds like your cert isn't allowed to be used for a server. IIRC, you can view the certificate in a browser and look for Usage or some such language, and it should say SSL Server (possibly among other things). |
364,448 | <p>Does anyone know how to show a asp:TreeView always expanded to the leaves? So if I have a 2-level tree, I want it to be expanded at all times. Is there a property on TreeView that does this or could you show the code snippet on how to do this?</p>
<p>Thank you very much!
Ray.</p>
| [
{
"answer_id": 364487,
"author": "maxnk",
"author_id": 45862,
"author_profile": "https://Stackoverflow.com/users/45862",
"pm_score": 3,
"selected": true,
"text": "<p>aspx.cs:</p>\n\n<pre><code>protected void Page_Load(object sender, EventArgs e)\n{\n TreeView1.ExpandAll();\n}\n</code>... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32240/"
] | Does anyone know how to show a asp:TreeView always expanded to the leaves? So if I have a 2-level tree, I want it to be expanded at all times. Is there a property on TreeView that does this or could you show the code snippet on how to do this?
Thank you very much!
Ray. | aspx.cs:
```
protected void Page_Load(object sender, EventArgs e)
{
TreeView1.ExpandAll();
}
```
if you also want to disable expand-collapse symbols in the tree:
```
<asp:TreeView ID="TreeView1" runat="server" ShowExpandCollapse="false">
</asp:TreeView>
``` |
364,454 | <p>When running FindBugs on my project, I got a few instances of the error described above.</p>
<p>Namely, my overriding versions of equals cast the RHS object into the same type as the object in which the overriding version is defined.</p>
<p>However, I'm not sure whether a better design is possible, since AFAIK Jav... | [
{
"answer_id": 364464,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 7,
"selected": true,
"text": "<p>Typically, when implementing equals you can check to see whether the class of the argument is equal (or compatible) to the... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23072/"
] | When running FindBugs on my project, I got a few instances of the error described above.
Namely, my overriding versions of equals cast the RHS object into the same type as the object in which the overriding version is defined.
However, I'm not sure whether a better design is possible, since AFAIK Java does not allow ... | Typically, when implementing equals you can check to see whether the class of the argument is equal (or compatible) to the implementing class before casting it. Something like this:
```
if (getClass() != obj.getClass())
return false;
MyObj myObj = (MyObj) obj;
```
Doing it this way will prevent the FindBugs warn... |
364,472 | <p>Is there an easy or straightforward way in Java to output the results of a DB Query to a file (either csv, tab, etc). Perhaps even in Hibernate?</p>
<p>I know that a query results can be dumped to a flat file on the DB Server. I am looking for a way that an application can run a query and get those results into a... | [
{
"answer_id": 364489,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 0,
"selected": false,
"text": "<p>I seem to remember IntelliJ's JDBC db explorer having the ability to export the results of queries. I wouldn't be surpris... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there an easy or straightforward way in Java to output the results of a DB Query to a file (either csv, tab, etc). Perhaps even in Hibernate?
I know that a query results can be dumped to a flat file on the DB Server. I am looking for a way that an application can run a query and get those results into a file.
I re... | You can change the EntityMode of your Session to "DOM4J" so that Hibernate will return the data represented as an XML document instead of a POJO graph.
```
xmlSession = session.getSession(EntityMode.DOM4J);
Element elem = (Element) xmlSession.load(SomePersistentClass.class, id);
System.out.println(elem.asXML());
```
... |
364,483 | <p>Can the alignment of a structure type be found if the alignments of the structure members are known? </p>
<p>Eg. for:</p>
<pre><code>struct S
{
a_t a;
b_t b;
c_t c[];
};
</code></pre>
<p>is the alignment of S = max(alignment_of(a), alignment_of(b), alignment_of(c))?</p>
<p>Searching the internet I found that ... | [
{
"answer_id": 364490,
"author": "gnud",
"author_id": 27204,
"author_profile": "https://Stackoverflow.com/users/27204",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think memory layout is guaranteed in any way in any C standard. This is very much vendor and architect-dependent. ... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45875/"
] | Can the alignment of a structure type be found if the alignments of the structure members are known?
Eg. for:
```
struct S
{
a_t a;
b_t b;
c_t c[];
};
```
is the alignment of S = max(alignment\_of(a), alignment\_of(b), alignment\_of(c))?
Searching the internet I found that "for structured types the largest ali... | There are two closely related concepts to here:
1. The alignment required by the processor to access a particular object
2. The alignment that the compiler actually uses to place objects in memory
To ensure alignment requirements for structure members, the alignment of a structure must be at least as strict as the a... |
364,501 | <p>We've got a few pages in our web systems that use the .net system.net.mail control to send emails. The thing has been working great, except it's now starting to look like the smptclient class may not actually be disconnecting from the server, such that the SMTP server leaves that connection open, and we ended up ma... | [
{
"answer_id": 364510,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 1,
"selected": false,
"text": "<p>Are you properly disposing of your MailMessage once it has been sent? I've never seen any indication that SmtpClie... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19074/"
] | We've got a few pages in our web systems that use the .net system.net.mail control to send emails. The thing has been working great, except it's now starting to look like the smptclient class may not actually be disconnecting from the server, such that the SMTP server leaves that connection open, and we ended up maxing... | The problem of emails not being sent right away with SmtpClient is because under some conditions, it does not send the SMTP command 'QUIT' when it should (i.e. it doesn't disconnect properly). I have used the following code to force a disconnect successfully in the past:
```
var smtp = new SmtpClient();
smtp.ServicePo... |
364,505 | <pre><code><% using (Html.BeginForm() { %>
<%=Html.DropDownList("TopItemsList", ViewData["ListData"], new { onchange="[???]" })%>
<% } %>
</code></pre>
<p>In the above example, what value should you set onchange to? Or, how do you get the correct form?</p>
<p>Is there any difference with Ajax.Be... | [
{
"answer_id": 364508,
"author": "maxnk",
"author_id": 45862,
"author_profile": "https://Stackoverflow.com/users/45862",
"pm_score": 7,
"selected": true,
"text": "<p>try this:</p>\n\n<pre><code><%=Html.DropDownList(\"TopItemsList\", ViewData[\"ListData\"], new { onchange=\"this.form.s... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
<% using (Html.BeginForm() { %>
<%=Html.DropDownList("TopItemsList", ViewData["ListData"], new { onchange="[???]" })%>
<% } %>
```
In the above example, what value should you set onchange to? Or, how do you get the correct form?
Is there any difference with Ajax.BeginFrom? | try this:
```
<%=Html.DropDownList("TopItemsList", ViewData["ListData"], new { onchange="this.form.submit();" })%>
```
Every form element in the has a "form" property that is pointed to the form that contains this element.
Yes, using "Html." and "Ajax." has a difference. Ajax. means that partial page update will be... |
364,519 | <p>There's an existing function that ends in the following, where <code>d</code> is a dictionary:</p>
<pre><code>return d.iteritems()
</code></pre>
<p>that returns an unsorted iterator for a given dictionary. I would like to return an iterator that goes through the items sorted <em>by key</em>. How do I do that?</p>
| [
{
"answer_id": 364521,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 6,
"selected": false,
"text": "<p>Use the <a href=\"http://pydoc.org/2.5.1/__builtin__.html#-sorted\" rel=\"noreferrer\"><code>sorted()</code></a> funct... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | There's an existing function that ends in the following, where `d` is a dictionary:
```
return d.iteritems()
```
that returns an unsorted iterator for a given dictionary. I would like to return an iterator that goes through the items sorted *by key*. How do I do that? | Haven't tested this very extensively, but works in Python 2.5.2.
```
>>> d = {"x":2, "h":15, "a":2222}
>>> it = iter(sorted(d.iteritems()))
>>> it.next()
('a', 2222)
>>> it.next()
('h', 15)
>>> it.next()
('x', 2)
>>>
```
If you are used to doing `for key, value in d.iteritems(): ...` instead of iterators, this will ... |
364,522 | <p>How do you correct use frame on a asp.net page, so I have a left frame and a right frame, when I click the links on the page presented in the left frame, it loads the according page in the right frame? On top of this, I need to have a master page on all the right frame's pages.</p>
<p>How do I do this? or is ther... | [
{
"answer_id": 364536,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 2,
"selected": false,
"text": "<p>Frames are generally frowned upon in modern web development for a few reasons (I won't get into them here). You're bett... | 2008/12/12 | [
"https://Stackoverflow.com/questions/364522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32240/"
] | How do you correct use frame on a asp.net page, so I have a left frame and a right frame, when I click the links on the page presented in the left frame, it loads the according page in the right frame? On top of this, I need to have a master page on all the right frame's pages.
How do I do this? or is there another wa... | Yup. Frames are evil. You shouldn't really use them.
They cause problems, but in a (very)few edge cases they can be useful and cheaper in terms of development time, they still show up in generated api documentation quite a lot.
But anyway, seeing as how you asked how to use them, here we go
First up, it depends o... |
364,540 | <p>I am currently playing around with the HybridSessionBuilder class found on Jeffrey Palermo's blog post:</p>
<p><a href="http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/" rel="noreferrer">http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-reposit... | [
{
"answer_id": 364591,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 3,
"selected": false,
"text": "<p>With ASP.Net MVC you want to make sure the life of the session is maintained during the Action method on your control... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] | I am currently playing around with the HybridSessionBuilder class found on Jeffrey Palermo's blog post:
<http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/>
Using this class, my repository looks like this:
```
public class UserRepository : IUserRepository
{
private... | You should not wrap your ISession in a using statement -- the point of passing the ISessionBuilder into the repository constructor (dependency injection) is that the calling code is responsible for controlling the life cycle of the ISession. By wrapping it in a using, Dispose() is called on the ISession and you won't b... |
364,558 | <p>It's been a while since I was in college and knew how to calculate a best fit line, but I find myself needing to. Suppose I have a set of points, and I want to find the line that is the best of those points.</p>
<p>What is the equation to determine a best fit line?
How would I do that with PHP?</p>
| [
{
"answer_id": 364563,
"author": "Svante",
"author_id": 31615,
"author_profile": "https://Stackoverflow.com/users/31615",
"pm_score": 0,
"selected": false,
"text": "<p>An often used approach is to iteratively minimize the sum of squared y-differences between your points and the fit funct... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12930/"
] | It's been a while since I was in college and knew how to calculate a best fit line, but I find myself needing to. Suppose I have a set of points, and I want to find the line that is the best of those points.
What is the equation to determine a best fit line?
How would I do that with PHP? | Of additional interest is probably how good of a fit the line is.
For that, use the Pearson correlation, here in a PHP function:
```
/**
* returns the pearson correlation coefficient (least squares best fit line)
*
* @param array $x array of all x vals
* @param array $y array of all y vals
*/
function pearson(a... |
364,564 | <p>I am writing a Cocoa application with Mono embedded. I want to run and see my debug output in Terminal. On the Cocoa side I am using <code>NSLog()</code>, and on the Mono side I am using <code>Debug.Write()</code>. I can see my debug output in Xcode's console, but not in Terminal. This is what I tried: </p>
<pr... | [
{
"answer_id": 364574,
"author": "Grant Limberg",
"author_id": 27314,
"author_profile": "https://Stackoverflow.com/users/27314",
"pm_score": 4,
"selected": false,
"text": "<p>Open Console.app in /Applications/Utilities. All NSLog output will be printed in the System log.</p>\n\n<p>Or, if... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45890/"
] | I am writing a Cocoa application with Mono embedded. I want to run and see my debug output in Terminal. On the Cocoa side I am using `NSLog()`, and on the Mono side I am using `Debug.Write()`. I can see my debug output in Xcode's console, but not in Terminal. This is what I tried:
```
$: open /path/build/Debug/MyPro... | Chris gave a good overview of how the Console works, but to specifically answer your question: If you want to see the results directly in your Terminal, you need to run the built product as a child of the Terminal, which means using something like
```
/path/debug/build/MyProgram.app/Contents/MacOS/MyProgram
```
to ... |
364,616 | <p>Per this page <a href="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx" rel="noreferrer">http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx</a>
"Top-down deletion" is an implementation of a red-black tree node removal that pro-actively balances a tree by pushing a ... | [
{
"answer_id": 365635,
"author": "mepcotterell",
"author_id": 43312,
"author_profile": "https://Stackoverflow.com/users/43312",
"pm_score": 2,
"selected": false,
"text": "<p>From what I gather: \"top-down deletion\" avoids traversing the same node in a path more than once during the oper... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20712/"
] | Per this page <http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx>
"Top-down deletion" is an implementation of a red-black tree node removal that pro-actively balances a tree by pushing a red node down through the tree so that the leaf node which is being removed is guaranteed to be red. Since ... | From what I gather: "top-down deletion" avoids traversing the same node in a path more than once during the operation. So, given the simple path from the root to a given node, if you're going to do some thing to a node that's in that path anyway, why not just do it on the way down? It avoids having to traverse over par... |
364,621 | <p>I am iterating over a list and I want to print out the index of the item if it meets a certain condition. How would I do this?</p>
<p>Example: </p>
<pre><code>testlist = [1,2,3,5,3,1,2,1,6]
for item in testlist:
if item == 1:
print position
</code></pre>
| [
{
"answer_id": 364638,
"author": "jakber",
"author_id": 29812,
"author_profile": "https://Stackoverflow.com/users/29812",
"pm_score": 3,
"selected": false,
"text": "<pre><code>for i in xrange(len(testlist)):\n if testlist[i] == 1:\n print i\n</code></pre>\n\n<p>xrange instead of rang... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44133/"
] | I am iterating over a list and I want to print out the index of the item if it meets a certain condition. How would I do this?
Example:
```
testlist = [1,2,3,5,3,1,2,1,6]
for item in testlist:
if item == 1:
print position
``` | Hmmm. There was an answer with a list comprehension here, but it's disappeared.
Here:
```
[i for i,x in enumerate(testlist) if x == 1]
```
Example:
```
>>> testlist
[1, 2, 3, 5, 3, 1, 2, 1, 6]
>>> [i for i,x in enumerate(testlist) if x == 1]
[0, 5, 7]
```
Update:
Okay, you want a generator expression, we'll ha... |
364,631 | <p>Given the following code snippet from inside a method; </p>
<pre><code>NSBezierPath * tempPath = [NSBezierPath bezierPathWithOvalInRect:pathRect];
[tempPath retain];
[path release];
[self setPath:tempPath];
</code></pre>
<p>Am I responsible for releasing <code>tempP... | [
{
"answer_id": 364647,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 1,
"selected": false,
"text": "<p>You don't need to release tempPath.</p>\n\n<p>You can also drop the <code>[tempPath retain]</code> and the <code>[p... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41880/"
] | Given the following code snippet from inside a method;
```
NSBezierPath * tempPath = [NSBezierPath bezierPathWithOvalInRect:pathRect];
[tempPath retain];
[path release];
[self setPath:tempPath];
```
Am I responsible for releasing `tempPath` or will it be done for me?
The setPat... | If `path` is the instance variable backing the `-setPath:` method then no, you absolutely should not be releasing it outside of your `-dealloc` method. You don't need to manually retain your `tempPath` object since you're using an accessor to save that object. Your accessors, `-setPath:` in this case, `-init` and `-dea... |
364,642 | <p>I want to know the basic principle used for WYSIWYG pages on the web. I started coding it and made it using a text area, but very soon I realized that I cannot add or show images or any HTML in the text area. So I made it using DIV, but I did not understand how I could make it editable.</p>
<p>So, in gist, <strong>... | [
{
"answer_id": 364651,
"author": "coobird",
"author_id": 17172,
"author_profile": "https://Stackoverflow.com/users/17172",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://tinymce.moxiecode.com/\" rel=\"nofollow noreferrer\">TinyMCE</a> is open-source, so you could take a l... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to know the basic principle used for WYSIWYG pages on the web. I started coding it and made it using a text area, but very soon I realized that I cannot add or show images or any HTML in the text area. So I made it using DIV, but I did not understand how I could make it editable.
So, in gist, **I want to know h... | There's the `contentEditable` flag that can be added to any element on a page to make it editable, eg.
```
<div contentEditable>I am editable!!!!</div>
```
Should work in all major browsers nowadays, and things like shortcuts keys (cmd/ctrl-b, etc) will Just Work.
Form submission can then be done by pulling innerHT... |
364,655 | <p>I'm trying to run Python scripts using Xcode's User Scripts menu.</p>
<p>The issue I'm having is that my usual os.sys.path (taken from ~/.profile) does not seem to be imported when running scripts from XCode the way it is when running them at the Terminal (or with IPython). All I get is the default path, which mean... | [
{
"answer_id": 364691,
"author": "Toby White",
"author_id": 45891,
"author_profile": "https://Stackoverflow.com/users/45891",
"pm_score": 1,
"selected": false,
"text": "<p>A quick but hackish way is to have a wrapper script for python.</p>\n\n<pre><code>cat > $HOME/bin/mypython <&l... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | I'm trying to run Python scripts using Xcode's User Scripts menu.
The issue I'm having is that my usual os.sys.path (taken from ~/.profile) does not seem to be imported when running scripts from XCode the way it is when running them at the Terminal (or with IPython). All I get is the default path, which means I can't ... | On the mac, environment variables in your .profile aren't visible to applications outside of the terminal.
If you want an environment variable (like PATH, PYTHONPATH, etc) to be available to xcode apps, you should add it to a new plist file that you create at ~/.MacOSX/environment.plist.
See the [EnvironmentVars](ht... |
364,664 | <p>I would like to restrict access to my <code>/admin</code> URL to internal IP addresses only. Anyone on the open Internet should not be able to login to my web site. Since I'm using Lighttpd my first thought was to use <code>mod_rewrite</code> to redirect any outside request for the <code>/admin</code> URL back to ... | [
{
"answer_id": 364991,
"author": "Patryk Kordylewski",
"author_id": 30927,
"author_profile": "https://Stackoverflow.com/users/30927",
"pm_score": 2,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>$HTTP[\"remoteip\"] == \"192.168.0.0/16\" {\n /* your rules here */\n}\n</code... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21512/"
] | I would like to restrict access to my `/admin` URL to internal IP addresses only. Anyone on the open Internet should not be able to login to my web site. Since I'm using Lighttpd my first thought was to use `mod_rewrite` to redirect any outside request for the `/admin` URL back to my home page, but I don't know much ab... | Try this:
```
$HTTP["remoteip"] == "192.168.0.0/16" {
/* your rules here */
}
```
Example from the [docs](http://redmine.lighttpd.net/wiki/lighttpd/Docs:Configuration):
```
# deny the access to www.example.org to all user which
# are not in the 10.0.0.0/8 network
$HTTP["host"] == "www.example.org" {
... |
364,671 | <p>I have a problem with a many-to-many relation in my tables, which is between an employee and instructor who work in a training centre. I cannot find the link between them, and I don't know how to get it. The employee fields are:</p>
<ul>
<li>employee no.</li>
<li>employee name</li>
<li>company name</li>
<li>departm... | [
{
"answer_id": 364677,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 3,
"selected": false,
"text": "<p>in a many-to-many relationship the relationships will be in a 3rd table, something like </p>\n\n<pre><code>table EmployeeIn... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a problem with a many-to-many relation in my tables, which is between an employee and instructor who work in a training centre. I cannot find the link between them, and I don't know how to get it. The employee fields are:
* employee no.
* employee name
* company name
* department job title
* business area
* mob... | in a many-to-many relationship the relationships will be in a 3rd table, something like
```
table EmployeeInstructor
EmployeeID
InstructorID
```
to find all the employees for a specific instructor, you'd use a join against all three tables. |
364,676 | <p>I have an array filled with values (twitter ids) and I would like to find the missing data between the lowest id and the highest id? Any care to share a simple function or idea on how to do this?</p>
<p>Also, I was wondering if I can do the same with mySQL? I have the key indexed. The table contains 250k rows right... | [
{
"answer_id": 364677,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 3,
"selected": false,
"text": "<p>in a many-to-many relationship the relationships will be in a 3rd table, something like </p>\n\n<pre><code>table EmployeeIn... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45530/"
] | I have an array filled with values (twitter ids) and I would like to find the missing data between the lowest id and the highest id? Any care to share a simple function or idea on how to do this?
Also, I was wondering if I can do the same with mySQL? I have the key indexed. The table contains 250k rows right now, so a... | in a many-to-many relationship the relationships will be in a 3rd table, something like
```
table EmployeeInstructor
EmployeeID
InstructorID
```
to find all the employees for a specific instructor, you'd use a join against all three tables. |
364,701 | <p>Here's my code:</p>
<pre><code><asp:TemplateField HeaderText="* License Setup Date">
<EditItemTemplate>
<asp:RequiredFieldValidator ID="LicenseSetupDateRequired"
ErrorMessage="License Setup Date can't be blank."
ValidationGroup="EditClientDetails"
Con... | [
{
"answer_id": 364725,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 0,
"selected": false,
"text": "<p>This really depends on who owns the AD, and who is going to be responsible for managing user accounts. If this AD is ... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22452/"
] | Here's my code:
```
<asp:TemplateField HeaderText="* License Setup Date">
<EditItemTemplate>
<asp:RequiredFieldValidator ID="LicenseSetupDateRequired"
ErrorMessage="License Setup Date can't be blank."
ValidationGroup="EditClientDetails"
ControlToValidate="BeginDate"
... | I don't think you should supply a Gui for active directory. Most organization that use active directory manage it with the standard active directory tools.
If you want to handle the case of small shops. Then make the groups internal to the application DB. You will still be able to use the active directory users. But t... |
364,730 | <p>Screenshot of the problem:</p>
<p><img src="https://i.stack.imgur.com/qutvW.jpg" alt="http://i36.tinypic.com/dfxdmd.jpg"></p>
<p>The yellow block is the logo and the blue box is the nav links (I have blanked them out). I would like to align the links at the bottom so they are stuck to the top of the body content (... | [
{
"answer_id": 364737,
"author": "John Dunagan",
"author_id": 28939,
"author_profile": "https://Stackoverflow.com/users/28939",
"pm_score": 0,
"selected": false,
"text": "<p>Bottom left? If so - start by setting <code>clear: both;</code> on your #nav block.</p>\n\n<p>Other than that, I d... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Screenshot of the problem:

The yellow block is the logo and the blue box is the nav links (I have blanked them out). I would like to align the links at the bottom so they are stuck to the top of the body content (white box). How would I do this... | Try this. Seems to work in Firefox/Mac
```
#header {
height: 42px;
}
#logo {
width: 253px;
height: 42px;
background: #00ffff;
float: left;
}
#nav {
width: 100%;
border-bottom: 2px solid #3edff2;
height: 42px;
}
#nav ul {
list-style-type: none;
margin: 0;
padding-top: 18px;
... |
364,731 | <p>I have this code that generates markets I want to be clickable with a pop up info window. </p>
<pre><code>for (i = 0; i < marker_array.length; i++) {
var point = new GLatLng(marker_array[i][0], marker_array[i][1]);
var marker = new GMarker(point, markerOptions);
GEvent.addListener(marker, "click", ... | [
{
"answer_id": 364760,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not quite sure if I follow, but are you saying that all popups have the same data in them?</p>\n\n<p>I think t... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30098/"
] | I have this code that generates markets I want to be clickable with a pop up info window.
```
for (i = 0; i < marker_array.length; i++) {
var point = new GLatLng(marker_array[i][0], marker_array[i][1]);
var marker = new GMarker(point, markerOptions);
GEvent.addListener(marker, "click", function() {
... | I believe your problem is that the variable html\_data is the same for all iterations of this loop. You should update that variable each go-through in the loop for the values to be different. |
364,757 | <p>I am restricted to C (cannot use C++). I wish C had stricter type checking.</p>
<p>Is there a way to get compile errors on the commented lines? If it helps, the enum values cannot overlap.</p>
<hr>
<pre><code>enum hundred {
VALUE_HUNDRED_A = 100,
VALUE_HUNDRED_B
};
enum thousand {
VALUE_THOUSAND_A = ... | [
{
"answer_id": 364767,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": -1,
"selected": false,
"text": "<p>I would argue that the problem isn't as much that C doesn't support strict type checking, as it's that it really doesn't s... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45908/"
] | I am restricted to C (cannot use C++). I wish C had stricter type checking.
Is there a way to get compile errors on the commented lines? If it helps, the enum values cannot overlap.
---
```
enum hundred {
VALUE_HUNDRED_A = 100,
VALUE_HUNDRED_B
};
enum thousand {
VALUE_THOUSAND_A = 1000,
VALUE_THOUSA... | In C, enum types are indistinguishable from integers. Very annoying.
The only way forward I can think of is a kludgy workaround using structs instead of enums. Structs are generative, so the hundreds and thousands are distinct. If the calling convention is sensible (AMD64) there will be no run-time overhead.
Here's a... |
364,788 | <p>Is there an easier way to achieve the following?</p>
<pre><code>var obj = from row in table.AsEnumerable()
select row["DOUBLEVALUE"];
double[] a = Array.ConvertAll<object, double>(obj.ToArray(), o => (double)o);
</code></pre>
<p>I'm extracting a column from a <code>DataTable</code> and storing ... | [
{
"answer_id": 374296,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 7,
"selected": true,
"text": "<p>I don't know about Artifactory but here are my reasons for using Nexus:</p>\n\n<ul>\n<li>Dead simple install (and ... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45914/"
] | Is there an easier way to achieve the following?
```
var obj = from row in table.AsEnumerable()
select row["DOUBLEVALUE"];
double[] a = Array.ConvertAll<object, double>(obj.ToArray(), o => (double)o);
```
I'm extracting a column from a `DataTable` and storing the column in an array of `double`s.
Assume t... | I don't know about Artifactory but here are my reasons for using Nexus:
* Dead simple install (and since 1.2, dead simple upgrade, too)
* Very good web UI
* Easy to maintain, almost no administrative overhead
* Provides you with RSS feeds of recently installed, broken artifacts and errors
* It can group several reposi... |
364,791 | <p>Consider the following HTML:</p>
<pre><code><div class="foo" id="obj">
I should be changed red
<div class="bar" style="color:black;">
I should not be changed red.
<div class="foo">I should be changed red.</div>
</div>
</div>
</code></pre>
<p>Given a DOM elem... | [
{
"answer_id": 364798,
"author": "rz.",
"author_id": 7407,
"author_profile": "https://Stackoverflow.com/users/7407",
"pm_score": -1,
"selected": false,
"text": "<pre><code> $('div.foo, div.foo > *').css('color','red');\n</code></pre>\n\n<p>The main idea is that you can separate differ... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43005/"
] | Consider the following HTML:
```
<div class="foo" id="obj">
I should be changed red
<div class="bar" style="color:black;">
I should not be changed red.
<div class="foo">I should be changed red.</div>
</div>
</div>
```
Given a DOM element `obj` and an expression, how do I go about selecting any c... | If I understand you correctly:
```
$(currentDiv).contents().addBack('.foo').css('color','red');
```
I renamed the "div" to "currentDiv" for clarity. This selects the current element and all of the elements it contains, then filters out the ones that do not have class `foo` and applies the style to the remainder, i.e... |
364,802 | <p>What does generator comprehension do? How does it work? I couldn't find a tutorial about it.</p>
| [
{
"answer_id": 364816,
"author": "rz.",
"author_id": 7407,
"author_profile": "https://Stackoverflow.com/users/7407",
"pm_score": 5,
"selected": false,
"text": "<p>A generator comprehension is the lazy version of a list comprehension.</p>\n\n<p>It is just like a list comprehension except ... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44354/"
] | What does generator comprehension do? How does it work? I couldn't find a tutorial about it. | Do you understand list comprehensions? If so, a generator expression is like a list comprehension, but instead of finding all the items you're interested and packing them into list, it waits, and yields each item out of the expression, one by one.
```
>>> my_list = [1, 3, 5, 9, 2, 6]
>>> filtered_list = [item for item... |
364,809 | <p>I want to gather data from different data servers located in Europe and Asia. Rather than running a plain data query task that will clog up the undersea network I am thinking of a couple of machines that will be available for me at the local sites.</p>
<p>I am thinking to design the master package so that I can:</p... | [
{
"answer_id": 365018,
"author": "Michael Entin",
"author_id": 19880,
"author_profile": "https://Stackoverflow.com/users/19880",
"pm_score": 0,
"selected": false,
"text": "<p>I probably would avoid creating a master package that does it for <strong>all</strong> locations. Instead, create... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30546/"
] | I want to gather data from different data servers located in Europe and Asia. Rather than running a plain data query task that will clog up the undersea network I am thinking of a couple of machines that will be available for me at the local sites.
I am thinking to design the master package so that I can:
1. run remo... | **Extraction over a slow or expensive WAN link**
I think what you describe sounds appropriate. For a slow or expensive WAN link you would want to reduce the amount of data transfer. Some approaches to this are:
* Changed data capture.
* Compression.
If you can easily identify new transactions or changed data at sour... |
364,825 | <p>I have a query to the effect of</p>
<pre><code>SELECT t3.id, a,bunch,of,other,stuff FROM t1, t2, t3
WHERE (associate t1,t2, and t3 with each other)
GROUP BY t3.id
LIMIT 10,20
</code></pre>
<p>I want to know to many total rows this query would return without the LIMIT (so I can show pagination information).</p>
... | [
{
"answer_id": 364833,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": false,
"text": "<p>You're using MySQL, so you can use their function to do exactly this.</p>\n\n<pre><code>SELECT SQL_CALC_FOUND_ROWS ... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36384/"
] | I have a query to the effect of
```
SELECT t3.id, a,bunch,of,other,stuff FROM t1, t2, t3
WHERE (associate t1,t2, and t3 with each other)
GROUP BY t3.id
LIMIT 10,20
```
I want to know to many total rows this query would return without the LIMIT (so I can show pagination information).
Normally, I would use this qu... | There is a nice solution in MySQL.
Add the keyword SQL\_CALC\_FOUND\_ROWS right after the keyword SELECT :
```
SELECT SQL_CALC_FOUND_ROWS t3.id, a,bunch,of,other,stuff FROM t1, t2, t3
WHERE (associate t1,t2, and t3 with each other)
GROUP BY t3.id
LIMIT 10,20
```
After that, run another query with the function F... |
364,832 | <p>So, I have the following rows in the DB:</p>
<p>1 | /users/</p>
<p>2 | /users/admin/</p>
<p>3 | /users/admin/*</p>
<p>4 | /users/admin/mike/</p>
<p>5 | /users/admin/steve/docs/</p>
<p>The input URL is <strong>/users/admin/steve/</strong>, and the goal is to find the URL match from the DB.</p>
<p>I want to ret... | [
{
"answer_id": 364839,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand this correctly, something like this should work: </p>\n\n<p>SELECT COALESCE( </p>\n\n<blockquote>\n <... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32881/"
] | So, I have the following rows in the DB:
1 | /users/
2 | /users/admin/
3 | /users/admin/\*
4 | /users/admin/mike/
5 | /users/admin/steve/docs/
The input URL is **/users/admin/steve/**, and the goal is to find the URL match from the DB.
I want to return #3 as the correct row, since the wildcard "\*" specifies tha... | Here's how I'd do it:
```
SELECT * FROM mytable AS m
WHERE <input-url> = m.urlpattern
OR <input-url> REGEXP REPLACE(m.urlpattern, '*', '.*');
```
The REPLACE() is to change the globbing-style wildcard into an equivalent regular-expression wildcard. |
364,842 | <p>I've got a Perl script that needs to execute another Perl script. This second script can be executed directly on the command line, but I need to execute it from within my first program. I'll need to pass it a few parameters that would normally be passed in when it's run standalone (the first script runs periodically... | [
{
"answer_id": 364858,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 3,
"selected": false,
"text": "<p>Use backticks if you need to capture the output of the command.</p>\n\n<p>Use <code>system</code> if you do no... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/774/"
] | I've got a Perl script that needs to execute another Perl script. This second script can be executed directly on the command line, but I need to execute it from within my first program. I'll need to pass it a few parameters that would normally be passed in when it's run standalone (the first script runs periodically, a... | The location of your current perl interpreter can be found in the special variable `$^X`. This is important if perl is not in your path, or if you have multiple perl versions available but which to make sure you're using the same one across the board.
When executing external commands, including other Perl programs, de... |
364,847 | <p>how to change connection string dynamically in object datasource in asp.net ?</p>
| [
{
"answer_id": 364850,
"author": "Tarik",
"author_id": 44852,
"author_profile": "https://Stackoverflow.com/users/44852",
"pm_score": 2,
"selected": false,
"text": "<pre><code>protected void ObjectDataSource1_ObjectCreated(object sender, ObjectDataSourceEventArgs e)\n{\n if (e.ObjectIn... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18709/"
] | how to change connection string dynamically in object datasource in asp.net ? | ```
protected void ObjectDataSource1_ObjectCreated(object sender, ObjectDataSourceEventArgs e)
{
if (e.ObjectInstance != null)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = MyConnectionManager.ConnectionString;
e.ObjectInstance.GetType().GetProperty("Connection").Se... |
364,925 | <p>Say I have a git repository and I've been working on master, can I retroactively create a branch. For example:</p>
<p>A - B - C - A1 - D - A2 - E</p>
<p>I want to make it look like this:</p>
<pre><code>A - A1 - A2
\ \
B - C - D - E
</code></pre>
<p>The specific use case is when I've cherry-picke... | [
{
"answer_id": 364998,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 3,
"selected": false,
"text": "<p>You can't do that transparently because the hashes will have to change, but you basically just need to branch HEAD and r... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9594/"
] | Say I have a git repository and I've been working on master, can I retroactively create a branch. For example:
A - B - C - A1 - D - A2 - E
I want to make it look like this:
```
A - A1 - A2
\ \
B - C - D - E
```
The specific use case is when I've cherry-picked a bunch of commits into an old version ... | Of course you can. (With Git there isn’t much than you can’t do anyway. :)
```
git checkout -b new-branch hash-of-A
git cherry-pick hash-of-A1
git cherry-pick hash-of-A2
```
This will create a new branch, starting from the commit `A`. Afterwards you go back to the same commit again, creating another branch:
```
git... |
364,941 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/225929/what-is-the-exact-problem-with-multiple-inheritance">What is the exact problem with multiple inheritance?</a> </p>
</blockquote>
<p>Why is multiple inheritance considered to be <em>evil</em> while implem... | [
{
"answer_id": 364944,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 2,
"selected": false,
"text": "<p>How do you reconcile if A implements a method called z and b implements a method called z and you have:</p>\n\n<p>chi... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45931/"
] | >
> **Possible Duplicate:**
>
> [What is the exact problem with multiple inheritance?](https://stackoverflow.com/questions/225929/what-is-the-exact-problem-with-multiple-inheritance)
>
>
>
Why is multiple inheritance considered to be *evil* while implementing multiple interfaces is not? Especially when once co... | The common problem with multiple inheritance is the "diamond problem".
```
A
/ \
B c
\ /
D
```
If a virtual method in A is implemented by both B and C, which one do you get when you create D?
The reason this isn't a problem with interfaces is because interfaces don't have implementations, so if A/B/C are al... |
364,946 | <p>I am giving link of a pdf file on my web page for download, like below</p>
<pre><code><a href="myfile.pdf">Download Brochure</a>
</code></pre>
<p>The problem is when user clicks on this link then</p>
<ul>
<li>If the user have installed Adobe Acrobat, then it opens the file in the same browser window i... | [
{
"answer_id": 364950,
"author": "TravisO",
"author_id": 35116,
"author_profile": "https://Stackoverflow.com/users/35116",
"pm_score": 8,
"selected": true,
"text": "<p>Instead of linking to the .PDF file, instead do something like </p>\n\n<pre><code><a href=\"pdf_server.php?file=pdffi... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45261/"
] | I am giving link of a pdf file on my web page for download, like below
```
<a href="myfile.pdf">Download Brochure</a>
```
The problem is when user clicks on this link then
* If the user have installed Adobe Acrobat, then it opens the file in the same browser window in Adobe Reader.
* If the Adobe Acrobat is not ins... | Instead of linking to the .PDF file, instead do something like
```
<a href="pdf_server.php?file=pdffilename">Download my eBook</a>
```
which outputs a custom header, opens the PDF (binary safe) and prints the data to the user's browser, then they can choose to save the PDF despite their browser settings. The pdf\_s... |
364,952 | <p>I would like to manipulate the HTML inside an iframe using jQuery.</p>
<p>I thought I'd be able to do this by setting the context of the jQuery function to be the document of the iframe, something like:</p>
<pre><code>$(function(){ //document ready
$('some selector', frames['nameOfMyIframe'].document).doStuff(... | [
{
"answer_id": 364983,
"author": "Khb",
"author_id": 37817,
"author_profile": "https://Stackoverflow.com/users/37817",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried the classic, waiting for the load to complete using jQuery's builtin ready function?</p>\n\n<pre><code>$(doc... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7407/"
] | I would like to manipulate the HTML inside an iframe using jQuery.
I thought I'd be able to do this by setting the context of the jQuery function to be the document of the iframe, something like:
```
$(function(){ //document ready
$('some selector', frames['nameOfMyIframe'].document).doStuff()
});
```
However t... | I think what you are doing is subject to the [same origin policy](http://en.wikipedia.org/wiki/Same_origin_policy). This should be the reason why you are getting *permission denied type* errors. |
364,959 | <p>Here I had build a HTML page with an <code>iFrame</code>. I had an id within the <code>iFrame</code> src page. Is it possible to access the id from my current page through JavaScript.</p>
<p>Please help me.</p>
| [
{
"answer_id": 364972,
"author": "Biswanath",
"author_id": 41968,
"author_profile": "https://Stackoverflow.com/users/41968",
"pm_score": 0,
"selected": false,
"text": "<p>This is a small example I put through,</p>\n\n<pre><code><title>Untitled Page</title>\n<script type=\"... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38172/"
] | Here I had build a HTML page with an `iFrame`. I had an id within the `iFrame` src page. Is it possible to access the id from my current page through JavaScript.
Please help me. | You must be careful if you are accessing an iframe's script from your parent page, to make sure that your iframe has already finished loading before requesting from it. Here is an example:
```
window.onload = function () {
document.getElementById('iframeId').onload = function () { //Attach an onload function to th... |
364,962 | <p>My application is already developed and now we are going to change the connection string whatever stored in the session object (Bcoz of Distributed Database Management System (DDBMS))</p>
<p>Problem is here.....</p>
<blockquote>
<pre><code>In that application There are so many **ObjectDataSource** which are
</code... | [
{
"answer_id": 404334,
"author": "sliderhouserules",
"author_id": 31385,
"author_profile": "https://Stackoverflow.com/users/31385",
"pm_score": 1,
"selected": false,
"text": "<p>This is one of the reasons I hate Typed Datasets, and is actually one of the short-comings of LinqToSQL as wel... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45934/"
] | My application is already developed and now we are going to change the connection string whatever stored in the session object (Bcoz of Distributed Database Management System (DDBMS))
Problem is here.....
>
>
> ```
> In that application There are so many **ObjectDataSource** which are
>
> ```
>
> initialize with ... | To change the connection of an XSD at runtime you'll need to set the ConnectionModifier property of the table adapter to Public. If they're created by the "wizard" they will be set to Friend/Internal (VB/C#) by default.
I had trouble finding the ConnectionModifier property (it's not listed in my vs2005 documentation)!... |
364,963 | <p>I have an a aspx page, but all content is generated by hands(yes I know that I need to make a handler, I have another question)</p>
<p>I want to cache output in client browser. Problem is that it's cached only for one query.</p>
<pre><code> public static void ProceedCaching(string etag, string lastModify, s... | [
{
"answer_id": 404334,
"author": "sliderhouserules",
"author_id": 31385,
"author_profile": "https://Stackoverflow.com/users/31385",
"pm_score": 1,
"selected": false,
"text": "<p>This is one of the reasons I hate Typed Datasets, and is actually one of the short-comings of LinqToSQL as wel... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41483/"
] | I have an a aspx page, but all content is generated by hands(yes I know that I need to make a handler, I have another question)
I want to cache output in client browser. Problem is that it's cached only for one query.
```
public static void ProceedCaching(string etag, string lastModify, string response, HttpR... | To change the connection of an XSD at runtime you'll need to set the ConnectionModifier property of the table adapter to Public. If they're created by the "wizard" they will be set to Friend/Internal (VB/C#) by default.
I had trouble finding the ConnectionModifier property (it's not listed in my vs2005 documentation)!... |
364,985 | <p>I need to find the smallest power of two that's greater or equal to a given value. So far, I have this:</p>
<pre><code>int value = 3221; // 3221 is just an example, could be any number
int result = 1;
while (result < value) result <<= 1;
</code></pre>
<p>It works fine, but feels kind of naive. Is there a... | [
{
"answer_id": 364993,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 4,
"selected": false,
"text": "<pre><code>ceil(log2(value))\n</code></pre>\n<p><code>ilog2()</code> can be calculated in 3 asm instructions e.g., <a href=\"htt... | 2008/12/13 | [
"https://Stackoverflow.com/questions/364985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38106/"
] | I need to find the smallest power of two that's greater or equal to a given value. So far, I have this:
```
int value = 3221; // 3221 is just an example, could be any number
int result = 1;
while (result < value) result <<= 1;
```
It works fine, but feels kind of naive. Is there a better algorithm for that problem?... | Here's my favorite. Other than the initial check for whether it's invalid (<0, which you could skip if you knew you'd only have >=0 numbers passed in), it has no loops or conditionals, and thus will outperform most other methods. This is similar to erickson's answer, but I think that my decrementing x at the beginning ... |
365,001 | <p>In the app I am working on, I want to allow the user to upload static HTML pages to replace the default "user profile" MVC View page. Is this possible? That is, the user uploaded html pages will totally run out of MVC, and it can include its own CSS links, etc.</p>
<p>Ideas? Suggestions?</p>
| [
{
"answer_id": 365032,
"author": "Ian",
"author_id": 4396,
"author_profile": "https://Stackoverflow.com/users/4396",
"pm_score": 5,
"selected": false,
"text": "<p>Obviously the .net MVC framework handles static content already for images / css / js etc. It would just be a matter of exte... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20067/"
] | In the app I am working on, I want to allow the user to upload static HTML pages to replace the default "user profile" MVC View page. Is this possible? That is, the user uploaded html pages will totally run out of MVC, and it can include its own CSS links, etc.
Ideas? Suggestions? | Obviously the .net MVC framework handles static content already for images / css / js etc. It would just be a matter of extending that (routing?) to pass .html files through straight to IIS. That coupled with a dash of rewriting to make prettier urls should do the trick.
However, I would be very, very wary of allowing... |
365,015 | <p>I'm using Windows XP and I want to know if the local area is available or not?</p>
<p>And if I'm using another OS would that affect on my code?</p>
| [
{
"answer_id": 368590,
"author": "Mick",
"author_id": 12458,
"author_profile": "https://Stackoverflow.com/users/12458",
"pm_score": -1,
"selected": false,
"text": "<p><a href=\"https://stackoverflow.com/questions/325872/detect-an-internet-connection-activation-with-delphi\">Here's how to... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42782/"
] | I'm using Windows XP and I want to know if the local area is available or not?
And if I'm using another OS would that affect on my code? | Use the following code
```
using System.Net.NetworkInformation; //(Add reference of System.Net.dll)
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
}
private void NetworkChan... |
365,028 | <p>I'm not a JS guy so I'm kinda stumbling around in the dark. Basically, I wanted something that would add a link to a twitter search for @replies to a particular user while on that person's page. </p>
<p>Two things I am trying to figure out:</p>
<ol>
<li>how to extract the user name from the page so that I can cons... | [
{
"answer_id": 365044,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 1,
"selected": false,
"text": "<p>Here is a way to do it, not really tested (no twitter account).</p>\n\n<pre><code>var userName = window.location.href.ma... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26366/"
] | I'm not a JS guy so I'm kinda stumbling around in the dark. Basically, I wanted something that would add a link to a twitter search for @replies to a particular user while on that person's page.
Two things I am trying to figure out:
1. how to extract the user name from the page so that I can construct the right URL.... | Here's a pure-DOM method of the above -- and for kicks, I played with the extraction of the username as well:
```
var menuNode = document.getElementById('tabMenu');
if (menuNode!=null)
{
// extract username from URL; matches /ev and /ev/favourites
var username = document.location.pathname.split("/")[1];
/... |
365,029 | <p>I was reading a book on templates and found the following piece of code:</p>
<pre><code>template <template <class> class CreationPolicy>
class WidgetManager : public CreationPolicy<Widget>
{
...
void DoSomething()
{
Gadget* pW = CreationPolicy<Gadget>().Create();
...
}
};
</code></pre>
<p>I... | [
{
"answer_id": 365035,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 4,
"selected": true,
"text": "<p>It means that <code>CreationPolicy</code> must also be a template, which accepts one type parameter. You can th... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39742/"
] | I was reading a book on templates and found the following piece of code:
```
template <template <class> class CreationPolicy>
class WidgetManager : public CreationPolicy<Widget>
{
...
void DoSomething()
{
Gadget* pW = CreationPolicy<Gadget>().Create();
...
}
};
```
I didn't get the nested templates specified for the... | It means that `CreationPolicy` must also be a template, which accepts one type parameter. You can think of it as a little like the template equivalent of function pointers, or callbacks.
As you can see in that example, `CreationPolicy` is used with an argument:
```
CreationPolicy<SomeType>
```
That wouldn't be poss... |
365,045 | <p>I have a database (NexusDB (supposedly SQL-92 compliant)) which contains and Item table, a Category table, and a many-to-many ItemCategory table, which is just a pair of keys. As you might expect, Items are assigned to multiple categories. </p>
<p>I am wanting to all the end user to select all items which are </p>... | [
{
"answer_id": 365053,
"author": "Tom",
"author_id": 13219,
"author_profile": "https://Stackoverflow.com/users/13219",
"pm_score": 3,
"selected": true,
"text": "<p>You could try with EXCEPT</p>\n\n<pre><code>SELECT ItemID FROM Table\nEXCEPT\nSELECT ItemID FROM Table\nWHERE\nCategoryID &l... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32303/"
] | I have a database (NexusDB (supposedly SQL-92 compliant)) which contains and Item table, a Category table, and a many-to-many ItemCategory table, which is just a pair of keys. As you might expect, Items are assigned to multiple categories.
I am wanting to all the end user to select all items which are
ItemID | Cate... | You could try with EXCEPT
```
SELECT ItemID FROM Table
EXCEPT
SELECT ItemID FROM Table
WHERE
CategoryID <> 12
``` |
365,071 | <p>I have a form in Axapta/Dynamics Ax (EmplTable) which has two data sources (EmplTable and HRMVirtualNetworkTable) where the second data source (HRMVirtualNetworkTable) is linked to the first on with "Delayed" link type.</p>
<p>Is there a way to set an filter on the records, based on the second data source, without ... | [
{
"answer_id": 396002,
"author": "AxCoder",
"author_id": 49486,
"author_profile": "https://Stackoverflow.com/users/49486",
"pm_score": 1,
"selected": false,
"text": "<p>You can do it programmaticaly by joining QueryBuildDataSource or by extended filter (Alt+F3, Right click on datasorce, ... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19808/"
] | I have a form in Axapta/Dynamics Ax (EmplTable) which has two data sources (EmplTable and HRMVirtualNetworkTable) where the second data source (HRMVirtualNetworkTable) is linked to the first on with "Delayed" link type.
Is there a way to set an filter on the records, based on the second data source, without having to ... | You could use "Outer join" instead of "Delayed" then change the join mode programmaticly when there is search for fields on HRMVirtualNetworkTable.
Add this method to class SysQuery:
```
static void updateJoinMode(QueryBuildDataSource qds)
{
Counter r;
if (qds)
{
qds.joinMode(JoinMode::OuterJoin);... |
365,086 | <p>How can I project the row number onto the linq query result set.</p>
<p>Instead of say:</p>
<p>field1, field2, field3</p>
<p>field1, field2, field3</p>
<p>I would like:</p>
<p>1, field1, field2, field3</p>
<p>2, field1, field2, field3</p>
<p>Here is my attempt at this:</p>
<pre><code>public List<ScoreWith... | [
{
"answer_id": 365127,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": false,
"text": "<p>Well, the easiest way would be to do it at the client side rather than the database side, and use the overload of Sel... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42818/"
] | How can I project the row number onto the linq query result set.
Instead of say:
field1, field2, field3
field1, field2, field3
I would like:
1, field1, field2, field3
2, field1, field2, field3
Here is my attempt at this:
```
public List<ScoreWithRank> GetHighScoresWithRank(string gameId, int count)
{
Guid g... | Well, the easiest way would be to do it at the client side rather than the database side, and use the overload of Select which provides an index as well:
```
public List<ScoreWithRank> GetHighScoresWithRank(string gameId, int count)
{
Guid guid = new Guid(gameId);
using (PPGEntities entities = new PPGEntities(... |
365,087 | <p>I m using a dropdown to display "Location" field of a table. I want to set first item of dropdowm as "-Select Location-". I can't set tables first record as "Select" because table is stroed in xml format. And table file is generated dynamicaly.
I am currentaly using as</p>
<pre><code> ddlLocationName.Dispose();
... | [
{
"answer_id": 365092,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 0,
"selected": false,
"text": "<p>Access the items in the form of ListItems:</p>\n\n<pre><code>ListItem li = new ListItem(\"Select Location\",\"-1\");\n... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43886/"
] | I m using a dropdown to display "Location" field of a table. I want to set first item of dropdowm as "-Select Location-". I can't set tables first record as "Select" because table is stroed in xml format. And table file is generated dynamicaly.
I am currentaly using as
```
ddlLocationName.Dispose();
ddlLocatio... | After you have databound, then call ddlLocationName.Items.Insert(0, "Select Location");
Example:
```
ddlLocationName.Items.Clear();
ddlLocationName.DataSource = _section.GetLocations();
ddlLocationName.DataBind();
ddlLocationName.Items.Insert(0, "Select Location"); // Adds the item in the first position
``` |
365,095 | <p>How do you make the authentication for a browser-based application dependent on the client machine? Say the admin can login only from <b>this</b> machine.</p>
<p>Assumptions: There is complete control over the network and all machines (client and server) involved.</p>
<p>I am looking for an apache/linux solution.<... | [
{
"answer_id": 365102,
"author": "The Archetypal Paul",
"author_id": 21755,
"author_profile": "https://Stackoverflow.com/users/21755",
"pm_score": 3,
"selected": true,
"text": "<p>You need to come up with some way of identifying <strong>this</strong> machine. What iis important in your a... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17404/"
] | How do you make the authentication for a browser-based application dependent on the client machine? Say the admin can login only from **this** machine.
Assumptions: There is complete control over the network and all machines (client and server) involved.
I am looking for an apache/linux solution. | You need to come up with some way of identifying **this** machine. What iis important in your application? Physical location? IP address?
If you have complete control over the machines I would use SSL with client certficates, and put the client certificate only on the machine that must be used. See [here](http://www.g... |
365,125 | <p>As part of a VBA program, I have to set the background colors of certain cells to green, yellow or red, based on their values (basically a health monitor where green is okay, yellow is borderline and red is dangerous).</p>
<p>I know how to set the values of those cells, but how do I set the background color.</p>
| [
{
"answer_id": 365131,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 7,
"selected": true,
"text": "<p>You can use either:</p>\n\n<pre><code>ActiveCell.Interior.ColorIndex = 28\n</code></pre>\n\n<p>or </p>\n\n<pre><co... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14860/"
] | As part of a VBA program, I have to set the background colors of certain cells to green, yellow or red, based on their values (basically a health monitor where green is okay, yellow is borderline and red is dangerous).
I know how to set the values of those cells, but how do I set the background color. | You can use either:
```
ActiveCell.Interior.ColorIndex = 28
```
or
```
ActiveCell.Interior.Color = RGB(255,0,0)
``` |
365,155 | <p>I want a simple tutorial to show me how to load a yaml file and parse the data. Expat style would be great but any solution that actually shows me the data in some form would be useful.</p>
<p>So far I ran multiple tests in the <code>yaml-0.1.1</code> source code for C and I either get an error, no output whatsoever... | [
{
"answer_id": 365230,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 3,
"selected": false,
"text": "<p>A Google Code Search (now defunct) for \"yaml load lang:c++\" gave this as the first link: <a href=\"https://github.com/wilhe... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want a simple tutorial to show me how to load a yaml file and parse the data. Expat style would be great but any solution that actually shows me the data in some form would be useful.
So far I ran multiple tests in the `yaml-0.1.1` source code for C and I either get an error, no output whatsoever, or in the `run-emi... | Try [yaml-cpp](https://github.com/jbeder/yaml-cpp) (as suggested by [this question](https://stackoverflow.com/questions/244784/yaml-serialization-library-for-c)) for a C++ parser.
Disclosure: I'm the author.
Example syntax (from the [Tutorial](https://github.com/jbeder/yaml-cpp/wiki/Tutorial)):
```
YAML::Node config... |
365,168 | <p>Since I kicked off the process of inserting 7M rows from one table into two others, I'm wondering now if there's a faster way to do this. The process is expected to finish in an hour, that's 24h of processing.</p>
<p>Here's how it goes:</p>
<p>The data from this table</p>
<pre><code>RAW (word VARCHAR2(4000), doc ... | [
{
"answer_id": 365226,
"author": "kdgregory",
"author_id": 42126,
"author_profile": "https://Stackoverflow.com/users/42126",
"pm_score": 2,
"selected": false,
"text": "<p>The first thing I'd recommend is to do a simple insert-select statement, and let the database handle all the data mov... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36942/"
] | Since I kicked off the process of inserting 7M rows from one table into two others, I'm wondering now if there's a faster way to do this. The process is expected to finish in an hour, that's 24h of processing.
Here's how it goes:
The data from this table
```
RAW (word VARCHAR2(4000), doc VARCHAR2(4000), count NUMBER... | The first thing I'd recommend is to do a simple insert-select statement, and let the database handle all the data movement. Not so useful if you're moving data between two machines, or if you don't have rollback segments large enough to handle the entire query.
The second thing I is to learn about the [addBatch()](htt... |
365,204 | <p>I am new to UserControls, and while developing my own control I found a problem with
showing events of my control in the property grid at design time.
If I have some events in my control I want to see them in Property grid and if I double-click that I want to have a handler, in the same way Microsoft does for its c... | [
{
"answer_id": 365216,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 3,
"selected": true,
"text": "<p>They should automatically appear if I'm not mistaken. Make sure you've built your project though, or changes won't propagate... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45648/"
] | I am new to UserControls, and while developing my own control I found a problem with
showing events of my control in the property grid at design time.
If I have some events in my control I want to see them in Property grid and if I double-click that I want to have a handler, in the same way Microsoft does for its cont... | They should automatically appear if I'm not mistaken. Make sure you've built your project though, or changes won't propagate to open designers. And make sure it's a **`public`** event too. (Private/protected events rightfully shouldn't show up because they're not accessible.)
One thing you can do to make your user's d... |
365,219 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/12249056/executing-sql-server-agent-job-from-a-stored-procedure-and-returning-job-result">Executing SQL Server Agent Job from a stored procedure and returning job result</a> </p>
</blockquote>
<p>Is there a way... | [
{
"answer_id": 365250,
"author": "gbn",
"author_id": 27535,
"author_profile": "https://Stackoverflow.com/users/27535",
"pm_score": 2,
"selected": false,
"text": "<p><code>XP_SQLAGENT_ENUM_JOBS</code> can be used but it undocumented.\nIt's normally used to detect long running jobs.</p>\n\... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1200558/"
] | >
> **Possible Duplicate:**
>
> [Executing SQL Server Agent Job from a stored procedure and returning job result](https://stackoverflow.com/questions/12249056/executing-sql-server-agent-job-from-a-stored-procedure-and-returning-job-result)
>
>
>
Is there a way to determine when a sql agent job as finished once... | This [article](http://blog.boxedbits.com/archives/124) describes an SP to launch a sql agent job and wait.
```
-- output from stored procedure xp_sqlagent_enum_jobs is captured in the following table
declare @xp_results TABLE ( job_id UNIQUEIDENTIFIER NOT NULL,
last_r... |
365,222 | <p>I have a base recipe class and I am using a datacontext. I overrode the insert method for the recipe in the datacontext and am trying to insert into its children. Nomatter what I do I cannot get the child to insert.Currently, just the recipe inserts and nothing happens with the child.</p>
<pre><code> partial voi... | [
{
"answer_id": 366876,
"author": "DamienG",
"author_id": 5720,
"author_profile": "https://Stackoverflow.com/users/5720",
"pm_score": 1,
"selected": false,
"text": "<p>The InsertX/UpdateX/DeleteX methods are called after LINQ to SQL has determined which objects will be included in SubmitC... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22521/"
] | I have a base recipe class and I am using a datacontext. I overrode the insert method for the recipe in the datacontext and am trying to insert into its children. Nomatter what I do I cannot get the child to insert.Currently, just the recipe inserts and nothing happens with the child.
```
partial void InsertRecipe... | I figured it out. Override SubmitChanges in the DataContext, and find all of the inserts and updates that are recipes. Run the algorithm to add children there.
```
public override void SubmitChanges(
System.Data.Linq.ConflictMode failureMode)
{
ChangeSet changes = this.GetChangeSet();
... |
365,223 | <p>Is there a way to programmatically disable usb storage devices from working while still keeping usb ports functional for other types of devices like keyboards and mice?</p>
| [
{
"answer_id": 365245,
"author": "PabloG",
"author_id": 394,
"author_profile": "https://Stackoverflow.com/users/394",
"pm_score": 4,
"selected": true,
"text": "<p>Taken from <a href=\"http://www.pragmaticutopia.com/content/view/89/125/\" rel=\"noreferrer\">here</a>, not tested:</p>\n\n<p... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41630/"
] | Is there a way to programmatically disable usb storage devices from working while still keeping usb ports functional for other types of devices like keyboards and mice? | Taken from [here](http://www.pragmaticutopia.com/content/view/89/125/), not tested:
```
Directions for Use:
1.) Take the following blue text, copy it, and paste it into a text document. Then, save it as USBSTOR.ADM.
CLASS MACHINE
CATEGORY "Custom Policies"
KEYNAME "SYSTEM\CurrentControlSet\Services\UsbStor"
POLI... |
365,224 | <p>Pour in your posts. I'll start with a couple, let us see how much we can collect.</p>
<p>To provide inline event handlers like</p>
<pre><code>button.Click += (sender,args) =>
{
};
</code></pre>
<p>To find items in a collection</p>
<pre><code> var dogs= animals.Where(animal => animal.Type == "dog");
</code>... | [
{
"answer_id": 365228,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 3,
"selected": true,
"text": "<p>Returning an custom object:</p>\n\n<pre><code>var dude = mySource.Select(x => new {Name = x.name, Surname = x.s... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45956/"
] | Pour in your posts. I'll start with a couple, let us see how much we can collect.
To provide inline event handlers like
```
button.Click += (sender,args) =>
{
};
```
To find items in a collection
```
var dogs= animals.Where(animal => animal.Type == "dog");
```
For iterating a collection, like
```
animals.ForE... | Returning an custom object:
```
var dude = mySource.Select(x => new {Name = x.name, Surname = x.surname});
``` |
365,249 | <p>when a System.Web.HttpResponse.End() is called a System.Thread.Abort is being fired, which i'm guessing is (or fires) an exception? I've got some logging and this is being listed in the log file...</p>
<p>A first chance </p>
<pre><code>exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.... | [
{
"answer_id": 365269,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": false,
"text": "<p>There is no such thing as a \"graceful\" abort. You could simply Flush() the response, though, instead of ending it... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | when a System.Web.HttpResponse.End() is called a System.Thread.Abort is being fired, which i'm guessing is (or fires) an exception? I've got some logging and this is being listed in the log file...
A first chance
```
exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
12/14/2008 01:09:... | Yes, this is indeed by design. Microsoft has even [documented](http://msdn.microsoft.com/lv-lv/library/system.web.httpresponse.end(en-us).aspx) it. How else would you stop the rest of your program from execution? |
365,284 | <p>When you rotate an image using canvas, it'll get cut off - how do I avoid this? I already made the canvas element bigger then the image, but it's still cutting off the edges.</p>
<p>Example:</p>
<pre><code><html>
<head>
<title>test</title>
<script type="text/javascrip... | [
{
"answer_id": 365292,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 4,
"selected": true,
"text": "<p>Rotation always occur around the current origin. So you might want to use translate first to translate the can... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45974/"
] | When you rotate an image using canvas, it'll get cut off - how do I avoid this? I already made the canvas element bigger then the image, but it's still cutting off the edges.
Example:
```
<html>
<head>
<title>test</title>
<script type="text/javascript">
function startup() {
... | Rotation always occur around the current origin. So you might want to use translate first to translate the canvas to the position around which you want to rotate (say the center) then rotate.
e.g.
```
ctx.translate(85, 85);
ctx.rotate(5 * Math.PI / 180);
```
The canvas now rotates around (85, 85). |
365,312 | <p>I have the following XML document:</p>
<pre><code><projects>
<project>
<name>Shockwave</name>
<language>Ruby</language>
<owner>Brian May</owner>
<state>New</state>
<startDate>31/10/2008 0:00:00</startDate>
</project&g... | [
{
"answer_id": 365338,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 7,
"selected": true,
"text": "<p>Found an XML transform stylesheet <a href=\"https://web.archive.org/web/20160624174014/http://wenzlaff.de/xmltocsv.htm... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7595/"
] | I have the following XML document:
```
<projects>
<project>
<name>Shockwave</name>
<language>Ruby</language>
<owner>Brian May</owner>
<state>New</state>
<startDate>31/10/2008 0:00:00</startDate>
</project>
<project>
<name>Other</name>
<language>Erlang</language>
<owner>Takashi Miik... | Found an XML transform stylesheet [here](https://web.archive.org/web/20160624174014/http://wenzlaff.de/xmltocsv.html) (wayback machine link, site itself is in german)
The stylesheet added here could be helpful:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="tex... |
365,339 | <p>We currently send an email notification in plain text or html format. Our environment is C#/.NET/SQL Server.</p>
<p>I'd like to know if anyone recommends a particular solution. I see two ways of doing this:</p>
<ul>
<li>dynamically convert current email to pdf using a third party library and sending the pdf as a... | [
{
"answer_id": 365341,
"author": "Joel Meador",
"author_id": 1976,
"author_profile": "https://Stackoverflow.com/users/1976",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://itextsharp.sourceforge.net/\" rel=\"nofollow noreferrer\">iText-Sharp</a><br>\nWorks very much like ... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36902/"
] | We currently send an email notification in plain text or html format. Our environment is C#/.NET/SQL Server.
I'd like to know if anyone recommends a particular solution. I see two ways of doing this:
* dynamically convert current email to pdf using a third party library and sending the pdf as an attachment
or
* us... | You can use [iTextSharp](http://itextsharp.sourceforge.net/) to convert your html pages to pdf. Here's an example:
```
class Program
{
static void Main(string[] args)
{
string html =
@"<html>
<head>
<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />
</head>
<body>
<p style="... |
365,352 | <p>It is not uncommon for me (or likely anyone else) to have a list of objects I need to iterate through and then interact with a list of properties. I use a nested loop, like this:</p>
<pre><code>IList<T> listOfObjects;
IList<TProperty> listOfProperties;
foreach (T dataObject in listOfObjects)
{
fore... | [
{
"answer_id": 365360,
"author": "Serge Wautier",
"author_id": 12379,
"author_profile": "https://Stackoverflow.com/users/12379",
"pm_score": 0,
"selected": false,
"text": "<p>In such a scenario, we often start by filtering the pieces we're interested in.\nyour block dosomethingclever() u... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/620435/"
] | It is not uncommon for me (or likely anyone else) to have a list of objects I need to iterate through and then interact with a list of properties. I use a nested loop, like this:
```
IList<T> listOfObjects;
IList<TProperty> listOfProperties;
foreach (T dataObject in listOfObjects)
{
foreach (TProperty property in... | Looks like you are trying to cartesian join two lists, and apply a where clause. Here's a simple example showing the Linq syntax for doing this, which I think is what you are looking for. list1 and list2 can be any IEnumerable, your where clause can contain more detailed logic, and in your select clause you can yank ou... |
365,353 | <ol>
<li>In WordPress, how do I hide a Page?</li>
<li>How do I then reimplement it as a DIV, let's say, on another Page?</li>
</ol>
<p><strong>Context</strong></p>
<p>I'm trying to get some year-end tax write-offs here for my freelance business, and so I'm donating WordPress sites to churches. Now, unfortunately I'm ... | [
{
"answer_id": 365545,
"author": "Sydius",
"author_id": 43496,
"author_profile": "https://Stackoverflow.com/users/43496",
"pm_score": 1,
"selected": false,
"text": "<p>I think the most logical way is to customize the theme. The theme system is sophisticated and could easily handle such ... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | 1. In WordPress, how do I hide a Page?
2. How do I then reimplement it as a DIV, let's say, on another Page?
**Context**
I'm trying to get some year-end tax write-offs here for my freelance business, and so I'm donating WordPress sites to churches. Now, unfortunately I'm finding that several pastors don't understand ... | *Someone named 'greyhoundcode' in another forum answered me, so I thought I'd post it here.*
*His response...*
If, for example, you have four pages:
1. Home
2. About
3. Sidebar
4. Contact
And you deliberately wish to exclude the Sidebar page from being part of the page navigation, you can exclude it like so:
```
w... |
365,354 | <p>So I have started playing around with FxCop lately and one thing I've noticed is it insists that any method attached to an event should be in the form</p>
<pre><code>void Callback(object sender, EventArgs args) { ...}
</code></pre>
<p>and to be attached with</p>
<pre><code>MyObject.Event += new EventHandler(Callb... | [
{
"answer_id": 365479,
"author": "technophile",
"author_id": 23029,
"author_profile": "https://Stackoverflow.com/users/23029",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think FxCop has been updated in a good long while now; have you tried it with the VS2008 Code Analysis tool... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | So I have started playing around with FxCop lately and one thing I've noticed is it insists that any method attached to an event should be in the form
```
void Callback(object sender, EventArgs args) { ...}
```
and to be attached with
```
MyObject.Event += new EventHandler(Callback);
```
Now that was all well and... | You should follow the convention.
1. Use the generic EventHandler<T>, where T is or derives from EventArgs. Hook up the event with
MyObject.SomeEvent += new EventHandler<EventArgs>(SomeMethod);
2. The event handler method should return void (makes no sense to return something to an event raiser), and the convention ... |
365,370 | <p>I am currently using TcpListener to address incoming connections, each of which are given a thread for handling the communication and then shutdown that single connection. Code looks as follows:</p>
<pre><code>TcpListener listener = new TcpListener(IPAddress.Any, Port);
System.Console.WriteLine("Server Initialized,... | [
{
"answer_id": 365390,
"author": "Paul",
"author_id": 41301,
"author_profile": "https://Stackoverflow.com/users/41301",
"pm_score": -1,
"selected": false,
"text": "<p>Probably best to use the asynchronous <a href=\"http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.be... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9479/"
] | I am currently using TcpListener to address incoming connections, each of which are given a thread for handling the communication and then shutdown that single connection. Code looks as follows:
```
TcpListener listener = new TcpListener(IPAddress.Any, Port);
System.Console.WriteLine("Server Initialized, listening for... | These are two quick fixes you can use, given the code and what I presume is your design:
1. Thread.Abort()
-----------------
If you have started this `TcpListener` thread from another, you can simply call `Abort()` on the thread, which will cause a `ThreadAbortException` within the blocking call and walk up the stack... |
365,371 | <p>I can't figure out how to achieve the following layout with CSS (probably because I don't actually know CSS).</p>
<p>I have a bunch of divs like this:</p>
<pre><code><div class="right"> <p>1</p> </div>
<div class="left"> <p>2</p> </div>
<div class="left"> <... | [
{
"answer_id": 365389,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>If you get rid of the clears it works fine. It looks like there's some overlap in the middle for whatever reason (rounding ... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4958/"
] | I can't figure out how to achieve the following layout with CSS (probably because I don't actually know CSS).
I have a bunch of divs like this:
```
<div class="right"> <p>1</p> </div>
<div class="left"> <p>2</p> </div>
<div class="left"> <p>3</p> </div>
<div class="left"> <p>4</p> </div>
<div class="right"> <p>5</... | You try to separate your input stream into two independent streams, and I don't think CSS allows you to do it. Using left and right floats is a clever idea, but it will not always work. [CSS spec](http://www.w3.org/TR/2006/WD-CSS21-20061106/visuren.html#float-position) says in 9.5.1 rule 5:
>
> The outer top of a flo... |
365,376 | <p>I use a basic Post to send data to a Django server.</p>
<p>The data consists of a base64 encoded 640*380 PNG image dynamically created by the flex
component.</p>
<pre><code><mx:HTTPService id="formSend" showBusyCursor="true"
useProxy="false" url="http://127.0.0.1/form/"
method="POST" result="formSentC... | [
{
"answer_id": 420041,
"author": "inferis",
"author_id": 51998,
"author_profile": "https://Stackoverflow.com/users/51998",
"pm_score": 1,
"selected": true,
"text": "<ol>\n<li><p>Probably, yes. It depends whether you impose a hard limit on the the file size and how the destination page ha... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32032/"
] | I use a basic Post to send data to a Django server.
The data consists of a base64 encoded 640\*380 PNG image dynamically created by the flex
component.
```
<mx:HTTPService id="formSend" showBusyCursor="true"
useProxy="false" url="http://127.0.0.1/form/"
method="POST" result="formSentConfirmation(event)" ... | 1. Probably, yes. It depends whether you impose a hard limit on the the file size and how the destination page handles the request.
2. I don't believe it's actually possible at the moment.
3. Read [this](http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=17_Ne... |
365,382 | <p>How do you rotate an image with the canvas html5 element from the bottom center angle?</p>
<pre><code><html>
<head>
<title>test</title>
<script type="text/javascript">
function startup() {
var canvas = document.getElementById('canvas');
... | [
{
"answer_id": 365418,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 6,
"selected": true,
"text": "<p>First you have to translate to the point around which you would like to rotate. In this case the image dimensi... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45974/"
] | How do you rotate an image with the canvas html5 element from the bottom center angle?
```
<html>
<head>
<title>test</title>
<script type="text/javascript">
function startup() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('... | First you have to translate to the point around which you would like to rotate. In this case the image dimensions are 64 x 120. To rotate around the bottom center you want to translate to 32, 120.
```
ctx.translate(32, 120);
```
That brings you to the bottom center of the image. Then rotate the canvas:
```
ctx.rota... |
365,391 | <p>I'm trying to use an excel VB macro to download excel files from a membership password-protected site. I am using the "InternetExplorer" object to open a browser window, log-in and browse to the correct page, then scanning for the links I want in the page. Using the Workbooks.Open(URLstring) doesn't work because Exc... | [
{
"answer_id": 365644,
"author": "Tmdean",
"author_id": 45084,
"author_profile": "https://Stackoverflow.com/users/45084",
"pm_score": 1,
"selected": false,
"text": "<p>There isn't really a way to do that with the Internet Explorer API. If it's just a throwaway script you can probably jus... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to use an excel VB macro to download excel files from a membership password-protected site. I am using the "InternetExplorer" object to open a browser window, log-in and browse to the correct page, then scanning for the links I want in the page. Using the Workbooks.Open(URLstring) doesn't work because Excel ... | There isn't really a way to do that with the Internet Explorer API. If it's just a throwaway script you can probably justify using SendKeys to yourself.
```
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
...
Sub YourMacro()
... Navigate IE to the correct document, and get it to pop
up the "Sa... |
365,395 | <p>just a quick question, if I have a matrix has n rows and m columns, how can I cut off the 4 sides of the matrix and return a new matrix? (the new matrix would have n-2 rows m-2 columns).</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 365399,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 5,
"selected": true,
"text": "<pre><code>a[1:-1, 1:-1]\n</code></pre>\n"
},
{
"answer_id": 365983,
"author": "jfs",
"author_id": 4279,
... | 2008/12/13 | [
"https://Stackoverflow.com/questions/365395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44354/"
] | just a quick question, if I have a matrix has n rows and m columns, how can I cut off the 4 sides of the matrix and return a new matrix? (the new matrix would have n-2 rows m-2 columns).
Thanks in advance | ```
a[1:-1, 1:-1]
``` |