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 |
|---|---|---|---|---|---|---|
285,521 | <p>I am making a post from a .NET console app to a .NET web service. I know that the timeout on the server side is 20 min, but if my client takes more than 100 seconds to post my data to that service then I get a timeout exception. How would I tell my client to wait the available 20 min to timeout?</p>
| [
{
"answer_id": 285536,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 3,
"selected": false,
"text": "<p>on the client side, your webservice object has a timeout value. It should be pretty easy to set by going:</p>\n\n<pre><code>... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13593/"
] | I am making a post from a .NET console app to a .NET web service. I know that the timeout on the server side is 20 min, but if my client takes more than 100 seconds to post my data to that service then I get a timeout exception. How would I tell my client to wait the available 20 min to timeout? | on the client side, your webservice object has a timeout value. It should be pretty easy to set by going:
```
myServiceInstance.Timeout = 1200000
```
for 20 minutes |
285,522 | <p>Let's say I have an html form. Each input/select/textarea will have a corresponding <code><label></code> with the <code>for</code> attribute set to the id of it's companion. In this case, I know that each input will only have a single label.</p>
<p>Given an input element in javascript — via an onkeyup ... | [
{
"answer_id": 285560,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": false,
"text": "<p>Earlier...</p>\n\n<pre><code>var labels = document.getElementsByTagName(\"LABEL\"),\n lookup = {},\n i, label;\n\... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] | Let's say I have an html form. Each input/select/textarea will have a corresponding `<label>` with the `for` attribute set to the id of it's companion. In this case, I know that each input will only have a single label.
Given an input element in javascript — via an onkeyup event, for example — what's the best way to f... | First, scan the page for labels, and assign a reference to the label from the actual form element:
```
var labels = document.getElementsByTagName('LABEL');
for (var i = 0; i < labels.length; i++) {
if (labels[i].htmlFor != '') {
var elem = document.getElementById(labels[i].htmlFor);
if (elem)
... |
285,523 | <p>Is there a way to determine if the loop is iterating for the last time. My code looks something like this:</p>
<pre><code>int[] array = {1, 2, 3...};
StringBuilder builder = new StringBuilder();
for(int i : array)
{
builder.append("" + i);
if(!lastiteration)
builder.append(",");
}
</code></pre>
<p... | [
{
"answer_id": 285530,
"author": "Dinah",
"author_id": 356,
"author_profile": "https://Stackoverflow.com/users/356",
"pm_score": 5,
"selected": false,
"text": "<p>It might be easier to always append. And then, when you're done with your loop, just remove the final character. Tons less co... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36858/"
] | Is there a way to determine if the loop is iterating for the last time. My code looks something like this:
```
int[] array = {1, 2, 3...};
StringBuilder builder = new StringBuilder();
for(int i : array)
{
builder.append("" + i);
if(!lastiteration)
builder.append(",");
}
```
Now the thing is I don't ... | Another alternative is to append the comma before you append i, just not on the *first* iteration. (Please don't use `"" + i`, by the way - you don't really want concatenation here, and StringBuilder has a perfectly good append(int) overload.)
```
int[] array = {1, 2, 3...};
StringBuilder builder = new StringBuilder()... |
285,524 | <p>With the following code:</p>
<pre><code>Dim x As System.Xml.Linq.XElement = _
<div>
<%= message.ToString() %>
</div>
Dim m = x.ToString()
</code></pre>
<p>...if message is HTML, then the < and > characters get converted to <code>&lt;</code> and <code>&rt;</code>. </p>
<p>How can I fo... | [
{
"answer_id": 286045,
"author": "Brody",
"author_id": 17131,
"author_profile": "https://Stackoverflow.com/users/17131",
"pm_score": 1,
"selected": false,
"text": "<p>You need to open the HTML snippit as an XML document and append the document node to the Div node you are creating.</p>\n... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] | With the following code:
```
Dim x As System.Xml.Linq.XElement = _
<div>
<%= message.ToString() %>
</div>
Dim m = x.ToString()
```
...if message is HTML, then the < and > characters get converted to `<` and `&rt;`.
How can I force it to skip this encoding? | What is the type of your `message` variable? If `message` is an `XElement`, then just leave off the `.ToString` call like this:
```
Dim x As System.Xml.Linq.XElement = _
<div>
<%= message %>
</div>
Dim m = x.ToString()
```
If `message` is some other type (like `StringBuilder`), then do this:
```
Dim... |
285,572 | <p>I've previously encountered the suggestion to call System.Threading.Thread.Sleep(0); in tights loops in C# to prevent CPU hogging and used it to good effect.</p>
<p>I have a PowerShell script that has a tight loop and I'm wondering whether I should be calling [Thread]::Sleep(0) or Start-Sleep 0 or whether the PS en... | [
{
"answer_id": 285831,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I would recommend to use Thread.SpinWait(20). It works well on Intel HT boxes.\nThe advanced way is to check the number of ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20819/"
] | I've previously encountered the suggestion to call System.Threading.Thread.Sleep(0); in tights loops in C# to prevent CPU hogging and used it to good effect.
I have a PowerShell script that has a tight loop and I'm wondering whether I should be calling [Thread]::Sleep(0) or Start-Sleep 0 or whether the PS engine will ... | I find there are a couple of problems with explicitly yielding a thread via .Sleep() or other means when you are just making sure it doesn't take over the processor. The first is that it just makes your code look poor as it's sprinkled with Thread.Sleep(0). You can comment every instance but it doesn't look great.
The... |
285,579 | <p>I'm fairly new to c# so that's why I'm asking this here.</p>
<p>I am consuming a web service that returns a long string of XML values. Because this is a string all the attributes have escaped double quotes</p>
<pre><code>string xmlSample = "<root><item att1=\"value\" att2=\"value2\" /></root>"
</... | [
{
"answer_id": 285603,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 2,
"selected": false,
"text": "<p>Both the string and the regex uses <code>\\</code> for escaping. The regex will see the character <code>\\</cod... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30408/"
] | I'm fairly new to c# so that's why I'm asking this here.
I am consuming a web service that returns a long string of XML values. Because this is a string all the attributes have escaped double quotes
```
string xmlSample = "<root><item att1=\"value\" att2=\"value2\" /></root>"
```
Here is my problem. I want to do a ... | the following statement in C#
```
string xmlSample = "<root><item att1=\"value\" att2=\"value2\" /></root>"
```
will actually store the value
```
<root><item att1="value" att2="value2" /></root>
```
whereas
```
string xmlSample = @"<root><item att1=\""value\"" att2=\""value2\"" /></root>";
```
have the valu... |
285,584 | <p>I am currently stuck on an ASP.NET error when trying to access a .aspx page through localhost. This is the error:</p>
<p><strong>OCIEnvCreate failed with return code -1 but error message text was not available.</strong></p>
<p><strong>Description</strong>: An unhandled exception occurred during the execution of th... | [
{
"answer_id": 858581,
"author": "Malcolm",
"author_id": 73700,
"author_profile": "https://Stackoverflow.com/users/73700",
"pm_score": 2,
"selected": false,
"text": "<p>I've come across the same problem with oracle 10g, from what I've read this error seems to mean that the .Net oracle dr... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37140/"
] | I am currently stuck on an ASP.NET error when trying to access a .aspx page through localhost. This is the error:
**OCIEnvCreate failed with return code -1 but error message text was not available.**
**Description**: An unhandled exception occurred during the execution of the current web request. Please review the st... | I've come across the same problem with oracle 10g, from what I've read this error seems to mean that the .Net oracle driver can't find the oracle client.
There are various suggestions to fix this, including checking the PATH and ORACLE\_HOME environment variables; re-installing the oracle client in the default locati... |
285,586 | <p>I have a script that constantly segfaults - the problem that I can't solve as segfault is in python libxml bindings - didn't write those. Ok, so in Linux I used to run an inf.loop so that when script dies - it restarts, like so:</p>
<pre><code>#!/bin/bash
while [ 1 ]
do
nice -n 19 python server.py
sleep 1
done
</co... | [
{
"answer_id": 285605,
"author": "Adam Jaskiewicz",
"author_id": 35322,
"author_profile": "https://Stackoverflow.com/users/35322",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure what shell FreeBSD uses by default, but it probably comes with a few. The man page for whatever shell ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37141/"
] | I have a script that constantly segfaults - the problem that I can't solve as segfault is in python libxml bindings - didn't write those. Ok, so in Linux I used to run an inf.loop so that when script dies - it restarts, like so:
```
#!/bin/bash
while [ 1 ]
do
nice -n 19 python server.py
sleep 1
done
```
Well, I can'... | /bin/sh almost certainly exists, but if you really need bash:
```
cd /usr/ports/*/bash
make install
```
that should install bash in /usr/local/bin/bash i believe |
285,587 | <p>When i do </p>
<pre><code>wnd = CreateWindow("EDIT", 0,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE |
ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN,
x, y, w, h,
parentWnd,
NULL, NULL, NULL);
</code></pre>
<p>everything is fine, however if i remove the WS_VSCROLL and WS_HSC... | [
{
"answer_id": 285757,
"author": "efotinis",
"author_id": 12320,
"author_profile": "https://Stackoverflow.com/users/12320",
"pm_score": 4,
"selected": true,
"text": "<p>Some control styles cannot be changed after window creation. The ES_AUTOHSCROLL style (which essentially controls word ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When i do
```
wnd = CreateWindow("EDIT", 0,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE |
ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN,
x, y, w, h,
parentWnd,
NULL, NULL, NULL);
```
everything is fine, however if i remove the WS\_VSCROLL and WS\_HSCROLL then do the below, ... | Some control styles cannot be changed after window creation. The ES\_AUTOHSCROLL style (which essentially controls word wrapping) is one of them; this is stated (somewhat indirectly) by the MSDN section on [Edit Control Styles](http://msdn.microsoft.com/en-us/library/bb775464.aspx). You can set the bits using SetWindow... |
285,591 | <p>Is it possible to use the __unused attribute macro on Objective-C object method parameters? I've tried placing it in various positions around the parameter declaration but it either causes a compilation error or seems to be ignored (i.e., the compiler still generates unused parameter warnings when compiling with -Wa... | [
{
"answer_id": 285702,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 2,
"selected": false,
"text": "<p>I can compile the following just fine:</p>\n\n<pre><code>- (NSString *) test:(__unused NSString *)test {\n ret... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34218/"
] | Is it possible to use the \_\_unused attribute macro on Objective-C object method parameters? I've tried placing it in various positions around the parameter declaration but it either causes a compilation error or seems to be ignored (i.e., the compiler still generates unused parameter warnings when compiling with -Wal... | Okay, I found the answer... it appears to be a bug with the implementation of Apple's gcc 4.0. Using gcc 4.2 it works as expected and the proper placement is the following:
```
-(void)someMethod:(id) __unused someParam;
```
It's documented in the Objective-C release notes if anyone is interested: <http://developer.a... |
285,614 | <p>Every night I need to trim back a table to only contain the latest 20,000 records. I could use a subquery:</p>
<pre><code>delete from table WHERE id NOT IN (select TOP 20000 ID from table ORDER BY date_added DESC)
</code></pre>
<p>But that seems inefficient, especially if we later decide to keep 50,000 records. ... | [
{
"answer_id": 285622,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 4,
"selected": true,
"text": "<p>If it just <em>seems</em> inefficient, I would make sure it is inefficient before I start barking up the wrong tree... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10876/"
] | Every night I need to trim back a table to only contain the latest 20,000 records. I could use a subquery:
```
delete from table WHERE id NOT IN (select TOP 20000 ID from table ORDER BY date_added DESC)
```
But that seems inefficient, especially if we later decide to keep 50,000 records. I'm using SQL 2005, and thou... | If it just *seems* inefficient, I would make sure it is inefficient before I start barking up the wrong tree.
Measure the time, cpu usage, disk I/O, etc. to see how well it performs. I think you'll find it performs better than you think. |
285,617 | <p>I'd like to call svn up from an asp.net page so people can hit the page to update a repository. (BTW: I'm using Beanstalk.com svn hosting which doesn't allow post-commit hooks, which is why I am doing it this way). </p>
<p>See what I've got below. The process starts (it shows up in Processes in Task Manager) and ex... | [
{
"answer_id": 286255,
"author": "JTew",
"author_id": 25372,
"author_profile": "https://Stackoverflow.com/users/25372",
"pm_score": 1,
"selected": false,
"text": "<p>You might be able to do this more effectively by using a .net SVN wrapper or library like this <a href=\"http://www.softec... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to call svn up from an asp.net page so people can hit the page to update a repository. (BTW: I'm using Beanstalk.com svn hosting which doesn't allow post-commit hooks, which is why I am doing it this way).
See what I've got below. The process starts (it shows up in Processes in Task Manager) and exits after ... | You can also use the Subversion library that comes with Ankh SVN.
I used it in a project to manage files in a Subversion repository and it worked well.
If you insist on using the command line client make sure you check the StandardError output for any error messages. Also make sure the user you run the process as has ... |
285,619 | <p>I have an input String say <code>Please go to http://stackoverflow.com</code>. The url part of the String is detected and an anchor <code><a href=""></a></code> is automatically added by many browser/IDE/applications. So it becomes <code>Please go to <a href='http://stackoverflow.com'>http://stacko... | [
{
"answer_id": 285667,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 3,
"selected": false,
"text": "<p>You could do something like this (adjust the regex to suit your needs):</p>\n\n<pre><code>String originalString = \"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37144/"
] | I have an input String say `Please go to http://stackoverflow.com`. The url part of the String is detected and an anchor `<a href=""></a>` is automatically added by many browser/IDE/applications. So it becomes `Please go to <a href='http://stackoverflow.com'>http://stackoverflow.com</a>`.
I need to do the same using J... | Use java.net.URL for that!!
---------------------------
Hey, why don't use the core class in java for this "java.net.URL" and let it validate the URL.
While the following code violates the golden principle "Use exception for exceptional conditions only" it does not make sense to me to try to reinvent the wheel for s... |
285,649 | <p>I have a web application that is using a data store that has it's own built in paging. The PagedResult class tells me the number of total pages. What I would like to do it (after binding my ASP.NET GridView) do this:</p>
<pre><code>MyGridView.PageCount = thePageCount;
</code></pre>
<p>And then have the GridView ma... | [
{
"answer_id": 285746,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 0,
"selected": false,
"text": "<p>You could create your own class that extends GridView and override the PageCount getter method to return the value f... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11917/"
] | I have a web application that is using a data store that has it's own built in paging. The PagedResult class tells me the number of total pages. What I would like to do it (after binding my ASP.NET GridView) do this:
```
MyGridView.PageCount = thePageCount;
```
And then have the GridView magically build the paginati... | To use the built-in paging the GridView interacts with the data source. The GridView has a settable property for PageSize.
If you use an ObjectDataSource, you configure both a SelectMethod and a SelectCountMethod. You could either modify your PagedResult class to return record count instead of page count, or wrap the ... |
285,658 | <p>Is there a way in FreeBSD to (being root) run a command as unprivileged user, like nobody? Kind of like reverse of sudo. Oh and considering that 'nobody' has /usr/sbin/nologin as shell - so <b>su</b> is not an option.</p>
| [
{
"answer_id": 285693,
"author": "DrStalker",
"author_id": 17007,
"author_profile": "https://Stackoverflow.com/users/17007",
"pm_score": 6,
"selected": true,
"text": "<p>sudo will allow you to run a command as another user.</p>\n\n<pre><code>sudo -u nobody <command>\n</code></pre>\... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37141/"
] | Is there a way in FreeBSD to (being root) run a command as unprivileged user, like nobody? Kind of like reverse of sudo. Oh and considering that 'nobody' has /usr/sbin/nologin as shell - so **su** is not an option. | sudo will allow you to run a command as another user.
```
sudo -u nobody <command>
```
will run as nobody, even if their login shell is not available. |
285,660 | <p>In Vim I can <code>:set wrapscan</code> so that when I do an incremental search, the cursor jumps to the first match whether the first match is above or below the cursor.</p>
<p>In Emacs, if I start a search via <code>C-s</code>, the search fails saying <em>Failing I-search</em> if the first match is above the curs... | [
{
"answer_id": 287067,
"author": "link0ff",
"author_id": 23952,
"author_profile": "https://Stackoverflow.com/users/23952",
"pm_score": 5,
"selected": true,
"text": "<p>The easiest way to do this is to use the following defadvice:</p>\n\n<pre><code>(defadvice isearch-repeat (after isearch... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23070/"
] | In Vim I can `:set wrapscan` so that when I do an incremental search, the cursor jumps to the first match whether the first match is above or below the cursor.
In Emacs, if I start a search via `C-s`, the search fails saying *Failing I-search* if the first match is above the cursor. If I hit `C-s` again it then wraps ... | The easiest way to do this is to use the following defadvice:
```
(defadvice isearch-repeat (after isearch-no-fail activate)
(unless isearch-success
(ad-disable-advice 'isearch-repeat 'after 'isearch-no-fail)
(ad-activate 'isearch-repeat)
(isearch-repeat (if isearch-forward 'forward))
(ad-enable-advi... |
285,662 | <pre><code>some_var = foo()
another_var = bar()
</code></pre>
<p>or</p>
<pre><code>some_var = foo()
another_var = bar()
</code></pre>
<p>Including changing the whitespace as lines are added or removed to keep them lined up. Does this really look good? Is it worth the mucking up of the diff?</p>
| [
{
"answer_id": 285672,
"author": "David Thornley",
"author_id": 14148,
"author_profile": "https://Stackoverflow.com/users/14148",
"pm_score": 3,
"selected": true,
"text": "<p>From my time as VCS admin, darn few stylistic issues are worth mucking up the diff. We had a developer change na... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19687/"
] | ```
some_var = foo()
another_var = bar()
```
or
```
some_var = foo()
another_var = bar()
```
Including changing the whitespace as lines are added or removed to keep them lined up. Does this really look good? Is it worth the mucking up of the diff? | From my time as VCS admin, darn few stylistic issues are worth mucking up the diff. We had a developer change names with his sex change procedure, and her new first name didn't have the same initial. She then changed her former initials to her new ones whenever she worked on a program, and that caused me a lot of annoy... |
285,666 | <p>I need to know how to return a default row if no rows exist in a table. What would be the best way to do this? I'm only returning a single column from this particular table to get its value. </p>
<p>Edit: This would be SQL Server. </p>
| [
{
"answer_id": 285699,
"author": "Jason Anderson",
"author_id": 1530166,
"author_profile": "https://Stackoverflow.com/users/1530166",
"pm_score": 1,
"selected": false,
"text": "<p>Do you want to return a full row? Does the default row need to have default values or can it be an empty ro... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26923/"
] | I need to know how to return a default row if no rows exist in a table. What would be the best way to do this? I'm only returning a single column from this particular table to get its value.
Edit: This would be SQL Server. | One approach for Oracle:
```
SELECT val
FROM myTable
UNION ALL
SELECT 'DEFAULT'
FROM dual
WHERE NOT EXISTS (SELECT * FROM myTable)
```
Or alternatively in Oracle:
```
SELECT NVL(MIN(val), 'DEFAULT')
FROM myTable
```
Or alternatively in SqlServer:
```
SELECT ISNULL(MIN(val), 'DEFAULT')
FROM myTable
```
These us... |
285,674 | <p>In firefox, the error messages display as should. Just to the right of the element being validated. In IE. No matter what I do with the sizing of the labels/elements/errors, the error is always posted below the element, causing every other element to be pushed down.</p>
<pre><code><p>
<label for="han... | [
{
"answer_id": 285699,
"author": "Jason Anderson",
"author_id": 1530166,
"author_profile": "https://Stackoverflow.com/users/1530166",
"pm_score": 1,
"selected": false,
"text": "<p>Do you want to return a full row? Does the default row need to have default values or can it be an empty ro... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26121/"
] | In firefox, the error messages display as should. Just to the right of the element being validated. In IE. No matter what I do with the sizing of the labels/elements/errors, the error is always posted below the element, causing every other element to be pushed down.
```
<p>
<label for="handle"><strong>User Name</st... | One approach for Oracle:
```
SELECT val
FROM myTable
UNION ALL
SELECT 'DEFAULT'
FROM dual
WHERE NOT EXISTS (SELECT * FROM myTable)
```
Or alternatively in Oracle:
```
SELECT NVL(MIN(val), 'DEFAULT')
FROM myTable
```
Or alternatively in SqlServer:
```
SELECT ISNULL(MIN(val), 'DEFAULT')
FROM myTable
```
These us... |
285,700 | <p>i'm looking for a way to programatically convert word documents in docx format to doc format without using ole automation. i already have a windows service that does this but it means installing office on a server and it is a little unreliable and not supported. i am aware of the aspose.words product, and i will t... | [
{
"answer_id": 320854,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 4,
"selected": false,
"text": "<p>One option without using OLE automation would be to wrap the converter dlls coming with compatibility pack in orde... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3142/"
] | i'm looking for a way to programatically convert word documents in docx format to doc format without using ole automation. i already have a windows service that does this but it means installing office on a server and it is a little unreliable and not supported. i am aware of the aspose.words product, and i will try it... | One option without using OLE automation would be to wrap the converter dlls coming with compatibility pack in order to convert from docx to doc without automating Office.
This requires only that the Compatibility Pack of Office is installed on the machine.
The Office converter dlls convert from the document format th... |
285,710 | <p>Some of the platforms that I develop on, don't have profiling tools. I am looking for suggestions/techniques that you have personally used to help you identify hotspots, without the use of a profiler.</p>
<p>The target language is C++.</p>
<p>I am interested in what you have personally used.</p>
| [
{
"answer_id": 285732,
"author": "Matt J",
"author_id": 18528,
"author_profile": "https://Stackoverflow.com/users/18528",
"pm_score": 2,
"selected": false,
"text": "<p>In essence, if a profiling tool is not available, you emulate what a profiler would have done. You insert counters into... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | Some of the platforms that I develop on, don't have profiling tools. I am looking for suggestions/techniques that you have personally used to help you identify hotspots, without the use of a profiler.
The target language is C++.
I am interested in what you have personally used. | I've found the following quite useful:
```
#ifdef PROFILING
# define PROFILE_CALL(x) do{ \
const DWORD t1 = timeGetTime(); \
x; \
const DWORD t2 = timeGetTime(); \
std::cout << "Call to '" << #x << "' took " << (t2 - t1) << " ms.\n"; \
}while(false)
#else
# define PROFILE_CALL(x) x
#endif
```
Which... |
285,712 | <p>I have a file (called "number.txt") which I want to read to an array in Java. How exactly do I go ahead and do this? It is a straight-forward "1-dimensional" file, containing 100 numbers.</p>
<p>The problem is that I get an exception every time. Apparently it can't find it (I am sure its spelled correctly). When lo... | [
{
"answer_id": 285745,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 6,
"selected": false,
"text": "<p>Here is some example code to help you get started:</p>\n\n<pre><code>package com.acme;\n\nimport java.io.BufferedReader;\... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37161/"
] | I have a file (called "number.txt") which I want to read to an array in Java. How exactly do I go ahead and do this? It is a straight-forward "1-dimensional" file, containing 100 numbers.
The problem is that I get an exception every time. Apparently it can't find it (I am sure its spelled correctly). When looking thro... | Here is some example code to help you get started:
```
package com.acme;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class FileArrayProvider {
public String[] readLines(String filename) throws IOException {
... |
285,715 | <h2>Background</h2>
<p>We are developing some in-house utilities using ASP.NET 2.0. One of which is extracting some information from databases and building an Excel workbook containing a number of spreadsheets with data based on queries into the database.</p>
<h2>Problem</h2>
<p>The proof-of-concept prototype (a sim... | [
{
"answer_id": 285745,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 6,
"selected": false,
"text": "<p>Here is some example code to help you get started:</p>\n\n<pre><code>package com.acme;\n\nimport java.io.BufferedReader;\... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23234/"
] | Background
----------
We are developing some in-house utilities using ASP.NET 2.0. One of which is extracting some information from databases and building an Excel workbook containing a number of spreadsheets with data based on queries into the database.
Problem
-------
The proof-of-concept prototype (a simple ASP.N... | Here is some example code to help you get started:
```
package com.acme;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class FileArrayProvider {
public String[] readLines(String filename) throws IOException {
... |
285,716 | <p>I have written a program that gets input from a usb second keyboard (actually a barcode scanner). The problem is that if another window is active the data is input there rather than in my program. Could someone give me advice on what I'm doing wrong?</p>
<pre><code>#include <stdio.h>
#include <string.h>... | [
{
"answer_id": 285876,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 1,
"selected": false,
"text": "<p>I'll get started with a list of common problems surrounding your task, I don't have the answer, but I can at leas... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37163/"
] | I have written a program that gets input from a usb second keyboard (actually a barcode scanner). The problem is that if another window is active the data is input there rather than in my program. Could someone give me advice on what I'm doing wrong?
```
#include <stdio.h>
#include <string.h>
int main(int argc, char ... | It's been a while since this question has been asked :) Anyway, I think what you should do is to use the linux input device subsystem API.
<http://www.linuxjournal.com/article/6429> here's a good introduction. |
285,717 | <p>What's the best way to run scheduled tasks in a Rails environment? Script/runner? Rake? I would like to run the task every few minutes.</p>
| [
{
"answer_id": 285870,
"author": "Freakent",
"author_id": 32747,
"author_profile": "https://Stackoverflow.com/users/32747",
"pm_score": 4,
"selected": false,
"text": "<p>Assuming your tasks don't take too long to complete, just create a new controller with an action for each task. Implem... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13195/"
] | What's the best way to run scheduled tasks in a Rails environment? Script/runner? Rake? I would like to run the task every few minutes. | I'm using the rake approach (as supported by [heroku](https://devcenter.heroku.com/articles/scheduler))
With a file called lib/tasks/cron.rake ..
```
task :cron => :environment do
puts "Pulling new requests..."
EdiListener.process_new_messages
puts "done."
end
```
To execute from the command line, this is jus... |
285,718 | <p>I'm using MediaTemple's (dv) hosting service. How do I determine what mail-server is installed? Should I use the shell? If so, what command would be used?</p>
| [
{
"answer_id": 285739,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 4,
"selected": false,
"text": "<p>Go to the shell and type this command:</p>\n\n<pre><code>telnet <hostname> 25\n</code></pre>\n\n<p>This will co... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using MediaTemple's (dv) hosting service. How do I determine what mail-server is installed? Should I use the shell? If so, what command would be used? | Go to the shell and type this command:
```
telnet <hostname> 25
```
This will come back with a line like so:
```
220 example.com ESMTP Exim 4.69 Thu, 13 Nov 2008 10:06:01 +1100
```
as you can see, this sever is running EXIM.
Then type QUIT to exit back to the shell.
---
**UPDATE:** Some hosts use a different a... |
285,723 | <p>I'm a .NET developer, and worked with VB6 before that. I've become very familiar with those environments, and working in the context of garbage collected languages. However, I now wish to bolster my skillset with native C++ and find myself a bit overwhelmed. Ironically, it's not what I'd imagine is the usual stum... | [
{
"answer_id": 285753,
"author": "Brian",
"author_id": 16457,
"author_profile": "https://Stackoverflow.com/users/16457",
"pm_score": 2,
"selected": false,
"text": "<p>You've got some toolkits available. For example, there are STL (Standard Template Library) and Boost/TR1 (extensions to ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5416/"
] | I'm a .NET developer, and worked with VB6 before that. I've become very familiar with those environments, and working in the context of garbage collected languages. However, I now wish to bolster my skillset with native C++ and find myself a bit overwhelmed. Ironically, it's not what I'd imagine is the usual stumbling ... | I know you say you've got a good grasp of pointers and memory management, but I'd still like to explain an important trick.
As a general rule of thumb, *never* have new/delete in your user code.
Every resource acquisition (whether it's a synchronization lock, a database connection or a chunk of memory or anything else... |
285,730 | <p>I'm attempting to bind a <code>DependancyProperty</code> in one of my usercontrols to the <code>Width</code> property of a <code>Column</code> in a <code>Grid</code>. </p>
<p>I have code similar to this:</p>
<pre><code><Grid x:Name="MyGridName">
<Grid.ColumnDefinitions>
<ColumnDefinition... | [
{
"answer_id": 286695,
"author": "Ian Oakes",
"author_id": 21606,
"author_profile": "https://Stackoverflow.com/users/21606",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried setting up the binding in xaml, the following should work for you.</p>\n\n<pre><code><ColumnDefinit... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31128/"
] | I'm attempting to bind a `DependancyProperty` in one of my usercontrols to the `Width` property of a `Column` in a `Grid`.
I have code similar to this:
```
<Grid x:Name="MyGridName">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="TitleSection" Width="100" />
<ColumnDefinition Width="*" />
... | Well I have got a bit of a kludge working, I'll explain how for future generations:
Essentially I have a 2 column, multi row grid with a splitter right aligned in the first column so it can be resized by the user if the content it contains requires more space. To complicate things I have a user control being loaded pr... |
285,733 | <p>I've tried the following, but I was unsuccessful:</p>
<pre><code>ALTER TABLE person ALTER COLUMN dob POSITION 37;
</code></pre>
| [
{
"answer_id": 285740,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 8,
"selected": true,
"text": "<p>\"<a href=\"http://wiki.postgresql.org/wiki/Alter_column_position\" rel=\"noreferrer\">Alter column position</a>\" i... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10040/"
] | I've tried the following, but I was unsuccessful:
```
ALTER TABLE person ALTER COLUMN dob POSITION 37;
``` | "[Alter column position](http://wiki.postgresql.org/wiki/Alter_column_position)" in the PostgreSQL Wiki says:
>
> PostgreSQL currently defines column
> order based on the `attnum` column of
> the `pg_attribute` table. The only way
> to change column order is either by
> recreating the table, or by adding
> colum... |
285,754 | <p>So, let's say I want to write a class that operates on different kinds of numbers, but I don't a priori know what kind of numbers (i.e. ints, doubles, etc.) I will be operating on.</p>
<p>I would like to use generics to create a general class for this scenario. Something like:</p>
<pre><code> Adder<Double> ... | [
{
"answer_id": 285773,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": true,
"text": "<p>Uh oh---generics are not C++ templates. Because of type erasure, the <code>Double</code> in your example won't even show t... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] | So, let's say I want to write a class that operates on different kinds of numbers, but I don't a priori know what kind of numbers (i.e. ints, doubles, etc.) I will be operating on.
I would like to use generics to create a general class for this scenario. Something like:
```
Adder<Double> adder = new Adder<Double>();... | Uh oh---generics are not C++ templates. Because of type erasure, the `Double` in your example won't even show through to the runtime system.
In your particular case, if you just want to be able to add various types together, may I suggest method overloading? e.g., `double add(double, double)`, `float add(float, fload)... |
285,760 | <p>I need to spawn a child process that is a console application, and capture its output.</p>
<p>I wrote up the following code for a method:</p>
<pre><code>string retMessage = String.Empty;
ProcessStartInfo startInfo = new ProcessStartInfo();
Process p = new Process();
startInfo.CreateNoWindow = true;
startInfo.Redi... | [
{
"answer_id": 285786,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 2,
"selected": false,
"text": "<p>You need to call p.Start() to actually run the process after you set the StartInfo. As it is, your function is probabl... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I need to spawn a child process that is a console application, and capture its output.
I wrote up the following code for a method:
```
string retMessage = String.Empty;
ProcessStartInfo startInfo = new ProcessStartInfo();
Process p = new Process();
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = ... | Here's code that I've verified to work. I use it for spawning MSBuild and listening to its output:
```
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += (sender, args) => Console.WriteLine("received output: {0}", args.Data);
process.Start();
proce... |
285,775 | <p>One of my columns is called <code>from</code>. I can't change the name because I didn't make it.
Am I allowed to do something like <code>SELECT from FROM TableName</code> or is there a special syntax to avoid the SQL Server being confused?</p>
| [
{
"answer_id": 285777,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 10,
"selected": true,
"text": "<p>Wrap the column name in brackets like so, <code>from</code> becomes [from].</p>\n\n<pre><code>select [from] from tab... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25645/"
] | One of my columns is called `from`. I can't change the name because I didn't make it.
Am I allowed to do something like `SELECT from FROM TableName` or is there a special syntax to avoid the SQL Server being confused? | Wrap the column name in brackets like so, `from` becomes [from].
```
select [from] from table;
```
It is also possible to use the following (useful when querying multiple tables):
```
select table.[from] from table;
``` |
285,790 | <pre><code>while (xxx) {
timeout.tv_sec=TIMEOUT;
timeout.tv_usec=0;
FD_ZERO(&set);
FD_SET(sd,&set);
switch (select(FD_SETSIZE,&set,NULL,NULL,&timeout))
xxxxx
}
</code></pre>
<p>works fine, however</p>
<pre><code>FD_ZERO(&set);
FD_SET(sd,&set);
while (xxx) {
time... | [
{
"answer_id": 285801,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 3,
"selected": false,
"text": "<p>Read the select man page. The returned set is only the file descriptors that are ready to be used. You are supposed t... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37169/"
] | ```
while (xxx) {
timeout.tv_sec=TIMEOUT;
timeout.tv_usec=0;
FD_ZERO(&set);
FD_SET(sd,&set);
switch (select(FD_SETSIZE,&set,NULL,NULL,&timeout))
xxxxx
}
```
works fine, however
```
FD_ZERO(&set);
FD_SET(sd,&set);
while (xxx) {
timeout.tv_sec=TIMEOUT;
timeout.tv_usec=0;
switch... | select modifies its arguments. You really do have to re-initialize it each time.
If you're concerned about overhead, the cost of processing the complete FD\_SET in the kernel is somewhat more significant than the cost of FD\_ZERO. You'd want to only pass in your maximum fd, not FD\_SETSZIZE, to minimize the kernel pro... |
285,793 | <p>Eclipse issues warnings when a <code>serialVersionUID</code> is missing. </p>
<blockquote>
<p>The serializable class Foo does not declare a static final
serialVersionUID field of type long</p>
</blockquote>
<p>What is <code>serialVersionUID</code> and why is it important? Please show an example where missing... | [
{
"answer_id": 285809,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 12,
"selected": true,
"text": "<p>The docs for <a href=\"https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html\" rel=\... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33203/"
] | Eclipse issues warnings when a `serialVersionUID` is missing.
>
> The serializable class Foo does not declare a static final
> serialVersionUID field of type long
>
>
>
What is `serialVersionUID` and why is it important? Please show an example where missing `serialVersionUID` will cause a problem. | The docs for [`java.io.Serializable`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/Serializable.html) are probably about as good an explanation as you'll get:
>
> The serialization runtime associates with each serializable class a version number, called a `serialVersionUID`, which is used duri... |
285,816 | <p>I want to add items in a LaTeX-document. Say for example, that I want add hints to the document. I create a command, so I can call something similar to this:</p>
<pre><code>\hint{foocareful}{Be careful with foo!}{foo is a very precious item and can easily be broken. Be careful, especially don't throw foo.}
</code><... | [
{
"answer_id": 285998,
"author": "coryan",
"author_id": 33325,
"author_profile": "https://Stackoverflow.com/users/33325",
"pm_score": 2,
"selected": false,
"text": "<p>Have not done this in years, but I would look at the LaTeX source code for \\tableofcontents and \\listoffigures. I thi... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21005/"
] | I want to add items in a LaTeX-document. Say for example, that I want add hints to the document. I create a command, so I can call something similar to this:
```
\hint{foocareful}{Be careful with foo!}{foo is a very precious item and can easily be broken. Be careful, especially don't throw foo.}
```
This will be for... | One way to do it is to use the `float` package. I think that, at least, the `floatrow` package can also do what you want, and may also be more flexible. See you go, though.
Here's an example of something like you're trying to do using `float`:
```
\documentclass{article}
\usepackage{float}
\floatstyle{boxed}
\newflo... |
285,818 | <p>With Java Version 1.5.0_06 on both Windows and Ubuntu Linux :</p>
<p>Whenever I add minutes to the date "2008/10/05 00:00:00" , it seems that an extra hour is wrongly added.</p>
<p>ie: adding 360 minutes to 2008/10/05 00:00:00 at midnight should arrive at 2008/10/05 06:00:00</p>
<p>But it is arriving at 2008/10/0... | [
{
"answer_id": 285822,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": false,
"text": "<p>There's a crossover to daylight savings on that day.</p>\n\n<p>Are you in New Zealand? If so, that means your timezone fi... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27262/"
] | With Java Version 1.5.0\_06 on both Windows and Ubuntu Linux :
Whenever I add minutes to the date "2008/10/05 00:00:00" , it seems that an extra hour is wrongly added.
ie: adding 360 minutes to 2008/10/05 00:00:00 at midnight should arrive at 2008/10/05 06:00:00
But it is arriving at 2008/10/05 07:00:00
The totally... | There's a crossover to daylight savings on that day.
Are you in New Zealand? If so, that means your timezone files are out of date. Better go to the Java download site and download new ones; look for "JDK DST Timezone Update Tool". |
285,829 | <p>I'd like to use the DataGridView control as a list with columns. Sort of like ListView in Details mode but I want to keep the DataGridView flexibility.</p>
<p><strong>ListView</strong> (with <em>Details</em> view and <em>FullRowSelect</em> enabled) highlights the whole line and shows the focus mark around the whole... | [
{
"answer_id": 331438,
"author": "Tomas Sedovic",
"author_id": 2239,
"author_profile": "https://Stackoverflow.com/users/2239",
"pm_score": 7,
"selected": true,
"text": "<p>Put this code either into your form's constructor or set it in datagridview's <em>Properties</em> using the IDE.</p>... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2239/"
] | I'd like to use the DataGridView control as a list with columns. Sort of like ListView in Details mode but I want to keep the DataGridView flexibility.
**ListView** (with *Details* view and *FullRowSelect* enabled) highlights the whole line and shows the focus mark around the whole line:
![selected row in ListView ... | Put this code either into your form's constructor or set it in datagridview's *Properties* using the IDE.
```
dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgv.MultiSelect = false;
dgv.RowPrePaint +=new DataGridViewRowPrePaintEventHandler(dgv_RowPrePaint);
```
Then paste the following event into the f... |
285,860 | <p>Using Java, how can I test that a URL is contactable, and returns a valid response?</p>
<pre><code>http://stackoverflow.com/about
</code></pre>
| [
{
"answer_id": 285862,
"author": "brasskazoo",
"author_id": 6340,
"author_profile": "https://Stackoverflow.com/users/6340",
"pm_score": 7,
"selected": true,
"text": "<p>The solution as a unit test:</p>\n\n<pre><code>public void testURL() throws Exception {\n String strUrl = \"http://s... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6340/"
] | Using Java, how can I test that a URL is contactable, and returns a valid response?
```
http://stackoverflow.com/about
``` | The solution as a unit test:
```
public void testURL() throws Exception {
String strUrl = "http://stackoverflow.com/about";
try {
URL url = new URL(strUrl);
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
urlConn.connect();
assertEquals(HttpURLConnection.... |
285,866 | <p>I want to create an Ant buildfile, that includes some files as a sort of plugin.</p>
<p>So if I want to activate a feature in a project - say pmd-checking - I copy a pmd.xml in a directory and the build.xml get on the start the idea, that pmd.xml exists and imports it, so that new targets can be available to the bu... | [
{
"answer_id": 285951,
"author": "Miguel Ping",
"author_id": 22992,
"author_profile": "https://Stackoverflow.com/users/22992",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the <a href=\"http://ant.apache.org/manual/Tasks/ant.html\" rel=\"nofollow noreferrer\"><strong>ant</st... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21005/"
] | I want to create an Ant buildfile, that includes some files as a sort of plugin.
So if I want to activate a feature in a project - say pmd-checking - I copy a pmd.xml in a directory and the build.xml get on the start the idea, that pmd.xml exists and imports it, so that new targets can be available to the build.
But ... | It's not explicitly stated in the import task documentation, but the task accepts a fileset as an alternative to a single file.
Hence this, at the top level, should do the trick, and targets created are listed by `ant -p`:
```
<property name="plugins.dir" value="plugins" />
<fileset id="plugin.modules" dir="${plugins.... |
285,869 | <p>Does anyone know how to use the <a href="http://msdn.microsoft.com/en-us/library/ms645543(VS.85).aspx" rel="nofollow noreferrer">Raw Input</a> facility on Windows from a WX Python application?</p>
<p>What I need to do is be able to differentiate the input from multiple keyboards. So if there is another way to achie... | [
{
"answer_id": 307018,
"author": "joeforker",
"author_id": 36330,
"author_profile": "https://Stackoverflow.com/users/36330",
"pm_score": 3,
"selected": true,
"text": "<p>Have you tried using ctypes?</p>\n\n<pre><code>>>> import ctypes\n>>> ctypes.windll.user32.RegisterR... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10286/"
] | Does anyone know how to use the [Raw Input](http://msdn.microsoft.com/en-us/library/ms645543(VS.85).aspx) facility on Windows from a WX Python application?
What I need to do is be able to differentiate the input from multiple keyboards. So if there is another way to achieving that, that would work too. | Have you tried using ctypes?
```
>>> import ctypes
>>> ctypes.windll.user32.RegisterRawInputDevices
<_FuncPtr object at 0x01FCFDC8>
```
It would be a little work setting up the Python version of the necessary structures, but you may be able to query the Win32 API directly this way without going through wxPython. |
285,889 | <p>I want to create a file on the webserver dynamically in PHP.</p>
<p>First I create a directory to store the file. THIS WORKS</p>
<pre><code>// create the users directory and index page
$dirToCreate = "..".$_SESSION['s_USER_URL'];
mkdir($dirToCreate, 0777, TRUE); // create the directory for the user
</code></pre>
... | [
{
"answer_id": 285900,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 0,
"selected": false,
"text": "<p>It could be a result of one of your php ini settings, or possibly an apache security setting. </p>\n\n<p>Try crea... | 2008/11/13 | [
"https://Stackoverflow.com/questions/285889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to create a file on the webserver dynamically in PHP.
First I create a directory to store the file. THIS WORKS
```
// create the users directory and index page
$dirToCreate = "..".$_SESSION['s_USER_URL'];
mkdir($dirToCreate, 0777, TRUE); // create the directory for the user
```
Now I want to create a file ca... | First you do :
```
$dirToCreate = "..".$_SESSION['s_USER_URL'];
```
But the filename you try to write to is not prefixed with the '..', so try changing
```
$ourFileName = $_SESSION['s_USER_URL']."/"."index.php";
```
to
```
$ourFileName = '..' . $_SESSION['s_USER_URL'] . '/index.php';
```
or probably tidier:
... |
285,928 | <pre><code> private void activateRecords(long[] stuff) {
...
api.activateRecords(Arrays.asList(specIdsToActivate));
}
</code></pre>
<p>Shouldn't this call to Arrays.asList return a list of <code>Long</code>s? Instead it is returning a <code>List<long[]></code></p>
<pre><code>public static <T> ... | [
{
"answer_id": 285947,
"author": "Pyrolistical",
"author_id": 21838,
"author_profile": "https://Stackoverflow.com/users/21838",
"pm_score": 4,
"selected": true,
"text": "<p>That's because long[] and Long[] are different types.</p>\n\n<p>In the first case T is long[], in the second T is L... | 2008/11/13 | [
"https://Stackoverflow.com/questions/285928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/402777/"
] | ```
private void activateRecords(long[] stuff) {
...
api.activateRecords(Arrays.asList(specIdsToActivate));
}
```
Shouldn't this call to Arrays.asList return a list of `Long`s? Instead it is returning a `List<long[]>`
```
public static <T> List<T> asList(T... a)
```
The method signature is consistent w... | That's because long[] and Long[] are different types.
In the first case T is long[], in the second T is Long.
How to fix this? Don't use long[] in the first place? |
285,937 | <p>Is it possible to insert a row, but only if one of the values already in the table does not exist?</p>
<p>I'm creating a <em>Tell A Friend</em> with referral points for an ecommerce system, where I need to insert the friend's email into the database table, but only if it doesn't already exist in the table. This is ... | [
{
"answer_id": 285953,
"author": "José Leal",
"author_id": 37190,
"author_profile": "https://Stackoverflow.com/users/37190",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure if I got it, but what about a</p>\n\n<pre><code>try {\n mysql_query($sql);\n}\ncatch(Exception $e) {\n\... | 2008/11/13 | [
"https://Stackoverflow.com/questions/285937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] | Is it possible to insert a row, but only if one of the values already in the table does not exist?
I'm creating a *Tell A Friend* with referral points for an ecommerce system, where I need to insert the friend's email into the database table, but only if it doesn't already exist in the table. This is because I don't w... | If the column is a primary key or a unique index:
```
INSERT INTO table (email) VALUES (email_address) ON DUPLICATE KEY UPDATE
email=email_address
```
Knowing my luck there's a better way of doing it though. AFAIK there's no equivalent of "ON DUPLICATE KEY DO NOTHING" in MySQL. I'm not sure about the email=email\_Ad... |
285,938 | <p>Given an HTML link like</p>
<pre><code><a href="urltxt" class="someclass" close="true">texttxt</a>
</code></pre>
<p>how can I isolate the url and the text? </p>
<p><strong>Updates</strong></p>
<p>I'm using Beautiful Soup, and am unable to figure out how to do that. </p>
<p>I did </p>
<pre><code>sou... | [
{
"answer_id": 285941,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 4,
"selected": true,
"text": "<p>Use <a href=\"http://crummy.com/software/BeautifulSoup\" rel=\"noreferrer\">Beautiful Soup</a>. Doing it yourself... | 2008/11/13 | [
"https://Stackoverflow.com/questions/285938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19731/"
] | Given an HTML link like
```
<a href="urltxt" class="someclass" close="true">texttxt</a>
```
how can I isolate the url and the text?
**Updates**
I'm using Beautiful Soup, and am unable to figure out how to do that.
I did
```
soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(url))
links = soup.findAll('a')
fo... | Use [Beautiful Soup](http://crummy.com/software/BeautifulSoup). Doing it yourself is harder than it looks, you'll be better off using a tried and tested module.
**EDIT:**
I think you want:
```
soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(url).read())
```
By the way, it's a bad idea to try opening the URL ther... |
285,955 | <p>Does anybody have a snippet of Java that can return the newest file in a directory (or knowledge of a library that simplifies this sort of thing)?</p>
| [
{
"answer_id": 285987,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 1,
"selected": false,
"text": "<p>Something like:</p>\n\n<pre><code>import java.io.File;\nimport java.util.Arrays;\nimport java.util.Comparator;\n\n\npu... | 2008/11/13 | [
"https://Stackoverflow.com/questions/285955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Does anybody have a snippet of Java that can return the newest file in a directory (or knowledge of a library that simplifies this sort of thing)? | The following code returns the last modified file or folder:
```
public static File getLastModified(String directoryFilePath)
{
File directory = new File(directoryFilePath);
File[] files = directory.listFiles(File::isFile);
long lastModifiedTime = Long.MIN_VALUE;
File chosenFile = null;
if (files ... |
285,990 | <p>In .Net, I found this great library, <a href="http://www.codeplex.com/htmlagilitypack" rel="noreferrer">HtmlAgilityPack</a> that allows you to easily parse non-well-formed HTML using XPath. I've used this for a couple years in my .Net sites, but I've had to settle for more painful libraries for my Python, Ruby and... | [
{
"answer_id": 286094,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://www.crummy.com/software/BeautifulSoup/\" rel=\"nofollow noreferrer\">BeautifulSoup</a> is a goo... | 2008/11/13 | [
"https://Stackoverflow.com/questions/285990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30529/"
] | In .Net, I found this great library, [HtmlAgilityPack](http://www.codeplex.com/htmlagilitypack) that allows you to easily parse non-well-formed HTML using XPath. I've used this for a couple years in my .Net sites, but I've had to settle for more painful libraries for my Python, Ruby and other projects. Is anyone aware ... | In python, [ElementTidy](http://pypi.python.org/pypi/elementtidy/1.0-20050212) parses tag soup and produces an element tree, which allows querying using XPath:
```
>>> from elementtidy.TidyHTMLTreeBuilder import TidyHTMLTreeBuilder as TB
>>> tb = TB()
>>> tb.feed("<p>Hello world")
>>> e= tb.close()
>>> e.find(".//{htt... |
286,004 | <p>There seem to be a decent number of <code>mod_rewrite</code> threads floating around lately with a bit of confusion over how certain aspects of it work. As a result I've compiled a few notes on common functionality, and perhaps a few annoying nuances.</p>
<p>What other features / common issues have you run across u... | [
{
"answer_id": 286005,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 8,
"selected": false,
"text": "<h2>Where to place mod_rewrite rules</h2>\n\n<p><code>mod_rewrite</code> rules may be placed within the <code>httpd.conf</code>... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4853/"
] | There seem to be a decent number of `mod_rewrite` threads floating around lately with a bit of confusion over how certain aspects of it work. As a result I've compiled a few notes on common functionality, and perhaps a few annoying nuances.
What other features / common issues have you run across using `mod_rewrite`? | Where to place mod\_rewrite rules
---------------------------------
`mod_rewrite` rules may be placed within the `httpd.conf` file, or within the `.htaccess` file. if you have access to `httpd.conf`, placing rules here will offer a performance benefit (as the rules are processed once, as opposed to each time the `.hta... |
286,007 | <p>I need to configure Tomcat memory settings as part of a larger installation, so manually configuring tomcat with the configuration app after the fact is out of the question. I thought I could just throw the JVM memory settings into the JAVA_OPTS environment variable, but I'm testing that with jconsole to see if it w... | [
{
"answer_id": 286011,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 3,
"selected": false,
"text": "<p>Use the <code>CATALINA_OPTS</code> environment variable.</p>\n"
},
{
"answer_id": 286389,
"author": "FoxyBOA",... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1282409/"
] | I need to configure Tomcat memory settings as part of a larger installation, so manually configuring tomcat with the configuration app after the fact is out of the question. I thought I could just throw the JVM memory settings into the JAVA\_OPTS environment variable, but I'm testing that with jconsole to see if it wor... | Serhii's suggestion works and here is some more detail.
If you look in your installation's bin directory you will see catalina.sh
or .bat scripts. If you look in these you will see that they run a
setenv.sh or setenv.bat script respectively, if it exists, to set environment variables.
The relevant environment variabl... |
286,021 | <p>We have YouTube videos on a site and want to detect if it is likely that they will not be able to view them due to (mostly likely) company policy or otherwise.</p>
<p>We have two sites:</p>
<p>1) Flex / Flash
2) HTML</p>
<p>I think with Flex I can attempt to download <a href="http://youtube.com/crossdomain.xml" r... | [
{
"answer_id": 286055,
"author": "Tristan Havelick",
"author_id": 30529,
"author_profile": "https://Stackoverflow.com/users/30529",
"pm_score": 3,
"selected": false,
"text": "<p>This should work. Basically, it loads a youtube.com javascript file, then checks if a function in that file e... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | We have YouTube videos on a site and want to detect if it is likely that they will not be able to view them due to (mostly likely) company policy or otherwise.
We have two sites:
1) Flex / Flash
2) HTML
I think with Flex I can attempt to download <http://youtube.com/crossdomain.xml> and if it is valid XML assume the... | I like lacker's solution, but yes, it creates a [race condition](http://en.wikipedia.org/wiki/Race_condition "Race Condition on Wikipedia").
This will work and won't create a race contition:
```
var image = new Image();
image.onload = function(){
// The user can access youtube
};
image.onerror = function(){
// The use... |
286,031 | <p>I am trying to share DTO's from my datalayer assembly between the client and WCF service. This works using svcutil, but doesn't work when using VS2008. VS2008 generates it's own DTO objects whereas svcutil uses the shared data type.</p>
<p>The svcutil parameters I used are:</p>
<pre><code>"C:\Program Files\Micro... | [
{
"answer_id": 289308,
"author": "Preet Sangha",
"author_id": 30225,
"author_profile": "https://Stackoverflow.com/users/30225",
"pm_score": 0,
"selected": false,
"text": "<p>If you avoid using a service reference, and just include a reference to the the svcutil generated code then this s... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24681/"
] | I am trying to share DTO's from my datalayer assembly between the client and WCF service. This works using svcutil, but doesn't work when using VS2008. VS2008 generates it's own DTO objects whereas svcutil uses the shared data type.
The svcutil parameters I used are:
```
"C:\Program Files\Microsoft SDKs\Windows\v6.0A... | I created a batch file which calls svcutil and added it as a pre-build task to avoid this being a manual operation. This has solved my problem, but I am still not sure why there is a different behaviour between svcutil and the vs2008 gui method. |
286,039 | <p>Is there a way to get the count of rows in all tables in a MySQL database without running a <code>SELECT count()</code> on each table?</p>
| [
{
"answer_id": 286047,
"author": "gpojd",
"author_id": 28071,
"author_profile": "https://Stackoverflow.com/users/28071",
"pm_score": 8,
"selected": false,
"text": "<p>You can probably put something together with <a href=\"http://dev.mysql.com/doc/refman/5.0/en/tables-table.html\" rel=\"n... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37204/"
] | Is there a way to get the count of rows in all tables in a MySQL database without running a `SELECT count()` on each table? | ```
SELECT SUM(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '{your_db}';
```
[Note from the docs though:](https://dev.mysql.com/doc/refman/5.7/en/tables-table.html) For InnoDB tables, **the row count is only a rough estimate** used in SQL optimization. You'll need to use COUNT(\*) for e... |
286,058 | <p>If I have a key set of 1000, what is a suitable size for my Hash table, and how is that determined?</p>
| [
{
"answer_id": 286063,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 1,
"selected": false,
"text": "<p>There's some discussion of these factors in the documentation for <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | If I have a key set of 1000, what is a suitable size for my Hash table, and how is that determined? | It depends on the load factor (the "percent full" point where the table will increase its size and re-distribute its elements). If you know you have exactly 1000 entries, and that number will never change, you can just set the load factor to 1.0 and the initial size to 1000 for maximum efficiency. If you weren't sure o... |
286,060 | <p>ASP.Net 3.5 running under IIS 7 doesn't seem to allow this out of the box.</p>
<pre><code> if (!EventLog.SourceExists("MyAppLog"))
EventLog.CreateEventSource("MyAppLog", "Application");
EventLog myLog = new EventLog();
myLog.Source = "MyAppLog";
myLog.WriteEntry("Message"... | [
{
"answer_id": 286082,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 6,
"selected": true,
"text": "<p>This is part of windows security since windows 2003.</p>\n\n<p>You need to create an entry in the registry under HKE... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25372/"
] | ASP.Net 3.5 running under IIS 7 doesn't seem to allow this out of the box.
```
if (!EventLog.SourceExists("MyAppLog"))
EventLog.CreateEventSource("MyAppLog", "Application");
EventLog myLog = new EventLog();
myLog.Source = "MyAppLog";
myLog.WriteEntry("Message");
``` | This is part of windows security since windows 2003.
You need to create an entry in the registry under HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application Make sure that network service or the account you impersonate has permission to this registry key.
@CheGueVerra's link: [Requested Registry... |
286,061 | <p>I seem to be losing a lot of precision with floats.</p>
<p>For example I need to solve a matrix:</p>
<pre><code>4.0x -2.0y 1.0z =11.0
1.0x +5.0y -3.0z =-6.0
2.0x +2.0y +5.0z =7.0
</code></pre>
<p>This is the code I use to import the matrix from a text file:</p>
<pre><code>f = open('gauss.dat')
lines = f.readlin... | [
{
"answer_id": 286064,
"author": "Jeremy",
"author_id": 1114,
"author_profile": "https://Stackoverflow.com/users/1114",
"pm_score": 5,
"selected": true,
"text": "<p>I'm not familiar enough with the Decimal class to help you out, but your problem is due to the fact that decimal fractions ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338360/"
] | I seem to be losing a lot of precision with floats.
For example I need to solve a matrix:
```
4.0x -2.0y 1.0z =11.0
1.0x +5.0y -3.0z =-6.0
2.0x +2.0y +5.0z =7.0
```
This is the code I use to import the matrix from a text file:
```
f = open('gauss.dat')
lines = f.readlines()
f.close()
j=0
for line in lines:
b... | I'm not familiar enough with the Decimal class to help you out, but your problem is due to the fact that decimal fractions can often not be accurate represented in binary, so what you're seeing is the closest possible approximation; there's no way to avoid this problem without using a special class (like Decimal, proba... |
286,062 | <p>How would I go about creating a Google map that allows the user to zoom beyond the default zoom levels for the map? Would I have to create a new map type that has a greater maximum zoom? Are there any tutorials out there that show how to do this?</p>
| [
{
"answer_id": 286064,
"author": "Jeremy",
"author_id": 1114,
"author_profile": "https://Stackoverflow.com/users/1114",
"pm_score": 5,
"selected": true,
"text": "<p>I'm not familiar enough with the Decimal class to help you out, but your problem is due to the fact that decimal fractions ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | How would I go about creating a Google map that allows the user to zoom beyond the default zoom levels for the map? Would I have to create a new map type that has a greater maximum zoom? Are there any tutorials out there that show how to do this? | I'm not familiar enough with the Decimal class to help you out, but your problem is due to the fact that decimal fractions can often not be accurate represented in binary, so what you're seeing is the closest possible approximation; there's no way to avoid this problem without using a special class (like Decimal, proba... |
286,085 | <p>I've installed Subversion on Ubuntu following the guide <em><a href="http://alephzarro.com/blog/2007/01/07/installation-of-subversion-on-ubuntu-with-apache-ssl-and-basicauth" rel="nofollow noreferrer">Installation of Subversion on Ubuntu, with Apache, SSL, and BasicAuth.</a></em>.</p>
<p>It works, and I was able co... | [
{
"answer_id": 286127,
"author": "ala",
"author_id": 37198,
"author_profile": "https://Stackoverflow.com/users/37198",
"pm_score": -1,
"selected": false,
"text": "<p>I'm using TortoiseSVN as well, but on Windows users' passwords are managed by <a href=\"http://en.wikipedia.org/wiki/Activ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32424/"
] | I've installed Subversion on Ubuntu following the guide *[Installation of Subversion on Ubuntu, with Apache, SSL, and BasicAuth.](http://alephzarro.com/blog/2007/01/07/installation-of-subversion-on-ubuntu-with-apache-ssl-and-basicauth)*.
It works, and I was able commit and create different repositories, but somehow, f... | Check if your password-file actually has changed. Do a
`md5 /etc/apache2/dav_svn.passwd` or `cat /etc/apache2/dav_svn.passwd`
when it works, and after it stops working. If it changes, you've gotta figure out why (automatic update from a cronjob? some website/admin tool changing it for you?)
Note that subversion + ap... |
286,090 | <p>The question is actually about stack overflows in C.
I have an assigment that I can not get done for the life of me, I've looked at everything in the gdb and I just cant figure it.</p>
<p>The question is the following:</p>
<pre><code>int i,n;
void confused()
{
printf("who called me");
exit(0);
}
void sh... | [
{
"answer_id": 286221,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 3,
"selected": false,
"text": "<p>I probably shouldn't do your homework for you. But the basically:</p>\n\n<p>You need to get a character buffer somewhe... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The question is actually about stack overflows in C.
I have an assigment that I can not get done for the life of me, I've looked at everything in the gdb and I just cant figure it.
The question is the following:
```
int i,n;
void confused()
{
printf("who called me");
exit(0);
}
void shell_call(char *c)
{
... | I probably shouldn't do your homework for you. But the basically:
You need to get a character buffer somewhere in memory to store the string you want to execute. Obviously, you can do this the same way you are getting the other functions called (i.e. you put the text on the stack as well). After you have that written,... |
286,093 | <p>I want to assert that a method is called exactly one time. I'm using RhinoMocks 3.5.</p>
<p>Here's what I thought would work:</p>
<pre class="lang-cs prettyprint-override"><code>[Test]
public void just_once()
{
var key = "id_of_something";
var source = MockRepository.GenerateStub<ISomeDataSource>(... | [
{
"answer_id": 286125,
"author": "Christopher Bennage",
"author_id": 6855,
"author_profile": "https://Stackoverflow.com/users/6855",
"pm_score": 2,
"selected": false,
"text": "<p>Here is what I just did (as recommended by <a href=\"http://twitter.com/rayhouston/statuses/1003171744\" rel=... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6855/"
] | I want to assert that a method is called exactly one time. I'm using RhinoMocks 3.5.
Here's what I thought would work:
```cs
[Test]
public void just_once()
{
var key = "id_of_something";
var source = MockRepository.GenerateStub<ISomeDataSource>();
source.Expect(x => x.GetSomethingThatTakesALotOfResources... | Here's how I'd verify a method is called once.
```cs
[Test]
public void just_once()
{
// Arrange (Important to GenerateMock not GenerateStub)
var a = MockRepository.GenerateMock<ISomeDataSource>();
a.Expect(x => x.GetSomethingThatTakesALotOfResources()).Return(new Something()).Repeat.Once();
// Act
... |
286,096 | <pre><code>typedef struct {
nat id;
char *data;
} element_struct;
typedef element_struct * element;
void push(element e, queue s) {
nat lt = s->length;
if (lt == max_length - 1) {
printf("Error in push: Queue is full.\n");
return;
}
... | [
{
"answer_id": 286108,
"author": "David Norman",
"author_id": 34502,
"author_profile": "https://Stackoverflow.com/users/34502",
"pm_score": 2,
"selected": false,
"text": "<p>How about:</p>\n\n<pre><code>element elem = malloc(sizeof(element_struct));\nif (elem == NULL) {\n /* Handle er... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31549/"
] | ```
typedef struct {
nat id;
char *data;
} element_struct;
typedef element_struct * element;
void push(element e, queue s) {
nat lt = s->length;
if (lt == max_length - 1) {
printf("Error in push: Queue is full.\n");
return;
}
else... | Like this:
```
element_struct foo = { 1, "bar" };
push(&foo, s);
```
If you have a C99 compiler you can do this:
```
element_struct foo = {
.id = 1,
.data = "bar"
};
push(&foo, s);
```
Note that the data in the structure must be copied if it needs to live longer than the scope in which it was defined. Oth... |
286,103 | <p>Our Windows Forms application by default saves data files in a user's 'My Documents' folder (on XP) or 'Documents' folder (on Vista). We look up this location by calling:</p>
<pre><code>Environment.GetFolderPath( Environment.SpecialFolder.Personal )
</code></pre>
<p>We know for sure this works great for users whos... | [
{
"answer_id": 286131,
"author": "Jon Norton",
"author_id": 4797,
"author_profile": "https://Stackoverflow.com/users/4797",
"pm_score": 1,
"selected": false,
"text": "<p>I would expect that it does. The documentation for both <code>Environment.GetFolderPath</code> and the underlying <a ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17966/"
] | Our Windows Forms application by default saves data files in a user's 'My Documents' folder (on XP) or 'Documents' folder (on Vista). We look up this location by calling:
```
Environment.GetFolderPath( Environment.SpecialFolder.Personal )
```
We know for sure this works great for users whose personal folder is on a ... | Yes it does. You can test this out yourself by updating the corresponding registry entry for the folder. Look under ...
```
\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\
``` |
286,104 | <p>Before anybody asks, I am not doing any kind of screenscraping.</p>
<p>I'm trying to parse an html string to find a div with a certain id. I cannot for the life of me get this to work. The following expression worked in one instance, but not in another. I'm not sure if it has to do with extra elements in the htm... | [
{
"answer_id": 286113,
"author": "Cybis",
"author_id": 32998,
"author_profile": "https://Stackoverflow.com/users/32998",
"pm_score": 3,
"selected": false,
"text": "<p>Are you asking for a regular expression that can keep track of the number of DIV tags nested inside a DIV tag? I'm afraid... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8534/"
] | Before anybody asks, I am not doing any kind of screenscraping.
I'm trying to parse an html string to find a div with a certain id. I cannot for the life of me get this to work. The following expression worked in one instance, but not in another. I'm not sure if it has to do with extra elements in the html or not.
``... | In .NET you can do this:
```
(?<text>
(<div\s*?id=(\"|"|&\#34;)content(\"|"|&\#34;).*?>)
(?>
.*?</div>
|
.*?<div (?>depth)
|
.*?</div> (?>-depth)
)*)
(?(depth)(?!))
.*?</div>
```
You must use the singleline option. Here is an example using the console:
```
using System;
us... |
286,105 | <p>I have a C library with numerous math routines for dealing with vectors, matrices, quaternions and so on. It needs to remain in C because I often use it for embedded work and as a Lua extension. In addition, I have C++ class wrappers to allow for more convenient object management and operator overloading for math op... | [
{
"answer_id": 286116,
"author": "CVertex",
"author_id": 209,
"author_profile": "https://Stackoverflow.com/users/209",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think you'll notice much perf difference. Assuming your target platform support all your data types, </p>\n\n<p>I'm... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1491/"
] | I have a C library with numerous math routines for dealing with vectors, matrices, quaternions and so on. It needs to remain in C because I often use it for embedded work and as a Lua extension. In addition, I have C++ class wrappers to allow for more convenient object management and operator overloading for math opera... | Your wrapper itself will be inlined, however, your method calls to the C library typically will not. (This would require link-time-optimizations which are technically possible, but to AFAIK rudimentary at best in todays tools)
Generally, a function call as such is not very expensive. The cycle cost has decreased consi... |
286,123 | <p>I have to read a txt file with lines formated like this:</p>
<pre>
1: (G, 2), (F, 3)
2: (G, 2), (F, 3)
3: (F, 4), (G, 5)
4: (F, 4), (G, 5)
5: (F, 6), (c, w)
6: (p, f), (G, 7)
7: (G, 7), (G, 7)
w: (c, w), (c, w)
</pre>
<p>Each line will feed a struct with its data (the 5 numbers or letters in it).<br>
What's the be... | [
{
"answer_id": 286133,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 0,
"selected": false,
"text": "<p>fgets() and sscanf() as I remember</p>\n"
},
{
"answer_id": 286138,
"author": "Adam Rosenfield",
"author_id... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9835/"
] | I have to read a txt file with lines formated like this:
```
1: (G, 2), (F, 3)
2: (G, 2), (F, 3)
3: (F, 4), (G, 5)
4: (F, 4), (G, 5)
5: (F, 6), (c, w)
6: (p, f), (G, 7)
7: (G, 7), (G, 7)
w: (c, w), (c, w)
```
Each line will feed a struct with its data (the 5 numbers or letters in it).
What's the best way to read... | ```
#include <stdio.h>
int main (void)
{
char buf[81]; /* Support lines up to 80 characters */
char parts[5][11]; /* Support up to 10 characters in each part */
while (fgets(buf, sizeof(buf), stdin) != NULL)
{
if (sscanf(buf, "%10[^:]: (%10[^,], %10[^)]), (%10[^,], %10[^)])",
parts[0... |
286,124 | <p>How can I test <code>Controller.ViewData.ModelState</code>? I would prefer to do it without any mock framework. </p>
| [
{
"answer_id": 589350,
"author": "Scott Hanselman",
"author_id": 6380,
"author_profile": "https://Stackoverflow.com/users/6380",
"pm_score": 7,
"selected": true,
"text": "<p>You don't have to use a Mock if you're using the Repository Pattern for your data, of course.</p>\n\n<p>Some examp... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32173/"
] | How can I test `Controller.ViewData.ModelState`? I would prefer to do it without any mock framework. | You don't have to use a Mock if you're using the Repository Pattern for your data, of course.
Some examples:
<http://www.singingeels.com/Articles/Test_Driven_Development_with_ASPNET_MVC.aspx>
```
// Test for required "FirstName".
controller.ViewData.ModelState.Clear();
newCustomer = new Customer
{
Fi... |
286,132 | <p>I have developed a simple mechanism for my mvc website to pull in html via jquery which then populates a specified div. All is well and it looks cool.<br>
My problem is that i'm now creating html markup inside of my controller (Which is very easy to do in VB.net btw) I'd rather not mix up the sepparation of concern... | [
{
"answer_id": 286177,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 0,
"selected": false,
"text": "<p>In rails this is called rendering a partial view, and you do it with <code>render :partial => 'yourfilename'</code... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30576/"
] | I have developed a simple mechanism for my mvc website to pull in html via jquery which then populates a specified div. All is well and it looks cool.
My problem is that i'm now creating html markup inside of my controller (Which is very easy to do in VB.net btw) I'd rather not mix up the sepparation of concerns.
I... | You have several options.
Create a MVC View User Control and action handler in your controller for the view. To render the view use
```
<% Html.RenderPartial("MyControl") %>
```
In this case your action handler will need to pass the model data to the view
```
public ActionResult MyControl ()
{
// get modelDat... |
286,141 | <p>How do I remove all attributes which are <code>undefined</code> or <code>null</code> in a JavaScript object?</p>
<p>(Question is similar to <a href="https://stackoverflow.com/questions/208105/how-to-remove-a-property-from-a-javascript-object">this one</a> for Arrays)</p>
| [
{
"answer_id": 286145,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 4,
"selected": false,
"text": "<p>You are probably looking for the <a href=\"http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Sp... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33581/"
] | How do I remove all attributes which are `undefined` or `null` in a JavaScript object?
(Question is similar to [this one](https://stackoverflow.com/questions/208105/how-to-remove-a-property-from-a-javascript-object) for Arrays) | You can loop through the object:
```js
var test = {
test1: null,
test2: 'somestring',
test3: 3,
}
function clean(obj) {
for (var propName in obj) {
if (obj[propName] === null || obj[propName] === undefined) {
delete obj[propName];
}
}
return obj
}
console.log(test);
console.log(clean(test))... |
286,149 | <p>I'm trying to disable a button when a user submits a payment form and the code to post the form is causing a double post in firefox.
This problem does not occur when the code is removed, and does not occur in any browser other than firefox.</p>
<p>Any idea how to prevent the double post here?</p>
<pre><code>Syste... | [
{
"answer_id": 286154,
"author": "Jeromy Irvine",
"author_id": 8223,
"author_profile": "https://Stackoverflow.com/users/8223",
"pm_score": 2,
"selected": false,
"text": "<p>Presumably, <code>btnSubmit</code> already has a server-side event hooked up. If so, the call to <code>Page.GetPost... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36798/"
] | I'm trying to disable a button when a user submits a payment form and the code to post the form is causing a double post in firefox.
This problem does not occur when the code is removed, and does not occur in any browser other than firefox.
Any idea how to prevent the double post here?
```
System.Text.StringBuilder ... | Presumably, `btnSubmit` already has a server-side event hooked up. If so, the call to `Page.GetPostBackEventReference` should not be necessary. You should get your desired behavior simply by removing that line.
Update: You mentioned attaching the event handler in C# code, but you don't mention where you do that. I'm g... |
286,150 | <p>So I'm using python to do some parsing of web pages and I want to split the full web address into two parts. Say I have the address <a href="http://www.stackoverflow.com/questions/ask">http://www.stackoverflow.com/questions/ask</a>. I would need the protocol and domain (e.g. <a href="http://www.stackoverflow.com">ht... | [
{
"answer_id": 286155,
"author": "Cybis",
"author_id": 32998,
"author_profile": "https://Stackoverflow.com/users/32998",
"pm_score": -1,
"selected": false,
"text": "<pre><code>import re\nurl = \"http://stackoverflow.com/questions/ask\"\nprotocol, domain = re.match(r\"(http://[^/]*)(.*)\"... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | So I'm using python to do some parsing of web pages and I want to split the full web address into two parts. Say I have the address <http://www.stackoverflow.com/questions/ask>. I would need the protocol and domain (e.g. <http://www.stackoverflow.com>) and the path (e.g. /questions/ask). I figured this might be solved ... | Dan is right: urlparse is your friend:
```
>>> from urlparse import urlparse
>>>
>>> parts = urlparse("http://www.stackoverflow.com/questions/ask")
>>> parts.scheme + "://" + parts.netloc
'http://www.stackoverflow.com'
>>> parts.path
'/questions/ask'
```
**Note**: In Python 3 it's `from urllib.parse import urlparse` |
286,161 | <p>example:</p>
<p>I want to see if <code>array[5]</code> holds a value or is empty.</p>
| [
{
"answer_id": 286163,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 3,
"selected": false,
"text": "<p>There is no such thing as an \"empty\" element in a Java array. If the array's length is at least six, then element... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | example:
I want to see if `array[5]` holds a value or is empty. | Elements in primitive arrays can't be empty. They'll always get initialized to something (usually `0` for `int` arrays, but depends on how you declare the array).
If you declare the array like so (for example):
```
int [] myArray ;
myArray = new int[7] ;
```
then all of the elements will default to `0`.
An alterna... |
286,184 | <p>I have a c# winforms program and it opens up a serial port. The problem happens when the end user unplugs the usb cable and then the device disappears. After this the program will crash and want to report the error to microsoft. </p>
<p>Is there a way to capture this event and shut down gracefully? </p>
| [
{
"answer_id": 286209,
"author": "Windows programmer",
"author_id": 23705,
"author_profile": "https://Stackoverflow.com/users/23705",
"pm_score": 0,
"selected": false,
"text": "<p>If your try statement isn't catching the exception then let's hope Microsoft will inspect the dumps.</p>\n\n... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32958/"
] | I have a c# winforms program and it opens up a serial port. The problem happens when the end user unplugs the usb cable and then the device disappears. After this the program will crash and want to report the error to microsoft.
Is there a way to capture this event and shut down gracefully? | You can use WMI (Windows Management Instrumentation) to receive notification on USB events.
I did exactly that two years ago, monitoring for plugging and unplugging of a specific usb device.
Unfortunately, the code stays with my former employer, but I found one example at [bytes.com](http://bytes.com/topic/net/answe... |
286,187 | <p>I'm developing an object-oriented PHP website right now and am trying to determine the best way to abstract database functionality from the rest of the system. Right now, I've got a DB class that manages all the connections and queries that the system uses (it's pretty much an interface to MDB2). However, when using... | [
{
"answer_id": 286208,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 4,
"selected": true,
"text": "<p>Having the SQL pulled out into separate functions is a decent start. Some other things you can do:</p>\n\n<ul>\n<... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33212/"
] | I'm developing an object-oriented PHP website right now and am trying to determine the best way to abstract database functionality from the rest of the system. Right now, I've got a DB class that manages all the connections and queries that the system uses (it's pretty much an interface to MDB2). However, when using th... | Having the SQL pulled out into separate functions is a decent start. Some other things you can do:
* Create separate classes for database access code. This will help make sure you don't have SQL functions scattered around in all of your PHP files.
* Load the SQL from external files. This completely separates your SQL ... |
286,190 | <p>My present contract engagement is at a large E-Commerce company. Their code base which has origins going back to .Net 1.0 has caught me by surprise to contain many issues that raise the level of smell beyond the last crap I took. </p>
<p>That notwithstanding and trying to diffuse my level of distraction from it, I ... | [
{
"answer_id": 286210,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 2,
"selected": false,
"text": "<p>Definitely get some using statements around the Connection and Reader objects. If there is an exception, they won... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4814/"
] | My present contract engagement is at a large E-Commerce company. Their code base which has origins going back to .Net 1.0 has caught me by surprise to contain many issues that raise the level of smell beyond the last crap I took.
That notwithstanding and trying to diffuse my level of distraction from it, I go along m... | Nothing wrong with inline sql if the user input is properly parameterized, and this looks like it is.
Other than that, yes you do need to close the connections. On a busy web site you could hit your limit and that would cause all kinds of weirdness.
I also noticed it's still using an arraylist. Since they've moved o... |
286,191 | <p>I have this query statement and want to only get records that has a certain column empty (<code>volunteers_2009.venue_id</code>)</p>
<p>Table is <code>volunteers_2009</code>, column I am looking to see if it is empty: <code>venue_id</code></p>
<p>Here is the current query:</p>
<pre><code>SELECT volunteers_2009.id... | [
{
"answer_id": 286201,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 2,
"selected": false,
"text": "<p>By empty do you mean null? If the <code>venue_id</code> field can contain nulls then you can compare using th... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26130/"
] | I have this query statement and want to only get records that has a certain column empty (`volunteers_2009.venue_id`)
Table is `volunteers_2009`, column I am looking to see if it is empty: `venue_id`
Here is the current query:
```
SELECT volunteers_2009.id, volunteers_2009.comments,
volunteers_2009.choice1, volu... | The WHERE clause is out of order in your 2nd query. It must go before the ORDER BY clause.
Also, I don't imagine you have any venues with an empty id. Perhaps what you really want is this:
```
SELECT volunteers_2009.id, volunteers_2009.comments,
volunteers_2009.choice1, volunteers_2009.choice2, volunteers_2009.c... |
286,207 | <p>I am showing an addressbook view to the user and letting them click on a contact and select a phone number. If they select a phone number, I want to get the phone number as an integer and the contact's name as an NSString. </p>
<p>I've tried doing it with the following code: </p>
<pre><code> //printf("%s\n",[[(... | [
{
"answer_id": 286229,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 3,
"selected": false,
"text": "<p>You can't convert the phone number into an integer. Phone numbers are strings. The default entry Apple includes f... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] | I am showing an addressbook view to the user and letting them click on a contact and select a phone number. If they select a phone number, I want to get the phone number as an integer and the contact's name as an NSString.
I've tried doing it with the following code:
```
//printf("%s\n",[[(NSArray *)ABMultiValu... | To get the property efficiently (as far as reading goes), you can do something like this in your callback method:
```
switch( propertyType ) {
case kABMultiStringPropertyType:
// this is the phone number, do something
break;
default:
[self wrongSelection];
break;
}
```
I'm not sure you actually e... |
286,238 | <p>is it possible to throw a custom error message to a ThrowActivity, in windows workflow foundation?</p>
<p>eg. Imagine i want to throw this exception, in my WF :-</p>
<pre><code>CutomException("This is my custom error message", myNumber, myObect);
</code></pre>
<p>cheers :)</p>
| [
{
"answer_id": 287159,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 3,
"selected": true,
"text": "<p>Maybe I do not understand your question well, but you can set the specific exception with the <code>Fault</code> property of... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | is it possible to throw a custom error message to a ThrowActivity, in windows workflow foundation?
eg. Imagine i want to throw this exception, in my WF :-
```
CutomException("This is my custom error message", myNumber, myObect);
```
cheers :) | Maybe I do not understand your question well, but you can set the specific exception with the `Fault` property of `ThrowActivity` in any place before the activity execution, e.g.:
```
throwActivity1.Fault = new CustomException("This is my custom error message", myNumber, myObect);
``` |
286,250 | <p>If I am evaluating two variables and not two method calls does it matter weather I use "&&" or "&"</p>
<pre><code>//some logic that sets bool values
boolean X = true;
boolean Y = true;
if (X & Y){
// perform some operation
}
if (X && Y){
// perform some operation
}
</code></pre>
<p... | [
{
"answer_id": 286258,
"author": "vfilby",
"author_id": 24279,
"author_profile": "https://Stackoverflow.com/users/24279",
"pm_score": 3,
"selected": false,
"text": "<p>Always use && if you are performing a true/false logic test. A single & performs a bit-wise 'and'. It make ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35585/"
] | If I am evaluating two variables and not two method calls does it matter weather I use "&&" or "&"
```
//some logic that sets bool values
boolean X = true;
boolean Y = true;
if (X & Y){
// perform some operation
}
if (X && Y){
// perform some operation
}
```
Further a book I am using for C# 3.0 / .NET 3.5 o... | As has been observed, `&` is the bitwise AND operator. Raw binary math is seeming to be less and less common over time, with an increasing number of developers not really understanding bitwise arithmetic. Which can be a pain at times.
However there are a lot of tasks that are best solved with such, in particular anyth... |
286,253 | <p>G'day everyone</p>
<p>I'm a newbie to C++ and even more so to Borland Turbo C++ Explorer. I've just encountered this compile error. Any clues as to how to fix it? </p>
<pre><code>[C++ Error] comsvcs.h(3209): E2015 Ambiguity between 'ITransaction' and 'Oledb::ITransaction'
[C++ Error] comsvcs.h(3275): E2015 Ambigui... | [
{
"answer_id": 286303,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": false,
"text": "<p>It depends, with eclipse 3.4, SWT 3.4 is quite supported with <a href=\"http://www.eclipse.org/swt/macosx/\" rel=\"nofollow ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426/"
] | G'day everyone
I'm a newbie to C++ and even more so to Borland Turbo C++ Explorer. I've just encountered this compile error. Any clues as to how to fix it?
```
[C++ Error] comsvcs.h(3209): E2015 Ambiguity between 'ITransaction' and 'Oledb::ITransaction'
[C++ Error] comsvcs.h(3275): E2015 Ambiguity between 'ITransact... | It depends, with eclipse 3.4, SWT 3.4 is quite supported with [MacOs](http://www.eclipse.org/swt/macosx/).

Now, SWT is OS specific, and you may not have the same flexibility than Swing, so you need to have good reason for looking for an alternative to Swi... |
286,257 | <p>I am currently refactoring an application that prints its status to the console window. At the moment I am doing something like this:</p>
<pre><code> Console.Write("Print some status.....")
//some code
Console.WriteLine("Done!")
</code></pre>
<p>Now while this works fine, all the logic is hidden between consol... | [
{
"answer_id": 286278,
"author": "user35978",
"author_id": 35978,
"author_profile": "https://Stackoverflow.com/users/35978",
"pm_score": 0,
"selected": false,
"text": "<p>Why not use a Logger object that write errors into a text file? You could come with some \"priority\" error messages ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] | I am currently refactoring an application that prints its status to the console window. At the moment I am doing something like this:
```
Console.Write("Print some status.....")
//some code
Console.WriteLine("Done!")
```
Now while this works fine, all the logic is hidden between console.writelines and I find mak... | Take a look at Log4Net, it handles everything, but might be an overkill for your app, no idea. However knowing Log4Net will likely help you down the road someday so maybe this is a good chance too learn it. |
286,270 | <p>What is the best way to password protect quicktime streaming videos using php/.htaccess. They are being streamed using rtsp, but I can use other formats if necessary.</p>
<p>I know how to do authentication with php, but I'm not sure how to setup authentication so that will protect the streaming files urls so that a... | [
{
"answer_id": 286307,
"author": "cmptrgeekken",
"author_id": 33212,
"author_profile": "https://Stackoverflow.com/users/33212",
"pm_score": 0,
"selected": false,
"text": "<p>First off, it is very easy to spoof a referer. This information is stored in the user's browser, so a user can sim... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the best way to password protect quicktime streaming videos using php/.htaccess. They are being streamed using rtsp, but I can use other formats if necessary.
I know how to do authentication with php, but I'm not sure how to setup authentication so that will protect the streaming files urls so that a user can'... | Both nginx and lighttpd web servers have X-Send-File headers you can return from PHP. So you can do your checks in PHP and then conditionally server out the file.
```
if (check_user_can_access()){
header('X-sendfile: /path/to/file');
} else {
header('HTTP/1.1 403 Fail!');
}
```
Lighttpd also has a neat modul... |
286,275 | <p>What's the best way (if any) to make an image appear "grayed out" with CSS (i.e., without loading a separate, grayed out version of the image)?</p>
<p>My context is that I have rows in a table that all have buttons in the right most cell and some rows need to look lighter than others. So I can make the font lighter... | [
{
"answer_id": 286279,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 9,
"selected": true,
"text": "<p>Does it have to be gray? You could just set the opacity of the image lower (to dull it). Alternatively, you could create a <c... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26842/"
] | What's the best way (if any) to make an image appear "grayed out" with CSS (i.e., without loading a separate, grayed out version of the image)?
My context is that I have rows in a table that all have buttons in the right most cell and some rows need to look lighter than others. So I can make the font lighter easily of... | Does it have to be gray? You could just set the opacity of the image lower (to dull it). Alternatively, you could create a `<div>` overlay and set that to be gray (change the alpha to get the effect).
* html:
```
<div id="wrapper">
<img id="myImage" src="something.jpg" />
</div>
```
* css:
```css
#myImage {
... |
286,285 | <p>In previous applications, I was able to get TinyMCE to work just fine. But in this web app, I get the rich editor to show up okay, but for some reason I cannot type into the rich editor field and when I click a button like for bolding, I get this error:</p>
<pre><code>Error: [Exception... "Component returned failur... | [
{
"answer_id": 286291,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 0,
"selected": false,
"text": "<p>Are you executing this in Firefox ?</p>\n\n<p>Because according to <a href=\"http://qualityobsession.com/blog/archives/72\" ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In previous applications, I was able to get TinyMCE to work just fine. But in this web app, I get the rich editor to show up okay, but for some reason I cannot type into the rich editor field and when I click a button like for bolding, I get this error:
```
Error: [Exception... "Component returned failure code: 0x8000... | The answer is [here](http://tinymce.moxiecode.com/punbb/viewtopic.php?pid=45174#p45174).
The deal is this. Ever use Facebook? We were trying to implement a similar interface where you click to edit a profile section, it collapses and re-expands with a progress bar, then collapses and re-expands with a profile form. In... |
286,297 | <p>I have a suspicion that I'm using the <code>finally</code> block incorrectly, and that I don't understand the fundamentals of its purpose...</p>
<pre><code> function myFunc() {
try {
if (true) {
throw "An error";
}
} catch (e) {
alert (e);
retu... | [
{
"answer_id": 286306,
"author": "Gilean",
"author_id": 6305,
"author_profile": "https://Stackoverflow.com/users/6305",
"pm_score": 7,
"selected": true,
"text": "<blockquote>\n <p>The finally block contains statements to execute after the try and catch blocks execute but before the stat... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | I have a suspicion that I'm using the `finally` block incorrectly, and that I don't understand the fundamentals of its purpose...
```
function myFunc() {
try {
if (true) {
throw "An error";
}
} catch (e) {
alert (e);
return false;
} finally... | >
> The finally block contains statements to execute after the try and catch blocks execute but before the statements following the try...catch statement. The finally block executes whether or not an exception is thrown. If an exception is thrown, the statements in the finally block execute even if no catch block hand... |
286,321 | <p>I would like to make my application somewhat REST compliant. I am using Rails on the backend and <a href="https://developers.google.com/web-toolkit/" rel="noreferrer">GWT</a> on the frontend. I would like to do updates and deletes. I realize I can do something like mydomain.com/:id/delete (GET) and accomplish the... | [
{
"answer_id": 286463,
"author": "Christian Lescuyer",
"author_id": 341,
"author_profile": "https://Stackoverflow.com/users/341",
"pm_score": 4,
"selected": true,
"text": "<p>Rails does this with hidden attributes. The easiest way to figure this out would be to create a new rails applica... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10333/"
] | I would like to make my application somewhat REST compliant. I am using Rails on the backend and [GWT](https://developers.google.com/web-toolkit/) on the frontend. I would like to do updates and deletes. I realize I can do something like mydomain.com/:id/delete (GET) and accomplish the same thing. However, as I stated ... | Rails does this with hidden attributes. The easiest way to figure this out would be to create a new rails application, generate a scaffold and have a look at the HTML in a browser.
Try this:
```
rails jp
cd jp
./script/generate scaffold RequestBuilder name:string
rake db:migrate
./script/server
```
Then navigate t... |
286,332 | <p>I have subclassed the UITableView control, and the style is grouped, but I do not need the cell separators. I tried setting my table view's separatorStyle to none, but it doesn't work. Can any one help me out?</p>
| [
{
"answer_id": 286505,
"author": "leonho",
"author_id": 30883,
"author_profile": "https://Stackoverflow.com/users/30883",
"pm_score": 2,
"selected": false,
"text": "<p>How about setSeparatorColor to your cell's background color?</p>\n"
},
{
"answer_id": 456945,
"author": "Com... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have subclassed the UITableView control, and the style is grouped, but I do not need the cell separators. I tried setting my table view's separatorStyle to none, but it doesn't work. Can any one help me out? | In a grouped table view, setting `separatorStyle` doesn't do anything. If you want to hide it, just do the following:
```
tableView.separatorColor = [UIColor clearColor];
``` |
286,334 | <p>I have a table of events, I need to find all tail events of type 1 and all head events of type 1. </p>
<p>So, for the set of events in this order [1, 1], 3, 1 ,4, 5, [1,1,1] the brackets denote head and tail events of type 1. </p>
<p>This is much better illustrated in SQL:</p>
<pre><code>drop table #event
go
cre... | [
{
"answer_id": 286343,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 0,
"selected": false,
"text": "<p>From what I understand you are after is the head and tail, ordered by day**, for each ID**. The head and tail bei... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17174/"
] | I have a table of events, I need to find all tail events of type 1 and all head events of type 1.
So, for the set of events in this order [1, 1], 3, 1 ,4, 5, [1,1,1] the brackets denote head and tail events of type 1.
This is much better illustrated in SQL:
```
drop table #event
go
create table #event (group_id i... | To generate a large subset of data you can use this:
```
declare @i int
set @i = 10000
while @i > 5
begin
insert into #event values (@i, '2000-01-01', 1)
insert into #event values (@i, '2000-01-02', 1)
insert into #event values (@i, '2000-01-03', 3)
insert into #event values (@i, '2000-01-04', 2)... |
286,375 | <p>Hi i am encountering problems trying to post a WebRequest under Https. </p>
<p>i received the following errors</p>
<h1>1.-The underlying connection was closed: Unable to connect to the remote server.</h1>
<h1>2.-the operation TimeOut</h1>
<h1>3-The underlying connection was closed: Could not establish secure cha... | [
{
"answer_id": 286393,
"author": "Sani Singh Huttunen",
"author_id": 26742,
"author_profile": "https://Stackoverflow.com/users/26742",
"pm_score": 0,
"selected": false,
"text": "<p>The SSL certificate name probably doesn't match. This is often the case with selfsigned certificates.</p>\n... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14440/"
] | Hi i am encountering problems trying to post a WebRequest under Https.
i received the following errors
1.-The underlying connection was closed: Unable to connect to the remote server.
================================================================================
2.-the operation TimeOut
========================
... | There are a whole number of things that could be complicating things, as far as inconsistencies with the SSL certs, etc. But first, you should do some basic debugging to rule out the obvious things:
-- Did you try sending a simple web request to other servers? Try both (unsecured) http and (secured) https
-- Did you ... |
286,392 | <p>How to use batch file to check if an application still running or not? If the application still running, this process will loop again and again. Else, there will be error message.</p>
<p>Thank you very much</p>
| [
{
"answer_id": 286397,
"author": "javamonkey79",
"author_id": 27657,
"author_profile": "https://Stackoverflow.com/users/27657",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps you mean tasklist? You can run that from the command line to get all running processes in windows...for th... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How to use batch file to check if an application still running or not? If the application still running, this process will loop again and again. Else, there will be error message.
Thank you very much | in windows you kan use [pstools](http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx) pslist to check if a process name is running by using a .cmd script like the following. Pslist will return ERRORLEVEL 0 if the process is running, 1 if not.
```
@echo off
CommandYouWillRun.exe
rem waiting for the process ... |
286,399 | <p>I want to build two-dimentional array of strings where length of one dimention is 2. Similar to this</p>
<pre><code>string[,] array = new string[,]
{
{"a", "b"},
{"c", "d"},
{"e", "f"},
{"g", "h"}
}
</code></pre>
<p>Doing</p>
<pre><code>List<string[]> list = new List<string[]>();
list... | [
{
"answer_id": 286420,
"author": "Andrew Kennan",
"author_id": 22506,
"author_profile": "https://Stackoverflow.com/users/22506",
"pm_score": 0,
"selected": false,
"text": "<p>This isn't possible with a <code>List<string[]></code>, as the type <code>string[,]</code> is different fro... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] | I want to build two-dimentional array of strings where length of one dimention is 2. Similar to this
```
string[,] array = new string[,]
{
{"a", "b"},
{"c", "d"},
{"e", "f"},
{"g", "h"}
}
```
Doing
```
List<string[]> list = new List<string[]>();
list.Add(new string[2] {"a", "b"});
list.Add(new stri... | Well, you could reasonably easily write an extension method to do it. Something like this (only tested very slightly):
```
public static T[,] ToRectangularArray<T>(this IEnumerable<T[]> source)
{
if (!source.Any())
{
return new T[0,0];
}
int width = source.First().Length;
if (source.Any(ar... |
286,402 | <p>I have a couple of array's:</p>
<pre><code>const string a_strs[] = {"cr=1", "ag=2", "gnd=U", "prl=12", "av=123", "sz=345", "rc=6", "pc=12345"};
const string b_strs[] = {"cr=2", "sz=345", "ag=10", "gnd=M", "prl=11", "rc=6", "cp=34", "cv=54", "av=654", "ct=77", "pc=12345"};
</code></pre>
<p>which i then need to pars... | [
{
"answer_id": 286450,
"author": "qrdl",
"author_id": 28494,
"author_profile": "https://Stackoverflow.com/users/28494",
"pm_score": 3,
"selected": false,
"text": "<p>Probably I didn't get it correctly, but obvious solutions is to split each array element into <code>key</code> and <code>v... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35416/"
] | I have a couple of array's:
```
const string a_strs[] = {"cr=1", "ag=2", "gnd=U", "prl=12", "av=123", "sz=345", "rc=6", "pc=12345"};
const string b_strs[] = {"cr=2", "sz=345", "ag=10", "gnd=M", "prl=11", "rc=6", "cp=34", "cv=54", "av=654", "ct=77", "pc=12345"};
```
which i then need to parse out for '=' and then put... | This shouldn't be too hard. Your first problem is that you don't have a fixed sized array, so you'd have to pass the size of the array, or what I'd prefer you make the arrays NULL-terminated, e.g.
`const string a_strs[] = {"cr=1", "ag=2", "gnd=U", NULL};`
Then I would write a (private) helper function that parse the ... |
286,426 | <p>I have a page P1 loading from site S1 which contains an iframe. That iframe loads a page P2 from another site S2. At some point P2 would like to close the browser window, which contains P1 loaded from S1. Of course, since P2 is loaded from another site, it can't just do parent.close().</p>
<p>I have full control ov... | [
{
"answer_id": 286472,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "<p>It's impossible, I am afraid. JavaScript from an iframe that is loaded to a different site then the one it is being rendered... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5295/"
] | I have a page P1 loading from site S1 which contains an iframe. That iframe loads a page P2 from another site S2. At some point P2 would like to close the browser window, which contains P1 loaded from S1. Of course, since P2 is loaded from another site, it can't just do parent.close().
I have full control over P1 and ... | It's impossible, I am afraid. JavaScript from an iframe that is loaded to a different site then the one it is being rendered on is strictly prohibited due to security issues.
However, if the iframe is pointed to the same site you can get to it like:
```
<iframe name = "frame1" src = "http://yoursite">
</iframe>
<scr... |
286,427 | <p>Inspired by this <a href="https://stackoverflow.com/questions/283561/extracting-leaf-paths-from-n-ary-tree-in-f">question</a> and <a href="https://stackoverflow.com/questions/283561/extracting-leaf-paths-from-n-ary-tree-in-f#283638">answer</a>, how do I create a generic permutations algorithm in F#? Google doesn't ... | [
{
"answer_id": 286544,
"author": "Benjol",
"author_id": 11410,
"author_profile": "https://Stackoverflow.com/users/11410",
"pm_score": 1,
"selected": false,
"text": "<p>My latest best answer</p>\n\n<pre><code>//mini-extension to List for removing 1 element from a list\nmodule List = \n ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] | Inspired by this [question](https://stackoverflow.com/questions/283561/extracting-leaf-paths-from-n-ary-tree-in-f) and [answer](https://stackoverflow.com/questions/283561/extracting-leaf-paths-from-n-ary-tree-in-f#283638), how do I create a generic permutations algorithm in F#? Google doesn't give any useful answers to... | you can also write something like this:
```
let rec permutations list taken =
seq { if Set.count taken = List.length list then yield [] else
for l in list do
if not (Set.contains l taken) then
for perm in permutations list (Set.add l taken) do
yield l::perm }
```
The ... |
286,441 | <pre><code>from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1}},
windows = [{'script': "single.py"}],
zipfile = None,
)
</code></pre>
<p>in this setup file for py2exe where it says single.py is that where I place the name of my... | [
{
"answer_id": 286484,
"author": "TheObserver",
"author_id": 20879,
"author_profile": "https://Stackoverflow.com/users/20879",
"pm_score": 2,
"selected": false,
"text": "<p>Yes. Are you making a windowing application or a console application? See the example setup.py files that came with... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1}},
windows = [{'script': "single.py"}],
zipfile = None,
)
```
in this setup file for py2exe where it says single.py is that where I place the name of my program? | I don't know your py2exe tool, but we usually use this way to convert py to exe:
1. Download and install Standard Python Software:
<http://www.python.org/download/>
2. Download PyInstaller via link below:
<http://pyinstaller.python-hosting.com/>
3. Unpack the archive, that you have downloaded!
In this examople, the d... |
286,459 | <p>I'm using VB .NET 2005 and Exchange Server 2003 installed
I have found some code which gives me the ability to connect in an Exchange Server and create an appointment.
The thing is that I cannot find the CDO. Appointment.
Where can I find it and make the below code to work ?
I have tried all the examples with CDO a... | [
{
"answer_id": 293356,
"author": "Patrick de Kleijn",
"author_id": 33221,
"author_profile": "https://Stackoverflow.com/users/33221",
"pm_score": 2,
"selected": false,
"text": "<p>CDO.Appointment indeed is part of cdoex.dll (Collaboration Data Objects for Exchange) that comes with some ve... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using VB .NET 2005 and Exchange Server 2003 installed
I have found some code which gives me the ability to connect in an Exchange Server and create an appointment.
The thing is that I cannot find the CDO. Appointment.
Where can I find it and make the below code to work ?
I have tried all the examples with CDO and O... | CDO.Appointment indeed is part of cdoex.dll (Collaboration Data Objects for Exchange) that comes with some versions of Exchange, SPS and Office. You can download and register cdoex.dll on your machine, and reference it in your VB.Net application.
These posts should be helpful:
* <http://support.microsoft.com/kb/31055... |
286,486 | <p>In relation to <a href="https://stackoverflow.com/questions/283431/why-would-an-command-not-recognized-error-occur-only-when-a-window-is-populated">another question</a>, how do you account for paths that may change? For example, if a program is calling a file in the same directory as the program, you can simply use ... | [
{
"answer_id": 286499,
"author": "TheObserver",
"author_id": 20879,
"author_profile": "https://Stackoverflow.com/users/20879",
"pm_score": 0,
"selected": false,
"text": "<p>If your file is always in the same directory as your program then:</p>\n\n<pre><code>def _isInProductionMode():\n ... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18676/"
] | In relation to [another question](https://stackoverflow.com/questions/283431/why-would-an-command-not-recognized-error-occur-only-when-a-window-is-populated), how do you account for paths that may change? For example, if a program is calling a file in the same directory as the program, you can simply use the path ".\fo... | Simple answer: You work out the absolute path based on the environment.
What you really need is a few pointers. There are various bits of runtime and environment information that you can glean from various places in the standard library (and they certainly help me when I want to deploy an application on windows).
So,... |
286,493 | <p>I use db2 v.9.1 on windows 2003 server so it can not use LPAD or RPAD functions scalar.
because that functions support only z/OS right?</p>
<p>Now, I use this way for pad zero when COLUMN1 type is VARCHAR</p>
<pre><code> RIGHT('0000' || COLUMN1 ,4) AS RPAD
LEFT('0000' || COLUMN1 ,4) AS LPAD
</code></pre>
<p>... | [
{
"answer_id": 287402,
"author": "Michael Sharek",
"author_id": 1958,
"author_profile": "https://Stackoverflow.com/users/1958",
"pm_score": 1,
"selected": false,
"text": "<p>I think you probably want the <a href=\"http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ib... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24550/"
] | I use db2 v.9.1 on windows 2003 server so it can not use LPAD or RPAD functions scalar.
because that functions support only z/OS right?
Now, I use this way for pad zero when COLUMN1 type is VARCHAR
```
RIGHT('0000' || COLUMN1 ,4) AS RPAD
LEFT('0000' || COLUMN1 ,4) AS LPAD
```
Have better way for replace LPAD ... | I think you probably want the [REPEAT](http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0000842.htm) scalar function. |
286,531 | <p>Env.: Vista SP1, SQL Server Express 2005</p>
<p>I'm able to connect to my localhost SQL Server using SQL Server Management Studio, using Windows authentication and, to the best of my knowledge, all default parameters, including network protocol.</p>
<p>Now I try to connect using sqlcmd.exe to no avail:</p>
<pre><... | [
{
"answer_id": 286535,
"author": "Dave",
"author_id": 32938,
"author_profile": "https://Stackoverflow.com/users/32938",
"pm_score": 3,
"selected": true,
"text": "<p>Lose the leading \\\\</p>\n\n<p>Actually, try .\\XPRESS (period slash instance)</p>\n"
},
{
"answer_id": 286536,
... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12379/"
] | Env.: Vista SP1, SQL Server Express 2005
I'm able to connect to my localhost SQL Server using SQL Server Management Studio, using Windows authentication and, to the best of my knowledge, all default parameters, including network protocol.
Now I try to connect using sqlcmd.exe to no avail:
```
C:\Program Files\Micros... | Lose the leading \\
Actually, try .\XPRESS (period slash instance) |
286,533 | <p>I'm testing how the classes FileStream and StreamReader work togheter. Via a Console application.
I'm trying to go in a file and read the lines and print them on the console.</p>
<p>I've been able to do it with a while-loop, but I want to try it with a foreach loop.</p>
<pre><code>using System;
using System.Collec... | [
{
"answer_id": 286539,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 2,
"selected": false,
"text": "<p>The problem is in:</p>\n\n<pre><code>foreach(string line in file)\n{\n Console.WriteLine(line);\n}\n</code></pre>\n\n<p... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] | I'm testing how the classes FileStream and StreamReader work togheter. Via a Console application.
I'm trying to go in a file and read the lines and print them on the console.
I've been able to do it with a while-loop, but I want to try it with a foreach loop.
```
using System;
using System.Collections.Generic;
using ... | To read all lines in New Text Document.txt:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace testing
{
public class Program
{
public static void Main(string[] args)
{
string file = @"C:\Temp\New Folder\New Text Doc... |
286,543 | <p>I have a checkbox in GridViewColumn which i use for show/change database value. The click event for the checkbox is used for change value in the database. For handling the state of property "IsChecked" I'm using datatrigger and a setter, se xaml code below:</p>
<pre><code><Style TargetType="CheckBox">
<... | [
{
"answer_id": 286764,
"author": "OliK",
"author_id": 23578,
"author_profile": "https://Stackoverflow.com/users/23578",
"pm_score": 0,
"selected": false,
"text": "<p>You can try to add a second data trigger to set the checkbox to false. As I can see from your code you set the IsChecked o... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37271/"
] | I have a checkbox in GridViewColumn which i use for show/change database value. The click event for the checkbox is used for change value in the database. For handling the state of property "IsChecked" I'm using datatrigger and a setter, se xaml code below:
```
<Style TargetType="CheckBox">
<Setter Property="IsEna... | Shouldn't
```
<Style TargetType="CheckBox">
```
instead be:
```
<Style TargetType="{x:Type CheckBox}">
```
Edit:
you could try this:
```
<Style TargetType="{x:Type CheckBox}" >
<Setter Property="IsChecked" Value="{Binding Path=ID, Converter={StaticResource Converter}}" />
</Style>
``` |
286,549 | <p>Can PL/SQL procedure in Oracle know it's own name?</p>
<p>Let me explain:</p>
<pre><code>CREATE OR REPLACE procedure some_procedure is
v_procedure_name varchar2(32);
begin
v_procedure_name := %%something%%;
end;
</code></pre>
<p>After <code>%%something%%</code> executes, variable <code>v_procedure_name</c... | [
{
"answer_id": 286569,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 6,
"selected": true,
"text": "<p>Try:</p>\n\n<pre><code>v_procedure_name := $$PLSQL_UNIT;\n</code></pre>\n\n<p>There's also $$PLSQL_LINE if you want to... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23220/"
] | Can PL/SQL procedure in Oracle know it's own name?
Let me explain:
```
CREATE OR REPLACE procedure some_procedure is
v_procedure_name varchar2(32);
begin
v_procedure_name := %%something%%;
end;
```
After `%%something%%` executes, variable `v_procedure_name` should contain 'SOME\_PROCEDURE'. It is also OK if... | Try:
```
v_procedure_name := $$PLSQL_UNIT;
```
There's also $$PLSQL\_LINE if you want to know which line number you are on. |
286,565 | <p>I'm using a QTableWidget to display several rows. Some of these rows should reflect an error and their text color is changed :</p>
<p>Rows reflecting that there is no error are displayed with a default color (black text on white background on my computer).<br>
Rows reflecting that there is an error are displayed wi... | [
{
"answer_id": 287660,
"author": "Caleb Huitt - cjhuitt",
"author_id": 9876,
"author_profile": "https://Stackoverflow.com/users/9876",
"pm_score": 0,
"selected": false,
"text": "<p>You could, of course, inherit from the table widget and override the paint event, but I don't think that is... | 2008/11/13 | [
"https://Stackoverflow.com/questions/286565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2796/"
] | I'm using a QTableWidget to display several rows. Some of these rows should reflect an error and their text color is changed :
Rows reflecting that there is no error are displayed with a default color (black text on white background on my computer).
Rows reflecting that there is an error are displayed with a red te... | Answering myself, here is what I ended up doing : a delegate.
This delegate will check the foreground color role of the item. If this foreground color is not the default WindowText color of the palette, that means a specific color is set and this specific color is used for the highlighted text color.
I'm not sure if ... |