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 |
|---|---|---|---|---|---|---|
125,094 | <p>I have a 2D character array:<br>
<code>char nm[MAX1][MAX2] = { "john", "bob", "david" };</code><br>
I want to swap two of these elements (without <code>std::swap</code>) by simply writing<br>
<code>swapPointers(nm[0], nm[1]);</code><br>
where <code>swapPointers</code> looks like this </p>
<pre><code>void swapPoint... | [
{
"answer_id": 125103,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 0,
"selected": false,
"text": "<pre><code>void swapPointers(char** ppa, char** ppb)\n{\n char* ptemp = *ppa;\n *ppb = *ppa;\n *ppa = ptemp;\n}\n... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21475/"
] | I have a 2D character array:
`char nm[MAX1][MAX2] = { "john", "bob", "david" };`
I want to swap two of these elements (without `std::swap`) by simply writing
`swapPointers(nm[0], nm[1]);`
where `swapPointers` looks like this
```
void swapPointers(char *&a, char *&b)
{
char *temp = a;
a = b; ... | Zan is close, but his problem is that his 'swap' function can take any pointer to characters. This can cause problems if misused. Here is a safer version:
```
void swap(char (&x)[MAX2], char (&y)[MAX2])
{
char temp[MAX2];
memcpy(temp, x, MAX2);
memcpy(x, y, MAX2);
memcpy(y, temp, MAX2);
}
```
There ... |
125,096 | <p>I have an app that has impersonation used throughout. But when a user is logged in as an admin, a few operation require them to write to the server itself. Now if these users do not have rights on the actual server (some don't) it will not let them write. </p>
<p>What I want to do is turn off impersonation for ju... | [
{
"answer_id": 125219,
"author": "jedatu",
"author_id": 2582,
"author_profile": "https://Stackoverflow.com/users/2582",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure if this is the preferred approach but when I wanted to do this I new'd up an instance of a <a href=\"http://... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14777/"
] | I have an app that has impersonation used throughout. But when a user is logged in as an admin, a few operation require them to write to the server itself. Now if these users do not have rights on the actual server (some don't) it will not let them write.
What I want to do is turn off impersonation for just a couple ... | Make sure the Application Pool do have the proper rights that you need.
Then, when you want to revert to the application pool identity... run the following:
```
private WindowsImpersonationContext context = null;
public void RevertToAppPool()
{
try
{
if (!WindowsIdentity.GetCurrent().IsSystem)
... |
125,099 | <p>Anyone know the formula used to control the movement of a simple tank-like vehicle?</p>
<p>To 'steer' it, you need to alter the force applied the left and right "wheels". Eg. 1 unit of force on both wheels makes it go forward. -1 units of force on both wheels makes it go backwards. Apply more force to one wheel... | [
{
"answer_id": 125116,
"author": "William Keller",
"author_id": 17095,
"author_profile": "https://Stackoverflow.com/users/17095",
"pm_score": 1,
"selected": false,
"text": "<p>Well, keep in mind that you're also talking about duration here. You need to find out the forces taking in to ac... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | Anyone know the formula used to control the movement of a simple tank-like vehicle?
To 'steer' it, you need to alter the force applied the left and right "wheels". Eg. 1 unit of force on both wheels makes it go forward. -1 units of force on both wheels makes it go backwards. Apply more force to one wheel than the othe... | For a skid steered vehicle that is required to turn in radius 'r' at a given speed 'Si' of the Inner Wheel/Track, the Outer track must be driven at speed 'So' :
```
So = Si * ((r+d)/r)
```
**Details:**
In Skid Steering, a turn is performed by the outer wheels/track traveling further distance than the inner wheels/t... |
125,102 | <p>Say I have the following string:</p>
<pre><code>"I am the most foo h4ck3r ever!!"
</code></pre>
<p>I'm trying to write a makeSpecial(foo) function where the foo substring would be wrapped in a new span element, resulting in:</p>
<pre><code>"I am the most <span class="special">foo></span> h4ck3r eve... | [
{
"answer_id": 125122,
"author": "fuentesjr",
"author_id": 10708,
"author_profile": "https://Stackoverflow.com/users/10708",
"pm_score": 3,
"selected": true,
"text": "<p>How about this:</p>\n\n<pre><code>Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on\nwin... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9106/"
] | Say I have the following string:
```
"I am the most foo h4ck3r ever!!"
```
I'm trying to write a makeSpecial(foo) function where the foo substring would be wrapped in a new span element, resulting in:
```
"I am the most <span class="special">foo></span> h4ck3r ever!!"
```
BeautifulSoup seemed like the way to go, ... | How about this:
```
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def makeSpecial(mystring, special_substr):
... return mystring.replace(special_substr, '<span class="special">%s</span>
' % special_su... |
125,109 | <p>I'm trying to bind a <code>List<T></code> to a DataGridView control, and I'm not having any luck creating custom bindings.</p>
<p>I have tried:</p>
<pre><code>gvProgramCode.DataBindings.Add(new Binding("Opcode",code,"Opcode"));
</code></pre>
<p>It throws an exception, saying that nothing was found by that p... | [
{
"answer_id": 125132,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 4,
"selected": false,
"text": "<p>Is the property on the grid you are binding to Opcode as well?.. if you want to bind directly to List you woul... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I'm trying to bind a `List<T>` to a DataGridView control, and I'm not having any luck creating custom bindings.
I have tried:
```
gvProgramCode.DataBindings.Add(new Binding("Opcode",code,"Opcode"));
```
It throws an exception, saying that nothing was found by that property name.
The name of the column in question ... | Is the property on the grid you are binding to Opcode as well?.. if you want to bind directly to List you would just DataSource = list. The databindings allows custom binding. are you trying to do something other than the datasource?
You are getting a bunch of empty rows? do the auto generated columns have names? Have... |
125,113 | <p>What is the most efficient way to convert a MySQL query to CSV in PHP please?</p>
<p>It would be best to avoid temp files as this reduces portability (dir paths and setting file-system permissions required).</p>
<p>The CSV should also include one top line of field names.</p>
| [
{
"answer_id": 125118,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 2,
"selected": false,
"text": "<pre><code>// Export to CSV\nif($_GET['action'] == 'export') {\n\n $rsSearchResults = mysql_query($sql, $db) or die(mysql_err... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5165/"
] | What is the most efficient way to convert a MySQL query to CSV in PHP please?
It would be best to avoid temp files as this reduces portability (dir paths and setting file-system permissions required).
The CSV should also include one top line of field names. | ```
SELECT * INTO OUTFILE "c:/mydata.csv"
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY "\n"
FROM my_table;
```
(*the documentation for this is here: <http://dev.mysql.com/doc/refman/5.0/en/select.html>*)
or:
```
$select = "SELECT * FROM table_name";
$export = mysql_query ( $select ) or d... |
125,117 | <p>I was looking at how some site implemented rounded corners, and the CSS had these odd tags that I've never really seen before.</p>
<pre><code>-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-bottomright: 5px;
-webkit-border-bottom-right-radius: 5px;
</code></pre>
<p>I goo... | [
{
"answer_id": 125123,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>I suggest browsing the site from IE or some other browser. I bet you get different markup.</p>\n"
},
{
"an... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] | I was looking at how some site implemented rounded corners, and the CSS had these odd tags that I've never really seen before.
```
-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-bottomright: 5px;
-webkit-border-bottom-right-radius: 5px;
```
I googled it, and they seem to ... | The `-moz-*` properties are Gecko-only (Firefox, Mozilla, Camino), the `-webkit-*` properties are WebKit-only (Chrome, Safari, Epiphany). Vendor-specific prefixes are common for implementing CSS capabilities that have not yet been standardized by the W3C.
---
Twitter's not "alienating" their IE users. There's simply ... |
125,124 | <p>How do you pass options to an executable? Is there an easier way than making the options boolean arguments?</p>
<p>EDIT: The last two answers have suggested using arguments. I know I can code a workable solution like that, but I'd rather have them be options.</p>
<p>EDIT2: Per requests for clarification, I'll u... | [
{
"answer_id": 125139,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "<p>I use two methods for passing information:</p>\n\n<p>1/ The use of command line arguments, which are made easier to h... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7545/"
] | How do you pass options to an executable? Is there an easier way than making the options boolean arguments?
EDIT: The last two answers have suggested using arguments. I know I can code a workable solution like that, but I'd rather have them be options.
EDIT2: Per requests for clarification, I'll use this simple examp... | You seem to think that there is some fundamental difference between "options" that start with "`--`" and "arguments" that don't. The only difference is in how you parse them.
It might be worth your time to look at GNU's `getopt()`/`getopt_long()` option parser. It supports passing arguments with options such as `--num... |
125,157 | <p>Is it possible to specify a relative path reference in connectionstring, attachDbFileName property in a web.config?</p>
<p>For example, In my database is located in the App_data folder, I can easily specify the AttachDBFilename as|DataDirectory|\mydb.mdf and the |Datadirectory| will automatically resolve to the cor... | [
{
"answer_id": 125236,
"author": "Jared",
"author_id": 7388,
"author_profile": "https://Stackoverflow.com/users/7388",
"pm_score": 3,
"selected": false,
"text": "<p>It depends on where your '|DataDirectory|' is located. If the resolved value of '|DataDirectory|' is in folder A (where th... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | Is it possible to specify a relative path reference in connectionstring, attachDbFileName property in a web.config?
For example, In my database is located in the App\_data folder, I can easily specify the AttachDBFilename as|DataDirectory|\mydb.mdf and the |Datadirectory| will automatically resolve to the correct path... | I had the same problem with the following scenario: I wanted to use the same database as the application from my integration tests.
I went with the following workaround:
In the App.config of my test-project I have:
```
<appSettings>
<add key="DataDirectory" value="..\..\..\BookShop\App_Data\"/>
</appSettings>
```... |
125,171 | <p>I need to pass a regex substitution as a variable:</p>
<pre><code>sub proc {
my $pattern = shift;
my $txt = "foo baz";
$txt =~ $pattern;
}
my $pattern = 's/foo/bar/';
proc($pattern);
</code></pre>
<p>This, of course, doesn't work. I tried eval'ing the substitution:</p>
<pre><code>eval("$... | [
{
"answer_id": 125212,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 3,
"selected": false,
"text": "<p>Well, you can precompile the regular expression using the <em>qr//</em> operator. But you can't pass an operator (s///).<... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8130/"
] | I need to pass a regex substitution as a variable:
```
sub proc {
my $pattern = shift;
my $txt = "foo baz";
$txt =~ $pattern;
}
my $pattern = 's/foo/bar/';
proc($pattern);
```
This, of course, doesn't work. I tried eval'ing the substitution:
```
eval("$txt =~ $pattern;");
```
but that didn't work ei... | >
> I need to pass a regex substitution as a variable
>
>
>
Do you? Why not pass a code reference? Example:
```
sub modify
{
my($text, $code) = @_;
$code->($text);
return $text;
}
my $new_text = modify('foo baz', sub { $_[0] =~ s/foo/bar/ });
```
In general, when you want to pass "something that does som... |
125,192 | <p>A common pattern with STL containers is this:</p>
<pre><code>map<Key, Value> map;
for(map<Key, Value>::iterator iter = map.begin(); iter != map.end(); ++iter)
{
...
}
</code></pre>
<p>So in order to avoid writing the declaration of the template parameters we can do this somewhere:</p>
<pre><code>typ... | [
{
"answer_id": 125201,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 3,
"selected": false,
"text": "<p>Not sure what you mean by \"overhead\". If it simplifies the way you write your code, use it, otherwise stick with... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9611/"
] | A common pattern with STL containers is this:
```
map<Key, Value> map;
for(map<Key, Value>::iterator iter = map.begin(); iter != map.end(); ++iter)
{
...
}
```
So in order to avoid writing the declaration of the template parameters we can do this somewhere:
```
typedef map<Key, Value> TNiceNameForAMap;
```
But ... | Not sure what you mean by "overhead". If it simplifies the way you write your code, use it, otherwise stick with the longhand.
If it's only used in a restricted scope, put the typedef in that same scope. Then it doesn't need to be published, or documented, or appear on any UML diagrams. For example (and I don't claim ... |
125,230 | <p>What MySQL query will do a text search and replace in one particular field in a table?</p>
<p>I.e. search for <code>foo</code> and replace with <code>bar</code> so a record with a field with the value <code>hello foo</code> becomes <code>hello bar</code>.</p>
| [
{
"answer_id": 125241,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 1,
"selected": false,
"text": "<p>The <a href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace\" rel=\"nofollow noreferrer\">R... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16536/"
] | What MySQL query will do a text search and replace in one particular field in a table?
I.e. search for `foo` and replace with `bar` so a record with a field with the value `hello foo` becomes `hello bar`. | Change `table_name` and `field` to match your table name and field in question:
```
UPDATE table_name SET field = REPLACE(field, 'foo', 'bar') WHERE INSTR(field, 'foo') > 0;
```
* [REPLACE](https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_replace) (string functions)
* [INSTR](https://dev.mysql.... |
125,265 | <p>In reading about Perl 6, I see a feature being trumpeted about, where you no longer have to do:</p>
<pre><code>return "0 but true";
</code></pre>
<p>...but can instead do:</p>
<pre><code>return 0 but True;
</code></pre>
<p>If that's the case, how does truth work in Perl 6? In Perl 5, it was pretty simple: 0, "",... | [
{
"answer_id": 125303,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 3,
"selected": false,
"text": "<p>According to O'Reilly's <em><a href=\"http://books.google.com/books?id=NYgzEwH5tsQC&pg=PA37&lpg=PA36&ots=... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | In reading about Perl 6, I see a feature being trumpeted about, where you no longer have to do:
```
return "0 but true";
```
...but can instead do:
```
return 0 but True;
```
If that's the case, how does truth work in Perl 6? In Perl 5, it was pretty simple: 0, "", and undef are false, everything else is true.
W... | So to combine what I think to be the best of everyone's answers:
When you evaluate a variable in boolean context, its .true() method gets called. The default .true() method used by an object does a Perl 5-style <0, "", undef> check of the object's value, but when you say "but True" or "but False", this method is overr... |
125,268 | <p>Is it possible to chain static methods together using a static class? Say I wanted to do something like this:</p>
<pre><code>$value = TestClass::toValue(5)::add(3)::subtract(2)::add(8)::result();
</code></pre>
<p>. . . and obviously I would want $value to be assigned the number 14. Is this possible?</p>
<p><stron... | [
{
"answer_id": 125291,
"author": "dirtside",
"author_id": 20903,
"author_profile": "https://Stackoverflow.com/users/20903",
"pm_score": 1,
"selected": false,
"text": "<p>In a nutshell... no. :) The resolution operator (::) would work for the TetsClass::toValue(5) part, but everything af... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | Is it possible to chain static methods together using a static class? Say I wanted to do something like this:
```
$value = TestClass::toValue(5)::add(3)::subtract(2)::add(8)::result();
```
. . . and obviously I would want $value to be assigned the number 14. Is this possible?
**Update**: It doesn't work (you can't ... | I like the solution provided by Camilo above, essentially since all you're doing is altering the value of a static member, and since you do want chaining (even though it's only syntatic sugar), then instantiating TestClass is probably the best way to go.
I'd suggest a Singleton pattern if you want to restrict instanti... |
125,272 | <p>I'm relatively new to Mercurial and my team is trying it out right now as a replacement for Subversion. </p>
<p>How can I commit and push a single file out to another repository while leaving other modifications in my working directory uncommitted (or at least not pushed to the other repository)?</p>
<p>This happ... | [
{
"answer_id": 125301,
"author": "Josh Matthews",
"author_id": 3830,
"author_profile": "https://Stackoverflow.com/users/3830",
"pm_score": 6,
"selected": true,
"text": "<p>There's a Mercurial feature that implements shelve and unshelve commands, which give you an interactive way to speci... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8912/"
] | I'm relatively new to Mercurial and my team is trying it out right now as a replacement for Subversion.
How can I commit and push a single file out to another repository while leaving other modifications in my working directory uncommitted (or at least not pushed to the other repository)?
This happens for us with da... | There's a Mercurial feature that implements shelve and unshelve commands, which give you an interactive way to specify changes to store away until a later time: [Shelve](http://www.selenic.com/mercurial/wiki/index.cgi/ShelveExtension).
Then you can `hg shelve` and `hg unshelve` to temporarily store changes away. It le... |
125,281 | <p>Given a string file path such as <code>/foo/fizzbuzz.bar</code>, how would I use bash to extract just the <code>fizzbuzz</code> portion of said string?</p>
| [
{
"answer_id": 125287,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 8,
"selected": false,
"text": "<p>look at the basename command:</p>\n<pre><code>NAME="$(basename /foo/fizzbuzz.bar .bar)"\n</code></pre>\n<p>instr... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | Given a string file path such as `/foo/fizzbuzz.bar`, how would I use bash to extract just the `fizzbuzz` portion of said string? | Here's how to do it with the # and % operators in Bash.
```
$ x="/foo/fizzbuzz.bar"
$ y=${x%.bar}
$ echo ${y##*/}
fizzbuzz
```
`${x%.bar}` could also be `${x%.*}` to remove everything after a dot or `${x%%.*}` to remove everything after the first dot.
Example:
```
$ x="/foo/fizzbuzz.bar.quux"
$ y=${x%.*}
$ echo $y... |
125,306 | <p>I'm writing an iPhone app that takes a photo and then uploads it to a server. How do I upload a photo to a server with Cocoa? I suppose I use NSUrl somewhere.</p>
<p>Thanks!</p>
| [
{
"answer_id": 136452,
"author": "user19087",
"author_id": 19087,
"author_profile": "https://Stackoverflow.com/users/19087",
"pm_score": 2,
"selected": false,
"text": "<p>Create an NSURLRequest and then use NSURLConnection to send it off to your server.</p>\n"
},
{
"answer_id": 1... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm writing an iPhone app that takes a photo and then uploads it to a server. How do I upload a photo to a server with Cocoa? I suppose I use NSUrl somewhere.
Thanks! | Header:
```
@interface EPUploader : NSObject {
NSURL *serverURL;
NSString *filePath;
id delegate;
SEL doneSelector;
SEL errorSelector;
BOOL uploadDidSucceed;
}
- (id)initWithURL: (NSURL *)serverURL
filePath: (NSString *)filePath
delegate: (id)delegate
done... |
125,313 | <p>I'm running programs from Eclipse (on Windows) that eat a lot of CPU time. To avoid bogging down my whole machine, I set the priority to Low with the Task Manager. However, this is a cumbersome manual process. Is there a way Eclipse can set this priority automatically?</p>
<p>EDIT: I realized that each particular l... | [
{
"answer_id": 125322,
"author": "marcospereira",
"author_id": 4600,
"author_profile": "https://Stackoverflow.com/users/4600",
"pm_score": 0,
"selected": false,
"text": "<p>A better alternative is configure the amount of memory that Eclipse will use: <a href=\"http://www.eclipsezone.com/... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9871/"
] | I'm running programs from Eclipse (on Windows) that eat a lot of CPU time. To avoid bogging down my whole machine, I set the priority to Low with the Task Manager. However, this is a cumbersome manual process. Is there a way Eclipse can set this priority automatically?
EDIT: I realized that each particular launcher (J... | I have the same problem on Windows--- launching subprocesses that use all the CPUs (thread-parallel jobs), yet I want good responsiveness in my Windows development environment.
**Solution**: after launching several jobs:
DOS cmd>> `wmic process where name="javaw.exe" CALL setpriority "below normal"`
No, this won't ... |
125,314 | <p>Selenium Remote Control has a method of "get_html_source", which returns the source of the current page as a string.</p>
<p>AFAIK, this method works in all cases in Firefox and Safari. But when it's invoked in Internet Explorer, it returns an incorrect source.</p>
<p>Does anyone know if this is a bug with Selenium... | [
{
"answer_id": 125361,
"author": "Alan Storm",
"author_id": 4668,
"author_profile": "https://Stackoverflow.com/users/4668",
"pm_score": 2,
"selected": false,
"text": "<p>I'm 99% sure get_html_source uses the browser's innerHTML property. InnerHTML returns the browser's internal represent... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21479/"
] | Selenium Remote Control has a method of "get\_html\_source", which returns the source of the current page as a string.
AFAIK, this method works in all cases in Firefox and Safari. But when it's invoked in Internet Explorer, it returns an incorrect source.
Does anyone know if this is a bug with Selenium or Internet Ex... | I'm 99% sure get\_html\_source uses the browser's innerHTML property. InnerHTML returns the browser's internal representation of a document, and has always been inconsistent and "wonky" between platforms.
You can test this by temporarily adding the following onload attribute to the body tag of your page.
```
onload=... |
125,319 | <p>I have been running <a href="http://en.wikipedia.org/wiki/StyleCop" rel="noreferrer">StyleCop</a> over some C# code, and it keeps reporting that my <code>using</code> directives should be inside the namespace.</p>
<p>Is there a technical reason for putting the <code>using</code> directives inside instead of outside... | [
{
"answer_id": 125330,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 8,
"selected": false,
"text": "<p>Putting it inside the namespaces makes the declarations local to that namespace for the file (in case you have multip... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4490/"
] | I have been running [StyleCop](http://en.wikipedia.org/wiki/StyleCop) over some C# code, and it keeps reporting that my `using` directives should be inside the namespace.
Is there a technical reason for putting the `using` directives inside instead of outside the namespace? | There is actually a (subtle) difference between the two. Imagine you have the following code in File1.cs:
```
// File1.cs
using System;
namespace Outer.Inner
{
class Foo
{
static void Bar()
{
double d = Math.PI;
}
}
}
```
Now imagine that someone adds another file (Fil... |
125,333 | <p>I'm looking for the simplest, most straightforward way to implement the following:</p>
<ul>
<li>The main program instantiates worker
threads to do a task.</li>
<li>Only <code>n</code> tasks can be running at once.</li>
<li>When <code>n</code> is reached, no more workers
are started until the count of
running thread... | [
{
"answer_id": 125350,
"author": "hazzen",
"author_id": 5066,
"author_profile": "https://Stackoverflow.com/users/5066",
"pm_score": 2,
"selected": false,
"text": "<p>Use the Executor framework; namely <a href=\"http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/292/"
] | I'm looking for the simplest, most straightforward way to implement the following:
* The main program instantiates worker
threads to do a task.
* Only `n` tasks can be running at once.
* When `n` is reached, no more workers
are started until the count of
running threads drops back below `n`. | I think that [Executors.newFixedThreadPool](http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool(int)) fits your requirements. There are a number of different ways to use the resulting ExecutorService, depending on whether you want a result returned to the main thread, or whet... |
125,359 | <p>In Java, web apps are bundled in to WARs. By default, many servlet containers will use the WAR name as the context name for the application.</p>
<p>Thus myapp.war gets deployed to <a href="http://example.com/myapp" rel="noreferrer">http://example.com/myapp</a>.</p>
<p>The problem is that the webapp considers its "... | [
{
"answer_id": 125420,
"author": "Swati",
"author_id": 12682,
"author_profile": "https://Stackoverflow.com/users/12682",
"pm_score": 0,
"selected": false,
"text": "<p>I by <em>no</em> means claim that the following is an elegant issue. In fact, in hindsight, I wouldn't recommend this iss... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13663/"
] | In Java, web apps are bundled in to WARs. By default, many servlet containers will use the WAR name as the context name for the application.
Thus myapp.war gets deployed to <http://example.com/myapp>.
The problem is that the webapp considers its "root" to be, well, "root", or simply "/", whereas HTML would consider t... | You can use JSTL for creating urls.
For example, `<c:url value="/images/header.jpg" />` will prefix the context root.
With CSS, this usually isn't an issue for me.
I have a web root structure like this:
/css
/images
In the CSS file, you then just need to use relative URLs (../images/header.jpg) and it doesn't n... |
125,369 | <p>I come across this problem when i am writing an event handler in SharePoint. My event handler has a web reference. When i create this web reference, the URL of the web service will be added in the .config file of the assembly. If i have to change the web reference URL i just have to change the link in the config fil... | [
{
"answer_id": 125375,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": true,
"text": "<p>If you have Visual Studio 2008, use a Service Reference instead of a Web Reference, which will generate partial classe... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1909/"
] | I come across this problem when i am writing an event handler in SharePoint. My event handler has a web reference. When i create this web reference, the URL of the web service will be added in the .config file of the assembly. If i have to change the web reference URL i just have to change the link in the config file. ... | If you have Visual Studio 2008, use a Service Reference instead of a Web Reference, which will generate partial classes that you can use to override functionality without your code overwritten by the generator.
For Visual Studio 2005, you could just add the *partial* keyword to the class in Reference.cs and keep a sep... |
125,377 | <p>I've tried this, but get a ClassNotFoundException when calling:</p>
<pre><code>Class.forName("com.AClass", false, mySpecialLoader)
</code></pre>
| [
{
"answer_id": 125686,
"author": "Brian Deterling",
"author_id": 14619,
"author_profile": "https://Stackoverflow.com/users/14619",
"pm_score": 3,
"selected": false,
"text": "<p>The ClassLoader will have to call defineClass to get the Class. According to the JavaDoc for defineClass: </... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21364/"
] | I've tried this, but get a ClassNotFoundException when calling:
```
Class.forName("com.AClass", false, mySpecialLoader)
``` | The ClassLoader will have to call defineClass to get the Class. According to the JavaDoc for defineClass:
>
> If name is not null, it must be equal
> to the binary name of the class
> specified by the byte array.
>
>
>
If the name is null, it will get it from the bytecode. So you can return any class you want ... |
125,389 | <p>I am writing a custom maven2 MOJO. I need to access the runtime configuration of another plugin, from this MOJO.</p>
<p>What is the best way to do this?</p>
| [
{
"answer_id": 130171,
"author": "Mike Deck",
"author_id": 1247,
"author_profile": "https://Stackoverflow.com/users/1247",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure how you would do that exactly, but it seems to me that this might not be the best design decision. If at ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2767300/"
] | I am writing a custom maven2 MOJO. I need to access the runtime configuration of another plugin, from this MOJO.
What is the best way to do this? | Using properties is certainly one way to go, however not ideal. It still requires a user to define the ${propertyName} in multiple places throughout the pom. I want to allow my plugin to work with no modifications to the user's pom, other than the plugin definition itself.
I don't see accessing the runtime properties ... |
125,400 | <p>Not sure if this is possible or if I'm expressing correctly what I'm looking for, but I have the following piece of code in my library repeatedly and would like to practice some DRY.
I have set of SQL Server tables that I'm querying based on a simple user-supplied search field ala Google. I'm using LINQ to compose ... | [
{
"answer_id": 125414,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 3,
"selected": false,
"text": "<p>What it sounds like is you want basically a conditional predicate builder.. </p>\n\n<p>I hope you can mold thi... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17729/"
] | Not sure if this is possible or if I'm expressing correctly what I'm looking for, but I have the following piece of code in my library repeatedly and would like to practice some DRY.
I have set of SQL Server tables that I'm querying based on a simple user-supplied search field ala Google. I'm using LINQ to compose the... | It sounds like you're looking for Dynamic Linq. Take a look [here](http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx). This allows you to pass strings as arguments to the query methods, like:
```
var query = dataSource.Where("CategoryID == 2 && UnitPrice > ... |
125,449 | <p>I am using Excel where certain fields are allowed for user input and other cells are to be protected. I have used Tools Protect sheet, however after doing this I am not able to change the values in the VBA script. I need to restrict the sheet to stop user input, at the same time allow the VBA code to change the cell... | [
{
"answer_id": 125505,
"author": "Kevin Crumley",
"author_id": 1818,
"author_profile": "https://Stackoverflow.com/users/1818",
"pm_score": 2,
"selected": false,
"text": "<p><strike>I don't think you can set any part of the sheet to be editable only by VBA</strike>, but you can do somethi... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17266/"
] | I am using Excel where certain fields are allowed for user input and other cells are to be protected. I have used Tools Protect sheet, however after doing this I am not able to change the values in the VBA script. I need to restrict the sheet to stop user input, at the same time allow the VBA code to change the cell va... | Try using
```
Worksheet.Protect "Password", UserInterfaceOnly := True
```
If the UserInterfaceOnly parameter is set to true, VBA code can modify protected cells. |
125,457 | <p>If I need to copy a stored procedure (SP) from one SQL Server to another I right click on the SP in SSMS and select Script Stored Procedure as > CREATE to > New Query Editor Window. I then change the connection by right clicking on that window and selecting Connection > Change Connection... and then selecting the ne... | [
{
"answer_id": 125469,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 2,
"selected": false,
"text": "<p>Try creating a linked server (which you can do with <a href=\"http://msdn.microsoft.com/en-us/library/ms190479.aspx\" rel=\... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | If I need to copy a stored procedure (SP) from one SQL Server to another I right click on the SP in SSMS and select Script Stored Procedure as > CREATE to > New Query Editor Window. I then change the connection by right clicking on that window and selecting Connection > Change Connection... and then selecting the new s... | Also, make sure when you write the query involving the linked server, you include brackets like this:
```
SELECT * FROM [LinkedServer].[RemoteDatabase].[User].[Table]
```
I've found that at least on 2000/2005 the [] brackets are necessary, at least around the server name. |
125,468 | <p>I have a repository of files which are unrelated to each other but are common to multiple projects. Each project might only need a subset of these files. For example:</p>
<pre><code>/myRepo:
/jquery.js
/jquery.form.js
/jquery.ui.js
</code></pre>
<p>Project A requires <code>jquery.js</code> and <code>jq... | [
{
"answer_id": 125478,
"author": "Hector Sosa Jr",
"author_id": 12829,
"author_profile": "https://Stackoverflow.com/users/12829",
"pm_score": 1,
"selected": false,
"text": "<p>If I understood your question correctly, you want to share code across projects? If so, look at the svn:external... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | I have a repository of files which are unrelated to each other but are common to multiple projects. Each project might only need a subset of these files. For example:
```
/myRepo:
/jquery.js
/jquery.form.js
/jquery.ui.js
```
Project A requires `jquery.js` and `jquery.form.js`, whereas Project B requires ... | Don't complicate yourself. Either pull out all files (what is the disadvatage of this ? a few more 100s of Ks of space ?), or divide the files into several directories, and only check out the needed directories (using the 'externals' property) in relevant projects. |
125,470 | <p>I need to create a configuration section, that is able to store key-value pairs in an app.config file and the key-value pairs can be added runtime regardless of their type. It is also important that the value keeps its original type. I need to extend the following interface </p>
<pre><code>public interface IPrefere... | [
{
"answer_id": 125479,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 2,
"selected": false,
"text": "<p>Phil Haack has a great article on <a href=\"http://haacked.com/archive/2007/03/12/custom-configuration-sections-in-3-easy-s... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260/"
] | I need to create a configuration section, that is able to store key-value pairs in an app.config file and the key-value pairs can be added runtime regardless of their type. It is also important that the value keeps its original type. I need to extend the following interface
```
public interface IPreferencesBackend
{
... | I found two great articles on codeproject.com that are explaining these issues in great detail.
Unraveling the Mysteries of .NET 2.0 Configuration
<http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx>
User Settings Applied
<http://www.codeproject.com/KB/dotnet/user_settings.aspx?display=PrintAll&fid=1... |
125,496 | <p>On my rails app I have a list of items (like a task list) and for each item there is a couple of check box to set parameters.</p>
<p>When I submit the form, the checked box are stored as zero and the unchecked as null on DB. </p>
<p>the question is: Is there a way to configure it? To store the data on a more tradi... | [
{
"answer_id": 125517,
"author": "Dan Harper",
"author_id": 14530,
"author_profile": "https://Stackoverflow.com/users/14530",
"pm_score": 2,
"selected": false,
"text": "<p>There are a number of potential reasons for this:</p>\n\n<ul>\n<li>Make sure that the column in the database is of t... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/440867/"
] | On my rails app I have a list of items (like a task list) and for each item there is a couple of check box to set parameters.
When I submit the form, the checked box are stored as zero and the unchecked as null on DB.
the question is: Is there a way to configure it? To store the data on a more traditional 0 or 1, be... | Let's assume that the attribute you are working with is `club_member` as in "are you a club\_member?".
Note that in Ruby/Rails, the way it is working now, `if model.club_member` will return false if it is not checked (value is null or in Ruby, nil) and true if it is checked (value is 0).
On the whole, I would strongl... |
125,523 | <p>Is it possible to use an attribute of a child to group a query?</p>
<pre><code>Post.find(:all, :include => [ :authors, :comments ], :group=>'authors.city')
</code></pre>
<p>does not work. </p>
<p>However, I am able to use <code>author.city</code> as part of the conditions.</p>
| [
{
"answer_id": 125537,
"author": "Terry G Lorber",
"author_id": 809,
"author_profile": "https://Stackoverflow.com/users/809",
"pm_score": 1,
"selected": false,
"text": "<p>If that's what you're using, then the syntax is wrong for the :group argument, it should be:</p>\n\n<pre><code>Post.... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1227001/"
] | Is it possible to use an attribute of a child to group a query?
```
Post.find(:all, :include => [ :authors, :comments ], :group=>'authors.city')
```
does not work.
However, I am able to use `author.city` as part of the conditions. | The solution is to force the necessary join so that ActiveRecord can resolve "authors.city":
```
Post.find(:all, :include => [ :author, :comments ], :joins=>"INNER JOIN authors ON posts.author_id=authors.id", :group=>'authors.city')
``` |
125,532 | <p>I decided to teach myself assembly language.</p>
<p>I have realized that my program will not compile if I attempt to change the value of any segment register.</p>
<p>Every article that I have found says that I can indeed change the value of at least 4 segment registers, so what gives? </p>
<p>I am really only in... | [
{
"answer_id": 125565,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 2,
"selected": false,
"text": "<p>Are you writing windows executables?</p>\n\n<p>In protected-mode (Win32), segment registers are not used any more.</p>\n... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1053/"
] | I decided to teach myself assembly language.
I have realized that my program will not compile if I attempt to change the value of any segment register.
Every article that I have found says that I can indeed change the value of at least 4 segment registers, so what gives?
I am really only interested in the why at th... | You said you were interested in why, so:
In real mode, a segment is a 64K "window" to physical memory and these windows are spaced 16 bytes apart. In protected mode, a segment is a window to either physical or virtual memory, whose size and location is determined by the OS, and it has many other properties, including ... |
125,536 | <p>I want to add a constant value onto an incoming bound integer. In fact I have several places where I want to bind to the same source value but add different constants. So the ideal solution would be something like this...</p>
<pre><code><TextBox Canvas.Top="{Binding ElementName=mySource, Path=myInt, Constant=5}"... | [
{
"answer_id": 125582,
"author": "Steve Steiner",
"author_id": 3892,
"author_profile": "https://Stackoverflow.com/users/3892",
"pm_score": 4,
"selected": true,
"text": "<p>I believe you can do this with a value converter. Here is a <a href=\"http://weblogs.asp.net/marianor/archive/2007/... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6276/"
] | I want to add a constant value onto an incoming bound integer. In fact I have several places where I want to bind to the same source value but add different constants. So the ideal solution would be something like this...
```
<TextBox Canvas.Top="{Binding ElementName=mySource, Path=myInt, Constant=5}"/>
<TextBox Canva... | I believe you can do this with a value converter. Here is a [blog entry](http://weblogs.asp.net/marianor/archive/2007/09/18/using-ivalueconverter-to-format-binding-values-in-wpf.aspx) that addresses passing a parameter to the value converter in the xaml. And [this blog](http://blogs.msdn.com/bencon/archive/2006/05/10/5... |
125,570 | <p>I am actually working on SP in SQL 2005. Using SP i am creating a job and am scheduling it for a particular time. These jobs take atleast 5 to 10 min to complete as the database is very huge. But I am not aware of how to check the status of the Job. I want to know if it has got completed successfully or was there an... | [
{
"answer_id": 125738,
"author": "Philip Fourie",
"author_id": 11123,
"author_profile": "https://Stackoverflow.com/users/11123",
"pm_score": 3,
"selected": true,
"text": "<p>This is what I could find, maybe it solves your problem:</p>\n\n<ol>\n<li>SP to get the current job activiity.</li... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20951/"
] | I am actually working on SP in SQL 2005. Using SP i am creating a job and am scheduling it for a particular time. These jobs take atleast 5 to 10 min to complete as the database is very huge. But I am not aware of how to check the status of the Job. I want to know if it has got completed successfully or was there any e... | This is what I could find, maybe it solves your problem:
1. SP to get the current job activiity.
>
>
> ```
> exec msdb.dbo.sp_help_jobactivity @job_id = (your job_id here)
>
> ```
>
>
You can execute this SP and place the result in a temp table and get the required result from there.
Otherwise have a look at... |
125,577 | <p>I open a connection like this:</p>
<pre><code>Using conn as New OdbcConnection(connectionString)
conn.Open()
//do stuff
End Using
</code></pre>
<p>If connection pooling is enabled, the connection is not physically closed but released to the pool and will get reused. If it is disabled, it will be physically... | [
{
"answer_id": 125581,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 2,
"selected": false,
"text": "<p>MSDN as <a href=\"http://msdn.microsoft.com/en-us/library/ms810829.aspx\" rel=\"nofollow noreferrer\">in-depth guideline... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10786/"
] | I open a connection like this:
```
Using conn as New OdbcConnection(connectionString)
conn.Open()
//do stuff
End Using
```
If connection pooling is enabled, the connection is not physically closed but released to the pool and will get reused. If it is disabled, it will be physically closed.
Is there any way... | Looks like you can just read this registry key:
[HKEYLOCALMACHINE]\SOFTWARE\ODBC\ODBCINST.INI\SQL Server\CPTimeout
(or some variant thereof, depending on your OS and user account). If the value is 0, then connection pooling is disabled. If it's any value above 0, it's enabled.
See:
<http://msdn.microsoft.com/en-us/... |
125,606 | <p>I'm working on a C#/ASP.NET web application, and I have a number of situations where I need to do locking. Ideally, I want the locks to act independently, since they have nothing to do with each other. I've been considering <code>[MethodImpl(MethodImplOptions.Synchronized)]</code> and a few ways of using <code>loc... | [
{
"answer_id": 125614,
"author": "cruizer",
"author_id": 6441,
"author_profile": "https://Stackoverflow.com/users/6441",
"pm_score": 0,
"selected": false,
"text": "<p>You can expose some static reference or a singleton, and lock() that.</p>\n\n<p>Maybe you can care to explain why you nee... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13348/"
] | I'm working on a C#/ASP.NET web application, and I have a number of situations where I need to do locking. Ideally, I want the locks to act independently, since they have nothing to do with each other. I've been considering `[MethodImpl(MethodImplOptions.Synchronized)]` and a few ways of using `lock()`, but I have a fe... | My preference is to create an object specifically for the lock.
```
private object lockForSomeResource = new object();
```
in the class that is managing the contentious resource.
Jeff Richter posted an [article](http://msdn.microsoft.com/en-us/magazine/cc188793.aspx) I read some time ago that recommended this.
You... |
125,612 | <p>I have a menu running off of a sitemap which one of the SiteMapNode looks like this: </p>
<pre><code><siteMapNode title="Gear" description="" url="">
<siteMapNode title="Armor" description="" url="~/Armor.aspx" />
<siteMapNode title="Weapons" description="" url="~/Weapons.aspx" />
</siteMa... | [
{
"answer_id": 125629,
"author": "Devin Ceartas",
"author_id": 14897,
"author_profile": "https://Stackoverflow.com/users/14897",
"pm_score": 2,
"selected": false,
"text": "<p>you can nest CSS commands by listing them in sequence</p>\n\n<p>siteMapNode siteMapNode { .... css code ... } wou... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4298/"
] | I have a menu running off of a sitemap which one of the SiteMapNode looks like this:
```
<siteMapNode title="Gear" description="" url="">
<siteMapNode title="Armor" description="" url="~/Armor.aspx" />
<siteMapNode title="Weapons" description="" url="~/Weapons.aspx" />
</siteMapNode>
```
I also have a Skin appl... | You should bind styles like this (for both static and dynamic menu items):
```
<asp:Menu ID="Menu1" runat="server" >
<StaticMenuStyle CssClass="nav-bar" />
<DynamicMenuStyle CssClass="nav-bar" />
</asp:Menu>
``` |
125,619 | <p>I'm working on an app that requires no user input, but I don't want the iPhone to enter the power saving mode.</p>
<p>Is it possible to disable power saving from an app?</p>
| [
{
"answer_id": 125645,
"author": "lajos",
"author_id": 3740,
"author_profile": "https://Stackoverflow.com/users/3740",
"pm_score": 9,
"selected": true,
"text": "<p><strong>Objective-C</strong></p>\n\n<pre><code>[[UIApplication sharedApplication] setIdleTimerDisabled:YES];\n</code></pre>\... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3740/"
] | I'm working on an app that requires no user input, but I don't want the iPhone to enter the power saving mode.
Is it possible to disable power saving from an app? | **Objective-C**
```
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
```
**Swift**
```
UIApplication.shared.isIdleTimerDisabled = true
``` |
125,627 | <p>I want to call a web service, but I won't know the url till runtime.</p>
<p>Whats the best way to get the web reference in, without actually committing to a url.</p>
<p>What about having 1 client hit the same web service on say 10 different domains?</p>
| [
{
"answer_id": 125637,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>Create the web reference, and convert the web service to a dynamic web service. A dynamic web service allows you to modify t... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220/"
] | I want to call a web service, but I won't know the url till runtime.
Whats the best way to get the web reference in, without actually committing to a url.
What about having 1 client hit the same web service on say 10 different domains? | Create the web reference, and convert the web service to a dynamic web service. A dynamic web service allows you to modify the Url.
You need to create the web reference now to ensure your application understands the interfaces available. By switching to a dynamic web service you can then modify the .Url property after... |
125,632 | <p>When providing a link to a PDF file on a website, is it possible to include information in the URL (request parameters) which will make the PDF browser plugin (if used) jump to a particular bookmark instead of just opening at the beginning?</p>
<p>Something like: <a href="http://www.somehost.com/user-guide.pdf?book... | [
{
"answer_id": 125650,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 7,
"selected": true,
"text": "<p>Yes, you can link to specific pages by number or named locations and that will always work <strong>if the user's browser use... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1119/"
] | When providing a link to a PDF file on a website, is it possible to include information in the URL (request parameters) which will make the PDF browser plugin (if used) jump to a particular bookmark instead of just opening at the beginning?
Something like: <http://www.somehost.com/user-guide.pdf?bookmark=chapter3> ?
... | Yes, you can link to specific pages by number or named locations and that will always work **if the user's browser uses Adobe Reader as plugin for viewing PDF files**.
For a specific page by number:
```
<a href="http://www.domain.com/file.pdf#page=3">Link text</a>
```
For a named location (destination):
```
<a hre... |
125,638 | <p>At run time I want to dynamically build grid columns (or another display layout) in a WPF ListView. I do not know the number and names of the columns before hand.</p>
<p>I want to be able to do:<br/>
MyListView.ItemSource = MyDataset;<br/>
MyListView.CreateColumns();</p>
| [
{
"answer_id": 125736,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 0,
"selected": false,
"text": "<p>Have a <strong>DataTemplateselector</strong> to select one of the predefined templates(Of same DataType) and apply the s... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5189/"
] | At run time I want to dynamically build grid columns (or another display layout) in a WPF ListView. I do not know the number and names of the columns before hand.
I want to be able to do:
MyListView.ItemSource = MyDataset;
MyListView.CreateColumns(); | i'd try following approach:
A) you need to have the list box display grid view - i believe this you've done already
B) define a style for GridViewColumnHeader:
```
<Style TargetType="{x:Type GridViewColumnHeader}" x:Key="gridViewColumnStyle">
<EventSetter Event="Click" Handler="OnHeaderClicked... |
125,664 | <p>How do I write a program that tells when my other program ends?</p>
| [
{
"answer_id": 125671,
"author": "Viktor",
"author_id": 17424,
"author_profile": "https://Stackoverflow.com/users/17424",
"pm_score": -1,
"selected": false,
"text": "<p>This is called the \"halting problem\" and is not solvable.\nSee <a href=\"http://en.wikipedia.org/wiki/Halting_problem... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I write a program that tells when my other program ends? | The only way to do a waitpid() or waitid() on a program that isn't spawned by yourself is to become its parent by ptrace'ing it.
Here is an example of how to use ptrace on a posix operating system to temporarily become another processes parent, and then wait until that program exits. As a side effect you can also get ... |
125,677 | <p>So I'm writing a framework on which I want to base a few apps that I'm working on (the framework is there so I have an environment to work with, and a system that will let me, for example, use a single sign-on)</p>
<p>I want to make this framework, and the apps it has use a Resource Oriented Architecture.</p>
<p>N... | [
{
"answer_id": 125799,
"author": "Mez",
"author_id": 20010,
"author_profile": "https://Stackoverflow.com/users/20010",
"pm_score": 1,
"selected": false,
"text": "<p>Use a list of Regexs to match which object I should be using</p>\n\n<p>For example</p>\n\n<pre><code>^/users/[\\w-]+/bookma... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20010/"
] | So I'm writing a framework on which I want to base a few apps that I'm working on (the framework is there so I have an environment to work with, and a system that will let me, for example, use a single sign-on)
I want to make this framework, and the apps it has use a Resource Oriented Architecture.
Now, I want to cre... | I prefer to use reg ex over making my own format since it is common knowledge. I wrote a small class that I use which allows me to nest these reg ex routing tables. I use to use something similar that was implemented by inheritance but it didn't need inheritance so I rewrote it.
I do a reg ex on a key and map to my ow... |
125,703 | <p>I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that?</p>
| [
{
"answer_id": 125713,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 7,
"selected": false,
"text": "<p>Depends on what you want to do. To append you can open it with \"a\":</p>\n\n<pre><code> with open(\"foo.txt\",... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using Python, and would like to insert a string into a text file without deleting or copying the file. How can I do that? | Depends on what you want to do. To append you can open it with "a":
```
with open("foo.txt", "a") as f:
f.write("new line\n")
```
If you want to preprend something you have to read from the file first:
```
with open("foo.txt", "r+") as f:
old = f.read() # read everything in the file
f.seek(0) # rewi... |
125,730 | <p>Why do I get following error when trying to start a ruby on rails application with <pre>mongrel_rails start</pre>?</p>
<pre>
C:\RailsTest\cookbook2>mongrel_rails start
** WARNING: Win32 does not support daemon mode.
** Daemonized, any open files are closed. Look at log/mongrel.pid and log/mongr
el.log for info.
*... | [
{
"answer_id": 125748,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 2,
"selected": false,
"text": "<p>I don't use mongrel on windows myself, but I guess that error is the equivalent of Linux' \"port in use\" error.... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14027/"
] | Why do I get following error when trying to start a ruby on rails application with
```
mongrel_rails start
```
?
```
C:\RailsTest\cookbook2>mongrel_rails start
** WARNING: Win32 does not support daemon mode.
** Daemonized, any open files are closed. Look at log/mongrel.pid and log/mongr
el.log for info.
** Starting... | You already have a process listening on port 3000 (the default port for mongrel).
Try:
```
mongrel_rails start -p 3001
```
and see whether you get a similar error.
If you're trying to install more than one Rails app, you need to assign each mongrel to a separate port and edit you apache conf accordingly.
If you n... |
125,735 | <p>I'm using the following code for setting/getting deleting cookies:</p>
<pre><code>function get_cookie(cookie_name)
{
var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
if (results)
return ( decodeURI(results[2]) );
else
return null;
}
function set_cookie(n... | [
{
"answer_id": 126115,
"author": "amix",
"author_id": 20081,
"author_profile": "https://Stackoverflow.com/users/20081",
"pm_score": 0,
"selected": false,
"text": "<p>Your code for set_cookie, get_cookie and delete_cookie seems to be correct. And your usage as well.</p>\n\n<p>I think you ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16542/"
] | I'm using the following code for setting/getting deleting cookies:
```
function get_cookie(cookie_name)
{
var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
if (results)
return ( decodeURI(results[2]) );
else
return null;
}
function set_cookie(name, value, exp... | If you're getting old cookies that might be because your page contains a lot of content and onload isn't called before onunload (because the page doesn't finish loading). So delete the cookie by calling something like this from both onload and onunload:
```
var deleted_cookie = false;
function delete_timestamp() {
... |
125,756 | <p>I'm looking for a way to set the default language for visitors comming to a site built in EPiServer for the first time. Not just administrators/editors in the backend, people comming to the public site.</p>
| [
{
"answer_id": 126318,
"author": "user19264",
"author_id": 19264,
"author_profile": "https://Stackoverflow.com/users/19264",
"pm_score": 3,
"selected": true,
"text": "<p>Depends on your setup.</p>\n\n<p>If the site languages is to change under different domains you can do this.\nAdd to c... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/452521/"
] | I'm looking for a way to set the default language for visitors comming to a site built in EPiServer for the first time. Not just administrators/editors in the backend, people comming to the public site. | Depends on your setup.
If the site languages is to change under different domains you can do this.
Add to configuration -> configSections nodes in web.config:
```
<sectionGroup name="episerver">
<section name="domainLanguageMappings" allowDefinition="MachineToApplication" allowLocation="false" type="EPiServer.Util.... |
125,785 | <p>I need a function written in Excel VBA that will hash passwords using a standard algorithm such as SHA-1. Something with a simple interface like:</p>
<pre><code>Public Function CreateHash(Value As String) As String
...
End Function
</code></pre>
<p>The function needs to work on an XP workstation with Excel 2003 i... | [
{
"answer_id": 482150,
"author": "Chris",
"author_id": 59198,
"author_profile": "https://Stackoverflow.com/users/59198",
"pm_score": 6,
"selected": false,
"text": "<p>Here's a module for calculating SHA1 hashes that is usable for Excel formulas eg. '=SHA1HASH(\"test\")'. To use it, make ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13087/"
] | I need a function written in Excel VBA that will hash passwords using a standard algorithm such as SHA-1. Something with a simple interface like:
```
Public Function CreateHash(Value As String) As String
...
End Function
```
The function needs to work on an XP workstation with Excel 2003 installed, but otherwise mus... | Here's a module for calculating SHA1 hashes that is usable for Excel formulas eg. '=SHA1HASH("test")'. To use it, make a new module called 'module\_sha1' and copy and paste it all in.
This is based on some VBA code from <http://vb.wikia.com/wiki/SHA-1.bas>, with changes to support passing it a string, and executable fr... |
125,806 | <p>First, yes I know about <a href="https://stackoverflow.com/questions/50182/linuxx11-input-library-without-creating-a-window">this question</a>, but I'm looking for a bit more information that that. I have actually, a fairly similar problem, in that I need to be able to capture input for mouse/keyboard/joystick, and ... | [
{
"answer_id": 125830,
"author": "dsm",
"author_id": 7780,
"author_profile": "https://Stackoverflow.com/users/7780",
"pm_score": 1,
"selected": false,
"text": "<p>You could start by reading <a href=\"http://tldp.org/LDP/khg/HyperNews/get/devices/devices.html\" rel=\"nofollow noreferrer\"... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14838/"
] | First, yes I know about [this question](https://stackoverflow.com/questions/50182/linuxx11-input-library-without-creating-a-window), but I'm looking for a bit more information that that. I have actually, a fairly similar problem, in that I need to be able to capture input for mouse/keyboard/joystick, and I'd also like ... | Using the link below look at the function void kGUISystemX::Loop(void)
This is my main loop for getting input via keyboard and mouse using X Windows on Linux.
<http://code.google.com/p/kgui/source/browse/trunk/kguilinux.cpp>
Here is a snippet:
```
if(XPending(m_display))
{
XNextEvent(m_display, &m_e... |
125,828 | <p>I'm trying to start an external application through <code>system()</code> - for example, <code>system("ls")</code>. I would like to capture its output as it happens so I can send it to another function for further processing. What's the best way to do that in C/C++?</p>
| [
{
"answer_id": 125851,
"author": "Blank",
"author_id": 19521,
"author_profile": "https://Stackoverflow.com/users/19521",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not entirely certain that its possible in standard C, as two different processes don't typically share memory space. ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10010/"
] | I'm trying to start an external application through `system()` - for example, `system("ls")`. I would like to capture its output as it happens so I can send it to another function for further processing. What's the best way to do that in C/C++? | From the popen manual:
```
#include <stdio.h>
FILE *popen(const char *command, const char *type);
int pclose(FILE *stream);
``` |
125,850 | <p>I have this RewriteRule that works too well :-)</p>
<pre><code>RewriteRule ^([^/]*)/$ /script.html?id=$1 [L]
</code></pre>
<p>The bad thing about this rule is that it also matches physical directories which I don't want.</p>
<p>How can I tell the <code>mod_rewrite</code> to ignore physical directories and apply t... | [
{
"answer_id": 125864,
"author": "ctcherry",
"author_id": 10322,
"author_profile": "https://Stackoverflow.com/users/10322",
"pm_score": 3,
"selected": true,
"text": "<p>Take a look at <a href=\"http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond\" rel=\"nofollow noreferrer\... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have this RewriteRule that works too well :-)
```
RewriteRule ^([^/]*)/$ /script.html?id=$1 [L]
```
The bad thing about this rule is that it also matches physical directories which I don't want.
How can I tell the `mod_rewrite` to ignore physical directories and apply the above rule only when the directory matche... | Take a look at [RewriteCond](http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond). Put the following before your rule to exempt out directories and files
```
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
``` |
125,857 | <p>Having a problem getting a TreeView control to display node images. The code below works sometimes but fails to show any image at other times.</p>
<pre><code>
private TreeNode AddNodeForCore(TreeNode root, Core c) {
string key = GetImageKey(c);
TreeNode t = root.Nodes.Add(c.Name, c.Name, key, key);
t.Ta... | [
{
"answer_id": 125871,
"author": "VVS",
"author_id": 21038,
"author_profile": "https://Stackoverflow.com/users/21038",
"pm_score": 2,
"selected": false,
"text": "<p>A quick google search found this answer: <a href=\"http://forums.microsoft.com/MSDN/ShowPost.aspx?siteid=1&PostID=96596... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1389021/"
] | Having a problem getting a TreeView control to display node images. The code below works sometimes but fails to show any image at other times.
```
private TreeNode AddNodeForCore(TreeNode root, Core c) {
string key = GetImageKey(c);
TreeNode t = root.Nodes.Add(c.Name, c.Name, key, key);
t.Tag = c;
ret... | The helpful bit of the googled posts above is in fact:
"This is a known bug in the Windows XP visual styles implementation. Certain controls, like ImageList, do not get properly initialized when they've been created before the app calls Application.EnableVisualStyles(). The normal Main() implementation in a C#'s Progr... |
125,875 | <p>I need to change the credentials of an already existing Windows service using C#. I am aware of two different ways of doing this.</p>
<ol>
<li>ChangeServiceConfig, see <a href="http://www.pinvoke.net/default.aspx/advapi32.ChangeServiceConfig" rel="nofollow noreferrer">ChangeServiceConfig on pinvoke.net</a></li>
<li... | [
{
"answer_id": 126549,
"author": "Magnus Johansson",
"author_id": 3584,
"author_profile": "https://Stackoverflow.com/users/3584",
"pm_score": 3,
"selected": false,
"text": "<p>Here is one quick and dirty method using the System.Management classes.</p>\n\n<pre><code>using System;\nusing S... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19676/"
] | I need to change the credentials of an already existing Windows service using C#. I am aware of two different ways of doing this.
1. ChangeServiceConfig, see [ChangeServiceConfig on pinvoke.net](http://www.pinvoke.net/default.aspx/advapi32.ChangeServiceConfig)
2. ManagementObject.InvokeMethod using Change as the metho... | Here is one quick and dirty method using the System.Management classes.
```
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace ServiceTest
{
class Program
{
static void Main(string[] args)
{
string theServiceName = "My Windows Service";
string... |
125,878 | <p>I am new to java so excuse my lame questions:)</p>
<p>I am trying to build a web service in Java NetBeans 6.1 , but I have some troubles with configuration parameters ( like .settings in .net).</p>
<p>What is the right way to save and access such settings in a java web service.</p>
<p>Is there a way to read cont... | [
{
"answer_id": 125949,
"author": "Lars Westergren",
"author_id": 15627,
"author_profile": "https://Stackoverflow.com/users/15627",
"pm_score": 2,
"selected": false,
"text": "<p>If you are using servlets, you can configure parameters in web.xml:</p>\n\n<pre><code><servlet>\n <se... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18834/"
] | I am new to java so excuse my lame questions:)
I am trying to build a web service in Java NetBeans 6.1 , but I have some troubles with configuration parameters ( like .settings in .net).
What is the right way to save and access such settings in a java web service.
Is there a way to read context parameters from web.x... | If you are using servlets, you can configure parameters in web.xml:
```
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
```
Thes... |
125,885 | <p>I'm working on a fairly complex project, a custom encryption routine if you will (just for fun) and I've run into this issue in designing my code layout.</p>
<p>I have a number of functions that I want to be able to call by index. Specifically, I need to be able to call one randomly for the encrypt process, but the... | [
{
"answer_id": 125906,
"author": "Khoth",
"author_id": 20686,
"author_profile": "https://Stackoverflow.com/users/20686",
"pm_score": 0,
"selected": false,
"text": "<p>An object with an operator() method defined can act a lot like a function but be generally nicer to work with.</p>\n"
}... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19521/"
] | I'm working on a fairly complex project, a custom encryption routine if you will (just for fun) and I've run into this issue in designing my code layout.
I have a number of functions that I want to be able to call by index. Specifically, I need to be able to call one randomly for the encrypt process, but then address ... | You could write something like:
```
class EncryptionFunction
{
public:
virtual Foo Run(Bar input) = 0;
virtual ~MyFunction() {}
};
class SomeSpecificEncryptionFunction : public EncryptionFunction
{
// override the Run function
};
// ...
std::vector<EncryptionFunction*> functions;
// ...
functions[2]->... |
125,921 | <p>I'm trying to handle Winsock_Connect event (Actually I need it in Excel macro) using the following code:</p>
<pre><code>Dim Winsock1 As Winsock 'Object type definition
Sub Init()
Set Winsock1 = CreateObject("MSWinsock.Winsock") 'Object initialization
Winsock1.RemoteHost = "MyHost"
Winsock1.RemotePort =... | [
{
"answer_id": 125975,
"author": "Nescio",
"author_id": 14484,
"author_profile": "https://Stackoverflow.com/users/14484",
"pm_score": 3,
"selected": true,
"text": "<p>Are you stuck using MSWinsock?<br>\n<a href=\"http://www.ostrosoft.com/oswinsck/oswinsck_reference.aspx\" rel=\"nofollow ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21530/"
] | I'm trying to handle Winsock\_Connect event (Actually I need it in Excel macro) using the following code:
```
Dim Winsock1 As Winsock 'Object type definition
Sub Init()
Set Winsock1 = CreateObject("MSWinsock.Winsock") 'Object initialization
Winsock1.RemoteHost = "MyHost"
Winsock1.RemotePort = "22"
Win... | Are you stuck using MSWinsock?
[Here](http://www.ostrosoft.com/oswinsck/oswinsck_reference.aspx) is a site/tutorial using a custom winsock object.
Also... You need to declare Winsock1 **WithEvents** within a "Class" module:
```
Private WithEvents Winsock1 As Winsock
```
And finally, make sure you reference the w... |
125,934 | <p>I'm writing an application to start and monitor other applications in C#. I'm using the System.Diagnostics.Process class to start applications and then monitor the applications using the Process.Responding property to poll the state of the application every 100 milisecs. I use Process.CloseMainWindow to stop the app... | [
{
"answer_id": 125961,
"author": "Jarod Elliott",
"author_id": 1061,
"author_profile": "https://Stackoverflow.com/users/1061",
"pm_score": 2,
"selected": false,
"text": "<p>I think it may be better to enhance the check for _process.Responding so that you only try to stop/kill the process... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3320/"
] | I'm writing an application to start and monitor other applications in C#. I'm using the System.Diagnostics.Process class to start applications and then monitor the applications using the Process.Responding property to poll the state of the application every 100 milisecs. I use Process.CloseMainWindow to stop the applic... | Now, I need to check this out later, but I am sure there is a method that tells the thread to wait until it is ready for input. Are you monitoring GUI processes only?
Isn't [Process.WaitForInputIdle](http://msdn.microsoft.com/en-us/library/kcdbkyt4.aspx) of any help to you? Or am I missing the point? :)
Update
------... |
125,951 | <p>What is a good command line tool to create screenshots of websites on Linux? I need to automatically generate screenshots of websites without human interaction. The only tool that I found was <a href="http://khtml2png.sourceforge.net/" rel="noreferrer">khtml2png</a>, but I wonder if there are others that aren't base... | [
{
"answer_id": 126000,
"author": "Paul Whelan",
"author_id": 3050,
"author_profile": "https://Stackoverflow.com/users/3050",
"pm_score": 2,
"selected": false,
"text": "<p>I know its not a command line tool but you could easily script up something to use <a href=\"http://browsershots.org/... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4936/"
] | What is a good command line tool to create screenshots of websites on Linux? I need to automatically generate screenshots of websites without human interaction. The only tool that I found was [khtml2png](http://khtml2png.sourceforge.net/), but I wonder if there are others that aren't based on khtml (i.e. have good Java... | A little more detail might be useful...
Start a firefox (or other browser) in an X session, either on your console or using a vncserver. You can use the `--height` and `--width` options to set the size of the window to full screen. Another firefox command can be used to set the URL being displayed in the first firefox... |
125,957 | <p>I know this is not directly a programming question, but people on stackoverflow seems to be able to answer any question.</p>
<p>I have a server running Centos 5.2 64 bit. Pretty powerful dual core 2 server with 4GB memory. It mostly serves static files, flash and pictures. When I use lighttpd it easily serves ov... | [
{
"answer_id": 129855,
"author": "Ross",
"author_id": 14794,
"author_profile": "https://Stackoverflow.com/users/14794",
"pm_score": 2,
"selected": false,
"text": "<p>Perhaps lighttpd is using some kind of caching? There's a great article <a href=\"http://www.igvita.com/2008/02/11/nginx-... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6801/"
] | I know this is not directly a programming question, but people on stackoverflow seems to be able to answer any question.
I have a server running Centos 5.2 64 bit. Pretty powerful dual core 2 server with 4GB memory. It mostly serves static files, flash and pictures. When I use lighttpd it easily serves over 80 MB/sec,... | When you reload your nginx (kiil -HUP) you'll get something like this in your error logs
```
2008/10/01 03:57:26 [notice] 4563#0: signal 1 (SIGHUP) received, reconfiguring
2008/10/01 03:57:26 [notice] 4563#0: reconfiguring
2008/10/01 03:57:26 [notice] 4563#0: using the "epoll" event method
2008/10/01 03:57:26 [notice... |
125,964 | <p>Is there an easier way to step through the code than to start the service through the Windows Service Control Manager and then attaching the debugger to the thread? It's kind of cumbersome and I'm wondering if there is a more straightforward approach.</p>
| [
{
"answer_id": 125980,
"author": "akauppi",
"author_id": 14455,
"author_profile": "https://Stackoverflow.com/users/14455",
"pm_score": 3,
"selected": false,
"text": "<p>You can also start the service through the command prompt (sc.exe).</p>\n\n<p>Personally, I'd run the code as a stand-a... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16440/"
] | Is there an easier way to step through the code than to start the service through the Windows Service Control Manager and then attaching the debugger to the thread? It's kind of cumbersome and I'm wondering if there is a more straightforward approach. | If I want to quickly debug the service, I just drop in a `Debugger.Break()` in there. When that line is reached, it will drop me back to VS. Don't forget to remove that line when you are done.
**UPDATE:** As an alternative to `#if DEBUG` pragmas, you can also use `Conditional("DEBUG_SERVICE")` attribute.
```
[Conditi... |
125,997 | <p>I'm a newbie in C# bu I'm experienced Delphi developer.
In Delphi I can use same code for MenuItem and ToolButton using TAction.OnExecute event and I can disable/enable MenuItem and ToolButton together using TAction.OnUpdate event.
Is there a similar way to do this in C# without using external libraries? Or more - H... | [
{
"answer_id": 126008,
"author": "VVS",
"author_id": 21038,
"author_profile": "https://Stackoverflow.com/users/21038",
"pm_score": 0,
"selected": false,
"text": "<p>You can enable or disable a control and all its children by setting its <a href=\"http://msdn.microsoft.com/en-us/library/s... | 2008/09/24 | [
"https://Stackoverflow.com/questions/125997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21540/"
] | I'm a newbie in C# bu I'm experienced Delphi developer.
In Delphi I can use same code for MenuItem and ToolButton using TAction.OnExecute event and I can disable/enable MenuItem and ToolButton together using TAction.OnUpdate event.
Is there a similar way to do this in C# without using external libraries? Or more - How ... | Try the a modification of the command pattern:
```
public abstract class ToolStripItemCommand
{
private bool enabled = true;
private bool visible = true;
private readonly List<ToolStripItem> controls;
protected ToolStripItemCommand()
{
controls = new List<ToolStripItem>();
}
publi... |
126,005 | <p>Specifically I have a PHP command-line script that at a certain point requires input from the user. I would like to be able to execute an external editor (such as vi), and wait for the editor to finish execution before resuming the script.</p>
<p>My basic idea was to use a temporary file to do the editing in, and t... | [
{
"answer_id": 126031,
"author": "lms",
"author_id": 21359,
"author_profile": "https://Stackoverflow.com/users/21359",
"pm_score": 0,
"selected": false,
"text": "<pre><code>system('vi');\n</code></pre>\n\n<p><a href=\"http://www.php.net/system\" rel=\"nofollow noreferrer\">http://www.php... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10942/"
] | Specifically I have a PHP command-line script that at a certain point requires input from the user. I would like to be able to execute an external editor (such as vi), and wait for the editor to finish execution before resuming the script.
My basic idea was to use a temporary file to do the editing in, and to retrieve... | You can redirect the editor's output to the terminal:
```
system("vim > `tty`");
``` |
126,028 | <p>We have a 3D viewer that uses OpenGL, but our clients sometimes complain about it "not working". We suspect that most of these issues stem from them trying to use, what is in effect a modern 3d realtime game, on a businiss laptop computer.</p>
<p><strong>How can we, in the windows msi installer we use, check for su... | [
{
"answer_id": 126082,
"author": "Nils Pipenbrinck",
"author_id": 15955,
"author_profile": "https://Stackoverflow.com/users/15955",
"pm_score": 1,
"selected": false,
"text": "<p>OpenGL is part of Windows since Windows NT or Win95. It's unlikely that you'll ever find a windows system wher... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4013/"
] | We have a 3D viewer that uses OpenGL, but our clients sometimes complain about it "not working". We suspect that most of these issues stem from them trying to use, what is in effect a modern 3d realtime game, on a businiss laptop computer.
**How can we, in the windows msi installer we use, check for support for openGL... | Depends on what the customers mean by "not working". It could be one of:
1. it does not install/launch at all, because of lack of some OpenGL support.
2. it launches, but crashes further on.
3. it launches, does not crash, but rendering is corrupt.
4. it launches and renders everything correctly, but performance is ab... |
126,036 | <p>Is there a way to know and output the stack size needed by a function at compile time in C ?
Here is what I would like to know :</p>
<p>Let's take some function :</p>
<pre><code>void foo(int a) {
char c[5];
char * s;
//do something
return;
}
</code></pre>
<p>When compiling this function, I would l... | [
{
"answer_id": 126047,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 1,
"selected": false,
"text": "<p>Only the compiler would really know, since it is the guy that puts all your stuff together. You'd have to look a... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11589/"
] | Is there a way to know and output the stack size needed by a function at compile time in C ?
Here is what I would like to know :
Let's take some function :
```
void foo(int a) {
char c[5];
char * s;
//do something
return;
}
```
When compiling this function, I would like to know how much stack space ... | Linux kernel code runs on a 4K stack on x86. Hence they care. What they use to check that, is a perl script they wrote, which you may find as scripts/checkstack.pl in a recent kernel tarball (2.6.25 has got it). It runs on the output of objdump, usage documentation is in the initial comment.
I think I already used it ... |
126,048 | <p>I have a problem where a Web Application needs to (after interaction from the user via Javascript)<br>
1) open a Windows Forms Application<br>
2) send a parameter to the app (e.g. an ID)</p>
<p>Correspondingly, the Windows Forms Application should be able to<br>
1) send parame... | [
{
"answer_id": 126057,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 0,
"selected": false,
"text": "<p>No I don't think it's possible.<br>\nThink of viruses/trojans/spyware. If it were possible to launch an application from ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21552/"
] | I have a problem where a Web Application needs to (after interaction from the user via Javascript)
1) open a Windows Forms Application
2) send a parameter to the app (e.g. an ID)
Correspondingly, the Windows Forms Application should be able to
1) send parameters back to the Web Application (updating ... | What you're asking for is possible but seems awkward.
Trying to call an application from a web page is not something you could do due to security considerations. You could however make a desktop application which would be associated with a certain type of files and then use content-type on the web page to make sure th... |
126,070 | <p>I have an email subject of the form:</p>
<pre><code>=?utf-8?B?T3.....?=
</code></pre>
<p>The body of the email is utf-8 base64 encoded - and has decoded fine.
I am current using Perl's Email::MIME module to decode the email.</p>
<p>What is the meaning of the =?utf-8 delimiter and how do I extract information from... | [
{
"answer_id": 126087,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 6,
"selected": true,
"text": "<p>The <a href=\"http://en.wikipedia.org/wiki/MIME#Encoded-Word\" rel=\"noreferrer\"><code>encoded-word</code></a> t... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21553/"
] | I have an email subject of the form:
```
=?utf-8?B?T3.....?=
```
The body of the email is utf-8 base64 encoded - and has decoded fine.
I am current using Perl's Email::MIME module to decode the email.
What is the meaning of the =?utf-8 delimiter and how do I extract information from this string? | The [`encoded-word`](http://en.wikipedia.org/wiki/MIME#Encoded-Word) tokens (as per [RFC 2047](http://www.faqs.org/rfcs/rfc2047.html)) can occur in values of some headers. They are parsed as follows:
```
=?<charset>?<encoding>?<data>?=
```
Charset is UTF-8 in this case, the encoding is `B` which means base64 (the ot... |
126,094 | <p>Considering that the debug data file is available (PDB) and by using either <strong>System.Reflection</strong> or another similar framework such as <strong>Mono.Cecil</strong>, how to retrieve programmatically the source file name and the line number where a type or a member of a type is declared.</p>
<p>For exampl... | [
{
"answer_id": 126132,
"author": "Richard",
"author_id": 20038,
"author_profile": "https://Stackoverflow.com/users/20038",
"pm_score": -1,
"selected": false,
"text": "<p>you might find some help with these links:</p>\n\n<p><a href=\"http://www.busycode.com/news/index.php/article/news-abo... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/563/"
] | Considering that the debug data file is available (PDB) and by using either **System.Reflection** or another similar framework such as **Mono.Cecil**, how to retrieve programmatically the source file name and the line number where a type or a member of a type is declared.
For example, let's say you have compiled this ... | Up to date method:
```
private static void Log(string text,
[CallerFilePath] string file = "",
[CallerMemberName] string member = "",
[CallerLineNumber] int line = 0)
{
Console.WriteLine("{0}_{1}({2}): {3}", Path.GetFileName(file), member, lin... |
126,100 | <p>What's the fastest way to count the number of keys/properties of an object? Is it possible to do this without iterating over the object? I.e., without doing:</p>
<pre><code>var count = 0;
for (k in myobj) if (myobj.hasOwnProperty(k)) ++count;
</code></pre>
<p>(Firefox did provide a magic <code>__count__</code> prop... | [
{
"answer_id": 126151,
"author": "Confusion",
"author_id": 16784,
"author_profile": "https://Stackoverflow.com/users/16784",
"pm_score": 5,
"selected": false,
"text": "<p>If you are actually running into a performance problem I would suggest wrapping the calls that add/remove properties ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11543/"
] | What's the fastest way to count the number of keys/properties of an object? Is it possible to do this without iterating over the object? I.e., without doing:
```
var count = 0;
for (k in myobj) if (myobj.hasOwnProperty(k)) ++count;
```
(Firefox did provide a magic `__count__` property, but this was removed somewhere... | To do this in any *[ES5](https://en.wikipedia.org/wiki/ECMAScript#5th_Edition)-compatible environment*, such as [Node.js](http://nodejs.org), Chrome, [Internet Explorer 9+](https://en.wikipedia.org/wiki/Internet_Explorer_9), Firefox 4+, or Safari 5+:
```js
Object.keys(obj).length
```
* [Browser compatibility](http:/... |
126,109 | <p>I defined a record named <code>log</code>. I want to create an mnesia table with name <code>log_table</code>. When I try to write a record to table, I get <code>bad_type</code> error as follows:</p>
<pre><code>(node1@kitt)4> mnesia:create_table(log_table, [{ram_copies, [node()]},
... | [
{
"answer_id": 126185,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 0,
"selected": false,
"text": "<p>How does your definition of the log-records look? Do you get the same error if you create a new table from scratch (i.e... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21000/"
] | I defined a record named `log`. I want to create an mnesia table with name `log_table`. When I try to write a record to table, I get `bad_type` error as follows:
```
(node1@kitt)4> mnesia:create_table(log_table, [{ram_copies, [node()]},
{attributes, record_info(fields, l... | By default the record name is assumed to be the same as the table name.
To fix this you should either name your table just `log` or append the option `{record_name, log}` in your table options (as you've done in your fix).
It is usually good practice to let your record and table be named the same thing, it makes the ... |
126,114 | <p><strong>Problem</strong>. I need a way to find Starteam server time through Starteam Java SDK 8.0. Version of server is 8.0.172 so method <code>Server.getCurrentTime()</code> is not available since it was added only in server version 9.0.</p>
<p><strong>Motivation</strong>. My application needs to use views at spec... | [
{
"answer_id": 126516,
"author": "Ioannis",
"author_id": 20428,
"author_profile": "https://Stackoverflow.com/users/20428",
"pm_score": -1,
"selected": false,
"text": "<p><code><stab_in_the_dark></code>\nI'm not familiar with that SDK but from looking at the API if the server is in ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15647/"
] | **Problem**. I need a way to find Starteam server time through Starteam Java SDK 8.0. Version of server is 8.0.172 so method `Server.getCurrentTime()` is not available since it was added only in server version 9.0.
**Motivation**. My application needs to use views at specific dates. So if there's some difference in sy... | After some investigation I haven't found any cleaner solution than using a temporary item. My app requests the item's time of creation and compares it with local time. Here's the method I use to get server time:
```
public Date getCurrentServerTime() {
Folder rootFolder = project.getDefaultView().getRootFolder();... |
126,116 | <p>Is it possbile to execute linux commands with java? I am trying to create a web servlet to allow ftp users to change their passwords without ssh login access. I would like to execute the next commands: </p>
<pre><code># adduser -s /sbin/nologin clientA -d /home/mainclient/clientA
# passwd clientA
# cd /home/maincl... | [
{
"answer_id": 126121,
"author": "Craig Day",
"author_id": 5193,
"author_profile": "https://Stackoverflow.com/users/5193",
"pm_score": 4,
"selected": true,
"text": "<p>Check out <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ProcessBuilder.html\" rel=\"nofollow noreferrer\">... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | Is it possbile to execute linux commands with java? I am trying to create a web servlet to allow ftp users to change their passwords without ssh login access. I would like to execute the next commands:
```
# adduser -s /sbin/nologin clientA -d /home/mainclient/clientA
# passwd clientA
# cd /home/mainclient; chgrp -R ... | Check out [this](http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ProcessBuilder.html).
However, doing what you are talking about is way outside spec, and I wouldnt reccommend it. To get it to work you are going to either run your app server as root, or use some other mechanism to give the user the app server is runn... |
126,138 | <p>I'm trying to run a process and do stuff with its input, output and error streams. The obvious way to do this is to use something like <code>select()</code>, but the only thing I can find in Java that does that is <code>Selector.select()</code>, which takes a <code>Channel</code>. It doesn't appear to be possible to... | [
{
"answer_id": 126366,
"author": "Matt Quail",
"author_id": 15790,
"author_profile": "https://Stackoverflow.com/users/15790",
"pm_score": 3,
"selected": true,
"text": "<p>As you said, the solution <a href=\"https://stackoverflow.com/questions/60302/starting-a-process-with-inherited-stdin... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11815/"
] | I'm trying to run a process and do stuff with its input, output and error streams. The obvious way to do this is to use something like `select()`, but the only thing I can find in Java that does that is `Selector.select()`, which takes a `Channel`. It doesn't appear to be possible to get a `Channel` from an `InputStrea... | As you said, the solution [outlined in this Answer](https://stackoverflow.com/questions/60302/starting-a-process-with-inherited-stdinstdoutstderr-in-java-6#60578) is the traditional way of reading both stdout and stderr from a Process. A thread-per-stream is the way to go, even though it is slightly annoying. |
126,141 | <p>I need to determine which version of GTK+ is installed on Ubuntu</p>
<p>Man does not seem to help</p>
| [
{
"answer_id": 126145,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 5,
"selected": false,
"text": "<p>You can use this command:</p>\n<pre><code>$ dpkg -s libgtk2.0-0|grep '^Version'\n</code></pre>\n"
},
{
"ans... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15352/"
] | I need to determine which version of GTK+ is installed on Ubuntu
Man does not seem to help | [This suggestion](https://stackoverflow.com/a/126145/) will tell you which minor version of 2.0 is installed. Different major versions will have different package names because they can co-exist on the system (in order to support applications built with older versions).
Even for development files, which normally would... |
126,148 | <p>How is the salt generated in HashProvider in Microsoft Enterprise Library when we set SaltEnabled?</p>
<p>Is it random to new machines? Is it some magic number?</p>
<p>(I know what is a salt, the question is what's the actual value of a/the salt in Enterprise Library HashProvider)</p>
| [
{
"answer_id": 128481,
"author": "Corbin March",
"author_id": 7625,
"author_profile": "https://Stackoverflow.com/users/7625",
"pm_score": 2,
"selected": false,
"text": "<p>Edit:</p>\n\n<p>See Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.HashAlgorithmProvider for an example... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How is the salt generated in HashProvider in Microsoft Enterprise Library when we set SaltEnabled?
Is it random to new machines? Is it some magic number?
(I know what is a salt, the question is what's the actual value of a/the salt in Enterprise Library HashProvider) | Edit:
See Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.HashAlgorithmProvider for an example implementation. Hashing steps are:
1. If SaltEnabled, generate random bytes for the salt length using RNGCryptoServiceProvider.
2. Append the salt to the plaintext.
3. Hash the salted plaintext.
4. Then (this is... |
126,154 | <p>I am designing a page to Add/Edit users - I used a repeater control and a table to display users. In users view the individual columns of the table row have labels to display a record values and when users click on edit button, the labels are hidden and text boxes are displayed for users to edit values - The problem... | [
{
"answer_id": 126254,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 0,
"selected": false,
"text": "<p>I'd use JS+CSS... You'll have to get your hands dirty for this one though. Visual Studio isn't going to help you much. </p>... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17296/"
] | I am designing a page to Add/Edit users - I used a repeater control and a table to display users. In users view the individual columns of the table row have labels to display a record values and when users click on edit button, the labels are hidden and text boxes are displayed for users to edit values - The problem is... | Dealing with tables, the question is: can your labels span on multiple text rows (ie: can you have long texts)? If yes, you may encounter layout problems any way. If no, a simple approach can be creating a CSS Class:
```
.CellContent { display:block; width: ...; height: ...; }
```
with your preferred cell width/hei... |
126,164 | <p>Assume the following class:</p>
<pre><code>public class MyEnum: IEnumerator
{
private List<SomeObject> _myList = new List<SomeObject>();
...
}
</code></pre>
<p>It is necessary to implement the IEnumerator methods in MyEnum.
But is it possible to 'delegate' or redirect the implementation for IEnume... | [
{
"answer_id": 126171,
"author": "Paul van Brenk",
"author_id": 1837197,
"author_profile": "https://Stackoverflow.com/users/1837197",
"pm_score": -1,
"selected": false,
"text": "<p>Not unless you derive from List<T>.</p>\n\n<pre><code>public class MyEnum : List<SomeObject>, IEnu... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21568/"
] | Assume the following class:
```
public class MyEnum: IEnumerator
{
private List<SomeObject> _myList = new List<SomeObject>();
...
}
```
It is necessary to implement the IEnumerator methods in MyEnum.
But is it possible to 'delegate' or redirect the implementation for IEnumerator directly to \_myList without nee... | **Method 1:**
Continue to use encapsulation and forward calls to the List implementation.
```
class SomeObject
{
}
class MyEnum : IEnumerable<SomeObject>
{
private List<SomeObject> _myList = new List<SomeObject>();
public void Add(SomeObject o)
{
_myList.Add(o);
}
public IEnumerator<Some... |
126,167 | <p>Application able to record error in OnError, but we are not able to do any redirect or so to show something meaningfull to user.
Any ideas?
I know that we can set maxRequestLength in web.config, but anyway user can exceed this limit and some normal error need to be displayed.</p>
| [
{
"answer_id": 126200,
"author": "Adam Vigh",
"author_id": 1613872,
"author_profile": "https://Stackoverflow.com/users/1613872",
"pm_score": -1,
"selected": false,
"text": "<p>You could check the length of the postedfile (FileUpload.PostedFile.ContentLength), to see if it's below the lim... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11768/"
] | Application able to record error in OnError, but we are not able to do any redirect or so to show something meaningfull to user.
Any ideas?
I know that we can set maxRequestLength in web.config, but anyway user can exceed this limit and some normal error need to be displayed. | As you say you can setup maxRequestLength in your web.config (overriding the default 4MB of your machine.config) and if this limits is exceeded you usually get a HTTP 401.1 error.
In order to handle a generic HTTP error at application level you can setup a CustomError section in your web.config within the system.web s... |
126,179 | <p>If I have a query like, </p>
<pre><code>DELETE FROM table WHERE datetime_field < '2008-01-01 00:00:00'
</code></pre>
<p>does having the <code>datetime_field</code> column indexed help? i.e. is the index only useful when using equality (or inequality) testing, or is it useful when doing an ordered comparison as... | [
{
"answer_id": 126183,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 1,
"selected": false,
"text": "<p>It does, check with a DESCRIBE SELECT FROM table ...</p>\n"
},
{
"answer_id": 126190,
"author": "... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4966/"
] | If I have a query like,
```
DELETE FROM table WHERE datetime_field < '2008-01-01 00:00:00'
```
does having the `datetime_field` column indexed help? i.e. is the index only useful when using equality (or inequality) testing, or is it useful when doing an ordered comparison as well?
>
> (Suggestions for better exec... | Maybe. In general, if there is such an index, it will use a range scan on that index if there is no "better" index on the query. However, if the optimiser decides that the range would end up being too big (i.e. include more than, say 1/3 of the rows), it probably won't use the index at all, as a table scan would be lik... |
126,238 | <p>Imagine to have two RESTful controllers (UsersController, OffersController) and a PagesController (used for static content such as index, about and so on) in your application.</p>
<p>You have the following routes defined:</p>
<pre><code>map.with_options :controller => 'pages' do |pages|
pages.root :action =&g... | [
{
"answer_id": 126849,
"author": "Jeremiah Peschka",
"author_id": 11780,
"author_profile": "https://Stackoverflow.com/users/11780",
"pm_score": 1,
"selected": false,
"text": "<p>Typically, I would abstract out the menuing functionality so that I have a helper method for rendering the Adm... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20467/"
] | Imagine to have two RESTful controllers (UsersController, OffersController) and a PagesController (used for static content such as index, about and so on) in your application.
You have the following routes defined:
```
map.with_options :controller => 'pages' do |pages|
pages.root :action => 'index' # static hom... | One thing you could play with is yield and content\_for, used with a few partials for the menus. For example you could put each section of the menu in a partial and then modify your layout to something like:
```
<%= yield(:menu) %>
```
You then can then specify in your views content\_for and put whatever partials yo... |
126,242 | <p>This is probably explained more easily with an example. I'm trying to find a way of turning a relative URL, e.g. "/Foo.aspx" or "~/Foo.aspx" into a full URL, e.g. <a href="http://localhost/Foo.aspx" rel="noreferrer">http://localhost/Foo.aspx</a>. That way when I deploy to test or stage, where the domain under which ... | [
{
"answer_id": 126258,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 7,
"selected": true,
"text": "<p>Have a play with this (modified <a href=\"http://web.archive.org/web/20130730034405/http://www.aspdotnetfaq.com/Faq/how-to-c... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12277/"
] | This is probably explained more easily with an example. I'm trying to find a way of turning a relative URL, e.g. "/Foo.aspx" or "~/Foo.aspx" into a full URL, e.g. <http://localhost/Foo.aspx>. That way when I deploy to test or stage, where the domain under which the site runs is different, I will get <http://test/Foo.as... | Have a play with this (modified [from here](http://web.archive.org/web/20130730034405/http://www.aspdotnetfaq.com/Faq/how-to-convert-relative-url-to-absolute-url-in-asp-net-page.aspx))
```
public string ConvertRelativeUrlToAbsoluteUrl(string relativeUrl) {
return string.Format("http{0}://{1}{2}",
(Request.... |
126,271 | <p>Does someone have experience with storing key-value pairs in a database?</p>
<p>I've been using this type of table:</p>
<pre><code>CREATE TABLE key_value_pairs (
itemid varchar(32) NOT NULL,
itemkey varchar(32) NOT NULL,
itemvalue varchar(32) NOT NULL,
CONSTRAINT ct_primary... | [
{
"answer_id": 126282,
"author": "Mladen",
"author_id": 21404,
"author_profile": "https://Stackoverflow.com/users/21404",
"pm_score": 1,
"selected": false,
"text": "<p>the first method is quite ok. you can create a UDF that extracts the desired data and just call that.</p>\n"
},
{
... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2887/"
] | Does someone have experience with storing key-value pairs in a database?
I've been using this type of table:
```
CREATE TABLE key_value_pairs (
itemid varchar(32) NOT NULL,
itemkey varchar(32) NOT NULL,
itemvalue varchar(32) NOT NULL,
CONSTRAINT ct_primarykey PRIMARY KEY(itemi... | Before you continue on your approach, I would humbly suggest you step back and consider if you really want to store this data in a "Key-Value Pair"table. I don't know your application but my experience has shown that every time I have done what you are doing, later on I wish I had created a color table, a fabric table ... |
126,277 | <p>Say you want to generate a matched list of identifiers and strings</p>
<pre><code>enum
{
NAME_ONE,
NAME_TWO,
NAME_THREE
};
myFunction(NAME_ONE, "NAME_ONE");
myFunction(NAME_TWO, "NAME_TWO");
myFunction(NAME_THREE, "NAME_THREE");
</code></pre>
<p>..without repeating yourself, and without auto-generating the code, ... | [
{
"answer_id": 126291,
"author": "Kristopher Johnson",
"author_id": 1175,
"author_profile": "https://Stackoverflow.com/users/1175",
"pm_score": 6,
"selected": true,
"text": "<p>For your second #define, you need to use the # preprocessor operator, like this:</p>\n\n<pre><code>#define myDe... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | Say you want to generate a matched list of identifiers and strings
```
enum
{
NAME_ONE,
NAME_TWO,
NAME_THREE
};
myFunction(NAME_ONE, "NAME_ONE");
myFunction(NAME_TWO, "NAME_TWO");
myFunction(NAME_THREE, "NAME_THREE");
```
..without repeating yourself, and without auto-generating the code, using C/C++ macros
**Init... | For your second #define, you need to use the # preprocessor operator, like this:
```
#define myDefine(a) myFunc(a, #a);
```
That converts the argument to a string. |
126,297 | <p>After I <a href="https://stackoverflow.com/questions/121922/automatic-casts">messed up the description of my previous post</a> on this I have sat down and tried to convey my exact intent.</p>
<p>I have a class called P which performs some distinct purpose. I also have PW which perform some distinct purpose on P. PW... | [
{
"answer_id": 126321,
"author": "Rik",
"author_id": 5409,
"author_profile": "https://Stackoverflow.com/users/5409",
"pm_score": 1,
"selected": false,
"text": "<p>If you make P a superclass to PW, like you did in your previous question, you could call p->a() and it would direct to class ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/342/"
] | After I [messed up the description of my previous post](https://stackoverflow.com/questions/121922/automatic-casts) on this I have sat down and tried to convey my exact intent.
I have a class called P which performs some distinct purpose. I also have PW which perform some distinct purpose on P. PW has no member variab... | You could try overriding operator\* and operator-> to return access to the embedded p.
Something like this might do the trick :
```
class P
{
public:
void a( ) { std::cout << "a" << std::endl; }
};
class PW
{
public:
PW(P& p) : p(p) { }
void b( ) { std::cout << "b" << std::endl; }
P & operator*(... |
126,320 | <p>Suppose I have a set of commits in a repository folder...</p>
<pre><code>123 (250 new files, 137 changed files, 14 deleted files)
122 (150 changed files)
121 (renamed folder)
120 (90 changed files)
119 (115 changed files, 14 deleted files, 12 added files)
118 (113 changed files)
117 (10 changed files)
</code></pre>... | [
{
"answer_id": 126357,
"author": "Christian Davén",
"author_id": 12534,
"author_profile": "https://Stackoverflow.com/users/12534",
"pm_score": -1,
"selected": false,
"text": "<p>I suppose you could create a branch from revision 117, then merge everything except 118 and 120.</p>\n\n<pre><... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4200/"
] | Suppose I have a set of commits in a repository folder...
```
123 (250 new files, 137 changed files, 14 deleted files)
122 (150 changed files)
121 (renamed folder)
120 (90 changed files)
119 (115 changed files, 14 deleted files, 12 added files)
118 (113 changed files)
117 (10 changed files)
```
I want to get a worki... | To undo revisions 118 and 120:
```
svn up -r HEAD # get latest revision
svn merge -c -120 . # undo revision 120
svn merge -c -118 . # undo revision 118
svn commit # after solving problems (if any)
```
Also see the description in [Undoing changes](http://svnbook.red-bean.com/en/1.5/svn.branchmerge.b... |
126,332 | <p>I'm wanting a method called same_url? that will return true if the passed in URLs are equal. The passed in URLs might be either params options hash or strings.</p>
<pre><code>same_url?({:controller => :foo, :action => :bar}, "http://www.example.com/foo/bar") # => true
</code></pre>
<p>The Rails Framework ... | [
{
"answer_id": 126693,
"author": "Codebeef",
"author_id": 12037,
"author_profile": "https://Stackoverflow.com/users/12037",
"pm_score": 1,
"selected": false,
"text": "<p>Is this the sort of thing you're after?</p>\n\n<pre><code>def same_url?(one, two)\n url_for(one) == url_for(two)\nend... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19588/"
] | I'm wanting a method called same\_url? that will return true if the passed in URLs are equal. The passed in URLs might be either params options hash or strings.
```
same_url?({:controller => :foo, :action => :bar}, "http://www.example.com/foo/bar") # => true
```
The Rails Framework helper [current\_page?](http://api... | Here's the method (bung it in /lib and require it in environment.rb):
```
def same_page?(a, b, params_to_exclude = {})
if a.respond_to?(:except) && b.respond_to?(:except)
url_for(a.except(params_to_exclude)) == url_for(b.except(params_to_exclude))
else
url_for(a) == url_for(b)
end
end
```
**If you are ... |
126,337 | <p>I have a 2.4 MB XML file, an export from Microsoft Project (hey I'm the victim here!) from which I am requested to extract certain details for re-presentation. Ignoring the intelligence or otherwise of the request, which library should I try first from a Ruby perspective?</p>
<p>I'm aware of the following (in no pa... | [
{
"answer_id": 146733,
"author": "dimus",
"author_id": 23080,
"author_profile": "https://Stackoverflow.com/users/23080",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://code.whytheluckystiff.net/hpricot/wiki/HpricotBasics\" rel=\"nofollow noreferrer\">Hpricot</a> is probabl... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1060/"
] | I have a 2.4 MB XML file, an export from Microsoft Project (hey I'm the victim here!) from which I am requested to extract certain details for re-presentation. Ignoring the intelligence or otherwise of the request, which library should I try first from a Ruby perspective?
I'm aware of the following (in no particular o... | [Hpricot](http://code.whytheluckystiff.net/hpricot/wiki/HpricotBasics) is probably the best tool for you -- it is easy to use and should handle 2mg file with no problem.
Speedwise libxml should be the best. I used libxml2 binding for python few months ago (at that moment rb-libxml was stale). Streaming interface worke... |
126,364 | <p><strong>Intro</strong>: I'm trying to migrate our Trac SQLite to a PostgreSQL backend, to do that I need psycopg2. After clicking past the embarrassing rant on www.initd.org I downloaded the latest version and tried running <code>setup.py install</code>. This didn't work, telling me I needed mingw. So I downloaded a... | [
{
"answer_id": 126494,
"author": "Michael Twomey",
"author_id": 995,
"author_profile": "https://Stackoverflow.com/users/995",
"pm_score": 3,
"selected": true,
"text": "<p>Have you tried the <a href=\"http://www.stickpeople.com/projects/python/win-psycopg/\" rel=\"nofollow noreferrer\">bi... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] | **Intro**: I'm trying to migrate our Trac SQLite to a PostgreSQL backend, to do that I need psycopg2. After clicking past the embarrassing rant on www.initd.org I downloaded the latest version and tried running `setup.py install`. This didn't work, telling me I needed mingw. So I downloaded and installed mingw.
**Prob... | Have you tried the [binary build](http://www.stickpeople.com/projects/python/win-psycopg/) of psycopg2 for windows? If that works with your python then it mitigates the need to build by hand.
I've seen random people ask this question on various lists and it seems one recommendation is to build postgresql by hand to wo... |
126,373 | <p>I write a lot of dynamically generated content (developing under PHP) and I use jQuery to add extra flexibility and functionality to my projects.</p>
<p>Thing is that it's rather hard to add JavaScript in an unobtrusive manner. Here's an example:</p>
<p>You have to generate a random number of <code>div</code> elem... | [
{
"answer_id": 126398,
"author": "roryf",
"author_id": 270,
"author_profile": "https://Stackoverflow.com/users/270",
"pm_score": 3,
"selected": false,
"text": "<p>You need to add something to the divs that defines what type of behaviour they have, then use jQuery to select those divs and... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20603/"
] | I write a lot of dynamically generated content (developing under PHP) and I use jQuery to add extra flexibility and functionality to my projects.
Thing is that it's rather hard to add JavaScript in an unobtrusive manner. Here's an example:
You have to generate a random number of `div` elements each with different fun... | You need to add something to the divs that defines what type of behaviour they have, then use jQuery to select those divs and add the behaviour. One option is to use the class attribute, although arguably this should be used for presentation rather than behaviour. An alternative would be the rel attribute, but I usuall... |
126,401 | <p>Debugging some finance-related SQL code found a strange issue with numeric(24,8) mathematics precision.</p>
<p>Running the following query on your MSSQL you would get A + B * C expression result to be 0.123457</p>
<p>SELECT A,
B,
C,
A + B * C
FROM
(
SELECT CAST(0.12345678 AS NUMERIC(24,8)) AS ... | [
{
"answer_id": 126473,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 4,
"selected": true,
"text": "<p>Just as addition of the float type is inaccurate, multiplication of the decimal types can be inaccurate (or cause in... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21603/"
] | Debugging some finance-related SQL code found a strange issue with numeric(24,8) mathematics precision.
Running the following query on your MSSQL you would get A + B \* C expression result to be 0.123457
SELECT A,
B,
C,
A + B \* C
FROM
(
SELECT CAST(0.12345678 AS NUMERIC(24,8)) AS A,
CAST(0 AS NUMERIC(24,8)) AS B... | Just as addition of the float type is inaccurate, multiplication of the decimal types can be inaccurate (or cause inaccuracy) if you exceed the precision. See [Data Type Conversion](http://msdn.microsoft.com/en-us/library/ms191530%28SQL.90%29.aspx#_decimal) and [decimal and numeric](http://msdn.microsoft.com/en-us/libr... |
126,406 | <p>I would like to change the database files location of MySQL administrator to another drive of my computer. (I run Windows XP SP2 and MySQL Administrator 1.2.8.)</p>
<p>--Under the startup variable --> General Parameters --> I changed <code>Data directory:</code> from <code>C:/Program Files/MySQL/MySQL Server 5.0/... | [
{
"answer_id": 126420,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 5,
"selected": true,
"text": "<p>Normally it works like this:</p>\n\n<ol>\n<li>shut down MySQL</li>\n<li>change the <code>[mysqld]</code> and <cod... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21608/"
] | I would like to change the database files location of MySQL administrator to another drive of my computer. (I run Windows XP SP2 and MySQL Administrator 1.2.8.)
--Under the startup variable --> General Parameters --> I changed `Data directory:` from `C:/Program Files/MySQL/MySQL Server 5.0/data` to `D:/.....`, but aft... | Normally it works like this:
1. shut down MySQL
2. change the `[mysqld]` and `[mysqld_safe]` `datadir` variable in the MySQL configuration
3. change the `basedir` variable in the same section.
4. move the location over
5. restart MySQL
If that doesn't work I have no idea. On linux you can try to move the socket to a ... |
126,409 | <p>What are the ways to eliminate the use of switch in code?</p>
| [
{
"answer_id": 126415,
"author": "Bernard",
"author_id": 61,
"author_profile": "https://Stackoverflow.com/users/61",
"pm_score": 4,
"selected": false,
"text": "<p>Everybody loves HUGE <code>if else</code> blocks. So easy to read! I am curious as to why you would want to remove switch sta... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12514/"
] | What are the ways to eliminate the use of switch in code? | Switch-statements are not an antipattern per se, but if you're coding object oriented you should consider if the use of a switch is better solved with [polymorphism](http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming) instead of using a switch statement.
With polymorphism, this:
```
foreach (var... |
126,430 | <p>Is it possible to change the natural order of columns in Postgres 8.1?</p>
<p>I know that you shouldn't rely on column order - it's not <em>essential</em> to what I am doing - I only need it to make some auto-generated stuff come out in a way that is more pleasing, so that the field order matches all the way from p... | [
{
"answer_id": 126432,
"author": "Nick Johnson",
"author_id": 12030,
"author_profile": "https://Stackoverflow.com/users/12030",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately, no, it's not. Column order is entirely up to Postgres.</p>\n"
},
{
"answer_id": 126437,
... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3408/"
] | Is it possible to change the natural order of columns in Postgres 8.1?
I know that you shouldn't rely on column order - it's not *essential* to what I am doing - I only need it to make some auto-generated stuff come out in a way that is more pleasing, so that the field order matches all the way from pgadmin through th... | You can actually just straight up change the column order, but I'd hardly recommend it, and you should be very careful if you decide to do it.
eg.
```
# CREATE TABLE test (a int, b int, c int);
# INSERT INTO test VALUES (1,2,3);
# SELECT * FROM test;
a | b | c
---+---+---
1 | 2 | 3
(1 row)
```
Now for the trick... |
126,445 | <p>I am implementing a design that uses custom styled submit-buttons. They are quite simply light grey buttons with a slightly darker outer border:</p>
<pre><code>input.button {
background: #eee;
border: 1px solid #ccc;
}
</code></pre>
<p>This looks just right in Firefox, Safari and Opera. The problem is with... | [
{
"answer_id": 126474,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 1,
"selected": false,
"text": "<p>Right, well here's an ugly fix for you to weigh up... Stick the button in a <code><span></code>, nuke the border on t... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1123/"
] | I am implementing a design that uses custom styled submit-buttons. They are quite simply light grey buttons with a slightly darker outer border:
```
input.button {
background: #eee;
border: 1px solid #ccc;
}
```
This looks just right in Firefox, Safari and Opera. The problem is with Internet Explorer, both 6... | Well this works here:
```
<html>
<head>
<style type="text/css">
span.button {
background: #eee;
border: 1px solid #ccc;
}
span.button input {
background:none;
border:0;
margin:0;
... |
126,513 | <p>I am running following <code>PHP</code> code to interact with a MS Access database.</p>
<pre><code>$odbc_con = new COM("ADODB.Connection");
$constr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . $db_path . ";";
$odbc_con -> open($constr);
$rs_select = $odbc_con -> execute ("SELECT * FROM Main");
</code... | [
{
"answer_id": 126543,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 0,
"selected": false,
"text": "<p>Doesn't Access have its own COUNT operator? eg:</p>\n\n<pre><code>$rs_select = $odbc_con -> execute (\"SELECT COUNT(*) F... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6561/"
] | I am running following `PHP` code to interact with a MS Access database.
```
$odbc_con = new COM("ADODB.Connection");
$constr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . $db_path . ";";
$odbc_con -> open($constr);
$rs_select = $odbc_con -> execute ("SELECT * FROM Main");
```
Using `($rs_select -> RecordCou... | ADODB has its own rules for what recordcount is returned depending on the type of recordset you've defined. See:
[MS Knowledge Base article 194973](http://support.microsoft.com/kb/194973)
[W3C Schools article](http://www.w3schools.com/ADO/prop_rs_recordcount.asp)
In the example above, the PHP COM() object is used to... |
126,524 | <p>I could swear I've seen the function (or method) that takes a list, like this <code>[3, 7, 19]</code> and makes it into iterable list of tuples, like so: <code>[(0,3), (1,7), (2,19)]</code> to use it instead of:</p>
<pre><code>for i in range(len(name_of_list)):
name_of_list[i] = something
</code></pre>
<p>but ... | [
{
"answer_id": 126533,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 10,
"selected": true,
"text": "<pre><code>>>> a = [3,4,5,6]\n>>> for i, val in enumerate(a):\n... print i, val\n...\n0 3\n1 4... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37141/"
] | I could swear I've seen the function (or method) that takes a list, like this `[3, 7, 19]` and makes it into iterable list of tuples, like so: `[(0,3), (1,7), (2,19)]` to use it instead of:
```
for i in range(len(name_of_list)):
name_of_list[i] = something
```
but I can't remember the name and googling "iterate ... | ```
>>> a = [3,4,5,6]
>>> for i, val in enumerate(a):
... print i, val
...
0 3
1 4
2 5
3 6
>>>
``` |
126,526 | <p>Has anyone got any suggestions for unit testing a Managed Application Add-In for Office? I'm using NUnit but I had the same issues with MSTest.</p>
<p>The problem is that there is a .NET assembly loaded inside the Office application (in my case, Word) and I need a reference to that instance of the .NET assembly. ... | [
{
"answer_id": 126560,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 2,
"selected": false,
"text": "<p>Consider the various mocking frameworks <a href=\"http://www.nmock.org/\" rel=\"nofollow noreferrer\">NMock</a>, <a hr... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20354/"
] | Has anyone got any suggestions for unit testing a Managed Application Add-In for Office? I'm using NUnit but I had the same issues with MSTest.
The problem is that there is a .NET assembly loaded inside the Office application (in my case, Word) and I need a reference to that instance of the .NET assembly. I can't just... | This is how I resolved it.
1. Just about everything in my add-in runs from the Click method of a button in the UI. I have changed all those Click methods to consist only of a simple, parameterless call.
2. I then created a new file (Partial Class) called EntryPoint that had lots of very short Friend Subs, each of whic... |
126,528 | <p>On the safari browser, the standard <asp:Menu> doesn't render well at all. How can this be fixed?</p>
| [
{
"answer_id": 126709,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 1,
"selected": false,
"text": "<p>You can use ControlAdapters to alter the rendering of server controls.</p>\n\n<p>Here's an example:\n<a href=\"http... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20524/"
] | On the safari browser, the standard <asp:Menu> doesn't render well at all. How can this be fixed? | Thanks for the advice, it led me into the following solution;
I created a file named "safari.browser" and placed it in the App\_Browsers directory. The content of this file is shown below;
```
<browsers>
<browser refID="safari1plus">
<controlAdapters>
<adapter controlType="System.Web.UI.WebCon... |
126,584 | <p>I have a requirement to be be able to embed scanned tiff images into some SSRS reports.</p>
<p>When I design a report in VS2005 and add an image control the tiff image displays perfectly however when I build it. I get the warning :</p>
<p><code>Warning 2 [rsInvalidMIMEType] The value of the MIMEType property ... | [
{
"answer_id": 130950,
"author": "Peter Wone",
"author_id": 1715673,
"author_profile": "https://Stackoverflow.com/users/1715673",
"pm_score": 3,
"selected": true,
"text": "<p>Assuming you're delivering the image file via IIS, use an ASP.NET page to change image formats and mime type to s... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1116/"
] | I have a requirement to be be able to embed scanned tiff images into some SSRS reports.
When I design a report in VS2005 and add an image control the tiff image displays perfectly however when I build it. I get the warning :
`Warning 2 [rsInvalidMIMEType] The value of the MIMEType property for the image ‘image1’ is “... | Assuming you're delivering the image file via IIS, use an ASP.NET page to change image formats and mime type to something that you *can* use.
```
Response.ContentType = "image/png";
Response.Clear();
using (Bitmap bmp = new Bitmap(tifFilepath))
bmp.Save(Response.OutputStream, ImageFormat.Png);
Response.End();
``` |
126,587 | <p>I have an old server with a defunct evaluation version of SQL 2000 on it (from 2006), and two databases which were sitting on it.</p>
<p>For some unknown reason, the LDF log files are missing. Presumed deleted.</p>
<p>I have the mdf files (and in one case an ndf file too) for the databases which used to exist on t... | [
{
"answer_id": 126633,
"author": "Jonathan",
"author_id": 6910,
"author_profile": "https://Stackoverflow.com/users/6910",
"pm_score": 4,
"selected": true,
"text": "<p>I found this answer, which worked with my SQL 2000 machines:</p>\n\n<p><strong>How to attach a database with a non-cleanl... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6910/"
] | I have an old server with a defunct evaluation version of SQL 2000 on it (from 2006), and two databases which were sitting on it.
For some unknown reason, the LDF log files are missing. Presumed deleted.
I have the mdf files (and in one case an ndf file too) for the databases which used to exist on that server, and I... | I found this answer, which worked with my SQL 2000 machines:
**How to attach a database with a non-cleanly detached MDF file.**
**Step 1:** Make a new database with same name, and which uses the same files as the old one on the new server.
**Step 2:** Stop SQL server, and move your mdf files (and any ndf files you h... |