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 |
|---|---|---|---|---|---|---|
550,121 | <p>Basically, I want this:</p>
<pre><code><select size="2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</code></pre>
<p>But instead of having two lines, I want it on a single line. Can this be done without J... | [
{
"answer_id": 550124,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 2,
"selected": false,
"text": "<p>Try this.</p>\n\n<pre><code><select size=\"2\" style=\"height:2em;\">\n <option>1</option>\n ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50475/"
] | Basically, I want this:
```
<select size="2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
```
But instead of having two lines, I want it on a single line. Can this be done without Javascript?
If not, I would imagine it's common enough (though I can't find any releva... | If you *can* use JavaScript, it looks like there are [some options for spinner controls](http://www.google.com/search?hl=en&q=javascript+spinner). [One such control](http://extjs.com/learn/Extension:Ext.ux.form.Spinner) has pretty good UI and functionality. Example:
[](h... |
550,129 | <p>I need to export the pages of an arbitrary PDF document into a series of individual images in jpeg/png/etc format. I need to do this in in Java. </p>
<p>Although I do know about iText, PDFBox and various other java pdf libraries, I am hoping for a pointer to some working example, or some how-to.</p>
<p>Thanks.</p>... | [
{
"answer_id": 550172,
"author": "jedierikb",
"author_id": 62255,
"author_profile": "https://Stackoverflow.com/users/62255",
"pm_score": 5,
"selected": true,
"text": "<p>Here is one way to do it, combining some code fragments from around the web.</p>\n\n<p><strong>How do I draw a PDF int... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31155/"
] | I need to export the pages of an arbitrary PDF document into a series of individual images in jpeg/png/etc format. I need to do this in in Java.
Although I do know about iText, PDFBox and various other java pdf libraries, I am hoping for a pointer to some working example, or some how-to.
Thanks. | Here is one way to do it, combining some code fragments from around the web.
**How do I draw a PDF into an Image?**
[https://pdf-renderer.dev.java.net/examples.html](http://java.net/projects/pdf-renderer)
**Creating a Buffered Image from an Image**
ORIGINAL: <http://www.exampledepot.com/egs/java.awt.image/Image2Bu... |
550,135 | <p>I'm using mod_rewrite to change all the URLs on a site. Example: <code>http://www.site.com/about/</code> becomes <code>http://www.site.com/?action=about</code> (don't worry, I have nice friendly sanity checking). The problem is that for anything other than <code>http://www.site.com/</code> the CSS stylesheet won't l... | [
{
"answer_id": 550139,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 4,
"selected": true,
"text": "<p>Try this.</p>\n\n<pre><code><link rel=\"stylesheet\" href=\"/content/style.css\" type=\"text/css\" />\n</code... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60777/"
] | I'm using mod\_rewrite to change all the URLs on a site. Example: `http://www.site.com/about/` becomes `http://www.site.com/?action=about` (don't worry, I have nice friendly sanity checking). The problem is that for anything other than `http://www.site.com/` the CSS stylesheet won't load. I assume this is because it lo... | Try this.
```
<link rel="stylesheet" href="/content/style.css" type="text/css" />
``` |
550,143 | <pre><code>string webPath = folderPath.Replace("\", "/");
</code></pre>
<p>Hi, I'm trying to replace the above but struggling.
Will I need an apply an escape sequence to /.
If so anyone know what it is in c#.
Any help/hints much appreciated.</p>
| [
{
"answer_id": 550144,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": false,
"text": "<pre><code>string webPath = folderPath.Replace(@\"\\\", \"/\");\n</code></pre>\n"
},
{
"answer_id": 550146,
... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17510/"
] | ```
string webPath = folderPath.Replace("\", "/");
```
Hi, I'm trying to replace the above but struggling.
Will I need an apply an escape sequence to /.
If so anyone know what it is in c#.
Any help/hints much appreciated. | ```
string webPath = folderPath.Replace(@"\", "/");
``` |
550,148 | <p>In C++ you can often drastically improve the readability of your code by careful usage of the "using" keyword, for example: </p>
<pre><code>void foo()
{
std::vector< std::map <int, std::string> > crazyVector;
std::cout << crazyVector[0].begin()->first;
}
</code></pre>
<p>becomes</p>
<... | [
{
"answer_id": 550156,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 3,
"selected": false,
"text": "<pre><code>import X\n</code></pre>\n\n<p>or</p>\n\n<pre><code>from X import *\n</code></pre>\n\n<p>or </p>\n\n<pre><... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8123/"
] | In C++ you can often drastically improve the readability of your code by careful usage of the "using" keyword, for example:
```
void foo()
{
std::vector< std::map <int, std::string> > crazyVector;
std::cout << crazyVector[0].begin()->first;
}
```
becomes
```
void foo()
{
using namespace std; // limited... | As Bill said, Python does have the construction
```
from X import *
```
but you can also explicitly specify which names you want imported from the module (namespace):
```
from X import foo, bar, blah
```
This tends to make the code even more readable/easier to understand, since someone seeing an identifier in the... |
550,181 | <p>Greetings everyone. This is my first question here at stackoverflow so please bear with me. </p>
<p>My programming class this semester is Java; last semester was C++. My Java teacher feels (justifiably, I think) that it is very important for we students to understand the mechanics of memory management. </p>
<p... | [
{
"answer_id": 550184,
"author": "17 of 26",
"author_id": 2284,
"author_profile": "https://Stackoverflow.com/users/2284",
"pm_score": 2,
"selected": false,
"text": "<p>Looks correct to me, with one exception - when you delete arrays you need the following syntax:</p>\n\n<pre><code>delete... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66556/"
] | Greetings everyone. This is my first question here at stackoverflow so please bear with me.
My programming class this semester is Java; last semester was C++. My Java teacher feels (justifiably, I think) that it is very important for we students to understand the mechanics of memory management.
Since Java has autom... | When you use
```
int* i = new int;
```
you pair it with
```
delete i;
```
and when you use
```
int* i = new int [12];
```
you pair it with
```
delete [] i;
```
If there are brackets in the new, there should be brackets in the delete. Otherwise, your program looks reasonable to me, except that you haven't i... |
550,187 | <p>I'm just started to read up on LINQ and I want to start incorporating it into my code. I know how to compute the sum of a DataTable's column by either "Foreach"-ing through the rows or by doing a compute.sum on the specific column. How do I do the equivalent with LINQ to DataSet?</p>
| [
{
"answer_id": 550261,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 7,
"selected": true,
"text": "<p>If untyped (replace <code>int</code> with the correct data type):</p>\n\n<pre><code> var sum = table.AsEnumerable()... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66559/"
] | I'm just started to read up on LINQ and I want to start incorporating it into my code. I know how to compute the sum of a DataTable's column by either "Foreach"-ing through the rows or by doing a compute.sum on the specific column. How do I do the equivalent with LINQ to DataSet? | If untyped (replace `int` with the correct data type):
```
var sum = table.AsEnumerable().Sum(x=>x.Field<int>(3));
```
or:
```
var sum = table.AsEnumerable().Sum(x=>x.Field<int>("SomeProperty"));
```
If typed:
```
var sum = table.Sum(x=>x.SomeProperty);
``` |
550,188 | <p>I'm running VPC 2007 and the OS is windows 3.1 I need to copy a C++ compiler from my real computer to the virtual one. How do I do this, it doesn't seem to read the .iso that I made. I don't have a floppy drive since I'm using a laptop.</p>
| [
{
"answer_id": 550261,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 7,
"selected": true,
"text": "<p>If untyped (replace <code>int</code> with the correct data type):</p>\n\n<pre><code> var sum = table.AsEnumerable()... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56555/"
] | I'm running VPC 2007 and the OS is windows 3.1 I need to copy a C++ compiler from my real computer to the virtual one. How do I do this, it doesn't seem to read the .iso that I made. I don't have a floppy drive since I'm using a laptop. | If untyped (replace `int` with the correct data type):
```
var sum = table.AsEnumerable().Sum(x=>x.Field<int>(3));
```
or:
```
var sum = table.AsEnumerable().Sum(x=>x.Field<int>("SomeProperty"));
```
If typed:
```
var sum = table.Sum(x=>x.SomeProperty);
``` |
550,195 | <p>I want to be able to debug C structures without having to explicitly type every property that they consist of.</p>
<p>i.e. I want to be able to do something like this:</p>
<pre><code>CGPoint cgPoint = CGPointMake(0,0);
NSLog(@"%@",cgPoint);
</code></pre>
<p>Obviously the '%@' won't work, hence the question. </p>
| [
{
"answer_id": 550243,
"author": "Alex",
"author_id": 35999,
"author_profile": "https://Stackoverflow.com/users/35999",
"pm_score": 11,
"selected": true,
"text": "<p>You can try this:</p>\n\n<pre><code>NSLog(@\"%@\", NSStringFromCGPoint(cgPoint));\n</code></pre>\n\n<p>There are a number ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42523/"
] | I want to be able to debug C structures without having to explicitly type every property that they consist of.
i.e. I want to be able to do something like this:
```
CGPoint cgPoint = CGPointMake(0,0);
NSLog(@"%@",cgPoint);
```
Obviously the '%@' won't work, hence the question. | You can try this:
```
NSLog(@"%@", NSStringFromCGPoint(cgPoint));
```
There are a number of functions [provided by UIKit](http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/doc/uid/TP40006894-CH3-SW34) that convert the various CG structs i... |
550,219 | <p>I converted a function to a template, and started getting this error. I must not be understanding a limitation of templates. Can someone tell me why this is broken?</p>
<p>I am receiving this error:</p>
<pre><code>Undefined symbols:
"bool foo<int>(int const&, int const&)", referenced from:
... | [
{
"answer_id": 550222,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 2,
"selected": false,
"text": "<p>It's been years since I did much C++, but I think you are encountering a problem of separate compilation. Templates are ins... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14356/"
] | I converted a function to a template, and started getting this error. I must not be understanding a limitation of templates. Can someone tell me why this is broken?
I am receiving this error:
```
Undefined symbols:
"bool foo<int>(int const&, int const&)", referenced from:
_main in file1.o
ld: symbol(s) not fo... | For the reason Uri gave, template methods are usually defined in the header file. Because yours is a function and not a method of a class, explicitly define it (in the header file which may be included by more than one CPP file) as static or inline.
**Put this in your foo.h**
```
template<class T> inline bool foo (co... |
550,223 | <p>Greetings again, and thanks once more to all of you who provided answers to the first question. The following code is updated to include the two functions per the assignment.</p>
<p>To see the original question, click <a href="https://stackoverflow.com/questions/550181/c-pointer-snippet">here</a>.</p>
<p>I am <em... | [
{
"answer_id": 550231,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 0,
"selected": false,
"text": "<p>Looks reasonable to me.</p>\n\n<p>I'm not sure about submitting a whole new question, though. It might have b... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66556/"
] | Greetings again, and thanks once more to all of you who provided answers to the first question. The following code is updated to include the two functions per the assignment.
To see the original question, click [here](https://stackoverflow.com/questions/550181/c-pointer-snippet).
I am *pretty* sure this fulfills the ... | The code looks good.
However, there are some problems you may want to address, for us humans:
1. Your function signatures (declarations) lack parameter names. More suitable:
```
int** createArray(int rows, int columns);
void deleteArray(int** array, int rows);
```
2. Your function names aren't too descriptive as t... |
550,226 | <p>I am finding it useful to define 'marker' css styles such as <code>'hidden'</code> or <code>'selected'</code> so I can easily mark something as hidden or selected - especially when using a tag based technology like ASP.NET MVC or PHP.</p>
<pre><code>.hidden
{
display:none;
}
.newsItemList li.selected
{
bac... | [
{
"answer_id": 550293,
"author": "HardCode",
"author_id": 62477,
"author_profile": "https://Stackoverflow.com/users/62477",
"pm_score": 1,
"selected": false,
"text": "<p>Let me give you an answer from a very novice web developer who has recently considered using CSS classes as \"markers\... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I am finding it useful to define 'marker' css styles such as `'hidden'` or `'selected'` so I can easily mark something as hidden or selected - especially when using a tag based technology like ASP.NET MVC or PHP.
```
.hidden
{
display:none;
}
.newsItemList li.selected
{
background-color: yellow;
}
```
I don... | I agree with the other posters who say only to define what you need, rather than bloating your code with a bunch of unnecessary classes.
That being said, I find myself using the following on a constant basis:
* .accessibility - visually hide elements, but keep them intact for screenreaders and print stylesheets
* .cl... |
550,227 | <p>I am having trouble importing a Collada file in Papervision3d. I have done an exhaustive Google search to no avail. All the examples and tutorials end with errors, be they "Can't find materials" errors or simply not showing the file at all. I have tried many different types of Collada files, including a lot of Colla... | [
{
"answer_id": 550293,
"author": "HardCode",
"author_id": 62477,
"author_profile": "https://Stackoverflow.com/users/62477",
"pm_score": 1,
"selected": false,
"text": "<p>Let me give you an answer from a very novice web developer who has recently considered using CSS classes as \"markers\... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50391/"
] | I am having trouble importing a Collada file in Papervision3d. I have done an exhaustive Google search to no avail. All the examples and tutorials end with errors, be they "Can't find materials" errors or simply not showing the file at all. I have tried many different types of Collada files, including a lot of Collada'... | I agree with the other posters who say only to define what you need, rather than bloating your code with a bunch of unnecessary classes.
That being said, I find myself using the following on a constant basis:
* .accessibility - visually hide elements, but keep them intact for screenreaders and print stylesheets
* .cl... |
550,246 | <p>I have a simple cocoa user interface with a list of items and a search field, implemented using NSTableView and NSSearchField, respectively. The data source and all of the bindings are set up and working nicely. I see my data in the list, and I can search through it by typing strings in the search field. As I type i... | [
{
"answer_id": 550269,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 3,
"selected": false,
"text": "<p>I figured it out. The following code works:</p>\n\n<pre><code>[searchField setStringValue:@\"\"];\n[[[searchField cell]... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33686/"
] | I have a simple cocoa user interface with a list of items and a search field, implemented using NSTableView and NSSearchField, respectively. The data source and all of the bindings are set up and working nicely. I see my data in the list, and I can search through it by typing strings in the search field. As I type in m... | >
> I figured it out. The following code
> works:
>
>
>
> ```
> [searchField setStringValue:@""];
> [[[searchField cell] cancelButtonCell] performClick:self];
>
> ```
>
> |
550,258 | <p>It used to be considered beneficial to include the 'o' modifier at the end of Perl regular expressions. The current <a href="http://perldoc.perl.org/" rel="noreferrer">Perl documentation</a> does not even seem to list it, certainly not at the <a href="http://perldoc.perl.org/perlre.html#Modifiers" rel="noreferrer">... | [
{
"answer_id": 550313,
"author": "denis phillips",
"author_id": 748,
"author_profile": "https://Stackoverflow.com/users/748",
"pm_score": 2,
"selected": false,
"text": "<p>This is an optimization in the case that the regex includes a variable reference. It indicates that the regex does n... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15168/"
] | It used to be considered beneficial to include the 'o' modifier at the end of Perl regular expressions. The current [Perl documentation](http://perldoc.perl.org/) does not even seem to list it, certainly not at the [modifiers section of perlre](http://perldoc.perl.org/perlre.html#Modifiers).
Does it provide any benefi... | `/o` is deprecated. The simplest way to make sure a regex is compiled only once is to use use a regex object, like so:
```
my $reg = qr/foo$bar/;
```
The interpolation of `$bar` is done when the variable `$reg` is initialized, and the cached, compiled regex will be used from then on within the enclosing scope. But s... |
550,277 | <p>I'm trying to incorporate the following JavaScript Scroller into a website but as soon as I include it in a HTML page that has layout eg. Tables/DIVs it seems to break and won't display. Was wondering if anyone had any advice.</p>
<pre><code><script language="javascript">
//ENTER CONTENT TO SCROLL BELOW.
var ... | [
{
"answer_id": 550304,
"author": "Andy Hume",
"author_id": 46460,
"author_profile": "https://Stackoverflow.com/users/46460",
"pm_score": 2,
"selected": true,
"text": "<p>I know I'm not answering your question, but this will at least help me to sleep tonight. :)</p>\n\n<p>I'm not sure exa... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66572/"
] | I'm trying to incorporate the following JavaScript Scroller into a website but as soon as I include it in a HTML page that has layout eg. Tables/DIVs it seems to break and won't display. Was wondering if anyone had any advice.
```
<script language="javascript">
//ENTER CONTENT TO SCROLL BELOW.
var content='Content to ... | I know I'm not answering your question, but this will at least help me to sleep tonight. :)
I'm not sure exactly what you are trying to do, but I wouldn't use that script. I'm guessing you've copied and pasted it from somewhere, but it looks like it was written a good few years ago, and doesn't really meet many of the... |
550,310 | <p>I have the following line of code in VS2008.</p>
<pre><code> VirtualPathData virtualPathData =
RouteTable.Routes.GetVirtualPath(_viewContext.RequestContext,
"Home",
pageLinkValueDictionary);
</code></pre>
<p>I wish to debug this <code>GetVirtualpath(..)</code> method .. to see what it... | [
{
"answer_id": 550404,
"author": "Jamie",
"author_id": 66585,
"author_profile": "https://Stackoverflow.com/users/66585",
"pm_score": -1,
"selected": false,
"text": "<p>Looks like you're talking about .NET, so it's actually IL byte code you're seeing. I don't think Microsoft releases sym... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I have the following line of code in VS2008.
```
VirtualPathData virtualPathData =
RouteTable.Routes.GetVirtualPath(_viewContext.RequestContext,
"Home",
pageLinkValueDictionary);
```
I wish to debug this `GetVirtualpath(..)` method .. to see what it's trying to do.
I'm assuming I need... | That the symbols file is downloaded doesn't mean that sources are available for it, the pdb needs to be source indexed as well.
From [Scott Guthrie's announcement](http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx):
>
> We'll begin by offering the source... |
550,322 | <p>It's been a long running issue that I've come across in many-a-hot-and-steamy coding sessions.</p>
<p>One person codes this way another codes that way. So after much push and pull I'm curious...
Is there any correct way of phrasing a PHP 'IF ELSE' statement?</p>
<p>Personally I use the:</p>
<pre><code>if ($variab... | [
{
"answer_id": 550325,
"author": "Sam152",
"author_id": 59730,
"author_profile": "https://Stackoverflow.com/users/59730",
"pm_score": 1,
"selected": false,
"text": "<p>In short, the is no <em>correct</em> way of doing. As long as it works, whatever you feel is the best, you can use. You ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66572/"
] | It's been a long running issue that I've come across in many-a-hot-and-steamy coding sessions.
One person codes this way another codes that way. So after much push and pull I'm curious...
Is there any correct way of phrasing a PHP 'IF ELSE' statement?
Personally I use the:
```
if ($variable == 'setvalue')
{
$var... | I personally format my if/else like the last one:
```
if ($variable == 'setvalue') {
$variable = executefunctiononvariable($variable);
} else {
$variable = executedifferentfunctiononvariable($variable);
}
```
Your version is kind a mixture of 1 and 3, in my mind.
I have also worked with coders that do all o... |
550,337 | <p>I am building a multi-user web application. Each user can have their own site under my application. I am considering how to allow user to modify template without security problem? I have evaluated some python template engine. For example, genshi, it is a pretty wonderful template engine, but however it might be dang... | [
{
"answer_id": 550344,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": -1,
"selected": false,
"text": "<p>The short answer is probably \"you can't\".</p>\n\n<p>The best you can probably do is to trap the individual us... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25077/"
] | I am building a multi-user web application. Each user can have their own site under my application. I am considering how to allow user to modify template without security problem? I have evaluated some python template engine. For example, genshi, it is a pretty wonderful template engine, but however it might be dangero... | Look at [Django templte engine](http://docs.djangoproject.com/en/dev/topics/templates/#topics-templates). It does not support execution of arbitrary python code and all accessible variables must be passed into template explicity. This should be pretty good foundation for building user-customizable pages. Beware that yo... |
550,370 | <p>a quick question. I am using the jQuery.forms.js plug-in. </p>
<p>I have a form that posts to a php page and returns data with jSon. </p>
<p>The data that is returned is code for a new form (it replaces the form that was used to post the information). The new form is not bound to any jQuery functions, as it was no... | [
{
"answer_id": 550377,
"author": "airportyh",
"author_id": 5304,
"author_profile": "https://Stackoverflow.com/users/5304",
"pm_score": 2,
"selected": false,
"text": "<p>You need to rebind the event handlers after the ajax call. I heard about a new feature in the newer version of jquery c... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54259/"
] | a quick question. I am using the jQuery.forms.js plug-in.
I have a form that posts to a php page and returns data with jSon.
The data that is returned is code for a new form (it replaces the form that was used to post the information). The new form is not bound to any jQuery functions, as it was not around when the... | The easiest solution to this is not using jQuery's form plugin and doing it manually, which is really not very difficult:
```
$(document).ready(function() {
jQuery('form[id*=postOnline]').live('submit', function() {
var formdata = $(this).serialize();
$.ajax({
type: $(this).attr('metho... |
550,374 | <p>Here's the scenario... </p>
<pre><code>if (entry.Properties["something"].Value != null)
attribs.something = entry.Properties["something"].Value.ToString();
</code></pre>
<p>While effective and working correctly, this looks ugly to me. If I don't check for a null before performing the ToString() then it throws ... | [
{
"answer_id": 550378,
"author": "Rex M",
"author_id": 67,
"author_profile": "https://Stackoverflow.com/users/67",
"pm_score": 8,
"selected": true,
"text": "<p>Update 8 years later (wow!) to cover <a href=\"https://msdn.microsoft.com/en-us/library/dn986595.aspx\" rel=\"noreferrer\">c# 6'... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51949/"
] | Here's the scenario...
```
if (entry.Properties["something"].Value != null)
attribs.something = entry.Properties["something"].Value.ToString();
```
While effective and working correctly, this looks ugly to me. If I don't check for a null before performing the ToString() then it throws an exception if the property... | Update 8 years later (wow!) to cover [c# 6's null-conditional operator](https://msdn.microsoft.com/en-us/library/dn986595.aspx):
```
var value = maybeNull?.ToString() ?? String.Empty;
```
Other approaches:
```
object defaultValue = "default";
attribs.something = (entry.Properties["something"].Value ?? defaultValue)... |
550,401 | <p>Lest my question is not clear; I don't mean dynamically replacing <code><p></code> nodes with <code><textarea></code>. I mean editing each and all text directly - including headers, text in <code><div></code> and <code><span></code> and yes editing tables. I know this is possible in IE and I ... | [
{
"answer_id": 550407,
"author": "Scott Evernden",
"author_id": 11397,
"author_profile": "https://Stackoverflow.com/users/11397",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://getfirebug.com/\" rel=\"nofollow noreferrer\">Firebug Extension</a> for Firefox pretty much all... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66580/"
] | Lest my question is not clear; I don't mean dynamically replacing `<p>` nodes with `<textarea>`. I mean editing each and all text directly - including headers, text in `<div>` and `<span>` and yes editing tables. I know this is possible in IE and I have a script which switches between editable and back which works in I... | In firefox > 3 you can use *contentEditable* for html elements I understood. A tag looks like this:
```
<div id="myEditableDiv" contentEditable="true">click here to edit ...</div>
```
you can control the editing process with 'execCommand' (see: [msdn](http://msdn.microsoft.com/en-us/library/ms533049(VS.85).aspx) for... |
550,405 | <p>I'm trying to use the <a href="http://www.stupendous.net/projects/bencoding-obj-c-class/" rel="noreferrer">BEncoding ObjC class</a> to decode a <code>.torrent</code> file.</p>
<pre><code>NSData *rawdata = [NSData dataWithContentsOfFile:@"/path/to/the.torrent"];
NSData *torrent = [BEncoding objectFromEncodedData:raw... | [
{
"answer_id": 550412,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 3,
"selected": false,
"text": "<p>Aha, the <code>NSString</code> method <code>stringWithCString</code> works correctly:</p>\n\n<p>With the <code>bencoding.h/.m</... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] | I'm trying to use the [BEncoding ObjC class](http://www.stupendous.net/projects/bencoding-obj-c-class/) to decode a `.torrent` file.
```
NSData *rawdata = [NSData dataWithContentsOfFile:@"/path/to/the.torrent"];
NSData *torrent = [BEncoding objectFromEncodedData:rawdata];
```
When I `NSLog` `torrent` I get the follo... | >
>
> ```
> NSData *torrent = [BEncoding objectFromEncodedData:rawdata];
>
> ```
>
> When I NSLog torrent I get the following:
>
>
>
> ```
> {
> ⋮
> }
>
> ```
>
>
That would be an NSDictionary, then, not an NSData.
>
>
> ```
> unsigned char aBuffer[[name length]];
> [name getBytes:aBuffer length:[name... |
550,418 | <p>I wrote a little "lazy vector" class (or, delayed vector) which is supposed to look like a <code>std::vector</code> and usable wherever a <code>std::vector</code> is used, but it loads its elements "lazily", i.e. it will load element <code>n</code> (and possibly a few more) from disk whenever someone accesses elemen... | [
{
"answer_id": 550421,
"author": "Miles",
"author_id": 64474,
"author_profile": "https://Stackoverflow.com/users/64474",
"pm_score": 2,
"selected": false,
"text": "<p>Use the <a href=\"http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.13\" rel=\"nofollow noreferrer\">mu... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60628/"
] | I wrote a little "lazy vector" class (or, delayed vector) which is supposed to look like a `std::vector` and usable wherever a `std::vector` is used, but it loads its elements "lazily", i.e. it will load element `n` (and possibly a few more) from disk whenever someone accesses element `n`. (The reason is that in my app... | You can either use mutable member data or const\_cast in the implementation of your LazyVector class. Thus you can create the illusion of constness needed by your consuming class without actually being const. |
550,428 | <p>I'm having some trouble with a particular piece of code, if anyone can enlighten me on this matter it would be greatly appreciated, I've isolated the problem down in the following sample:</p>
<pre><code>#include <iostream>
using namespace std;
class testing{
int test();
int test1(const testing& te... | [
{
"answer_id": 550431,
"author": "Tom Alsberg",
"author_id": 66034,
"author_profile": "https://Stackoverflow.com/users/66034",
"pm_score": 7,
"selected": true,
"text": "<p>The problem is calling a non-<code>const</code> function <code>test2.test()</code> on a <code>const</code> object <c... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60893/"
] | I'm having some trouble with a particular piece of code, if anyone can enlighten me on this matter it would be greatly appreciated, I've isolated the problem down in the following sample:
```
#include <iostream>
using namespace std;
class testing{
int test();
int test1(const testing& test2);
};
int testing::t... | The problem is calling a non-`const` function `test2.test()` on a `const` object `test2` from `testing::test1`.
`testing::test1` gets `test2` as a parameter `const testing &test2`. So within `testing::test1`, `test2const`. Then in the first line of the function:
```
test2.test()
```
The `testing::test` function is ... |
550,445 | <p>I have a SQL Server 2008 table with a column of the geography datatype. The value is a point (latitude and longitude). </p>
<p>How do I query the table to return all rows where the location is within a 10 kilometer radius of a given coordinate?</p>
| [
{
"answer_id": 550473,
"author": "pawstrong",
"author_id": 66307,
"author_profile": "https://Stackoverflow.com/users/66307",
"pm_score": 3,
"selected": false,
"text": "<p>You probably want the STDistance method:\n<a href=\"http://msdn.microsoft.com/en-us/library/bb933952.aspx\" rel=\"nor... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10932/"
] | I have a SQL Server 2008 table with a column of the geography datatype. The value is a point (latitude and longitude).
How do I query the table to return all rows where the location is within a 10 kilometer radius of a given coordinate? | This query eventually solved my problem:
```
DECLARE @geoMyPoint geography
SET @geoMyPoint = geography::STGeomFromText('POINT(56.5667 9.0333)', 4326);
SELECT vchZipCode, nvcCity, vchLat, vchLong,
(geography::STGeomFromText('POINT(' + vchLat + ' ' + vchLong + ')', 4326)).STDistance(@geoMyPoint)
FROM MyTable
``` |
550,448 | <p>I'm using JSF with facelets and I need to get the request and session parameters inside the JSF page. In JSP pages I got this parameter like that: <code>"${requestScope.paramName}"</code> or <code>"${sessionScope.paramName}"</code>. But now after using JSF there are only beans and you can't get any value except bean... | [
{
"answer_id": 550718,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 7,
"selected": false,
"text": "<p>You can get a request parameter <em>id</em> using the expression:</p>\n\n<pre><code><h:outputText value=\"#{param['id']... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using JSF with facelets and I need to get the request and session parameters inside the JSF page. In JSP pages I got this parameter like that: `"${requestScope.paramName}"` or `"${sessionScope.paramName}"`. But now after using JSF there are only beans and you can't get any value except bean attributes.
NOTE: The s... | You can get a request parameter *id* using the expression:
```
<h:outputText value="#{param['id']}" />
```
* *param*—An immutable Map of the request parameters for this request, keyed by
parameter name. Only the first value for each parameter name is included.
* *sessionScope*—A Map of the session attributes for thi... |
550,451 | <p>I know that according to C++ standard in case the new fails to allocate memory it is supposed to throw std::bad_alloc exception. But I have heard that some compilers such as VC6 (or CRT implementation?) do not adhere to it. Is this true ? I am asking this because checking for NULL after each and every new statement ... | [
{
"answer_id": 550453,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 3,
"selected": false,
"text": "<p>Based on the C++ spec, it will always throw std::bad_alloc when you use just plain new with no params, but of cour... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39742/"
] | I know that according to C++ standard in case the new fails to allocate memory it is supposed to throw std::bad\_alloc exception. But I have heard that some compilers such as VC6 (or CRT implementation?) do not adhere to it. Is this true ? I am asking this because checking for NULL after each and every new statement ma... | VC6 was non-compliant by default in this regard. VC6's `new` returned `0` (or `NULL`).
Here's Microsoft's KB Article on this issue along with their suggested workaround using a custom `new` handler:
* [Operator new does not throw a bad\_alloc exception on failure in Visual C++](http://support2.microsoft.com/kb/167733... |
550,455 | <p>I have the following code:</p>
<pre><code>#include <iostream>
using namespace std;
class testing{
int test() const;
int test1(const testing& test2);
};
int testing::test() const{
return 1;
}
int testing::test1(const testing& test2){
test2.test();
return 1;
}
</code></pre>
<p>after ... | [
{
"answer_id": 550459,
"author": "Himadri Choudhury",
"author_id": 66344,
"author_profile": "https://Stackoverflow.com/users/66344",
"pm_score": 2,
"selected": false,
"text": "<p>If you declare the main function in another file, then you must compile the two files separately, and then li... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60893/"
] | I have the following code:
```
#include <iostream>
using namespace std;
class testing{
int test() const;
int test1(const testing& test2);
};
int testing::test() const{
return 1;
}
int testing::test1(const testing& test2){
test2.test();
return 1;
}
```
after compilation, it gives me the following e... | You have tried to link it already:
```
g++ file.cpp
```
That will not only compile it, but try to already create the executable. The linker then is unable to find the main function that it needs. Well, do it like this:
```
g++ -c file.cpp
g++ -c hasmain.cpp
```
That will create two files file.o and hasmain.o, bot... |
550,467 | <p>I guess there are two major approaches to date representations in XML:</p>
<pre><code><date>1984-10-27</date>
</code></pre>
<p>and </p>
<pre><code><date>
<year>1984</year>
<month>10</month>
<day>27</day>
</date>
</code></pre>
<p>Personally I would... | [
{
"answer_id": 550482,
"author": "pawstrong",
"author_id": 66307,
"author_profile": "https://Stackoverflow.com/users/66307",
"pm_score": 3,
"selected": false,
"text": "<p>Practical experience has taught me that the easiest date values to work with is seconds-since-epoch. This value is p... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66056/"
] | I guess there are two major approaches to date representations in XML:
```
<date>1984-10-27</date>
```
and
```
<date>
<year>1984</year>
<month>10</month>
<day>27</day>
</date>
```
Personally I would go for the former. It's more compact and at the same time more readable. The split-up of the second form see... | The standard for dates/times in xml is much more formal than that; most xml parsers will respect (for example):
* 2009-02-15
* 2009-02-15T10:20:34.0000000
* 2009-02-15T10:20:34.0000000+00:00
This is always yyyy-MM-dd; the time portion is optional, as is the UTC offset.
(edit: [lucas-insasho](https://stackoverflow.co... |
550,469 | <p>I am trying to access entity class but getting the error message "No overload method for CreateDoctor takse 3 argument" Here is my code please modify somebody..
DoctorProperty class:</p>
<pre><code>public class DoctorProperty //class for doctor table
{
int _Id;
string _Name;
string _Address;
int _Ph... | [
{
"answer_id": 550482,
"author": "pawstrong",
"author_id": 66307,
"author_profile": "https://Stackoverflow.com/users/66307",
"pm_score": 3,
"selected": false,
"text": "<p>Practical experience has taught me that the easiest date values to work with is seconds-since-epoch. This value is p... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59637/"
] | I am trying to access entity class but getting the error message "No overload method for CreateDoctor takse 3 argument" Here is my code please modify somebody..
DoctorProperty class:
```
public class DoctorProperty //class for doctor table
{
int _Id;
string _Name;
string _Address;
int _Phone;
publi... | The standard for dates/times in xml is much more formal than that; most xml parsers will respect (for example):
* 2009-02-15
* 2009-02-15T10:20:34.0000000
* 2009-02-15T10:20:34.0000000+00:00
This is always yyyy-MM-dd; the time portion is optional, as is the UTC offset.
(edit: [lucas-insasho](https://stackoverflow.co... |
550,470 | <p>Am I able to overload the <code>print</code> function and call the normal function from within? What I want to do is after a specific line I want <code>print</code> to call my <code>print</code> which will call the normal <code>print</code> and write a copy to file.</p>
<p>Also I don't know how to overload <code>pr... | [
{
"answer_id": 550477,
"author": "Joonas Pulakka",
"author_id": 59279,
"author_profile": "https://Stackoverflow.com/users/59279",
"pm_score": 2,
"selected": false,
"text": "<p>In Python 2.x you can't, because print isn't a function, it's a statement. In Python 3 print is a function, so I... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Am I able to overload the `print` function and call the normal function from within? What I want to do is after a specific line I want `print` to call my `print` which will call the normal `print` and write a copy to file.
Also I don't know how to overload `print`. I don't know how to do variable length arguments. I'l... | For those reviewing the previously dated answers, as of version release "Python 2.6" there is a new answer to the original poster's question.
In Python 2.6 and up, you can disable the print statement in favor of the print function, and then override the print function with your own print function:
```
from __future__... |
550,474 | <p>I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.</p>
<p>So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.</p>
<p>So my question is which one to study? Which languag... | [
{
"answer_id": 550485,
"author": "Chris Lutz",
"author_id": 60777,
"author_profile": "https://Stackoverflow.com/users/60777",
"pm_score": 2,
"selected": false,
"text": "<p>As a Perlite, I'm just going to point out that OS X has Perl as well as Python or Ruby.</p>\n\n<p>As far as Perl/Pyt... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33411/"
] | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see th... | I use all the languages C++, Ruby, Python and Objective-C. I like each one in different ways. If you want to get into Mac and iPhone development as others I recommend Objective-C.
One of the benefits not mentioned is that Objective-C is a proper superset of C (C++ is almost a superset), that means you can bring over ... |
550,479 | <p>In the answer to question #<a href="https://stackoverflow.com/questions/56107/what-is-the-best-way-to-parse-html-in-c">56107</a>, Erlend provided this sample c# code:</p>
<pre><code>using mshtml;
...
object[] oPageText = { html };
HTMLDocument doc = new HTMLDocumentClass();
IHTMLDocument2 doc2 = (IHTMLDocument2)doc... | [
{
"answer_id": 550492,
"author": "Jim Counts",
"author_id": 36737,
"author_profile": "https://Stackoverflow.com/users/36737",
"pm_score": 5,
"selected": true,
"text": "<p>Found an answer to my own question:</p>\n\n<p><a href=\"http://web.archive.org/web/20081006160223/http://radio.javara... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36737/"
] | In the answer to question #[56107](https://stackoverflow.com/questions/56107/what-is-the-best-way-to-parse-html-in-c), Erlend provided this sample c# code:
```
using mshtml;
...
object[] oPageText = { html };
HTMLDocument doc = new HTMLDocumentClass();
IHTMLDocument2 doc2 = (IHTMLDocument2)doc;
doc2.write(oPageText);
... | Found an answer to my own question:
[MSHTML in ASP.NET](http://web.archive.org/web/20081006160223/http://radio.javaranch.com/balajidl/2006/01/18/1137606354980.html)
>
> If you are interested, here is the solution based on VB.NET which you can use with
> ASP.NET(.aspx.vb). Make sure you add reference to Microsoft.m... |
550,490 | <p>I tried to include the following unsuccessfully to my ~/.profile:</p>
<pre><code>export PATH='$HOME/opt/git/bin'
</code></pre>
<p>It seems not to work because $git gives me nothing.
I am trying to install Git.</p>
<p>I have also tried commands <a href="https://stackoverflow.com/questions/315911/git-for-beginners-... | [
{
"answer_id": 550497,
"author": "Himadri Choudhury",
"author_id": 66344,
"author_profile": "https://Stackoverflow.com/users/66344",
"pm_score": 1,
"selected": false,
"text": "<p>This should have worked. </p>\n\n<p>Where does $HOME point to? </p>\n\n<p>Make sure that $HOME/opt/git/bin ac... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54964/"
] | I tried to include the following unsuccessfully to my ~/.profile:
```
export PATH='$HOME/opt/git/bin'
```
It seems not to work because $git gives me nothing.
I am trying to install Git.
I have also tried commands [here](https://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide/3237... | You'll want to be careful with that command. It will **override** your $PATH.
You might need to put it in `~/.bash_profile` and change it to this:
```
export PATH="$HOME/opt/git/bin:$PATH"
``` |
550,494 | <p>I'm trying to make a simple MySQL Admin thing with php and jQuery. I've never used jQuery so my code is probably quite lol-worthy. The problem I'm having with the code is that when I click the button, nothing happens. I know the even fires because if I open the html file in firefox (not going to the url, using the f... | [
{
"answer_id": 550547,
"author": "bhollis",
"author_id": 11284,
"author_profile": "https://Stackoverflow.com/users/11284",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure exactly what the question is. But you don't need the $(function() {}) inside your $.get callback - passing... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I'm trying to make a simple MySQL Admin thing with php and jQuery. I've never used jQuery so my code is probably quite lol-worthy. The problem I'm having with the code is that when I click the button, nothing happens. I know the even fires because if I open the html file in firefox (not going to the url, using the file... | Ok, firstly **don't do that** and by "that" I mean:
* Don't put DB connection details in Javascript; and
* Don't use input from the user without sanitizing it. You're just asking to be hacked.
That being said, your main problem seems to be that `$(#content)` should be `$("#content")`. Also putting an onclick on the b... |
550,508 | <p>So far the <code>hyperref</code> package in LaTeX has automatically linked all the items in my report correctly. But there is one that did not get linked properly, possibly because I manually added it to the table of contents like this:</p>
<pre><code>\addcontentsline{toc}{chapter}{Bibliography}
</code></pre>
<p>H... | [
{
"answer_id": 550519,
"author": "Diego Sevilla",
"author_id": 62365,
"author_profile": "https://Stackoverflow.com/users/62365",
"pm_score": 4,
"selected": true,
"text": "<p>You have to use the <code>\\phantomsection</code> macro just before or after the <code>\\addtocontentsline</code>.... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58521/"
] | So far the `hyperref` package in LaTeX has automatically linked all the items in my report correctly. But there is one that did not get linked properly, possibly because I manually added it to the table of contents like this:
```
\addcontentsline{toc}{chapter}{Bibliography}
```
How do I fix this? | You have to use the `\phantomsection` macro just before or after the `\addtocontentsline`. This instructs `hyperref` to add an anchor at that point. Also, take into account that you have to run LaTeX several times to make this anchor to be in the exact place. |
550,522 | <p>I’m having some problems with John Guenin's x_sendfile (<a href="http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/" rel="nofollow noreferrer">http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/</a>).</p>
<p>When coding the download of a PDF file, I’m using the following code:</p>... | [
{
"answer_id": 552232,
"author": "Jeremy Weiskotten",
"author_id": 61123,
"author_profile": "https://Stackoverflow.com/users/61123",
"pm_score": 3,
"selected": true,
"text": "<p>What version of Rails are you using? If you're on 2.1 or later, the X-Sendfile option is built into Rails' sen... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22687/"
] | I’m having some problems with John Guenin's x\_sendfile (<http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/>).
When coding the download of a PDF file, I’m using the following code:
```
def send_the_file(filename)
xsendfile (“#{Rails.root}/doc/” + filename, :type => ‘application/pdf’)
end
```
bu... | What version of Rails are you using? If you're on 2.1 or later, the X-Sendfile option is built into Rails' send\_file method.
```
send_file 'filename', :x_sendfile => true
```
Otherwise, are you sure that mod\_xsendfile has been installed and configured correctly? |
550,525 | <p>Using Apache2 on a Linux system is there a way to have multiple VirtualDocumentRoot using <a href="http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html" rel="noreferrer">mod_vhost_alias</a>?</p>
<p>This is naming convention I am currently using and would like to continue to use:</p>
<pre><code>host ... | [
{
"answer_id": 550581,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 4,
"selected": false,
"text": "<p>Apache typically will pick the first virtual host whose <code>ServerName</code> or <code>ServerAlias</code> matches the... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52130/"
] | Using Apache2 on a Linux system is there a way to have multiple VirtualDocumentRoot using [mod\_vhost\_alias](http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html)?
This is naming convention I am currently using and would like to continue to use:
```
host directory
127.0.0.1 domain doma... | Apache typically will pick the first virtual host whose `ServerName` or `ServerAlias` matches the host name provided in the `Host` HTTP header. In your case, since you have no `ServerName` directives, Apache supposedly uses a reverse DNS lookup on the IP address to fake a server name, and presuming that the reverse DNS... |
550,536 | <p>I am trying to learn WPF and so far I love it. However, there is something missing or simply something that I don't understand. How can we display multiple layers of controls in WPF? Attached, the screenshot gives a good idea of what I am trying to do. I have a window and I want to display something else on top of i... | [
{
"answer_id": 550541,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know much about WPF myself, but is the <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.contr... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42024/"
] | I am trying to learn WPF and so far I love it. However, there is something missing or simply something that I don't understand. How can we display multiple layers of controls in WPF? Attached, the screenshot gives a good idea of what I am trying to do. I have a window and I want to display something else on top of it. ... | Placing two elements into the same row/column in a Grid simply overlays them. You can then use the Visibility on each element to show/hide them. So for example:
```
<Grid>
... row/column definitions
<Grid Grid.Row="0" Grid.Column="0">
... main content here
</Grid>
<Grid Grid.Row="0" Grid.Column... |
550,548 | <p>I'm having a strange behavior with an operator overloading in C++. I have a class, and I need to check if its contents are greater or equal to a long double. I overloaded the >= operator to make this check, my declaration is as follows:</p>
<pre><code>bool MyClass::operator>=(long double value) const;
</code></p... | [
{
"answer_id": 550553,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 0,
"selected": false,
"text": "<p>You've got <code>long double</code> in the declaration. Try changing it to <code>double</code>.</p>\n"
},
... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25418/"
] | I'm having a strange behavior with an operator overloading in C++. I have a class, and I need to check if its contents are greater or equal to a long double. I overloaded the >= operator to make this check, my declaration is as follows:
```
bool MyClass::operator>=(long double value) const;
```
I have to say that I ... | **2015 update:** Or, if you want to keep conversion ability using the `(double)obj` syntax instead the `obj.to_double()` syntax, make the conversion function `explicit` by prefixing it with that keyword. You need an explicit cast then for the conversion to trigger. Personally, I prefer the `.to_double` syntax, unless t... |
550,556 | <p>I have an interesting problem, and I can't seem to figure out the lambda expression to make this work.</p>
<p>I have the following code:</p>
<pre><code>List<string[]> list = GetSomeData(); // Returns large number of string[]'s
List<string[]> list2 = GetSomeData2(); // similar data, but smaller subset
&... | [
{
"answer_id": 550562,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>You could join? I'd use two steps myself, though:</p>\n\n<pre><code>var keys = new HashSet<string>(list2.Sele... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61164/"
] | I have an interesting problem, and I can't seem to figure out the lambda expression to make this work.
I have the following code:
```
List<string[]> list = GetSomeData(); // Returns large number of string[]'s
List<string[]> list2 = GetSomeData2(); // similar data, but smaller subset
List<string[]> newList = li... | You could join? I'd use two steps myself, though:
```
var keys = new HashSet<string>(list2.Select(x => x[0]));
var data = list.Where(x => keys.Contains(x[0]));
```
If you only have .NET 2.0, then either install [LINQBridge](http://www.albahari.com/nutshell/linqbridge.aspx) and use the above (or similar with a `Dicti... |
550,571 | <p>What is the complexity of:</p>
<pre><code>int f4(int n)
{
int i, j, k=1, count = 0;
for(i = 0; i < n; i++)
{
k *= 3;
for(j = k; j; j /= 2)
count++;
}
return count;
}
</code></pre>
<p>I know it is O(n^2) but how do you calculate this? and why isn't it n*log n?</p>
| [
{
"answer_id": 550586,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>There are n outer loops. At any point, <code>k = 3<sup>i</sup></code>. There are <code>log2(k)</code> inner loops (bec... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63995/"
] | What is the complexity of:
```
int f4(int n)
{
int i, j, k=1, count = 0;
for(i = 0; i < n; i++)
{
k *= 3;
for(j = k; j; j /= 2)
count++;
}
return count;
}
```
I know it is O(n^2) but how do you calculate this? and why isn't it n\*log n? | There are n outer loops. At any point, `k = 3i`. There are `log2(k)` inner loops (because we halve `j` on each iteration.)
>
> `log2(3i) = log3 (3i) / log3(2) = i / (constant)`
>
>
>
So the complexity of the inner loop is `i`. In other words, this program has the same *complexity* (but not the exact same number o... |
550,574 | <p>How can I exit the JavaScript script much like PHP's <code>exit</code> or <code>die</code>? I know it's not the best programming practice but I need to.</p>
| [
{
"answer_id": 550583,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 8,
"selected": true,
"text": "<p><a href=\"https://github.com/kvz/phpjs/blob/master/experimental/misc/die.js\" rel=\"noreferrer\">JavaScript equival... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64106/"
] | How can I exit the JavaScript script much like PHP's `exit` or `die`? I know it's not the best programming practice but I need to. | [JavaScript equivalent for PHP's `die`](https://github.com/kvz/phpjs/blob/master/experimental/misc/die.js). BTW it just calls [`exit()`](https://github.com/kvz/phpjs/blob/master/experimental/misc/exit.js) (thanks splattne):
```
function exit( status ) {
// http://kevin.vanzonneveld.net
// + original by: Bret... |
550,587 | <p>I have the following rewrite rules in my <code>.htaccess</code> file:</p>
<pre><code>RewriteEngine on
RewriteRule ^news/([0-9]+)/?$ /?action=news&start=$1 [L]
RewriteRule ^man/([a-zA-Z0-9_]+)/?$ /?action=man&page=$1 [L]
RewriteRule ^([a-zA-Z0-9_]+)/?$ /?action=$1 [L]
</code></pre>
<p>All of then end with a... | [
{
"answer_id": 550597,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe <a href=\"http://httpd.apache.org/docs/2.2/mod/core.html#options\" rel=\"nofollow noreferrer\"><code>MultiViews</co... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60777/"
] | I have the following rewrite rules in my `.htaccess` file:
```
RewriteEngine on
RewriteRule ^news/([0-9]+)/?$ /?action=news&start=$1 [L]
RewriteRule ^man/([a-zA-Z0-9_]+)/?$ /?action=man&page=$1 [L]
RewriteRule ^([a-zA-Z0-9_]+)/?$ /?action=$1 [L]
```
All of then end with a `/?` to check for an optional trailing slash... | A wild guess: there is a directory named "news", and the the automatic Apache directory "add a trailing slash" redirect is kicking in and interacting with your RewriteRule in a weird way. If that's the case,
```
DirectorySlash Off
```
may help. |
550,632 | <p>Inspired by the question series 'Hidden features of ...', I am curious to hear about your favorite Django tips or lesser known but useful features you know of.</p>
<ul>
<li>Please, include only one tip per answer.</li>
<li>Add Django version requirements if there are any.</li>
</ul>
| [
{
"answer_id": 550644,
"author": "Haes",
"author_id": 4993,
"author_profile": "https://Stackoverflow.com/users/4993",
"pm_score": 8,
"selected": false,
"text": "<p>I'm just going to start with a tip from myself :)</p>\n\n<p><strong>Use os.path.dirname() in settings.py to avoid hardcoded ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4993/"
] | Inspired by the question series 'Hidden features of ...', I am curious to hear about your favorite Django tips or lesser known but useful features you know of.
* Please, include only one tip per answer.
* Add Django version requirements if there are any. | I'm just going to start with a tip from myself :)
**Use os.path.dirname() in settings.py to avoid hardcoded dirnames.**
Don't hardcode path's in your settings.py if you want to run your project in different locations. Use the following code in settings.py if your templates and static files are located within the Djan... |
550,633 | <p>I am working on an idea wherein I have to identify lines in a JPG or PNG file. The PNG file contains one graph of a single value - one x,y combination. For example, the graph looks like Y = mx+c.
I would like to identify the line in the graph - if I can indentify the position of the pixel in the frame, I believe I... | [
{
"answer_id": 550648,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 0,
"selected": false,
"text": "<p>Generally, on a computer monitor you don't have a central <code>(0,0)</code> point, as that point is defined to be t... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61395/"
] | I am working on an idea wherein I have to identify lines in a JPG or PNG file. The PNG file contains one graph of a single value - one x,y combination. For example, the graph looks like Y = mx+c.
I would like to identify the line in the graph - if I can indentify the position of the pixel in the frame, I believe I can... | I'm a bit confused as to whether your problem is simply *determining the colour* of pixels in an image, or if the problem is the *mathematics* of what you're trying to do.
For the former, do something such as the following:
```
BufferedImage bimg = ImageIO.read(new File("whatever.png"));
// get the colour of... |
550,653 | <p>Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using <strong>python</strong> or <strong>jython</strong>?</p>
<ol>
<li>I want something like <code>pidof</code> but in python. (I don't have <code>pidof</code> anyway.)</li>
<li>I can't pa... | [
{
"answer_id": 550672,
"author": "David Cournapeau",
"author_id": 11465,
"author_profile": "https://Stackoverflow.com/users/11465",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think you will be able to find a purely python-based, portable solution without using /proc or command... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66473/"
] | Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using **python** or **jython**?
1. I want something like `pidof` but in python. (I don't have `pidof` anyway.)
2. I can't parse `/proc` because it might be unavailable (on HP-UX).
3. I do not... | You can use psutil (<https://github.com/giampaolo/psutil>), which works on Windows and UNIX:
```
import psutil
PROCNAME = "python.exe"
for proc in psutil.process_iter():
if proc.name() == PROCNAME:
print(proc)
```
On my machine it prints:
```
<psutil.Process(pid=3881, name='python.exe') at 14019213387... |
550,673 | <p>I have a very frustrating python problem. In this code</p>
<pre><code>fixedKeyStringInAVar = "SomeKey"
def myFunc(a, b):
global sleepTime
global fixedKeyStringInAVar
varMe=int("15")
sleepTime[fixedKeyStringInAVar] = varMe*60*1000
#more code
</code></pre>
<p>Now this works. BUT sometimes when I... | [
{
"answer_id": 550679,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Your sleepTime is a global variable. It could be changed to be an int at some point in your program.</p>\n\n<p>The item ass... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a very frustrating python problem. In this code
```
fixedKeyStringInAVar = "SomeKey"
def myFunc(a, b):
global sleepTime
global fixedKeyStringInAVar
varMe=int("15")
sleepTime[fixedKeyStringInAVar] = varMe*60*1000
#more code
```
Now this works. BUT sometimes when I run this function I get
... | 1. Don't use `global` keyword in a function unless you'd like to change binding of a global name.
2. Search for '`sleepTime =`' in your code. You are binding an int object to the `sleepTime` name at some point in your program. |
550,686 | <p>POSIX uses <code>struct timeval</code> to represent time intervals.</p>
<pre><code>struct timeval
{
time_t tv_sec;
unsigned tv_usec;
};
</code></pre>
<p>GHS Integrity represents <code>Time</code> in the following manner,</p>
<pre><code>struct Time
{
time_t Seconds;
unsigned Fraction;
};
</code><... | [
{
"answer_id": 550690,
"author": "Tom Alsberg",
"author_id": 66034,
"author_profile": "https://Stackoverflow.com/users/66034",
"pm_score": 4,
"selected": true,
"text": "<p>This is an unusual way to represent time.</p>\n\n<p>Anyway, there are two easy ways to do it either way if you have ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30333/"
] | POSIX uses `struct timeval` to represent time intervals.
```
struct timeval
{
time_t tv_sec;
unsigned tv_usec;
};
```
GHS Integrity represents `Time` in the following manner,
```
struct Time
{
time_t Seconds;
unsigned Fraction;
};
```
For example, 0.5sec is represented as `0x80000000` and 0.25se... | This is an unusual way to represent time.
Anyway, there are two easy ways to do it either way if you have 64-bit integers or floating points (the former are more likely on an embedded system):
```
/* assuming long is 64-bit and int is 32-bit
or in general long twice the size of int: */
Fraction = (long) tv_usec * ... |
550,694 | <p>Why isn't this working ?</p>
<pre><code>public interface IPoint
{
// not important
}
public interface IPointList
{
List<IPoint> Points { get; }
}
public abstract class Point : IPoint
{
// implemented IPoint
}
public abstract class PointList<TPointType> : IPointList
where TPointType: IPoint
{
... | [
{
"answer_id": 550705,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 2,
"selected": false,
"text": "<p>The class PointList <em>should</em> implement the IPointList interface. Methods/properties cannot differ by return t... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66607/"
] | Why isn't this working ?
```
public interface IPoint
{
// not important
}
public interface IPointList
{
List<IPoint> Points { get; }
}
public abstract class Point : IPoint
{
// implemented IPoint
}
public abstract class PointList<TPointType> : IPointList
where TPointType: IPoint
{
public abstract List<TPo... | As an answer to your comment, on how to get best of both worlds;
I was thinking of something like this, where you implement your interface GetPoints property explictily, create a GetPoints property that is 'more typed', and an protected abstract method that you can override in concrete implementations.
The 2 proper... |
550,698 | <p>i have a directory in my website that is protected from anonymous users. my web.config looks like this</p>
<pre><code><location path="members">
<system.web>
<authorization>
<allow roles="members" />
<deny users="*" />
</authorization>
... | [
{
"answer_id": 550705,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 2,
"selected": false,
"text": "<p>The class PointList <em>should</em> implement the IPointList interface. Methods/properties cannot differ by return t... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65005/"
] | i have a directory in my website that is protected from anonymous users. my web.config looks like this
```
<location path="members">
<system.web>
<authorization>
<allow roles="members" />
<deny users="*" />
</authorization>
</system.web>
</location>
```
if anonymous us... | As an answer to your comment, on how to get best of both worlds;
I was thinking of something like this, where you implement your interface GetPoints property explictily, create a GetPoints property that is 'more typed', and an protected abstract method that you can override in concrete implementations.
The 2 proper... |
550,702 | <p>Recently I have found myself using StringBuilder for all string concatenations, big and small, however in a recent performance test I swapped out a colleague's <em>stringOut = string1 + "." string2</em> style concatenation (being used in a 10000x + loop with the StringBuilder being newed each time) for a StringBuild... | [
{
"answer_id": 550713,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 5,
"selected": true,
"text": "<p>The rule that I follow is -</p>\n\n<p>Use a StringBuilder when the number of concatenations is unknown at compile time.</p>\... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] | Recently I have found myself using StringBuilder for all string concatenations, big and small, however in a recent performance test I swapped out a colleague's *stringOut = string1 + "." string2* style concatenation (being used in a 10000x + loop with the StringBuilder being newed each time) for a StringBuilder just to... | The rule that I follow is -
Use a StringBuilder when the number of concatenations is unknown at compile time.
So, in your case each StringBuilder was only appending a few times and then being discarded. That isn't really the same as something like
```
string s = String.Empty;
for (int i = 0; i < 10000; ++i)
{
s ... |
550,703 | <p>Take the below code:</p>
<pre><code>private void anEvent(object sender, EventArgs e) {
//some code
}
</code></pre>
<hr>
<p>What is the difference between the following ?</p>
<pre><code>[object].[event] += anEvent;
//and
[object].[event] += new EventHandler(anEvent);
</code></pre>
<p><strong>[UPDATE]</stro... | [
{
"answer_id": 550707,
"author": "Megacan",
"author_id": 54947,
"author_profile": "https://Stackoverflow.com/users/54947",
"pm_score": 4,
"selected": false,
"text": "<p>I don't think there is a difference. The compiler transforms the first into the second.</p>\n"
},
{
"answer_id"... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44084/"
] | Take the below code:
```
private void anEvent(object sender, EventArgs e) {
//some code
}
```
---
What is the difference between the following ?
```
[object].[event] += anEvent;
//and
[object].[event] += new EventHandler(anEvent);
```
**[UPDATE]**
Apparently, there is no difference between the two...the f... | There is no difference. In your first example, the compiler will automatically infer the delegate you would like to instantiate. In the second example, you explicitly define the delegate.
Delegate inference was added in C# 2.0. So for C# 1.0 projects, second example was your only option. For 2.0 projects, the first e... |
550,714 | <p>I want to add a text box on a web page in order for users to add space delimited tags. When the user submits the page how do I take the tags out of the text box and add each as a record in a SQL database? </p>
<p>I want to use VB.NET.</p>
| [
{
"answer_id": 550755,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 3,
"selected": true,
"text": "<p>Sounds like you want something like:</p>\n\n<pre><code>Using connection as New SqlConnection(\"connection string\")\n... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to add a text box on a web page in order for users to add space delimited tags. When the user submits the page how do I take the tags out of the text box and add each as a record in a SQL database?
I want to use VB.NET. | Sounds like you want something like:
```
Using connection as New SqlConnection("connection string")
connection.Open()
For Each tag As String In TextBox.Split(CChar(" "))
Using command as New SqlCommand("INSERT INTO UsedTags(Tag) VALUES(@Tag)", connection)
command.Parameters.Add("@Tag", Sql... |
550,716 | <p>I don’t have any experience in F# but have a few lines of test code in C# for a framework I've made that I need to rewrite in F#.</p>
<p>Any help would be appreciated. </p>
<pre><code> bar.Ready += new Agent.ReadyHandler(bar_Ready);
static void bar_Ready(string msg)
{
Conso... | [
{
"answer_id": 550776,
"author": "Martin Jonáš",
"author_id": 58763,
"author_profile": "https://Stackoverflow.com/users/58763",
"pm_score": 3,
"selected": false,
"text": "<p>Try this -</p>\n\n<pre><code>bar.Ready.AddHandler(new Agent.ReadyHandler (fun sender msg -> System.Console.Writ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61976/"
] | I don’t have any experience in F# but have a few lines of test code in C# for a framework I've made that I need to rewrite in F#.
Any help would be appreciated.
```
bar.Ready += new Agent.ReadyHandler(bar_Ready);
static void bar_Ready(string msg)
{
Console.WriteLine(msg.body); ... | I have played a lot with this and this is the code that work.
```
bar.add_Ready(fun msg -> Console.WriteLine(msg))
```
I don't know how theoreticly correct it is but it works fine.
Can any one confirm it is correct? |
550,723 | <p>I have a class library that is usually called from a .net console or web application. It integrates with various components, and relies on an app.config or web.config.</p>
<p>If I want to utilise the class library from script (i.e. IronPython), how can I get the script to utilise the config file? Ideally I want to ... | [
{
"answer_id": 550760,
"author": "oefe",
"author_id": 49793,
"author_profile": "https://Stackoverflow.com/users/49793",
"pm_score": 0,
"selected": false,
"text": "<p>Translating <a href=\"http://weblogs.asp.net/israelio/archive/2005/01/10/349825.aspx\" rel=\"nofollow noreferrer\">this bl... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1982/"
] | I have a class library that is usually called from a .net console or web application. It integrates with various components, and relies on an app.config or web.config.
If I want to utilise the class library from script (i.e. IronPython), how can I get the script to utilise the config file? Ideally I want to be able to... | I have a working solution with code sample. See my blog:
<http://technomosh.blogspot.com/2012/01/using-appconfig-in-ironpython.html>
It requires a special proxy class which is injected to the ConfigurationManager.
Here is the source for the ConfigurationProxy library:
```
using System;
using System.Collections.Gener... |
550,728 | <p>What is the easiest way to add a text to the beginning of another text file in Command Line (Windows)?</p>
| [
{
"answer_id": 550737,
"author": "DarkwingDuck",
"author_id": 51948,
"author_profile": "https://Stackoverflow.com/users/51948",
"pm_score": 7,
"selected": true,
"text": "<pre><code>echo \"my line\" > newFile.txt\ntype myOriginalFile.txt >> newFile.txt\ntype newFile.txt > myOr... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40322/"
] | What is the easiest way to add a text to the beginning of another text file in Command Line (Windows)? | ```
echo "my line" > newFile.txt
type myOriginalFile.txt >> newFile.txt
type newFile.txt > myOriginalFile.txt
```
Untested.
Double >> means 'append' |
550,741 | <p>I have problem with gridview deleting.I have table name Doctor with
Id,Name,Address,Phone.Id is auto generated field.After adding data
when i am displaying in gridview then if delete any id from gridview
Again then if i add any new details from the form its starting from
the new number.I mean if i delete the last id... | [
{
"answer_id": 550761,
"author": "Torbjørn",
"author_id": 22621,
"author_profile": "https://Stackoverflow.com/users/22621",
"pm_score": 1,
"selected": false,
"text": "<p>So the Id is created by the database (autonumber). When id 5 is used it's used up. This is normal behavior.</p>\n"
}... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59637/"
] | I have problem with gridview deleting.I have table name Doctor with
Id,Name,Address,Phone.Id is auto generated field.After adding data
when i am displaying in gridview then if delete any id from gridview
Again then if i add any new details from the form its starting from
the new number.I mean if i delete the last id no... | This is perfectly normal database behaviour and has nothing to do with your GridView. If you have an issue with gaps in autogenerated (identity) columns, either use your own logic to generate unique ID's or use custom SQL scripts to check for gaps in Identity values and fill those gaps.
Example B in the [Transact-SQL ... |
550,753 | <p>I have a class for interacting with a memcache server. I have different functions for inserting, deleting and retrieving data. Originally each function made a call to <code>memcache_connect()</code>, however that was unnecessary, e.g.:</p>
<pre><code>mc->insert()
mc->get()
mc->delete()
</code></pre>
... | [
{
"answer_id": 550759,
"author": "Greg",
"author_id": 1916,
"author_profile": "https://Stackoverflow.com/users/1916",
"pm_score": 3,
"selected": false,
"text": "<p>Pass in the MC instance:</p>\n\n<pre><code>class abc\n{\n function __construct($mc) {\n $this->mc = $mc;\n }... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66613/"
] | I have a class for interacting with a memcache server. I have different functions for inserting, deleting and retrieving data. Originally each function made a call to `memcache_connect()`, however that was unnecessary, e.g.:
```
mc->insert()
mc->get()
mc->delete()
```
would make three memcache connections. I wo... | I would code another class using singleton pattern for getting the only instance of memcache. Like this -
```
class MemCache
{
private static $instance = false;
private function __construct() {}
public static function getInstance()
{
if(self::$instance === false)
{
self::$instance = memca... |
550,778 | <p><em>With reference to <a href="https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment">this programming game</a> I am currently building.</em></p>
<p>I wrote the below method to move (translate) a canvas to a specific distance and according to its current angle:<... | [
{
"answer_id": 550783,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 3,
"selected": true,
"text": "<p>Is there are reason you're using DoubleAnimation? DoubleAnimation is designed to take a value from A to B over a ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44084/"
] | *With reference to [this programming game](https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment) I am currently building.*
I wrote the below method to move (translate) a canvas to a specific distance and according to its current angle:
```
private void MoveBot(do... | Is there are reason you're using DoubleAnimation? DoubleAnimation is designed to take a value from A to B over a specific time period using linear interpolation acceleration/deceleration at the start/end of that period if required (which is why it's "faster" for longer distance.. it has further to go in the same time!)... |
550,785 | <p>I've got the following (simplified):</p>
<pre><code>interface IFindFilesObserver
{
void OnFoundFile(FileInfo fileInfo);
void OnFoundDirectory(DirectoryInfo directoryInfo);
}
class FindFiles
{
IFindFilesObserver _observer;
// ...
}
</code></pre>
<p>...and I'm conflicted. This is basically what I w... | [
{
"answer_id": 550789,
"author": "Frederik Gheysels",
"author_id": 55774,
"author_profile": "https://Stackoverflow.com/users/55774",
"pm_score": 5,
"selected": false,
"text": "<p>Hmm, events can be used to implement the Observer pattern. In fact, using events can be regarded as another ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] | I've got the following (simplified):
```
interface IFindFilesObserver
{
void OnFoundFile(FileInfo fileInfo);
void OnFoundDirectory(DirectoryInfo directoryInfo);
}
class FindFiles
{
IFindFilesObserver _observer;
// ...
}
```
...and I'm conflicted. This is basically what I would have written in C++, ... | Consider an event to be a callback interface where the interface has only one method.
**Only hook events you need**
With events, you only need to implement handlers for events you're interested in handling. In the observer interface pattern, you'd have to implement all methods in the entire interface including impl... |
550,787 | <p>I've setup a git repository one a remote server. Now I'm trying to checkout from it with:</p>
<pre><code>git fetch ssh://username@url.com/~username/workfolder/
</code></pre>
<p>but I get an error:</p>
<pre><code>fatal: Not a git repository
</code></pre>
<p>What am I doing wrong? Could it be the server does not s... | [
{
"answer_id": 550801,
"author": "Andy Hume",
"author_id": 46460,
"author_profile": "https://Stackoverflow.com/users/46460",
"pm_score": 5,
"selected": true,
"text": "<p>Try </p>\n\n<pre><code>git clone ssh://username@url.com/~username/workfolder/\n</code></pre>\n\n<p>Which will create t... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58521/"
] | I've setup a git repository one a remote server. Now I'm trying to checkout from it with:
```
git fetch ssh://username@url.com/~username/workfolder/
```
but I get an error:
```
fatal: Not a git repository
```
What am I doing wrong? Could it be the server does not support Git+SSH? | Try
```
git clone ssh://username@url.com/~username/workfolder/
```
Which will create the repository on your local machine. Any commits you make to that branch are to your local repository, and when you want to push back up to the remote server you can run:
```
git push ssh://username@url.com/~username/workfolder/
... |
550,797 | <p>-edit- I am sending binary and not a string. My test is using html pages so in this example i am only using a string but my question is about binary, vectors and debugging with ostream. I make this clears some confusion.</p>
<p>I have the following code:</p>
<pre><code>cout << string(&v[0]).substr(0, len... | [
{
"answer_id": 550834,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": false,
"text": "<pre><code>vector<char> v;\nv.reserve(1024*16); //required\nv.resize(1); //so we can do &v[0]\nre... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | -edit- I am sending binary and not a string. My test is using html pages so in this example i am only using a string but my question is about binary, vectors and debugging with ostream. I make this clears some confusion.
I have the following code:
```
cout << string(&v[0]).substr(0, len);
```
Is there a better way ... | You can use the method ostream::write on the cout object:
```
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<char> test;
test.push_back('a');
test.push_back('b');
test.push_back('c');
cout.write(&test[0], 3);
cout << endl;
}
```
Outputs:
>
> abc
>
>
>
Since ostrea... |
550,804 | <p>I am using libcurl to DL a webpage, then i am scanning it for data and doing something with one of the links. However, once in a while the page is different then i except thus i extract bad data and pycurl throws an exception. I tried finding the exception name for pycurl but had no luck.</p>
<p>Is there a way i ca... | [
{
"answer_id": 550815,
"author": "Jiri",
"author_id": 39726,
"author_profile": "https://Stackoverflow.com/users/39726",
"pm_score": 2,
"selected": false,
"text": "<p>Can you catch all exceptions somewhere in the main block and use sys.exc_info() for callback information and log that to y... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using libcurl to DL a webpage, then i am scanning it for data and doing something with one of the links. However, once in a while the page is different then i except thus i extract bad data and pycurl throws an exception. I tried finding the exception name for pycurl but had no luck.
Is there a way i can get the ... | [sys.excepthook](http://docs.python.org/library/sys.html#sys.excepthook) may help you here, where you can set a global exception handler. I am not sure how pycurl exceptions are handled, it being a binding library, but it will probably work to reassign it to a generic function. Something like:
```
>>> import sys
>>>
... |
550,807 | <p>What I am asking, is what is the best way (i.e. the way that is easiest for neophyte web developers) to consume/integrate data that I make available on my website, into their own website.</p>
<p>I have a website written in asp.net/sql server back end.</p>
<p>I have clients that would like to be able to incorporate... | [
{
"answer_id": 550812,
"author": "Andy Hume",
"author_id": 46460,
"author_profile": "https://Stackoverflow.com/users/46460",
"pm_score": 1,
"selected": false,
"text": "<p>Your list of requirements seem to be pretty broad.</p>\n\n<p>I was going to suggest building some kind of RESTful Web... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53686/"
] | What I am asking, is what is the best way (i.e. the way that is easiest for neophyte web developers) to consume/integrate data that I make available on my website, into their own website.
I have a website written in asp.net/sql server back end.
I have clients that would like to be able to incorporate selections of da... | >
> I have clients that would like to be able to incorporate selections of data (...) into their website, so that the data looks like it belongs to them, and is branded by them
>
>
>
A number of sites make this functionality available via snippets of javascript code, e.g. [TechnicalJobs.ie](http://technicaljobs.ie... |
550,826 | <p>I want to translate LINQ expression tree to SQL statement and I don't want to write my own code for this.</p>
<p>Example:</p>
<pre><code>var query = from c in Customers
where c.Country == "UK" &&
c.City == "London"
select c);
</code></pre>
<p>To </p>
<pre><code>SELECT ... FROM Customers AS c WHERE ... | [
{
"answer_id": 551145,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 5,
"selected": true,
"text": "<pre><code>CustomDataContext dc = new CustomDataContext();\nIQueryable<Customer> query =\n from c in dc.Customer\n wher... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66621/"
] | I want to translate LINQ expression tree to SQL statement and I don't want to write my own code for this.
Example:
```
var query = from c in Customers
where c.Country == "UK" &&
c.City == "London"
select c);
```
To
```
SELECT ... FROM Customers AS c WHERE c.Country = "UK" AND c.City = "London"
```
I know ... | ```
CustomDataContext dc = new CustomDataContext();
IQueryable<Customer> query =
from c in dc.Customer
where c.Country == "UK"
select c;
//
string command = dc.GetCommand(query).CommandText;
``` |
550,828 | <p>I have a pretty complex database with loads of different tables for different things, every thing of which has a timestamp (Y-M-D h:m:s format)</p>
<p>Is there a way I can limit my SQL query to just results from a certain timespan, for example a week ago?</p>
<p>If needbe I have a function to convert these timesta... | [
{
"answer_id": 550835,
"author": "Jakob Stoeck",
"author_id": 62372,
"author_profile": "https://Stackoverflow.com/users/62372",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, like you have written you can make greater than and lower than restrictions on your output. Where is the prob... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a pretty complex database with loads of different tables for different things, every thing of which has a timestamp (Y-M-D h:m:s format)
Is there a way I can limit my SQL query to just results from a certain timespan, for example a week ago?
If needbe I have a function to convert these timestamps into unix as
... | That's totally possible with the BETWEEN-statement (Since MySQL 4.0):
```
mysql_query("SELECT id FROM entries WHERE entries.date BETWEEN 'Y-M-D h:m:s' AND 'Y-M-D h:m:s'");
```
Also, to calculate the timestamp one week before the current date have a look at the [MySQL Online Documentation](http://dev.mysql.com/doc/re... |
550,831 | <p>How do you write a module for Perl? In Python you can use: </p>
<pre><code># module.py
def helloworld(name):
print "Hello, %s" % name
# main.py
import module
module.helloworld("Jim")
</code></pre>
| [
{
"answer_id": 550837,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 5,
"selected": false,
"text": "<p>A class:</p>\n\n<pre><code># lib/Class.pm\npackage Class;\nuse Moose;\n\n# define the class\n\n1;\n</code></pre>\n\n<p>A... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66437/"
] | How do you write a module for Perl? In Python you can use:
```
# module.py
def helloworld(name):
print "Hello, %s" % name
# main.py
import module
module.helloworld("Jim")
``` | A class:
```
# lib/Class.pm
package Class;
use Moose;
# define the class
1;
```
A module that exports functions:
```
# lib/A/Module.pm
package A::Module;
use strict;
use warnings;
use Sub::Exporter -setup => {
exports => [ qw/foo bar/ ],
};
sub foo { ... }
sub bar { ... }
1;
```
A script that uses these:
... |
550,859 | <p>Is it OK to pass to function a reference to the value of map element, and to modify it there?</p>
<pre><code>foo(string & s)
{
s = "xyz";
}
map<int, string> m;
m[1] = "abc";
foo(m[1]); // <-- Is it ok? Will m[1] be "xyz" after this call?
</code></pre>
<p>Thank you.</p>
| [
{
"answer_id": 550862,
"author": "Assaf Lavie",
"author_id": 11208,
"author_profile": "https://Stackoverflow.com/users/11208",
"pm_score": 4,
"selected": true,
"text": "<p>The answer is Yes.</p>\n\n<p>(operator [] returns a <a href=\"http://www.cplusplus.com/reference/stl/map/operator[].... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44673/"
] | Is it OK to pass to function a reference to the value of map element, and to modify it there?
```
foo(string & s)
{
s = "xyz";
}
map<int, string> m;
m[1] = "abc";
foo(m[1]); // <-- Is it ok? Will m[1] be "xyz" after this call?
```
Thank you. | The answer is Yes.
(operator [] returns a [reference](http://www.cplusplus.com/reference/stl/map/operator[].html)) |
550,879 | <p>Once in a while my shared hosting environment gets compromised because, well, I failed to keep the portfolio of my installed apps patched up.
Last week, it was because of an old and unused installation of a PHP application called Help Center Live.
The result was that every single PHP file on the server (and I have s... | [
{
"answer_id": 550934,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 4,
"selected": false,
"text": "<p>1.) Keep a repository of the files you are using for these apps (e.g. SVN or similar)</p>\n\n<p>2.) Keep up-to-date as ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58880/"
] | Once in a while my shared hosting environment gets compromised because, well, I failed to keep the portfolio of my installed apps patched up.
Last week, it was because of an old and unused installation of a PHP application called Help Center Live.
The result was that every single PHP file on the server (and I have seve... | After your system has been comprised you really have only two options: audit every line of every application or reinstall everything. Since it sounds like these are all open-source or commercial programs you're probably better to re-install them all. There really isn't a better way to ensure you don't have a back-door ... |
550,905 | <p>Just like the iPhone has a UIImagePickerController to let the user access pictures stored on the device, do we have a similar control in the Android SDK?</p>
<p>Thanks.</p>
| [
{
"answer_id": 551151,
"author": "Reto Meier",
"author_id": 822,
"author_profile": "https://Stackoverflow.com/users/822",
"pm_score": 7,
"selected": true,
"text": "<p>You can use<code>startActivityForResult</code>, passing in an Intent that describes an action you want completed and and ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46297/"
] | Just like the iPhone has a UIImagePickerController to let the user access pictures stored on the device, do we have a similar control in the Android SDK?
Thanks. | You can use`startActivityForResult`, passing in an Intent that describes an action you want completed and and data source to perform the action on.
Luckily for you, Android includes an Action for picking things: `Intent.ACTION__PICK` and a data source containing pictures:
`android.provider.MediaStore.Images.Media.INT... |
550,906 | <p>In the question <a href="https://stackoverflow.com/questions/546175/is-returning-a-whole-array-from-a-perl-subroutine-inefficient">"Is returning a whole array from a Perl subroutine inefficient"</a> two people recommend against optimizing if there is no need for it. As a general rule, optimizing can add complexity,... | [
{
"answer_id": 550917,
"author": "Tom Alsberg",
"author_id": 66034,
"author_profile": "https://Stackoverflow.com/users/66034",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure if returning a reference is more efficient in this case; i.e. does Perl copy data returned by subrou... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45978/"
] | In the question ["Is returning a whole array from a Perl subroutine inefficient"](https://stackoverflow.com/questions/546175/is-returning-a-whole-array-from-a-perl-subroutine-inefficient) two people recommend against optimizing if there is no need for it. As a general rule, optimizing can add complexity, and if it's no... | You shouldn't return an array reference if it's inconsistent with the rest of your interface. If everything else that you work with returns lists instead of references, don't be the odd duck who causes other programmers to remember the exception.
Unless you have large lists, this is really a micro-optimization issue. ... |
550,913 | <p><strong>The post aims to summarize all pieces of information to set up a closed repository for 3 people in a competition.</strong> Please, feel free to add a problem to the list which I have not noted. Please, add each answer to each question as a separate answer.</p>
<ol>
<li><strong>Situation A:</strong> Drafts a... | [
{
"answer_id": 551031,
"author": "Emil Sit",
"author_id": 55284,
"author_profile": "https://Stackoverflow.com/users/55284",
"pm_score": 5,
"selected": true,
"text": "<p><strong>Situation A</strong></p>\n\n<p>It sounds like you want to set up a <a href=\"http://www.whygitisbetterthanx.com... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54964/"
] | **The post aims to summarize all pieces of information to set up a closed repository for 3 people in a competition.** Please, feel free to add a problem to the list which I have not noted. Please, add each answer to each question as a separate answer.
1. **Situation A:** Drafts and files can exchange between 3 people.... | **Situation A**
It sounds like you want to set up a [integration manager workflow](http://www.whygitisbetterthanx.com/#any-workflow). In this scenario, person A creates an initial repository which is the sacred repository. Each person, A, B and C, clones that repository for their personal work. When person B or C has ... |
550,918 | <p>I'm creating a cursor at runtime from a image resource. The HotSpot of the new Cursor is always set to 16x16 (32x32 image). Is it possible to change the HotSpot at runtime or will I need to create .cur files?</p>
| [
{
"answer_id": 550965,
"author": "Nick",
"author_id": 1490,
"author_profile": "https://Stackoverflow.com/users/1490",
"pm_score": 6,
"selected": true,
"text": "<p>You sure can. Here are my utility functions, edit as you see fit :)</p>\n\n<pre><code> public struct IconInfo\n {\n ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26566/"
] | I'm creating a cursor at runtime from a image resource. The HotSpot of the new Cursor is always set to 16x16 (32x32 image). Is it possible to change the HotSpot at runtime or will I need to create .cur files? | You sure can. Here are my utility functions, edit as you see fit :)
```
public struct IconInfo
{
public bool fIcon;
public int xHotspot;
public int yHotspot;
public IntPtr hbmMask;
public IntPtr hbmColor;
}
[DllImport("user32.dll")]
[return: MarshalAs(Unmanag... |
550,919 | <p>I have seen it written in multiple threads/comments on stackoverflow that using <code>switch</code> is just bad OOP style. Personally I disagree with this.</p>
<p>There will be many cases where you cannot add code (i.e. methods) to <code>enum</code> classes you want to switch on because you don't control them, perh... | [
{
"answer_id": 550923,
"author": "Pete Kirkham",
"author_id": 1527,
"author_profile": "https://Stackoverflow.com/users/1527",
"pm_score": 4,
"selected": false,
"text": "<p>It's bad OOP style.</p>\n\n<p>Not all problems are best solved with OO. Some you want pattern matching, which switch... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16853/"
] | I have seen it written in multiple threads/comments on stackoverflow that using `switch` is just bad OOP style. Personally I disagree with this.
There will be many cases where you cannot add code (i.e. methods) to `enum` classes you want to switch on because you don't control them, perhaps they are in a 3rd-party jar ... | Taking your followup:
>
> *What if this is just the "investibility" logic for a customer wishing for a business loan. Perhaps the innvestibility decision of a customer for another product is really quite different ... Also, what if there are new products coming out all the time, each with different investibility deci... |
550,922 | <p>How can I delete all files and subdirectories from current directory including current directory?</p>
| [
{
"answer_id": 550930,
"author": "neoice",
"author_id": 66422,
"author_profile": "https://Stackoverflow.com/users/66422",
"pm_score": 0,
"selected": false,
"text": "<p>operating system? on the *NIX-based stuff, you're looking for 'rm -rf directory/'</p>\n\n<p>NOTE: the '-r' flag for 'rec... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65516/"
] | How can I delete all files and subdirectories from current directory including current directory? | Under bash with GNU tools, I would do it like that (should be secure in most cases):
```
rm -rf -- "$(pwd -P)" && cd ..
```
not under bash and without GNU tools, I would use:
```
TMP=`pwd -P` && cd "`dirname $TMP`" && rm -rf "./`basename $TMP`" && unset TMP
```
why this more secure:
* end the argument list with ... |
550,984 | <p>I have a stored procedure that takes a comma-delimited string of IDs. I split them and put them into a temporary table and pull out records from another table using <strong>where id IN [table]</strong></p>
<p>Is it ok to use this same procedure when only one id is passed in for the param? I could write a second sto... | [
{
"answer_id": 550994,
"author": "Kristen",
"author_id": 65703,
"author_profile": "https://Stackoverflow.com/users/65703",
"pm_score": 3,
"selected": true,
"text": "<p>You might like to try a JOIN instead of WHERE id IN - although I think you will get the same query plan.</p>\n\n<p>So I ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10941/"
] | I have a stored procedure that takes a comma-delimited string of IDs. I split them and put them into a temporary table and pull out records from another table using **where id IN [table]**
Is it ok to use this same procedure when only one id is passed in for the param? I could write a second stored procedure that woul... | You might like to try a JOIN instead of WHERE id IN - although I think you will get the same query plan.
So I assume you are doing:
```
SELECT COl1, Col2, ...
FROM MyTable
WHERE id IN (SELECT id FROM @MyTempTable)
```
in which case the equivalent JOIN syntax would be :
```
SELECT COl1, Col2, ...
FROM MyTable AS T... |
550,995 | <p><code>RedirectToAction</code> is protected, and we can use it only inside actions. But if I want to redirect in a filter?</p>
<pre><code>public class IsGuestAttribute: ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (!Ctx.User.IsGuest)
... | [
{
"answer_id": 551184,
"author": "veggerby",
"author_id": 54108,
"author_profile": "https://Stackoverflow.com/users/54108",
"pm_score": 8,
"selected": true,
"text": "<p><code>RedirectToAction</code> is just a helper method to construct a <code>RedirectToRouteResult()</code>, so what you ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40789/"
] | `RedirectToAction` is protected, and we can use it only inside actions. But if I want to redirect in a filter?
```
public class IsGuestAttribute: ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (!Ctx.User.IsGuest)
filterContext.Resu... | `RedirectToAction` is just a helper method to construct a `RedirectToRouteResult()`, so what you do is simply create a new `RedirectToRouteResult()` passing along a `RouteValueDictionary()` with values for your action.
Complete sample based on code from @Domenic in the comment below:
```
public class IsGuestAttribute... |
551,001 | <p>I learning c++, started learning File Handling today. but getting a error when runinng this code</p>
<pre><code>#include <iostream>
#include <fstream.h>
using namespace std;
int main()
{
fstream file;
file.open("test.txt",ios::in|ios::out)
file.close();
return... | [
{
"answer_id": 551003,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 3,
"selected": false,
"text": "<p>Change your include to:</p>\n\n<pre><code>#include <fstream>\n</code></pre>\n\n<p>It is a standard library, an... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66437/"
] | I learning c++, started learning File Handling today. but getting a error when runinng this code
```
#include <iostream>
#include <fstream.h>
using namespace std;
int main()
{
fstream file;
file.open("test.txt",ios::in|ios::out)
file.close();
return 0;
}
```
Gets error... | Change your include to:
```
#include <fstream>
```
It is a standard library, and you are trying to point it to a non existing header file. |
551,015 | <p>I have a web page with tabs or accordion, generated with YUI or jquery or another javascript+css framework.</p>
<p>Say an HTML form is processed in one tab. What should the server do? Send back all the tabs, with the tab that submitted the form having the results and all the other tabs unmodified? Or what?</p>
| [
{
"answer_id": 551030,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": -1,
"selected": false,
"text": "<p>You could use <a href=\"http://docs.jquery.com/Ajax/jQuery.get#urldatacallbacktype\" rel=\"nofollow noreferrer\">... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63051/"
] | I have a web page with tabs or accordion, generated with YUI or jquery or another javascript+css framework.
Say an HTML form is processed in one tab. What should the server do? Send back all the tabs, with the tab that submitted the form having the results and all the other tabs unmodified? Or what? | As you select each new tab, you can send a jQuery AJAX request for just the content you require, e.g. if your user clicks on a tab titled "Sports", you can make a request to "sports.html" on your server, and display it in the tab.
There's a good walk-through [here](http://jetlogs.org/2008/03/17/jquery-ajax-tabs/) that... |
551,028 | <p>Here is my script code:</p>
<pre><code> // ==UserScript==
// @name test
// @description test
// @include http://*
// @copyright Bruno Tyndall
// ==/UserScript==
var main = function() {
var b = document.getElementsByTagName('body')[0];
var t = documen... | [
{
"answer_id": 551032,
"author": "Assaf Lavie",
"author_id": 11208,
"author_profile": "https://Stackoverflow.com/users/11208",
"pm_score": 1,
"selected": false,
"text": "<p>Try adding the function test to the window object</p>\n\n<pre><code>window.test = function ...\n</code></pre>\n\n<p... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | Here is my script code:
```
// ==UserScript==
// @name test
// @description test
// @include http://*
// @copyright Bruno Tyndall
// ==/UserScript==
var main = function() {
var b = document.getElementsByTagName('body')[0];
var t = document.createElemen... | Greasemonkey executes the script in a sandbox - the page doesn't have access to it for security reasons. All acceses to dom and window are via wrappers.
If you want to access the unsecured objects you can use `wrappedJSObject` property.
For your case you can use `unsafeWindow` (or `window.wrappedJSObject`):
```
unsa... |
551,038 | <p>I am coding a small Python module composed of two parts:</p>
<ul>
<li>some functions defining a public interface,</li>
<li>an implementation class used by the above functions, but which is not meaningful outside the module.</li>
</ul>
<p>At first, I decided to "hide" this implementation class by defining it inside... | [
{
"answer_id": 551047,
"author": "Benjamin Peterson",
"author_id": 33795,
"author_profile": "https://Stackoverflow.com/users/33795",
"pm_score": 4,
"selected": false,
"text": "<p>The convention is prepend \"_\" to internal classes, functions, and variables.</p>\n"
},
{
"answer_id... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38096/"
] | I am coding a small Python module composed of two parts:
* some functions defining a public interface,
* an implementation class used by the above functions, but which is not meaningful outside the module.
At first, I decided to "hide" this implementation class by defining it inside the function using it, but this ha... | Use a single underscore prefix:
```
class _Internal:
...
```
This is the official Python convention for 'internal' symbols; "from module import \*" does not import underscore-prefixed objects.
Reference to the [single underscore convention](https://docs.python.org/2/tutorial/classes.html#private-variables-and-c... |
551,058 | <p>How would I go about keeping the state of a tree control?
I'd like to keep the state of the tree when it's data provider gets updated, instead of it collapsing.</p>
| [
{
"answer_id": 551157,
"author": "James Hay",
"author_id": 47339,
"author_profile": "https://Stackoverflow.com/users/47339",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think there is a way to do this automatically (although i've never had to use the tree control). I would thi... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49684/"
] | How would I go about keeping the state of a tree control?
I'd like to keep the state of the tree when it's data provider gets updated, instead of it collapsing. | How about something like this :
```
var openItems:Object = tree.openItems;
tree.dataProvider = myNewDataProvider;
tree.openItems = openItems;
tree.validateNow();
```
I'm not sure how well this will work if the new dataProvider is radically different from the old one, but it works when you're lazy lo... |
551,082 | <p>I'm learning File Handling in C++, but there is a problem here. I am trying to read a file.
This code is meant to output Hello World. but it outputs 0x22fed8.</p>
<pre><code>#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream file;
file.open("test.t... | [
{
"answer_id": 551100,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": false,
"text": "<p>Lets examine the line </p>\n\n<pre><code>cout << file;\n</code></pre>\n\n<p>The reason this outputs a number is ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66437/"
] | I'm learning File Handling in C++, but there is a problem here. I am trying to read a file.
This code is meant to output Hello World. but it outputs 0x22fed8.
```
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream file;
file.open("test.txt",ios::in|ios::out);
... | Simple solution
---------------
As others have pointed out, directly printing a file to a stream does't work. Printing the file contents would require opening *another stream* that reads from the file, or re-setting your stream's read pointer to the beginning and then reading the whole file again (as others have shown... |
551,101 | <p>I'm using Fluent NHibernate and I would like to implement NHibernate.Search with Lucene but I can't find any examples on how to do that with Fluent NHibernate. It appears there are two steps. (According to <a href="http://using.castleproject.org/display/AR/Using+NHibernate.Search+with+ActiveRecord" rel="nofollow nor... | [
{
"answer_id": 552815,
"author": "James Gregory",
"author_id": 27206,
"author_profile": "https://Stackoverflow.com/users/27206",
"pm_score": 4,
"selected": true,
"text": "<p>If you're using the <a href=\"http://wiki.fluentnhibernate.org/show/FluentConfiguration\" rel=\"nofollow noreferre... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2627/"
] | I'm using Fluent NHibernate and I would like to implement NHibernate.Search with Lucene but I can't find any examples on how to do that with Fluent NHibernate. It appears there are two steps. (According to [Castle](http://using.castleproject.org/display/AR/Using+NHibernate.Search+with+ActiveRecord))
1. Set the Hiberna... | If you're using the [Fluent Configuration](http://wiki.fluentnhibernate.org/show/FluentConfiguration) API, then you just need to use the `ExposeConfiguration` method to get at the NHibernate Configuration instance.
```
Fluently.Configure()
.Database(...)
.Mappings(...)
.ExposeConfiguration(cfg =>
{
cfg.Set... |
551,111 | <p>I have problem with GetDate() method.When i am creating any new user,in DateTime field Date is coming correctly time is not coming correctly,it should show generate always system date and time.Ex:2/6/2009 12:00:00 AM,2/7/2009 12:00:00 AM,2/8/2009 12:00:00 AM etc. I mean here
date is changing but system time is not ... | [
{
"answer_id": 551125,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>I would suggest two changes:</p>\n\n<ul>\n<li>Change the parameter of the stored procedure to <a href=\"http://msdn.m... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59637/"
] | I have problem with GetDate() method.When i am creating any new user,in DateTime field Date is coming correctly time is not coming correctly,it should show generate always system date and time.Ex:2/6/2009 12:00:00 AM,2/7/2009 12:00:00 AM,2/8/2009 12:00:00 AM etc. I mean here
date is changing but system time is not cha... | I would suggest two changes:
* Change the parameter of the stored procedure to [`datetime2`](http://msdn.microsoft.com/en-us/library/bb677335.aspx) instead of just [`date`](http://msdn.microsoft.com/en-us/library/bb630352.aspx). (There are other options as well, such as [`datetimeoffset`](http://msdn.microsoft.com/en-... |
551,131 | <p>I use Mac OS X's Preview to view pdf and PostScript files. However some ps files generated with latex appear blurred, for example,</p>
<p><a href="http://img261.imageshack.us/img261/4686/picture1ky5.png" rel="nofollow noreferrer">alt text http://img261.imageshack.us/img261/4686/picture1ky5.png</a></p>
<p>Is there ... | [
{
"answer_id": 551175,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 0,
"selected": false,
"text": "<p>I believe Preview anti-aliases by default. How do they look when you blow them up a bit? How do th... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51164/"
] | I use Mac OS X's Preview to view pdf and PostScript files. However some ps files generated with latex appear blurred, for example,
[alt text http://img261.imageshack.us/img261/4686/picture1ky5.png](http://img261.imageshack.us/img261/4686/picture1ky5.png)
Is there a way to solve this issue? | I've been bothered by this too, so I looked it up just now. [Anyone: Please edit this answer if it's wrong.] As the others have said,
1. it's probably just the viewer (Preview), and printing it will look fine. Nevertheless, if you're trying to read it on screen, "it will look fine in print" is not much of a consolatio... |
551,142 | <p>I've got an <a href="https://stackoverflow.com/questions/161432/best-algorithm-for-synchronizing-two-ilist-in-c-2-0/161535#161535">algorithm that compares two sorted lists</a>, and I'm planning to make it more LINQ-y.</p>
<p>My first question: is there anything like this in LINQ already?</p>
<p>If not, I'm plannin... | [
{
"answer_id": 551163,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 0,
"selected": false,
"text": "<p>That algorithm that is linked, is very close to a \"Full Outer Merge Join\". It differs only in how duplicates are treated... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] | I've got an [algorithm that compares two sorted lists](https://stackoverflow.com/questions/161432/best-algorithm-for-synchronizing-two-ilist-in-c-2-0/161535#161535), and I'm planning to make it more LINQ-y.
My first question: is there anything like this in LINQ already?
If not, I'm planning on writing it as an extens... | You are [Synchronizing](http://en.wikipedia.org/wiki/Data_synchronization) the lists, though the name has unfortunate connotations of thread synchronization.
I would say that 'ReconcileOrdered' (perhaps OrderedReconcile) is a reasonable name (it is probably very important to indicate in the function's name that the ar... |
551,156 | <p>I have a class, defined in a head as:</p>
<pre><code>template <typename T> class MyClass
{
template <typename U> friend std::ostream& operator<<(std::ostream& output, const MyClass<U>& p);
public:
...
}
</code></pre>
<p>In an implementation file, I have:</p>
<pre><c... | [
{
"answer_id": 551160,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>In an implementation file, I have:</p>\n</blockquote>\n\n<p>That's the problem. You can't split tem... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23167/"
] | I have a class, defined in a head as:
```
template <typename T> class MyClass
{
template <typename U> friend std::ostream& operator<<(std::ostream& output, const MyClass<U>& p);
public:
...
}
```
In an implementation file, I have:
```
template <typename U> std::ostream& operator<<(std::ostream& output, ... | >
> In an implementation file, I have:
>
>
>
That's the problem. You can't split template definitions between header and implementation files. Due to the nature of templates, C++ compilers are finicky here. Define all the code in the header to make it work.
In fact, the problem here is that all template definitio... |
551,159 | <p><em>With reference to <a href="https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment">this programming game</a> I am currently building.</em></p>
<p>When the game is started, I am generating these robots at supposingly random points on a Canvas, and at first loo... | [
{
"answer_id": 551172,
"author": "Dominic Hopton",
"author_id": 9475,
"author_profile": "https://Stackoverflow.com/users/9475",
"pm_score": 3,
"selected": true,
"text": "<p>I believe the problem is that your random numbers aren't being seeded properly. Use a single instance of Random, ra... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44084/"
] | *With reference to [this programming game](https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment) I am currently building.*
When the game is started, I am generating these robots at supposingly random points on a Canvas, and at first look (adding one or two bots at... | I believe the problem is that your random numbers aren't being seeded properly. Use a single instance of Random, rather than multiple ones, and you should see much improvement.
User added "why they were in a straight line" -- probably because of the default progression of the generated random numbers based on the seed... |
551,183 | <p>i am new to asp.net.Can you post an equivalent vb.net code following the C#.net code.
Thanks</p>
<pre><code>public string getSecureCookie(HttpRequest Request)
{
HttpCookie secureCookie = Request.Cookies["Test"];
if(secureCookie!=null)
{
return secureCookie.ToString();
}
else
... | [
{
"answer_id": 551193,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 2,
"selected": false,
"text": "<p>Try this</p>\n\n<pre><code>Public Function getSecureCookie(ByVal request as HttpRequest) As String\n Dim cookie = req... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66143/"
] | i am new to asp.net.Can you post an equivalent vb.net code following the C#.net code.
Thanks
```
public string getSecureCookie(HttpRequest Request)
{
HttpCookie secureCookie = Request.Cookies["Test"];
if(secureCookie!=null)
{
return secureCookie.ToString();
}
else
{
... | Run through the code translator available at <http://www.carlosag.net/Tools/CodeTranslator/>
```
Public Function getSecureCookie(ByVal Request As HttpRequest) As String
Dim secureCookie As HttpCookie = Request.Cookies("Test")
If (Not (secureCookie) Is Nothing) Then
Return secureCookie.ToString
Else... |
551,226 | <p>I am starting Boost.Asio and trying to make examples given on official website work.<br>
here`s client code:</p>
<pre><code>
using boost::asio::ip::tcp;
int _tmain(int argc, _TCHAR* argv[])
{
try {
boost::asio::io_service io_service;
tcp::resolver resolver(io_service);
tcp::resolver::q... | [
{
"answer_id": 551262,
"author": "Artyom",
"author_id": 66522,
"author_profile": "https://Stackoverflow.com/users/66522",
"pm_score": 0,
"selected": false,
"text": "<p>If I not mistake, you are trying to use UNICODE string -- tchar. Use <strong>standard</strong></p>\n\n<pre><code>int mai... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28298/"
] | I am starting Boost.Asio and trying to make examples given on official website work.
here`s client code:
```
using boost::asio::ip::tcp;
int _tmain(int argc, _TCHAR* argv[])
{
try {
boost::asio::io_service io_service;
tcp::resolver resolver(io_service);
tcp::resolver::query query(argv... | You would run the program with the IP or Hostname of the server you want to connect to. tcp::resolver::query takes the host to resolve or the IP as the first parameter and the name of the service (as defined e.g. in /etc/services on Unix hosts) - you can also use a numeric service identifier (aka port number). It retur... |
551,227 | <p>I'm thinking about using Python as an <strong>embedded scripting language</strong> in a hobby project written in <strong>C++</strong>. I would not like to depend on separately installed Python distribution. Python documentation seems to be quite clear about general usage, but I couldn't find a clear answer to this.<... | [
{
"answer_id": 551252,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 3,
"selected": false,
"text": "<p>The embedding process is fully documented : <a href=\"http://docs.python.org/extending/embedding.html\" rel=\"nofollow nore... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1640962/"
] | I'm thinking about using Python as an **embedded scripting language** in a hobby project written in **C++**. I would not like to depend on separately installed Python distribution. Python documentation seems to be quite clear about general usage, but I couldn't find a clear answer to this.
Is it feasible to deploy a P... | Link your application to the python library (pythonXX.lib on Windows) and add the following to your main() function.
```
Py_NoSiteFlag = 1; // Disable importing site.py
Py_Initialize(); // Create a python interpreter
```
Put the python standard library bits you need into a zip file (called pythonXX.zip) and plac... |
551,246 | <p>Why can't I filter results on the attribute value rather than the index?</p>
<p>Something like this fails.</p>
<pre><code>foreach ($portfolio->clientGroup[$id]->client['name=foo']->src as $src) {
echo $src . '<br />';
}
</code></pre>
<p>But this works.</p>
<pre><code>foreach ($portfolio->cli... | [
{
"answer_id": 551255,
"author": "phihag",
"author_id": 35070,
"author_profile": "https://Stackoverflow.com/users/35070",
"pm_score": 3,
"selected": true,
"text": "<p>This does not work because SimpleXML is a lightweight implementation. Plus, you can't assume <strong>anything</strong> to... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4241/"
] | Why can't I filter results on the attribute value rather than the index?
Something like this fails.
```
foreach ($portfolio->clientGroup[$id]->client['name=foo']->src as $src) {
echo $src . '<br />';
}
```
But this works.
```
foreach ($portfolio->clientGroup[$id]->client[0]->src as $src) {
echo $src . '<br /... | This does not work because SimpleXML is a lightweight implementation. Plus, you can't assume **anything** to work unless you have a specification.
You are looking for the [xpath function](http://php.net/manual/en/function.simplexml-element-xpath.php) of `SimpleXMLElement` objects, i.e.:
```
foreach ($portfolio->clien... |
551,263 | <p>Consider:</p>
<pre><code>// member data omitted for brevity
// assume that "setAngle" needs to be implemented separately
// in Label and Image, and that Button does need to inherit
// Label, rather than, say, contain one (etc)
struct Widget {
Widget& move(Point newPos) { pos = newPos; return *this; }
};
... | [
{
"answer_id": 551267,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 0,
"selected": false,
"text": "<p>Well, you know it's a <code>Button</code> so you should be able to cast the returned <code>Widget&</code> as a <code>Bu... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Consider:
```
// member data omitted for brevity
// assume that "setAngle" needs to be implemented separately
// in Label and Image, and that Button does need to inherit
// Label, rather than, say, contain one (etc)
struct Widget {
Widget& move(Point newPos) { pos = newPos; return *this; }
};
struct Label : Wid... | For the second problem, making setAngle virtual should do the trick.
For the first one, there are no easy solutions. Widget::move returns a Widget, which doesn't have a setText method. You could make a pure virtual setText method, but that'd be a pretty ugly solution. You could overload move() on the button class, but... |
551,309 | <p>I am trying to have 2 tables with crossed foreign keys, but I am not allowed to reference a table that doesn't exist when I am creating them. Any way of creating tables like this for mysql, something like declare both tables at the same time or delay evaluation of foreign keys?</p>
<p>Error is 1005: Can't create ta... | [
{
"answer_id": 551340,
"author": "Alexander Lebedev",
"author_id": 64045,
"author_profile": "https://Stackoverflow.com/users/64045",
"pm_score": 4,
"selected": true,
"text": "<p>Bringing cletus's answer (which is perfectly correct) to the code...</p>\n\n<pre><code>create table if not exi... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to have 2 tables with crossed foreign keys, but I am not allowed to reference a table that doesn't exist when I am creating them. Any way of creating tables like this for mysql, something like declare both tables at the same time or delay evaluation of foreign keys?
Error is 1005: Can't create table blocks... | Bringing cletus's answer (which is perfectly correct) to the code...
```
create table if not exists pages(
pageID int unsigned not null auto_increment,
title varchar(50) not null,
content blob,
blockid int unsigned not null,
primary key(pageID) ) engine=innodb;
create table if not exists blo... |
551,320 | <p>If you have a layout that has in a menu which gets its menu items from a database. Where is the recommended place in a Rails application to place that call and assigns it to the instance variable that the layout uses?</p>
<pre><code>1. @menuitems # exists in application.html.erb
2. @menuitems = MenuItem.find(:all) ... | [
{
"answer_id": 551466,
"author": "Joe Soul-bringer",
"author_id": 56279,
"author_profile": "https://Stackoverflow.com/users/56279",
"pm_score": 0,
"selected": false,
"text": "<p>Martin Fowler has described direct calls to active record function within template code one of the weaknesses ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34991/"
] | If you have a layout that has in a menu which gets its menu items from a database. Where is the recommended place in a Rails application to place that call and assigns it to the instance variable that the layout uses?
```
1. @menuitems # exists in application.html.erb
2. @menuitems = MenuItem.find(:all) # code exists ... | Yes, you can define and set this as a `before_filter` in your application controller. All your controllers will call that before filter. It's not all that uncommon to set global instance variables this way.
An alternative is to use a memoization method in application controller and set is as a helper method, in a simi... |
551,326 | <p>I have IIS log with extra field 'foo'. </p>
<pre><code>#Fields: foo date s-sitename ...
foo1 2009-02-15 W3SVC1 ...
foo2 2009-02-15 W3SVC1 ...
</code></pre>
<p>As result all LogParser queries are broken:</p>
<pre><code>logparser -i:IISW3C "SELECT c-ip, s-ip FROM my.log"
Statistics:
-----------
Elements processed... | [
{
"answer_id": 551347,
"author": "Robin",
"author_id": 60234,
"author_profile": "https://Stackoverflow.com/users/60234",
"pm_score": 0,
"selected": false,
"text": "<p>Don't know about LogParser but if you're not successful with that you could try <a href=\"http://splunk.com\" rel=\"nofol... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62192/"
] | I have IIS log with extra field 'foo'.
```
#Fields: foo date s-sitename ...
foo1 2009-02-15 W3SVC1 ...
foo2 2009-02-15 W3SVC1 ...
```
As result all LogParser queries are broken:
```
logparser -i:IISW3C "SELECT c-ip, s-ip FROM my.log"
Statistics:
-----------
Elements processed: 0
Elements output: 0
Execution t... | Try W3C format (-i:W3C).
If that doesn't work and this is a one-time analysis, you could create a script to strip out that column. If this is an ongoing activity, you might want to consider using a standard format, or at least moving the extra field to the end.
By the way LogParser does support [custom input formats]... |
551,350 | <p>Anything wrong with my code below? I got the compile error!</p>
<pre><code>typedef unsigned char BYTE;
void foo(char* & p)
{
return;
}
int main()
{
BYTE * buffer;
// error C2664: 'foo' : cannot convert parameter 1 from 'char *' to 'char *&'
foo ((char*)buffer);
return 0;
}
</code></pre>
<p>Than... | [
{
"answer_id": 551367,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 4,
"selected": false,
"text": "<p>When you cast the <code>BYTE*</code> to <code>char*</code> a unnamed temporary entity is created with the type <code>char*... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63235/"
] | Anything wrong with my code below? I got the compile error!
```
typedef unsigned char BYTE;
void foo(char* & p)
{
return;
}
int main()
{
BYTE * buffer;
// error C2664: 'foo' : cannot convert parameter 1 from 'char *' to 'char *&'
foo ((char*)buffer);
return 0;
}
```
Thanks in advance,
George | When you cast the `BYTE*` to `char*` a unnamed temporary entity is created with the type `char*`. The function you call takes a reference to a `char*` but you can't take a reference to such a temporary entity because it is not a real variable. |