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 |
|---|---|---|---|---|---|---|
265,750 | <p>I have a xml build of</p>
<pre><code><elig>
<subscriber code="1234"/>
<date to="12/30/2004"
from="12/31/2004"/>
<person name="bob"
ID="654321"/>
<dog type="labrador"
color="white"/>
<location name="hawaii"
islandCod... | [
{
"answer_id": 265828,
"author": "mkoeller",
"author_id": 33433,
"author_profile": "https://Stackoverflow.com/users/33433",
"pm_score": 1,
"selected": false,
"text": "<p>I modified one typo in your example XML:</p>\n\n<pre><code><elig>\n <subscriber code=\"1234\">\n <da... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16354/"
] | I have a xml build of
```
<elig>
<subscriber code="1234"/>
<date to="12/30/2004"
from="12/31/2004"/>
<person name="bob"
ID="654321"/>
<dog type="labrador"
color="white"/>
<location name="hawaii"
islandCode="01"/>
</subscriber>
</elig>
```
In XSL I ... | First of all your XML is still not well-formed and I actually cannot catch why you're looping over the `<date/>` tags - there is only one `<date/>` tag inside `<subscriber/>` (assuming that the first `<subscriber/>` should not be self-closed).
When using XPath you alway have to think about the context in which the XPa... |
265,761 | <p>In the iPhone 2.x firmware, can you make the iPhone vibrate for durations other than the system-defined:</p>
<pre><code>AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
</code></pre>
<p>In jailbroken phones, you used to be able to use the MeCCA.framework to do this:</p>
<p><a href="http://pastie.org/94481" r... | [
{
"answer_id": 266995,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 2,
"selected": false,
"text": "<p>There's no way to do this using the SDK, sorry.</p>\n"
},
{
"answer_id": 267015,
"author": "Can Berk Güd... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34463/"
] | In the iPhone 2.x firmware, can you make the iPhone vibrate for durations other than the system-defined:
```
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
```
In jailbroken phones, you used to be able to use the MeCCA.framework to do this:
<http://pastie.org/94481>
```
MeCCA_Vibrator *v = new MeCCA_Vibrato... | Yes, this is something that has caused AppStore rejections in the past, and probably will again...which means it is still possible to do it.
Answering my own question, here's how to do it:
Add framework CoreTelephony in Build Phases.
declare:
```
extern void * _CTServerConnectionCreate(CFAllocatorRef, int (*)(void... |
265,774 | <p>Consider the following code:</p>
<pre><code><a href="#label2">GoTo Label2</a>
... [content here] ...
<a name="label0"></a>More content
<a name="label1"></a>More content
<a name="label2"></a>More content
<a name="label3"></a>More content
<a name="label4"... | [
{
"answer_id": 265789,
"author": "mkoeller",
"author_id": 33433,
"author_profile": "https://Stackoverflow.com/users/33433",
"pm_score": 2,
"selected": false,
"text": "<p>I suppose this will work:</p>\n\n<pre><code>window.location=\"<yourCurrentUri>#label2\";\n</code></pre>\n"
},
... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | Consider the following code:
```
<a href="#label2">GoTo Label2</a>
... [content here] ...
<a name="label0"></a>More content
<a name="label1"></a>More content
<a name="label2"></a>More content
<a name="label3"></a>More content
<a name="label4"></a>More content
```
Is there a way to emulate clicking on the "GoTo Label... | This JS has generally worked well for me if you also put an ID on the element:
```
document.getElementById('MyID').scrollIntoView(true);
```
This is good as it will also position scrollable divs etc so that the content is visible. |
265,809 | <p>I'm scouring the internet for a definition of the term "Internal Node." I cannot find a succinct definition. Every source I'm looking at uses the term without defining it, and the usage doesn't yield a proper definition of what an internal node actually is.</p>
<p>Here are the two places I've been mainly l... | [
{
"answer_id": 265815,
"author": "Alphager",
"author_id": 21684,
"author_profile": "https://Stackoverflow.com/users/21684",
"pm_score": 4,
"selected": false,
"text": "<p>As far as i understand it, it is a node which is not a leaf.</p>\n"
},
{
"answer_id": 265823,
"author": "V... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29119/"
] | I'm scouring the internet for a definition of the term "Internal Node." I cannot find a succinct definition. Every source I'm looking at uses the term without defining it, and the usage doesn't yield a proper definition of what an internal node actually is.
Here are the two places I've been mainly looking:
[Link](http... | ```
I ROOT (root is also an INTERNAL NODE, unless it is leaf)
/ \
I I INTERNAL NODES
/ / \
o o o EXTERNAL NODES (or leaves)
```
As the wonderful picture shows, internal nodes are nodes located between the root of the tree and the leaves. Note that the root is also an interna... |
265,814 | <p>How can I create a regex for a string such as this:</p>
<pre><code><SERVER> <SERVERKEY> <COMMAND> <FOLDERPATH> <RETENTION> <TRANSFERMODE> <OUTPUTPATH> <LOGTO> <OPTIONAL-MAXSIZE> <OPTIONAL-OFFSET>
</code></pre>
<p>Most of these fields are just simple words... | [
{
"answer_id": 265839,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "<p>The problem is that because you're allowing spaces in filenames and using spaces to separate fields, the solution... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34395/"
] | How can I create a regex for a string such as this:
```
<SERVER> <SERVERKEY> <COMMAND> <FOLDERPATH> <RETENTION> <TRANSFERMODE> <OUTPUTPATH> <LOGTO> <OPTIONAL-MAXSIZE> <OPTIONAL-OFFSET>
```
Most of these fields are just simple words, but some of them can be paths, such as FOLDERPATH, OUTPUTPATH, these paths can also ... | Just splitting on whitespace is never going to work. But if you can make some assumptions on the data it could be made to work.
Some assumptions I had in mind:
* `SERVER`, `SERVERKEY` and `COMMAND` not containing any spaces: `\S+`
* `FOLDERPATH` beginning with a slash: `/.*?`
* `RETENTION` being a number: `\d+`
* `TR... |
265,849 | <p>That's it. It's a dumb dumb (embarrassing!) question, but I've never used C# before, only C++ and I can't seem to figure out how to access a Label on my main form from a secondary form and change the text. If anybody can let me know real quick what to do I'd be so grateful!</p>
<p>BTW, I should really clarify. Sorr... | [
{
"answer_id": 265867,
"author": "Aaron Smith",
"author_id": 12969,
"author_profile": "https://Stackoverflow.com/users/12969",
"pm_score": 0,
"selected": false,
"text": "<p>You have to have a reference to Form1 from Form2. Then you need either a method or a property on Form 1 visible t... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | That's it. It's a dumb dumb (embarrassing!) question, but I've never used C# before, only C++ and I can't seem to figure out how to access a Label on my main form from a secondary form and change the text. If anybody can let me know real quick what to do I'd be so grateful!
BTW, I should really clarify. Sorry: I've go... | You'll need a reference to the instance of Form1 - for example, if it's Form1 which is constructing Form2, you might pass `this` in as a constructor parameter.
Then you'll need to either expose the label of Form1 via a property (or - ick! - a non-private field) or write a method/property which will set the text of the... |
265,850 | <p>Usually, I need to retrieve data from a table in some range; for example, a separate page for each search result. In MySQL I use LIMIT keyword but in DB2 I don't know. Now I use this query for retrieve range of data.</p>
<pre><code>SELECT *
FROM(
SELECT
SMALLINT(RANK() OVER(ORDER BY NAME DESC)) AS RUNNI... | [
{
"answer_id": 273106,
"author": "Paul Morgan",
"author_id": 16322,
"author_profile": "https://Stackoverflow.com/users/16322",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure why you are creating the TMP table. Isn't RUNNING_NO aready in ascending sequence? I would think:</p>\n\... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24550/"
] | Usually, I need to retrieve data from a table in some range; for example, a separate page for each search result. In MySQL I use LIMIT keyword but in DB2 I don't know. Now I use this query for retrieve range of data.
```
SELECT *
FROM(
SELECT
SMALLINT(RANK() OVER(ORDER BY NAME DESC)) AS RUNNING_NO
, ... | My requirement have been added into DB2 9.7.2 already.
DB2 9.7.2 adds new syntax for limit query result as illustrate below:
```
SELECT * FROM TABLE LIMIT 5 OFFSET 20
```
the database will retrieve result from row no. 21 - 25 |
265,855 | <p>I've got a database here that runs entirely on GMT. The client machines, however, may run on many different time zones (including BST). When you pull data back using SqlConnection, it will translate the datetime value so, for instance</p>
<p>19 August 2008</p>
<p>becomes</p>
<p>18 August 2008 23:00:00.</p>
<p>... | [
{
"answer_id": 265878,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>Only keep UTC values in the database. Have your business objects always translate to/from UTC/local time when storin... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got a database here that runs entirely on GMT. The client machines, however, may run on many different time zones (including BST). When you pull data back using SqlConnection, it will translate the datetime value so, for instance
19 August 2008
becomes
18 August 2008 23:00:00.
My question is, is there a way to... | How are you accessing the data?
I had the same problem when passing DataSets / DataTables from a webservice.
I got round it by setting the DataColumn.DateTimeMode property in the DataTable
```
returnedDataTable.Columns("ColumnName").DateTimeMode = DataSetDateTime.Unspecified
```
It was just fine after that.
Don't... |
265,879 | <p>I am interested in using/learning RoR in a project where I have to use a .NET dll. Is Ruby capable of importing a .NET dll?</p>
| [
{
"answer_id": 265890,
"author": "Herms",
"author_id": 1409,
"author_profile": "https://Stackoverflow.com/users/1409",
"pm_score": 0,
"selected": false,
"text": "<p>If you use IronRuby (Ruby implementation built on .Net) then it should be able to. If you're already using .Net and want t... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34766/"
] | I am interested in using/learning RoR in a project where I have to use a .NET dll. Is Ruby capable of importing a .NET dll? | While IronRuby will make short work of talking to your .NET dll (it'll be literally no code at all), it was abandoned by microsoft, and it never got a large enough open source community to keep it going after that event. I wouldn't recommend it these days
Regarding the COM solution, this may actually be a good way to ... |
265,888 | <p>I'm having an issue getting validation error messages to display for a particular field in a Django form, where the field in question is a <strong>ModelMultipleChoiceField</strong>.</p>
<p>In the <code>clean(self)</code> method for the Form, I try to add the error message to the field like so:</p>
<pre><code>msg =... | [
{
"answer_id": 314830,
"author": "lawrence",
"author_id": 56817,
"author_profile": "https://Stackoverflow.com/users/56817",
"pm_score": 0,
"selected": false,
"text": "<p>Why are you instantiating an ErrorList and writing to self._errors directly? Calling \"raise forms.ValidationError(msg... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34759/"
] | I'm having an issue getting validation error messages to display for a particular field in a Django form, where the field in question is a **ModelMultipleChoiceField**.
In the `clean(self)` method for the Form, I try to add the error message to the field like so:
```
msg = 'error'
self._errors['field_name'] = ErrorLi... | Yeah, it sounds like you're doing it wrong.
You should be using the [clean\_](http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-a-specific-field-attribute) method instead. Read through that whole document, in fact - it's very informative. |
265,896 | <p>I've got a junk directory where I toss downloads, one-off projects, email drafts, and other various things that might be useful for a few days but don't need to be saved forever. To stop this directory from taking over my machine, I wrote a program that will delete all files older than a specified number of days an... | [
{
"answer_id": 265909,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 2,
"selected": false,
"text": "<p>Why do you need to check? Just forcibly clear the read-only flag and delete the file.</p>\n"
},
{
"answer_id... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2547/"
] | I've got a junk directory where I toss downloads, one-off projects, email drafts, and other various things that might be useful for a few days but don't need to be saved forever. To stop this directory from taking over my machine, I wrote a program that will delete all files older than a specified number of days and lo... | According to [File.Delete's documentation,](http://msdn.microsoft.com/en-us/library/system.io.file.delete.aspx), you'll have to strip the read-only attribute. You can set the file's attributes using [File.SetAttributes()](http://msdn.microsoft.com/en-us/library/system.io.file.setattributes.aspx).
```
using System.IO;
... |
265,898 | <p>I'm coding a small CMS to get a better understanding of how they work and to learn some new things about PHP. I have however come across a problem.</p>
<p>I want to use mod_rewrite (though if someone has a better solution I'm up for trying it) to produce nice clean URLs, so site.com/index.php?page=2 can instead be ... | [
{
"answer_id": 265934,
"author": "Ken",
"author_id": 20074,
"author_profile": "https://Stackoverflow.com/users/20074",
"pm_score": 4,
"selected": true,
"text": "<p>One approach is to rewrite everything to a handling script</p>\n\n<pre><code>RewriteEngine on\nRewriteBase /\n\n# only rewri... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | I'm coding a small CMS to get a better understanding of how they work and to learn some new things about PHP. I have however come across a problem.
I want to use mod\_rewrite (though if someone has a better solution I'm up for trying it) to produce nice clean URLs, so site.com/index.php?page=2 can instead be site.com/... | One approach is to rewrite everything to a handling script
```
RewriteEngine on
RewriteBase /
# only rewrite if the requested file doesn't exist
RewriteCond %{REQUEST_FILENAME} !-s
# pass the rest of the request into index.php to handle
RewriteRule ^(.*)$ /index.php/$1 [L]
```
so if you have a request to <ht... |
265,914 | <p>I am trying to monitor a tcp flow using flow monitor. attach-fmon wants link object which is not available in wireless connections. How can I solve this problem ? Are there any other solutions ?</p>
<p>My code is here
<a href="http://pastebin.com/f59241692" rel="nofollow noreferrer">http://pastebin.com/f59241692</a... | [
{
"answer_id": 266406,
"author": "Joseph Bui",
"author_id": 3275,
"author_profile": "https://Stackoverflow.com/users/3275",
"pm_score": 0,
"selected": false,
"text": "<p>I caution you that I have no experience with ns (Network Simulator). Clearly the variable $lnk has the value \"\" in t... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to monitor a tcp flow using flow monitor. attach-fmon wants link object which is not available in wireless connections. How can I solve this problem ? Are there any other solutions ?
My code is here
<http://pastebin.com/f59241692>
I got this error message
```
eid@eid-laptop:~/code/ns2/noisy$ ns mixed.tcl... | Wireshark (<http://wireshark.org>) replaced ethereal in 2006, and is a free, open-source network protocol analyser. It can capture, and analyse data from pretty much any network interface, and will allow you to filter on the communication path of interest by filtering on port number etc. |
265,944 | <p>How do you reverse the effect of a merge on polarised branches without dying of agony?</p>
<p>This problem has been plaguing me for <strong>months</strong> and I have finally given up. </p>
<p>You have 1 Repository, with 2 <strong>Named</strong> Branches. A and B. </p>
<p>Changes that occur to A will inevitably... | [
{
"answer_id": 267973,
"author": "Justin Love",
"author_id": 30203,
"author_profile": "https://Stackoverflow.com/users/30203",
"pm_score": 2,
"selected": false,
"text": "<p>In a pinch, you can export the repository to a bunch diffs, edit history, and then glue back together just what you... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15614/"
] | How do you reverse the effect of a merge on polarised branches without dying of agony?
This problem has been plaguing me for **months** and I have finally given up.
You have 1 Repository, with 2 **Named** Branches. A and B.
Changes that occur to A will inevitably occur on B.
Changes that occur directly on B MUST... | I think I found a solution which permanently fixes the bad merge, and which does not require you to manually check any diffs. The trick is to go back in history and generate commits parallel to the bad merge.
So we have repository with separate branches per maintained version of a single product. Like the situation po... |
265,956 | <p>I am pretty new to php, but I am learning! I have a simple form on a client website. I am testing the form and when I click submit, I get the following error:</p>
<p>Form Mail Script</p>
<pre><code>Wrong referrer (referring site). For security reasons the form can only be used, if the referring page is part of this ... | [
{
"answer_id": 265981,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 2,
"selected": false,
"text": "<p>You are obviously using the Form Mail script on your page. It has a security feature that prevents other domains fro... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30043/"
] | I am pretty new to php, but I am learning! I have a simple form on a client website. I am testing the form and when I click submit, I get the following error:
Form Mail Script
```
Wrong referrer (referring site). For security reasons the form can only be used, if the referring page is part of this website.
Note for ... | The referrer is a value that's usually sent to a server by a client (your browser) along with a request. It indicates the URL from which the requested resource was linked or submitted. This error is part of a security mechanism in FormMail that is intended to prevent the script from handling input that doesn't originat... |
265,960 | <p>It seems like there should be a simpler way than:</p>
<pre><code>import string
s = "string. With. Punctuation?" # Sample string
out = s.translate(string.maketrans("",""), string.punctuation)
</code></pre>
<p>Is there?</p>
| [
{
"answer_id": 265995,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 5,
"selected": false,
"text": "<p>Not necessarily simpler, but a different way, if you are more familiar with the re family. </p>\n\n<pre><code>imp... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | It seems like there should be a simpler way than:
```
import string
s = "string. With. Punctuation?" # Sample string
out = s.translate(string.maketrans("",""), string.punctuation)
```
Is there? | From an efficiency perspective, you're not going to beat
```
s.translate(None, string.punctuation)
```
For higher versions of Python use the following code:
```
s.translate(str.maketrans('', '', string.punctuation))
```
It's performing raw string operations in C with a lookup table - there's not much that will b... |
265,970 | <p>I'm more of a programmer than a designer, and I'm trying to embrace <code><div></code>s rather than using tables but am getting stuck.</p>
<p>Here's what I'm trying to do. I am setting up a survey page. I want each question's text to sit at the top of the blue div, and wrap if it's too long. I want all of ... | [
{
"answer_id": 265980,
"author": "Eric Wendelin",
"author_id": 25066,
"author_profile": "https://Stackoverflow.com/users/25066",
"pm_score": 0,
"selected": false,
"text": "<p>Very little testing here, but I <em>think</em> you'll want \"clear: both;\" on .greencontainer instead of \"float... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28351/"
] | I'm more of a programmer than a designer, and I'm trying to embrace `<div>`s rather than using tables but am getting stuck.
Here's what I'm trying to do. I am setting up a survey page. I want each question's text to sit at the top of the blue div, and wrap if it's too long. I want all of the red divs to line up at the... | Here is what I would do:
```
<div class="greencontainer">
<div class="redcontainer">
<input type="checkbox" />
</div>
<div class="bluecontainer">
<label>Text about this checkbox...</label>
</div>
</div>
```
with css:
```
.greencontainer{
float:left;
clear:left;
width:100%;
}
.redcontainer... |
265,984 | <p>Let's say we have defined a CSS class that is being applied to various elements on a page.</p>
<pre><code>colourful
{
color: #DD00DD;
background-color: #330033;
}
</code></pre>
<p>People have complained about the colour, that they don't like pink/purple. So you want to give them the ability to change the s... | [
{
"answer_id": 266023,
"author": "kemiller2002",
"author_id": 1942,
"author_profile": "https://Stackoverflow.com/users/1942",
"pm_score": -1,
"selected": false,
"text": "<p>Something like</p>\n\n<pre><code>function changeColourful(colorRGB, backgroundColorRGB)\n {changeColor (document, c... | 2008/11/05 | [
"https://Stackoverflow.com/questions/265984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34778/"
] | Let's say we have defined a CSS class that is being applied to various elements on a page.
```
colourful
{
color: #DD00DD;
background-color: #330033;
}
```
People have complained about the colour, that they don't like pink/purple. So you want to give them the ability to change the style as they wish, and the... | I don't know about manipulating the class directly, but you can effectively do the same thing. Here's an example in jQuery.
```
$('.colourful').css('background-color', 'purple').css('color','red');
```
In plain javascript, you would have to do more work. |
266,002 | <p>I'm using this XPath to get the value of a field:</p>
<pre class="lang-none prettyprint-override"><code>//input[@type="hidden"][@name="val"]/@value
</code></pre>
<p>I get several results, but I only want the first. Using</p>
<pre class="lang-none prettyprint-override"><code>//input[@type="hidden"][@name="val"]/@v... | [
{
"answer_id": 266083,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": false,
"text": "<p>For the XPath, try:</p>\n\n<pre>\n//input[@type=\"hidden\" and @name=\"val\" and position() = 1]/@value\n</pre>\n\n<p>F... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using this XPath to get the value of a field:
```none
//input[@type="hidden"][@name="val"]/@value
```
I get several results, but I only want the first. Using
```none
//input[@type="hidden"][@name="val"]/@value[1]
```
Doesn't work. Once I have this, how do I pick up the value in Greasemonkey? I am trying thing... | For the XPath, try:
```
//input[@type="hidden" and @name="val" and position() = 1]/@value
```
For use in a GreaseMonkey script, do something like this:
```
var result = document.evaluate(
"//input[@type='hidden' and @name='var' and position()=1]/@value",
document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, ... |
266,015 | <p>I want to have two items on the same line using <code>float: left</code> for the item on the left.</p>
<p>I have no problems achieving this alone. The problem is, I want the two items to <strong>stay</strong> on the same line <em>even when you resize the browser very small</em>. You know... like how it was with tab... | [
{
"answer_id": 266025,
"author": "Eric Wendelin",
"author_id": 25066,
"author_profile": "https://Stackoverflow.com/users/25066",
"pm_score": 7,
"selected": true,
"text": "<p>Wrap your floating <code><div></code>s in a container <code><div></code> that uses this cross-browser ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2908/"
] | I want to have two items on the same line using `float: left` for the item on the left.
I have no problems achieving this alone. The problem is, I want the two items to **stay** on the same line *even when you resize the browser very small*. You know... like how it was with tables.
The goal is to keep the item on the... | Wrap your floating `<div>`s in a container `<div>` that uses this cross-browser min-width hack:
```
.minwidth { min-width:100px; width: auto !important; width: 100px; }
```
You *may* also need to set "overflow" but probably not.
This works because:
* The `!important` declaration, combined with `min-width` cause ev... |
266,026 | <p>Just looking for the relevant documentation. An example is not necessary, but would be appreciated. </p>
<p>We have a situation where we are having to create 100s of virtual directories manually, and it seems like automating this would be a good way to make the process more efficient for now. </p>
<p>Perhaps ne... | [
{
"answer_id": 266045,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 2,
"selected": false,
"text": "<p>NOT TESTED (from an old code base and written by a former contractor of mine)</p>\n\n<pre><code>using System;\nusing... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17847/"
] | Just looking for the relevant documentation. An example is not necessary, but would be appreciated.
We have a situation where we are having to create 100s of virtual directories manually, and it seems like automating this would be a good way to make the process more efficient for now.
Perhaps next year we can rewor... | Evidently you can also do this via PowerShell scripting:
```
$objIIS = new-object System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/1/Root")
$children = $objIIS.psbase.children
$vDir = $children.add("NewFolder",$objIIS.psbase.SchemaClassName)
$vDir.psbase.CommitChanges()
$vDir.Path = "C:\Documents and Set... |
266,028 | <p>We are looking to provide two <strong>custom Platform switches</strong> (the <strong>platform dropdown</strong> in the configuration manager) for our projects <strong>in Visual Studio</strong>. </p>
<p>For example one for 'Desktop' and one for 'Web'. The target build tasks then compile the code in a custom way base... | [
{
"answer_id": 266137,
"author": "Joel Lucsy",
"author_id": 645,
"author_profile": "https://Stackoverflow.com/users/645",
"pm_score": -1,
"selected": false,
"text": "<p>Rename \"Debug\" and \"Release\" to \"Debug Desktop\" and \"Release Desktop\" and copy them into names \"Debug Web\" an... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1747/"
] | We are looking to provide two **custom Platform switches** (the **platform dropdown** in the configuration manager) for our projects **in Visual Studio**.
For example one for 'Desktop' and one for 'Web'. The target build tasks then compile the code in a custom way based on the platform switch. We don't want to add to... | You should be able to use the Configuration Manager dialog to create new platforms. |
266,082 | <p>How do I tell if my application (compiled in Visual Studio 2008 as <em>Any CPU</em>) is running as a 32-bit or 64-bit application?</p>
| [
{
"answer_id": 266084,
"author": "Redwood",
"author_id": 1512,
"author_profile": "https://Stackoverflow.com/users/1512",
"pm_score": 3,
"selected": false,
"text": "<p>I found this code from <a href=\"http://bytes.com/forum/thread525905.html\" rel=\"nofollow noreferrer\">Martijn Boven</a>... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | How do I tell if my application (compiled in Visual Studio 2008 as *Any CPU*) is running as a 32-bit or 64-bit application? | ```
if (IntPtr.Size == 8)
{
// 64 bit machine
}
else if (IntPtr.Size == 4)
{
// 32 bit machine
}
``` |
266,115 | <p>The title is kind of obscure. What I want to know is if this is possible:</p>
<pre><code>string typeName = <read type name from somwhere>;
Type myType = Type.GetType(typeName);
MyGenericClass<myType> myGenericClass = new MyGenericClass<myType>();
</code></pre>
<p>Obviously, MyGenericClass is des... | [
{
"answer_id": 266127,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 4,
"selected": false,
"text": "<p>Unfortunately no there is not. Generic arguments must be resolvable at Compile time as either 1) a valid type or 2) a... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9209/"
] | The title is kind of obscure. What I want to know is if this is possible:
```
string typeName = <read type name from somwhere>;
Type myType = Type.GetType(typeName);
MyGenericClass<myType> myGenericClass = new MyGenericClass<myType>();
```
Obviously, MyGenericClass is described as:
```
public class MyGenericClass<... | You can't do this without reflection. However, you *can* do it with reflection. Here's a complete example:
```
using System;
using System.Reflection;
public class Generic<T>
{
public Generic()
{
Console.WriteLine("T={0}", typeof(T));
}
}
class Test
{
static void Main()
{
string ty... |
266,116 | <p>How do you programmatically obtain a picture of a .Net control?</p>
| [
{
"answer_id": 266139,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": true,
"text": "<p>There's a method on every control called <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.control.draw... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34787/"
] | How do you programmatically obtain a picture of a .Net control? | There's a method on every control called [DrawToBitmap](http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx). You don't need to p/invoke to do this.
```
Control c = new TextBox();
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(c.Width, c.Height);
c.DrawToBitmap(bmp, c.ClientRe... |
266,123 | <p>Maybe I should further qualify this - Is there a way to specify which direction a ComboBox will open without copying and pasting the entire ComboBox class and ripping out the code where it determines which direction it will open in...</p>
<p>I'm my specific case - I need it to open upwards - always.</p>
<p>UPDATE:... | [
{
"answer_id": 266194,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 0,
"selected": false,
"text": "<p>I doubt it - you'd need to subclass the control (which isn't <em>that</em> big a deal.)</p>\n\n<p>Maybe you could mess w... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3435/"
] | Maybe I should further qualify this - Is there a way to specify which direction a ComboBox will open without copying and pasting the entire ComboBox class and ripping out the code where it determines which direction it will open in...
I'm my specific case - I need it to open upwards - always.
UPDATE: You can't fix th... | If you build up the Menu object yourself, you can place the menu anywhere you want by simply setting the x,y coordinates of the menu object. You'll need to calculate those coordinates, but you might be able to do this easily without subclassing ComboBox.
I am doing something similar with PopUpButton; you might find it... |
266,168 | <p>Can someone post a simple example of starting two (Object Oriented) threads in C++. </p>
<p>I'm looking for actual C++ thread objects that I can extend run methods on (or something similar) as opposed to calling a C-style thread library.</p>
<p>I left out any OS specific requests in the hopes that whoever replied ... | [
{
"answer_id": 266180,
"author": "LorenzCK",
"author_id": 3118,
"author_profile": "https://Stackoverflow.com/users/3118",
"pm_score": 3,
"selected": false,
"text": "<p>It largely depends on the library you decide to use. For instance, if you use the <a href=\"https://en.wikipedia.org/wik... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2112692/"
] | Can someone post a simple example of starting two (Object Oriented) threads in C++.
I'm looking for actual C++ thread objects that I can extend run methods on (or something similar) as opposed to calling a C-style thread library.
I left out any OS specific requests in the hopes that whoever replied would reply with ... | Create a function that you want the thread to execute, for example:
```
void task1(std::string msg)
{
std::cout << "task1 says: " << msg;
}
```
Now create the `thread` object that will ultimately invoke the function above like so:
```
std::thread t1(task1, "Hello");
```
(You need to `#include <thread>` to acc... |
266,184 | <p>I'm trying to be responsible with my "DOM" references in this little Flash 8/AS2 project.</p>
<p>What has become increasingly frustrating is obtaining references to other movie clips and objects. For example, currently my code to access the submit button of a form looks something like this</p>
<pre><code>var b:Bu... | [
{
"answer_id": 266604,
"author": "moritzstefaner",
"author_id": 23069,
"author_profile": "https://Stackoverflow.com/users/23069",
"pm_score": 2,
"selected": true,
"text": "<p>If the MovieClip was placed on the stage in the Flash IDE, you can give it a proper instance name in the properti... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8815/"
] | I'm trying to be responsible with my "DOM" references in this little Flash 8/AS2 project.
What has become increasingly frustrating is obtaining references to other movie clips and objects. For example, currently my code to access the submit button of a form looks something like this
```
var b:Button = _level0.instanc... | If the MovieClip was placed on the stage in the Flash IDE, you can give it a proper instance name in the properties panel.
If it was dynamically added, you can also give it a name, and additionally store a reference:
```
var my_MC=createEmptyMovieClip("instanceName", depth);
```
In either case, you can then adress ... |
266,196 | <p>I'm looking at having certain users access one database and other users accessing another database based on the company they belong to. What would be the best way to handle the connection strings and make sure the user connects to the right db when they login?</p>
<p>Thanks for any ideas.</p>
| [
{
"answer_id": 266207,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 2,
"selected": false,
"text": "<p>Have a database table that stores the connection info for each user. Maybe something like the <a href=\"http://msdn.... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34571/"
] | I'm looking at having certain users access one database and other users accessing another database based on the company they belong to. What would be the best way to handle the connection strings and make sure the user connects to the right db when they login?
Thanks for any ideas. | In Web.Config or App.Config
```
<connectionStrings>
<add name="ConnectionForDudes" providerName="System.Data.SqlClient"
connectionString="Data Source=___MALECONNECTIONHERE___"/>
<add name="ConnectionForChicks" providerName="System.Data.SqlClient"
connectionString="Data Source=___FEMALECONNECTIONHERE__... |
266,199 | <p>I'm trying to do a very simple button that changes color based on mouseover, mouseout and
click, I'm doing this in prototype and the weird thing is if I used mouseover and mouseout,
after I clicked on the button, the button wouldn't change to white, seems like it is because of the mouseout, here's my code</p>
<pre>... | [
{
"answer_id": 266212,
"author": "schonarth",
"author_id": 22116,
"author_profile": "https://Stackoverflow.com/users/22116",
"pm_score": 0,
"selected": false,
"text": "<p>If you move the cursor away from the button after clicking on it, the last event is mouseout, so it happens no matter... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34797/"
] | I'm trying to do a very simple button that changes color based on mouseover, mouseout and
click, I'm doing this in prototype and the weird thing is if I used mouseover and mouseout,
after I clicked on the button, the button wouldn't change to white, seems like it is because of the mouseout, here's my code
```
$("izzy"... | Unless there's something else happening in mouse over and out, why not use css?
```
#izzy:hover { color: '#FFFFFF'; }
```
However, I'm a little confused as to what exactly you want to happen. Assuming you want the button white if it has been clicked or if the mouse is over it. I'd have the click event handler add a... |
266,202 | <h2>There seems to be two major conventions for organizing project files and then many variations.</h2>
<p><strong>Convention 1: High-level type directories, project sub-directories</strong></p>
<p>For example, the <a href="http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk/" rel="nofollow noreferrer">wxWidgets</a> proj... | [
{
"answer_id": 267889,
"author": "JXG",
"author_id": 15456,
"author_profile": "https://Stackoverflow.com/users/15456",
"pm_score": 3,
"selected": true,
"text": "<p>[A partial answer.]</p>\n\n<p>In \"Convention 2: High-level project dirs, type sub-directories,\" your single con is</p>\n\n... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2233/"
] | There seems to be two major conventions for organizing project files and then many variations.
----------------------------------------------------------------------------------------------
**Convention 1: High-level type directories, project sub-directories**
For example, the [wxWidgets](http://svn.wxwidgets.org/svn... | [A partial answer.]
In "Convention 2: High-level project dirs, type sub-directories," your single con is
>
> If there are dependencies between
> projects, you need an additional layer
> of build scripts above the project
> directories to manage the build order
>
>
>
That can also be viewed as a pro, in many p... |
266,206 | <p>I'm relatively new to C++. In Java, it's easy for me to instantiate and use a hashmap. I'd like to know how to do it in a simple way in C++, since I saw many different implementations and none of them looked simple to me.</p>
| [
{
"answer_id": 266231,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 2,
"selected": false,
"text": "<p>Try boost's <a href=\"http://www.boost.org/doc/libs/1_37_0/doc/html/unordered.html\" rel=\"nofollow noreferrer\">unor... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33857/"
] | I'm relatively new to C++. In Java, it's easy for me to instantiate and use a hashmap. I'd like to know how to do it in a simple way in C++, since I saw many different implementations and none of them looked simple to me. | Most compilers should define `std::hash_map` for you; in the coming `C++0x` standard, it will be part of the standard library as [`std::unordered_map`](http://en.cppreference.com/w/cpp/container/unordered_map). The [STL Page](http://www.sgi.com/tech/stl/hash_map.html) on it is fairly standard. If you use Visual Studio,... |
266,213 | <p>Is there a way (preferrably using JavaScript) to determine whether a URL is to a SWF or a JPG? </p>
<p>The obvious answer is to sniff the filename for ".jpg" or ".swf" but I'm dealing with banners that are dynamically decided by the server and usually have a lot of parameters and generally don't include an extensio... | [
{
"answer_id": 266240,
"author": "Sijin",
"author_id": 8884,
"author_profile": "https://Stackoverflow.com/users/8884",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure the of the exact setup you have, but can you use the HTTP response and check the mime-type to determine image... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8349/"
] | Is there a way (preferrably using JavaScript) to determine whether a URL is to a SWF or a JPG?
The obvious answer is to sniff the filename for ".jpg" or ".swf" but I'm dealing with banners that are dynamically decided by the server and usually have a lot of parameters and generally don't include an extension.
so i'... | You could use javascript to detect if it is a image by creating a dynamic img-tag.
```
function isImage(url, callback) {
var img = document.createElement('img');
img.onload = function() {
callback(url);
}
img.src = url;
}
```
And then calling it with:
```
isImage('http://animals.nationalgeog... |
266,245 | <p>I have a git repository with remote foo.</p>
<p>foo is a web app, is contains some files and dirs directly in its root:</p>
<pre><code>Rakefile
app
...
public
script
</code></pre>
<p>My main git repository is a larger system which comprises this web app. I want to pull the commits from foo, but I need the files t... | [
{
"answer_id": 266334,
"author": "kch",
"author_id": 13989,
"author_profile": "https://Stackoverflow.com/users/13989",
"pm_score": 2,
"selected": false,
"text": "<p>This answers my question:</p>\n\n<p><a href=\"http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.htm... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13989/"
] | I have a git repository with remote foo.
foo is a web app, is contains some files and dirs directly in its root:
```
Rakefile
app
...
public
script
```
My main git repository is a larger system which comprises this web app. I want to pull the commits from foo, but I need the files to reside inside the `web` dir. So... | Here's a community-wiki version of your answer if you'd like to accept it as the answer.
---
This answers my question:
<http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html> |
266,250 | <p>I'm learning some PowerShell. Is it possible to see the source code for a built-in cmdlet like <a href="http://technet.microsoft.com/en-us/library/hh849800.aspx" rel="noreferrer">Get-ChildItem</a>?</p>
| [
{
"answer_id": 266259,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 0,
"selected": false,
"text": "<p>I do not believe that the source code for PowerShell has ever been released.</p>\n"
},
{
"answer_id": 266286,
... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm learning some PowerShell. Is it possible to see the source code for a built-in cmdlet like [Get-ChildItem](http://technet.microsoft.com/en-us/library/hh849800.aspx)? | Actually, your best bet is to go check out [PowerShell Community Extensions](https://github.com/Pscx/Pscx). This open source software community project is "aimed at providing a widely useful set of additional cmdlets...". The developers on the project are PowerShell MVPs and know their stuff.
As far as using reflectio... |
266,255 | <p>I try to instantiate an instance of <code>SPSite</code> on the farm server in a custom process (MyApp.exe) and I give it as parameter the whole URI (<a href="http://mysite:80/" rel="nofollow noreferrer">http://mysite:80/</a>). I also made sure that the account running <code>MyApp.exe</code> is <code>Site Collection ... | [
{
"answer_id": 266274,
"author": "axk",
"author_id": 578,
"author_profile": "https://Stackoverflow.com/users/578",
"pm_score": 1,
"selected": false,
"text": "<p>Stacktrace of the exception would be helpful.</p>\n\n<p>I think you possibly can get some idea of what file it is and what is h... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24975/"
] | I try to instantiate an instance of `SPSite` on the farm server in a custom process (MyApp.exe) and I give it as parameter the whole URI (<http://mysite:80/>). I also made sure that the account running `MyApp.exe` is `Site Collection Administrator`.
However, I can't make an instance of `SPSite` whatever I am trying to... | The FileNotFoundException is thrown by SharePoint when it cannot find the requested site collection in the SharePoint configuration database. My guess is that you have not yet created a site collection on the URL <http://mysite:80>. I see the following stack trace if I try and instantiate a new SPSite object with the U... |
266,308 | <p>Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does?</p>
<p>When you compile in Visual Studio, the "output" window shows the actual call to the compiler, which normally looks like:</p>
<p>vbc.exe [bunch of options] [looooong list of .vb files]</p>
<p>I would like to ... | [
{
"answer_id": 266318,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 3,
"selected": false,
"text": "<p>MSBuild can also take your solution file and use it to do the compile.</p>\n"
},
{
"answer_id": 266319,
... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does?
When you compile in Visual Studio, the "output" window shows the actual call to the compiler, which normally looks like:
vbc.exe [bunch of options] [looooong list of .vb files]
I would like to programatically call "so... | MSBuild is the easiest way to go. For instance:
```
msbuild /property:Configuration=Release MyFile.vbproj
``` |
266,326 | <p>Am I safe in casting a C++ bool to a Windows API BOOL via this construct</p>
<pre><code>bool mybool = true;
BOOL apiboolean = mybool ? TRUE : FALSE;
</code></pre>
<p>I'd assume this is a yes because I don't see any obvious problems but I wanted to take a moment to ask only because this may be more subtle than it a... | [
{
"answer_id": 266338,
"author": "Dima",
"author_id": 13313,
"author_profile": "https://Stackoverflow.com/users/13313",
"pm_score": 4,
"selected": true,
"text": "<p>Do you mean</p>\n\n<pre><code>\nbool b;\n...\nBOOL apiboolean = b ? TRUE : FALSE;\n</code></pre>\n\n<p>If so, then yes, thi... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2820/"
] | Am I safe in casting a C++ bool to a Windows API BOOL via this construct
```
bool mybool = true;
BOOL apiboolean = mybool ? TRUE : FALSE;
```
I'd assume this is a yes because I don't see any obvious problems but I wanted to take a moment to ask only because this may be more subtle than it appears.
*Thanks to Dima ... | Do you mean
```
bool b;
...
BOOL apiboolean = b ? TRUE : FALSE;
```
If so, then yes, this will work. |
266,327 | <p>A pattern that's started to show up a lot in one of the web apps I'm working are links that used to just be a regular a-tag link now need a popup box asking "are you sure?" before the link will go. (If the user hits cancel, nothing happens.)</p>
<p>We've got a solution that works, but somehow we're a web app shop ... | [
{
"answer_id": 266347,
"author": "Electrons_Ahoy",
"author_id": 19074,
"author_profile": "https://Stackoverflow.com/users/19074",
"pm_score": 3,
"selected": false,
"text": "<p>Here's how we've been doing it:</p>\n\n<pre><code><a href=\"#\" onClick=\"goThere(); return false;\">Go to... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19074/"
] | A pattern that's started to show up a lot in one of the web apps I'm working are links that used to just be a regular a-tag link now need a popup box asking "are you sure?" before the link will go. (If the user hits cancel, nothing happens.)
We've got a solution that works, but somehow we're a web app shop without a J... | **Unobtrusive Javascript**
The best practice is to add event handler methods to the links.
The *confirm()* function produces the dialog box you described, and returns true or false depending on the user's choice.
Event handler methods on links have a special behavior, which is that they kill the link action if they ... |
266,357 | <p>I have been trying to tokenize a string using SPACE as delimiter but it doesn't work. Does any one have suggestion on why it doesn't work?</p>
<p>Edit: tokenizing using:</p>
<pre><code>strtok(string, " ");
</code></pre>
<p>The code is like the following</p>
<pre><code>pch = strtok (str," ");
while (pch != NULL)
... | [
{
"answer_id": 266381,
"author": "xtofl",
"author_id": 6610,
"author_profile": "https://Stackoverflow.com/users/6610",
"pm_score": 0,
"selected": false,
"text": "<p>When reading the strtok documentation, I see you need to pass in a NULL pointer after the first \"initializing\" call. May... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/382480/"
] | I have been trying to tokenize a string using SPACE as delimiter but it doesn't work. Does any one have suggestion on why it doesn't work?
Edit: tokenizing using:
```
strtok(string, " ");
```
The code is like the following
```
pch = strtok (str," ");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NUL... | Do it like this:
```
char s[256];
strcpy(s, "one two three");
char* token = strtok(s, " ");
while (token) {
printf("token: %s\n", token);
token = strtok(NULL, " ");
}
```
Note: `strtok` modifies the string its tokenising, so it cannot be a `const char*`. |
266,364 | <p>I've got a DB table where we store a lot of MD5 hashes (and yes I know that they aren't 100% unique...) where we have a lot of comparison queries against those strings.
This table can become quite large with over 5M rows.</p>
<p>My question is this: Is it wise to keep the data as hexadecimal strings or should I con... | [
{
"answer_id": 266381,
"author": "xtofl",
"author_id": 6610,
"author_profile": "https://Stackoverflow.com/users/6610",
"pm_score": 0,
"selected": false,
"text": "<p>When reading the strtok documentation, I see you need to pass in a NULL pointer after the first \"initializing\" call. May... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got a DB table where we store a lot of MD5 hashes (and yes I know that they aren't 100% unique...) where we have a lot of comparison queries against those strings.
This table can become quite large with over 5M rows.
My question is this: Is it wise to keep the data as hexadecimal strings or should I convert the h... | Do it like this:
```
char s[256];
strcpy(s, "one two three");
char* token = strtok(s, " ");
while (token) {
printf("token: %s\n", token);
token = strtok(NULL, " ");
}
```
Note: `strtok` modifies the string its tokenising, so it cannot be a `const char*`. |
266,371 | <p>In VIM in command line mode a "%" denotes the current file, "cword" denotes the current word under the cursor. I want to create a shortcut where I need the current line number. What is the symbol which denotes this?</p>
| [
{
"answer_id": 266386,
"author": "WMR",
"author_id": 2844,
"author_profile": "https://Stackoverflow.com/users/2844",
"pm_score": 4,
"selected": false,
"text": "<p>. (dot) stands for the current line.</p>\n\n<p>To clarify:\nThis is meant for stuff like <code>:1,.s/foo/bar/g</code> which w... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29653/"
] | In VIM in command line mode a "%" denotes the current file, "cword" denotes the current word under the cursor. I want to create a shortcut where I need the current line number. What is the symbol which denotes this? | If you want to pass the current line number to a shell command, you could do
```
:exe "!echo " . line(".")
``` |
266,389 | <p>What's the easiest programmatic way to restart a service on a remote Windows system? Language or method doesn't matter as long as it doesn't require human interaction.</p>
| [
{
"answer_id": 266419,
"author": "Raz",
"author_id": 5661,
"author_profile": "https://Stackoverflow.com/users/5661",
"pm_score": 1,
"selected": false,
"text": "<p>look at <a href=\"http://technet.microsoft.com/en-us/sysinternals/bb897542.aspx\" rel=\"nofollow noreferrer\">sysinternals</a... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What's the easiest programmatic way to restart a service on a remote Windows system? Language or method doesn't matter as long as it doesn't require human interaction. | As of Windows XP, you can use `sc.exe` to interact with local and remote services. Schedule a task to run a batch file similar to this:
```
sc \\server stop service
sc \\server start service
```
Make sure the task runs under a user account privileged on the target server.
`psservice.exe` from the [Sysinternals PST... |
266,395 | <p>I have a git repository which tracks an svn repository. I cloned it using <code>--stdlayout</code>.</p>
<p>I created a new local branch via <code>git checkout -b foobar</code></p>
<p>Now I want this branch to end up in <code>…/branches/foobar</code> in the svn repository.</p>
<p>How do I go about that?</p>
<p>(s... | [
{
"answer_id": 266561,
"author": "kch",
"author_id": 13989,
"author_profile": "https://Stackoverflow.com/users/13989",
"pm_score": 7,
"selected": true,
"text": "<p>as of git v1.6.1, <code>git svn branch</code> is available.</p>\n\n<p>From the git docs:</p>\n\n<pre>\n branch\n C... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13989/"
] | I have a git repository which tracks an svn repository. I cloned it using `--stdlayout`.
I created a new local branch via `git checkout -b foobar`
Now I want this branch to end up in `…/branches/foobar` in the svn repository.
How do I go about that?
(snipped lots of investigative text. see question history if you c... | as of git v1.6.1, `git svn branch` is available.
From the git docs:
```
branch
Create a branch in the SVN repository.
-m, --message
Allows to specify the commit message.
-t, --tag
Create a tag by using the tags_subdir instead of the branches_subdir
sp... |
266,409 | <p>I've got a WAR file that I need to add two files to. Currently, I'm doing this:</p>
<pre><code>File war = new File(DIRECTORY, "server.war");
JarOutputStream zos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(war)));
//Add file 1
File file = new File(DIRECTORY, "file1.jar");
InputStream is = ne... | [
{
"answer_id": 266469,
"author": "hark",
"author_id": 34826,
"author_profile": "https://Stackoverflow.com/users/34826",
"pm_score": 3,
"selected": false,
"text": "<p>Yeah, there's an extra boolean argument to the <a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileOutputStream.... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4893/"
] | I've got a WAR file that I need to add two files to. Currently, I'm doing this:
```
File war = new File(DIRECTORY, "server.war");
JarOutputStream zos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(war)));
//Add file 1
File file = new File(DIRECTORY, "file1.jar");
InputStream is = new BufferedInpu... | It seems this can't be done. I thought it was for a while, but it seems that it wasn't quite having the effect I wanted. Doing it this way resulted in the equivalent of two separate jar files concatinated together. The weird part was that the tools were making some sense of it. JAR found the first, original jar file an... |
266,417 | <p>We are in a Windows environment and looking to automate this process for non-company machines. If a vendor comes on site, we'd like to be able to have him/her hit a website that can perform a quick scan of the workstation to determine if they have the proper MS KB patches and if their virus scanner dats are up to d... | [
{
"answer_id": 392605,
"author": "Hernán",
"author_id": 48026,
"author_profile": "https://Stackoverflow.com/users/48026",
"pm_score": 3,
"selected": true,
"text": "<p>In Windows Vista there are some new APIs to interface with the Security Center component status: <a href=\"http://msdn2.m... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11130/"
] | We are in a Windows environment and looking to automate this process for non-company machines. If a vendor comes on site, we'd like to be able to have him/her hit a website that can perform a quick scan of the workstation to determine if they have the proper MS KB patches and if their virus scanner dats are up to date.... | In Windows Vista there are some new APIs to interface with the Security Center component status: <http://msdn2.microsoft.com/en-us/library/bb963845(VS.85).aspx>
Through WMI, here's a VBS code snippet I checked out on <http://social.msdn.microsoft.com/forums/en-US/windowssecurity/thread/bd97d9e6-75c1-4f58-9573-9009df5d... |
266,431 | <p>I used to use the standard mysql_connect(), mysql_query(), etc statements for doing MySQL stuff from PHP. Lately I've been switching over to using the wonderful MDB2 class. Along with it, I'm using prepared statements, so I don't have to worry about escaping my input and SQL injection attacks.</p>
<p>However, there... | [
{
"answer_id": 266464,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 0,
"selected": false,
"text": "<p>Doesn't an empty set of quotes, <code>\"\"</code> do that?</p>\n"
},
{
"answer_id": 266512,
"author": "Powerlo... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14569/"
] | I used to use the standard mysql\_connect(), mysql\_query(), etc statements for doing MySQL stuff from PHP. Lately I've been switching over to using the wonderful MDB2 class. Along with it, I'm using prepared statements, so I don't have to worry about escaping my input and SQL injection attacks.
However, there's one p... | This sounds like a problem with the MDB2 API fumbling PHP's duck typing semantics. Because the empty string in PHP is equivalent to NULL, MDB2 is probably mis-treating it as such. The ideal solution would be to find a workaround for it within it's API, but I'm not overly familiar with it.
One thing that you should con... |
266,433 | <p>So... I used to think that when you accessed a file but specified the name without a path (CAISLog.csv in my case) that .NET would expect the file to reside at the same path as the running .exe. </p>
<p>This works when I'm stepping through a solution (C# .NET2.* VS2K5) but when I run the app in normal mode (Star... | [
{
"answer_id": 266456,
"author": "tomasr",
"author_id": 10292,
"author_profile": "https://Stackoverflow.com/users/10292",
"pm_score": 2,
"selected": false,
"text": "<p>Relative Path resolution <em>never</em> works against the path of the launching executable. It always works against the ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30901/"
] | So... I used to think that when you accessed a file but specified the name without a path (CAISLog.csv in my case) that .NET would expect the file to reside at the same path as the running .exe.
This works when I'm stepping through a solution (C# .NET2.\* VS2K5) but when I run the app in normal mode (Started by a Web... | When an application (WinForms) starts up, the `Environment.CurrentDirectory` contains the path to the application folder (i.e. the folder that contains the .exe assembly). Using any of the File Dialogs, ex. `OpenFileDialog`, `SaveFileDialog`, etc. will cause the current directory to change (if a different folder was se... |
266,448 | <p>How would I format the standard RSS pubDate string as something closer to ASP.NET's DateTime?</p>
<p>So, from this:</p>
<p>Wed, 29 Oct 2008 14:14:48 +0000</p>
<p>to this:</p>
<p>10/29/2008 2:14 PM</p>
| [
{
"answer_id": 266470,
"author": "AaronS",
"author_id": 26932,
"author_profile": "https://Stackoverflow.com/users/26932",
"pm_score": 3,
"selected": true,
"text": "<p>Something close to this should work:</p>\n\n<pre><code>string orig = \"Wed, 29 Oct 2008 14:14:48 +0000\";\nstring newstri... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4241/"
] | How would I format the standard RSS pubDate string as something closer to ASP.NET's DateTime?
So, from this:
Wed, 29 Oct 2008 14:14:48 +0000
to this:
10/29/2008 2:14 PM | Something close to this should work:
```
string orig = "Wed, 29 Oct 2008 14:14:48 +0000";
string newstring = String.Format("{0:MM/dd/yyyy hh:mm tt}", DateTime.Parse(orig.Remove(orig.IndexOf(" +"))));
```
Taken from <http://blog.stevex.net/index.php/string-formatting-in-csharp/> |
266,457 | <p>I have a linq query and I am trying to put that in to a serializable object for a distributed caching (Velocity) but its failing due to a LINQ-to-SQL lazy list</p>
<p>like so</p>
<pre><code> return from b in _datacontext.MemberBlogs
let cats = GetBlogCategories(b.MemberBlogID)
... | [
{
"answer_id": 266537,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 2,
"selected": false,
"text": "<p>If you're caching it why are you using a lazy list? Don't use a lazy list, use caching, and the problem goes away.</p>\n"... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22093/"
] | I have a linq query and I am trying to put that in to a serializable object for a distributed caching (Velocity) but its failing due to a LINQ-to-SQL lazy list
like so
```
return from b in _datacontext.MemberBlogs
let cats = GetBlogCategories(b.MemberBlogID)
select new MemberBl... | If you are putting it in a distributed cache you will need to avoid the LazyList altogether. You can then call .ToList() around the whole LINQ statement as in:
```
(from x select new MemberBlogs).ToList()
```
This should then be cachable because it forces the queries to be evaluated. |
266,486 | <p>I am trying to write out a png file from a java.awt.image.BufferedImage. Everything works fine but the resulting png is a 32-bit file.</p>
<p>Is there a way to make the png file be 8-bit? The image is grayscale, but I do need transparency as this is an overlay image. I am using java 6, and I would prefer to retu... | [
{
"answer_id": 267316,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 1,
"selected": false,
"text": "<p>It is an interesting question... It is late, I will experiment tomorrow. I will first try and use a BufferedImage.TYPE_B... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to write out a png file from a java.awt.image.BufferedImage. Everything works fine but the resulting png is a 32-bit file.
Is there a way to make the png file be 8-bit? The image is grayscale, but I do need transparency as this is an overlay image. I am using java 6, and I would prefer to return an OutputS... | The build in imageio png writer will write 32bit png files on all the platforms I have used it on, no matter what the source image is. You should also be aware that many people have complained that the resulting compression is much lower than what is possible with the png format. There are several independent [png libr... |
266,491 | <p>I have a lot of buttons and by clicking on different button, different image and text would appear. I can achieve what I want, but the code is just so long and it seems very repetitive.
For example:</p>
<pre><code> var aaClick = false;
$("aa").observe('click', function() {
unclick();
$('charac... | [
{
"answer_id": 266515,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 0,
"selected": false,
"text": "<p>Do the buttons share a common container? Then the following code works:</p>\n\n<pre><code>$(container).childElemen... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34797/"
] | I have a lot of buttons and by clicking on different button, different image and text would appear. I can achieve what I want, but the code is just so long and it seems very repetitive.
For example:
```
var aaClick = false;
$("aa").observe('click', function() {
unclick();
$('characterPic').write... | Build it all into a function where you can simply pass it the names of the DIVs you want to register. As long are you are consistent with your .jpg names, it should work.
```
var clicks = []
function regEvents(divName) {
$(divName).observe('click', function() {
unclick(divName);
$('characterPic').w... |
266,501 | <p>Is there a way to define a macro that contains a <code>#include</code>
directive in its body?</p>
<p>If I just put
the "<code>#include</code>", it gives the error</p>
<pre><code>C2162: "expected macro formal parameter"
</code></pre>
<p>since here I am not using <code>#</code> to concatenate strings.<br>
If I use ... | [
{
"answer_id": 266529,
"author": "helloandre",
"author_id": 50,
"author_profile": "https://Stackoverflow.com/users/50",
"pm_score": 0,
"selected": false,
"text": "<p>Why would the macro need to have an #include? if you're #include'ing whatever file the macro is in, you could just put the... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34829/"
] | Is there a way to define a macro that contains a `#include`
directive in its body?
If I just put
the "`#include`", it gives the error
```
C2162: "expected macro formal parameter"
```
since here I am not using `#` to concatenate strings.
If I use "`\# include`", then I receive the following two errors:
```
error... | So like the others say, no, you can't have #include statements inside a macro, since the preprocessor only does one pass. However, you can make the preprocessor do basically the same thing with a gnarly trick I found myself using recently.
Realise that preprocessor directives won't do anything inside a macro, however ... |
266,506 | <p>Using a standard ASP.NET ListView with a LinqDataSource and pagination enabled (with a DataPager), what would be the best way to default to displaying the last page of results?</p>
| [
{
"answer_id": 266529,
"author": "helloandre",
"author_id": 50,
"author_profile": "https://Stackoverflow.com/users/50",
"pm_score": 0,
"selected": false,
"text": "<p>Why would the macro need to have an #include? if you're #include'ing whatever file the macro is in, you could just put the... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9433/"
] | Using a standard ASP.NET ListView with a LinqDataSource and pagination enabled (with a DataPager), what would be the best way to default to displaying the last page of results? | So like the others say, no, you can't have #include statements inside a macro, since the preprocessor only does one pass. However, you can make the preprocessor do basically the same thing with a gnarly trick I found myself using recently.
Realise that preprocessor directives won't do anything inside a macro, however ... |
266,549 | <p>Using MEF I want to do the following.</p>
<p>I have a WPF Shell. To the shell I want to Import from another DLL a UserControl that is also a View of my MVP triad.
The way the MVP triad works, is that in presenter I have a constructor that takes both IModel and IView and wires them up.
So, in order for this to work,... | [
{
"answer_id": 285531,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>The way you outlined in your blog post is the perfectly valid way for utilizing MEF. This is nested composition, and while ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13163/"
] | Using MEF I want to do the following.
I have a WPF Shell. To the shell I want to Import from another DLL a UserControl that is also a View of my MVP triad.
The way the MVP triad works, is that in presenter I have a constructor that takes both IModel and IView and wires them up.
So, in order for this to work, I need ME... | Check my answer here.
<http://codebetter.com/blogs/glenn.block/archive/2008/11/12/mvp-with-mef.aspx>
EDIT: (*Added from the link, to prevent not being flagged as low quality / LOA*)
```
1: using System.ComponentModel.Composition;
2: using System.Reflection;
3: using Microsoft.VisualStudio.TestTools.UnitTes... |
266,570 | <p>Is there any performance difference between the for loops on a primitive array? </p>
<p>Assume:</p>
<pre><code>double[] doubleArray = new double[300000];
for (double var: doubleArray)
someComplexCalculation(var);
</code></pre>
<p>or :</p>
<pre><code>for ( int i = 0, y = doubleArray.length; i < y; i++)
... | [
{
"answer_id": 266572,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>Why not measure it yourself?</p>\n\n<p>This sounds a bit harsh, but this kind of questions are very easy to verify... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9774/"
] | Is there any performance difference between the for loops on a primitive array?
Assume:
```
double[] doubleArray = new double[300000];
for (double var: doubleArray)
someComplexCalculation(var);
```
or :
```
for ( int i = 0, y = doubleArray.length; i < y; i++)
someComplexCalculation(doubleArray[i]);
```
... | Your hand-written, "old" form executes fewer instructions, and may be faster, although you'd have to profile it under a given JIT compiler to know for sure. The "new" form is definitely **not** faster.
If you look at the disassembled code (compiled by Sun's JDK 1.5), you'll see that the "new" form is equivalent to the... |
266,586 | <p>I am coding in ColdFusion, but trying to stay in cfscript, so I have a function that allows me to pass in a query to run it with
<code>
<cfquery blah >
#query#
</cfquery> </code></p>
<p>Somehow though, when I construct my queries with <code>sql = "SELECT * FROM a WHERE b='#c#'"</code> and pass it in, Cold... | [
{
"answer_id": 266680,
"author": "ale",
"author_id": 21960,
"author_profile": "https://Stackoverflow.com/users/21960",
"pm_score": 4,
"selected": false,
"text": "<p>ColdFusion, by design, escapes single quotes when interpolating variables within <code><cfquery></code> tags.</p>\n\n... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am coding in ColdFusion, but trying to stay in cfscript, so I have a function that allows me to pass in a query to run it with
`<cfquery blah >
#query#
</cfquery>`
Somehow though, when I construct my queries with `sql = "SELECT * FROM a WHERE b='#c#'"` and pass it in, ColdFusion has replaced the single quotes wit... | ColdFusion, by design, escapes single quotes when interpolating variables within `<cfquery>` tags.
To do what you want, you need to use the [`PreserveSingleQuotes()`](http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_m-r_14.html) function.
```
<cfquery ...>#PreserveSingleQuotes(query)#</cfquery>
```
This do... |
266,601 | <p>My spring-context file is shown below.</p>
<pre><code><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jms="http://www.... | [
{
"answer_id": 266627,
"author": "Mike Pone",
"author_id": 16404,
"author_profile": "https://Stackoverflow.com/users/16404",
"pm_score": 0,
"selected": false,
"text": "<p>you are not closing the <code><beans></code> tag. Add <code></beans></code> to the end of your config fi... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] | My spring-context file is shown below.
```
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jms="http://www.springframework.o... | Turns out this is because I'm using Hibernate 3 with Spring 1.x which means the DTDs are wrong. Updated the Spring JAR file in the project and that fixed the problem. |
266,639 | <p>What is the best tool / practice to enable browser history for Flash (or AJAX) websites?
I guess the established practice is to set and read a hash-addition to the URL like</p>
<pre><code>http://example.com/#id=1
</code></pre>
<p>I am aware of the Flex History Manager, but was wondering if there are any good alter... | [
{
"answer_id": 266654,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 2,
"selected": false,
"text": "<p>For AJAX, something like <a href=\"http://code.google.com/p/reallysimplehistory/\" rel=\"nofollow noreferrer\">Real... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23069/"
] | What is the best tool / practice to enable browser history for Flash (or AJAX) websites?
I guess the established practice is to set and read a hash-addition to the URL like
```
http://example.com/#id=1
```
I am aware of the Flex History Manager, but was wondering if there are any good alternatives to consider. Would... | I've used [swfadress](http://www.asual.com/swfaddress/) for some small stuff. |
266,648 | <p>How can I check if a file uploaded by a user is a real jpg file in Python (Google App Engine)?</p>
<p>This is how far I got by now:</p>
<p>Script receives image via HTML Form Post and is processed by the following code</p>
<pre><code>...
incomming_image = self.request.get("img")
image = db.Blob(incomming_image)
.... | [
{
"answer_id": 266731,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stackoverflow.com/users/9493",
"pm_score": 6,
"selected": true,
"text": "<p>If you need more than looking at extension, one way would be to read the JPEG header, and check that it matches valid data. ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26763/"
] | How can I check if a file uploaded by a user is a real jpg file in Python (Google App Engine)?
This is how far I got by now:
Script receives image via HTML Form Post and is processed by the following code
```
...
incomming_image = self.request.get("img")
image = db.Blob(incomming_image)
...
```
I found mimetypes.g... | If you need more than looking at extension, one way would be to read the JPEG header, and check that it matches valid data. The format for this is:
```
Start Marker | JFIF Marker | Header Length | Identifier
0xff, 0xd8 | 0xff, 0xe0 | 2-bytes | "JFIF\0"
```
so a quick recogniser would be:
```
def is_jpg(f... |
266,652 | <p>We are trying to build a Crystal Report that sends control characters directly to the printer, without going through the (buggy) Windows driver for that printer. Does anyone know a way to do this from within a Crystal Report? </p>
<p>The specific control character we are trying to send is CHR(2). However when we pu... | [
{
"answer_id": 266731,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stackoverflow.com/users/9493",
"pm_score": 6,
"selected": true,
"text": "<p>If you need more than looking at extension, one way would be to read the JPEG header, and check that it matches valid data. ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20068/"
] | We are trying to build a Crystal Report that sends control characters directly to the printer, without going through the (buggy) Windows driver for that printer. Does anyone know a way to do this from within a Crystal Report?
The specific control character we are trying to send is CHR(2). However when we put that in ... | If you need more than looking at extension, one way would be to read the JPEG header, and check that it matches valid data. The format for this is:
```
Start Marker | JFIF Marker | Header Length | Identifier
0xff, 0xd8 | 0xff, 0xe0 | 2-bytes | "JFIF\0"
```
so a quick recogniser would be:
```
def is_jpg(f... |
266,664 | <p>What's the easiest method people have found to monitor memcached on Windows? One method I've tried, which works decently:</p>
<p>telnet into the memcached port (11211) and enter the "stats" command. You'll get back a listing like this:</p>
<pre><code>stats
STAT pid 2816
STAT uptime 791
STAT time 1225918895
STAT ve... | [
{
"answer_id": 266678,
"author": "dove",
"author_id": 30913,
"author_profile": "https://Stackoverflow.com/users/30913",
"pm_score": 0,
"selected": false,
"text": "<p>I've worked with memcached on windows and found this to be one of the main drawbacks. It's surprising better tools have n... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/109/"
] | What's the easiest method people have found to monitor memcached on Windows? One method I've tried, which works decently:
telnet into the memcached port (11211) and enter the "stats" command. You'll get back a listing like this:
```
stats
STAT pid 2816
STAT uptime 791
STAT time 1225918895
STAT version 1.2.1
STAT poin... | The PHP Memcached module also includes [a script](http://svn.php.net/viewvc/pecl/apc/trunk/apc.php?view=markup) that will display the stats in summary, and also graph form, as well as being able to view individual cached items. If you are already using PHP & memcache on windows, it's an almost drop-in solution. |
266,665 | <p>I'm learning C++ and writing little programs as I go along. The following is one such program:</p>
<pre><code>// This program is intended to take any integer and convert to the
// corresponding signed char.
#include <iostream>
int main()
{
signed char sch = 0;
int n = 0;
while(true){
std::cin >... | [
{
"answer_id": 266699,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 2,
"selected": false,
"text": "<p>Given that you are on a 32 bit machine, 10000000000 is too big a number to be represented by an int. Also converting an int... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32944/"
] | I'm learning C++ and writing little programs as I go along. The following is one such program:
```
// This program is intended to take any integer and convert to the
// corresponding signed char.
#include <iostream>
int main()
{
signed char sch = 0;
int n = 0;
while(true){
std::cin >> n;
sch = n;
s... | Basically your `cin` stream is in a fail state and thus returns immediately when you try to read it. Rewrite your example like this:
```
#include <iostream>
int main()
{
signed char sch = 0;
int n = 0;
while(std::cin >> n){
sch = n;
std::cout << n << " --> " << sch << std::endl;
}
}
```
`cin >> n` w... |
266,681 | <p>I just realized that in some place in my code I have the return statement inside the lock and sometime outside. Which one is the best?</p>
<p>1)</p>
<pre><code>void example()
{
lock (mutex)
{
//...
}
return myData;
}
</code></pre>
<p>2)</p>
<pre><code>void example()
{
lock (mutex)
{
... | [
{
"answer_id": 266685,
"author": "Greg Beech",
"author_id": 13552,
"author_profile": "https://Stackoverflow.com/users/13552",
"pm_score": 5,
"selected": false,
"text": "<p>It doesn't make any difference; they're both translated to the same thing by the compiler.</p>\n\n<p>To clarify, eit... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] | I just realized that in some place in my code I have the return statement inside the lock and sometime outside. Which one is the best?
1)
```
void example()
{
lock (mutex)
{
//...
}
return myData;
}
```
2)
```
void example()
{
lock (mutex)
{
//...
return myData;
}
}
```
W... | Essentially, which-ever makes the code simpler. Single point of exit is a nice ideal, but I wouldn't bend the code out of shape just to achieve it... And if the alternative is declaring a local variable (outside the lock), initializing it (inside the lock) and then returning it (outside the lock), then I'd say that a s... |
266,688 | <p>As many do I have a config.php file in the root of a web app that I want to include in almost every other php file. So most of them have a line like:</p>
<pre><code>require_once("config.php");
</code></pre>
<p>or sometimes</p>
<pre><code>require_once("../config.php");
</code></pre>
<p>or even</p>
<pre><code>re... | [
{
"answer_id": 266707,
"author": "Thomas Owens",
"author_id": 572,
"author_profile": "https://Stackoverflow.com/users/572",
"pm_score": 0,
"selected": false,
"text": "<p>The only place I've seen the path evaluated from is the file that you are currently editing. I've never had any proble... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28565/"
] | As many do I have a config.php file in the root of a web app that I want to include in almost every other php file. So most of them have a line like:
```
require_once("config.php");
```
or sometimes
```
require_once("../config.php");
```
or even
```
require_once("../../config.php");
```
But I never get it righ... | The current working directory for PHP is the directory in which the called script file is located. If your files looked like this:
```
/A
foo.php
tar.php
B/
bar.php
```
If you call foo.php (ex: <http://example.com/foo.php>), the working directory will be /A/. If you call bar.php (ex: <http://example.... |
266,693 | <p>I'd like to remove all "unchecked" warnings from this general utility method (part of a larger class with a number of similar methods). In a pinch, I can use @SuppressWarnings("unchecked") but I'm wondering if I can use generics properly to avoid the warning.</p>
<p>The method is intended to be allow callers to c... | [
{
"answer_id": 266741,
"author": "jfpoilpret",
"author_id": 1440720,
"author_profile": "https://Stackoverflow.com/users/1440720",
"pm_score": -1,
"selected": false,
"text": "<p>Did you test the following?</p>\n\n<pre><code>public static <T> int compareObject(Comparable<T> o1,... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32978/"
] | I'd like to remove all "unchecked" warnings from this general utility method (part of a larger class with a number of similar methods). In a pinch, I can use @SuppressWarnings("unchecked") but I'm wondering if I can use generics properly to avoid the warning.
The method is intended to be allow callers to compare two o... | I just tried this:
```
public static <T extends Comparable> int compareObject(T o1, T o2) {
if ((o1 instanceof String) && (o2 instanceof String))
return ((String) o1).toUpperCase().compareTo(((String) o2).toUpperCase());
else
return o1.compareTo(o2);
}
```
It compiles, but gives a unchecked c... |
266,697 | <p>I have a stored procedure that has a optional parameter, <code>@UserID VARCHAR(50)</code>. The thing is, there are two ways to work with it:</p>
<ol>
<li>Give it a default value of <code>NULL</code>, the have an <code>IF...ELSE</code> clause, that performs two different <code>SELECT</code> queries, one with <code>'... | [
{
"answer_id": 266717,
"author": "Matt Rogish",
"author_id": 2590,
"author_profile": "https://Stackoverflow.com/users/2590",
"pm_score": 3,
"selected": false,
"text": "<p>What I typically do is something like</p>\n\n<pre><code>WHERE ( @UserID IS NULL OR UserID = @UserID )\n</code></pre>\... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8363/"
] | I have a stored procedure that has a optional parameter, `@UserID VARCHAR(50)`. The thing is, there are two ways to work with it:
1. Give it a default value of `NULL`, the have an `IF...ELSE` clause, that performs two different `SELECT` queries, one with `'WHERE UserID = @UserID'` and without the where.
2. Give it a d... | What I typically do is something like
```
WHERE ( @UserID IS NULL OR UserID = @UserID )
```
And why isn't it indexed? It's generally good form to index FKs, since you often join on them...
If you're worried about query plan storage, simply do:
CREATE PROCEDURE ... WITH RECOMPILE |
266,719 | <p>I've seen a lot of discussion on URL Routing, and LOTS of great suggestions... but in the real world, one thing I haven't seen discussed are: </p>
<ol>
<li>Creating Friendly URLs <strong>with Spaces and illegal characters</strong> </li>
<li>Querying the DB</li>
</ol>
<p>Say you're building a Medical site, which ha... | [
{
"answer_id": 266725,
"author": "Armstrongest",
"author_id": 26931,
"author_profile": "https://Stackoverflow.com/users/26931",
"pm_score": 0,
"selected": false,
"text": "<p>As a follow-up. I do have some ideas. So feel free to comment on the ideas or give your own answer to the questio... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26931/"
] | I've seen a lot of discussion on URL Routing, and LOTS of great suggestions... but in the real world, one thing I haven't seen discussed are:
1. Creating Friendly URLs **with Spaces and illegal characters**
2. Querying the DB
Say you're building a Medical site, which has **Articles** with a **Category** and optional... | I myself prefer \_ to - for readability reasons ( you put an underline on it and the `_`'s virtually go\_away ) , if you're going to strip spaces.
You may want to try casting extended characters, ie, ü , to close-ascii equivelants where possible, ie:
ü -> u
However, in my experience the biggest problem with *Actua... |
266,761 | <p>I'm pivoting data in MS SQL stored procedure. Columns which are pivoted are dynamically created using stored procedure parameter (for exampe: "location1,location2,location3,") so number of columns which will be generated is not known. Output should look like (where locations are taken from stored procedure parameter... | [
{
"answer_id": 266810,
"author": "bovium",
"author_id": 11135,
"author_profile": "https://Stackoverflow.com/users/11135",
"pm_score": 0,
"selected": false,
"text": "<p>You can create your linq object for access after your returned dataset.</p>\n\n<p>But would that really be of any use. L... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23280/"
] | I'm pivoting data in MS SQL stored procedure. Columns which are pivoted are dynamically created using stored procedure parameter (for exampe: "location1,location2,location3,") so number of columns which will be generated is not known. Output should look like (where locations are taken from stored procedure parameter):
... | Assuming truly dire dynamic need, you could use [DataContext.ExecuteQuery](http://msdn.microsoft.com/en-us/library/bb361109.aspx)
Just whip up a type that will cover the result space (the property names must match the column names in the query):
```
public class DynamicResult
{
public DateTime OrderDate {get;set;}
... |
266,771 | <p>I'm trying to figure out a way to detect files that are not opened for editing but have nevertheless been modified locally. <code>p4 fstat</code> returns a value <code>headModTime</code> for any given file, but this is the change time in the depot, which should not be equal to the filesystem's <code>stat</code> last... | [
{
"answer_id": 266813,
"author": "grieve",
"author_id": 34329,
"author_profile": "https://Stackoverflow.com/users/34329",
"pm_score": 6,
"selected": true,
"text": "<p>From: <a href=\"http://answers.perforce.com/articles/KB/3481/?q=disconnected&l=en_US&fs=Search&pn=1\" rel=\"n... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | I'm trying to figure out a way to detect files that are not opened for editing but have nevertheless been modified locally. `p4 fstat` returns a value `headModTime` for any given file, but this is the change time in the depot, which should not be equal to the filesystem's `stat` last modified time.
I'm hoping that the... | From: <http://answers.perforce.com/articles/KB/3481/?q=disconnected&l=en_US&fs=Search&pn=1>
See step 2 specifically:
---
2 . Next, open for "edit" any files that have changed:
```
p4 diff -se //myclient/... | p4 -x - edit
```
p4 diff -se returns the names of depot files whose corresponding client file differs in ... |
266,776 | <p>We have some methods that call File.Copy, File.Delete, File.Exists, etc. How can we test these methods without actually hitting the file system?</p>
<p>I consider myself a unit testing n00b, so any advice is appreciated.</p>
| [
{
"answer_id": 266783,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>If you absolutely have to do this, <a href=\"http://www.typemock.com/\" rel=\"nofollow noreferrer\">Typemock Isolator... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/681/"
] | We have some methods that call File.Copy, File.Delete, File.Exists, etc. How can we test these methods without actually hitting the file system?
I consider myself a unit testing n00b, so any advice is appreciated. | ```
public interface IFile {
void Copy(string source, string dest);
void Delete(string fn);
bool Exists(string fn);
}
public class FileImpl : IFile {
public virtual void Copy(string source, string dest) { File.Copy(source, dest); }
public virtual void Delete(string fn) { File.Delete(fn); }
publ... |
266,794 | <p>I'm trying to submit a form with javascript. Firefox works fine but IE complains that "Object doesn't support this property or method" on the submit line of this function:</p>
<pre><code>function submitPGV(formName, action)
{
var gvString = "";
pgVisibilities.each(function(pair) {
gvString += pair.... | [
{
"answer_id": 266822,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 0,
"selected": false,
"text": "<p>Are you sure you have your JavaScript library loaded? (jQuery or Prototype)</p>\n\n<p>It worked for ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34859/"
] | I'm trying to submit a form with javascript. Firefox works fine but IE complains that "Object doesn't support this property or method" on the submit line of this function:
```
function submitPGV(formName, action)
{
var gvString = "";
pgVisibilities.each(function(pair) {
gvString += pair.key + ":" + pa... | Try checking the type of the element IE is selecting:
```
// For getting element with id you must use #
alert( typeof( $( '#ProductGroupVisibility' )));
```
It is possible there is something else on the page with that ID that IE selects before the form. |
266,800 | <p>I have a C# class the returns a List, using System.Collections.Generic Lists not F# List</p>
<p>I want to iterate though the list to find a object or not find it. Here is how I would do it in C#. How would I accomplish the similar thing in F#</p>
<pre><code>foreach (AperioCaseObj caseObj in CaseList)
{
if (... | [
{
"answer_id": 267047,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 3,
"selected": true,
"text": "<p>See this example for iterating an integer generic list:</p>\n\n<pre><code>#light\nopen System.Collections.Gen... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/72123/"
] | I have a C# class the returns a List, using System.Collections.Generic Lists not F# List
I want to iterate though the list to find a object or not find it. Here is how I would do it in C#. How would I accomplish the similar thing in F#
```
foreach (AperioCaseObj caseObj in CaseList)
{
if (caseObj.CaseId == "")
... | See this example for iterating an integer generic list:
```
#light
open System.Collections.Generic
let genList = new List<int>()
genList.Add(1)
genList.Add(2)
genList.Add(3)
for x in genList do
printf "%d" x
``` |
266,803 | <p>I have several static factory patterns in my PHP library. However, memory footprint is getting out of hand and we want to reduce the number of files required during execution time. Here is an example of where we are today:</p>
<pre><code>require_once('Car.php');
require_once('Truck.php');
abstract class Auto
{
... | [
{
"answer_id": 266820,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 4,
"selected": true,
"text": "<p>The Autoload facility is often seen as Evil, but it works at these task quite nicely. </p>\n\n<p>If you can get a g... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20176/"
] | I have several static factory patterns in my PHP library. However, memory footprint is getting out of hand and we want to reduce the number of files required during execution time. Here is an example of where we are today:
```
require_once('Car.php');
require_once('Truck.php');
abstract class Auto
{
// ... some s... | The Autoload facility is often seen as Evil, but it works at these task quite nicely.
If you can get a good filesystem <-> classname mapping so you can, when given a class to provide, find it, then it will save you overhead and only load classes when needed.
It works for static classes too, so once the static class... |
266,805 | <p>I'm trying to get rid of some spurious warnings in my SSIS Progress log. I'm getting a bunch of warnings about unused columns in tasks that use raw SQL to do their work. I have a Data Flow responsible for archiving data in a staging table prior to loading new data. The Data Flow looks like this:</p>
<pre><code>+---... | [
{
"answer_id": 266816,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 3,
"selected": false,
"text": "<p>Union All - select only the columns you want to pass through - delete any others.</p>\n\n<p>I thought they were going... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34861/"
] | I'm trying to get rid of some spurious warnings in my SSIS Progress log. I'm getting a bunch of warnings about unused columns in tasks that use raw SQL to do their work. I have a Data Flow responsible for archiving data in a staging table prior to loading new data. The Data Flow looks like this:
```
+-----------------... | Union All - select only the columns you want to pass through - delete any others.
I thought they were going to address this in the 2008 version to allow columns to be trimmed/suppressed from the pipeline. |
266,806 | <p>Is there any performance reason to declare method parameters final in Java?</p>
<p>As in:</p>
<pre><code>public void foo(int bar) { ... }
</code></pre>
<p>Versus:</p>
<pre><code>public void foo(final int bar) { ... }
</code></pre>
<p>Assuming that <code>bar</code> is only read and never modified in <code>foo()<... | [
{
"answer_id": 266830,
"author": "branchgabriel",
"author_id": 30807,
"author_profile": "https://Stackoverflow.com/users/30807",
"pm_score": -1,
"selected": false,
"text": "<p>Compilers that operate after class loading, such as JIT compilers, can take advantage of final methods. Conseque... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | Is there any performance reason to declare method parameters final in Java?
As in:
```
public void foo(int bar) { ... }
```
Versus:
```
public void foo(final int bar) { ... }
```
Assuming that `bar` is only read and never modified in `foo()`. | The final keyword does not appear in the class file for local variables and parameters, thus it cannot impact the runtime performance. It's only use is to clarify the coders intent that the variable not be changed (which many consider dubious reason for its usage), and dealing with anonymous inner classes.
There is a ... |
266,818 | <p>I need to see if a string value matches with an object value, but why won't this work?</p>
<pre><code>public int countPacks(String flavour) {
int counter = 0;
for(int index = 0; index < packets.size(); index++) {
if (packets.equals(flavour)) {
counter ++;
}
... | [
{
"answer_id": 266827,
"author": "micro",
"author_id": 23275,
"author_profile": "https://Stackoverflow.com/users/23275",
"pm_score": 2,
"selected": false,
"text": "<p>You probably mean something like </p>\n\n<pre><code>if (packets.get(index).equals(flavour)) {\n ...\n</code></pre>\n"
... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to see if a string value matches with an object value, but why won't this work?
```
public int countPacks(String flavour) {
int counter = 0;
for(int index = 0; index < packets.size(); index++) {
if (packets.equals(flavour)) {
counter ++;
}
else {
... | What is "packets"? It's not going to be a string - so how would it equal a string?
I suspect you meant your test to be:
```
if (packets.get(index).equals(flavour))
```
However you're still going to print out "You have not entered a correct flavour" for every packet of the "wrong" flavour even if there's one with th... |
266,819 | <p>Where is the best place to add a method to the integer class in Rails?
I'd like to add a <code>to_meters</code> and <code>to_miles</code> methods.</p>
| [
{
"answer_id": 266840,
"author": "Zak",
"author_id": 2112692,
"author_profile": "https://Stackoverflow.com/users/2112692",
"pm_score": 2,
"selected": false,
"text": "<p>Normally (and logically), integers can't be converted to miles or to meters. It sounds like you may want to create a ne... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6705/"
] | Where is the best place to add a method to the integer class in Rails?
I'd like to add a `to_meters` and `to_miles` methods. | If you have your heart set on mucking with the Numeric (or integer, etc) class to get unit conversion, then at least do it logically and with some real value.
First, create a Unit class that stores the unit type (meters,feet, cubits, etc.) and the value on creation. Then add a bunch of methods to Numeric that corresp... |
266,825 | <p>I'd like to format a duration in seconds using a pattern like H:MM:SS. The current utilities in java are designed to format a time but not a duration.</p>
| [
{
"answer_id": 266846,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": true,
"text": "<p>If you're using a version of Java prior to 8... you can use <a href=\"http://joda-time.sourceforge.net/\" rel=\"norefe... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to format a duration in seconds using a pattern like H:MM:SS. The current utilities in java are designed to format a time but not a duration. | If you're using a version of Java prior to 8... you can use [Joda Time](http://joda-time.sourceforge.net/) and [`PeriodFormatter`](http://joda-time.sourceforge.net/api-release/org/joda/time/format/PeriodFormatter.html). If you've really got a duration (i.e. an elapsed amount of time, with no reference to a calendar sys... |
266,849 | <p>I'm conducting experiments regarding e-mail spam. One of these experiments require sending mail thru Tor. Since I'm using Python and smtplib for my experiments, I'm looking for a way to use the Tor proxy (or other method) to perform that mail sending.
Ideas how this can be done?</p>
| [
{
"answer_id": 266846,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": true,
"text": "<p>If you're using a version of Java prior to 8... you can use <a href=\"http://joda-time.sourceforge.net/\" rel=\"norefe... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9941/"
] | I'm conducting experiments regarding e-mail spam. One of these experiments require sending mail thru Tor. Since I'm using Python and smtplib for my experiments, I'm looking for a way to use the Tor proxy (or other method) to perform that mail sending.
Ideas how this can be done? | If you're using a version of Java prior to 8... you can use [Joda Time](http://joda-time.sourceforge.net/) and [`PeriodFormatter`](http://joda-time.sourceforge.net/api-release/org/joda/time/format/PeriodFormatter.html). If you've really got a duration (i.e. an elapsed amount of time, with no reference to a calendar sys... |
266,854 | <p>I frequently run into large, non-template classes in C++ where simple methods are defined directly in the class body in the header file instead of separately in the implementation file. For example:</p>
<pre><code>class Foo {
int getBar() const { return bar; }
...
};
</code></pre>
<p>Why do this? It seems like... | [
{
"answer_id": 266858,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>You answered your own question, they are indeed inline methods.</p>\n\n<p>Reasons to use them are performance. </p... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1891/"
] | I frequently run into large, non-template classes in C++ where simple methods are defined directly in the class body in the header file instead of separately in the implementation file. For example:
```
class Foo {
int getBar() const { return bar; }
...
};
```
Why do this? It seems like there are disadvantages. ... | The C++ standard says that methods defined inside the class definition are `inline` by default. This results in obvious performance gains for simplistic functions such as getters and setters. Link-time cross-module optimization is harder, although some compilers can do it. |
266,857 | <p>I'm writing a Rails plugin that includes some partials. I'd like to test the partials, but I'm having a hard time setting up a test that will render them. There's no associated controller, so I'm just faking one:</p>
<pre><code>require 'action_controller'
require 'active_support'
require 'action_pack'
require 'ac... | [
{
"answer_id": 266876,
"author": "danpickett",
"author_id": 21788,
"author_profile": "https://Stackoverflow.com/users/21788",
"pm_score": 2,
"selected": false,
"text": "<p>checkout ActionView::TestCase - <a href=\"http://api.rubyonrails.org/classes/ActionView/TestCase.html\" rel=\"nofoll... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I'm writing a Rails plugin that includes some partials. I'd like to test the partials, but I'm having a hard time setting up a test that will render them. There's no associated controller, so I'm just faking one:
```
require 'action_controller'
require 'active_support'
require 'action_pack'
require 'action_view'
clas... | The final answer:
```
require 'action_controller'
require 'active_support'
require 'action_pack'
require 'action_view'
require 'action_controller/test_case'
class StubController < ActionController::Base
helper MyHelper
append_view_path '...'
attr_accessor :thing
def my_partial
render :partial => '/my_part... |
266,874 | <p>I'm setting the below variables in my vimrc to control how windows get split when I bring up the file explorer plugin for vim. But it appears these variables are not being read because they have no effect on how the file explorer window is displayed. I'm new to vim. I know the vimrc file is being read because I can ... | [
{
"answer_id": 266904,
"author": "grieve",
"author_id": 34329,
"author_profile": "https://Stackoverflow.com/users/34329",
"pm_score": 0,
"selected": false,
"text": "<p>Create a gvimrc right beside your vimrc file and add those settings in there.</p>\n"
},
{
"answer_id": 269952,
... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16973/"
] | I'm setting the below variables in my vimrc to control how windows get split when I bring up the file explorer plugin for vim. But it appears these variables are not being read because they have no effect on how the file explorer window is displayed. I'm new to vim. I know the vimrc file is being read because I can mak... | Wherever you got those settings from is outdated. They were valid in vim 6.x, but not 7.x.
For 7.x, use the following settings instead:
```
let g:netrw_winsize=10
let g:netrw_alto=1
```
There is no option for disabling "detailed help" that I can find, but the help provided by netrw in v6 vs v7 is quite different an... |
266,877 | <p>I have a very specific html table construct that seems to reveal a Gecko bug.</p>
<p>Here's a distilled version of the problem. Observe the following table in a gecko-based browser (FF, for example): (you'll have to copy and paste this into a new file)</p>
<pre><code><style>
table.example{
border-colla... | [
{
"answer_id": 266906,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": true,
"text": "<p>Strange... definitely a painting bug. If you right-click to get the context menu to appear over <em>part</em> of where the... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34832/"
] | I have a very specific html table construct that seems to reveal a Gecko bug.
Here's a distilled version of the problem. Observe the following table in a gecko-based browser (FF, for example): (you'll have to copy and paste this into a new file)
```
<style>
table.example{
border-collapse:collapse;
}
table.example... | Strange... definitely a painting bug. If you right-click to get the context menu to appear over *part* of where the line should be, then when you dismiss the context menu, the line has been redrawn underneath.
Edit: Workaround - if you put `style="border-color: ...;"` on the `<td rowspan="3">` you can get the border t... |
266,888 | <p>I have a situation where I want to copy the output assembly from one project into the output directory of my target application using MSBuild, without hard-coding paths in my MSBuild Copy task. Here's the scenario:</p>
<ul>
<li>Project A - Web Application Project</li>
<li>Project B - Dal Interface Project</li>
<li>... | [
{
"answer_id": 266956,
"author": "Andrew Van Slaars",
"author_id": 8087,
"author_profile": "https://Stackoverflow.com/users/8087",
"pm_score": 4,
"selected": true,
"text": "<p>I have made this work, though I would love to find a cleaner solution that takes advanctage of the built-in para... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8087/"
] | I have a situation where I want to copy the output assembly from one project into the output directory of my target application using MSBuild, without hard-coding paths in my MSBuild Copy task. Here's the scenario:
* Project A - Web Application Project
* Project B - Dal Interface Project
* Project C - Dal Implementati... | I have made this work, though I would love to find a cleaner solution that takes advanctage of the built-in parameters within MSBuild (like $(TargetDir), etc but to point at the project I want to grab the output for). Anyway, here is what I've done:
```
<Target Name="AfterBuild">
<Copy SourceFiles="$(SolutionDir)MyPro... |
266,901 | <p>Just wondering if there is any way to do the following:</p>
<pre><code>public Interface IDataField
{
object GetValue();
}
public Interface IComplexDataField : IDataField
{
object GetDefaultValue();
}
public class MyBase
{
private IDataField _DataField;
public MyBase()
{
this._DataFie... | [
{
"answer_id": 266911,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>What you want is <em>covariance of return types</em>. This doesn't exist in C#.</p>\n\n<p>Could you perhaps make <cod... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30572/"
] | Just wondering if there is any way to do the following:
```
public Interface IDataField
{
object GetValue();
}
public Interface IComplexDataField : IDataField
{
object GetDefaultValue();
}
public class MyBase
{
private IDataField _DataField;
public MyBase()
{
this._DataField = this.Crea... | What you want is *covariance of return types*. This doesn't exist in C#.
Could you perhaps make `MyBase` generic:
```
public class MyBase<T> where T : IDataField
{
public virtual T CreateDataField()
{
... etc ...
}
}
```
Alternatively, you can redeclare the method with "new" and shadow the base ... |
266,903 | <p>How can I create an instance of the following annotation (with all fields set to their default value).</p>
<pre><code> @Retention( RetentionPolicy.RUNTIME )
public @interface Settings {
String a() default "AAA";
String b() default "BBB";
String c() default "CCC";
}
</c... | [
{
"answer_id": 266945,
"author": "Florin",
"author_id": 34565,
"author_profile": "https://Stackoverflow.com/users/34565",
"pm_score": 1,
"selected": false,
"text": "<p>If used with a method:</p>\n\n<pre><code>@Settings\npublic void myMethod() {\n}\n</code></pre>\n\n<p>Now your annotation... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24468/"
] | How can I create an instance of the following annotation (with all fields set to their default value).
```
@Retention( RetentionPolicy.RUNTIME )
public @interface Settings {
String a() default "AAA";
String b() default "BBB";
String c() default "CCC";
}
```
I tried `ne... | You cannot create an instance, but at least get the default values
```
Settings.class.getMethod("a").getDefaultValue()
Settings.class.getMethod("b").getDefaultValue()
Settings.class.getMethod("c").getDefaultValue()
```
And then, a dynamic proxy could be used to return the default values. Which is, as far as I can te... |
266,923 | <p>In C# which is more memory efficient: Option #1 or Option #2?</p>
<pre><code>public void TestStringBuilder()
{
//potentially a collection with several hundred items:
string[] outputStrings = new string[] { "test1", "test2", "test3" };
//Option #1
StringBuilder formattedOutput = new StringBuilder();... | [
{
"answer_id": 266929,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 0,
"selected": false,
"text": "<p>I'd say option #2 if definitely more straightforward. In terms of performance, sounds like something you'd just need to t... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9711/"
] | In C# which is more memory efficient: Option #1 or Option #2?
```
public void TestStringBuilder()
{
//potentially a collection with several hundred items:
string[] outputStrings = new string[] { "test1", "test2", "test3" };
//Option #1
StringBuilder formattedOutput = new StringBuilder();
foreach (... | Several of the answers gently suggested that I get off my duff and figure out it myself so below are my results. I think that sentiment generally goes against the grain of this site but if you want something done right, you might as well do.... :)
I modified option #1 to take advantage of @Ty suggestion to use StringB... |
266,924 | <p>I am trying to convert a date with individual parts such as 12, 1, 2007 into a datetime in SQL Server 2005. I have tried the following:</p>
<pre><code>CAST(DATEPART(year, DATE)+'-'+ DATEPART(month, DATE) +'-'+ DATEPART(day, DATE) AS DATETIME)
</code></pre>
<p>but this results in the wrong date. What is the correct... | [
{
"answer_id": 266934,
"author": "devio",
"author_id": 21336,
"author_profile": "https://Stackoverflow.com/users/21336",
"pm_score": 4,
"selected": false,
"text": "<p>Try CONVERT instead of CAST.</p>\n\n<p>CONVERT allows a third parameter indicating the date format.</p>\n\n<p>List of for... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23133/"
] | I am trying to convert a date with individual parts such as 12, 1, 2007 into a datetime in SQL Server 2005. I have tried the following:
```
CAST(DATEPART(year, DATE)+'-'+ DATEPART(month, DATE) +'-'+ DATEPART(day, DATE) AS DATETIME)
```
but this results in the wrong date. What is the correct way to turn the three dat... | Assuming `y, m, d` are all `int`, how about:
```
CAST(CAST(y AS varchar) + '-' + CAST(m AS varchar) + '-' + CAST(d AS varchar) AS DATETIME)
```
Please see [my other answer](https://stackoverflow.com/a/10142966/18255) for SQL Server 2012 and above |
266,927 | <p>I receive an error message when exposing an ADO.NET Data Service using an Entity Framework data model that contains an entity (called "Case") with an internal setter on a property. If I modify the setter to be public (using the entity designer), the data services works fine.</p>
<p>I don’t need the entity "Case" ex... | [
{
"answer_id": 421500,
"author": "ggponti",
"author_id": 6840,
"author_profile": "https://Stackoverflow.com/users/6840",
"pm_score": 0,
"selected": false,
"text": "<p>I had a similar problem, and it was caused by passing the wrong class to DataService. You need to pass the data entities ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33496/"
] | I receive an error message when exposing an ADO.NET Data Service using an Entity Framework data model that contains an entity (called "Case") with an internal setter on a property. If I modify the setter to be public (using the entity designer), the data services works fine.
I don’t need the entity "Case" exposed in t... | I recently ran into a similar issue, and the fix in my case was changinghe the name of the EntitySetAccessRule to "\*", like this:
```
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.DataServiceBehavior.MaxProtocolVersion = Dat... |
266,931 | <p>It seems that nginx is used with php, ruby and python. </p>
<p>Anyone has an example of how to setup nginx to work with jetty/tomcat in backend? </p>
<p>Thanks.</p>
| [
{
"answer_id": 267072,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 4,
"selected": true,
"text": "<p>nginx can forward via HTTP protocol, so just point it to the correct port and you're set:</p>\n\n<pre><code>server {\n ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34565/"
] | It seems that nginx is used with php, ruby and python.
Anyone has an example of how to setup nginx to work with jetty/tomcat in backend?
Thanks. | nginx can forward via HTTP protocol, so just point it to the correct port and you're set:
```
server {
location /anything {
proxy_pass http://localhost:8080/whatever;
}
}
``` |
266,988 | <p>I'm working on a Facebook FBML controls library and would like to create my FBML controls somewhat patterned like the ASP.NET WebControls library. I have a base class that handles rendering by default; here's my render method:</p>
<pre><code>
protected override void Render(HtmlTextWriter writer)
{
... | [
{
"answer_id": 270417,
"author": "Jason Hernandez",
"author_id": 34863,
"author_profile": "https://Stackoverflow.com/users/34863",
"pm_score": 4,
"selected": true,
"text": "<p>This should get you going - it will render as <code><fb:name uid=\"00101010101\"/></code>. You could also ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34224/"
] | I'm working on a Facebook FBML controls library and would like to create my FBML controls somewhat patterned like the ASP.NET WebControls library. I have a base class that handles rendering by default; here's my render method:
```
protected override void Render(HtmlTextWriter writer)
{
Add... | This should get you going - it will render as `<fb:name uid="00101010101"/>`. You could also override the RenderBeginTag, RenderContents, RenderEndTag. Depending on what you are doing there may be some other things going on in RenderControl that you need. You could also look into using a ControlAdapter, this may give y... |
266,997 | <p>I'm trying to extract all matches from a EBML definition, which is something like this:</p>
<pre><code>| + A track
| + Track number: 3
| + Track UID: 724222477
| + Track type: subtitles
...
| + Language: eng
...
| + A track
| + Track number: 4
| + Track UID: 745646561
| + Track type: subtitles
...
| + Langu... | [
{
"answer_id": 267007,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 2,
"selected": false,
"text": "<p>You need to use a lazy quantifier instead of <code>.*</code>. Try this:</p>\n\n<pre><code>/Track type: subtitle... | 2008/11/05 | [
"https://Stackoverflow.com/questions/266997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16957/"
] | I'm trying to extract all matches from a EBML definition, which is something like this:
```
| + A track
| + Track number: 3
| + Track UID: 724222477
| + Track type: subtitles
...
| + Language: eng
...
| + A track
| + Track number: 4
| + Track UID: 745646561
| + Track type: subtitles
...
| + Language: jpn
...
... | You need to make your regex non-greedy by changing this:
```
.*
```
To this:
```
.*?
```
Your regex is matching from the first occurence of `Track type: subtitles` to the last occurence of `Language: (\w\w\w)`. Making it non-greedy will work because it matches as few characters as possible. |
267,001 | <p>I'm trying to save the output of an vector image drawin in Java2D to an SWF file. There are great libraries for saving java2D output as things like SVG (BATIK) and PDF(itext) but I can't find one for SWF. Any ideas?</p>
| [
{
"answer_id": 267023,
"author": "rmeador",
"author_id": 10861,
"author_profile": "https://Stackoverflow.com/users/10861",
"pm_score": 1,
"selected": false,
"text": "<p>Flash generally uses SVG as its native format. You could export to SVG and then write a trivial Flash program to embed... | 2008/11/05 | [
"https://Stackoverflow.com/questions/267001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34888/"
] | I'm trying to save the output of an vector image drawin in Java2D to an SWF file. There are great libraries for saving java2D output as things like SVG (BATIK) and PDF(itext) but I can't find one for SWF. Any ideas? | I just got an example to work using the [SpriteGraphics2D](http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/modules/swfutils/src/java/flash/graphics/g2d/SpriteGraphics2D.java) object from [Adobe's Flex 3](http://opensource.adobe.com/wiki/display/flexsdk/Downloads). FYI... Flex 3 is now open source.
>
> *(fro... |
267,006 | <p>My new ASP.NET MVC Web Application works on my development workstation, but does not run on my web server...</p>
<hr>
<h1>Server Error in '/' Application.</h1>
<hr>
<h2>Configuration Error</h2>
<p><strong>Description:</strong> An error occurred during the processing of a configuration file required to service t... | [
{
"answer_id": 267020,
"author": "Matt Rudder",
"author_id": 29715,
"author_profile": "https://Stackoverflow.com/users/29715",
"pm_score": 5,
"selected": false,
"text": "<p>Installing MVC directly on your web server is one option, as then the assemblies will be installed in the GAC. You ... | 2008/11/05 | [
"https://Stackoverflow.com/questions/267006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | My new ASP.NET MVC Web Application works on my development workstation, but does not run on my web server...
---
Server Error in '/' Application.
================================
---
Configuration Error
-------------------
**Description:** An error occurred during the processing of a configuration file required to... | I just wrote a blog post addressing this. You could install ASP.NET MVC on your server OR you can follow the [steps here](http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx).
---
**EDIT:** (by jcolebrand) I went through this link, then had the same issue as [Victor](https://stackoverflow.com/users/653855... |
267,011 | <p>I'm trying to understand what this method means as I'm reading <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getpostbackeventreference.aspx" rel="noreferrer">this</a> and have wondered what uses this may have. I don't quite understand the example given.</p>
<p>Can anyone give an... | [
{
"answer_id": 267246,
"author": "stevemegson",
"author_id": 25028,
"author_profile": "https://Stackoverflow.com/users/25028",
"pm_score": 4,
"selected": true,
"text": "<p>The simplest example is a LinkButton. Drop one in a page and look at the HTML it generates. You'll see something lik... | 2008/11/05 | [
"https://Stackoverflow.com/questions/267011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5853/"
] | I'm trying to understand what this method means as I'm reading [this](http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getpostbackeventreference.aspx) and have wondered what uses this may have. I don't quite understand the example given.
Can anyone give another explanation of it. Examples woul... | The simplest example is a LinkButton. Drop one in a page and look at the HTML it generates. You'll see something like.
```
href="javascript:__doPostBack('ctl00$LinkButton1','')"
```
GetPostBackEventReference allows you to get that piece of JavaScript, so that you can trigger that postback from elsewhere. However you... |
267,026 | <p>This very simple code gives me tons of errors:</p>
<pre><code>#include <iostream>
#include <string>
int main() {
std::string test = " ";
std::cout << test;
}
</code></pre>
<p>I tried to compile it on linux by typing <strong>gcc -o simpletest simpletest.cpp</strong> on the console. I can'... | [
{
"answer_id": 267031,
"author": "rmeador",
"author_id": 10861,
"author_profile": "https://Stackoverflow.com/users/10861",
"pm_score": 0,
"selected": false,
"text": "<p>You declared your <code>main()</code> as returning an <code>int</code> yet you have no return statement. Add <code>ret... | 2008/11/05 | [
"https://Stackoverflow.com/questions/267026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27090/"
] | This very simple code gives me tons of errors:
```
#include <iostream>
#include <string>
int main() {
std::string test = " ";
std::cout << test;
}
```
I tried to compile it on linux by typing **gcc -o simpletest simpletest.cpp** on the console. I can't see why it isn't working. What is happening? | Try using 'g++' instead of 'gcc'. |
267,030 | <p>I'm needing to script my build. I'm using MSBUILD because of it's integration with VS.net. I am trying to copy some files from the build environment to the deployment folder. I'm using the copy task of MSBuild. But instead of copying the directory tree as I would expect. it copies all the contents into a single fol... | [
{
"answer_id": 267088,
"author": "minty",
"author_id": 4491,
"author_profile": "https://Stackoverflow.com/users/4491",
"pm_score": 2,
"selected": false,
"text": "<p>I found the example in one of the examples in <a href=\"http://msdn.microsoft.com/en-us/library/3e54c37h.aspx\" rel=\"nofol... | 2008/11/05 | [
"https://Stackoverflow.com/questions/267030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] | I'm needing to script my build. I'm using MSBUILD because of it's integration with VS.net. I am trying to copy some files from the build environment to the deployment folder. I'm using the copy task of MSBuild. But instead of copying the directory tree as I would expect. it copies all the contents into a single folder.... | When you specify the DestinationFolder for the Copy task, it takes all items from the SourceFiles collection and copies them to the DestinationFolder. This is expected, as there is no way for the Copy task to figure out what part of each item's path needs to be replaced with the DestinationFolder in order to keep the t... |
267,033 | <p>Say I have a list of all <code>Projects</code>, and that I group them by <code>Category</code> like this:</p>
<pre><code>var projectsByCat = from p in Projects
group p by p.Category into g
orderby g.Count() descending
select new { Category = g.Key, Projects... | [
{
"answer_id": 267053,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 7,
"selected": true,
"text": "<p>If you're using LINQ to SQL or LINQ to Entities you should first fully materialize the results into memory:</p>\n\n<pr... | 2008/11/05 | [
"https://Stackoverflow.com/questions/267033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2122/"
] | Say I have a list of all `Projects`, and that I group them by `Category` like this:
```
var projectsByCat = from p in Projects
group p by p.Category into g
orderby g.Count() descending
select new { Category = g.Key, Projects = g };
```
Now I want to display... | If you're using LINQ to SQL or LINQ to Entities you should first fully materialize the results into memory:
```
var oddCategories = projectsByCat.ToList().Where((c,i) => i % 2 != 0);
var evenCategories = projectsByCat.ToList().Where((c,i) => i % 2 == 0);
```
It isn't possible to iterate through results on the datab... |
267,057 | <p>I hope someone can help me with this, I'm mostly a C# developer so my
C and C++ skills are bad. I have a native C dll that is a plugin of a
larger application. I cross compile this dll for windows on linux
using gcc.</p>
<p>In the native dll when I create a D3DSurface I want to call a function
in a Mixed Mode C++... | [
{
"answer_id": 267348,
"author": "Joel Lucsy",
"author_id": 645,
"author_profile": "https://Stackoverflow.com/users/645",
"pm_score": 2,
"selected": false,
"text": "<p>Have you looked into <a href=\"http://en.wikipedia.org/wiki/Microsoft_XNA\" rel=\"nofollow noreferrer\">Microsoft XNA</a... | 2008/11/05 | [
"https://Stackoverflow.com/questions/267057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I hope someone can help me with this, I'm mostly a C# developer so my
C and C++ skills are bad. I have a native C dll that is a plugin of a
larger application. I cross compile this dll for windows on linux
using gcc.
In the native dll when I create a D3DSurface I want to call a function
in a Mixed Mode C++ dll and pas... | Have you looked into [Microsoft XNA](http://en.wikipedia.org/wiki/Microsoft_XNA)? It supposedly has managed wrappers for DirectX. |