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 |
|---|---|---|---|---|---|---|
338,285 | <p>I'm trying to prevent <code>bash</code> from saving duplicate commands to my history. Here's what I've got:</p>
<pre><code>shopt -s histappend
export HISTIGNORE='&:ls:cd ~:cd ..:[bf]g:exit:h:history'
export HISTCONTROL=erasedups
export PROMPT_COMMAND='history -a'
</code></pre>
<p>This works fine while I'm logg... | [
{
"answer_id": 338399,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 3,
"selected": false,
"text": "<pre><code>export HISTCONTROL=ignoreboth\n</code></pre>\n"
},
{
"answer_id": 338593,
"author": "Communit... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1019/"
] | I'm trying to prevent `bash` from saving duplicate commands to my history. Here's what I've got:
```
shopt -s histappend
export HISTIGNORE='&:ls:cd ~:cd ..:[bf]g:exit:h:history'
export HISTCONTROL=erasedups
export PROMPT_COMMAND='history -a'
```
This works fine while I'm logged in and `.bash_history` is in memory. F... | As far as I know, it is not possible to do what you want. I see this as a bug in bash's history processing that could be improved.
```
export HISTCONTROL=ignoreboth:erasedups # no duplicate entries
shopt -s histappend # append history file
export PROMPT_COMMAND="history -a" # update hist... |
338,317 | <p>I'm trying to build GNU grep, and when I run make, I get:</p>
<pre><code>[snip]
/bin/bash: line 9: makeinfo: command not found
</code></pre>
<p>What is makeinfo, and how do I get it?</p>
<p>(This is Ubuntu, if it makes a difference)</p>
| [
{
"answer_id": 338384,
"author": "Tuminoid",
"author_id": 40657,
"author_profile": "https://Stackoverflow.com/users/40657",
"pm_score": 10,
"selected": true,
"text": "<p>In (at least) Ubuntu when using <code>bash</code>, it tells you what package you need to install if you type in a comm... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | I'm trying to build GNU grep, and when I run make, I get:
```
[snip]
/bin/bash: line 9: makeinfo: command not found
```
What is makeinfo, and how do I get it?
(This is Ubuntu, if it makes a difference) | In (at least) Ubuntu when using `bash`, it tells you what package you need to install if you type in a command and its not found in your path. My terminal says you need to install 'texinfo' package.
```
sudo apt-get install texinfo
``` |
338,366 | <p>Is there a way to have different application settings per each build configuration?</p>
<p>I would like to be able to batch build a few configurations with different settings, instead of having to change the settings and build, rinse repeat.</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 338395,
"author": "Matt Briggs",
"author_id": 10771,
"author_profile": "https://Stackoverflow.com/users/10771",
"pm_score": 0,
"selected": false,
"text": "<p>You could add a prebuild or postbuild task to the proj, you have access to the ConfigurationName from there. Would ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42931/"
] | Is there a way to have different application settings per each build configuration?
I would like to be able to batch build a few configurations with different settings, instead of having to change the settings and build, rinse repeat.
Thanks in advance! | I don't know much about the appsettings architecture (I've never really used it), but you can define different values for constants using a bit of MSBuild magic.
Create two .cs files, Constants1.cs and Constants2.cs (or name them after your configurations).
In each file, define a class called Constants (or whatever) ... |
338,379 | <p>I need to take in a Date Range from the UI, retrieve the records within that range and plot a graph. This is the relevant section in my Rails view.</p>
<pre><code><span>
<%= check_box_tag :applyRange, @params[:applyRange]%>
From
<%= select_date Time.now, :prefix=>"fromDate" %>
... | [
{
"answer_id": 338395,
"author": "Matt Briggs",
"author_id": 10771,
"author_profile": "https://Stackoverflow.com/users/10771",
"pm_score": 0,
"selected": false,
"text": "<p>You could add a prebuild or postbuild task to the proj, you have access to the ConfigurationName from there. Would ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | I need to take in a Date Range from the UI, retrieve the records within that range and plot a graph. This is the relevant section in my Rails view.
```
<span>
<%= check_box_tag :applyRange, @params[:applyRange]%>
From
<%= select_date Time.now, :prefix=>"fromDate" %>
To
<%= select_date Time.now, :p... | I don't know much about the appsettings architecture (I've never really used it), but you can define different values for constants using a bit of MSBuild magic.
Create two .cs files, Constants1.cs and Constants2.cs (or name them after your configurations).
In each file, define a class called Constants (or whatever) ... |
338,385 | <p>Trying to make a <a href="http://en.wikipedia.org/wiki/Web_service" rel="noreferrer">web service</a> call to an <a href="http://en.wikipedia.org/wiki/HTTP_Secure" rel="noreferrer">HTTPS</a> endpoint in my <a href="http://en.wikipedia.org/wiki/Microsoft_Silverlight" rel="noreferrer">Silverlight</a> application result... | [
{
"answer_id": 338575,
"author": "joshperry",
"author_id": 30587,
"author_profile": "https://Stackoverflow.com/users/30587",
"pm_score": 2,
"selected": false,
"text": "<p>This does not look like an certificate validation error. It looks like a webservice configuration error. Can you p... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28643/"
] | Trying to make a [web service](http://en.wikipedia.org/wiki/Web_service) call to an [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure) endpoint in my [Silverlight](http://en.wikipedia.org/wiki/Microsoft_Silverlight) application results in this error: "Could not find a base address that matches scheme https for the endpo... | You might be able to achieve this in Silverlight by **allowing cross-domain communication** between the web server the hosts the Silverlight application and the remote WCF service.
In that case you need to place a [**clientaccesspolicy.xml**](http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html) file... |
338,398 | <p>Every now and then, I bump into syntax that I've seen before, but never used. This is one of those times.</p>
<p>Can someone explain the purpose of ":this" or ":base" following a C# constructor method?</p>
<p>For example:</p>
<pre><code>public MyClass(SomeArg arg) : this(new SomethingElse(), arg)
{
}
</code></pre... | [
{
"answer_id": 338402,
"author": "MrKurt",
"author_id": 35296,
"author_profile": "https://Stackoverflow.com/users/35296",
"pm_score": 5,
"selected": true,
"text": "<p>You're basically right. <code>this()</code> calls a constructor on the current instance, <code>base()</code> calls the s... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | Every now and then, I bump into syntax that I've seen before, but never used. This is one of those times.
Can someone explain the purpose of ":this" or ":base" following a C# constructor method?
For example:
```
public MyClass(SomeArg arg) : this(new SomethingElse(), arg)
{
}
```
My gut feeling is that it is used ... | You're basically right. `this()` calls a constructor on the current instance, `base()` calls the supertype's constructor on current instance. They're generally used to handle constructor overloads so you can add additional options without breaking things out into a separate method. |
338,400 | <p>Compiling this lines</p>
<pre><code> long int sz;
char tmpret[128];
//take substring of c, translate in c string, convert to int,
//and multiply with 1024
sz=atoi(c.substr(0,pos).c_str())*1024;
snprintf(tmpret,128,"%l",sz);
</code></pre>
<p>I read two warning on snprintf line:</p>
<pre>... | [
{
"answer_id": 338418,
"author": "Dmitry Khalatov",
"author_id": 18174,
"author_profile": "https://Stackoverflow.com/users/18174",
"pm_score": 4,
"selected": true,
"text": "<p>Your format lacks type, because l is a \"sizeof\" modifier. Should be %ld </p>\n"
},
{
"answer_id": 3384... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39796/"
] | Compiling this lines
```
long int sz;
char tmpret[128];
//take substring of c, translate in c string, convert to int,
//and multiply with 1024
sz=atoi(c.substr(0,pos).c_str())*1024;
snprintf(tmpret,128,"%l",sz);
```
I read two warning on snprintf line:
```
warning: conversion lacks type... | Your format lacks type, because l is a "sizeof" modifier. Should be %ld |
338,406 | <p>So I'm trying to run my first hello world prog written in C. I compiled it in eclipse and get no errors, but when I try to run it I get:</p>
<p>"This application has failed to start because cygwin1.dll was not found."</p>
<p>I found <a href="http://dev.eclipse.org/newslists/news.eclipse.tools.cdt/msg08271.html" re... | [
{
"answer_id": 338412,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 5,
"selected": true,
"text": "<p>The PATH environment variable needs to include the directory containing cygwin1.dll, not the path to cygwin1.dll i... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So I'm trying to run my first hello world prog written in C. I compiled it in eclipse and get no errors, but when I try to run it I get:
"This application has failed to start because cygwin1.dll was not found."
I found [this post](http://dev.eclipse.org/newslists/news.eclipse.tools.cdt/msg08271.html) which seems to i... | The PATH environment variable needs to include the directory containing cygwin1.dll, not the path to cygwin1.dll itself. So just make sure that PATH has the string `"C:\cygwin\bin"` in it. |
338,417 | <p>I have just installed the Platform SDK for Windows Server 2008 and .NET 3.5 on my new system, and for the first time tried to compile a project for WIN64. The Unicode Release version of that program, built for 32 bit (using the optimizing compiler from the no longer available Free Toolkit), comes in at about 2.8 MB... | [
{
"answer_id": 338422,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 0,
"selected": false,
"text": "<p>I highly doubt that it's the optimizer. The difference in program size probably has to with debugging informatio... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30568/"
] | I have just installed the Platform SDK for Windows Server 2008 and .NET 3.5 on my new system, and for the first time tried to compile a project for WIN64. The Unicode Release version of that program, built for 32 bit (using the optimizing compiler from the no longer available Free Toolkit), comes in at about 2.8 MB. Us... | A 64-bit binary will be larger than a 32-bit binary due to code side differences, static data, etc. Our project comes in at 7.1MB (x86) vs 10.7MB (x64), and that is for a significant amount of code. Nearly doubling sounds excessive, unless you have a lot of pointer sized static data.
Make sure you are linking with /OP... |
338,427 | <p>[This is for PC/Visual C++ specifically (although any other answers would be quite illuminating :))]</p>
<p>How can you tell if a pointer comes from an object in the stack? For example:</p>
<pre><code>int g_n = 0;
void F()
{
int *pA = &s_n;
ASSERT_IS_POINTER_ON_STACK(pA);
int i = 0;
int *pB = ... | [
{
"answer_id": 338446,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "<p>Whatever you do, it'll be extremely platform-specific and non-portable. Assuming you're ok with that, read on. ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13004/"
] | [This is for PC/Visual C++ specifically (although any other answers would be quite illuminating :))]
How can you tell if a pointer comes from an object in the stack? For example:
```
int g_n = 0;
void F()
{
int *pA = &s_n;
ASSERT_IS_POINTER_ON_STACK(pA);
int i = 0;
int *pB = &i;
ASSERT_IS_POINTER... | Technically speaking, in portable C you can't know. A stack for arguments is a hardware detail that is honored on many but not all compilers. Some compilers will use registers for arguments when they can (ie, fastcall).
If you are working specifically on windows NT, you want to grab the Thread Execution Block from cal... |
338,436 | <p>Is there a command in Git to see (either dumped to stdout, or in <code>$PAGER</code> or <code>$EDITOR</code>) a particular version of a particular file?</p>
| [
{
"answer_id": 338470,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 11,
"selected": false,
"text": "<p>You can use <code>git show</code> with a path from the root of the repository (<code>./</code> or <code>../</code> for ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | Is there a command in Git to see (either dumped to stdout, or in `$PAGER` or `$EDITOR`) a particular version of a particular file? | You can use `git show` with a path from the root of the repository (`./` or `../` for relative pathing):
```
$ git show REVISION:path/to/file
```
Replace `REVISION` with your actual revision (could be a Git commit SHA, a tag name, a branch name, a relative commit name, or any other way of identifying a commit in Git... |
338,445 | <p>Please can someone explain what the following statement does in SQL Server 2005:</p>
<pre><code>GRANT ALL TO pax_writer
</code></pre>
<p>pax_writer is a database role previously created using the statement</p>
<pre><code>CREATE ROLE pax_writer AUTHORIZATION dbo
</code></pre>
| [
{
"answer_id": 338470,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 11,
"selected": false,
"text": "<p>You can use <code>git show</code> with a path from the root of the repository (<code>./</code> or <code>../</code> for ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3012/"
] | Please can someone explain what the following statement does in SQL Server 2005:
```
GRANT ALL TO pax_writer
```
pax\_writer is a database role previously created using the statement
```
CREATE ROLE pax_writer AUTHORIZATION dbo
``` | You can use `git show` with a path from the root of the repository (`./` or `../` for relative pathing):
```
$ git show REVISION:path/to/file
```
Replace `REVISION` with your actual revision (could be a Git commit SHA, a tag name, a branch name, a relative commit name, or any other way of identifying a commit in Git... |
338,450 | <p>I am trying to implement the python logging handler <code>TimedRotatingFileHandler</code>.</p>
<p>When it rolls over to midnight it appends the current day in the form <code>YYYY-MM-DD</code>.</p>
<pre><code>LOGGING_MSG_FORMAT = '%(name)-14s > [%(levelname)s] [%(asctime)s] : %(message)s'
LOGGING_DATE_FORMAT = '%... | [
{
"answer_id": 338566,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 7,
"selected": true,
"text": "<p>\"How can i change how it alters the filename?\"</p>\n\n<p>Since it isn't documented, I elected to read the source. This... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34395/"
] | I am trying to implement the python logging handler `TimedRotatingFileHandler`.
When it rolls over to midnight it appends the current day in the form `YYYY-MM-DD`.
```
LOGGING_MSG_FORMAT = '%(name)-14s > [%(levelname)s] [%(asctime)s] : %(message)s'
LOGGING_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(
... | "How can i change how it alters the filename?"
Since it isn't documented, I elected to read the source. This is what I concluded from reading the source of `logging/handlers.py`
```
handler = logging.handlers.TimedRotatingFileHandler("C:\\isis_ops\\logs\\Rotate_Test",'midnight',1)
handler.suffix = "%Y-%m-%d" # or any... |
338,463 | <p>I would like to compare two dates in javascript. I have been doing some research, but all I can find is how to return the current date. I want to compare 2 separate dates, not related to today. How do I do that. </p>
<pre><code>var startDate = Date(document.form1.Textbox2);
</code></pre>
| [
{
"answer_id": 338474,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 9,
"selected": true,
"text": "<pre><code>if (date1.getTime() > date2.getTime()) {\n alert(\"The first date is after the second date!\");\n}\n</code></... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to compare two dates in javascript. I have been doing some research, but all I can find is how to return the current date. I want to compare 2 separate dates, not related to today. How do I do that.
```
var startDate = Date(document.form1.Textbox2);
``` | ```
if (date1.getTime() > date2.getTime()) {
alert("The first date is after the second date!");
}
```
[Reference to Date object](https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date) |
338,472 | <p>I have a list box control:</p>
<pre>
<code>
<asp:ListBox runat="server" id="lbox" autoPostBack="true" />
</code>
</pre>
<p>The code behind resembles:</p>
<pre>
<code>
private void Page_Load(object sender, System.EventArgs e)
{
lbox.SelectedIndexChanged+=new EventHandler(lbox_SelectedIndexChanged);
if(!... | [
{
"answer_id": 338513,
"author": "Briggie Smalls",
"author_id": 9559,
"author_profile": "https://Stackoverflow.com/users/9559",
"pm_score": -1,
"selected": false,
"text": "<p>I dont know if it makes a difference or not, but i generally attach my controls to events on the front page rathe... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have a list box control:
```
<asp:ListBox runat="server" id="lbox" autoPostBack="true" />
```
The code behind resembles:
```
private void Page_Load(object sender, System.EventArgs e)
{
lbox.SelectedIndexChanged+=new EventHandler(lbox_SelectedIndexChanged);
if(!Page.IsPostBack)
{
LoadData(); ... | What's the output of the foo() function call?
Populating manually the list box you can set indexes to whatever you want (all 0 for example) - so the same thing can happen setting a given dataSource under certain circumstances (one that specifies indexes I suppose). If all the item indexes are 0 the result is that the ... |
338,482 | <p>Is there a way to do your timezone offsets on the server side, by reading something in the request over http, instead of sending everything to the client and letting it deal with it?</p>
| [
{
"answer_id": 338503,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 0,
"selected": false,
"text": "<p>In any of the events prior to Page Unload...Request.ServerVariables. If you want their physical timezone then you... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220/"
] | Is there a way to do your timezone offsets on the server side, by reading something in the request over http, instead of sending everything to the client and letting it deal with it? | This is more complicated but I've had to resort to this scenario before because machine and user profile settings sometimes don't match your visitor's preferences. For example, a UK visitor accessing your site temporarily from an Australian server.
1. Use a geolocation service (e.g MaxMind.com) as suggested by @balaba... |
338,483 | <p>I'm on Windows Vista and IE7.</p>
<p>Here's what I'd like to do:</p>
<ol>
<li>I have two flash files: <code>page1.swf</code> and <code>page2.swf</code>. They are just page from a magazine.</li>
<li>Display <code>page1.swf</code></li>
<li>Have a button that says "Change page"</li>
<li>When I click the button; displ... | [
{
"answer_id": 338503,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 0,
"selected": false,
"text": "<p>In any of the events prior to Page Unload...Request.ServerVariables. If you want their physical timezone then you... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39973/"
] | I'm on Windows Vista and IE7.
Here's what I'd like to do:
1. I have two flash files: `page1.swf` and `page2.swf`. They are just page from a magazine.
2. Display `page1.swf`
3. Have a button that says "Change page"
4. When I click the button; display `page2.swf` instead of `page1.swf` (only `page2.swf`, not both pages... | This is more complicated but I've had to resort to this scenario before because machine and user profile settings sometimes don't match your visitor's preferences. For example, a UK visitor accessing your site temporarily from an Australian server.
1. Use a geolocation service (e.g MaxMind.com) as suggested by @balaba... |
338,499 | <p>I would (as the question states) like to make an asynchronous call, preferably using ASP.net AJAX.</p>
<p>The code for the WebMethod looks like this:</p>
<pre><code>[WebMethod]
public void SendMail(string name, string email, string subject, string body)
{
MailMessage toSend = new MailMessage(email, address@domai... | [
{
"answer_id": 338533,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>This is not an answer to your question but a warning. I was looking at this method and thinking, \"hmm, I wonder if ASP.NE... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13139/"
] | I would (as the question states) like to make an asynchronous call, preferably using ASP.net AJAX.
The code for the WebMethod looks like this:
```
[WebMethod]
public void SendMail(string name, string email, string subject, string body)
{
MailMessage toSend = new MailMessage(email, address@domain.com, subject, body)... | [Here](http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=314) you can find an example of invoking asynchronous methods with AJAX in ASP.NET MVC with elements like
```
<% using (Ajax.Form("SendMail", new AjaxOptions { UpdateTargetId = "resultDiv" })) { %>
<!-- Your form elements here... -->
<% } %>
```
... |
338,537 | <p>Is there a way to specify a one dimensional array in a ini file. </p>
<p>so in my ini I would like to do</p>
<p>someproperty = [array of something]</p>
<p>I am using <code>Zend_Config_Ini</code> config adapter (I prefer ini for base configuration). </p>
| [
{
"answer_id": 338568,
"author": "Alister Bulman",
"author_id": 6216,
"author_profile": "https://Stackoverflow.com/users/6216",
"pm_score": 6,
"selected": true,
"text": "<pre><code>someproperty[] = a\nsomeproperty[] = b\nsomeproperty[] = c\nsomeproperty[] = d\nsomeproperty[] = e\n</code>... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35505/"
] | Is there a way to specify a one dimensional array in a ini file.
so in my ini I would like to do
someproperty = [array of something]
I am using `Zend_Config_Ini` config adapter (I prefer ini for base configuration). | ```
someproperty[] = a
someproperty[] = b
someproperty[] = c
someproperty[] = d
someproperty[] = e
```
see: <http://us.php.net/manual/en/function.parse-ini-file.php#75983> |
338,540 | <p>Here's an interesting puzzle.</p>
<p>I downloaded Snippet Compiler to try some stuff out, and wanted to write the following code:</p>
<pre><code>using System;
using System.Collections.Generic;
public class MyClass
{
public static void RunSnippet()
{
HashSet<int> h = new HashSet<int>();... | [
{
"answer_id": 338547,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 3,
"selected": true,
"text": "<p>Check what version of System.Core.dll Snippet Compiler is using.</p>\n"
},
{
"answer_id": 338551,
"author": "F... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14537/"
] | Here's an interesting puzzle.
I downloaded Snippet Compiler to try some stuff out, and wanted to write the following code:
```
using System;
using System.Collections.Generic;
public class MyClass
{
public static void RunSnippet()
{
HashSet<int> h = new HashSet<int>();
}
}
```
But the above code... | Check what version of System.Core.dll Snippet Compiler is using. |
338,541 | <p>I'm extending the Gridview Web Control as my first attempt at creating a custom control.</p>
<p>As part of the extension I am encapsulating the localization of the grid column headers within the control. Among others, I'm exposing a couple of properties to enable this feature:</p>
<p>bool AutoLocalizeColumnHeaders... | [
{
"answer_id": 344734,
"author": "Victor",
"author_id": 42518,
"author_profile": "https://Stackoverflow.com/users/42518",
"pm_score": 0,
"selected": false,
"text": "<p>Interesting idea. I imagine that your property is currently set as a string?\ni wonder if you set your property as an E... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42964/"
] | I'm extending the Gridview Web Control as my first attempt at creating a custom control.
As part of the extension I am encapsulating the localization of the grid column headers within the control. Among others, I'm exposing a couple of properties to enable this feature:
bool AutoLocalizeColumnHeaders - enables the fe... | I think I've found the solution now.
Running the following from inside a Page\_Load event gave me the Resource class names:
```
String[] resourceClassNames = (from type in assembly.GetTypes()
where type.IsClass && type.Namespace.Equals("Resources")
select type.Name).ToArray();
```
So I thought I'd be able to ... |
338,559 | <p>I want to build a toolchain from gnuarm.org from sources. I don't want to use binary version because i'm running x64 linux. Can you point me to some kind of tutorial?</p>
| [
{
"answer_id": 338738,
"author": "Max Lybbert",
"author_id": 10593,
"author_profile": "https://Stackoverflow.com/users/10593",
"pm_score": -1,
"selected": false,
"text": "<ol>\n<li>Download the sources available under \"Files\"</li>\n<li>Unpack them </li>\n<li><p>Go to each unpacked dire... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42968/"
] | I want to build a toolchain from gnuarm.org from sources. I don't want to use binary version because i'm running x64 linux. Can you point me to some kind of tutorial? | You need to install *libx11-dev* to compile Insight.
```
sudo apt-get install libx11-dev
```
Besides that, your own answer works just fine.
Edit: Oh, and you might miss termcap as well, get it here: [GNU Termcap](http://ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz)
Edit2: Configure seems to be tight-ass abou... |
338,561 | <p>I have a Visual Studio 2005 solution (.sln) with a mix of .NET and C++ projects. What is the best way to generate the .build file I will need to run my build process with NAnt. I'm new to using NAnt, and I'm not sure how to set it up. Will I have to update the .build file manually every time there is a new source fi... | [
{
"answer_id": 338599,
"author": "Mike Marshall",
"author_id": 29798,
"author_profile": "https://Stackoverflow.com/users/29798",
"pm_score": 3,
"selected": true,
"text": "<p>There is no way that I know of to generate a .build file from an sln. There should be decent examples of .build fi... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363/"
] | I have a Visual Studio 2005 solution (.sln) with a mix of .NET and C++ projects. What is the best way to generate the .build file I will need to run my build process with NAnt. I'm new to using NAnt, and I'm not sure how to set it up. Will I have to update the .build file manually every time there is a new source file ... | There is no way that I know of to generate a .build file from an sln. There should be decent examples of .build files at <http://nant.sourceforge.net>.
That being said there are two ways to build a .sln file from NAnt.
* checkout nant.sourceforge.net or
nant-contrib for built in or
extended tasks to do this
* use an ... |
338,563 | <p>I have a Javascript that changes the host in links to match the current development/test server.</p>
<p>Here's an example:</p>
<pre><code>var ndomain = document.domain;
var mydomain = 'www.foo.com';
var alink = document.getElementsByTagName('a');
for (var i = 0; i < alink.length; i++) {
if (alink[i].href.le... | [
{
"answer_id": 338599,
"author": "Mike Marshall",
"author_id": 29798,
"author_profile": "https://Stackoverflow.com/users/29798",
"pm_score": 3,
"selected": true,
"text": "<p>There is no way that I know of to generate a .build file from an sln. There should be decent examples of .build fi... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42969/"
] | I have a Javascript that changes the host in links to match the current development/test server.
Here's an example:
```
var ndomain = document.domain;
var mydomain = 'www.foo.com';
var alink = document.getElementsByTagName('a');
for (var i = 0; i < alink.length; i++) {
if (alink[i].href.length > 0){
if (a... | There is no way that I know of to generate a .build file from an sln. There should be decent examples of .build files at <http://nant.sourceforge.net>.
That being said there are two ways to build a .sln file from NAnt.
* checkout nant.sourceforge.net or
nant-contrib for built in or
extended tasks to do this
* use an ... |
338,567 | <p>I currently have a gridview that has an asp:ButtonField as one of the columns. The event handler for the command extracts the row id of the gridview from the command argument and uses that to perform some logic. I now need to switch to using a template field for this column, and want to do something like this:</p>
... | [
{
"answer_id": 338605,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 3,
"selected": true,
"text": "<p>Check out this document on Microsoft's website. </p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/syste... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2327/"
] | I currently have a gridview that has an asp:ButtonField as one of the columns. The event handler for the command extracts the row id of the gridview from the command argument and uses that to perform some logic. I now need to switch to using a template field for this column, and want to do something like this:
```
<as... | Check out this document on Microsoft's website.
<http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx>
You don't need to bind the row id. The command argument is used for event arguments as opposed to row arguments... if that makes sense.
I guess what I'm trying to say is the r... |
338,598 | <p>I have a couple of lines of trivial code such as the following:</p>
<pre><code>NSData *dataReply;
NSString *stringReply;
dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
stringReply = [[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding... | [
{
"answer_id": 338646,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 0,
"selected": false,
"text": "<p>Not really sure what's going on, I ran the code below and got an NSString returned. Switching out the data with ni... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | I have a couple of lines of trivial code such as the following:
```
NSData *dataReply;
NSString *stringReply;
dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
stringReply = [[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding];
```
The problem h... | A "type mismatch" from the compiler when you try to use stringReply in another location has nothing to do with the object being returned from initWithData:encoding: and everything to do with where stringReply is subsequently being used.
For example, if you are getting a type mismatch when you do this:
```
SomeClass *... |
338,621 | <p>I'm downloading a logfile quite often from a ftp-server (which I'm not in control over, btw), and it seems rather rediciolus to download the whole file every time. </p>
<p>So I'm looking for a program (linux-ish) or Perl module that in a way combines ftp and rsync, and only "updates" the file. </p>
<p>The logfile ... | [
{
"answer_id": 338698,
"author": "Eric",
"author_id": 6367,
"author_profile": "https://Stackoverflow.com/users/6367",
"pm_score": 2,
"selected": false,
"text": "<p>Wouldn't \"resume download\" work for your case?</p>\n\n<p>Just pretend your transfer was aborted last time and restart down... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33232/"
] | I'm downloading a logfile quite often from a ftp-server (which I'm not in control over, btw), and it seems rather rediciolus to download the whole file every time.
So I'm looking for a program (linux-ish) or Perl module that in a way combines ftp and rsync, and only "updates" the file.
The logfile is constantly gro... | ```
Install curlftpfs (if on Windows, use cygwin)
# Create local mount path
mkdir -p /mnt/myftp
# Mount the destination ftp site using curlftpfs
curlftpfs -o allow_other ftp://myusername:mypassword@ftp.mydomain.com /mnt/myftp
# rsync inplace using append option
# use a long timeout value as the first long phase
# (... |
338,628 | <p>I'm trying to write a TCustomDBGrid descendant that's designed to feel like a TListBox. One of the things I want to change is the Options property's defaults. TCustomDBGrid defines Options as:</p>
<pre><code>property Options: TDBGridOptions read FOptions write SetOptions
default [dgEditing, dgTitles, dgIndicato... | [
{
"answer_id": 338640,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 4,
"selected": true,
"text": "<p>Don't specify the type. Then you can change the default. And remember that you also have to set the Options property... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32914/"
] | I'm trying to write a TCustomDBGrid descendant that's designed to feel like a TListBox. One of the things I want to change is the Options property's defaults. TCustomDBGrid defines Options as:
```
property Options: TDBGridOptions read FOptions write SetOptions
default [dgEditing, dgTitles, dgIndicator, dgColumnResiz... | Don't specify the type. Then you can change the default. And remember that you also have to set the Options property to this default in the constructor. The code below does not actually set the default, it just lets it know to not stream the property value when the value is like that.
```
property Options default [dgT... |
338,652 | <p>I have an Xcode project with the following group structure:</p>
<pre><code>ProjectName/
Classes/
class1.h
class1.m
class2.h
class2.m
...
XMLDocs/
doc1.xml
doc2.xml
...
Resources/
Info.plist
MainMenu.xib
...
</code></... | [
{
"answer_id": 339194,
"author": "amrox",
"author_id": 4468,
"author_profile": "https://Stackoverflow.com/users/4468",
"pm_score": 4,
"selected": false,
"text": "<p>A folder reference is what you want. When dragging or adding files to the project there is an option to \"Create Folder Re... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | I have an Xcode project with the following group structure:
```
ProjectName/
Classes/
class1.h
class1.m
class2.h
class2.m
...
XMLDocs/
doc1.xml
doc2.xml
...
Resources/
Info.plist
MainMenu.xib
...
```
and so on and so ... | There's no "make my disk look like my project structure" functionality in Xcode.
You could automate the task using AppleScript, though: You can both examine and change project structure from a script. So you'd just have to write a script that iterates over the project structure and makes the folder hierarchy look the ... |
338,657 | <p>I'm working on a web app that needs an ActiveX control to function. It installs just fine when the user has admin privileges, but fails to load otherwise. Is this by design and if so, is this documented somewhere? (preferably MSDN)</p>
| [
{
"answer_id": 338666,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 1,
"selected": false,
"text": "<p><strong>Complex answer: Yes.</strong> The user's account needs to be part of a group that affords the privelege o... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] | I'm working on a web app that needs an ActiveX control to function. It installs just fine when the user has admin privileges, but fails to load otherwise. Is this by design and if so, is this documented somewhere? (preferably MSDN) | Actually, none of these answers are completely correct; if you install an ActiveX control in a per-user basis it will work just fine without Administrative privileges, regardless of the group that the user is in. Bascially this involves installing it to HKEY\_CURRENT\_USER instead of HKEY\_LOCAL\_MACHINE.
Depending on... |
338,658 | <p>Can you round a .NET <code>TimeSpan</code> object?</p>
<p>I have a <code>Timespan</code> value of: 00:00:00.6193789</p>
<p>Is there a simple way to keep it a <code>TimeSpan</code> object but round it to something like<br>
00:00:00.62?</p>
| [
{
"answer_id": 338672,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure about TimeSpan, but you might check this post on DateTimes:<br>\n<a href=\"http://mikeinmadison.wordpress.... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | Can you round a .NET `TimeSpan` object?
I have a `Timespan` value of: 00:00:00.6193789
Is there a simple way to keep it a `TimeSpan` object but round it to something like
00:00:00.62? | Sorry, guys, but ***both*** the question and the popular answer so far are wrong :-)
The question is wrong because Tyndall asks for a way to ***round*** but shows an example of ***truncation***.
Will Dean's answer is wrong because it also addresses ***truncation*** rather than ***rounding***. (I suppose one could arg... |
338,673 | <p>I have a strange, sporadic issue. </p>
<p>I have stored procedure that returns back 5 small tables (e.g. IDs and Text Descriptions for Status drop down lists and such). The code calls this and places the returning dataset into ASP.Net cache. Separate methods are called to retrieve individual tables from the data... | [
{
"answer_id": 338736,
"author": "Radu094",
"author_id": 3263,
"author_profile": "https://Stackoverflow.com/users/3263",
"pm_score": 3,
"selected": true,
"text": "<p>The ASP.NET Cache will only work directly on the objects you insert in it's IEnumerable list. </p>\n\n<p>If you add a List... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28540/"
] | I have a strange, sporadic issue.
I have stored procedure that returns back 5 small tables (e.g. IDs and Text Descriptions for Status drop down lists and such). The code calls this and places the returning dataset into ASP.Net cache. Separate methods are called to retrieve individual tables from the dataset to databi... | The ASP.NET Cache will only work directly on the objects you insert in it's IEnumerable list.
If you add a List<> of objects as one cache item, it will either keep the entire list or it will discard the entire list from cache. It will never go arround the list and remove single items from it. The same should be valid... |
338,701 | <p>Due to a weird request, I can't put <code>null</code> in a database if there is no value. I'm wondering what can I put in the store procedure for nothing instead of <code>null</code>.</p>
<p>For example: </p>
<pre><code>insert into blah (blah1) values (null)
</code></pre>
<p>Is there something like nothing or em... | [
{
"answer_id": 338720,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "<p>I would push back on this bizarre request. That's exactly what <code>NULL</code> is for in SQL, to denote a missing... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] | Due to a weird request, I can't put `null` in a database if there is no value. I'm wondering what can I put in the store procedure for nothing instead of `null`.
For example:
```
insert into blah (blah1) values (null)
```
Is there something like nothing or empty for "blah1" instead using `null`? | I would push back on this bizarre request. That's exactly what `NULL` is for in SQL, to denote a missing or inapplicable value in a column.
Is the requester experiencing grief over SQL logic with `NULL`?
**edit:** Okay, I've read your reply with the extra detail about this job assignment (btw, generally you should ed... |
338,712 | <p>I have a Queue object that I need to ensure is thread-safe. Would it be better to use a lock object like this:</p>
<pre><code>lock(myLockObject)
{
//do stuff with the queue
}
</code></pre>
<p>Or is it recommended to use Queue.Synchronized like this:</p>
<pre><code>Queue.Synchronized(myQueue).whatever_i_want_to_do... | [
{
"answer_id": 338731,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 1,
"selected": false,
"text": "<p>It seems clear to me that using a lock(...) {...} lock is the right answer.</p>\n\n<blockquote>\n <p><strong>To guarant... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] | I have a Queue object that I need to ensure is thread-safe. Would it be better to use a lock object like this:
```
lock(myLockObject)
{
//do stuff with the queue
}
```
Or is it recommended to use Queue.Synchronized like this:
```
Queue.Synchronized(myQueue).whatever_i_want_to_do();
```
From reading the MSDN docs ... | Personally I always prefer locking. It means that *you* get to decide the granularity. If you just rely on the Synchronized wrapper, each individual operation is synchronized but if you ever need to do more than one thing (e.g. iterating over the whole collection) you need to lock anyway. In the interests of simplicity... |
338,719 | <p>Can I write to the end of a 5GB file in Java? This question came up in my office and no one is sure what the answer is.</p>
| [
{
"answer_id": 338735,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 3,
"selected": false,
"text": "<p>Yes. Take a look at this link RandomAccessFile</p>\n\n<p><a href=\"http://java.sun.com/javase/6/docs/api/java/io/Rando... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1447/"
] | Can I write to the end of a 5GB file in Java? This question came up in my office and no one is sure what the answer is. | This should be possible fairly easily using a [RandomAccessFile](http://java.sun.com/javase/6/docs/api/java/io/RandomAccessFile.html). Something like the following should work:
```
String filename;
RandomAccessFile myFile = new RandomAccessFile(filename, "rw");
// Set write pointer to the end of the file
myFile.seek... |
338,732 | <p>I want to be able to apply a style at runtime to an object <strong>ONLY</strong> if the current style is the default style. I don't want to override any user defined styles. Anyone know how to do this?</p>
| [
{
"answer_id": 338900,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": -1,
"selected": false,
"text": "<p>Check the DefaultStyleKeyProperty, which is a static property of any custom control.</p>\n\n<pre><code>string styleKeyN... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | I want to be able to apply a style at runtime to an object **ONLY** if the current style is the default style. I don't want to override any user defined styles. Anyone know how to do this? | It appears you can do it this way:
```
DependencyPropertyHelper.GetValueSource(
someControl, FrameworkElement.StyleProperty).BaseValueSource
== BaseValueSource.Default;
```
You can wrap that up in an extension method like this:
```
static public bool HasDefaultStyle(this FrameworkElement item)
{
return... |
338,734 | <p>I'm looking to be able to reference certain state/objects through anywhere in my application. For instance, a user logs in to their application, I need to call a web service and retrieve the users information. Then I want to be able to access this information from anywhere in the application with something like the ... | [
{
"answer_id": 338832,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 4,
"selected": false,
"text": "<p>I don't see any problem with your approach. I usually use a singleton to handle this situation:</p>\n\n<pre><code>// My... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | I'm looking to be able to reference certain state/objects through anywhere in my application. For instance, a user logs in to their application, I need to call a web service and retrieve the users information. Then I want to be able to access this information from anywhere in the application with something like the fol... | Normally, you should only connect things to the app delegate if they:
* Were created from the same NIB file as the app delegate (i.e. static UI elements in single window interfaces)
* Are associated with application-level event handling that passes through the app delegate (like the menu item for the Preferences Windo... |
338,739 | <p>I have a MySQL table containing domain names:</p>
<pre><code>+----+---------------+
| id | domain |
+----+---------------+
| 1 | amazon.com |
| 2 | google.com |
| 3 | microsoft.com |
| | ... |
+----+---------------+
</code></pre>
<p>I'd like to be able to search through this table for ... | [
{
"answer_id": 338755,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 5,
"selected": true,
"text": "<p>You can use the column on the right of the like too:</p>\n\n<pre><code>SELECT domain FROM table WHERE 'www.google.com' LIKE... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42974/"
] | I have a MySQL table containing domain names:
```
+----+---------------+
| id | domain |
+----+---------------+
| 1 | amazon.com |
| 2 | google.com |
| 3 | microsoft.com |
| | ... |
+----+---------------+
```
I'd like to be able to search through this table for a full hostname (i.e. 'www... | You can use the column on the right of the like too:
```
SELECT domain FROM table WHERE 'www.google.com' LIKE CONCAT('%', domain);
```
or
```
SELECT domain FROM table WHERE 'www.google.com' LIKE CONCAT('%', domain, '%');
```
It's not particularly efficient but it works. |
338,740 | <p>Currently I have the function CreateLog() for creating a a log4net Log with name after the constructing instance's class.
Typically used as in:</p>
<pre><code>class MessageReceiver
{
protected ILog Log = Util.CreateLog();
...
}
</code></pre>
<p>If we remove lots of error handling the implementation boil... | [
{
"answer_id": 338760,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n <p>Is there anyone who can show me how to implement a zero argument CreateLog() that gets the name from t... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41884/"
] | Currently I have the function CreateLog() for creating a a log4net Log with name after the constructing instance's class.
Typically used as in:
```
class MessageReceiver
{
protected ILog Log = Util.CreateLog();
...
}
```
If we remove lots of error handling the implementation boils down to:
[EDIT: Please r... | >
> Is there anyone who can show me how to implement a zero argument CreateLog() that gets the name from the subclass and not the declaring class?
>
>
>
I don't think you'll be able to do it by looking at the stack frame.
While your class is `IMReceiver`, the call to `CreateLog` method is in the `MessageReceiver... |
338,762 | <p>How do you calculate the angle between two normals in glsl? I am trying to add the fresnel effect to the outer edges of an object (combining that effect with phong shading), and I think that the angle is the only thing I am missing.</p>
<p>Fragment Shader:</p>
<pre><code>varying vec3 N;
varying vec3 v;
void main(... | [
{
"answer_id": 338801,
"author": "David Norman",
"author_id": 34502,
"author_profile": "https://Stackoverflow.com/users/34502",
"pm_score": 3,
"selected": false,
"text": "<p>From the dot product of two vectors you can get the cosine of the angle between them</p>\n\n<pre><code>cos A = Dot... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do you calculate the angle between two normals in glsl? I am trying to add the fresnel effect to the outer edges of an object (combining that effect with phong shading), and I think that the angle is the only thing I am missing.
Fragment Shader:
```
varying vec3 N;
varying vec3 v;
void main(void) {
v = vec3(gl... | dot product between two vectors will return the cosine of the angle (in GLSL it's dot(a,b)). Taking arc-cosine of that will return angle in radians (in GLSL it's acos(x)).
Dot product is very cheap, arc-cosine is quite expensive.
However, Fresnel effect does not really need the angle. Just having dot result between t... |
338,768 | <p>Python is installed in a local directory. </p>
<p>My directory tree looks like this:</p>
<pre><code>(local directory)/site-packages/toolkit/interface.py
</code></pre>
<p>My code is in here:</p>
<pre><code>(local directory)/site-packages/toolkit/examples/mountain.py
</code></pre>
<p>To run the example, I write ... | [
{
"answer_id": 338790,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 4,
"selected": false,
"text": "<p>To mark a directory as a package you need a file named <code>__init__.py</code>, does this help?</p>\n"
},
{
"answ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39160/"
] | Python is installed in a local directory.
My directory tree looks like this:
```
(local directory)/site-packages/toolkit/interface.py
```
My code is in here:
```
(local directory)/site-packages/toolkit/examples/mountain.py
```
To run the example, I write `python mountain.py`, and in the code I have:
```
from t... | Based on your comments to orip's post, I guess this is what happened:
1. You edited `__init__.py` on windows.
2. The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).
3. You used WinSCP to copy the... |
338,776 | <p>I'm trying to convert an Excel document into a table in SQL 2005. I found the link below and am wondering if it looks like a solution. If so, what would the @excel_full_file_name syntax be and where would the path be relative to? </p>
<p><a href="http://www.siccolo.com/Articles/SQLScripts/how-to-create-sql-to-con... | [
{
"answer_id": 338788,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 2,
"selected": false,
"text": "<p>Glancing over the code, I would expect it to be the full path name of the excel document:</p>\n\n<p>For example: c... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13954/"
] | I'm trying to convert an Excel document into a table in SQL 2005. I found the link below and am wondering if it looks like a solution. If so, what would the @excel\_full\_file\_name syntax be and where would the path be relative to?
<http://www.siccolo.com/Articles/SQLScripts/how-to-create-sql-to-convert-Excel_to_tab... | You can use the BULK INSERT T-SQL command if you just want a pure sql solution. You have to save the file as csv/text first.
```
BULK
INSERT YourDestinationTable
FROM 'D:\YourFile.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
```
Alternative... |
338,816 | <p>The controllers in my ASP.NET MVC web app are starting to get a bit bloated with business logic. The examples on the web all show simple controller actions that simply pull data out of a repository and pass it to the view. But what if you also need to support business logic on top of that? </p>
<p>Say, for insta... | [
{
"answer_id": 338855,
"author": "Harper Shelby",
"author_id": 21196,
"author_profile": "https://Stackoverflow.com/users/21196",
"pm_score": 0,
"selected": false,
"text": "<p>Your business logic should be encapsulated in business objects - if you have an Order object (and you do, don't y... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] | The controllers in my ASP.NET MVC web app are starting to get a bit bloated with business logic. The examples on the web all show simple controller actions that simply pull data out of a repository and pass it to the view. But what if you also need to support business logic on top of that?
Say, for instance, an actio... | Your controllers (in the MVC project) should be calling your objects in the Service project. The services project is where all the business logic is handled.
A good example is this:
```
public ActionResult Index()
{
ProductServices productServices = new ProductServices();
// top 10 products, for example.
... |
338,817 | <p>I'm generating a menu with a Repeater control bound to an XmlDataSource. </p>
<pre><code><asp:Repeater ID="myRepeater" runat="server"
DataSourceID="myDataSource"
onitemdatabound="myRepeater_ItemDataBound"
onitemcreated="myRepeater_ItemCreated">
<HeaderTemplate>
<ul class="... | [
{
"answer_id": 338843,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 4,
"selected": true,
"text": "<p>The style property is a collection. Do this:</p>\n\n<pre><code>l_genericControl.Style.Add(\"css-name\", \"css-value\")\n... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27870/"
] | I'm generating a menu with a Repeater control bound to an XmlDataSource.
```
<asp:Repeater ID="myRepeater" runat="server"
DataSourceID="myDataSource"
onitemdatabound="myRepeater_ItemDataBound"
onitemcreated="myRepeater_ItemCreated">
<HeaderTemplate>
<ul class="menu_list">
</HeaderTempla... | The style property is a collection. Do this:
```
l_genericControl.Style.Add("css-name", "css-value")
```
Or if you are using CSS classes, then change the CssClass property:
```
l_genericControl.CssClass = "on-nav";
```
If you're trying to toggle the CSS class with your javascript, try something like this (unteste... |
338,836 | <p>I have a GridView with several fields, one of which can potentially have a crazy wide value in it like this:</p>
<p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
<p>If <em>that</em> sort of thing is in the field, I want it to wrap.</p>
<p>I can easily insert a cha... | [
{
"answer_id": 338877,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 0,
"selected": false,
"text": "<p>You can do a few things here. </p>\n\n<p>One option is change the column in question to a TemplateColumn, and p... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5486/"
] | I have a GridView with several fields, one of which can potentially have a crazy wide value in it like this:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
If *that* sort of thing is in the field, I want it to wrap.
I can easily insert a character in code every 50 charact... | ItemStyle-Wrap="true" ItemStyle-Width="100" doesn't work for one long word with no space.
**Found the solution:**
```
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.... |
338,856 | <p>Is there a way that I can do a select as such</p>
<pre><code>select * from attributes where product_id = 500
</code></pre>
<p>would return </p>
<pre><code>id name description
1 wheel round and black
2 horn makes loud noise
3 window solid object you can see through
</code></pre>
<p>and the que... | [
{
"answer_id": 338893,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 2,
"selected": false,
"text": "<p>Even if it was possible, I doubt it would work. Both of those WHERE clauses expect one thing to be returned, therefo... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] | Is there a way that I can do a select as such
```
select * from attributes where product_id = 500
```
would return
```
id name description
1 wheel round and black
2 horn makes loud noise
3 window solid object you can see through
```
and the query
```
select * from attributes where product_id... | Even if it was possible, I doubt it would work. Both of those WHERE clauses expect one thing to be returned, therefore the code would probably just use the first row returned, not all of them.
It would also give the database a behaviour that would make future developers pull their hair out trying to understand.
Do it... |
338,887 | <p>I'm looking at some GXT code for GWT and I ran across this use of Generics that I can't find another example of in the Java tutorials. The class name is <a href="http://extjs.com/deploy/gxtdocs/com/extjs/gxt/ui/client/data/BaseModelData.html" rel="noreferrer"><code>com.extjs.gxt.ui.client.data.BaseModelData</code></... | [
{
"answer_id": 338906,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 5,
"selected": false,
"text": "<p>The type is declared on the method. That's that \"<code><X></code>\" means. The type is scoped then to just the met... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42994/"
] | I'm looking at some GXT code for GWT and I ran across this use of Generics that I can't find another example of in the Java tutorials. The class name is [`com.extjs.gxt.ui.client.data.BaseModelData`](http://extjs.com/deploy/gxtdocs/com/extjs/gxt/ui/client/data/BaseModelData.html) if you want to look at all of the code.... | The method returns a type of whatever you expect it to be (`<X>` is defined in the method and is absolutely unbounded).
This is very, very dangerous as no provision is made that the return type actually matches the returned value.
The only advantage this has is that you don't have to cast the return value of such gen... |
338,895 | <p>In earlier versions of MS-DOS - I want to say version 7, but I could be wrong - there was a <code>deltree</code> command, which recursively deleted all subdirectories and files from a given path. </p>
<p><code>deltree</code> no longer exists, but <code>del</code> didn't seem to inherit the ability to delete a tree... | [
{
"answer_id": 338905,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<pre><code>rmdir /s /q directory\n</code></pre>\n"
},
{
"answer_id": 338921,
"author": "Jeremiah",
"auth... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] | In earlier versions of MS-DOS - I want to say version 7, but I could be wrong - there was a `deltree` command, which recursively deleted all subdirectories and files from a given path.
`deltree` no longer exists, but `del` didn't seem to inherit the ability to delete a tree. `del /s` deletes files, but not folders.
... | As others have mentioned, the `rd` command has the `/s` switch to recursively remove sub-directories. You can combine it with the `/q` switch to forcibly delete a sub-directory (and its contents) without prompting as so
```
rd /s /q c:\foobar
```
What everybody is missing is that `rd` is *not* an exact replacement f... |
338,927 | <p>Given the following Flash method:</p>
<pre><code>function sendToJava(name:String, ... args)
{
ExternalInterface.call("sendCommand", name, args);
}
</code></pre>
<p>How do I ensure that ExternalInterface.call() interprets args in its expanded form? Right now, if I pass a list into "args", that list gets interpret... | [
{
"answer_id": 339001,
"author": "Gili",
"author_id": 14731,
"author_profile": "https://Stackoverflow.com/users/14731",
"pm_score": 1,
"selected": false,
"text": "<p>I found an answer on IRC :)</p>\n\n<pre><code>function sendToJava(name:String, ... args)\n{\n // See Array.unshift()\n a... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14731/"
] | Given the following Flash method:
```
function sendToJava(name:String, ... args)
{
ExternalInterface.call("sendCommand", name, args);
}
```
How do I ensure that ExternalInterface.call() interprets args in its expanded form? Right now, if I pass a list into "args", that list gets interpreted as a single argument of... | One small typo. It should be:
```
function sendToJava(name:String, ... args)
{
// See Array.unshift()
args.unshift("sendCommand", name);
// See Function.apply()
ExternalInterface.call.apply(null, args);
}
```
Just change "array" to "apply"
Anyways, thanks a ton for posting this. You're a lifesaver! |
338,934 | <p>I am using the SharpZipLib open source .net library from <a href="http://www.icsharpcode.net" rel="nofollow noreferrer">www.icsharpcode.net</a></p>
<p>My goal is to unzip an xml file and read it into a dataset. However I get the following error reading the file into a dataset: "Data at the root level is invalid. Li... | [
{
"answer_id": 338991,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": true,
"text": "<p>Well, what does the final file look like? (compared to the original). You don't show the zipping code, which might ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4096/"
] | I am using the SharpZipLib open source .net library from [www.icsharpcode.net](http://www.icsharpcode.net)
My goal is to unzip an xml file and read it into a dataset. However I get the following error reading the file into a dataset: "Data at the root level is invalid. Line 1, position 1."
I believe what is happening ... | Well, what does the final file look like? (compared to the original). You don't show the zipping code, which might be part of the puzzle, especially as you are partially swallowing the exception.
I would also try ensuring everything `IDisposable` is `Dispose()`d, ideally via `using`; also - in case the problem is with... |
338,935 | <p>I am binding a List to a DataGridView. One property of the SomeObject class will be a status code (ex. Red, Yellow, Green). Can I "bind" the status to the background color of a cell easily? How about binding to a tooltip also?</p>
| [
{
"answer_id": 340063,
"author": "Sergiu Damian",
"author_id": 41345,
"author_profile": "https://Stackoverflow.com/users/41345",
"pm_score": 2,
"selected": false,
"text": "<p>Out of the box, any DataGridViewColumn can be bound to only one property of the objects in the DataSource, the na... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | I am binding a List to a DataGridView. One property of the SomeObject class will be a status code (ex. Red, Yellow, Green). Can I "bind" the status to the background color of a cell easily? How about binding to a tooltip also? | You can write a handler for the DataGridView's CellFormatting event to customise the background colour. Here's a worked example (you'll need to have dragged a DataGridView onto the default Form then double-clicked on the CellFormatting event to create a handler):
```
using System.Drawing;
using System.Windows.Forms;
... |
338,950 | <p>How would one code the following C# code in Managed C++</p>
<pre><code>void Foo()
{
using (SqlConnection con = new SqlConnection("connectionStringGoesHere"))
{
//do stuff
}
}
</code></pre>
<p><strong>Clarificaton:</strong>
For managed objects.</p>
| [
{
"answer_id": 339109,
"author": "Mike Hall",
"author_id": 18202,
"author_profile": "https://Stackoverflow.com/users/18202",
"pm_score": -1,
"selected": false,
"text": "<p>If you're concerned about limiting the variable's lifetime rather than automatic disposal, you can always just put i... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] | How would one code the following C# code in Managed C++
```
void Foo()
{
using (SqlConnection con = new SqlConnection("connectionStringGoesHere"))
{
//do stuff
}
}
```
**Clarificaton:**
For managed objects. | Assuming you mean C++/CLI (not the old Managed C++), the following are your options:
(1) Mimic a using-Block with using automatic / stackbased objects:
```
{
SqlConnection conn(connectionString);
}
```
This will call the Destructor of the "conn" Object when the next enclosing block ends. Whether this is the enclo... |
338,951 | <p>I'm writing an application that can be started either as a standard WinForms app or in unattended mode from the command-line. The application was built using the VS 2k5 standard WinForms template.</p>
<p>When the application is executed from the command-line, I want it to output information that can be captured by ... | [
{
"answer_id": 339216,
"author": "Igal Serban",
"author_id": 25737,
"author_profile": "https://Stackoverflow.com/users/25737",
"pm_score": 3,
"selected": true,
"text": "<p><strong>Update 1:</strong></p>\n\n<p>As said in Michael Burr answer, <a href=\"http://blogs.msdn.com/oldnewthing/\" ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287/"
] | I'm writing an application that can be started either as a standard WinForms app or in unattended mode from the command-line. The application was built using the VS 2k5 standard WinForms template.
When the application is executed from the command-line, I want it to output information that can be captured by the script... | **Update 1:**
As said in Michael Burr answer, [Raymond Chen](http://blogs.msdn.com/oldnewthing/) recently [posted a short article about this](http://blogs.msdn.com/oldnewthing/archive/2009/01/01/9259142.aspx). I am happy to see that my guess was not totally wrong.
**Update 0:**
Disclaimer: This "answer" is mostly sp... |
338,978 | <p>Here's my table: </p>
<pre><code>CREATE TABLE `alums_alumphoto` (
`id` int(11) NOT NULL auto_increment,
`alum_id` int(11) NOT NULL,
`photo_id` int(11) default NULL,
`media_id` int(11) default NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `alums_alumphoto_alum_id` (`alum_id... | [
{
"answer_id": 339015,
"author": "yogman",
"author_id": 24349,
"author_profile": "https://Stackoverflow.com/users/24349",
"pm_score": 4,
"selected": true,
"text": "<p>The sure thing is to make a duplicate table.</p>\n\n<pre><code>> CREATE TABLE alums_alumphoto_new LIKE alums_alumphoto... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35579/"
] | Here's my table:
```
CREATE TABLE `alums_alumphoto` (
`id` int(11) NOT NULL auto_increment,
`alum_id` int(11) NOT NULL,
`photo_id` int(11) default NULL,
`media_id` int(11) default NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `alums_alumphoto_alum_id` (`alum_id`),
KEY `al... | The sure thing is to make a duplicate table.
```
> CREATE TABLE alums_alumphoto_new LIKE alums_alumphoto;
> ALTER TABLE .... // Drop constraint
> ALTER TABLE .... // Drop KEY
> ALTER TABLE .... // Drop the column
> INSERT INTO alums_alumphoto_new (SELECT id, alum_id, photo_id, media_id, updated FROM alums_alumphoto);
... |
338,981 | <p>My dilema:</p>
<p>In .htaccess in my website's root:</p>
<pre><code>RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</code></pre>
<p>In .htaccess in the subdirectory /foo</p>
<pre><code>RewriteEngine On
RewriteRule ^page1\.html$ /foo/page2... | [
{
"answer_id": 339188,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 2,
"selected": false,
"text": "<p>i'm not sure of the specifics as to why the rules in <code>/.htaccess</code> aren't applying to <code>/foo/.htaccess</code>.... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16272/"
] | My dilema:
In .htaccess in my website's root:
```
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
```
In .htaccess in the subdirectory /foo
```
RewriteEngine On
RewriteRule ^page1\.html$ /foo/page2.html [R=301]
```
In the first, I'm trying... | You are missing the following directive in `foo/.htaccess`:
```
RewriteOptions inherit
```
cf. [the documentation](http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteoptions) |
338,986 | <p>In a <a href="http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/" rel="nofollow noreferrer">controversial blog post</a> today, Hackification pontificates on what appears to be a bug in the new LINQ To Entities framework: </p>
<blockquote>
<p>Suppose I search for a customer:</p>... | [
{
"answer_id": 339000,
"author": "dtc",
"author_id": 32892,
"author_profile": "https://Stackoverflow.com/users/32892",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know much about ORMs, but as a user of LinqToSql and LinqToEntities I would hope that when you try to query Orders ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | In a [controversial blog post](http://www.hackification.com/2008/12/03/linq-to-entities-the-blackberry-storm-of-orms/) today, Hackification pontificates on what appears to be a bug in the new LINQ To Entities framework:
>
> Suppose I search for a customer:
>
>
>
> ```
> var alice = data.Customers.First( c => c.Na... | Jon,
I've been playing with linq to entities also. It's got a long way to go before it catches up with linq to SQL. I've had to use linq to entities for the Table per Type Inheritance stuff. I found a good article recently which explains the whole 1 company 2 different ORM technologies thing [here](http://www.infoq.co... |
338,988 | <p>How do you get/set the absolute position of a MovieClip in Flash/AS3? And by absolute, I mean its position relative to the stage's origo.</p>
<p>I currently have this setter:</p>
<pre><code>class MyMovieClip extends MovieClip
{
function set xAbs(var x:Number):void
{
this.x = -(this.parent.localToGlobal(new... | [
{
"answer_id": 339068,
"author": "moritzstefaner",
"author_id": 23069,
"author_profile": "https://Stackoverflow.com/users/23069",
"pm_score": 3,
"selected": false,
"text": "<p>Two things:</p>\n\n<p>Why the substractions?</p>\n\n<pre><code>var x=this.parent.localToGlobal(new Point(this.x,... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7724/"
] | How do you get/set the absolute position of a MovieClip in Flash/AS3? And by absolute, I mean its position relative to the stage's origo.
I currently have this setter:
```
class MyMovieClip extends MovieClip
{
function set xAbs(var x:Number):void
{
this.x = -(this.parent.localToGlobal(new Point()).x) + x;
}... | Two things:
Why the substractions?
```
var x=this.parent.localToGlobal(new Point(this.x,0)).x;
```
should give the proper result already. If the parent clip is scaled, your calculation will be off by the scaling factor...
Just a shot in the dark, but you could add a `globalToLocal(this.stage)` for compensating th... |
339,007 | <p>How do I pad a numeric string with zeroes to the left, so that the string has a specific length?</p>
| [
{
"answer_id": 339012,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 8,
"selected": false,
"text": "<p>Besides <code>zfill</code>, you can use general string formatting:</p>\n\n<pre class=\"lang-py prettyprint-overrid... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I pad a numeric string with zeroes to the left, so that the string has a specific length? | To pad strings:
```
>>> n = '4'
>>> print(n.zfill(3))
004
```
To pad numbers:
```
>>> n = 4
>>> print(f'{n:03}') # Preferred method, python >= 3.6
004
>>> print('%03d' % n)
004
>>> print(format(n, '03')) # python >= 2.6
004
>>> print('{0:03d}'.format(n)) # python >= 2.6 + python 3
004
>>> print('{foo:03d}'.format(... |
339,041 | <p>I've been working with LINQ To SQL for a little while now and when it comes to removing an entity from the DB, I've always called the table's .DeleteOnSubmit and passed in the entity. Sometimes I've found myself writing something like:</p>
<pre><code>db.Users.DeleteOnSubmit(db.Users.Where(c => c.ID == xyz).Selec... | [
{
"answer_id": 339099,
"author": "Adam Lassek",
"author_id": 1249,
"author_profile": "https://Stackoverflow.com/users/1249",
"pm_score": 0,
"selected": false,
"text": "<p>I don't believe Linq to Sql can do this natively, although writing a stored procedure would give you what you want, w... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've been working with LINQ To SQL for a little while now and when it comes to removing an entity from the DB, I've always called the table's .DeleteOnSubmit and passed in the entity. Sometimes I've found myself writing something like:
```
db.Users.DeleteOnSubmit(db.Users.Where(c => c.ID == xyz).Select(c => c).Single(... | Here is a solution...
```
public static void DeleteByPK<TSource, TPK>(TPK pk, DataContext dc)
where TSource : class
{
Table<TSource> table = dc.GetTable<TSource>();
TableDef tableDef = GetTableDef<TSource>();
dc.ExecuteCommand("DELETE FROM [" + tableDef.TableName
+ "] WHERE [" = tableDef.PKFieldName + "] ... |
339,042 | <p>I am trying to write a fragment program that will take a texture and clamp the texels between two values. That is, if the min value is say 0.2 and the max value is 0.6, any texel less than 0.2 will become 0, any texel greater than 0.6 will become 1.0, and all values in between will be mapped from 0 to 1.0.</p>
<p>M... | [
{
"answer_id": 340083,
"author": "Maurice Gilden",
"author_id": 7866,
"author_profile": "https://Stackoverflow.com/users/7866",
"pm_score": 0,
"selected": false,
"text": "<p>First: I don't know much about ARB_fragment_program so I'm partly guessing here.</p>\n\n<p>Your best option would ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55638/"
] | I am trying to write a fragment program that will take a texture and clamp the texels between two values. That is, if the min value is say 0.2 and the max value is 0.6, any texel less than 0.2 will become 0, any texel greater than 0.6 will become 1.0, and all values in between will be mapped from 0 to 1.0.
My call to ... | I haven't really programed any shaders, but maybe the shader compiler doesn't recognize the new line? have you tried putting "\n\r"?
EDIT:
Another question that you may ask yourself is what language are you using? Are strings in UNICODE, ie 16-bits/char? I just noticed that the format you are passing into the glProgr... |
339,044 | <p>A puzzler from a coworker that I cannot figure out...</p>
<pre><code>update btd.dbo.tblpayroll
set empname = ( select b.Legal_Name
from ( SELECT Legal_Name,
Employee_ID
FROM Com.dbo.Workers
... | [
{
"answer_id": 339080,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>I suspect that the optimizer is attempting to apply the where clause of the outer select before the inner select. Pr... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37379/"
] | A puzzler from a coworker that I cannot figure out...
```
update btd.dbo.tblpayroll
set empname = ( select b.Legal_Name
from ( SELECT Legal_Name,
Employee_ID
FROM Com.dbo.Workers
WHE... | I suspect that the optimizer is attempting to apply the where clause of the outer select before the inner select. Presumably it thinks it would be able to do an index lookup on Employee\_ID resulting in a faster query in this case. Try:
```
update btd.dbo.tblpayroll
set empname = ( select Legal_Name
... |
339,045 | <p>I'm not of the Perl world, so some of this is new to me. I'm running Ubuntu Hardy LTS with apache2 and mod_fcgid packages installed. I'd like to get MT4 running under fcgid rather than mod-cgi (it seems to run OK with plain-old CGI).</p>
<p>I can't seem to get even a simple Perl script to run under fcgid. I creat... | [
{
"answer_id": 339094,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 2,
"selected": false,
"text": "<p>I use CGI::Fast more than FCGI, but the idea is the same, I think. The goal of fast cgi is to load the program once, and it... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/323748/"
] | I'm not of the Perl world, so some of this is new to me. I'm running Ubuntu Hardy LTS with apache2 and mod\_fcgid packages installed. I'd like to get MT4 running under fcgid rather than mod-cgi (it seems to run OK with plain-old CGI).
I can't seem to get even a simple Perl script to run under fcgid. I created a simple... | I use CGI::Fast more than FCGI, but the idea is the same, I think. The goal of fast cgi is to load the program once, and iterate in a loop for every request.
FCGI's man page says :
```
use FCGI;
my $count = 0;
my $request = FCGI::Request();
while($request->Accept() >= 0) {
print("Content-type: text/html\r\n\r\n... |
339,053 | <p>Using python 2.4 and the built-in <code>ZipFile</code> library, I cannot read very large zip files (greater than 1 or 2 GB) because it wants to store the entire contents of the uncompressed file in memory. Is there another way to do this (either with a third-party library or some other hack), or must I "shell out" ... | [
{
"answer_id": 339506,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 5,
"selected": true,
"text": "<p>Here's an outline of decompression of large files.</p>\n\n<pre><code>import zipfile\nimport zlib\nimport os\n\nsrc = open... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27020/"
] | Using python 2.4 and the built-in `ZipFile` library, I cannot read very large zip files (greater than 1 or 2 GB) because it wants to store the entire contents of the uncompressed file in memory. Is there another way to do this (either with a third-party library or some other hack), or must I "shell out" and unzip it th... | Here's an outline of decompression of large files.
```
import zipfile
import zlib
import os
src = open( doc, "rb" )
zf = zipfile.ZipFile( src )
for m in zf.infolist():
# Examine the header
print m.filename, m.header_offset, m.compress_size, repr(m.extra), repr(m.comment)
src.seek( m.header_offset )
... |
339,056 | <p>I need to be able to allow query strings that contain characters like '<' and '>'. However, putting something like id=mi<ke into the the URL will output an error page saying:</p>
<p><em>A potentially dangerous Request.QueryString value was detected from the client (id="mi<ke").</em></p>
<p>If I first url ... | [
{
"answer_id": 339078,
"author": "JasonS",
"author_id": 1865,
"author_profile": "https://Stackoverflow.com/users/1865",
"pm_score": 0,
"selected": false,
"text": "<p>Instead of URL encode, you could encrypt your id value to get around the issue. You will probably then need to URL encode... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18202/"
] | I need to be able to allow query strings that contain characters like '<' and '>'. However, putting something like id=mi<ke into the the URL will output an error page saying:
*A potentially dangerous Request.QueryString value was detected from the client (id="mi<ke").*
If I first url encode the url (to create id=mi%3... | I ran into a problem similar to this. I chose to base64 encode the query string to work around it.
using
```
System.Text.ASCIIEncoding.ASCII.GetBytes
```
to get the string as bytes
and then
```
System.Convert.ToBase64String
```
to turn it into a "safe" string.
To get it back, use:
```
System.Convert.FromBase6... |
339,100 | <p>I’m selecting data on an old database which has an abused status column. The status column has multiple pieces of information in it. Values are like ‘New Contact YYYY’, ‘Online YYYY’, ‘Updated YYYY’, ‘Withdrawn YYYY’, etc…. As you may have guessed, YYYY represents the year … which I need.</p>
<p>In the past I’ve ... | [
{
"answer_id": 339125,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 4,
"selected": true,
"text": "<p>If you simply want to extract a four digit year from the string, you could use PATINDEX</p>\n\n<pre><code>SELECT SUBSTRING(F... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29043/"
] | I’m selecting data on an old database which has an abused status column. The status column has multiple pieces of information in it. Values are like ‘New Contact YYYY’, ‘Online YYYY’, ‘Updated YYYY’, ‘Withdrawn YYYY’, etc…. As you may have guessed, YYYY represents the year … which I need.
In the past I’ve done somethi... | If you simply want to extract a four digit year from the string, you could use PATINDEX
```
SELECT SUBSTRING(FieldName, PATINDEX('%[0-9][0-9][0-9][0-9]%', FieldName), 4)
FROM TableName
``` |
339,105 | <p>I'm really struggling with grasping how to effectively use FasterCSV to accomplish what I want.</p>
<p>I have a CSV file; say:</p>
<pre><code>ID,day,site
test,tuesday,cnn.com
bozo,friday,fark.com
god,monday,xkcd.com
test,saturday,whatever.com
</code></pre>
<p>I what to go through this file and end up with a hash ... | [
{
"answer_id": 339147,
"author": "Eli",
"author_id": 5958,
"author_profile": "https://Stackoverflow.com/users/5958",
"pm_score": 0,
"selected": false,
"text": "<p>I don't have the code in front of me, but I believe <code>row.to_hash</code> does that (where <code>row</code> is the <code>F... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32154/"
] | I'm really struggling with grasping how to effectively use FasterCSV to accomplish what I want.
I have a CSV file; say:
```
ID,day,site
test,tuesday,cnn.com
bozo,friday,fark.com
god,monday,xkcd.com
test,saturday,whatever.com
```
I what to go through this file and end up with a hash that has a counter for how many t... | Easy:
```
h = Hash.new(0)
FasterCSV.read("file.csv")[1..-1].each {|row| h[row[0]] += 1}
```
Works the same with CSV.read, as well. |
339,106 | <p>Some time ago I got this error when building ANY Visual Studio Deployment project.</p>
<p><strong>"Unrecoverable build error"</strong> </p>
<p><em>I thought my VS installation was corrupted or I deleted some important files, but ...</em></p>
| [
{
"answer_id": 339111,
"author": "Robin Rodricks",
"author_id": 41021,
"author_profile": "https://Stackoverflow.com/users/41021",
"pm_score": 6,
"selected": true,
"text": "<p>...all I had to do was.</p>\n<p><strong>Close down</strong> Visual Studio.</p>\n<p>Start, <strong>Run</strong> or... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41021/"
] | Some time ago I got this error when building ANY Visual Studio Deployment project.
**"Unrecoverable build error"**
*I thought my VS installation was corrupted or I deleted some important files, but ...* | ...all I had to do was.
**Close down** Visual Studio.
Start, **Run** or WIN+R, type **cmd**, OK.
```
regsvr32 "C:\Program Files\Common Files\Microsoft Shared\MSI Tools\mergemod.dll"
regsvr32 ole32.dll
```
**For x64 bit machines**
```
regsvr32 "C:\Program Files (x86)\Common Files\Microsoft Shared\MSI Tools\mergemo... |
339,116 | <p>We have a page of search results which the user can hit in several ways. 90% of the ways will set up a 'Search Criteria' session object, which the results page will use to retrieve the search results.</p>
<p>When the session object isn't found, we will typically show the user an 'invalid search' message, and give ... | [
{
"answer_id": 339143,
"author": "Ta01",
"author_id": 7280,
"author_profile": "https://Stackoverflow.com/users/7280",
"pm_score": 4,
"selected": true,
"text": "<p>This is an excellent <a href=\"http://www.eggheadcafe.com/articles/20051228.asp\" rel=\"noreferrer\">article</a> which is bas... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23902/"
] | We have a page of search results which the user can hit in several ways. 90% of the ways will set up a 'Search Criteria' session object, which the results page will use to retrieve the search results.
When the session object isn't found, we will typically show the user an 'invalid search' message, and give them a link... | This is an excellent [article](http://www.eggheadcafe.com/articles/20051228.asp) which is based off of [this one](http://aspalliance.com/520). I think you will find your answers here (Page 2 of the second article specifically) |
339,130 | <p>I'm trying to generate a JSON response that includes some HTML. Thus, I have <code>/app/views/foo/bar.json.erb</code>:</p>
<pre><code>{
someKey: 'some value',
someHTML: "<%= h render(:partial => '/foo/baz') -%>"
}
</code></pre>
<p>I want it to render <code>/app/views/foo/_baz.html.erb</code>, but it ... | [
{
"answer_id": 340335,
"author": "roninek",
"author_id": 42642,
"author_profile": "https://Stackoverflow.com/users/42642",
"pm_score": 3,
"selected": false,
"text": "<p>You have two options:</p>\n\n<p>1) use <code>render :file</code></p>\n\n<pre><code>render :file => \"foo/_baz.json.e... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I'm trying to generate a JSON response that includes some HTML. Thus, I have `/app/views/foo/bar.json.erb`:
```
{
someKey: 'some value',
someHTML: "<%= h render(:partial => '/foo/baz') -%>"
}
```
I want it to render `/app/views/foo/_baz.html.erb`, but it will only render `/app/views/foo/_baz.json.erb`. Passing `... | Building on [roninek's response](https://stackoverflow.com/questions/339130/how-do-i-render-a-partial-of-a-different-format-in-rails#340335), I've found the best solution to be the following:
in /app/helpers/application.rb:
```
def with_format(format, &block)
old_format = @template_format
@template_format = forma... |
339,133 | <p>The scenario: we have a web system that automatically generates office 2003 excel files "on the fly" (using the 2003 XML file format, not the binary format.) These files do get kept on the web server for various things.</p>
<p>Now, we're in a situation where the client would really like us to take the xls files ge... | [
{
"answer_id": 339139,
"author": "Victor",
"author_id": 42518,
"author_profile": "https://Stackoverflow.com/users/42518",
"pm_score": 1,
"selected": false,
"text": "<p>so your user would like to append the latest file generated every time? or just glue\" them together when they make a re... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19074/"
] | The scenario: we have a web system that automatically generates office 2003 excel files "on the fly" (using the 2003 XML file format, not the binary format.) These files do get kept on the web server for various things.
Now, we're in a situation where the client would really like us to take the xls files generated by ... | Perhaps ADO would suit? Here is a script example.
```
strXLToOpen = "C:\Docs\ltd.xls"
strXLToImport = "C:\Docs\ltd2.xls"
Set cn = CreateObject("ADODB.Connection")
''EDIT I not that MSDASQL is deprecated by Microsoft, so
''Please see below.
With cn
.Provider = "MSDASQL"
.ConnectionString = "Driver={Microsoft... |
339,146 | <p>I don't know why this bothers me so much, but when I create websites, I always try to do all my styling with CSS. However one thing I always have to remember to do when I'm working with tables is add cellspacing="0" and cellpadding="0"</p>
<p>Why is there not a CSS property to override these antiquated HTML 4 attr... | [
{
"answer_id": 339154,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 0,
"selected": false,
"text": "<pre><code>table { border-collapse:collapse; }\n</code></pre>\n"
},
{
"answer_id": 339164,
"author": "mat",
"a... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10420/"
] | I don't know why this bothers me so much, but when I create websites, I always try to do all my styling with CSS. However one thing I always have to remember to do when I'm working with tables is add cellspacing="0" and cellpadding="0"
Why is there not a CSS property to override these antiquated HTML 4 attributes? | [Cellspacing](http://www.w3schools.com/Css/pr_tab_border-collapse.asp) :
```
table { border-collapse: collapse; }
```
As for [cellpadding](http://www.w3schools.com/css/css_padding.asp), you can do
```
table tr td, table tr th { padding: 0; }
``` |
339,150 | <p>I have been banging my head on this one all day. The C++ project I am currently working on has a requirement to display an editable value. The currently selected digit displays the incremented value above and decremented value below for said digit. It is useful to be able to reference the editable value as both a... | [
{
"answer_id": 339161,
"author": "Loki",
"author_id": 39057,
"author_profile": "https://Stackoverflow.com/users/39057",
"pm_score": 4,
"selected": true,
"text": "<p>Internal representation of the float point numbers aren't like was you see. You can only cast to a stirng.</p>\n\n<p>To cas... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43028/"
] | I have been banging my head on this one all day. The C++ project I am currently working on has a requirement to display an editable value. The currently selected digit displays the incremented value above and decremented value below for said digit. It is useful to be able to reference the editable value as both a numbe... | Internal representation of the float point numbers aren't like was you see. You can only cast to a stirng.
To cast, do this:
```
char string[99];
sprintf(string,"%f",floatValue);
```
Or see this : <http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.1>
The wikipedia article can explain more on ... |
339,170 | <p>I have a client who had to rebuild his automated build server. He checked out his project folder from my subversion server but is now no longer able to commit - he gets this error:</p>
<pre><code>Error: Commit failed (details follow):
Error: Cannot write to the prototype revision file of transaction
'551-1' becau... | [
{
"answer_id": 339197,
"author": "DamianM",
"author_id": 30734,
"author_profile": "https://Stackoverflow.com/users/30734",
"pm_score": 1,
"selected": false,
"text": "<p>I haven't seen it, but going on the error message I'm guessing something has gotten stuck writing a file. I'd try resta... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9731/"
] | I have a client who had to rebuild his automated build server. He checked out his project folder from my subversion server but is now no longer able to commit - he gets this error:
```
Error: Commit failed (details follow):
Error: Cannot write to the prototype revision file of transaction
'551-1' because a
Error:... | You can clear this error w/out a reboot:
1. Identify (or create) a directory in the root SVN repository that was not a part of the failed commit.
2. Create a new file in the directory from step 1.
3. Commit the new file (and directory if created in step 1). Because the file is new, it doesn't conflict w/the previous c... |
339,172 | <p>Is there any possibility that GetPropInfo returns nil even if the given class is declared with correct {$METHODINFO} directives.</p>
<pre><code> type
...
...
{$METHODINFO ON}
TMyClass = class
private
fField: integer;
published
property Field: integer read fField write fField;
... | [
{
"answer_id": 339301,
"author": "utku_karatas",
"author_id": 14716,
"author_profile": "https://Stackoverflow.com/users/14716",
"pm_score": 4,
"selected": true,
"text": "<p>Gotcha! It seems the problem is hidden at the forward declaration that I overlooked. Didn't know that sneaky featur... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14716/"
] | Is there any possibility that GetPropInfo returns nil even if the given class is declared with correct {$METHODINFO} directives.
```
type
...
...
{$METHODINFO ON}
TMyClass = class
private
fField: integer;
published
property Field: integer read fField write fField;
end;
{$MET... | Gotcha! It seems the problem is hidden at the forward declaration that I overlooked. Didn't know that sneaky feature.
It seems the compiler considers only the first declaration of the class to generate RTTI or not so if you have a forward declaration like this...
```
type
TMyClass = class;
...
... |
339,180 | <p>I run all my integers through a <code>(int)Integer</code> to make them safe to use in my query strings.</p>
<p>I also run my strings through this function code:-</p>
<pre><code>if(!get_magic_quotes_gpc()) {
$string = mysql_real_escape_string($string);
}
$pattern = array("\\'", "\\\"", "\\\\", "... | [
{
"answer_id": 339187,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": -1,
"selected": false,
"text": "<p>On your second point:<br />\nIt is completely redundant, all the characters have been properly escaped if you run it thr... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] | I run all my integers through a `(int)Integer` to make them safe to use in my query strings.
I also run my strings through this function code:-
```
if(!get_magic_quotes_gpc()) {
$string = mysql_real_escape_string($string);
}
$pattern = array("\\'", "\\\"", "\\\\", "\\0");
$replace = array("", "", ... | yeah I think you've got things going a bit strangely there.
First of all, I'd check for magic quotes and *remove* the slashes if it's turned on. That way you've got a string which actually represents the information you want (and not one that has been treated with slashes).
If you particularly want to remove the % wi... |
339,181 | <p>In ruby, is there a way to "undefine" a variable or constant once it's been defined?</p>
<p>In our rails environemnts, we define one of three contants to be <code>true</code>, depending on the environment: <code>TESTING</code>, <code>DEVELOPMENT</code>, or <code>PRODUCTION</code>. Then, in controller code, we use ... | [
{
"answer_id": 339226,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 2,
"selected": false,
"text": "<p>Instead of checking each constant, why not do something like:</p>\n\n<pre><code>environment = :TESTING\n\nif(environ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/339181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41177/"
] | In ruby, is there a way to "undefine" a variable or constant once it's been defined?
In our rails environemnts, we define one of three contants to be `true`, depending on the environment: `TESTING`, `DEVELOPMENT`, or `PRODUCTION`. Then, in controller code, we use `defined?` to see if what environment we're in, ie: `de... | I found [this answer](http://www.ruby-forum.com/topic/2530)
```
Object.send(:remove_const, "TESTING")
```
If I remember correctly, using `send` here is kind of a hack, because remove\_const is really a private method. You want to ask yourself why you need to define constants PRODUCTION, DEVELOPMENT and TESTING at t... |
339,199 | <p>First, I know there are methods off of the generic <code>List<></code> class already in the framework do iterate over the <code>List<></code>.</p>
<p>But as an example, what is the correct syntax to write a ForEach method to iterate over each object of a <code>List<></code>, and do a <code>Console... | [
{
"answer_id": 339206,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 7,
"selected": true,
"text": "<pre><code>public void Each<T>(IEnumerable<T> items, Action<T> action)\n{\n foreach (var item in ite... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | First, I know there are methods off of the generic `List<>` class already in the framework do iterate over the `List<>`.
But as an example, what is the correct syntax to write a ForEach method to iterate over each object of a `List<>`, and do a `Console.WriteLine(object.ToString())` on each object.
Something that take... | ```
public void Each<T>(IEnumerable<T> items, Action<T> action)
{
foreach (var item in items)
action(item);
}
```
... and call it thusly:
```
Each(myList, i => Console.WriteLine(i));
``` |
339,202 | <p>I'm in the process of setting up a php project, but am not very familiar with how to properly use php's include/require commands. My layout currently looks like this:</p>
<pre><code>/public --apache points into this directory
/public/index.php
/public/blah/page.php
/utils/util1.php -- useful classes/... | [
{
"answer_id": 339219,
"author": "Rob Burke",
"author_id": 135,
"author_profile": "https://Stackoverflow.com/users/135",
"pm_score": -1,
"selected": false,
"text": "<p>Why not require it based on it's full path?</p>\n\n<p>For example, /sharedhost/yourdomain.com/apache/www is your documen... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/945/"
] | I'm in the process of setting up a php project, but am not very familiar with how to properly use php's include/require commands. My layout currently looks like this:
```
/public --apache points into this directory
/public/index.php
/public/blah/page.php
/utils/util1.php -- useful classes/code are stored... | Usually, the standard conventions are thus: like @grepsedawk said, you'll want to define a constant that contains the root of your project folder and if you can the root of your includes folder:
```
define('APP_ROOT', dirname(__FILE__));
define('INCLUDE_ROOT', APP_ROOT . "/includes");
```
Note: the constant name nee... |
339,210 | <p>[Meta-note:] I was browsing the question page, getting really tired of "DIVS vs Tables" "When to use tables vs DIVS" "Are Divs better than Tables" "Tables versus CSS" and all the questions that ask <em>THE SAME THING OMG PEOPLE</em> but I would like to see all the ways people tackle the translation of the canonical ... | [
{
"answer_id": 339229,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 5,
"selected": true,
"text": "<p>What I usually do is :</p>\n\n<pre><code><form>\n <label for=\"param_1\">Param 1</label>\n <input id=\"... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4435/"
] | [Meta-note:] I was browsing the question page, getting really tired of "DIVS vs Tables" "When to use tables vs DIVS" "Are Divs better than Tables" "Tables versus CSS" and all the questions that ask *THE SAME THING OMG PEOPLE* but I would like to see all the ways people tackle the translation of the canonical example of... | What I usually do is :
```
<form>
<label for="param_1">Param 1</label>
<input id="param_1" name="param_1"><br />
<label for="param_2">Param 2</label>
<input id="param_2" name="param_2"><br />
</form>
```
and in a CSS :
```
label,input { display: block; float: left; margin-bottom: 1ex; }
input { width: 20em; }
l... |
339,225 | <p>Does anyone know of a short cut to place my name and the date where the cursor is i.e.</p>
<pre><code> //021208 DarkAxi0m
</code></pre>
<p>so i don't keep check what the date is when i'm adding comments. </p>
<p>Im using Delphi7, with CnPack And GExperts Installed.
I think it should be able to be done with one of... | [
{
"answer_id": 339236,
"author": "Christopher Chase",
"author_id": 11016,
"author_profile": "https://Stackoverflow.com/users/11016",
"pm_score": 1,
"selected": false,
"text": "<p>Never mind found one in CnPack/Soure Templates\nAdded the template</p>\n\n<pre><code> //%Date% DarkAxi0m\n</... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11016/"
] | Does anyone know of a short cut to place my name and the date where the cursor is i.e.
```
//021208 DarkAxi0m
```
so i don't keep check what the date is when i'm adding comments.
Im using Delphi7, with CnPack And GExperts Installed.
I think it should be able to be done with one of those experts. | I use GExperts to do this, like so:
in the
GExperts\Configuration
Select the Editor Experts tab.
In the list of experts, select
Insert Date\Time
Click on the configuration, insert the desired text:
'//' ddmmyy 'DarkAxi0m: '
//021208 DarkAxi0m:
After, to insert your new Date name comment all you need to do is:... |
339,228 | <p>Excel macros do not seem to allow the use of "undo" after running them. Is there any way to bake <code>undo</code> functionality into a VBA macro in Excel?</p>
| [
{
"answer_id": 339239,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "<p>I always save immediately before running my macros (during testing at least) then, if everything goes pear-shaped, I ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Excel macros do not seem to allow the use of "undo" after running them. Is there any way to bake `undo` functionality into a VBA macro in Excel? | Excel VBA has the `Application.OnUndo` function to handle this:
```
Public Sub DoSomething
... do stuff here
Application.OnUndo "Undo something", "UnDoSomething"
End Sub
Public Sub UnDoSomething
... reverse the action here
End Sub
``` |
339,230 | <p>I'm trying to figure out what would be the simplest way to validate required fields without having to do an if statement for each element's name. Perhaps just with a loop and verify its class.</p>
<p>What I'm trying to accomplish is to check only the ones that have the class name as "required"</p>
<pre><code><i... | [
{
"answer_id": 339237,
"author": "Ricardo Acras",
"author_id": 19224,
"author_profile": "https://Stackoverflow.com/users/19224",
"pm_score": 0,
"selected": false,
"text": "<p>I would recommend you to use <a href=\"http://www.openjs.com/scripts/dom/css_selector/\" rel=\"nofollow noreferre... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to figure out what would be the simplest way to validate required fields without having to do an if statement for each element's name. Perhaps just with a loop and verify its class.
What I'm trying to accomplish is to check only the ones that have the class name as "required"
```
<input name="a1" class="re... | I'm not at all against the libraries suggested by others, but I thought that you may want some samples of how you could do it on your own, I hope it helps.
This should work:
```
function validate() {
var inputs = document.getElementsByTagName("input");
for (inputName in inputs) {
if (inputs[inputName... |
339,231 | <p>If I have something like a loop or a set of if/else statements, and I want to return a value from within the nest (see below), is the best way of doing this to assign the value to a field or property and return that?</p>
<p>See below:</p>
<pre><code>bool b;
public bool ifelse(int i)
{
if(i == 5)
{
b = true;
}
el... | [
{
"answer_id": 339241,
"author": "gcores",
"author_id": 40256,
"author_profile": "https://Stackoverflow.com/users/40256",
"pm_score": 3,
"selected": false,
"text": "<p>what about</p>\n\n<pre><code>return i == 5;\n</code></pre>\n"
},
{
"answer_id": 339242,
"author": "DaEagle",... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | If I have something like a loop or a set of if/else statements, and I want to return a value from within the nest (see below), is the best way of doing this to assign the value to a field or property and return that?
See below:
```
bool b;
public bool ifelse(int i)
{
if(i == 5)
{
b = true;
}
else
{
b = false;
}
ret... | Yes, that is good style.
The alternative (which would be **bad**) would be to do this:
```
public bool ifelse(int i)
{
if(i == 5)
{
return true;
}
else
{
return false;
}
}
```
The reason multiple return points are regarded as bad style is that especially for larger m... |
339,245 | <p>Sorry for the bad title, but I couldn't think of a better one.</p>
<p>I'm having a class A and a class B which is kind of a sub class of A, like so:</p>
<p>(Is there actually a correct name for it? Isn't "sub class" reserved for inheritance?)</p>
<pre><code>class A {
int i = 0;
class B {
int j = 1... | [
{
"answer_id": 339267,
"author": "Juliet",
"author_id": 40516,
"author_profile": "https://Stackoverflow.com/users/40516",
"pm_score": 2,
"selected": false,
"text": "<p>[Edit: My answer is appropriate for C# programmers, but I can't guarantee that its applicable to Java.]</p>\n\n<p>B is a... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36253/"
] | Sorry for the bad title, but I couldn't think of a better one.
I'm having a class A and a class B which is kind of a sub class of A, like so:
(Is there actually a correct name for it? Isn't "sub class" reserved for inheritance?)
```
class A {
int i = 0;
class B {
int j = 1;
}
}
class Test {
... | There doesn't seem to be a way to access the outer class from outside. But you can do it like this:
```
class A {
int i = 0;
class B {
final A outer = A.this;
int j = 1;
}
}
class Test {
public static void main() {
A a = new A();
A.B b = a.new B();
A c = b.outer... |
339,262 | <p>Given a NxN matrix with 0s and 1s. Set every row that contains a <code>0</code> to all <code>0</code>s and set every column that contains a <code>0</code> to all <code>0</code>s.</p>
<p>For example</p>
<pre><code>1 0 1 1 0
0 1 1 1 0
1 1 1 1 1
1 0 1 1 1
1 1 1 1 1
</code></pre>
<p>results in</p>
<pre><code>0 0 0 0... | [
{
"answer_id": 339294,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 2,
"selected": false,
"text": "<p>I can do it with two integer variables and two passes (up to 32 rows and columns...)</p>\n\n<pre><code>bool matrix[5][5]... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20915/"
] | Given a NxN matrix with 0s and 1s. Set every row that contains a `0` to all `0`s and set every column that contains a `0` to all `0`s.
For example
```
1 0 1 1 0
0 1 1 1 0
1 1 1 1 1
1 0 1 1 1
1 1 1 1 1
```
results in
```
0 0 0 0 0
0 0 0 0 0
0 0 1 1 0
0 0 0 0 0
0 0 1 1 0
```
A Microsoft Engineer told me that there... | Ok, so I'm tired as it's 3AM here, but I have a first try inplace with exactly 2 passes on each number in the matrix, so in O(NxN) and it is linear in the size of the matrix.
I use 1rst column and first row as markers to know where are rows/cols with only 1's. Then, there are 2 variables l and c to remember if 1rst ro... |
339,266 | <p>I'm trying to make a calculator that will take inputs from users and estimate for them how much money they'll save if they use various different VoIP services.</p>
<p>I've set it up like this:</p>
<pre><code><form method="get" action="voip_calculator.php">
How much is your monthly phone bill?
<inpu... | [
{
"answer_id": 339298,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": true,
"text": "<p>You need to get the value from the QueryString and put it into a PHP variable.</p>\n\n<p>Like this:</p>\n\n<pre><code>$month... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43035/"
] | I'm trying to make a calculator that will take inputs from users and estimate for them how much money they'll save if they use various different VoIP services.
I've set it up like this:
```
<form method="get" action="voip_calculator.php">
How much is your monthly phone bill?
<input name="monthlybill" type="tex... | You need to get the value from the QueryString and put it into a PHP variable.
Like this:
```
$monthlyBill = $_GET['monthlybill'];
```
Now the variable $monthlyBill contains the value from the QueryString.
To display it:
```
echo "Your monthly bill is: $monthlyBill";
``` |
339,269 | <p>Here is the current architecture of my transaction scope source code. The third insert throws an .NET exception (Not a SQL Exception) and it is not rolling back the two previous insert statements. What I am doing wrong?</p>
<p><b>EDIT:</b> I removed the try/catch from insert2 and insert3. I also removed the exc... | [
{
"answer_id": 339282,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": false,
"text": "<p>It looks like you are catching the exception in Insert3() so your code continues after the call. If you want it to ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] | Here is the current architecture of my transaction scope source code. The third insert throws an .NET exception (Not a SQL Exception) and it is not rolling back the two previous insert statements. What I am doing wrong?
**EDIT:** I removed the try/catch from insert2 and insert3. I also removed the exception handling u... | I have also run into a similar issue. My problem occurred because the SqlConnection I used in my SqlCommands was already open before the TransactionScope was created, so it never got enlisted in the TransactionScope as a transaction.
Is it possible that the SqlHelper class is reusing an instance of SqlConnection that ... |
339,286 | <p>I'm looking for an XML editor that lets me type and copy and paste arbitrary text into an XML element or attribute without requiring me to go back through and escape any characters that must use reserved XML entities (ampersands, angle brackets, or quote marks). XMLSpy came up short.</p>
| [
{
"answer_id": 339309,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 0,
"selected": false,
"text": "<p>You could use <a href=\"http://notepad-plus.sourceforge.net/uk/site.htm\" rel=\"nofollow noreferrer\">Notepad++</a> ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm looking for an XML editor that lets me type and copy and paste arbitrary text into an XML element or attribute without requiring me to go back through and escape any characters that must use reserved XML entities (ampersands, angle brackets, or quote marks). XMLSpy came up short. | Do you really expect the editor to know that when you paste `a<b` it should escape the `<` , but when you paste `a<b/>` it shouldn't? Seems like a tall order...
Having thought about this for a bit, I think that what you want can be achieved, either through a **separate** "Special Paste" command, or a special editor mo... |
339,296 | <p>Greetings!</p>
<p>I have some XML like this:</p>
<pre><code><Root>
<AlphaSection>
.
.
.
</AlphaSection>
<BetaSection>
<Choices>
<SetA>
<Choice id="choice1">
<Title>Choice 1 Title</Tit... | [
{
"answer_id": 339338,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": true,
"text": "<pre><code>element => new {\n ID = element.Attribute(\"id\").Value,\n Title = element.Element(\"... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27870/"
] | Greetings!
I have some XML like this:
```
<Root>
<AlphaSection>
.
.
.
</AlphaSection>
<BetaSection>
<Choices>
<SetA>
<Choice id="choice1">
<Title>Choice 1 Title</Title>
<Body>Choice 1 Body</Body>
</Cho... | ```
element => new {
ID = element.Attribute("id").Value,
Title = element.Element("Title").Value,
Body = element.Element("Body").Value
});
``` |
339,314 | <p>I am working on a ASP.net project created with local file system settings. I am using MVC and Jquery. Jquery is working fine when I run the application in debug mode i.e. in ASP.net Development server. I am trying to host the application in IIS 7. In hosted mode, it does not recognize Jquery and gives scripting erro... | [
{
"answer_id": 339318,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 0,
"selected": false,
"text": "<p>This usually occurs when you have malformed HTML or JavaScript.</p>\n"
},
{
"answer_id": 339319,
"autho... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43049/"
] | I am working on a ASP.net project created with local file system settings. I am using MVC and Jquery. Jquery is working fine when I run the application in debug mode i.e. in ASP.net Development server. I am trying to host the application in IIS 7. In hosted mode, it does not recognize Jquery and gives scripting error '... | Try using Firebug 'Net' tab to see if the file gets loaded.
You can also configure Firebug to fail on all errors and see when the error happens as compared to when jQuery gets loaded. |
339,353 | <p>How best can I convert instances of double backslashes to a single backslash in a string, but remove any occurrences of single backslash?</p>
<p>So this:</p>
<pre>
\|Testing|ABC:1234\\1000-1\|
</pre>
<p>Should convert to this:</p>
<pre>
|Testing|ABC:1234\1000-1|
</pre>
<p>Ideally I want to avoid a temporary rep... | [
{
"answer_id": 339369,
"author": "Juliet",
"author_id": 40516,
"author_profile": "https://Stackoverflow.com/users/40516",
"pm_score": 4,
"selected": true,
"text": "<pre><code>Regex.Replace(input, @\"\\\\(.|$)\", \"$1\");\n</code></pre>\n\n<p>[Edit: Pattern didn't match all possible cases... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41211/"
] | How best can I convert instances of double backslashes to a single backslash in a string, but remove any occurrences of single backslash?
So this:
```
\|Testing|ABC:1234\\1000-1\|
```
Should convert to this:
```
|Testing|ABC:1234\1000-1|
```
Ideally I want to avoid a temporary replace of '\' to another charact... | ```
Regex.Replace(input, @"\\(.|$)", "$1");
```
[Edit: Pattern didn't match all possible cases specified in the OP. Thanks for the suggestions, GONeale and Alan M.] |
339,370 | <p>This question is simple. What function would I use in a PHP script to load data from a URL into a string?</p>
| [
{
"answer_id": 339381,
"author": "ehassler",
"author_id": 38019,
"author_profile": "https://Stackoverflow.com/users/38019",
"pm_score": 2,
"selected": false,
"text": "<p>With file wrappers you can use file_get_contents to access http resources (pretty much just GET requests, no POST). F... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26659/"
] | This question is simple. What function would I use in a PHP script to load data from a URL into a string? | CURL is usually a good solution: <http://www.php.net/curl>
```
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// grab URL and pass... |
339,371 | <p>I have this method in my db class</p>
<pre><code>public function query($queryString)
{
if (!$this->_connected) $this->_connectToDb(); //connect to database
$results = mysql_query($queryString, $this->_dbLink) or trigger_error(mysql_error());
return mysql_num_rows($results) > 0 ?... | [
{
"answer_id": 339384,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 3,
"selected": true,
"text": "<pre><code>public function query($queryString)\n {\n\n if (!$this->_connected) $this->_connectToDb(); //conne... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] | I have this method in my db class
```
public function query($queryString)
{
if (!$this->_connected) $this->_connectToDb(); //connect to database
$results = mysql_query($queryString, $this->_dbLink) or trigger_error(mysql_error());
return mysql_num_rows($results) > 0 ? mysql_fetch_assoc($result... | ```
public function query($queryString)
{
if (!$this->_connected) $this->_connectToDb(); //connect to database
$results = mysql_query($queryString, $this->_dbLink) or trigger_error(mysql_error());
$data = array();
while($row = mysql_fetch_assoc($results))
{
... |
339,387 | <p>I'm trying to validate that a submitted URL doesn't already exist in the database.</p>
<p>The relevant parts of the Form class look like this:</p>
<pre><code>from django.contrib.sites.models import Site
class SignUpForm(forms.Form):
# ... Other fields ...
url = forms.URLField(label='URL for new site, eg: e... | [
{
"answer_id": 339463,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "<p>I do it this way. It's slightly simpler.</p>\n\n<pre><code>try:\n a = Site.objects.get(domain=url)\n raise forms.... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3912/"
] | I'm trying to validate that a submitted URL doesn't already exist in the database.
The relevant parts of the Form class look like this:
```
from django.contrib.sites.models import Site
class SignUpForm(forms.Form):
# ... Other fields ...
url = forms.URLField(label='URL for new site, eg: example.com')
def... | django channel in IRC saved me here. The problem was that the URLField.clean() does two things I wasn't expecting:
1. If no URL scheme is present (eg, http://) the method prepends 'http://' to the url
2. the method also appends a trailing slash.
The results are returned and stored in the form's cleaned\_data. So I wa... |
339,397 | <p>I'm coming from a C# background and I really like the type inference that C# 3.0 has. I'm trying to do similar things in VB.NET (some of which appear possible), but in some cases the compiler seems to be not nearly as good at inferring the type.</p>
<p>For example, I have a method that returns an object of type S... | [
{
"answer_id": 339401,
"author": "J Cooper",
"author_id": 38803,
"author_profile": "https://Stackoverflow.com/users/38803",
"pm_score": 2,
"selected": false,
"text": "<p>I'm assuming by \"played with the VB.NET project settings\" you mean you already did this: <a href=\"http://www.emadib... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11807/"
] | I'm coming from a C# background and I really like the type inference that C# 3.0 has. I'm trying to do similar things in VB.NET (some of which appear possible), but in some cases the compiler seems to be not nearly as good at inferring the type.
For example, I have a method that returns an object of type System.Guid. ... | You mention below that you're trying to do this in a static variable declaration. That won't work in C#, and will give you Object in VB.NET (for instance and statics). |
339,409 | <p>I have a problem where I want to read an object from the database using Hibernate, change a value, and save the object. If changing the value takes some time, what's the best way to ensure the underlying object in the database has not changed? I am doing this in one transaction (and one session). </p>
<p>The code l... | [
{
"answer_id": 339449,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 0,
"selected": false,
"text": "<p>You can use pessimistic lock although I wouldn't do that, but it may be useful in your case.</p>\n\n<p>Since your obje... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43067/"
] | I have a problem where I want to read an object from the database using Hibernate, change a value, and save the object. If changing the value takes some time, what's the best way to ensure the underlying object in the database has not changed? I am doing this in one transaction (and one session).
The code looks somet... | I'd recommend optimistic locking instead. you add a "version" property to your object and then hibernate does an update operation at the end and verifies that the version has not changed since you read the object. generally a much better design than pessimistic locking (nothing like finding those db deadlocks!).
Of co... |
339,424 | <p>I'm a pretty experienced Grails developer, but most of my experience has been with using grails for serving up JSON/XML to a flex app and some relatively simple HTML websites.</p>
<p>I've been diving deeper into using the sitemesh integration in grails and I'm struggling a little to find best practices for some mor... | [
{
"answer_id": 343027,
"author": "billjamesdev",
"author_id": 13824,
"author_profile": "https://Stackoverflow.com/users/13824",
"pm_score": 5,
"selected": true,
"text": "<p>Well, I can answer a bit:</p>\n\n<p>Your first and third questions are related, as you can't chain layouts using th... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8912/"
] | I'm a pretty experienced Grails developer, but most of my experience has been with using grails for serving up JSON/XML to a flex app and some relatively simple HTML websites.
I've been diving deeper into using the sitemesh integration in grails and I'm struggling a little to find best practices for some more complex ... | Well, I can answer a bit:
Your first and third questions are related, as you can't chain layouts using the meta tag.
Your final page should have a meta tag as you suggest, but if you want to layer a layout on top of another layout, you put a g:applyLayout tag at the top of the child layout, pointing at the parent.
I... |
339,429 | <p>Is there an SSH client that can present a client side GUI interface to the <a href="http://www.cyberciti.biz/tips/how-to-use-screen-command-under-linux.html" rel="nofollow noreferrer">screen</a>* program?</p>
<p>I'm thinking of an SSH program that would hook in with screen's session handling and map client side act... | [
{
"answer_id": 339509,
"author": "Mikeage",
"author_id": 41308,
"author_profile": "https://Stackoverflow.com/users/41308",
"pm_score": 0,
"selected": false,
"text": "<p>I've never seen one, but the following may help you. Add to your .screenrc</p>\n\n<p>To show a row of \"tabs\" on the b... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | Is there an SSH client that can present a client side GUI interface to the [screen](http://www.cyberciti.biz/tips/how-to-use-screen-command-under-linux.html)\* program?
I'm thinking of an SSH program that would hook in with screen's session handling and map client side actions (clicking on a tab, ctrl-tab, scrolling, ... | An interesting idea, and quite possible (vim7's tabs show as clicky GUI tabs in gnome-terminal), but I don't see the benefit of doing this..
Using the follow `~/.screenrc` shows "graphical" tabs:
```
startup_message off
vbell off
hardstatus alwayslastline
hardstatus string '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR... |
339,455 | <p>When I include an image as an <img> tag as well as a background image on a DOM element, the browser sometimes makes two requests for the same image. This also sometimes happens when using the hover pseudo-property. For example:</p>
<pre><code><html>
<head>
<style>
div{
backgrou... | [
{
"answer_id": 339458,
"author": "Ryan Smith",
"author_id": 10420,
"author_profile": "https://Stackoverflow.com/users/10420",
"pm_score": 0,
"selected": false,
"text": "<p>It seems like this would be a browser caching issue to me.</p>\n\n<p>You could try preloading it like:</p>\n\n<pre><... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/208/"
] | When I include an image as an <img> tag as well as a background image on a DOM element, the browser sometimes makes two requests for the same image. This also sometimes happens when using the hover pseudo-property. For example:
```
<html>
<head>
<style>
div{
background: transparent url(/img/stuff.png) no-r... | This is a known problem with IE6, is that the browser you're having problems with?
There are several causes and fixes listed here:
<http://www.fivesevensix.com/studies/ie6flicker/> |
339,469 | <p>I'm using MS Access to create a database with over 5000 contacts. These contacts are separated up into which employee the contact belongs to, and then again into categories for easy searching. What I want to do is create a button that will open up a query in table form (simple), then have check boxes so an employee ... | [
{
"answer_id": 339511,
"author": "Kevin Tighe",
"author_id": 39461,
"author_profile": "https://Stackoverflow.com/users/39461",
"pm_score": 0,
"selected": false,
"text": "<p>I think you're going to need to learn some VBA coding to get this done. This <a href=\"http://www.functionx.com/vb... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using MS Access to create a database with over 5000 contacts. These contacts are separated up into which employee the contact belongs to, and then again into categories for easy searching. What I want to do is create a button that will open up a query in table form (simple), then have check boxes so an employee can... | I have just created the following **working** example in MS Access 97.
A sample table (I tested the code with valid e-mail addresses):
ID Name Email
1 Rics rics@stack.com
2 Kate kate@stack.com
3 X x@stack.com
A form with one button.
The following code is being performed when the button is clicked:
```
Private S... |