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 |
|---|---|---|---|---|---|---|
299,565 | <p>I am compiling a legacy C code here and there is a lot of variables and struct members named "interface", but VC2008 express is complaining about these, do you know how to disable this?</p>
<p>I already changed settings to compile the code only as a C code, but no effect on this.</p>
| [
{
"answer_id": 299593,
"author": "wimh",
"author_id": 33499,
"author_profile": "https://Stackoverflow.com/users/33499",
"pm_score": 3,
"selected": true,
"text": "<p>Do a </p>\n\n<pre><code>#define interface QQInterface\n</code></pre>\n\n<p>before your code (eg. in the header file), this ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/440867/"
] | I am compiling a legacy C code here and there is a lot of variables and struct members named "interface", but VC2008 express is complaining about these, do you know how to disable this?
I already changed settings to compile the code only as a C code, but no effect on this. | Do a
```
#define interface QQInterface
```
before your code (eg. in the header file), this way everywhere where the keyword interface is used, the compilers sees "QQInterface", which is not a keyword. If all code includes this define, you will not get compiler or linker errors. |
299,574 | <p>If I have the following setting in my app.config file. It is a setting I need to make sure my WCF client can negotiate the default proxy server.</p>
<pre><code><system.net>
<defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy>
</system.net>
</code></pre>
<p>Unfortun... | [
{
"answer_id": 299627,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": -1,
"selected": false,
"text": "<p>Whatever the defined name of your executable (not a library dll) assembly is, add a \".config\" at the end...... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36687/"
] | If I have the following setting in my app.config file. It is a setting I need to make sure my WCF client can negotiate the default proxy server.
```
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy>
</system.net>
```
Unfortunately, I can't add to the app.config file in my env... | I think what you do is create a `System.Net.WebProxy` object, then set the appropriate variables, then set the `System.Net.WebRequest.DefaultWebProxy`:
```
System.Net.WebProxy proxy = new WebProxy();
proxy.UseDefaultCredentials = true;
WebRequest.DefaultWebProxy = proxy;
```
This post sort of talks about the whole t... |
299,585 | <p>The net is overflowing with explanations of the <a href="http://en.wikipedia.org/wiki/Diamond_problem" rel="nofollow noreferrer">"dreaded diamond problem"</a>.
So is StackOverflow. I think I understand that bit, but I fail to translate that knowledge into comprehending something similar yet different.</p>
<p>My qu... | [
{
"answer_id": 299952,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 2,
"selected": false,
"text": "<p>I <strong>think</strong> the issue with your COM example is that by adding the virtual keyword you are saying that all... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38656/"
] | The net is overflowing with explanations of the ["dreaded diamond problem"](http://en.wikipedia.org/wiki/Diamond_problem).
So is StackOverflow. I think I understand that bit, but I fail to translate that knowledge into comprehending something similar yet different.
My question begins as a pure C++ question, but the a... | I **think** the issue with your COM example is that by adding the virtual keyword you are saying that all the IOle\* interfaces share a common IUnknown implementation. In order to implement this the compiler has to create multiple v-tables, hence you different 'this' values depending on the derived class it came down.
... |
299,604 | <p>My current project involves deploying an upgraded .exe file that runs as a Windows Service. In order to overwrite the existing .exe with the new version, I currently need to:</p>
<ol>
<li>Stop the service</li>
<li>Uninstall the service</li>
<li>Reboot the system (so Windows releases it's hold on the file)</li>
<li... | [
{
"answer_id": 299614,
"author": "Jonathan S.",
"author_id": 2034,
"author_profile": "https://Stackoverflow.com/users/2034",
"pm_score": 4,
"selected": false,
"text": "<p>Are you not able to stop the service before the update (and restart after the update) using the commands below?</p>\n... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38657/"
] | My current project involves deploying an upgraded .exe file that runs as a Windows Service. In order to overwrite the existing .exe with the new version, I currently need to:
1. Stop the service
2. Uninstall the service
3. Reboot the system (so Windows releases it's hold on the file)
4. Deploy the new .exe
5. Reinstal... | ```
sc delete "service name"
```
will delete a service. I find that the [sc utility](http://technet.microsoft.com/en-us/library/bb490995.aspx) is much easier to locate than digging around for installutil. Remember to stop the service if you have not already. |
299,606 | <p>What is the most direct and/or efficient way to convert a <code>char[]</code> into a <code>CharSequence</code>? </p>
| [
{
"answer_id": 299609,
"author": "jjnguy",
"author_id": 2598,
"author_profile": "https://Stackoverflow.com/users/2598",
"pm_score": 3,
"selected": false,
"text": "<p>A <code>String</code> is a <code>CharSequence</code>. So you can just create a new <code>String</code> given your <code>c... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | What is the most direct and/or efficient way to convert a `char[]` into a `CharSequence`? | Without the copy:
```
CharSequence seq = java.nio.CharBuffer.wrap(array);
```
However, the `new String(array)` approach is likely to be easier to write, easier to read and faster. |
299,608 | <p>In addition to informing the user, we want to collect information for our debugging purposes. Our system is a niche system for only about 1400 customers, and therefore we are not as well-financed as we would hope, so bugs are more common than we would like. We currently have a window that shows the first line of t... | [
{
"answer_id": 299609,
"author": "jjnguy",
"author_id": 2598,
"author_profile": "https://Stackoverflow.com/users/2598",
"pm_score": 3,
"selected": false,
"text": "<p>A <code>String</code> is a <code>CharSequence</code>. So you can just create a new <code>String</code> given your <code>c... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12897/"
] | In addition to informing the user, we want to collect information for our debugging purposes. Our system is a niche system for only about 1400 customers, and therefore we are not as well-financed as we would hope, so bugs are more common than we would like. We currently have a window that shows the first line of the er... | Without the copy:
```
CharSequence seq = java.nio.CharBuffer.wrap(array);
```
However, the `new String(array)` approach is likely to be easier to write, easier to read and faster. |
299,619 | <p>I'd like to write a plugin that does something with the currently edited file in Eclipse. But I'm not sure how to properly get the file's full path.</p>
<p>This is what I do now:</p>
<pre><code>IFile file = (IFile) window.getActivePage().getActiveEditor.getEditorInput().
getAdapter(IFile.class);
</code></pre>
... | [
{
"answer_id": 299633,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 6,
"selected": true,
"text": "<p>Looks like you want <a href=\"http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fref... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4465/"
] | I'd like to write a plugin that does something with the currently edited file in Eclipse. But I'm not sure how to properly get the file's full path.
This is what I do now:
```
IFile file = (IFile) window.getActivePage().getActiveEditor.getEditorInput().
getAdapter(IFile.class);
```
Now I have an IFile object, a... | Looks like you want [`IResource.getRawLocation()`](http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fcore%2Fresources%2FIResource.html). That returns an `IPath`, which also has a `makeAbsolute()` method if you want to be doubly sure you've got an absolute... |
299,620 | <p>Long ago, I wrote a style 'normalizer' program to scan the ASP/HTML code of a big pile of classic ASP pages (most of which were originally generated from MS-Word documents, so naturally they were littered with superflous stylesheets and massive one-off styles). The style normalizer generated a minimal set of stylesh... | [
{
"answer_id": 300073,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 2,
"selected": false,
"text": "<p>Well, I can't say definitively that this \"works\" for everything described, but Tidy does a bit more than clean up ta... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9345/"
] | Long ago, I wrote a style 'normalizer' program to scan the ASP/HTML code of a big pile of classic ASP pages (most of which were originally generated from MS-Word documents, so naturally they were littered with superflous stylesheets and massive one-off styles). The style normalizer generated a minimal set of stylesheet... | Well, I can't say definitively that this "works" for everything described, but Tidy does a bit more than clean up tags.
See the [HTML Tidy Configuration Options](http://tidy.sourceforge.net/docs/quickref.html), especially those relating to Microsoft Word (like [word-2000](http://tidy.sourceforge.net/docs/quickref.html... |
299,659 | <p>What's the difference between <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ref/WeakReference.html" rel="noreferrer"><code>java.lang.ref.WeakReference</code></a> and <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ref/SoftReference.html" rel="noreferr... | [
{
"answer_id": 299663,
"author": "driekken",
"author_id": 24982,
"author_profile": "https://Stackoverflow.com/users/24982",
"pm_score": 8,
"selected": false,
"text": "<p>Weak references are collected eagerly. If GC finds that an object is\nweakly reachable (reachable only through weak re... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24982/"
] | What's the difference between [`java.lang.ref.WeakReference`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ref/WeakReference.html) and [`java.lang.ref.SoftReference`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ref/SoftReference.html) ? | From [Understanding Weak References](https://web.archive.org/web/20061130103858/http://weblogs.java.net/blog/enicholas/archive/2006/05/understanding_w.html), by Ethan Nicholas:
>
> **Weak references**
>
>
> A *weak reference*, simply put, is a
> reference that isn't strong enough to
> force an object to remain in... |
299,679 | <p>In my web app, when a user logs in, I add his Id to a vector of valid Ids in the servlet, when he logs out, I remove his Id from the vector, so I can see how many current users are active, if a user forgets to log out, my servelt generated html has : </p>
<pre><code><meta http-equiv="Refresh" content="30; url=My... | [
{
"answer_id": 299697,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 2,
"selected": false,
"text": "<p>in JavaScript you can use the <code>onbeforeclose</code> event to pass a call back to the server whe... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32834/"
] | In my web app, when a user logs in, I add his Id to a vector of valid Ids in the servlet, when he logs out, I remove his Id from the vector, so I can see how many current users are active, if a user forgets to log out, my servelt generated html has :
```
<meta http-equiv="Refresh" content="30; url=My_Servlet?User_Act... | There is no way to know on the server-side (unless you are using some JavaScript to send a message to the server) that the browser has closed. How could there be? Think of how HTTP works - everything is request and response.
However, the application server will track when Sessions are active and will even tell you whe... |
299,703 | <p>Once it is compiled, is there a difference between:</p>
<pre><code>delegate { x = 0; }
</code></pre>
<p>and</p>
<pre><code>() => { x = 0 }
</code></pre>
<p>?</p>
| [
{
"answer_id": 299712,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 8,
"selected": true,
"text": "<p>Short answer : no.</p>\n\n<p>Longer answer that may not be relevant: </p>\n\n<ul>\n<li>If you assign the lambda to a delega... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/93/"
] | Once it is compiled, is there a difference between:
```
delegate { x = 0; }
```
and
```
() => { x = 0 }
```
? | Short answer : no.
Longer answer that may not be relevant:
* If you assign the lambda to a delegate type (such as `Func` or `Action`) you'll get an anonymous delegate.
* If you assign the lambda to an Expression type, you'll get an expression tree instead of a anonymous delegate. The expression tree can then be comp... |
299,723 | <p>I need to do transactions (begin, commit or rollback), locks (select for update).
How can I do it in a document model db?</p>
<p>Edit:</p>
<p>The case is this:</p>
<ul>
<li>I want to run an auctions site.</li>
<li>And I think how to direct purchase as well.</li>
<li>In a direct purchase I have to decrement the qu... | [
{
"answer_id": 299744,
"author": "MrKurt",
"author_id": 35296,
"author_profile": "https://Stackoverflow.com/users/35296",
"pm_score": 8,
"selected": true,
"text": "<p>No. CouchDB uses an \"optimistic concurrency\" model. In the simplest terms, this just means that you send a document v... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1356709/"
] | I need to do transactions (begin, commit or rollback), locks (select for update).
How can I do it in a document model db?
Edit:
The case is this:
* I want to run an auctions site.
* And I think how to direct purchase as well.
* In a direct purchase I have to decrement the quantity field in the item record, but only ... | No. CouchDB uses an "optimistic concurrency" model. In the simplest terms, this just means that you send a document version along with your update, and CouchDB rejects the change if the current document version doesn't match what you've sent.
It's deceptively simple, really. You can reframe many normal transaction bas... |
299,728 | <p>I am running a script on a solaris Box. specifically SunOS 5.7. I am not root. I am trying to execute a script similar to the following:</p>
<blockquote>
<blockquote>
<p>newgrp thegroup <<
FOO<br>
source .login_stuff<br>
echo "hello world"<br>
FOO</p>
</blockquote>
</blockquote>
<p>Th... | [
{
"answer_id": 299767,
"author": "nobody",
"author_id": 19405,
"author_profile": "https://Stackoverflow.com/users/19405",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe </p>\n\n<pre><code>exec $SHELL\n</code></pre>\n\n<p>would do the trick?</p>\n"
},
{
"answer_id": 299840,
... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34531/"
] | I am running a script on a solaris Box. specifically SunOS 5.7. I am not root. I am trying to execute a script similar to the following:
>
>
> >
> > newgrp thegroup <<
> > FOO
> >
> > source .login\_stuff
> >
> > echo "hello world"
> >
> > FOO
> >
> >
> >
>
>
>
The Script runs. The problem is it... | ```
newgrp adm << ANYNAME
# You can do more lines than just this.
echo This is running as group \$(id -gn)
ANYNAME
```
..will output:
```
This is running as group adm
```
Be careful -- Make sure you escape the '$' with a slash. The interactions are a little strange, because it expands even single-quotes before it ... |
299,729 | <p>I am trying to call a Actionscript function from javascript but I am having problems in Internet Explorer.
I am using Swiff.remote in mootools 1.2.1 to call the actionscript function ie:</p>
<pre><code>Swiff.remote(playSwf.toElement(), 'sendResult', result, plays, name);
</code></pre>
<p>This all works fine in Fir... | [
{
"answer_id": 299882,
"author": "picardo",
"author_id": 32816,
"author_profile": "https://Stackoverflow.com/users/32816",
"pm_score": 3,
"selected": false,
"text": "<p>I'm not familiar with the Swiff plugin, but you don't need a plugin to call flash functions from Javascript. It's even ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to call a Actionscript function from javascript but I am having problems in Internet Explorer.
I am using Swiff.remote in mootools 1.2.1 to call the actionscript function ie:
```
Swiff.remote(playSwf.toElement(), 'sendResult', result, plays, name);
```
This all works fine in FireFox, Safari and Opera but... | I'm not familiar with the Swiff plugin, but you don't need a plugin to call flash functions from Javascript. It's even easier to do it natively.
From AS:
```
//1. calling javascript function from Flash.
ExternalInterface.call("sendData",tempStr);
// argument 1: javascript function, argument 2: data/variables to pass... |
299,761 | <p>I'm starting to use CUDA at the moment and have to admit that I'm a bit disappointed with the C API. I understand the reasons for choosing C but had the language been based on C++ instead, several aspects would have been a lot simpler, e.g. device memory allocation (via <code>cudaMalloc</code>).</p>
<p>My plan was ... | [
{
"answer_id": 300753,
"author": "coryan",
"author_id": 33325,
"author_profile": "https://Stackoverflow.com/users/33325",
"pm_score": 4,
"selected": true,
"text": "<p>I would go with the placement new approach. Then I would define a class that conforms to the std::allocator<> interfa... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1968/"
] | I'm starting to use CUDA at the moment and have to admit that I'm a bit disappointed with the C API. I understand the reasons for choosing C but had the language been based on C++ instead, several aspects would have been a lot simpler, e.g. device memory allocation (via `cudaMalloc`).
My plan was to do this myself, us... | I would go with the placement new approach. Then I would define a class that conforms to the std::allocator<> interface. In theory, you could pass this class as a template parameter into std::vector<> and std::map<> and so forth.
Beware, I have heard that doing such things is fraught with difficulty, but at least you ... |
299,770 | <p>I am trying to convert a working MS Access query to run on an Oracle database being accessed via VB Script (.asp). This is the last section of the WHERE clause:</p>
<pre><code>sql = sql & "WHERE (UAT.HB.MB_MODE = 'A' AND UAT.HB.PRINT_DATE >= '"
& SD & "' AND UAT.HB.PRINT_DATE <= '" & ED &a... | [
{
"answer_id": 299779,
"author": "Brett McCann",
"author_id": 9293,
"author_profile": "https://Stackoverflow.com/users/9293",
"pm_score": 0,
"selected": false,
"text": "<p>The default date format for Oracle is \"dd-mon-yy\". You can do a TO_CHAR function on the date field to convert it ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26883/"
] | I am trying to convert a working MS Access query to run on an Oracle database being accessed via VB Script (.asp). This is the last section of the WHERE clause:
```
sql = sql & "WHERE (UAT.HB.MB_MODE = 'A' AND UAT.HB.PRINT_DATE >= '"
& SD & "' AND UAT.HB.PRINT_DATE <= '" & ED &"' )"
```
The variable "SD" (i.e. ... | In Oracle, your date should be written as an ANSI date literal like this:
```
DATE '2008-11-11'
```
Or converted to a date from a string like this:
```
TO_DATE('11/11/2008', 'MM/DD/YYYY')
```
See [here](https://docs.oracle.com/database/121/SQLRF/sql_elements003.htm#BABGIGCJ) |
299,797 | <p>I'm executing several discrete queries in a single batch against SQL Server. For example:</p>
<pre>
update tableX set colA = 'freedom';
select lastName from customers;
insert into tableY (a,b,c) values (x,y,z);
</pre>
<p>Now, I want to capture the result in a DataSet (from select statement) which is easy enough ... | [
{
"answer_id": 299925,
"author": "Nick DeVore",
"author_id": 1380,
"author_profile": "https://Stackoverflow.com/users/1380",
"pm_score": 2,
"selected": false,
"text": "<p>My suggestion would be to use the @@rowcount variable for this. Usually, when I'm doing these kind of commands, if I... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4398/"
] | I'm executing several discrete queries in a single batch against SQL Server. For example:
```
update tableX set colA = 'freedom';
select lastName from customers;
insert into tableY (a,b,c) values (x,y,z);
```
Now, I want to capture the result in a DataSet (from select statement) which is easy enough to do...but h... | look into SQL Connection events. I think that's what you're after:
<http://msdn.microsoft.com/en-us/library/a0hee08w.aspx> |
299,802 | <p>In Mootools, I'd just run <code>if ($('target')) { ... }</code>. Does <code>if ($('#target')) { ... }</code> in jQuery work the same way?</p>
| [
{
"answer_id": 299812,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 7,
"selected": false,
"text": "<p>no, jquery always returns a jquery object regardless if a selector was matched or not.\nYou need to use .length</p>\n\n... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38666/"
] | In Mootools, I'd just run `if ($('target')) { ... }`. Does `if ($('#target')) { ... }` in jQuery work the same way? | As the other commenters are suggesting the most efficient way to do it seems to be:
```
if ($(selector).length ) {
// Do something
}
```
If you absolutely must have an exists() function - which will be slower- you can do:
```
jQuery.fn.exists = function(){return this.length>0;}
```
Then in your code you can ... |
299,806 | <p>I'd like to have my Eclipse plugin cause a URL to be opened by the users' default browser. This seems like pretty standard behavior, but I haven't been able to find any docs on how to do this.</p>
<p>Can anyone help?</p>
| [
{
"answer_id": 299841,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 1,
"selected": false,
"text": "<p>Do you mean launch an external windows (IE, FireFox, ...) outside eclipse, or opening an internal \"<a href=\"http://kickjav... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4465/"
] | I'd like to have my Eclipse plugin cause a URL to be opened by the users' default browser. This seems like pretty standard behavior, but I haven't been able to find any docs on how to do this.
Can anyone help? | You are looking for:
```
final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser( ... );
browser.openURL(url);
``` |
299,811 | <p>I'm reloading a web page that has the following code:</p>
<pre><code><label for="showimage">Show Image</label>
<input id="showimage" name="showimage" type="checkbox" value="1" />
</code></pre>
<p>Even though the HTML stays sent to the browser is the same for each reload of the page, the checkbox ... | [
{
"answer_id": 299849,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 6,
"selected": true,
"text": "<p>Yes, I believe it is caching. I see this behaviour on Firefox for example (not Safari, for what that's worth :) ).</p>\n\n<p>... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | I'm reloading a web page that has the following code:
```
<label for="showimage">Show Image</label>
<input id="showimage" name="showimage" type="checkbox" value="1" />
```
Even though the HTML stays sent to the browser is the same for each reload of the page, the checkbox always takes on the checked value when a rel... | Yes, I believe it is caching. I see this behaviour on Firefox for example (not Safari, for what that's worth :) ).
you can reload the page and bypass the cache (on Firefox) using `CTRL`-`SHIFT`-`R` and you'll see the check value doesn't carry (a normal `CTRL`-`R` will grab the info from the cache however)
**edit**: I... |
299,814 | <p>I'm trying to setup an alert to let me know via email (SMTP) when free disk space on one of my servers is less than a specified value. To do this I'm using PerfMon alerts, as described at <a href="http://support.microsoft.com/kb/324796" rel="nofollow noreferrer">MSFT Technet</a>. I have the alert working and writing... | [
{
"answer_id": 299849,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 6,
"selected": true,
"text": "<p>Yes, I believe it is caching. I see this behaviour on Firefox for example (not Safari, for what that's worth :) ).</p>\n\n<p>... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32474/"
] | I'm trying to setup an alert to let me know via email (SMTP) when free disk space on one of my servers is less than a specified value. To do this I'm using PerfMon alerts, as described at [MSFT Technet](http://support.microsoft.com/kb/324796). I have the alert working and writing to the system log, but when I try to se... | Yes, I believe it is caching. I see this behaviour on Firefox for example (not Safari, for what that's worth :) ).
you can reload the page and bypass the cache (on Firefox) using `CTRL`-`SHIFT`-`R` and you'll see the check value doesn't carry (a normal `CTRL`-`R` will grab the info from the cache however)
**edit**: I... |
299,851 | <p>CodeIgniter allows access to POSTed data via:</p>
<pre><code>$this->input->post('input_name');
</code></pre>
<p>where 'input_name' is the name of a form field. This works well for a static form where each input name in known ahead of time.</p>
<p>In my case, I am loading a collection of key/value pairs from... | [
{
"answer_id": 299865,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 4,
"selected": true,
"text": "<p>According to the documentation, no. I would suggest just using <code>array_keys($_POST)</code> to get the keys.</p>\n"
... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3238/"
] | CodeIgniter allows access to POSTed data via:
```
$this->input->post('input_name');
```
where 'input\_name' is the name of a form field. This works well for a static form where each input name in known ahead of time.
In my case, I am loading a collection of key/value pairs from the database. The form contains a tex... | According to the documentation, no. I would suggest just using `array_keys($_POST)` to get the keys. |
299,869 | <p>I am using a ResourceDictionary, but I would like to be able to look up the value or the key with the other item. Each is always unique, so that is not a problem. Is there a type that has this double sided lookup feature?</p>
| [
{
"answer_id": 299878,
"author": "Craig Wilson",
"author_id": 25333,
"author_profile": "https://Stackoverflow.com/users/25333",
"pm_score": 4,
"selected": true,
"text": "<p>Not built in, but this is pretty easy to write. I would probably implement IDictionary for this though... You wou... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30838/"
] | I am using a ResourceDictionary, but I would like to be able to look up the value or the key with the other item. Each is always unique, so that is not a problem. Is there a type that has this double sided lookup feature? | Not built in, but this is pretty easy to write. I would probably implement IDictionary for this though... You would then dump the ResourceDictionary into your custom type.
```
public class DoubleLookup<TKey, TValue>
{
private IDictionary<TKey, TValue> keys;
private IDictionary<TValue, TKey> values;
//stuff...
... |
299,870 | <p>How can I center an image horizontally and aligned to the bottom of the container at the same time? </p>
<p>I have been able to center the image horizontally by its self. I have also been able to align the bottom of the container by its self. But I have not been able to do both at the same time. </p>
<p>Here is wh... | [
{
"answer_id": 299884,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 0,
"selected": false,
"text": "<p>Remove the <code>position: relative;</code> line. I'm not sure why exactly but it fixes it for me.</p>\n"
},
{
... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13778/"
] | How can I center an image horizontally and aligned to the bottom of the container at the same time?
I have been able to center the image horizontally by its self. I have also been able to align the bottom of the container by its self. But I have not been able to do both at the same time.
Here is what I have:
```
.... | ```
.image_block {
width: 175px;
height: 175px;
position: relative;
}
.image_block a {
width: 100%;
text-align: center;
position: absolute;
bottom: 0px;
}
.image_block img {
/* nothing specific */
}
```
**explanation**: an element positioned absolutely will be relative to the cl... |
299,895 | <p>When I call this function, everything works, as long as I don't try to recursively call the function again. In other words if I uncomment the line:</p>
<pre><code>GetChilds rsData("AcctID"), intLevel + 1
</code></pre>
<p>Then the function breaks. </p>
<pre><code><%
Function GetChilds(ParentID, intLevel)
... | [
{
"answer_id": 299908,
"author": "devio",
"author_id": 21336,
"author_profile": "https://Stackoverflow.com/users/21336",
"pm_score": 0,
"selected": false,
"text": "<p>try declaring the variables as local using a DIM statement within the function definition:</p>\n\n<pre><code>Function Get... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38678/"
] | When I call this function, everything works, as long as I don't try to recursively call the function again. In other words if I uncomment the line:
```
GetChilds rsData("AcctID"), intLevel + 1
```
Then the function breaks.
```
<%
Function GetChilds(ParentID, intLevel)
Set rsData= Server.CreateObject("... | Look like it fails because your connection is still busy serving the RecordSet from the previous call.
One option is to use a fresh connection for each call. The danger there is that you'll quickly run out of connections if you recurse too many times.
Another option is to read the contents of each RecordSet into a d... |
299,940 | <p>The following code works for me:</p>
<pre><code>var webProxy = WebProxy.GetDefaultProxy();
webProxy.UseDefaultCredentials = true;
WebRequest.DefaultWebProxy = webProxy;
</code></pre>
<p>Unfortunately, <code>WebProxy.GetDefaultProxy()</code> is deprecated. What else should I be doing?</p>
<p>(using app.config to ... | [
{
"answer_id": 300738,
"author": "Martin Hollingsworth",
"author_id": 29491,
"author_profile": "https://Stackoverflow.com/users/29491",
"pm_score": 7,
"selected": true,
"text": "<p>From .NET 2.0 you shouldn't need to do this. If you do not explicitly set the Proxy property on a web reque... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36687/"
] | The following code works for me:
```
var webProxy = WebProxy.GetDefaultProxy();
webProxy.UseDefaultCredentials = true;
WebRequest.DefaultWebProxy = webProxy;
```
Unfortunately, `WebProxy.GetDefaultProxy()` is deprecated. What else should I be doing?
(using app.config to set the defaultProxy settings is not allowed ... | From .NET 2.0 you shouldn't need to do this. If you do not explicitly set the Proxy property on a web request it uses the value of the static WebRequest.DefaultWebProxy. If you wanted to change the proxy being used by all subsequent WebRequests, you can set this static DefaultWebProxy property.
The default behaviour o... |
299,942 | <p>I have a string of test like this:</p>
<pre><code><customtag>hey</customtag>
</code></pre>
<p>I want to use a RegEx to modify the text between the "customtag" tags so that it might look like this:</p>
<pre><code><customtag>hey, this is changed!</customtag>
</code></pre>
<p>I know that I c... | [
{
"answer_id": 299951,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": false,
"text": "<p>I'd chew my own leg off before using a regular expression to parse and alter HTML.</p>\n\n<p>Use <a href=\"http://w... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] | I have a string of test like this:
```
<customtag>hey</customtag>
```
I want to use a RegEx to modify the text between the "customtag" tags so that it might look like this:
```
<customtag>hey, this is changed!</customtag>
```
I know that I can use a MatchEvaluator to modify the text, but I'm unsure of the proper ... | I wouldn't use regex either for this, but if you must this expression should work:
`<customtag>(.+?)</customtag>` |
299,950 | <p>I am trying to use a Generic Linked List to hold some WorkFlow steps in my application. Here is how I'm persisting it to my database.</p>
<p>OrderID WorkFlowStepID ParentWorkFlowStepID<br/>
178373 1 ... | [
{
"answer_id": 299979,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>So do you mean you're using the <a href=\"http://msdn.microsoft.com/en-us/library/he2s3bh7.aspx\" rel=\"nofollow noref... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37347/"
] | I am trying to use a Generic Linked List to hold some WorkFlow steps in my application. Here is how I'm persisting it to my database.
OrderID WorkFlowStepID ParentWorkFlowStepID
178373 1 NULL
178373 2 1
178373 3 2
I get this... | So do you mean you're using the [linked list class in the framework](http://msdn.microsoft.com/en-us/library/he2s3bh7.aspx)?
If so, the `Find` method doesn't really do what you want it to. Basically you want a version which takes a predicate. This would be easier if the class exposed an iterator of [`LinkedListNode<T>... |
299,956 | <p>I have a CompositeDataBoundControl and im trying to add a ItemCommand to it, ala the System.Web.UI.WebControls.Repeater - so like a numpty, I just thought if I reflector'ed and added the code like so, it should work:</p>
<pre><code>private static readonly object EventItemCommand = new object();
protected override ... | [
{
"answer_id": 300345,
"author": "Atanas Korchev",
"author_id": 10141,
"author_profile": "https://Stackoverflow.com/users/10141",
"pm_score": 3,
"selected": true,
"text": "<p>In the case of the Repeater control the RepeaterItem object is actually raising the bubble event and supplying th... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1276/"
] | I have a CompositeDataBoundControl and im trying to add a ItemCommand to it, ala the System.Web.UI.WebControls.Repeater - so like a numpty, I just thought if I reflector'ed and added the code like so, it should work:
```
private static readonly object EventItemCommand = new object();
protected override bool OnBubbleE... | In the case of the Repeater control the RepeaterItem object is actually raising the bubble event and supplying the RepeaterCommandEventArgs:
```
protected override bool OnBubbleEvent(object source, EventArgs e)
{
if (e is CommandEventArgs)
{
RepeaterCommandEventArgs args = new RepeaterCommandEventArgs(... |
299,969 | <p>I have form with 2 DDL named</p>
<p>State and City</p>
<p>State:</p>
<pre><code><asp:UpdatePanel ID="States" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="States"EventName="SelectedIndexChanged" />
</Triggers>
&... | [
{
"answer_id": 300452,
"author": "Chris Marisic",
"author_id": 37055,
"author_profile": "https://Stackoverflow.com/users/37055",
"pm_score": 2,
"selected": false,
"text": "<p>I recommend creating a private property in the ViewState that holds the collection of physical objects. Then add ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38230/"
] | I have form with 2 DDL named
State and City
State:
```
<asp:UpdatePanel ID="States" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="States"EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:DropDownList ID="S... | I recommend creating a private property in the ViewState that holds the collection of physical objects. Then add the object to that list then databind the list of objects to the drop down.
Page Behind
```
<asp:DropDownList runat="server" ID="ddlCity" DataValueField="Key" DataTextField="Value">
</asp:DropDownList>
``... |
299,978 | <p>I am in the process of creating an XML Schema and one of my values is a year. As such, I'd like to ensure that all values have exactly 4 characters. To do so, I am using the following syntax:</p>
<pre><code><xs:element name="publish_year" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="x... | [
{
"answer_id": 299988,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 4,
"selected": true,
"text": "<p>How about a plage of value as an additional restriction ?</p>\n\n<p>(<a href=\"http://www.w3.org/TR/xmlschema-2/#rf-minInclus... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10040/"
] | I am in the process of creating an XML Schema and one of my values is a year. As such, I'd like to ensure that all values have exactly 4 characters. To do so, I am using the following syntax:
```
<xs:element name="publish_year" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:positiveInteger">
<xs:t... | How about a plage of value as an additional restriction ?
([minInclusive](http://www.w3.org/TR/xmlschema-2/#rf-minInclusive) - [maxInclusive](http://www.w3.org/TR/xmlschema-2/#dc-maxInclusive))
For instance ?
```
<xs:minInclusive value="1900"/> et <xs:maxInclusive value="2008"/>
```
But to get back to the [totalDi... |
299,987 | <p>How can I select the good method (I have in the example below show 2 differents way that doesn't work). I was using instead of a variable of type Object with a IF and IS to do the job but I am trying to avoid using Object and boxing/unboxing. So I thought that Generic could do the job but I am stuck here.</p>
<p>H... | [
{
"answer_id": 300008,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>No, you can't do this. Generics don't work like C++ templates - the generic method is compiled just once. The only inf... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] | How can I select the good method (I have in the example below show 2 differents way that doesn't work). I was using instead of a variable of type Object with a IF and IS to do the job but I am trying to avoid using Object and boxing/unboxing. So I thought that Generic could do the job but I am stuck here.
Here is a sm... | No, you can't do this. Generics don't work like C++ templates - the generic method is compiled just once. The only information that the compiler can use for overload resolution is the information it knows about within the generic method, regardless of what code uses it.
As an example to show this, here's a bit of code... |
299,992 | <p>I'm working on some Silverlight controls and I would like to explicitly handle the way they appear in Blend.
Specifically, these controls have dependencies that are initialized at runtime, and thus throw exceptions in the designer. But even in the absence of the exception, I would like to make them appear a certain ... | [
{
"answer_id": 300170,
"author": "Bryant",
"author_id": 10893,
"author_profile": "https://Stackoverflow.com/users/10893",
"pm_score": 3,
"selected": true,
"text": "<p>There is an extremely detailed post on <a href=\"http://silverlight.net/blogs/justinangel/archive/2008/11/17/silverlight-... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6855/"
] | I'm working on some Silverlight controls and I would like to explicitly handle the way they appear in Blend.
Specifically, these controls have dependencies that are initialized at runtime, and thus throw exceptions in the designer. But even in the absence of the exception, I would like to make them appear a certain way... | There is an extremely detailed post on [how to deal with design time extensibility here](http://silverlight.net/blogs/justinangel/archive/2008/11/17/silverlight-design-time-extensibility.aspx). There you will find out how to do the Visual Studio and Blend design time stuff for Silverlight.
>
> Control vendors and pe... |
299,998 | <p>I have got a template class as follows:</p>
<pre><code>class MyClass<T>
{
T field;
public void myMethod()
{
field = new T(); // gives compiler error
}
}
</code></pre>
<p>How do I create a new instance of T in my class?</p>
| [
{
"answer_id": 300013,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 8,
"selected": true,
"text": "<p>After type erasure, all that is known about <code>T</code> is that it is some subclass of <code>Object</code>. You need t... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36858/"
] | I have got a template class as follows:
```
class MyClass<T>
{
T field;
public void myMethod()
{
field = new T(); // gives compiler error
}
}
```
How do I create a new instance of T in my class? | After type erasure, all that is known about `T` is that it is some subclass of `Object`. You need to specify some factory to create instances of `T`.
One approach could use a [`Supplier<T>`](http://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html):
```
class MyClass<T> {
private final Supplier<? ... |
299,999 | <p>Here's the code:</p>
<pre><code>render :file => @somedir + "/blah.xml"
</code></pre>
<p>...but the resulting MIME type is text/html when I check in FireBug. How do I specify a MIME type in this case?</p>
| [
{
"answer_id": 300043,
"author": "srboisvert",
"author_id": 6805,
"author_profile": "https://Stackoverflow.com/users/6805",
"pm_score": 2,
"selected": false,
"text": "<p>Take a look <a href=\"http://api.rubyonrails.org/classes/Mime/Type.html\" rel=\"nofollow noreferrer\">here</a>. Basic... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38684/"
] | Here's the code:
```
render :file => @somedir + "/blah.xml"
```
...but the resulting MIME type is text/html when I check in FireBug. How do I specify a MIME type in this case? | Actually there are two ways to set the content-type (I think this is what you mean by mime-type). You should use the second option, if it works for your Rails version.
```
class FileController < ApplicationController
def index
filename = 'some.xml'
extname = File.extname(filename)[1..-1]
mime_type = Mi... |
300,055 | <p>In C# if I want to convert a double (1.71472) to an int then I get the answer 2. If I do this in Java using intValue() method, I get 1 as the answer.</p>
<p>Does Java round down on conversions?</p>
<p>Why do the Java API docs have such scant information about their classes i.e. </p>
<blockquote>
<p>Returns the... | [
{
"answer_id": 300067,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 3,
"selected": false,
"text": "<p>Java rounds toward zero when narrowing from a floating point to an integer type.</p>\n\n<p>There's more documentation ab... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5175/"
] | In C# if I want to convert a double (1.71472) to an int then I get the answer 2. If I do this in Java using intValue() method, I get 1 as the answer.
Does Java round down on conversions?
Why do the Java API docs have such scant information about their classes i.e.
>
> Returns the value of the specified
> number a... | Java rounds toward zero when narrowing from a floating point to an integer type—and so does C#, when you use the casting conversion. It's `Convert.ToInt32` that rounds:
```
double d = 1.71472;
int x = (int) d; // x = 1
int y = Convert.ToInt32(d); // y = 2
```
Details can be found in the [Java Language Specification]... |
300,078 | <p>I know this specific question has been <a href="https://stackoverflow.com/questions/185235/jquery-tabs-getting-newly-selected-index">asked before</a>, but I am not getting any results using the <code>bind()</code> event on the <code>jQuery UI Tabs</code> plugin. </p>
<p>I just need the <code>index</code> of the new... | [
{
"answer_id": 300221,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 7,
"selected": true,
"text": "<p><strong>For JQuery UI versions before 1.9</strong>: <code>ui.index</code> from the <code>event</code> is what you want.<... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1284/"
] | I know this specific question has been [asked before](https://stackoverflow.com/questions/185235/jquery-tabs-getting-newly-selected-index), but I am not getting any results using the `bind()` event on the `jQuery UI Tabs` plugin.
I just need the `index` of the newly selected tab to perform an action when the tab is c... | **For JQuery UI versions before 1.9**: `ui.index` from the `event` is what you want.
**For JQuery UI 1.9 or later**: see the [answer](https://stackoverflow.com/a/12973370/2333214) by Giorgio Luparia, below. |
300,091 | <p>Assuming a class called <code>Bar</code> in a namespace called <code>foo</code>, which syntax do you prefer for your source (.cpp/.cc) file?</p>
<pre><code>namespace foo {
...
void Bar::SomeMethod()
{
...
}
} // foo
</code></pre>
<p>or</p>
<pre><code>void foo::Bar::SomeMethod()
{
...
}
</code></pre>
<p>... | [
{
"answer_id": 300107,
"author": "GeekyMonkey",
"author_id": 29900,
"author_profile": "https://Stackoverflow.com/users/29900",
"pm_score": 1,
"selected": false,
"text": "<p>I think it depends on each case. If it's a 3rd party library that's similar to your own code, and you want to avoi... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | Assuming a class called `Bar` in a namespace called `foo`, which syntax do you prefer for your source (.cpp/.cc) file?
```
namespace foo {
...
void Bar::SomeMethod()
{
...
}
} // foo
```
or
```
void foo::Bar::SomeMethod()
{
...
}
```
I use namespaces heavily and prefer the first syntax, but when adding c... | I would decline the first (*edit* : question changed, the first is what i prefer too now). Since it is not clear where Bar refers to from only looking at the function definition. Also, with your first method, slippy errors could show up:
```
namespace bar {
struct foo { void f(); };
}
namespace baz {
struc... |
300,093 | <p>In the Application_Error method in Global.asax I am trying to retrieve a value from session state.</p>
<p>I am able to access session state as long as I throw the exception. EG: </p>
<pre><code>thow new Exception("Test exception");
</code></pre>
<p>However if it is an unhandled exception, i get the following erro... | [
{
"answer_id": 300969,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 0,
"selected": false,
"text": "<p>I think you are trying to access the session through HttpContext.Current.Session. I believe the difference in beh... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1375/"
] | In the Application\_Error method in Global.asax I am trying to retrieve a value from session state.
I am able to access session state as long as I throw the exception. EG:
```
thow new Exception("Test exception");
```
However if it is an unhandled exception, i get the following error when trying to access session ... | I hate ASP.NET sometimes...
So generating an error using:
```
Response.Redirect("thispagedoesnotexist.aspx", false);
```
The above line will redirect to Application\_Error with session state not available
However
```
throw new Exception("test");
```
The above line will redirect to Application\_Error with sess... |
300,118 | <p>I have 2 tables, an active table and an inactive table. I want to <em>move</em> rows from the active to the inactive table. My first thought was</p>
<pre><code>insert into inactive select * from active where ...
delete from active active where ...
</code></pre>
<p>However about .42 seconds later I noticed this wil... | [
{
"answer_id": 300126,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 4,
"selected": true,
"text": "<p>Status flags are your friend.</p>\n\n<pre><code>UPDATE old_data SET move=\"MARKED\";\nINSERT INTO somewhere... SELECT whe... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | I have 2 tables, an active table and an inactive table. I want to *move* rows from the active to the inactive table. My first thought was
```
insert into inactive select * from active where ...
delete from active active where ...
```
However about .42 seconds later I noticed this will drop/duplicate rows if updates ... | Status flags are your friend.
```
UPDATE old_data SET move="MARKED";
INSERT INTO somewhere... SELECT where move="MARKED";
DELETE FROM old_data WHERE move="MARKED";
```
If you do this with Autocommit off, it will seize locks all over the place.
You can COMMIT after each step, if you want to do a little less locking. |
300,175 | <p>I've got a css menu like this:</p>
<pre><code><ul>
<li><a>Item1</a></li>
<li><a>Item Two</a></li>
<li><a>Item C</a></li>
<li><a>A Rather Long Menu Item Down Here</a></li>
</ul>
</code></pre>
<p>I want ... | [
{
"answer_id": 300218,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 2,
"selected": true,
"text": "<p>Your only option is javascript.</p>\n\n<p>BTW, one of my sites is visited by a large amount of home users. We've seen that ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24197/"
] | I've got a css menu like this:
```
<ul>
<li><a>Item1</a></li>
<li><a>Item Two</a></li>
<li><a>Item C</a></li>
<li><a>A Rather Long Menu Item Down Here</a></li>
</ul>
```
I want to create this:
```
|-----------------------------------|
| Item1 |
|---------------------------------... | Your only option is javascript.
BTW, one of my sites is visited by a large amount of home users. We've seen that IE6 is down to 12% of our traffic. Two months ago it was 20%. This is while overall IE traffic is staying at 76%
My point is that you probably shouldn't worry about IE6 quirks too much anymore. |
300,181 | <p>In a C# program, I have an abstract base class with a static "Create" method. The Create method is used to create an instance of the class and store it locally for later use. Since the base class is abstract, implementation objects will always derive from it.</p>
<p>I want to be able to derive an object from the ... | [
{
"answer_id": 300186,
"author": "technophile",
"author_id": 23029,
"author_profile": "https://Stackoverflow.com/users/23029",
"pm_score": 1,
"selected": false,
"text": "<p>You can't do it without outside information; either the type of the derived class, an instance of it, or the fully-... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19853/"
] | In a C# program, I have an abstract base class with a static "Create" method. The Create method is used to create an instance of the class and store it locally for later use. Since the base class is abstract, implementation objects will always derive from it.
I want to be able to derive an object from the base class, ... | Try using generics:
```
public static BaseClass Create<T>() where T : BaseClass, new()
{
T newVar = new T();
// Do something with newVar
return T;
}
```
Sample use:
```
DerivedClass d = BaseClass.Create<DerivedClass>();
``` |
300,185 | <p>Which version of JavaScript does Google Chrome support in relation to Mozilla Firefox? In other words, does Chrome support JavaScript 1.6, 1.7, or 1.8 which Firefox also supports or some combination of them?</p>
| [
{
"answer_id": 300231,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": false,
"text": "<p>Google Chrome supports up to Javascript 1.7:</p>\n\n<pre><code><script language=\"javascript1.7\">alert(1.7);</sc... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/208/"
] | Which version of JavaScript does Google Chrome support in relation to Mozilla Firefox? In other words, does Chrome support JavaScript 1.6, 1.7, or 1.8 which Firefox also supports or some combination of them? | While Chrome will execute Javascript marked as "javascript1.7", it does not support JS1.7 features like the "let" scoped variable operator.
This code will run on Firefox 3.5 but not on Chrome using V8:
```
<script language="javascript" type="application/javascript;version=1.7">
function foo(){ let a = 4; alert(a)... |
300,187 | <p>We have 2 flowdocuments that we'd like to compare similar to when using a diff viewer (winmerge, beyond compare, etc). Has anybody done this or know how to get the text out of a flowdocument to do a compare?</p>
| [
{
"answer_id": 300231,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": false,
"text": "<p>Google Chrome supports up to Javascript 1.7:</p>\n\n<pre><code><script language=\"javascript1.7\">alert(1.7);</sc... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | We have 2 flowdocuments that we'd like to compare similar to when using a diff viewer (winmerge, beyond compare, etc). Has anybody done this or know how to get the text out of a flowdocument to do a compare? | While Chrome will execute Javascript marked as "javascript1.7", it does not support JS1.7 features like the "let" scoped variable operator.
This code will run on Firefox 3.5 but not on Chrome using V8:
```
<script language="javascript" type="application/javascript;version=1.7">
function foo(){ let a = 4; alert(a)... |
300,196 | <p>I work on a W3C XML Schema (not written by me). One tool, xmllint,
refuses to use the schema:</p>
<pre><code>traceroute.xsd:658: element element: Schemas parser error : Element
'{http://www.w3.org/2001/XMLSchema}element', attribute 'maxOccurs': The value
'4294967295' is not valid. Expected is '(xs:nonNegativeInte... | [
{
"answer_id": 300256,
"author": "David Hall",
"author_id": 2660,
"author_profile": "https://Stackoverflow.com/users/2660",
"pm_score": 2,
"selected": false,
"text": "<p>While perhaps being a 'technically' correct usage of the <code>maxOccurs</code> attribute, this usage isn't (IMO) how ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15625/"
] | I work on a W3C XML Schema (not written by me). One tool, xmllint,
refuses to use the schema:
```
traceroute.xsd:658: element element: Schemas parser error : Element
'{http://www.w3.org/2001/XMLSchema}element', attribute 'maxOccurs': The value
'4294967295' is not valid. Expected is '(xs:nonNegativeInteger | unbounde... | While perhaps being a 'technically' correct usage of the `maxOccurs` attribute, this usage isn't (IMO) how the `maxOccurs` is intended to be used.
It looks like the schema writer intended to mean that this element may occur any number of times, in which case the correct value of the definition would be `unbounded`.
W... |
300,200 | <p>I want to embed a swf over a html page, like a floating video watching panel. I already have a swf file which will automatically adjust its size according to the browser size, and the swf file is partially transparent. I thought I can just add a div tag, make the position absolute and change z-index bigger, but that... | [
{
"answer_id": 300338,
"author": "Adam",
"author_id": 36324,
"author_profile": "https://Stackoverflow.com/users/36324",
"pm_score": 0,
"selected": false,
"text": "<p>I believe the problem with this is that the CSS doesn't work well with <code><object /></code> tags. The <code>swfo... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34797/"
] | I want to embed a swf over a html page, like a floating video watching panel. I already have a swf file which will automatically adjust its size according to the browser size, and the swf file is partially transparent. I thought I can just add a div tag, make the position absolute and change z-index bigger, but that do... | Once you get your sizing to work properly you will need to set the *wmode* to *transparent* to be able to see what's behind the flash, if you don't it's background will be opaque.
This is a quick copypaste from the [swfobject docs](http://code.google.com/p/swfobject/wiki/documentation), but it should get the point acr... |
300,208 | <p>for the following:</p>
<pre><code>( a != b ) ? cout<<"not equal" : cout<<"equal";
</code></pre>
<p>suppose I don't care if it's equal, how can I use the above statement by substituting <code>cout<<"equal"</code> with a no-op.</p>
| [
{
"answer_id": 300223,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 1,
"selected": false,
"text": "<p>This is very confusing code. You <em>could</em> just write</p>\n\n<pre><code>cond ? cout << \"equal\" : cout... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8661/"
] | for the following:
```
( a != b ) ? cout<<"not equal" : cout<<"equal";
```
suppose I don't care if it's equal, how can I use the above statement by substituting `cout<<"equal"` with a no-op. | If it really is for a ternary operator that doesn't need a second action, the best option would be to replace it for an if:
```
if (a!=b) cout << "not equal";
```
it will smell a lot less. |
300,217 | <p>In javascript how do I get a handle on the frame that I'm in based on an element in that frame?</p>
<pre><code>function myFunction(elementInFrame){
// here I want to get a handle on the frame that elementInFrame lives in
}
</code></pre>
| [
{
"answer_id": 300279,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "<p>In IE you can do <code>elementInFrame.document.parentWindow</code>\nDoesn't work in Firefox unfortunately.</p>\n\n<p>Edit:... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24908/"
] | In javascript how do I get a handle on the frame that I'm in based on an element in that frame?
```
function myFunction(elementInFrame){
// here I want to get a handle on the frame that elementInFrame lives in
}
``` | elementInFrame.document.defaultView for non-IE browsers.
(It's not *quite* a standard part of the DOM; DOM Level 2 Views says the property exists but doesn't explicitly say it points to ‘window’, since the DOM standard currently known nothing about the window object.) |
300,220 | <p>Does anyone know how I can prevent the text in a table cell from wrapping? This is for the header of a table, and the heading is a lot longer than the data under it, but I need it to display on only one line. It is okay if the column is very wide.</p>
<p>The HTML of my (simplified) table looks like this:</p>
<pr... | [
{
"answer_id": 300235,
"author": "Sergey Golovchenko",
"author_id": 26592,
"author_profile": "https://Stackoverflow.com/users/26592",
"pm_score": 5,
"selected": false,
"text": "<p>There are at least two ways to do it:</p>\n\n<p>Use nowrap attribute inside the \"td\" tag:</p>\n\n<pre><cod... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4257/"
] | Does anyone know how I can prevent the text in a table cell from wrapping? This is for the header of a table, and the heading is a lot longer than the data under it, but I need it to display on only one line. It is okay if the column is very wide.
The HTML of my (simplified) table looks like this:
```
<table>
<thea... | Have a look at the [`white-space`](http://www.w3.org/TR/CSS21/text.html#white-space-prop) property, used like this:
```css
th {
white-space: nowrap;
}
```
This will force the contents of `<th>` to display on one line.
From linked page, here are the various options for `white-space`:
>
> **normal**
>
> Thi... |
300,259 | <p>I am sending the echo to mail function via PHP from variable that includes HTML code. The strange thing is, that this </p>
<pre><code><����}im�
</code></pre>
<p>shows up AFTER the string.. but I do not manipulate with it anymore. The charset of mail function (the attachment) is same as charset of HTML code.</p>... | [
{
"answer_id": 300267,
"author": "Alex",
"author_id": 16974,
"author_profile": "https://Stackoverflow.com/users/16974",
"pm_score": 3,
"selected": true,
"text": "<p>Encoding problem, maybe it tries to display binary code?</p>\n\n<p>You should use htmlentities if ou want to display HTML</... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21209/"
] | I am sending the echo to mail function via PHP from variable that includes HTML code. The strange thing is, that this
```
<����}im�
```
shows up AFTER the string.. but I do not manipulate with it anymore. The charset of mail function (the attachment) is same as charset of HTML code. | Encoding problem, maybe it tries to display binary code?
You should use htmlentities if ou want to display HTML
>
> // Outputs: A 'quote' is
>
>
> <b>bold</b> echo
>
>
> htmlentities($str);
>
>
> |
300,286 | <p>Let's say we have</p>
<pre><code>public interface ITimestampProvider
{
DateTime GetTimestamp();
}
</code></pre>
<p>and a class which consumes it</p>
<pre><code>public class Timestamped
{
private ITimestampProvider _timestampProvider
public Timestamped(ITimestampProvider timestampProvider)
{
... | [
{
"answer_id": 300301,
"author": "Kyle West",
"author_id": 34133,
"author_profile": "https://Stackoverflow.com/users/34133",
"pm_score": 2,
"selected": false,
"text": "<p>i wouldn't provide that constructor. Doing so makes it far too easy to call new TimeStamped and get an instance with ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37815/"
] | Let's say we have
```
public interface ITimestampProvider
{
DateTime GetTimestamp();
}
```
and a class which consumes it
```
public class Timestamped
{
private ITimestampProvider _timestampProvider
public Timestamped(ITimestampProvider timestampProvider)
{
// arg null check
_timest... | I think it depends on the scenario, and is basically a function of who the consumer the code is (library vs. application) and whether you're using an IoC container or not.
* If you're using an IoC container, and this is not part of a public API, then let the container do the heavy lifting, and just have the single con... |
300,303 | <p>I have an html like this:</p>
<pre><code><div id="container1">
<div class="dragme">drag me</div>
</div>
<div id="container2">
<div class="dragme">drag me</div>
</div>
<div id="droponme"></div>
$(".dragme").draggable();
$("#droponme").droppable({
... | [
{
"answer_id": 300364,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 3,
"selected": true,
"text": "<pre><code>$(\".dragme\").draggable();\n$(\"#droponme\").droppable({\n accept: \".dragme\",\n drop: function(e, u) {\n ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | I have an html like this:
```
<div id="container1">
<div class="dragme">drag me</div>
</div>
<div id="container2">
<div class="dragme">drag me</div>
</div>
<div id="droponme"></div>
$(".dragme").draggable();
$("#droponme").droppable({
accept: ".dragme",
drop: function(e, u) { alert( /* find id of the ... | ```
$(".dragme").draggable();
$("#droponme").droppable({
accept: ".dragme",
drop: function(e, u) {
alert(u.draggable.parent().attr('id') );
// in your example: container1 or container2
}
});
``` |
300,306 | <p>What I'm looking for looks like this in jQuery:</p>
<pre><code>jQuery.ajaxSetup({
'beforeSend': function(xhr) {
xhr.setRequestHeader("Accept", "text/javascript");
}
});
...
$("#my_form").submit({
$.post($(this).attr("action", $(this).serialize(), null, "script");
return false;
});
</code></pre>
<p>Then... | [
{
"answer_id": 300354,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure about dojo myself but I do know that phiggins (lead dojo dev) is available on the #dojo channel over on freeno... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | What I'm looking for looks like this in jQuery:
```
jQuery.ajaxSetup({
'beforeSend': function(xhr) {
xhr.setRequestHeader("Accept", "text/javascript");
}
});
...
$("#my_form").submit({
$.post($(this).attr("action", $(this).serialize(), null, "script");
return false;
});
```
Then, when my server returns s... | I believe the answer is:
```
form = dojo.byId("my_form")
form.onsubmit = function() {
dojo.xhrGet({
url: form.action,
form: form,
handleAs: "javascript",
headers: { "Accept": "text/javascript" }
})
}
``` |
300,316 | <p>Here's the deal. I have a hash map containing data I call "program codes", it lives in an object, like so:</p>
<pre><code>Class Metadata
{
private HashMap validProgramCodes;
public HashMap getValidProgramCodes() { return validProgramCodes; }
public void setValidProgramCodes(HashMap h) { validProgramCod... | [
{
"answer_id": 300330,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": -1,
"selected": false,
"text": "<p>I think it's risky. Threading results in all kinds of subtly issues that are a giant pain to debug. You might want to lo... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38716/"
] | Here's the deal. I have a hash map containing data I call "program codes", it lives in an object, like so:
```
Class Metadata
{
private HashMap validProgramCodes;
public HashMap getValidProgramCodes() { return validProgramCodes; }
public void setValidProgramCodes(HashMap h) { validProgramCodes = h; }
}
``... | Use Volatile
------------
Is this a case where one thread cares what another is doing? Then the [JMM FAQ](http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#reordering) has the answer:
>
> Most of the time, one thread doesn't
> care what the other is doing. But when
> it does, that's what synchronizatio... |
300,327 | <p>I'm jealous of the rails guys. They can do this:</p>
<pre><code><%= javascript_include_tag "all_min" %>
</code></pre>
<p>... and I'm stuck doing this:</p>
<pre><code><script src="/public/javascript/jquery/jquery.js" type="text/javascript"></script>
<script src="/public/javascript/jquery/jquer... | [
{
"answer_id": 300352,
"author": "Chris Fulstow",
"author_id": 38126,
"author_profile": "https://Stackoverflow.com/users/38126",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this using an HTTP handler. Check out this blog post from Mads Kristensen:</p>\n\n<p><a href=\"http:/... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34133/"
] | I'm jealous of the rails guys. They can do this:
```
<%= javascript_include_tag "all_min" %>
```
... and I'm stuck doing this:
```
<script src="/public/javascript/jquery/jquery.js" type="text/javascript"></script>
<script src="/public/javascript/jquery/jquery.tablesorter.js" type="text/javascript"></script>
<script... | You can use a [ScriptManager](http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.aspx)/[ScriptManagerProxy](http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanagerproxy.aspx) control and define the scripts in the [CompositeScript](http://msdn.microsoft.com/en-us/library/system.web.ui.script... |
300,328 | <p>I have a third-party library in my SVN repository and I'd like to associate source/javadoc with it locally in Eclipse. I.e., there should be some local setting (for example, an entry in the <code>local.properties</code> file) that associates the source/javadoc with the JAR file, but which doesn't introduce local dep... | [
{
"answer_id": 300346,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 5,
"selected": true,
"text": "<p>I believe this would be better achieved through:</p>\n\n<ul>\n<li>the creation of a linked folder combined with</li>\n<li>the... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | I have a third-party library in my SVN repository and I'd like to associate source/javadoc with it locally in Eclipse. I.e., there should be some local setting (for example, an entry in the `local.properties` file) that associates the source/javadoc with the JAR file, but which doesn't introduce local dependencies into... | I believe this would be better achieved through:
* the creation of a linked folder combined with
* the declaration of a linked resource
The linked resource defines a path variable which would be equals to `/my/path/to/lib/src`

The linked folder would ... |
300,334 | <p>I have a process that runs on a UNIX (Solaris) server that runs nightly and needs to be able to send out encrypted emails.</p>
<p>I only need the "encryption" portion, NOT the digital signature / self-repudiation part of PKI.</p>
<p>I use MS Outlook in a corporate setting and I am assuming that when a user clicks ... | [
{
"answer_id": 301872,
"author": "Guillaume",
"author_id": 23704,
"author_profile": "https://Stackoverflow.com/users/23704",
"pm_score": 2,
"selected": false,
"text": "<p>In the general case : to send an encrypted message to someone, you only need their public key. You dont need to have ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a process that runs on a UNIX (Solaris) server that runs nightly and needs to be able to send out encrypted emails.
I only need the "encryption" portion, NOT the digital signature / self-repudiation part of PKI.
I use MS Outlook in a corporate setting and I am assuming that when a user clicks "Publish to GAL..... | **You're logic is right.**
Typical PKI encryption is:
```
cryptoAlgorithm(plaintext, public key) = ciphertext
cryptoAlgorithm(ciphertext, private key) = plaintext
```
For some algorithms, the cryptoAlgorithm is the same procedure, sending and receiving.
So... for each recipient you need their digital certificate,... |
300,339 | <p>Can anyone tell me how to display all the selected value of my multi value parameter in SSRS report. When giving <code>parameter.value</code> option it gives error.</p>
| [
{
"answer_id": 300362,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 7,
"selected": false,
"text": "<p>You can use the \"Join\" function to create a single string out of the array of labels, like this:</p>\n\n<pre><code>... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can anyone tell me how to display all the selected value of my multi value parameter in SSRS report. When giving `parameter.value` option it gives error. | You can use the "Join" function to create a single string out of the array of labels, like this:
```
=Join(Parameters!Product.Label, ",")
``` |
300,344 | <p>I have a class which has a private member <code>$content</code>. This is wrapped by a get-method:</p>
<pre><code>class ContentHolder
{
private $content;
public function __construct()
{
$this->content = "";
}
public function getContent()
{
return $this->content;
}
}... | [
{
"answer_id": 300358,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 1,
"selected": false,
"text": "<p>In PHP, you don't say: \"<code>$foo = new array();</code>\"\nInstead, you simply say: \"<code>$foo = array();</code... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a class which has a private member `$content`. This is wrapped by a get-method:
```
class ContentHolder
{
private $content;
public function __construct()
{
$this->content = "";
}
public function getContent()
{
return $this->content;
}
}
$c = new ContentHolder();
$foo... | I just tried your code and `$foo['c']` is not a reference to `$content`. (Assigning a new value to `$foo['c']` does not affect `$content`.)
By default all PHP functions/methods pass arguments by value and return by value. To return by reference you would need to use this syntax for the method definition:
```
public f... |
300,360 | <p>I want to create buttons with icons in Flex dynamically using Actionscript.</p>
<p>I tried this, with no success:</p>
<pre><code>var closeButton = new Button();
closeButton.setStyle("icon", "@Embed(source='images/closeWindowUp.png");
</code></pre>
| [
{
"answer_id": 300431,
"author": "HanClinto",
"author_id": 26933,
"author_profile": "https://Stackoverflow.com/users/26933",
"pm_score": 0,
"selected": false,
"text": "<p>I'm assuming you're adding it to the stage?</p>\n\n<p>Also, I think your Embed is missing a close quote / paren.</p>\... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24734/"
] | I want to create buttons with icons in Flex dynamically using Actionscript.
I tried this, with no success:
```
var closeButton = new Button();
closeButton.setStyle("icon", "@Embed(source='images/closeWindowUp.png");
``` | I found an answer that works for me. In my .mxml file, I create Classes for the icons I will use:
```
// Classes for icons
[Embed(source='images/closeWindowUp.png')]
public static var CloseWindowUp:Class;
[Embed(source='/images/Down_Up.png')]
public static var Down_Up:Class;
[Embed(source='/images/Up_Up.png')]
public ... |
300,376 | <p>I'm trying to select the "name" field from the author node in an ATOM feed using LINQ. I can get all the fields I need like so:</p>
<pre><code>XDocument stories = XDocument.Parse(xmlContent);
XNamespace xmlns = "http://www.w3.org/2005/Atom";
var story = from entry in stories.Descendants(xmlns + "entry")
... | [
{
"answer_id": 300418,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>You basically want:</p>\n\n<pre><code>entry.Element(xmlns + \"author\").Element(xmlns + \"name\").Value\n</code></pre>... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2913/"
] | I'm trying to select the "name" field from the author node in an ATOM feed using LINQ. I can get all the fields I need like so:
```
XDocument stories = XDocument.Parse(xmlContent);
XNamespace xmlns = "http://www.w3.org/2005/Atom";
var story = from entry in stories.Descendants(xmlns + "entry")
select new St... | You basically want:
```
entry.Element(xmlns + "author").Element(xmlns + "name").Value
```
But you might want to wrap that in an extra method so you can easily take appropriate action if either the author or name elements are missing. You might also want to think about what you want to happen if there's more than one... |
300,383 | <p>I have some Jasper reports which are displayed in HTML format. I would like the width of the columns in the HTML tables to automatically resize to fit the content of the widest cell (in that column), such that all the data is displayed.</p>
<p>Currently this does not happen because the HTML generated by Jasper spec... | [
{
"answer_id": 306816,
"author": "Jamie Love",
"author_id": 27308,
"author_profile": "https://Stackoverflow.com/users/27308",
"pm_score": 3,
"selected": false,
"text": "<p>While not perfect, you could flag the field to stretch with overflow. This would at least give you all the data. In ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I have some Jasper reports which are displayed in HTML format. I would like the width of the columns in the HTML tables to automatically resize to fit the content of the widest cell (in that column), such that all the data is displayed.
Currently this does not happen because the HTML generated by Jasper specifies fixe... | While not perfect, you could flag the field to stretch with overflow. This would at least give you all the data. In your jrxml file it would be similar to:
```
<textField isStretchWithOverflow="true" hyperlinkType="None">
<reportElement style="Report Sub-Title" x="0" y="84" width="802" height="20"/>
<textEleme... |
300,389 | <p>i am programatically adding Webcontrols in to a User Control i am also adding a javascript event passing the controlID as a parameter but the clientID is the one i assigned a it does not contain the one that asp.net generates</p>
<pre><code> var txt = new TextBox();
txt.ID = "MyID"+Number;
chkBox.Attribute... | [
{
"answer_id": 300466,
"author": "baretta",
"author_id": 30052,
"author_profile": "https://Stackoverflow.com/users/30052",
"pm_score": 4,
"selected": true,
"text": "<p>You need to add the control to the control hierarchy before you add the attribute.</p>\n\n<pre><code> var txt = new Te... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14440/"
] | i am programatically adding Webcontrols in to a User Control i am also adding a javascript event passing the controlID as a parameter but the clientID is the one i assigned a it does not contain the one that asp.net generates
```
var txt = new TextBox();
txt.ID = "MyID"+Number;
chkBox.Attributes.Add("onClick... | You need to add the control to the control hierarchy before you add the attribute.
```
var txt = new TextBox();
txt.ID = "MyID"+Number;
Controls.Add ( txt );
chkBox.Attributes.Add("onClick", "EnableTxtBox('" +txt.ClientID + "');");
```
ControlCollection is no ordinary collection; it notifies the owner co... |
300,402 | <p>When I make the same query twice, the second time it does not return new rows form the database (I guess it just uses the cache).</p>
<p>This is a Windows Form application, where I create the dataContext when the application starts.</p>
<p>How can I force Linq to SQL not to use the cache?</p>
<p>Here is a sample ... | [
{
"answer_id": 300409,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>The simplest way would be to use a new DataContext - given that most of what the context gives you is caching and iden... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8547/"
] | When I make the same query twice, the second time it does not return new rows form the database (I guess it just uses the cache).
This is a Windows Form application, where I create the dataContext when the application starts.
How can I force Linq to SQL not to use the cache?
Here is a sample function where I have th... | The simplest way would be to use a new DataContext - given that most of what the context gives you is caching and identity management, it really sounds like you just want a new context. Why did you want to create just the one and then hold onto it?
By the way, for simple queries like yours it's more readable (IMO) to ... |
300,406 | <p>I'm storing some files in my database and since I'm storing them in binary format and not keeping any other information, I have to make sure that all of them are in the same format so that I'll be able to "serve" them later (If there's a <strong><em>simple</em></strong> way to infer the file type from a byte array, ... | [
{
"answer_id": 300506,
"author": "baretta",
"author_id": 30052,
"author_profile": "https://Stackoverflow.com/users/30052",
"pm_score": 3,
"selected": true,
"text": "<p>Use the FileUpload.PostedFile.ContentType property to validate the MIME type ( should be application/pdf ). For security... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2841/"
] | I'm storing some files in my database and since I'm storing them in binary format and not keeping any other information, I have to make sure that all of them are in the same format so that I'll be able to "serve" them later (If there's a ***simple*** way to infer the file type from a byte array, please tell, but that's... | Use the FileUpload.PostedFile.ContentType property to validate the MIME type ( should be application/pdf ). For security reasons, also validate that the file extension is appropriate ( .pdf ). You could have a static hashtable containing mappings from MIME type to file extension(s) and use as lookup to validate an exte... |
300,417 | <p>Say I have the following route:</p>
<pre><code>routes.MapRoute("Default", "{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" });
</code></pre>
<p>Lets also say that my controller has the following methods: <code>Index(Int32 id)</code> and <code>Edit(Int32 id)</code>.</p>
<p>So... | [
{
"answer_id": 300729,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 5,
"selected": true,
"text": "<p>You can do the following for now.</p>\n\n<pre><code>protected override void HandleUnknownAction(string actionName) {\n //yo... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32588/"
] | Say I have the following route:
```
routes.MapRoute("Default", "{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" });
```
Lets also say that my controller has the following methods: `Index(Int32 id)` and `Edit(Int32 id)`.
So `/MyController/Index/1` is a valid URL for that route.... | You can do the following for now.
```
protected override void HandleUnknownAction(string actionName) {
//your code here.
}
```
Another approach is that you put a constraint on the default route so it only matches methods you *know* exist on the controller. Then you could have another route like so:
```
routes.Map... |
300,424 | <p>I have HTML code edited by FCKEditor stored in a database and would like to display (well render) it onto a view. So, for instance, something stored as:</p>
<pre><code>&lt;&gt;pre&lt;&gt;This is some sample text&lt;&gt;pre&lt;/&gt
</code></pre>
<p>Will be displayed to the user as:</p>... | [
{
"answer_id": 300464,
"author": "Pure.Krome",
"author_id": 30674,
"author_profile": "https://Stackoverflow.com/users/30674",
"pm_score": 7,
"selected": true,
"text": "<p>Try this:</p>\n<pre><code><%= System.Web.HttpUtility.HtmlDecode(yourEncodedHtmlFromYouDatabase) %>\n</code></pr... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9913/"
] | I have HTML code edited by FCKEditor stored in a database and would like to display (well render) it onto a view. So, for instance, something stored as:
```
<>pre<>This is some sample text<>pre</>
```
Will be displayed to the user as:
```
This is some sample text
```
(With the appropriate s... | Try this:
```
<%= System.Web.HttpUtility.HtmlDecode(yourEncodedHtmlFromYouDatabase) %>
```
More info [here](http://msdn.microsoft.com/en-us/library/system.web.httputility.htmldecode.aspx). |
300,427 | <p>Is it possible to create a parameterized SQL statement that will taken an arbitrary number of parameters? I'm trying to allow users to filter a list based on multiple keywords, each separated by a semicolon. So the input would be something like "Oakland;City;Planning" and the WHERE clause would come out something ... | [
{
"answer_id": 300443,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 0,
"selected": false,
"text": "<p>using a tool like NHibernate will allow you to dynamically construct your queries safely without the need for stored procedu... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21979/"
] | Is it possible to create a parameterized SQL statement that will taken an arbitrary number of parameters? I'm trying to allow users to filter a list based on multiple keywords, each separated by a semicolon. So the input would be something like "Oakland;City;Planning" and the WHERE clause would come out something equiv... | A basic proof-of-concept... Actual code would be less, but since I don't know your table/field names, this is the full code, so anyone can verify it works, tweak it, etc.
```
--Search Parameters
DECLARE @SearchString VARCHAR(MAX)
SET @SearchString='Oakland;City;Planning' --Using your example search
DECLARE @Delim CHA... |
300,445 | <p>I have a unicode string like "Tanım" which is encoded as "Tan%u0131m" somehow. How can i convert this encoded string back to original unicode.
Apparently urllib.unquote does not support unicode.</p>
| [
{
"answer_id": 300531,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 4,
"selected": false,
"text": "<pre><code>def unquote(text):\n def unicode_unquoter(match):\n return unichr(int(match.group(1),16))\n ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12785/"
] | I have a unicode string like "Tanım" which is encoded as "Tan%u0131m" somehow. How can i convert this encoded string back to original unicode.
Apparently urllib.unquote does not support unicode. | %uXXXX is a [non-standard encoding scheme](http://en.wikipedia.org/wiki/Percent-encoding#Non-standard_implementations) that has been rejected by the w3c, despite the fact that an implementation continues to live on in JavaScript land.
The more common technique seems to be to UTF-8 encode the string and then % escape t... |
300,448 | <p>On the user pages of Stack Overflow where the tabs are (Stats, Recent, Responses, etc.) you get the illusion that the tabs are extensions of the line they're sitting on. Stack Overflow creates this effect by defining pure CSS borders. I want to achieve the same effect but I have images both for the tabs and for the ... | [
{
"answer_id": 300473,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "<p>May be the <a href=\"http://www.alistapart.com/articles/slidingdoors2/\" rel=\"nofollow noreferrer\">sliding doors technique... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/356/"
] | On the user pages of Stack Overflow where the tabs are (Stats, Recent, Responses, etc.) you get the illusion that the tabs are extensions of the line they're sitting on. Stack Overflow creates this effect by defining pure CSS borders. I want to achieve the same effect but I have images both for the tabs and for the lin... | I have previously done something similar by giving the "active" tab class a negative bottom position, thus moving it so it sits on top of the frame border. Could perhaps be the solution? For example:
```
<style>
ul.tabs {
border-bottom: 1px solid blue;
height: 20px;
margin: 0;
padding: 0;
list-style-type: none;
}
... |
300,472 | <p>Looking in the gnuwin32/bin directory, there is an odd-looking program file named <code>[.exe</code></p>
<p>I couldn't find it in the documentation, gnuwin32.sourceforge.net or in a google search, so I ran it and got:</p>
<pre><code>$ [
[: missing `]'
$
</code></pre>
<p>so I gave it ] as a parameter and got</p>
... | [
{
"answer_id": 300477,
"author": "tusho",
"author_id": 22331,
"author_profile": "https://Stackoverflow.com/users/22331",
"pm_score": 3,
"selected": false,
"text": "<pre><code>test a\n</code></pre>\n\n<p>==</p>\n\n<pre><code>[ a ]\n</code></pre>\n\n<p>It's just sugar</p>\n\n<p>Edit: To cl... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] | Looking in the gnuwin32/bin directory, there is an odd-looking program file named `[.exe`
I couldn't find it in the documentation, gnuwin32.sourceforge.net or in a google search, so I ran it and got:
```
$ [
[: missing `]'
$
```
so I gave it ] as a parameter and got
```
$ [ ]
$
```
It didn't complain, so I assu... | It's used to evaluate *conditional* expressions.
It is equivalent to (possibly a symlink to?) the `test` executable.
The manpage is [here](http://www.ss64.com/bash/test.html).
You may see this in a lot of bash scripts:
```
if [ "$LOGNAME" = "scott" ]
then
echo "Logged in as Scott"
else
echo "incorrect... |
300,491 | <p>I'm trying to implement paging using row-based limiting (for example: <code>setFirstResult(5)</code> and <code>setMaxResults(10)</code>) on a Hibernate Criteria query that has joins to other tables.</p>
<p>Understandably, data is getting cut off randomly; and the reason for that is explained <a href="https://develo... | [
{
"answer_id": 300708,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 8,
"selected": true,
"text": "<p>You can achieve the desired result by requesting a list of distinct ids instead of a list of distinct hydrated objects.</p>\... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34553/"
] | I'm trying to implement paging using row-based limiting (for example: `setFirstResult(5)` and `setMaxResults(10)`) on a Hibernate Criteria query that has joins to other tables.
Understandably, data is getting cut off randomly; and the reason for that is explained [here](https://developer.jboss.org/wiki/HibernateFAQ-Ad... | You can achieve the desired result by requesting a list of distinct ids instead of a list of distinct hydrated objects.
Simply add this to your criteria:
```
criteria.setProjection(Projections.distinct(Projections.property("id")));
```
Now you'll get the correct number of results according to your row-based limitin... |
300,498 | <p>I have a FooController that responds to HTML and JS (AJAX) queries:</p>
<pre><code># app/controllers/foo_controller.rb:
class FooController < ApplicationController
layout 'foo'
def bar
respond_to do |format|
format.html # foo/bar.html.erb
format.js # foo/bar.js.erb
end
end
end
</code>... | [
{
"answer_id": 301899,
"author": "mwilliams",
"author_id": 23909,
"author_profile": "https://Stackoverflow.com/users/23909",
"pm_score": 3,
"selected": false,
"text": "<p>The most recent <a href=\"http://railscasts.com/episodes/136-jquery\" rel=\"noreferrer\">Railscast covers this topic ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I have a FooController that responds to HTML and JS (AJAX) queries:
```
# app/controllers/foo_controller.rb:
class FooController < ApplicationController
layout 'foo'
def bar
respond_to do |format|
format.html # foo/bar.html.erb
format.js # foo/bar.js.erb
end
end
end
```
The templates to s... | The most recent [Railscast covers this topic (using jQuery)](http://railscasts.com/episodes/136-jquery).
I'm not quite seeing where you might be going wrong, but here's a snippit from the Railscast that works just fine to render a partial:
```
// views/reviews/create.js.erb
$("#new_review").before('<div id="flash_not... |
300,499 | <p>When we talk about the .NET world the CLR is what everything we do depends on.
What is the minimum knowledge of CLR a .NET programmer must have to be a good programmer?
Can you give me one/many you think is/are the most important subjects:
GC?, AppDomain?, Threads?, Processes?, Assemblies/Fusion? </p>
<p>I will ver... | [
{
"answer_id": 300510,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 2,
"selected": false,
"text": "<p>Updated: reading the relevant parts of the book CLR via C# by Jeffrey Richter..this book can be a good reference..</... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2921654/"
] | When we talk about the .NET world the CLR is what everything we do depends on.
What is the minimum knowledge of CLR a .NET programmer must have to be a good programmer?
Can you give me one/many you think is/are the most important subjects:
GC?, AppDomain?, Threads?, Processes?, Assemblies/Fusion?
I will very much app... | Most of those are way deeper than the kind of thing many developers fall down on in my experience. Most misunderstood (and important) aspects in my experience:
* Value types vs reference types
* Variables vs objects
* Pass by ref vs pass by value
* Delegates and events
* Distinguishing between language, runtime and fr... |
300,509 | <p>From a Java program, I need to launch the default browser on a local HTML file, pointed to an anchor inside the file. In Java SE 6, the java.awt.Desktop.browse method will open the file, but will not honor the anchor, so something like the following opens the file at the top, but does not page the browser to the an... | [
{
"answer_id": 323170,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 0,
"selected": false,
"text": "<p>For Windows only, you could try</p>\n\n<pre><code>System.exec(\"cmd.exe start file:///C:/foo/bar.html#anchor\")\n</c... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15988/"
] | From a Java program, I need to launch the default browser on a local HTML file, pointed to an anchor inside the file. In Java SE 6, the java.awt.Desktop.browse method will open the file, but will not honor the anchor, so something like the following opens the file at the top, but does not page the browser to the anchor... | I just solved this another way, because no amount of quoting or spaces in any of these examples worked for me.
1 Detect if the file URI has a anchor or query string
2 If so, create a temp file `File tmpfile = File.createTempFile("apphelp", ".html")` with a meta-redirect to the actual file URI I desire:
```
<html><h... |
300,515 | <p>I need a technique for dealing with what seems pretty simple!</p>
<p>I have a form, with some logic on the server side for validation.
if the server side code indicates that there is an issue, I want to display a modal popup to the client.</p>
<p>I am having trouble getting it to work in this way.</p>
<p>I found ... | [
{
"answer_id": 300571,
"author": "flesh",
"author_id": 27805,
"author_profile": "https://Stackoverflow.com/users/27805",
"pm_score": 0,
"selected": false,
"text": "<p>You need to use an AJAX callback to perform your server side validation and return a response to the client - then decide... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33186/"
] | I need a technique for dealing with what seems pretty simple!
I have a form, with some logic on the server side for validation.
if the server side code indicates that there is an issue, I want to display a modal popup to the client.
I am having trouble getting it to work in this way.
I found if I keep all the logic ... | I know that you do it using the ScriptManager control. Basically you just send from the server a line of JavaScript to execute immediately. In this case, the client side line you describe.
Sorry to be vague, but it's almost quitting time and I'll have to grep through a lot of code to find an example.
[Here is an exam... |
300,521 | <p>I am looking for a LaTeX package that does syntax highlighting on code. For example, right now I use the verbatim block to write code:</p>
<pre><code>\begin{verbatim}
<html>
<head>
<title>Hello</title>
</head>
<body>Hello</body>
</... | [
{
"answer_id": 300546,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://www.ctan.org/pkg/lgrind\" rel=\"noreferrer\">LGrind</a> does this. It's a mature La... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27439/"
] | I am looking for a LaTeX package that does syntax highlighting on code. For example, right now I use the verbatim block to write code:
```
\begin{verbatim}
<html>
<head>
<title>Hello</title>
</head>
<body>Hello</body>
</html>
\end{verbatim}
```
And this works fine to display t... | You can use the [listings](http://www.ctan.org/tex-archive/macros/latex/contrib/listings/) package. It supports many different languages and there are lots of options for customising the output.
```
\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[language=html]
<html>
<head>
... |
300,522 | <p>From using a number of programming languages and libraries I have noticed various terms used for the total number of elements in a collection.</p>
<p>The most common seem to be <code>length</code>, <code>count</code>, and <code>size</code>.</p>
<p>eg.</p>
<pre><code>array.length
vector.size()
collection.count
</c... | [
{
"answer_id": 300530,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 0,
"selected": false,
"text": "<p>To me, this is a little like asking whether \"foreach\" is better than \"for each\". It just depends on the language/fram... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11293/"
] | From using a number of programming languages and libraries I have noticed various terms used for the total number of elements in a collection.
The most common seem to be `length`, `count`, and `size`.
eg.
```
array.length
vector.size()
collection.count
```
Is there any preferred term to be used?
Does it depend on ... | `Length()` tends to refer to contiguous elements - a string has a length for example.
`Count()` tends to refer to the number of elements in a looser collection.
`Size()` tends to refer to the size of the collection, often this can be different from the length in cases like vectors (or strings), there may be 10 char... |
300,551 | <pre><code> (define a 42)
(set! 'a 10)
(define a 42)
(define (symbol) 'a)
(set! (symbol) 10)
(define a (cons 1 2))
(set! (car a) 10)
</code></pre>
<p>I tried running them in DrScheme and they don't work. Why?</p>
| [
{
"answer_id": 300561,
"author": "sanxiyn",
"author_id": 18382,
"author_profile": "https://Stackoverflow.com/users/18382",
"pm_score": 2,
"selected": false,
"text": "<p>Because the first argument of set! is a variable name, not an \"lvalue\", so to speak.</p>\n\n<p>For the last case, use... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
(define a 42)
(set! 'a 10)
(define a 42)
(define (symbol) 'a)
(set! (symbol) 10)
(define a (cons 1 2))
(set! (car a) 10)
```
I tried running them in DrScheme and they don't work. Why? | Think of set! is a special form like define which does not evaluate its first operand. You are telling the scheme interpreter to set that variable exactly how you write it. In your example, it will not evaluate the expression 'a to the word a. Instead, it will look for a variable binding named "'a" (or depending on you... |
300,559 | <p>Is there a standard Java library that handles common file operations such as moving/copying files/folders?</p>
| [
{
"answer_id": 300562,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 5,
"selected": false,
"text": "<p>Not yet, but the <a href=\"http://jcp.org/en/jsr/detail?id=203\" rel=\"noreferrer\">New NIO (JSR 203)</a> will have supp... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19026/"
] | Is there a standard Java library that handles common file operations such as moving/copying files/folders? | Here's how to do this with `java.nio` operations:
```
public static void copyFile(File sourceFile, File destFile) throws IOException {
if(!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(... |
300,578 | <p>How do get the startup path ( system.windows.forms.application.StartupPath ) of my exe without adding a reference to system.windows.forms?</p>
| [
{
"answer_id": 300591,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 2,
"selected": false,
"text": "<p>EDIT: @KiwiBastard's answer is the correct method:</p>\n\n<pre><code>System.AppDomain.CurrentDomain.BaseDirectory\n... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] | How do get the startup path ( system.windows.forms.application.StartupPath ) of my exe without adding a reference to system.windows.forms? | You could try
```
System.AppDomain.CurrentDomain.BaseDirectory
```
which would work for most cases. |
300,581 | <p>I have an application with my object types that inherit from a base class that contains the majority of properties for the application objects. All the object types are stored in one table in the database. The "ClassType" column determines what object type I cast the SqlDataReader row to. </p>
<p>Here is my curr... | [
{
"answer_id": 300589,
"author": "Jim Burger",
"author_id": 20164,
"author_profile": "https://Stackoverflow.com/users/20164",
"pm_score": 3,
"selected": false,
"text": "<p>I guess I would lean towards an Object-Relational Mapper for this. <a href=\"http://www.hibernate.org/343.html\" rel... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] | I have an application with my object types that inherit from a base class that contains the majority of properties for the application objects. All the object types are stored in one table in the database. The "ClassType" column determines what object type I cast the SqlDataReader row to.
Here is my current implement... | I guess I would lean towards an Object-Relational Mapper for this. [NHibernate](http://www.hibernate.org/343.html) is an example of an existing, free, mature ORM solution for the .NET platform. |
300,582 | <p>Has anyone been able to use the SSCrypto Framework for Cocoa to encrypt text and then decrypt it in C#/.NET ? Or can someone offer some guidance?</p>
<p>I'm pretty sure my issue has to do with getting the crypto settings correct but I am far from fluent in Cocoa so I can't really tell what settings are being used i... | [
{
"answer_id": 300781,
"author": "tomasr",
"author_id": 10292,
"author_profile": "https://Stackoverflow.com/users/10292",
"pm_score": 1,
"selected": false,
"text": "<p>A couple of things to watch out for:</p>\n\n<p>1- Make sure that you're interpreting the key and data strings correctly.... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Has anyone been able to use the SSCrypto Framework for Cocoa to encrypt text and then decrypt it in C#/.NET ? Or can someone offer some guidance?
I'm pretty sure my issue has to do with getting the crypto settings correct but I am far from fluent in Cocoa so I can't really tell what settings are being used in the libr... | You could use OpenSSL directly in C# with the [OpenSSL.NET](http://openssl-net.sourceforge.net) wrapper! |
300,592 | <p>At one point I had looked at implementing a class/template in C++ that would support an Enum that would behave like it does in Ada. It has been some time since I thought about this problem and I was wondering if anyone has ever solved this problem?</p>
<p>EDIT:</p>
<p>My apologies, I should clarify what functional... | [
{
"answer_id": 300730,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 1,
"selected": false,
"text": "<p>There isn't an easy way to do that in C++, not least because the enumeration constants are not required to be ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1265473/"
] | At one point I had looked at implementing a class/template in C++ that would support an Enum that would behave like it does in Ada. It has been some time since I thought about this problem and I was wondering if anyone has ever solved this problem?
EDIT:
My apologies, I should clarify what functionality I thought wer... | One of my colleagues has implemented a tool to generate classes that do most (if not all) of what you want:
<http://code.google.com/p/enumgen/>
The current implementation is in Lisp, but do not hold that against him :-) |
300,595 | <p>What would be a clever way to make a 'please wait' control for a Flex application for long running operations like calling a webservice.</p>
<p>I am not asking about the graphical portion of it - just the 'controller' part. How should I trigger it and hide it. I am planning to make just a simple canvas with text in... | [
{
"answer_id": 302118,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 2,
"selected": true,
"text": "<p>One way I have done it in the past is to have a global integer and increment / decrement the value based on the web servic... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | What would be a clever way to make a 'please wait' control for a Flex application for long running operations like calling a webservice.
I am not asking about the graphical portion of it - just the 'controller' part. How should I trigger it and hide it. I am planning to make just a simple canvas with text in.
For ins... | One way I have done it in the past is to have a global integer and increment / decrement the value based on the web services running. When the counter was 0, I would hide the loading text, when it was greater than 0, I would display the loading text. Here is a simplified version of it:
```
<mx:Application>
<mx:Sc... |
300,606 | <p>I need to convert strings with optional trailing signs into actual numbers using Powershell.</p>
<p>Possible strings are:</p>
<ul>
<li>1000-</li>
<li>323+</li>
<li>456</li>
</ul>
<p>I'm trying to use System.Int.TryParse with a NumberStyles of AllowTrailingSign, but I can't work out how to make System.Globalizatio... | [
{
"answer_id": 300636,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>If you are sure that the signs could be - or +, String.Replace could help.</p>\n\n<p>If you mean that 323- should r... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11571/"
] | I need to convert strings with optional trailing signs into actual numbers using Powershell.
Possible strings are:
* 1000-
* 323+
* 456
I'm trying to use System.Int.TryParse with a NumberStyles of AllowTrailingSign, but I can't work out how to make System.Globalization.NumberStyles available to Powershell. | EDIT: as per Halr9000's suggestion
```
$foo = "300-";
$bar = 0;
$numberStyles = [System.Globalization.NumberStyles];
$cultureInfo = [System.Globalization.CultureInfo];
[int]::TryParse($foo, $numberStyles::AllowTrailingSign, $cultureInfo::CurrentCulture, [ref]$bar);
``` |
300,607 | <p>In Windows Mobile, when you open Internet Explorer and type in a URL that your device can't connect to, you are notified of this and prompted to (manually) navigate to the screen where you can actually do something about this as a user (Network Management), like so:</p>
<p><a href="http://www.freeimagehosting.net/u... | [
{
"answer_id": 301047,
"author": "Shane Powell",
"author_id": 23235,
"author_profile": "https://Stackoverflow.com/users/23235",
"pm_score": 2,
"selected": false,
"text": "<p>You need to use the <a href=\"http://msdn.microsoft.com/en-us/library/ms879581.aspx\" rel=\"nofollow noreferrer\">... | 2008/11/18 | [
"https://Stackoverflow.com/questions/300607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14606/"
] | In Windows Mobile, when you open Internet Explorer and type in a URL that your device can't connect to, you are notified of this and prompted to (manually) navigate to the screen where you can actually do something about this as a user (Network Management), like so:
[alt text http://www.freeimagehosting.net/uploads/d3... | In answer to your question 2, this code will show the connections control panel:
```
Process.Start(@"\windows\ctlpnl.exe", "cplmain.cpl,19");
```
A lot of the built in settings applets are shown through ctlpnl.exe. I got the magic number from the list [here](http://knowledgepointer.wordpress.com/2009/02/07/how-to-sh... |
300,618 | <p>My application is a viewer for a custom format, a zip file with a well defined XML manifest and resources, such as images and movies. I use zlib to open up the zip file in memory and then proceed to display said resources. </p>
<p>One problem I've ran into is that I'm unable to properly display videos, apparently b... | [
{
"answer_id": 303709,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 4,
"selected": true,
"text": "<p>The problem your having is that m4v and m4p dont have a mime types registered with Launch Services (probably because ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38753/"
] | My application is a viewer for a custom format, a zip file with a well defined XML manifest and resources, such as images and movies. I use zlib to open up the zip file in memory and then proceed to display said resources.
One problem I've ran into is that I'm unable to properly display videos, apparently because QTM... | The problem your having is that m4v and m4p dont have a mime types registered with Launch Services (probably because the mime type for m4v and m4p is not standard). In any event, what you should probably do is handle edge cases like this and then check for nil when the function returns (in case the extension is both no... |
300,629 | <p>I'm writing a direct3d application and after noticing strange bugs such as anti-aliasing occurring even when it was turned off and the mouse pointer not lining up to things with the same coordinates as itself I discovered that when creating a window the width and height parameters include the border. The program wa... | [
{
"answer_id": 300638,
"author": "DocMax",
"author_id": 6234,
"author_profile": "https://Stackoverflow.com/users/6234",
"pm_score": 3,
"selected": true,
"text": "<p>It sounds like you are looking for the GetSystemMetrics function. For example, the border width in pixels is returned by</... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2222/"
] | I'm writing a direct3d application and after noticing strange bugs such as anti-aliasing occurring even when it was turned off and the mouse pointer not lining up to things with the same coordinates as itself I discovered that when creating a window the width and height parameters include the border. The program was re... | It sounds like you are looking for the GetSystemMetrics function. For example, the border width in pixels is returned by
```
GetSystemMetrics(SM_CXBORDER)
```
**ADDED:** For the total size you will need to add together the various "pieces" of the non-client area: border, frame sizes, title bars, etc. |
300,656 | <p>I'm using a WPF RichTextBox control to input some text with user formatting capability, including font size adjustment. The built-in commands for IncreaseFontSize and DecreaseFontSize will adjust the font size by 0.75pt each time the command is executed. I would like to increase the granularity to 2pt.</p>
<p>Can... | [
{
"answer_id": 321798,
"author": "ligaz",
"author_id": 6409,
"author_profile": "https://Stackoverflow.com/users/6409",
"pm_score": 1,
"selected": false,
"text": "<p>Unfortunately the value is hard-coded and you cannot change it. The fastest way to implement this is to use the TextRange c... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25879/"
] | I'm using a WPF RichTextBox control to input some text with user formatting capability, including font size adjustment. The built-in commands for IncreaseFontSize and DecreaseFontSize will adjust the font size by 0.75pt each time the command is executed. I would like to increase the granularity to 2pt.
Can this be don... | Unfortunately the value is hard-coded and you cannot change it. The fastest way to implement this is to use the TextRange class. Something like this:
```
var range = new TextRange( rtb.Document.ContentStart, rtb.Document.ContentEnd );
range.ApplyPropertyValue( TextElement.FontSizeProperty, 30.0 );
``` |
300,658 | <p>How would you use set! in a simple procedure f such that evaluating (+ (f 0) (f 1)) will return 0 if the arguments to + are evaluated from left to right but will return 1 if the arguments are evaluated from right to left?</p>
| [
{
"answer_id": 300678,
"author": "Andrew Beyer",
"author_id": 38691,
"author_profile": "https://Stackoverflow.com/users/38691",
"pm_score": 3,
"selected": false,
"text": "<p>Easiest approach is probably to store some external state and have the implementation of f affect it's contents.</... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How would you use set! in a simple procedure f such that evaluating (+ (f 0) (f 1)) will return 0 if the arguments to + are evaluated from left to right but will return 1 if the arguments are evaluated from right to left? | Easiest approach is probably to store some external state and have the implementation of f affect it's contents.
```
(define x 0)
(define (f n) (let ((tmp x)) (set! x n) tmp))
```
Thus, x is initially 0 and each call to f will return the current value of x and save the argument as the new value of x. Thus (f 0) foll... |
300,660 | <p>I know I can loop over the string or build a regex or invert the set (ASCII isn't that big after all) and search for the first instance of that, but Yuck.</p>
<p>What I'm looking for is a nice one liner.</p>
<p>fewer features is better, LINQ is out (for me, don't ask, it's a <em>long</em> story)</p>
<hr>
<p>The ... | [
{
"answer_id": 300666,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Not all that efficient, but:</p>\n\n<pre><code>char f(string str, IEnumerable<char> list)\n{\n return str.ToCharArra... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | I know I can loop over the string or build a regex or invert the set (ASCII isn't that big after all) and search for the first instance of that, but Yuck.
What I'm looking for is a nice one liner.
fewer features is better, LINQ is out (for me, don't ask, it's a *long* story)
---
The solution I'm going with (unless ... | This works:
```
public static char FindFirstNotAny(this string value, params char[] charset)
{
return value.TrimStart(charset)[0];
}
``` |
300,662 | <p>I want to insert something into a STL list in C++, but I only have a reverse iterator. What is the usual way to accomplish this?</p>
<p>This works: (of course it does)</p>
<pre><code>std::list<int> l;
std::list<int>::iterator forward = l.begin();
l.insert(forward, 5);
</code></pre>
<p>This doesn't wor... | [
{
"answer_id": 300693,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 6,
"selected": true,
"text": "<p><code>l.insert(reverse.base(), 10);</code> will insert '10' at the end, given your definition of the 'rev... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25164/"
] | I want to insert something into a STL list in C++, but I only have a reverse iterator. What is the usual way to accomplish this?
This works: (of course it does)
```
std::list<int> l;
std::list<int>::iterator forward = l.begin();
l.insert(forward, 5);
```
This doesn't work: (what should I do instead?)
```
std::list... | `l.insert(reverse.base(), 10);` will insert '10' at the end, given your definition of the 'reverse' iterator. Actually, `l.rbegin().base() == l.end()`. |
300,669 | <p>How do I launch an app and capture the output via stdout and maybe stderr?</p>
<p>I am writing an automated build system and I need to capture the output to analyze. I'd like to update the svn repo and grab the revision number so I can move the files in autobuild/revNumber/ if successful. I also would like to build... | [
{
"answer_id": 300680,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 5,
"selected": true,
"text": "<p>In real shells (meaning, not sea shells - I mean, not in C Shell or its derivatives), then:</p>\n\n<pre><code>p... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I launch an app and capture the output via stdout and maybe stderr?
I am writing an automated build system and I need to capture the output to analyze. I'd like to update the svn repo and grab the revision number so I can move the files in autobuild/revNumber/ if successful. I also would like to build using mak... | In real shells (meaning, not sea shells - I mean, not in C Shell or its derivatives), then:
```
program arg1 arg2 >/tmp/log.file 2>&1
```
This runs program with the given arguments, and redirects the stdout to /tmp/log.file; the notation (~~hieroglyph~~) '`2>&1`' at the end sends stderr (file descriptor 2) to the sa... |
300,673 | <p>I was told this a few times in this very site, but I wanted to make sure this is really the case.</p>
<p>I was expecting to be able to sprinkle NSLog function calls throughout my code, and that Xcode/gcc would automatically strip those calls out when building my Release/Distribution builds.</p>
<p>Should I avoid u... | [
{
"answer_id": 300694,
"author": "Matthew Schinckel",
"author_id": 188,
"author_profile": "https://Stackoverflow.com/users/188",
"pm_score": 5,
"selected": false,
"text": "<p>NSLog calls can be left in production code, but should only be there for truly exceptional cases, or information ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35478/"
] | I was told this a few times in this very site, but I wanted to make sure this is really the case.
I was expecting to be able to sprinkle NSLog function calls throughout my code, and that Xcode/gcc would automatically strip those calls out when building my Release/Distribution builds.
Should I avoid using this? If so,... | Preprocessor macros are indeed great for debugging. There's nothing wrong with NSLog(), but it's simple to define your own logging function with better functionality. Here's the one I use, it includes the file name and line number to make it easier to track down log statements.
```
#define DEBUG_MODE
#ifdef DEBUG_MOD... |
300,674 | <p>I'm trying to trouble shoot a web service client in my current project. I'm not sure of the platform of the Service Server (Most likely LAMP). I believe there is a fault on their side of the fence as i have eliminated the potential issues with my client. The client is a standard ASMX type web reference proxy auto... | [
{
"answer_id": 300776,
"author": "rbrayb",
"author_id": 9922,
"author_profile": "https://Stackoverflow.com/users/9922",
"pm_score": 0,
"selected": false,
"text": "<p>You haven't specified what language you are using but assuming C# / .NET you could use <a href=\"http://msdn.microsoft.com... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30576/"
] | I'm trying to trouble shoot a web service client in my current project. I'm not sure of the platform of the Service Server (Most likely LAMP). I believe there is a fault on their side of the fence as i have eliminated the potential issues with my client. The client is a standard ASMX type web reference proxy auto gener... | I made following changes in `web.config` to get the SOAP (Request/Response) Envelope. This will output all of the raw SOAP information to the file `trace.log`.
```
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="System.Net" maxdatasize="1024">
<listeners>
<add name="TraceFi... |
300,685 | <p>I would like to generate documentation for a RESTful web service API that is written in Python. Ideally it would look like Yahoo's RESTful web service docs. Does anyone have any ideas or references?</p>
| [
{
"answer_id": 635504,
"author": "Mark",
"author_id": 76343,
"author_profile": "https://Stackoverflow.com/users/76343",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately I don't know anything specific that will help you in Python specifically -- However just as points of refere... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14311/"
] | I would like to generate documentation for a RESTful web service API that is written in Python. Ideally it would look like Yahoo's RESTful web service docs. Does anyone have any ideas or references? | The Sphinx project ([www.sphinx-doc.org](https://www.sphinx-doc.org)) is the current state-of-the-art in Python documentation. It's really powerful and flexible... so also somewhat confusing. Still, I think it is your best bet.
There is excellent documentation on their site on how to set up the document source files a... |
300,692 | <p>I'd like to know how to convert Perforce depot locations to client view locations for the purpose of script writing.</p>
<p>I have a script that first checks out a file for edit in perforce and then interacts with the file. I need to have the depot location (i.e. \Projects\Project6) converted to the client view l... | [
{
"answer_id": 300701,
"author": "Graeme Perrow",
"author_id": 1821,
"author_profile": "https://Stackoverflow.com/users/1821",
"pm_score": 2,
"selected": false,
"text": "<p>Check out the <code>p4 have</code> command. You give it <em>either</em> a depot location <em>or</em> a client filen... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38774/"
] | I'd like to know how to convert Perforce depot locations to client view locations for the purpose of script writing.
I have a script that first checks out a file for edit in perforce and then interacts with the file. I need to have the depot location (i.e. \Projects\Project6) converted to the client view location. (i.... | I have always used the **p4 where** command for this. Here is its description from the built-in help:
>
>
> ```
> where -- Show how file names map through the client view
>
> p4 where [ file ... ]
>
> Where shows how the named files map through the client view.
> For each argument, three names are produced... |
300,705 | <p>I have the following code:</p>
<pre><code>for attribute in site.device_attributes
device.attribute
end
</code></pre>
<p>where I would like the code to substitute the value of "attribute" for the method name.</p>
<p>I have tried <code>device."#{attribute}"</code> and various permutations.</p>
<p>Is this complet... | [
{
"answer_id": 300723,
"author": "Matt Campbell",
"author_id": 27043,
"author_profile": "https://Stackoverflow.com/users/27043",
"pm_score": 4,
"selected": false,
"text": "<p>The \"send\" method should do what you're looking for:</p>\n\n<pre><code>object = \"upcase me!\"\nmethod = \"upca... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/757/"
] | I have the following code:
```
for attribute in site.device_attributes
device.attribute
end
```
where I would like the code to substitute the value of "attribute" for the method name.
I have tried `device."#{attribute}"` and various permutations.
Is this completely impossible? Am I missing something?
I have con... | You can use #send method to call object's method by method's name:
```
object.send(:foo) # same as object.foo
```
You can pass arguments with to invoked method:
```
object.send(:foo, 1, "bar", 1.23) # same as object.foo(1, "bar", 1.23)
```
So, if you have attribute name in variable "attribute" you can read object... |
300,746 | <p>I've been attempting to write embedded SQL statements for DB2 that ultimately gets compiled in C. </p>
<p>I couldn't find a tutorial or manual on the embedded SQL syntax for C for reference. One case I would like to do is to insert data into a table. I know most embedded sql statements need the initalizer <code>EXE... | [
{
"answer_id": 300751,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": false,
"text": "<p>See IBM's <a href=\"http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.embed.doc/d... | 2008/11/19 | [
"https://Stackoverflow.com/questions/300746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38781/"
] | I've been attempting to write embedded SQL statements for DB2 that ultimately gets compiled in C.
I couldn't find a tutorial or manual on the embedded SQL syntax for C for reference. One case I would like to do is to insert data into a table. I know most embedded sql statements need the initalizer `EXEC SQL`, but tha... | See IBM's [Embedded SQL](http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.embed.doc/doc/t0007158.htm) manual.
Embedded SQL is largely the same no matter what the host language is. |