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 |
|---|---|---|---|---|---|---|
414,138 | <p>I need to filter result sets from sql server based on selections from a multi-select list box. I've been through the idea of doing an instring to determine if the row value exists in the selected filter values, but that's prone to partial matches (e.g. Car matches Carpet). </p>
<p>I also went through splitting the ... | [
{
"answer_id": 414212,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 3,
"selected": true,
"text": "<p>I solved this one by writing a table-valued function (we're using 2005) which takes a delimited string and returns a t... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28926/"
] | I need to filter result sets from sql server based on selections from a multi-select list box. I've been through the idea of doing an instring to determine if the row value exists in the selected filter values, but that's prone to partial matches (e.g. Car matches Carpet).
I also went through splitting the string int... | I solved this one by writing a table-valued function (we're using 2005) which takes a delimited string and returns a table. You can then join to that or use WHERE EXISTS or WHERE x IN. We haven't done full stress testing yet, but with limited use and reasonably small sets of items I think that performance should be ok.... |
414,164 | <p>I have a directory with about 2000 files. How can I select a random sample of <code>N</code> files through using either a bash script or a list of piped commands?</p>
| [
{
"answer_id": 414316,
"author": "Josh Lee",
"author_id": 19750,
"author_profile": "https://Stackoverflow.com/users/19750",
"pm_score": 9,
"selected": true,
"text": "<p>Here's a script that uses GNU sort's random option:</p>\n\n<pre><code>ls |sort -R |tail -$N |while read file; do\n #... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8330/"
] | I have a directory with about 2000 files. How can I select a random sample of `N` files through using either a bash script or a list of piped commands? | Here's a script that uses GNU sort's random option:
```
ls |sort -R |tail -$N |while read file; do
# Something involving $file, or you can leave
# off the while to just get the filenames
done
``` |
414,166 | <p>I was taking a look at <a href="http://www.zenfolio.com/zf/features.aspx" rel="nofollow noreferrer">http://www.zenfolio.com/zf/features.aspx</a> and I can't figure out how they are doing the accordion style expand and collapse when you click on the orange links. I have been using the Web Developer Toolbar add-on fo... | [
{
"answer_id": 414192,
"author": "EdgarVerona",
"author_id": 3068,
"author_profile": "https://Stackoverflow.com/users/3068",
"pm_score": 3,
"selected": true,
"text": "<p>They're setting the .display CSS property on an internal DIV from 'none' to '', which renders it.</p>\n\n<p>It's a bit... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] | I was taking a look at <http://www.zenfolio.com/zf/features.aspx> and I can't figure out how they are doing the accordion style expand and collapse when you click on the orange links. I have been using the Web Developer Toolbar add-on for firefox, but I have not been able to find anything in the source of the page like... | They're setting the .display CSS property on an internal DIV from 'none' to '', which renders it.
It's a bit tricky, as the JS seems to be in here that's doing it:
<http://www.zenfolio.com/zf/script/en-US/mozilla5/windows/5AN2EHZJSZSGS/sitehome.js>
But that's basically how everyone does this. It's in there, somewher... |
414,176 | <p>One advantage of lambda expressions is that you have to evaluate a function only when you need its result.</p>
<p>In the following (simple) example, the text function is only evaluated when a writer is present:</p>
<pre><code>public static void PrintLine(Func<string> text, TextWriter writer)
{
if (writer... | [
{
"answer_id": 414185,
"author": "Yuliy",
"author_id": 47527,
"author_profile": "https://Stackoverflow.com/users/47527",
"pm_score": 1,
"selected": false,
"text": "<p>Well those two statements are completely different. One is defining a function, while the other is a statement. Confusing... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48722/"
] | One advantage of lambda expressions is that you have to evaluate a function only when you need its result.
In the following (simple) example, the text function is only evaluated when a writer is present:
```
public static void PrintLine(Func<string> text, TextWriter writer)
{
if (writer != null)
{
wri... | The compiler is very good at inferring *types*, it is not good at inferring *intent*. One of the tricky things about all the new syntactic sugar in C# 3 is that they can lead to confusion as to what exactly the compiler does with them.
Consider your example:
```
() => "SomeText"
```
The compiler sees this and under... |
414,179 | <p>Not sure this is a programming question, but we use LaTeX for all our API documentation and user documentation, so I hope it will go through.</p>
<p>Can someone please explain what are the relative merits of using <code>pdflatex</code> as opposed to the "classic" technique of</p>
<pre><code>latex foo
dvips -Ppdf f... | [
{
"answer_id": 414252,
"author": "Josh Lee",
"author_id": 19750,
"author_profile": "https://Stackoverflow.com/users/19750",
"pm_score": 5,
"selected": true,
"text": "<p>My favorite pdflatex feature is the <a href=\"http://www.ctan.org/tex-archive/macros/latex/contrib/microtype/\" rel=\"n... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41661/"
] | Not sure this is a programming question, but we use LaTeX for all our API documentation and user documentation, so I hope it will go through.
Can someone please explain what are the relative merits of using `pdflatex` as opposed to the "classic" technique of
```
latex foo
dvips -Ppdf foo
ps2pdf foo.ps
```
From time... | My favorite pdflatex feature is the [microtype package](http://www.ctan.org/tex-archive/macros/latex/contrib/microtype/), which is available only when using pdflatex to go directly to PDF, and really produces stunning results with no effort on my part. Apart from that, the only caveats I run into are image formats:
* ... |
414,191 | <p>Most things I've wanted to do in LaTeX have either been straight-forward, or easily found on the web, but this one has been stumping me.</p>
<p>I have a macro 'solution': to apply some common formatting to each solution:</p>
<pre><code>\newcommand\solution[1]{{\\ \\* \bf Solution.}#1\qed \newpage}
</code></pre>
<... | [
{
"answer_id": 414394,
"author": "Jouni K. Seppänen",
"author_id": 26575,
"author_profile": "https://Stackoverflow.com/users/26575",
"pm_score": 2,
"selected": false,
"text": "<p>This is a <a href=\"http://www.tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin\" rel=\"nofollow noreferrer\">F... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24700/"
] | Most things I've wanted to do in LaTeX have either been straight-forward, or easily found on the web, but this one has been stumping me.
I have a macro 'solution': to apply some common formatting to each solution:
```
\newcommand\solution[1]{{\\ \\* \bf Solution.}#1\qed \newpage}
```
Which has worked nicely so far,... | You could try changing `\newcommand` to `\newenvironment` and then use something like
```
\begin{solution}
\begin{verbatim}
[ascii art here]
\end{verbatim}
\end{solution}
``` |
414,207 | <p>I'm wondering what would be the best prectice regarding mainataining connections to the database in .Net application (ADO.NET but I guess the practice should be the same for any data layer). Should I create a database connection and propagate it throughout my application, or would it be better to just pass connectio... | [
{
"answer_id": 414216,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "<p>ADO.NET SQL Server provider does the connection pooling itself. You can control the pool size by <code>MinPoolSize</code> a... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51765/"
] | I'm wondering what would be the best prectice regarding mainataining connections to the database in .Net application (ADO.NET but I guess the practice should be the same for any data layer). Should I create a database connection and propagate it throughout my application, or would it be better to just pass connection s... | I found myself needing to pass around a connection object so I could allow several business objects to save themselves to the database inside a single transaction.
If each business object had to create its own SQLConnection to the database, the transaction would escalate to a distributed transaction and I wanted to av... |
414,210 | <p>In my output, I get</p>
<p>@{ActiveSyncEnabled=False}</p>
<p>how do I parse this so that it just says "False"?</p>
<p>the output is coming from this line of code: </p>
<pre><code> $pda = get-casmailbox -Anr $user.displayname | select activesyncenabled
</code></pre>
| [
{
"answer_id": 414344,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 1,
"selected": true,
"text": "<p>I don't have access to an exchange box right now, but the information should be there now for someone that does. Here is w... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] | In my output, I get
@{ActiveSyncEnabled=False}
how do I parse this so that it just says "False"?
the output is coming from this line of code:
```
$pda = get-casmailbox -Anr $user.displayname | select activesyncenabled
``` | I don't have access to an exchange box right now, but the information should be there now for someone that does. Here is what worked:
$pda = get-casmailbox -Anr $user.displayname | select activesyncenabled
$pda.ActiveSyncEnabled | Write-Host |
414,222 | <p>If I have a table that (among other columns) has two DATETIME columns, how would I select the <strong>most recent</strong> date from those two columns.</p>
<p>Example:</p>
<pre><code>ID Date1 Date2
1 1/1/2008 2/1/2008
2 2/1/2008 1/1/2008
3 1/10/2008 1/10/2008
</code></pre>
<p>If I w... | [
{
"answer_id": 414232,
"author": "Rockcoder",
"author_id": 5290,
"author_profile": "https://Stackoverflow.com/users/5290",
"pm_score": 7,
"selected": true,
"text": "<p>CASE is IMHO your best option:</p>\n\n<pre><code>SELECT ID,\n CASE WHEN Date1 > Date2 THEN Date1\n E... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22164/"
] | If I have a table that (among other columns) has two DATETIME columns, how would I select the **most recent** date from those two columns.
Example:
```
ID Date1 Date2
1 1/1/2008 2/1/2008
2 2/1/2008 1/1/2008
3 1/10/2008 1/10/2008
```
If I wanted my results to look like
```
ID Mos... | CASE is IMHO your best option:
```
SELECT ID,
CASE WHEN Date1 > Date2 THEN Date1
ELSE Date2
END AS MostRecentDate
FROM Table
```
---
If one of the columns is nullable just need to enclose in [`COALESCE`](https://learn.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql):
... |
414,230 | <p>I wrote this tiny Python snippet that scrapes a feed and prints it out. When I run the code, something in the feed triggers the error message you see here as my question. Here's the complete console output on error:</p>
<pre><code>> Traceback (most recent call last):
> File "/home/vijay/ffour/ffour5.py",
&g... | [
{
"answer_id": 414239,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": false,
"text": "<blockquote>\n<pre><code>> sys.stdout.write(entry[\"title\"]).encode('utf-8')\n</code></pre>\n</blockquote>\n\n<p>... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I wrote this tiny Python snippet that scrapes a feed and prints it out. When I run the code, something in the feed triggers the error message you see here as my question. Here's the complete console output on error:
```
> Traceback (most recent call last):
> File "/home/vijay/ffour/ffour5.py",
> line 20, in <module>... | >
>
> ```
> > sys.stdout.write(entry["title"]).encode('utf-8')
>
> ```
>
>
This is the culprit. You probably mean:
```
sys.stdout.write(entry["title"].encode('utf-8'))
```
(Notice the position of the last closing bracket.) |
414,243 | <p>C++ does not have native support for lazy evaluation (as Haskell does).</p>
<p>I'm wondering if it is possible to implement lazy evaluation in C++ in a reasonable manner. If yes, how would you do it?</p>
<p>EDIT: I like Konrad Rudolph's answer.</p>
<p>I'm wondering if it's possible to implement it in a more gener... | [
{
"answer_id": 414248,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "<p>As it's going to be done in <a href=\"http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions\" rel=\"nofol... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51568/"
] | C++ does not have native support for lazy evaluation (as Haskell does).
I'm wondering if it is possible to implement lazy evaluation in C++ in a reasonable manner. If yes, how would you do it?
EDIT: I like Konrad Rudolph's answer.
I'm wondering if it's possible to implement it in a more generic fashion, for example ... | >
> I'm wondering if it is possible to implement lazy evaluation in C++ in a reasonable manner. If yes, how would you do it?
>
>
>
Yes, this is possible and quite often done, e.g. for matrix calculations. The main mechanism to facilitate this is operator overloading. Consider the case of matrix addition. The signa... |
414,264 | <p>Suppose I have a method </p>
<pre><code>public Patient(int id)
{
----
}
</code></pre>
<p>that returns Patient object given an id.. I could define contract in 2 ways</p>
<ol>
<li>Method would return null if patient does not exist</li>
<li>Method would throw an exception if patient does not exist. In this case ... | [
{
"answer_id": 414281,
"author": "Chris Shaffer",
"author_id": 6744,
"author_profile": "https://Stackoverflow.com/users/6744",
"pm_score": 2,
"selected": false,
"text": "<p>Another option would be the <a href=\"http://en.wikipedia.org/wiki/Null_Object_pattern\" rel=\"nofollow noreferrer\... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30917/"
] | Suppose I have a method
```
public Patient(int id)
{
----
}
```
that returns Patient object given an id.. I could define contract in 2 ways
1. Method would return null if patient does not exist
2. Method would throw an exception if patient does not exist. In this case I would also define a query method that re... | Keep in mind that going "over the wire" to another tier (whether a database or an application server) is one of the most expensive activities you can do - typically a network call will take several orders of magnitude longer than in-memory calls.
It's therefore worth while structuring your API to avoid redundant calls... |
414,267 | <p>Where would you place the SaveSettings method in your project when the user is done editing any settings on the Settings dialog in your program?</p>
<p>Should it be in the return like:</p>
<pre><code> using (frmSettings frmSettings = new frmSettings())
{
if (frmSettings.ShowDialog() == D... | [
{
"answer_id": 414271,
"author": "EdgarVerona",
"author_id": 3068,
"author_profile": "https://Stackoverflow.com/users/3068",
"pm_score": 3,
"selected": true,
"text": "<pre><code>// clicked OK, should I call SaveSettings() here? \n</code></pre>\n\n<p>That seems like a good place. =)</p>\n... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Where would you place the SaveSettings method in your project when the user is done editing any settings on the Settings dialog in your program?
Should it be in the return like:
```
using (frmSettings frmSettings = new frmSettings())
{
if (frmSettings.ShowDialog() == DialogResult.OK)
... | ```
// clicked OK, should I call SaveSettings() here?
```
That seems like a good place. =)
EDIT: I suppose it depends on the framework of the application, but there's nothing wrong with putting it there. It's a logical (by all definitions of logic) place to put it. |
414,276 | <p>I want to limit a report to return records from Date A through Date B. This is what I have been doing:</p>
<pre><code>declare @startDate varchar(20)
declare @endDate varchar(20)
set @startDate = '01/01/2008'
set @endDate = '04/01/2008'
-- test what are the start and end dates
select min(date),max(date) from view_In... | [
{
"answer_id": 414286,
"author": "Rowland Shaw",
"author_id": 50447,
"author_profile": "https://Stackoverflow.com/users/50447",
"pm_score": 4,
"selected": true,
"text": "<p>There's always the easy option:</p>\n\n<pre><code>declare @startDate varchar(20)\ndeclare @endDate varchar(20)\nset... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26198/"
] | I want to limit a report to return records from Date A through Date B. This is what I have been doing:
```
declare @startDate varchar(20)
declare @endDate varchar(20)
set @startDate = '01/01/2008'
set @endDate = '04/01/2008'
-- test what are the start and end dates
select min(date),max(date) from view_Inspections
whe... | There's always the easy option:
```
declare @startDate varchar(20)
declare @endDate varchar(20)
set @startDate = '01/01/2008'
set @endDate = '04/01/2008'
-- test what are the start and end dates
select min(date),max(date) from view_Inspections
where date >= @startDate
and date < @endDate
``` |
414,290 | <p>How do I do sorting when generating anonymous types in linq to sql?</p>
<p>Ex:</p>
<pre><code>from e in linq0
order by User descending /* ??? */
select new
{
Id = e.Id,
CommentText = e.CommentText,
UserId = e.UserId,
User = (e.User.FirstName + " " + e.User.LastName).Trim()),
Date = string.Format("{0... | [
{
"answer_id": 414297,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 3,
"selected": false,
"text": "<p>If I've understood your question correctly, you want to do this:</p>\n\n<pre><code>from e in linq0\norder by (e.User.FirstN... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40939/"
] | How do I do sorting when generating anonymous types in linq to sql?
Ex:
```
from e in linq0
order by User descending /* ??? */
select new
{
Id = e.Id,
CommentText = e.CommentText,
UserId = e.UserId,
User = (e.User.FirstName + " " + e.User.LastName).Trim()),
Date = string.Format("{0:d}", e.Date)
}
``` | If you're using LINQ to Objects, I'd do this:
```
var query = from e in linq0
select new
{
Id = e.Id,
CommentText = e.CommentText,
UserId = e.UserId,
User = (e.User.FirstName + " " + e.User.LastName).Trim()),
Date =... |
414,307 | <p>I currently working with a larger wikipedia-dump derived PostgreSQL database; it contains about 40 GB of data. The database is running on an HP Proliant ML370 G5 server with Suse Linux Enterprise Server 10; I am querying it from my laptop over a private network managed by a simple D-Link router. I assigned static DH... | [
{
"answer_id": 414557,
"author": "alex",
"author_id": 26787,
"author_profile": "https://Stackoverflow.com/users/26787",
"pm_score": 1,
"selected": false,
"text": "<p>To your second question; you could try creating a new table with just the records you need with a CREATE TABLE AS statemen... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49985/"
] | I currently working with a larger wikipedia-dump derived PostgreSQL database; it contains about 40 GB of data. The database is running on an HP Proliant ML370 G5 server with Suse Linux Enterprise Server 10; I am querying it from my laptop over a private network managed by a simple D-Link router. I assigned static DHCP ... | Indeed, I decided to CREATE a temporary table to speed up query execution:
```
CREATE TABLE temp_to_delete AS(
(SELECT DISTINCT pl_from FROM pagelinks)
EXCEPT
(SELECT page_id FROM page));
DELETE FROM pagelinks USING temp_to_delete
WHERE pagelinks.pl_from IN (temp_to_delete.pl_from);
```
Surpri... |
414,310 | <p>I've got two WPF Toolkit <code>DataGrids</code>, I'd like so that when the user resizes the first column in the first grid, it resizes the first column in the second grid. I've tried binding the width of the <code>DataGridColumn</code> in the second grid to the appropriate column in the first grid, but it doesn't wo... | [
{
"answer_id": 414884,
"author": "Ray Booysen",
"author_id": 42124,
"author_profile": "https://Stackoverflow.com/users/42124",
"pm_score": 1,
"selected": false,
"text": "<p>I tried this:</p>\n\n<pre><code><tk:DataGrid Width=\"100\" Height=\"100\" x:Name=\"Grid1\" Grid.Column=\"0\">... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4572/"
] | I've got two WPF Toolkit `DataGrids`, I'd like so that when the user resizes the first column in the first grid, it resizes the first column in the second grid. I've tried binding the width of the `DataGridColumn` in the second grid to the appropriate column in the first grid, but it doesn't work. I'd prefer to use all... | Well, I don't think that it is possible using straight XAML, but I still feel like it should because `DataGridColumn` does derive from `DependencyObject`. I did find a way to do it programatically though. I'm not thrilled about it, but it works:
```
DataGridColumn.WidthProperty.AddValueChanged(upperCol, delegate
{
... |
414,328 | <p>In C# should you have code like:</p>
<pre><code>public static string importantRegex = "magic!";
public void F1(){
//code
if(Regex.IsMatch(importantRegex)){
//codez in here.
}
//more code
}
public void main(){
F1();
/*
some stuff happens......
*/
F1();
}
</code></pre>
<p>or should you persist an ... | [
{
"answer_id": 414335,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "<p>If you're going to reuse the regular expression multiple times, I'd create it with <code>RegexOptions.Compiled</code>... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1455/"
] | In C# should you have code like:
```
public static string importantRegex = "magic!";
public void F1(){
//code
if(Regex.IsMatch(importantRegex)){
//codez in here.
}
//more code
}
public void main(){
F1();
/*
some stuff happens......
*/
F1();
}
```
or should you persist an instance of a Regex contai... | In a rare departure from my typical egotism, I'm kind of reversing myself on this answer.
My original answer, preserved below, was based on an examination of version *1.1* of the .NET framework. This is pretty shameful, since .NET 2.0 had been out for over three years at the time of my answer, and it contained changes... |
414,336 | <p>I know this has something to do with parameter sniffing, but I'm just perplexed at how something like the following example is even possible with a piece of technology that does so many complex things well.</p>
<p>Many of us have run into stored procedures that intermittently run several of orders of magnitude slow... | [
{
"answer_id": 414360,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "<p>It's probably caused by the fact that SQL Server compiles stored procedures and <b>caches</b> execution plans for them and ... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] | I know this has something to do with parameter sniffing, but I'm just perplexed at how something like the following example is even possible with a piece of technology that does so many complex things well.
Many of us have run into stored procedures that intermittently run several of orders of magnitude slower than us... | The 1 in 10 gives the wrong plan that is cached.
RECOMPILE adds an overhead, masking allows each parameter to be evaluated on it's own merits (very simply).
By wrong plan, what if the 1 in 10 generates an scan on index 1 but the other 9 produce a seek on index 2? eg, the 1 in 10 is, say, 50% of the rows?
Edit: other... |
414,431 | <p>I read about using the CASE expression inside the WHERE clause here:</p>
<p><a href="http://scottelkin.com/sql/using-a-case-statement-in-a-sql-where-clause/" rel="nofollow noreferrer">http://scottelkin.com/sql/using-a-case-statement-in-a-sql-where-clause/</a></p>
<p>I'm trying to use this to filter results from my... | [
{
"answer_id": 414443,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 2,
"selected": false,
"text": "<p>Try leaving out the parentheses which are in the wrong place anyway - the right one should be after \"END\".</p>\n"
},... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I read about using the CASE expression inside the WHERE clause here:
<http://scottelkin.com/sql/using-a-case-statement-in-a-sql-where-clause/>
I'm trying to use this to filter results from my select statement, based on a contract number which will be passed in by the user's application. My code currently throws an er... | After reading your explanation, there's a better way to do this without `CASE`:
```
WHERE @ContractNo = 0 OR tblContracts.ContractNo = @ContractNo
```
This will return only matching contract numbers, unless `@ContractNo` is 0, in which case it will return all records.
**Edit:** I've just noticed that [casperOne pro... |
414,449 | <p>For example:</p>
<pre><code>using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Web.Security;
using System.Data;
using System.IO;
using System.Net;
using System... | [
{
"answer_id": 414463,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 2,
"selected": false,
"text": "<p>Using statements are only used by the compiler for type resolution so feel free to remove them if they are not need... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32372/"
] | For example:
```
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Web.Security;
using System.Data;
using System.IO;
using System.Net;
using System.Text;
using S... | **In general** all they do is add clutter.
However, they can *in some specific circumstances* cause problems with duplicate names in scope, or duplicate extension methods. For example, if there are classes `Foo.SomeType` and `Bar.SomeType`, and you have `using Foo;` and `using Bar;`, then references to `SomeType` will... |
414,488 | <p>it's a really weird thing - i have a website that works perfectly in maxthon (internet explorer based browser). i started it in opera and found out that the data put in the Session dictionary on one site, is not available on the other... i mean i have Welcome.aspx, where when you click next the following code is exe... | [
{
"answer_id": 414497,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 3,
"selected": true,
"text": "<p>We used to use ajax in classic ASP simply by posting XML messages to an ASP page that would load the xml from the requ... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40872/"
] | it's a really weird thing - i have a website that works perfectly in maxthon (internet explorer based browser). i started it in opera and found out that the data put in the Session dictionary on one site, is not available on the other... i mean i have Welcome.aspx, where when you click next the following code is execut... | We used to use ajax in classic ASP simply by posting XML messages to an ASP page that would load the xml from the request body.
You could do this using an ASHX page (ASP.Net handler) You won't have any of the extra overhead of the page objects. So you can basically create an Xml payload (or json or whatever you want)... |
414,529 | <p>I am having some difficulty accessing the value of the selected radio button in a radiogroup. I've attempted a number of different approaches based upon discussion in other posts on the forum and around the web. Unfortunately haven't been lucky (or skilled) enough to get it working. Based on the following FormPanel ... | [
{
"answer_id": 414668,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 4,
"selected": true,
"text": "<p>This is something of a wild guess, but how about this:</p>\n\n<pre><code>myForm2.getForm().getValues()['id-1'];\n<... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26241/"
] | I am having some difficulty accessing the value of the selected radio button in a radiogroup. I've attempted a number of different approaches based upon discussion in other posts on the forum and around the web. Unfortunately haven't been lucky (or skilled) enough to get it working. Based on the following FormPanel con... | This is something of a wild guess, but how about this:
```
myForm2.getForm().getValues()['id-1'];
``` |
414,541 | <p>In Oracle's PL/SQL I can create a session based global variable with the package definition. With Postgresql's PLpg/SQL, it doesn't seem possible since there are no packages, only independent procedures and functions.</p>
<p>Here is the syntax for PL/SQL to declare g_spool_key as a global...</p>
<pre><code>CREATE... | [
{
"answer_id": 414628,
"author": "dacracot",
"author_id": 13930,
"author_profile": "https://Stackoverflow.com/users/13930",
"pm_score": 1,
"selected": false,
"text": "<p>From the <a href=\"http://archives.postgresql.org/pgsql-sql/2006-04/msg00079.php\" rel=\"nofollow noreferrer\">Postgre... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13930/"
] | In Oracle's PL/SQL I can create a session based global variable with the package definition. With Postgresql's PLpg/SQL, it doesn't seem possible since there are no packages, only independent procedures and functions.
Here is the syntax for PL/SQL to declare g\_spool\_key as a global...
```
CREATE OR REPLACE PACKAGE ... | You could define some custom-variable-classes in your postgresql.conf and use it as connection-variables in your stored-procedure. See the [docs](http://www.postgresql.org/docs/8.1/static/runtime-config-custom.html).
Usage example for a custom-variable-class "imos":
```
imos=> set imos.testvar to 'foobar';
SET
Time: ... |
414,543 | <p>I have a Django model (schedule) with the class of entity, that is the parent of <code>Activity</code>, that is the parent of <code>Event</code>.</p>
<pre><code>class Entity(models.Model):
<...>
class Activity(models.Model):
<...>
team_entity = models.ForeignKey(Entity)
<...>
... | [
{
"answer_id": 414573,
"author": "Sarat",
"author_id": 18937,
"author_profile": "https://Stackoverflow.com/users/18937",
"pm_score": 2,
"selected": false,
"text": "<p>Have a look at serializing inherited models and objects from the Django documentation available at <a href=\"http://docs.... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51799/"
] | I have a Django model (schedule) with the class of entity, that is the parent of `Activity`, that is the parent of `Event`.
```
class Entity(models.Model):
<...>
class Activity(models.Model):
<...>
team_entity = models.ForeignKey(Entity)
<...>
class Event(models.Model):
<...>
activity = mo... | I now use django-piston. This does the trick. |
414,575 | <p>I don't know if this is the right way to phrase the question or not. Here is a typically databinding example: </p>
<pre><code><UserControl x:Name="root">
<ListView ItemsSource="{Binding MyItemsSource, ElementName=root}" />
</UserControl>
</code></pre>
<p>But this is what I want to be able to d... | [
{
"answer_id": 414592,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 0,
"selected": false,
"text": "<p>As long as you're not doing it at the <code>UserControl</code> level, you almost answered your own question. For ex... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | I don't know if this is the right way to phrase the question or not. Here is a typically databinding example:
```
<UserControl x:Name="root">
<ListView ItemsSource="{Binding MyItemsSource, ElementName=root}" />
</UserControl>
```
But this is what I want to be able to do:
```
<UserControl DataContext="{Binding S... | I solved my problem by doing this:
```
<UserControl x:Name="root">
<ListView ItemsSource="{Binding MyItemsSource}"
SelectedItem="{Binding DataContext, ElementName=root, Mode=OneWayToSource}">
</UserControl>
```
The trick is in the Mode=OneWayToSource setting. |
414,604 | <p>I am trying to create an ActiveRecord object via a JSON request. However the controller fails to set the variables passed in the parameters in the newly created object. As an example, a person object has two fields: firstname and lastname.</p>
<p>The JSON generated by the JSON.stringify function of the JSON.org lib... | [
{
"answer_id": 414634,
"author": "Zach Langley",
"author_id": 45230,
"author_profile": "https://Stackoverflow.com/users/45230",
"pm_score": 3,
"selected": true,
"text": "<p>If you are just passing a hash of all of the person parameters (rather than a nested-hash with \"person\" as the ke... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51812/"
] | I am trying to create an ActiveRecord object via a JSON request. However the controller fails to set the variables passed in the parameters in the newly created object. As an example, a person object has two fields: firstname and lastname.
The JSON generated by the JSON.stringify function of the JSON.org library produ... | If you are just passing a hash of all of the person parameters (rather than a nested-hash with "person" as the key) then you should just be able to do `@person = Person.new(params)`. |
414,605 | <p>Rendering HTML with the HtmlTextWriter isn't incredibly intuitive in my opinion, but if you're implementing web controls in web forms it's what you have to work with. I thought that it might be possible to create a fluent interface for this that reads a bit more like the HTML it outputs. I would like to know what pe... | [
{
"answer_id": 414698,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>There are two issues that I see:</p>\n\n<ul>\n<li>Repeated use of <code>Tag(Tagname, …)</code>. Why not offer exte... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46187/"
] | Rendering HTML with the HtmlTextWriter isn't incredibly intuitive in my opinion, but if you're implementing web controls in web forms it's what you have to work with. I thought that it might be possible to create a fluent interface for this that reads a bit more like the HTML it outputs. I would like to know what peopl... | There are two issues that I see:
* Repeated use of `Tag(Tagname, …)`. Why not offer extension methods for each tag name? Admittedly, this bloats the interface and is quite a lot to write (=> code generation!).
* The compiler/IDE doesn't assist you. In particular, it doesn't check indentation (it will even destroy it w... |
414,616 | <p>You can initialize an array like this:</p>
<pre><code>int [ ] arr = { 1, 2, 3, 4, 5 };
</code></pre>
<p>but <code>List<T></code> doesn't allow this:</p>
<pre><code>List<int> list = { 1, 2, 3, 4, 5 };
</code></pre>
<p>What's the reason behind this?</p>
<p>After all both allow this:</p>
<pre><code>... | [
{
"answer_id": 414624,
"author": "Patrik Hägne",
"author_id": 46187,
"author_profile": "https://Stackoverflow.com/users/46187",
"pm_score": 1,
"selected": false,
"text": "<p>I never realized you can't use collection initialization with a LinkedList(T), but it seems logical since it has n... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51816/"
] | You can initialize an array like this:
```
int [ ] arr = { 1, 2, 3, 4, 5 };
```
but `List<T>` doesn't allow this:
```
List<int> list = { 1, 2, 3, 4, 5 };
```
What's the reason behind this?
After all both allow this:
```
int [ ] arr = new int [ ] { 1, 2, 3, 4, 5 };
List<int> list = new List<int> { 1, 2, 3, 4... | Your first sample is the standard language syntax for initializing an array of integers. The left-hand value evaluates to int[]. In the second sample you are attempting to assign an int[] to a List<int>. The assignment operator doesn't support this as they are different types. A List<int> is **not** an array of type in... |
414,630 | <p>I have a web service that needs different settings for different environments (debug, test, prod). What's the easiest way to setup separate config files for these different environments? Everything I find on the web tells me how to use configuration manager to retrieve settings, but not how to find particular settin... | [
{
"answer_id": 414635,
"author": "Tom Anderson",
"author_id": 13502,
"author_profile": "https://Stackoverflow.com/users/13502",
"pm_score": 0,
"selected": false,
"text": "<p>We use a few different methods.</p>\n\n<p>Environment.MachineName.config (for users)</p>\n\n<pre><code> Sys... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51819/"
] | I have a web service that needs different settings for different environments (debug, test, prod). What's the easiest way to setup separate config files for these different environments? Everything I find on the web tells me how to use configuration manager to retrieve settings, but not how to find particular settings ... | I find having several config files for each environment works well. ie:
* config\local.endpoints.xml
* config\ dev.endpoints.xml
* config\ test.endpoints.xml
* config\ staging.endpoints.xml
* config\ prod.endpoints.xml
I then link to a "master" version of this using the built in configSource attribute within the web.... |
414,631 | <p>How does one tell the XML parser to honor leading and trailing whitespace?</p>
<pre><code>Dim xml: Set xml = CreateObject("MSXML2.DOMDocument")
xml.async = False
xml.loadxml "<xml>1 2</xml>"
wscript.echo len(xml.documentelement.text)
</code></pre>
<p>Above prints out 3.</p>
<pre><code>Dim xml: Set xml... | [
{
"answer_id": 415506,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 4,
"selected": true,
"text": "<p>As I commented, <strong>all answers recommending the usage of the <code>xml:space=\"preserve\"</code> are wron... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/245/"
] | How does one tell the XML parser to honor leading and trailing whitespace?
```
Dim xml: Set xml = CreateObject("MSXML2.DOMDocument")
xml.async = False
xml.loadxml "<xml>1 2</xml>"
wscript.echo len(xml.documentelement.text)
```
Above prints out 3.
```
Dim xml: Set xml = CreateObject("MSXML2.DOMDocument")
xml.async =... | As I commented, **all answers recommending the usage of the `xml:space="preserve"` are wrong**.
**The `xml:space` attribute can only be used to control the treatment of whitespace-only nodes**, that is text nodes composed **entirely** of whitespace characters.
This is not at all the case with the current problem.
I... |
414,639 | <p>So I've finally got my WCF service setup and talking to browser via ASP.NET AJAX. But I have found that when I populate a html table with my data... the datetime format looks like this:</p>
<p>Fri Jan 02 2009 15:27:12 GMT-0500 (Eastern Standard Time)</p>
<p>On the server I am using the .NET DateTime format. Should... | [
{
"answer_id": 414655,
"author": "Richard L",
"author_id": 51017,
"author_profile": "https://Stackoverflow.com/users/51017",
"pm_score": 1,
"selected": false,
"text": "<p>When you print the value you should be able to print it in the browsers native format,</p>\n\n<p>Or if you want t des... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | So I've finally got my WCF service setup and talking to browser via ASP.NET AJAX. But I have found that when I populate a html table with my data... the datetime format looks like this:
Fri Jan 02 2009 15:27:12 GMT-0500 (Eastern Standard Time)
On the server I am using the .NET DateTime format. Should I use something ... | Since you are using ASP.NET Ajax, you can call format on your Date object in javascript, similar to how you would in .NET. for example:
```
var myDateString = myServiceObject.Date.format("d"); //short date pattern
```
or a custom pattern...
```
var myDateString2 = myServiceObject.Date.format("yyyy/mm/dd"); //some c... |
414,664 | <p>I have a big list of hexadecimal numbers I'd like to insert into a PostgresQL table. I tried something like this:</p>
<pre><code>INSERT INTO foo (i)
VALUES (0x1234);
</code></pre>
<p>...but that didn't work. Is this possible?</p>
| [
{
"answer_id": 414708,
"author": "mike",
"author_id": 91385,
"author_profile": "https://Stackoverflow.com/users/91385",
"pm_score": 3,
"selected": false,
"text": "<p>This seems to work:</p>\n\n<pre><code> CAST(X'3e000000' AS INT)\n</code></pre>\n"
},
{
"answer_id": 414729,
"a... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | I have a big list of hexadecimal numbers I'd like to insert into a PostgresQL table. I tried something like this:
```
INSERT INTO foo (i)
VALUES (0x1234);
```
...but that didn't work. Is this possible? | As you've noted, you can start with a [bit-string constant](http://www.postgresql.org/docs/8.3/interactive/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS) written in hexadecimal, and then [type-cast it](http://www.postgresql.org/docs/8.3/interactive/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS) to the type you want. So,
`... |
414,676 | <p>In an Intranet environment, I have an FTP server set up for publishing files to websites. A user connected to the production FTP server (allowed) to publish files (allowed) then navigated to a folder that was not hers (allowed) then wrote files there (allowed by FTP, but not by NTFS.)</p>
<p>Only Administrators and... | [
{
"answer_id": 414708,
"author": "mike",
"author_id": 91385,
"author_profile": "https://Stackoverflow.com/users/91385",
"pm_score": 3,
"selected": false,
"text": "<p>This seems to work:</p>\n\n<pre><code> CAST(X'3e000000' AS INT)\n</code></pre>\n"
},
{
"answer_id": 414729,
"a... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14127/"
] | In an Intranet environment, I have an FTP server set up for publishing files to websites. A user connected to the production FTP server (allowed) to publish files (allowed) then navigated to a folder that was not hers (allowed) then wrote files there (allowed by FTP, but not by NTFS.)
Only Administrators and System ha... | As you've noted, you can start with a [bit-string constant](http://www.postgresql.org/docs/8.3/interactive/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS) written in hexadecimal, and then [type-cast it](http://www.postgresql.org/docs/8.3/interactive/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS) to the type you want. So,
`... |
414,679 | <p>I need some way to add a class attribute to the output of the <code>label_tag()</code> method for a forms field.</p>
<p>I see that there is the ability to pass in an <code>attrs</code> dictionary and I have tested it in the shell and I can do something like:</p>
<pre><code>for field in form:
print field.label_ta... | [
{
"answer_id": 415770,
"author": "muhuk",
"author_id": 42188,
"author_profile": "https://Stackoverflow.com/users/42188",
"pm_score": 4,
"selected": true,
"text": "<p>A <a href=\"http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags\" rel=\"nofollow n... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22306/"
] | I need some way to add a class attribute to the output of the `label_tag()` method for a forms field.
I see that there is the ability to pass in an `attrs` dictionary and I have tested it in the shell and I can do something like:
```
for field in form:
print field.label_tag(attrs{'class':'Foo'})
```
I will see ... | A [custom template tag](http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags) seems to be the solution. A custom filter would also do, although it can be less elegant. But you would need to fall back to custom form rendering in both cases.
If this is a task of high importance; I'... |
414,714 | <p>Quick question: what is the compiler flag to allow g++ to spawn multiple instances of itself in order to compile large projects quicker (for example 4 source files at a time for a multi-core CPU)?</p>
| [
{
"answer_id": 414719,
"author": "rmeador",
"author_id": 10861,
"author_profile": "https://Stackoverflow.com/users/10861",
"pm_score": 4,
"selected": false,
"text": "<p><code>make</code> will do this for you. Investigate the <code>-j</code> and <code>-l</code> switches in the man page. ... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51827/"
] | Quick question: what is the compiler flag to allow g++ to spawn multiple instances of itself in order to compile large projects quicker (for example 4 source files at a time for a multi-core CPU)? | You can do this with make - with gnu make it is the -j flag (this will also help on a uniprocessor machine).
For example if you want 4 parallel jobs from make:
```
make -j 4
```
You can also run gcc in a pipe with
```
gcc -pipe
```
This will pipeline the compile stages, which will also help keep the cores busy.... |
414,715 | <p>I am looking for some examples of a .bat OR .wsh script that can do the following:</p>
<ul>
<li>Recursively read file names in a directory with a user-provided extension (.dll, .exe, etc)</li>
<li>Search a user-provided directory for the above file names</li>
<li>Generate a txt or xls report of the findings, like: ... | [
{
"answer_id": 414727,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 4,
"selected": false,
"text": "<p>Why not use dir?</p>\n\n<p>Search current directory and all subdirs for dlls</p>\n\n<blockquote>\n<pre><code>dir /S *.... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51826/"
] | I am looking for some examples of a .bat OR .wsh script that can do the following:
* Recursively read file names in a directory with a user-provided extension (.dll, .exe, etc)
* Search a user-provided directory for the above file names
* Generate a txt or xls report of the findings, like: x.txt was found in "C:\temp"... | Put the following in a .bat file, say `FindAll.bat`:
```
@echo OFF
for /f %%F in ('dir %2\%1 /s /b') do (
<nul (set /p msg=%%~nxF )
for /f %%G in ('dir %3\%%~nxF /s /b') do (
if exist %%G (
@echo found at %%G
)
)
)
```
`%1` is the user provided file mask.
`%2` is the user p... |
414,726 | <p>I am totally confused on how to do ajax stuffs with jQuery and it seems the more I try the more confused I get. At this point all I want to do is get data to my controller using jQuery ajax. Some code for my jquery ajax call is.</p>
<pre><code>$(function() {
$('#buttonAddLink').click(function() {
var A... | [
{
"answer_id": 414873,
"author": "foxxtrot",
"author_id": 10369,
"author_profile": "https://Stackoverflow.com/users/10369",
"pm_score": 2,
"selected": false,
"text": "<p>It has to do with the way you're structuring your request. Your JQuery call is sending the data to the AddLink action ... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23571/"
] | I am totally confused on how to do ajax stuffs with jQuery and it seems the more I try the more confused I get. At this point all I want to do is get data to my controller using jQuery ajax. Some code for my jquery ajax call is.
```
$(function() {
$('#buttonAddLink').click(function() {
var AjaxLink = {
... | It has to do with the way you're structuring your request. Your JQuery call is sending the data to the AddLink action on the User controller as POST data, which means in your C# code, you'll access it via the Request.Form object. With what you're trying to do, you'd structure the jQuery URL as
```
/User/AddLink/{Title... |
414,733 | <p>How could I get the current h/m/s AM time into a string? And maybe also the date in numeric form (01/02/09) into another one?</p>
| [
{
"answer_id": 414739,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 4,
"selected": false,
"text": "<blockquote>\n<pre><code>DateTime.Now.ToString(\"h:mm tt\")\nDateTime.Now.ToString(\"MM/dd/yyyy\")\n</code></pre>\n</bloc... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How could I get the current h/m/s AM time into a string? And maybe also the date in numeric form (01/02/09) into another one? | I'd just like to point out something in these answers. In a date/time format string, '/' will be replaced with *whatever the user's date separator is*, and ':' will be replaced with *whatever the user's time separator is*. That is, if I've defined my date separator to be '.' (in the Regional and Language Options contro... |
414,741 | <p>I would like to pass a reference of a method into another method and store it as a variable. Later, I would like to use this reference to define an event handler.</p>
<p>When making an event handler, a method reference is passed like:</p>
<pre><code>myButton.Click += new RoutedEventHandler(myButton_Click);
</code... | [
{
"answer_id": 414754,
"author": "Jacob Adams",
"author_id": 32518,
"author_profile": "https://Stackoverflow.com/users/32518",
"pm_score": 0,
"selected": false,
"text": "<p>try</p>\n\n<pre><code>private static delegate void(object sender, RoutedEventArgs e) _buttonClickHandler;\n</code><... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50859/"
] | I would like to pass a reference of a method into another method and store it as a variable. Later, I would like to use this reference to define an event handler.
When making an event handler, a method reference is passed like:
```
myButton.Click += new RoutedEventHandler(myButton_Click);
```
And if you look at the... | To reference a Method Reference (called a [delegate](http://msdn.microsoft.com/en-us/library/ms173171.aspx) in .NET), use the Handler name, rather than the signature.
```
public class EventBuilder
{
private static RoutedEventHandler _buttonClickHandler;
public EventBuilder(RoutedEventHandler buttonClickHandle... |
414,746 | <p>How do you declare a method in C# that should be overridden (or overridable) by a dereived class - possibly even outside your assembly - but that should be callable only from within the actual class?</p>
<p>(i.e. like a private virtual function in C++)</p>
<p><strong>[edit]</strong><br>
<em><code>private</code></e... | [
{
"answer_id": 414770,
"author": "Timothy Carter",
"author_id": 4660,
"author_profile": "https://Stackoverflow.com/users/4660",
"pm_score": 2,
"selected": false,
"text": "<p>A private member is not visible to child classes. I think protected virtual will perform the way you'd like?</p>\n... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31317/"
] | How do you declare a method in C# that should be overridden (or overridable) by a dereived class - possibly even outside your assembly - but that should be callable only from within the actual class?
(i.e. like a private virtual function in C++)
**[edit]**
*`private`* `virtual` is exactly what I intend: "Here's a ... | C# makes a stronger guarantee for "private" than C++ does. In C++, you can indeed override a private virtual method. But that means that code in a base class can execute code in a derived class. Breaking the promise that the private method is truly private and can only be called by methods in the same class.
Something... |
414,749 | <p>in that specific case</p>
<pre><code> Const debugTime As String = "hh:mm:ss.fffffff"
Dim i As Integer
Debug.Print("Start " & Now.ToString(debugTime))
For i = 0 To 4000000
j = 5 - 4
Next
Debug.Print("End " & Now.ToString(debugTime))
Debug.Print("Start " & Now.ToString... | [
{
"answer_id": 414763,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 3,
"selected": false,
"text": "<p>The compiler will optimize both of them to an assignment. The very small difference is probably a result of another factor.... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40868/"
] | in that specific case
```
Const debugTime As String = "hh:mm:ss.fffffff"
Dim i As Integer
Debug.Print("Start " & Now.ToString(debugTime))
For i = 0 To 4000000
j = 5 - 4
Next
Debug.Print("End " & Now.ToString(debugTime))
Debug.Print("Start " & Now.ToString(debugTime))
For i = 0... | * Benchmarking with such tiny time intervals leaves you wide open to problems of timer granularity, which is what you're seeing here.
* Your code doesn't actually calculate anything, as you've got a constant both times.
In fact, benchmarking operations this small is quite tricky - to make sure neither the compiler nor... |
414,761 | <p>I have a C++ driver I'm trying to compile, and it has this line in the code:</p>
<pre><code>#import "msado15.dll" no_namespace rename("EOF", "EndOfFile")
</code></pre>
<p>But when I compile the project, I get the error:</p>
<p>Error 1 fatal error C1083: Cannot open type library file: 'msado15.dll': No such fi... | [
{
"answer_id": 414782,
"author": "Craig Shearer",
"author_id": 14537,
"author_profile": "https://Stackoverflow.com/users/14537",
"pm_score": 0,
"selected": false,
"text": "<p>OK, found it by reading the documentation. I just had to put it in the same folder as the referenced file (which ... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14537/"
] | I have a C++ driver I'm trying to compile, and it has this line in the code:
```
#import "msado15.dll" no_namespace rename("EOF", "EndOfFile")
```
But when I compile the project, I get the error:
Error 1 fatal error C1083: Cannot open type library file: 'msado15.dll': No such file or directory
I have the DLL, but... | You can place the DLL in the same path as the referencing file (.h) as you have done, alternatively you can modify the additional include paths for the LIB section of your project(s). In VC++ this will be:
Project | Properties | Configuration Properties | Linker | General | Additional Library Directories
This method ... |
414,788 | <p>In C++ you are able to compile files that are not included in the solution, with c# this is not the case.</p>
<p>Is there a way to keep a file in a project but not have the standard SCCI provider attempt to keep checking in the file?</p>
<p>Essentially what we are wanting to do is to create "by developer" code abi... | [
{
"answer_id": 414806,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>MSBuild has <a href=\"http://msdn.microsoft.com/en-us/library/ms164307.aspx\" rel=\"nofollow noreferrer\">Conditional Const... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13502/"
] | In C++ you are able to compile files that are not included in the solution, with c# this is not the case.
Is there a way to keep a file in a project but not have the standard SCCI provider attempt to keep checking in the file?
Essentially what we are wanting to do is to create "by developer" code ability similar to h... | Well, it seems after working off the post here, and literally trying "wierd" things, I had an idea.
Essentially I used the \*.csproj.user file, declared a UserConfig property, added a new Constant (for code checks), and did an ItemGroup with the condition of the UserConfig. All this fell under the DEBUG flag.
The onl... |
414,789 | <p>In one form I am creating a territory and editing multiple users. The "user_attributes" below are for the users and the "name" is for the territory. So for each user_attribute I wanted to update the user model.</p>
<h1>params</h1>
<pre><code>{ "territory"=>{"name"=>"... | [
{
"answer_id": 414795,
"author": "Sophie Alpert",
"author_id": 49485,
"author_profile": "https://Stackoverflow.com/users/49485",
"pm_score": -1,
"selected": false,
"text": "<p>Try params[\"user_attributes\"].</p>\n"
},
{
"answer_id": 414872,
"author": "J Cooper",
"author_... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10258/"
] | In one form I am creating a territory and editing multiple users. The "user\_attributes" below are for the users and the "name" is for the territory. So for each user\_attribute I wanted to update the user model.
params
======
```
{ "territory"=>{"name"=>"Central Canada",
"user_attributes"=>[{"user_id"=>"30"},{"use... | From what you posted, your `user_attributes` hash is INSIDE your `territory` hash. That should be your problem -- either move it outside, or do `params[:territory][:user_attributes]` |
414,801 | <p>I am wondering if there are any additional optimizations I can implement to improve the speed of reflective invocations in Java. Not that the performance is prohibitive, but I get the willies when thinking about some piece of code in a library I am writing being implemented in a tight loop somewhere.</p>
<p>Conside... | [
{
"answer_id": 414823,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 7,
"selected": true,
"text": "<p>The comments below relate to Sun's implementation, in particular OpenJDK 6. Your mileage may vary with other Java platform... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43786/"
] | I am wondering if there are any additional optimizations I can implement to improve the speed of reflective invocations in Java. Not that the performance is prohibitive, but I get the willies when thinking about some piece of code in a library I am writing being implemented in a tight loop somewhere.
Consider a utilit... | The comments below relate to Sun's implementation, in particular OpenJDK 6. Your mileage may vary with other Java platform implementations.
`java.lang.Class` does some caching itself, so implementing your own cache may not improve things very much. Do timing tests with and without manual caching.
The actual invocatio... |
414,809 | <p>I want to know if the page is being accessed via http or https using JavaScript. Is there some sort of isSecure() method, or should I just parse it out of the URL somehow?</p>
| [
{
"answer_id": 414827,
"author": "Peter Stone",
"author_id": 1806,
"author_profile": "https://Stackoverflow.com/users/1806",
"pm_score": 8,
"selected": true,
"text": "<p><code>location.protocol</code> should do it for you.</p>\n\n<p>(as in:</p>\n\n<pre><code>if (location.protocol === 'ht... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28991/"
] | I want to know if the page is being accessed via http or https using JavaScript. Is there some sort of isSecure() method, or should I just parse it out of the URL somehow? | `location.protocol` should do it for you.
(as in:
```
if (location.protocol === 'https:') {
// page is secure
}
```
) |
414,828 | <p>Is it possible to run an UPDATE command on mysql 5.0 with a sub select.</p>
<p>The command I would like to run is this:</p>
<pre><code>UPDATE book_details
SET live = 1
WHERE ISBN13 = '(SELECT ISBN13 FROM book_details_old WHERE live = 1)';
</code></pre>
<p>ISBN13 is currently stored as a string.</p>
<p>This shou... | [
{
"answer_id": 414841,
"author": "Rob",
"author_id": 41908,
"author_profile": "https://Stackoverflow.com/users/41908",
"pm_score": 5,
"selected": false,
"text": "<pre><code>UPDATE book_details AS bd, book_details_old AS old\nSET bd.live=1 \nWHERE bd.isbn13=old.isbn13 \nAND old.live=1;\... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2725/"
] | Is it possible to run an UPDATE command on mysql 5.0 with a sub select.
The command I would like to run is this:
```
UPDATE book_details
SET live = 1
WHERE ISBN13 = '(SELECT ISBN13 FROM book_details_old WHERE live = 1)';
```
ISBN13 is currently stored as a string.
This should be updating 10k+ rows.
Thanks,
Will... | Just a litle change and you got it:
```
UPDATE book_details
SET live = 1
WHERE ISBN13 in (SELECT ISBN13 FROM book_details_old WHERE live = 1);
``` |
414,835 | <p>A while back, online apps used to say, "do not click submit more than once." That's gone now, right? How do you guard against that in, say, PHP?</p>
<p>One solution I'm using involves putting a variable in the Session, so you cannot submit to a page more than once every 10 seconds. That way the database work will h... | [
{
"answer_id": 414846,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 1,
"selected": false,
"text": "<p>One solution is to immediately disable the button on click using Javascript. This obviously relies on javascript being ... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] | A while back, online apps used to say, "do not click submit more than once." That's gone now, right? How do you guard against that in, say, PHP?
One solution I'm using involves putting a variable in the Session, so you cannot submit to a page more than once every 10 seconds. That way the database work will have comple... | You should do both client- and server-side protections.
**Client side** - disable button e.g. by jquery as cletus has described.
**Server side** - put a token in the form. If there are two submissions with the same token, ignore the latter. Using this approach, you are protected against [CSRF](http://en.wikipedia.org... |
414,849 | <p>I've got a production DB with, say, ten million rows. I'd like to extract the 10,000 or so rows from the past hour off of production and copy them to my local box. How do I do that?</p>
<p>Let's say the query is:</p>
<pre><code>SELECT * FROM mytable WHERE date > '2009-01-05 12:00:00';
</code></pre>
<p>How do I... | [
{
"answer_id": 414902,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 2,
"selected": false,
"text": "<p>From within <code>psql</code>, you just use <code>copy</code> with the query you gave us, exporting this as a CSV (or wh... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | I've got a production DB with, say, ten million rows. I'd like to extract the 10,000 or so rows from the past hour off of production and copy them to my local box. How do I do that?
Let's say the query is:
```
SELECT * FROM mytable WHERE date > '2009-01-05 12:00:00';
```
How do I take the output, export it to some ... | Source:
```
psql -c "COPY (SELECT * FROM mytable WHERE ...) TO STDOUT" > mytable.copy
```
Destination:
```
psql -c "COPY mytable FROM STDIN" < mytable.copy
```
This assumes mytable has the same schema and column order in both the source and destination. If this isn't the case, you could try `STDOUT CSV HEADER` an... |
414,879 | <p>This sounds like a look-up-in-the-manual question to me, but I can't find it. Suppose we have a repository with files and directories in it that shouldn't be under version control but rather should be on the ignore list (such as Eclipse files <code>.settings</code>, <code>.project</code>, generated documentation fil... | [
{
"answer_id": 414888,
"author": "Kevin Davis",
"author_id": 49993,
"author_profile": "https://Stackoverflow.com/users/49993",
"pm_score": 3,
"selected": false,
"text": "<pre><code>svn remove filename\n</code></pre>\n\n<p>Ignoring: </p>\n\n<pre><code>svn propset svn:ignore filename|patte... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25517/"
] | This sounds like a look-up-in-the-manual question to me, but I can't find it. Suppose we have a repository with files and directories in it that shouldn't be under version control but rather should be on the ignore list (such as Eclipse files `.settings`, `.project`, generated documentation files - things that should n... | There are two ways with subversion, one is specific to the user and the other is actually maintained in the repository, and therefore affects everyone.
For a list of globally ignored files (exclusive to each user/machine), you need to edit the subversion config file and alter the *global-ignores* directive in the *mis... |
414,889 | <p>I'm trying to insert some new objects into a firebird database using NHibernate. </p>
<p>I get the error "could not get next sequence value[SQL: SQL not available]"</p>
<p>Here is the mapping I'm using at present. Note ANML_EVNT is the name of the generator I want to use.</p>
<pre><code> <id name="Id" colum... | [
{
"answer_id": 414967,
"author": "gcores",
"author_id": 40256,
"author_profile": "https://Stackoverflow.com/users/40256",
"pm_score": 2,
"selected": false,
"text": "<p>That looks all right. The problem is not the end bracket after ANML_EVNT, right? </p>\n\n<pre><code> <id name=\"Id\" ... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74652/"
] | I'm trying to insert some new objects into a firebird database using NHibernate.
I get the error "could not get next sequence value[SQL: SQL not available]"
Here is the mapping I'm using at present. Note ANML\_EVNT is the name of the generator I want to use.
```
<id name="Id" column="ID" type="integer">
... | If you still are looking for an answer here is how I've used it successfully.
I use the "native" generator because when adding support for SQL Server to our program the only thing in NHibernate I had to change was the generator types to "native" because Firebird and SQL Server implement their "auto incrementing identi... |
414,891 | <ul>
<li>What is DOCTYPE and why do I want to use it?</li>
<li>What are the different DOCTYPEs I can use?</li>
<li>What is the difference between standards and quirks mode, and what are some quirks I may run into with differently set DOCTYPEs?</li>
</ul>
<p>Lastly, what is the proper DOCTYPE that I should be using?</p... | [
{
"answer_id": 414895,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>A doctype defines which version of HTML/XHTML your document uses. You would want to use a doctype so that when you run your... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45/"
] | * What is DOCTYPE and why do I want to use it?
* What are the different DOCTYPEs I can use?
* What is the difference between standards and quirks mode, and what are some quirks I may run into with differently set DOCTYPEs?
Lastly, what is the proper DOCTYPE that I should be using? | Basically, the DOCTYPE describes the HTML that will be used in your page.
Browsers also use the DOCTYPE to determine how to render a page. Not including a DOCTYPE or including an incorrect one can trigger quirks mode.
The kicker here is, that quirks mode in Internet Explorer is quite different from quirks mode in Fir... |
414,894 | <p>The Ubuntu startup/login sound can be very loud, but I do like having it. I wrote a script that uses amixer to set the volume to 25%. This is the level I like to have it at, but when I use TV out or headphones I have to turn up the volume. I cannot seem to get the script to run before the login sound plays. I have t... | [
{
"answer_id": 415071,
"author": "Zoredache",
"author_id": 20267,
"author_profile": "https://Stackoverflow.com/users/20267",
"pm_score": 3,
"selected": true,
"text": "<p>You might want to try adding that line to your like to <code>/etc/rc.local</code> This may not be soon enough though... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41908/"
] | The Ubuntu startup/login sound can be very loud, but I do like having it. I wrote a script that uses amixer to set the volume to 25%. This is the level I like to have it at, but when I use TV out or headphones I have to turn up the volume. I cannot seem to get the script to run before the login sound plays. I have trie... | You might want to try adding that line to your like to `/etc/rc.local` This may not be soon enough though, since rc.local will be called after gdm.
Also note, the default runlevel on Ubuntu is **2**, not **3**. Your link in rc3.d probably didn't work simply because you where not using runlevel 3. The default runlevel ... |
414,905 | <p>I have a whole heap of legacy code that I checked into my SVN repository. I checked it in under my user name. I'd like to change the author of that commit to another user, 'legacy', in order to clean up the <code>svn blame</code> printouts.</p>
| [
{
"answer_id": 414914,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure you can do this directly but what is possible is dumping the repo, using <code>sed</code> on it and re-impo... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23071/"
] | I have a whole heap of legacy code that I checked into my SVN repository. I checked it in under my user name. I'd like to change the author of that commit to another user, 'legacy', in order to clean up the `svn blame` printouts. | You need to have have a pre-revprop-change hook in your repository hooks directory that will allow changes to the svn:author property. (An executable script containing just "exit 0" will do.) Once you have this, then you can do:
```
svn propedit --revprop -r*rev* svn:author *url*
```
and make the necessary changes. |
414,906 | <p>Basically I have a setup like the following:</p>
<pre><code>Array (
[0] => Array ( [0] => stdClass Object ( [nid] => 1 [title] => title1 [uid] => 1 [parent] => 0 [weight] => -15 [name] => name1 [value] => 0 )
[1] => stdClass Object ( [nid] => 2 [title] => title2 [... | [
{
"answer_id": 414923,
"author": "Logan Serman",
"author_id": 29595,
"author_profile": "https://Stackoverflow.com/users/29595",
"pm_score": 0,
"selected": false,
"text": "<p>I could be wrong, but I believe I did something like this using asort() (or asort()). It was in a search function,... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Basically I have a setup like the following:
```
Array (
[0] => Array ( [0] => stdClass Object ( [nid] => 1 [title] => title1 [uid] => 1 [parent] => 0 [weight] => -15 [name] => name1 [value] => 0 )
[1] => stdClass Object ( [nid] => 2 [title] => title2 [uid] => 1 [parent] => 0 [weight] => -7 [name] => n... | Use [usort](http://au2.php.net/manual/en/function.usort.php):
```
function cmp($a, $b) {
if ($a->value == $b->value) {
return 0;
} else {
return $a->value < $b->value ? 1 : -1; // reverse order
}
}
usort($arr, 'cmp');
``` |
414,915 | <p>Clicking through JMenu options is causing my JOGL GLCanvas to flicker. </p>
<p>The JMenu has the setDefaultLightWeightPopupEnabled set to false. I don't want to use JGLPanel because it runs slower (the application needs to run in full screen mode).</p>
<p>Interesting, the flicker stops if I set sun.java2d.opengl... | [
{
"answer_id": 415038,
"author": "wusher",
"author_id": 1632,
"author_profile": "https://Stackoverflow.com/users/1632",
"pm_score": 2,
"selected": false,
"text": "<p>Try calling <a href=\"http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Canvas.html#createBufferStrategy%28int%29\... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41762/"
] | Clicking through JMenu options is causing my JOGL GLCanvas to flicker.
The JMenu has the setDefaultLightWeightPopupEnabled set to false. I don't want to use JGLPanel because it runs slower (the application needs to run in full screen mode).
Interesting, the flicker stops if I set sun.java2d.opengl=true on the comman... | Try calling [`createBufferStrategy(2);`](http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Canvas.html#createBufferStrategy%28int%29) in the JFrame constructor. This should enable double buffering in the JFrame. |
414,928 | <p>I've got a form with a bunch of controls on it, and I wanted to iterate through all the controls on a certain panel and enable/disable them.</p>
<p>I tried this:</p>
<pre><code>var component: TComponent;
begin
for component in myPanel do
(component as TControl).Enabled := Value;
end;
</code></pre>
<p>But th... | [
{
"answer_id": 414940,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 6,
"selected": true,
"text": "<p>You're looking for the <code>TWinControl.Controls</code> array and the accompanying <code>ControlCount</code> proper... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32914/"
] | I've got a form with a bunch of controls on it, and I wanted to iterate through all the controls on a certain panel and enable/disable them.
I tried this:
```
var component: TComponent;
begin
for component in myPanel do
(component as TControl).Enabled := Value;
end;
```
But that did nothing. Turns out all com... | You're looking for the `TWinControl.Controls` array and the accompanying `ControlCount` property. Those are for a control's immediate children. To get grandchildren etc., use standard recursive techniques.
You don't really want the `Components` array (which is what the `for`-`in` loop iterates over) since it has nothi... |
414,931 | <p>I am currently playing around with the Asp.Net mvc framework and loving it compared to the classic asp.net way. One thing I am mooting is whether or not it is acceptable for a View to cause (indirectly) access to the database?</p>
<p>For example, I am using the controller to populate a custom data class with all th... | [
{
"answer_id": 414970,
"author": "Jeff Atwood",
"author_id": 1,
"author_profile": "https://Stackoverflow.com/users/1",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>One thing I am mooting is whether or not it is acceptable for a View to cause (indirectly) access to the da... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31128/"
] | I am currently playing around with the Asp.Net mvc framework and loving it compared to the classic asp.net way. One thing I am mooting is whether or not it is acceptable for a View to cause (indirectly) access to the database?
For example, I am using the controller to populate a custom data class with all the informat... | Your view isn't really causing data access. The view is simply calling the GetDiscount() method in a model interface. It's the **model** which is causing data access. Indeed, you could create another implementation of IProduct which wouldn't cause data access, yet there would be no change to the view.
Model objects th... |
414,943 | <p>I am inserting the HTML response from an AJAX call into my page, but then when I try to access those elements after they have been created, it fails..</p>
<p>This is how i retrieve and insert the HTML:</p>
<pre><code>$.ajax({url: 'output.aspx',
data: 'id=5',
type: 'get',
datatype: 'html',
success: fu... | [
{
"answer_id": 414961,
"author": "Salty",
"author_id": 50548,
"author_profile": "https://Stackoverflow.com/users/50548",
"pm_score": 0,
"selected": false,
"text": "<p>Are you sure your actual request is successful? If nothing is selected, the most probably reason is that nothing was actu... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49742/"
] | I am inserting the HTML response from an AJAX call into my page, but then when I try to access those elements after they have been created, it fails..
This is how i retrieve and insert the HTML:
```
$.ajax({url: 'output.aspx',
data: 'id=5',
type: 'get',
datatype: 'html',
success: function(outData) {$('#... | How are you checking to see whether your AJAX call has completed? Because it's asynchronous, the elements will not, of course, be available to the code which executes immediately after your `$.ajax(…)` call.
Try manipulating those elements from within the `success` function or in other code which is called from there ... |
414,945 | <p>I have a self-referencing table with an Id, CategoryName, and ParentId. It's a typical scenario of a hierarchy table of categories that can themselves be divided into categories that DB experts tell me is called the adjacency model. </p>
<p>What I want is to use Linq to SQL to query for subcategories that themselve... | [
{
"answer_id": 415079,
"author": "Noah",
"author_id": 47496,
"author_profile": "https://Stackoverflow.com/users/47496",
"pm_score": 0,
"selected": false,
"text": "<p>I think if I understand your question correctly you're trying to get all of the Child elements that have no children of th... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16426/"
] | I have a self-referencing table with an Id, CategoryName, and ParentId. It's a typical scenario of a hierarchy table of categories that can themselves be divided into categories that DB experts tell me is called the adjacency model.
What I want is to use Linq to SQL to query for subcategories that themselves are rela... | Your solution is correct because the `Any()` method, translates into sql "EXISTS()" function
and `!c.Children.Any ( d => d.ParentId == c.Id))` translates into a sql clause similar to `NOT EXISTS (SELECT * FROM Categories WHERE ParentID = outerRef.ID)`
Another way to do it is to use `Count` :
```
Categories.Where( c ... |
414,946 | <p>Is there a way to check if a ValidationSummary control has its IsValid property set to true using Javascript in the OnClientClick event of a button? </p>
<p>What I'm trying to do is to show a message that says "please wait while your file is uploading" on an upload page, but if I use javascript to show that message... | [
{
"answer_id": 414963,
"author": "Richard L",
"author_id": 51017,
"author_profile": "https://Stackoverflow.com/users/51017",
"pm_score": 0,
"selected": false,
"text": "<p>I guess what you should do is <a href=\"http://blog.shkedy.com/2007/01/clickonce-button-for-aspnet-20.html\" rel=\"no... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18234/"
] | Is there a way to check if a ValidationSummary control has its IsValid property set to true using Javascript in the OnClientClick event of a button?
What I'm trying to do is to show a message that says "please wait while your file is uploading" on an upload page, but if I use javascript to show that message, it shows... | In case others need something like this, here is my solution:
In the button's OnClientClick event, I'm calling a javascript function called showContent(). In this function, I use setTimeout to call a second function that checks the page's IsValid property:
```
function showContent()
{
setTimeout("delayedShow()",... |
414,952 | <p>SQLAlchemy's <code>DateTime</code> type allows for a <code>timezone=True</code> argument to save a non-naive datetime object to the database, and to return it as such. Is there any way to modify the timezone of the <code>tzinfo</code> that SQLAlchemy passes in so it could be, for instance, UTC? I realize that I coul... | [
{
"answer_id": 462028,
"author": "iny",
"author_id": 27067,
"author_profile": "https://Stackoverflow.com/users/27067",
"pm_score": 6,
"selected": true,
"text": "<p><a href=\"http://www.postgresql.org/docs/8.3/interactive/datatype-datetime.html#DATATYPE-TIMEZONES\" rel=\"noreferrer\">http... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12650/"
] | SQLAlchemy's `DateTime` type allows for a `timezone=True` argument to save a non-naive datetime object to the database, and to return it as such. Is there any way to modify the timezone of the `tzinfo` that SQLAlchemy passes in so it could be, for instance, UTC? I realize that I could just use `default=datetime.datetim... | <http://www.postgresql.org/docs/8.3/interactive/datatype-datetime.html#DATATYPE-TIMEZONES>
>
> All timezone-aware dates and times are stored internally in UTC. They are converted to local time in the zone specified by the timezone configuration parameter before being displayed to the client.
>
>
>
The only way t... |
414,954 | <p>I get this fatal error only when I run on a Macintosh, but not on a windows browser, which doesn't make sense since, other than checking for the Browser condition, the conditional loops run the same code:</p>
<p>Can someone help me understand how to stop this error in php? The error occurs on the FIRST instance of ... | [
{
"answer_id": 415086,
"author": "Chris Burgess",
"author_id": 43034,
"author_profile": "https://Stackoverflow.com/users/43034",
"pm_score": 0,
"selected": false,
"text": "<p>Both blocks of code define the same class:</p>\n\n<pre><code>class QEnterKeyEvent extends QKeyDownEvent {\n ... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43980/"
] | I get this fatal error only when I run on a Macintosh, but not on a windows browser, which doesn't make sense since, other than checking for the Browser condition, the conditional loops run the same code:
Can someone help me understand how to stop this error in php? The error occurs on the FIRST instance of QEnterKeyE... | I see this code sample is from the QCodo codebase? In that case you probably ought to report the issue via their ["Bugs and Issues" forum.](http://www.qcodo.com/forums/forum.php/3) After a look there, I see there are already a couple of reports: [this](http://www.qcodo.com/forums/topic.php/3506/1) and [this](http://www... |
414,959 | <p>I have a user control and I want to create a property of type storyboard which I can set in xaml, so I tried to following, but I get a bad property error when I run it:</p>
<pre><code>private Storyboard sbTransitionIn_m;
public Storyboard TransitionIn
{
get {return sbTransitionIn_m;}
set {sbTransitionIn_m =... | [
{
"answer_id": 415046,
"author": "Michael S. Scherotter",
"author_id": 27306,
"author_profile": "https://Stackoverflow.com/users/27306",
"pm_score": 1,
"selected": false,
"text": "<p>Storyboard can't serialize from a string attribute like that. Try this:</p>\n\n<pre><code><MyStuff:My... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] | I have a user control and I want to create a property of type storyboard which I can set in xaml, so I tried to following, but I get a bad property error when I run it:
```
private Storyboard sbTransitionIn_m;
public Storyboard TransitionIn
{
get {return sbTransitionIn_m;}
set {sbTransitionIn_m = value;}
}
``... | Define the storyboard in Resources and then refer it as staticresource
```
<UserControl.Resources>
<Storyboard x:Key="sbShow">
<!-- -->
</Storyboard>
</UserControl.Resources>
<MyStuff:MyUserControl x:Name="ctlTest" TransitionIn="{StaticResource sbShow}"/>
``` |
414,976 | <p>I have 4 images on a page. I want to trigger a JS event once all 4 images are loaded. I of course can't be sure which order the images will be loaded in, so I can't trigger the event on the last image. One thought was to have a counter, but I can't think of the best way to check when that counter is equal to 4 as I ... | [
{
"answer_id": 414980,
"author": "Salty",
"author_id": 50548,
"author_profile": "https://Stackoverflow.com/users/50548",
"pm_score": 2,
"selected": false,
"text": "<pre><code>count=0;\n$(\"img\").load(function() {\n count++;\n if(count==4) { //All images have loaded\n //Do s... | 2009/01/05 | [
"https://Stackoverflow.com/questions/414976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | I have 4 images on a page. I want to trigger a JS event once all 4 images are loaded. I of course can't be sure which order the images will be loaded in, so I can't trigger the event on the last image. One thought was to have a counter, but I can't think of the best way to check when that counter is equal to 4 as I don... | As regards [Salty's example](https://stackoverflow.com/a/414980/44084), it's best to use a closure to avoid global variables, like such:
```
$("img").load(function() {
var count = 0, numImages = $("img").size();
return function () {
if (++count === numImages) {
//All images have loade... |
414,981 | <p>I have this struct:</p>
<pre><code>struct Map
{
public int Size;
public Map ( int size )
{
this.Size = size;
}
public override string ToString ( )
{
return String.Format ( "Size: {0}", this.Size );
}
}
</code></pre>
<p>When using array, it works:</p>
<pre><code>Map [ ... | [
{
"answer_id": 414989,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 7,
"selected": true,
"text": "<p>The C# compiler will give you the following error:</p>\n\n<blockquote>\n <p>Cannot modify the return value of 'Sys... | 2009/01/06 | [
"https://Stackoverflow.com/questions/414981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51816/"
] | I have this struct:
```
struct Map
{
public int Size;
public Map ( int size )
{
this.Size = size;
}
public override string ToString ( )
{
return String.Format ( "Size: {0}", this.Size );
}
}
```
When using array, it works:
```
Map [ ] arr = new Map [ 4 ] {
new Map(1... | The C# compiler will give you the following error:
>
> Cannot modify the return value of 'System.Collections.Generic.List.this[int]' because it is not a variable
>
>
>
The reason is that structs are value types so when you access a list element you will in fact access an intermediate copy of the element which has... |
414,982 | <p>I am working with some Xml Serialization in ASP.NET 2.0 in a web service. The issue is that I have an element which is defined such as this:</p>
<pre><code><System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable:=True)> _
Public Property COMMENTFIELD() As S... | [
{
"answer_id": 415030,
"author": "Tom A",
"author_id": 10226,
"author_profile": "https://Stackoverflow.com/users/10226",
"pm_score": 0,
"selected": false,
"text": "<p>It is probably dangerous to mix two different encoding conventions within the same string. Since you have your own conve... | 2009/01/06 | [
"https://Stackoverflow.com/questions/414982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5862/"
] | I am working with some Xml Serialization in ASP.NET 2.0 in a web service. The issue is that I have an element which is defined such as this:
```
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable:=True)> _
Public Property COMMENTFIELD() As String
Get
... | If you look at the [XML spec](http://www.w3.org/TR/REC-xml/) section 2.4, you see that the & character in an element's text always used to indicate something escaped, so if you want to send an & character, it needs to be escaped, e.g., as & So .Net is converting the literal string you gave it into valid XML.
If you re... |
414,984 | <p>Given the following code:</p>
<pre><code>var people = new List<person>(){ new person { Name = "John", FamilyName = "Pendray" },
new person { FamilyName = "Emery", Name = "Jake"},
new person { FamilyName = "Pendray", Name = "Richard" } };
var q = from p in people
ord... | [
{
"answer_id": 415148,
"author": "configurator",
"author_id": 9536,
"author_profile": "https://Stackoverflow.com/users/9536",
"pm_score": 0,
"selected": false,
"text": "<p>Definitely.</p>\n\n<p>You would have to change the select part. The easiest way would be to define a function that w... | 2009/01/06 | [
"https://Stackoverflow.com/questions/414984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18899/"
] | Given the following code:
```
var people = new List<person>(){ new person { Name = "John", FamilyName = "Pendray" },
new person { FamilyName = "Emery", Name = "Jake"},
new person { FamilyName = "Pendray", Name = "Richard" } };
var q = from p in people
orderby p.Name
... | ```
var q = from p in people
orderby p.Name
group p by p.FamilyName into fam
orderby fam.Key
select fam.Key + " " + string.Join(" ", (from fm in fam select fm.Name).ToArray());
```
Returns
`Emery Jake`
`Pendray John Richard` |
414,986 | <p>I have a chunk of code where it appears that a variable is changing at the end of a pre-processor block of code.</p>
<pre><code>int initialKeyCount;
#if(DEBUG)
// int initialKeyCount = _root.CountAllKeys();
initialKeyCount = 20000;
#endif
currNode = currNode.EnsureDegreeKeysPresent(parent); //i... | [
{
"answer_id": 415024,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 1,
"selected": false,
"text": "<p>This sort of behaviour sounds very much like the debugger is running code that doesn't match the source code you are e... | 2009/01/06 | [
"https://Stackoverflow.com/questions/414986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51851/"
] | I have a chunk of code where it appears that a variable is changing at the end of a pre-processor block of code.
```
int initialKeyCount;
#if(DEBUG)
// int initialKeyCount = _root.CountAllKeys();
initialKeyCount = 20000;
#endif
currNode = currNode.EnsureDegreeKeysPresent(parent); //initialKeyCount... | Sounds like Visual Studio got confused. Try these steps in order
1. Use the Clean command
2. Restart Visual Studio
3. Delete every DLL and EXE that even remotely looks like your program
4. Double check every BIN and OBJ folder to see if you missed anything.
5. Search your whole hard drive for any DLL and EXE that even... |
415,005 | <p>I'm using <strong>PHP 4.3.9, Apache/2.0.52</strong></p>
<p>I'm trying to get a login system working that registers DB values in a session where they're available once logged in. <strong>I'm losing the session variables once I'm redirected</strong>.</p>
<p>I'm using the following code to print the session ID/values... | [
{
"answer_id": 415017,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 2,
"selected": false,
"text": "<p>Try doing a </p>\n\n<pre><code>session_regenerate_id(true); \n</code></pre>\n\n<p>before the </p>\n\n<pre><code>se... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using **PHP 4.3.9, Apache/2.0.52**
I'm trying to get a login system working that registers DB values in a session where they're available once logged in. **I'm losing the session variables once I'm redirected**.
I'm using the following code to print the session ID/values on my login form page and the redirected p... | I don't see a `session_start()` in your login script. If you aren't starting the session I don't think php will save any data you place in the `$_SESSION` array. Also to be safe I'd explicitly place variables into the `$_SESSION` array instead of just overwriting the whole thing with `$_SESSION = mysql_fetch_array($res... |
415,036 | <p>I'm trying to sort through a collection of DeepZoom sub-images based on arbitrary data associated with each image. The sub-images get loaded automagically through an XML file generated by DeepZoom Composer. I don't see a clear way to associate arbitrary data with a DeepZoom sub-image. </p>
<p>The solutions that see... | [
{
"answer_id": 476724,
"author": "Gabriel Isenberg",
"author_id": 1473493,
"author_profile": "https://Stackoverflow.com/users/1473493",
"pm_score": 1,
"selected": false,
"text": "<p>Metadata.xml has a Tag property that can be associated with each image. Hurray!</p>\n"
},
{
"answe... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1473493/"
] | I'm trying to sort through a collection of DeepZoom sub-images based on arbitrary data associated with each image. The sub-images get loaded automagically through an XML file generated by DeepZoom Composer. I don't see a clear way to associate arbitrary data with a DeepZoom sub-image.
The solutions that seem most obv... | As you've noticed DeepZoomComposer supports a `<Tag></Tag>` element which you can use in your Silverlight MultiScaleImage control ([filtering by tag example](http://blog.kirupa.com/?p=212)).
You are also right that you would 'lose' any information you add to the XML file when you edit in DeepZoomComposer and re-genera... |
415,063 | <p>I am compiling some benchmarks, and it says that I can try the option gcc-serial instead of only gcc, can anyone please explain the difference between gcc and gcc serial?.</p>
<p>The place where that appears is <a href="http://parsec.cs.princeton.edu/download/tutorial/parsec-tutorial.pdf" rel="nofollow noreferrer">... | [
{
"answer_id": 415097,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 1,
"selected": false,
"text": "<p>I've never heard of <code>gcc-serial</code>, and I've used <code>gcc</code> for quite a while. Can you clarify m... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39160/"
] | I am compiling some benchmarks, and it says that I can try the option gcc-serial instead of only gcc, can anyone please explain the difference between gcc and gcc serial?.
The place where that appears is [here](http://parsec.cs.princeton.edu/download/tutorial/parsec-tutorial.pdf) and it is mentioned for example in the... | The slides refer to a tool from Stanford (PARSEC) meant to benchmark multithreaded shared memory programs -- a.k.a. parallel programs. In many cases, "serial" is the opposite of "parallel":
```
$ cat config/gcc-serial.bldconf
#!/bin/bash
#
# gcc-serial.bldconf - file containing global information necessary to build
# ... |
415,065 | <p>I am trying to write a CSS in which when the user writes text and it overflows instead of having a scrollbar or hiding, it just goes down like in a normal Word Document or so. I have this code:</p>
<pre><code>#content-text {
width: 960px;
padding-left: 10px;
padding-right:10px;
text-align: left;
... | [
{
"answer_id": 415072,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 2,
"selected": false,
"text": "<p>Try: <a href=\"http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow\" rel=\"nofollow noreferrer\"><code>overflow: visible</... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28586/"
] | I am trying to write a CSS in which when the user writes text and it overflows instead of having a scrollbar or hiding, it just goes down like in a normal Word Document or so. I have this code:
```
#content-text {
width: 960px;
padding-left: 10px;
padding-right:10px;
text-align: left;
color:#000;
... | So your css is probably fine. For example on my page I have css is like this:
```
textarea.input_field2 {
margin: 10px 10px 10px 0px;
width: 440px;
height: 150px;
background:#696969;
color: white;
border: none;
font-size: 14px;
text-align: left;
vertical-align: middle;
}
```... |
415,092 | <p>I'm writing my first PHP app that has to directly deal with dates, and thus to directly deal with the fact that PHP and MySQL have different date formats.</p>
<p>My question is: what's the most elegant way to manage this difference?</p>
<p>I have the following two functions to manage the difference using php:</p>
... | [
{
"answer_id": 415106,
"author": "Bill Zeller",
"author_id": 19234,
"author_profile": "https://Stackoverflow.com/users/19234",
"pm_score": 2,
"selected": false,
"text": "<p>Store everything in the database in a datetime field in UTC. For PHP manipulation, use the <a href=\"http://pear.ph... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36848/"
] | I'm writing my first PHP app that has to directly deal with dates, and thus to directly deal with the fact that PHP and MySQL have different date formats.
My question is: what's the most elegant way to manage this difference?
I have the following two functions to manage the difference using php:
```
function mysql_d... | Since (around) PHP 5.2, PHP has had a built in class/object for dealing with Dates and Times, called [DateTime](http://us2.php.net/date_create). In a void, it's always better to use a built-in than to wrangle with the messy details yourself.
The DateTime constructor (or the date\_create function) accepts a date in any... |
415,101 | <p>Can someone post a Visual Studio macro which goes through all C# source files in a project and adds a file banner? Extra credit if it works for any type of source file (.cs, .xaml, etc).</p>
| [
{
"answer_id": 415157,
"author": "Pop Catalin",
"author_id": 4685,
"author_profile": "https://Stackoverflow.com/users/4685",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://jamesewelch.com/2008/09/09/visual-studio-macro-to-add-file-headers/\" rel=\"nofollow noreferrer\">Vi... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38087/"
] | Can someone post a Visual Studio macro which goes through all C# source files in a project and adds a file banner? Extra credit if it works for any type of source file (.cs, .xaml, etc). | Here you go, I provide an example for .cs and .vb but shouldn't be hard for you to adjust it to your other file type needs: ***Edited to recursively add header to sub-folders***
```
Sub IterateFiles()
Dim solution As Solution = DTE.Solution
For Each prj As Project In solution.Projects
IterateProjectFil... |
415,158 | <p>I have the following code, which splits up a Vector into a string vector (to use as a key) and an integer at the end (to use as value).</p>
<pre><code>payoffs.put(new Vector<String>(keyAndOutput.subList(0, keyAndOutput.size() - 1)), Integer.parseInt(keyAndOutput.lastElement()));
</code></pre>
<p>The TreeMap ... | [
{
"answer_id": 415166,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know if this is the cause of your problem, but compare functions in Java usually return negative or positive or 0, ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51792/"
] | I have the following code, which splits up a Vector into a string vector (to use as a key) and an integer at the end (to use as value).
```
payoffs.put(new Vector<String>(keyAndOutput.subList(0, keyAndOutput.size() - 1)), Integer.parseInt(keyAndOutput.lastElement()));
```
The TreeMap in question is constructed using... | Answering Not answering the question, with but a couple minor points besides about your code:
1. You should not do the compareTo twice; compare once and assign the result to sgn; then break if !=0
2. Your else continue is redundant.
3. You should not compare for -1 or 1, but <0 or >0; many compareTo methods return bas... |
415,160 | <p>What is the best method for creating an <a href="http://en.wikipedia.org/wiki/XMLHttpRequest" rel="noreferrer">XMLHttpRequest</a> object?</p>
<p>It should work in all capable browsers.</p>
| [
{
"answer_id": 415165,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 3,
"selected": false,
"text": "<p>Use <a href=\"http://jquery.com/\" rel=\"nofollow noreferrer\">jQuery</a> (or a similar JavaScript library). It takes c... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51886/"
] | What is the best method for creating an [XMLHttpRequest](http://en.wikipedia.org/wiki/XMLHttpRequest) object?
It should work in all capable browsers. | For a library-less solution, you can emulate Prototype's use of `Try.these` fairly easily:
```
function newAjax() {
try { return new XMLHttpRequest(); } catch(){}
try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(){}
try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } cat... |
415,170 | <p>I am working on my first project using ExtJS.</p>
<p>I have a Data Grid sitting inside a Tab that is inside a Window.</p>
<p>I want to add a link or button to the each element of the grid (I am using extended elements at the moment with HTML content through the RowExpander) that will make an AJAX call and open ano... | [
{
"answer_id": 415165,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 3,
"selected": false,
"text": "<p>Use <a href=\"http://jquery.com/\" rel=\"nofollow noreferrer\">jQuery</a> (or a similar JavaScript library). It takes c... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14971/"
] | I am working on my first project using ExtJS.
I have a Data Grid sitting inside a Tab that is inside a Window.
I want to add a link or button to the each element of the grid (I am using extended elements at the moment with HTML content through the RowExpander) that will make an AJAX call and open another tab. | For a library-less solution, you can emulate Prototype's use of `Try.these` fairly easily:
```
function newAjax() {
try { return new XMLHttpRequest(); } catch(){}
try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(){}
try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } cat... |
415,199 | <p>I understand that const_cast to remove constness of objects is bad, </p>
<p>I have the following use case, </p>
<pre><code>//note I cannot remove constness in the foo function
foo(const std::vector<Object> & objectVec) {
...
int size = (int) objectVec.size();
std::vector<Object> tempObjec... | [
{
"answer_id": 415226,
"author": "luqui",
"author_id": 33796,
"author_profile": "https://Stackoverflow.com/users/33796",
"pm_score": 3,
"selected": true,
"text": "<p>Well, that depends on Object. But the Objects <em>are</em> being copied, when you pass them to push_back. You can check ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | I understand that const\_cast to remove constness of objects is bad,
I have the following use case,
```
//note I cannot remove constness in the foo function
foo(const std::vector<Object> & objectVec) {
...
int size = (int) objectVec.size();
std::vector<Object> tempObjectVec;
//Indexing here is to just ... | Well, that depends on Object. But the Objects *are* being copied, when you pass them to push\_back. You can check this by adding some debug code to the copy constructor. So if Object is well-behaved and keeps distinct copies separate, then foo1 can change the vector it gets all it likes.
A more efficient way to do thi... |
415,213 | <p>I have a PHP IRC Robot that I use in my channel and I need it to make OPs to specific set users in the script by me. Anyways I want the robot to check if the user is logged into NickServ to prevent any sort of fraud or anything.</p>
<p>Anyways, here is my connect and DO things code, followed by what I really need h... | [
{
"answer_id": 415271,
"author": "Forrest Marvez",
"author_id": 51237,
"author_profile": "https://Stackoverflow.com/users/51237",
"pm_score": 0,
"selected": false,
"text": "<p>First of all, remove the password for your bot.(fixed)</p>\n\n<p>Gave some tips on your IRC, good luck, you're o... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a PHP IRC Robot that I use in my channel and I need it to make OPs to specific set users in the script by me. Anyways I want the robot to check if the user is logged into NickServ to prevent any sort of fraud or anything.
Anyways, here is my connect and DO things code, followed by what I really need help with b... | I assume the second snippet resides inside your while(fgets()) loop.
You won't have your result in the loop where you use fwrite() then. Either add another fgets() after
```
$result = fwrite($socket, "$command \r\n");
```
or consequently use your loop and maybe add a status flag to know how to treat the next execut... |
415,218 | <p>I have this function from a plugin (from a previous post)</p>
<pre><code>// This method implements the test condition for
// finding the ResolutionInfo.
private static bool IsResolutionInfo(ImageResource res)
{
return res.ID == (int)ResourceIDs.ResolutionInfo;
}
</code></pre>
<p>And the line thats calling this ... | [
{
"answer_id": 415227,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 3,
"selected": true,
"text": "<pre><code>get\n {\n return (ResolutionInfo)m_imageResources.Find(res => res.ID == (int)ResourceIDs.ResolutionInfo);\n... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50312/"
] | I have this function from a plugin (from a previous post)
```
// This method implements the test condition for
// finding the ResolutionInfo.
private static bool IsResolutionInfo(ImageResource res)
{
return res.ID == (int)ResourceIDs.ResolutionInfo;
}
```
And the line thats calling this function:
```
get
{
... | ```
get
{
return (ResolutionInfo)m_imageResources.Find(res => res.ID == (int)ResourceIDs.ResolutionInfo);
}
```
Does that clear it up at all?
Just to further clear things up, looking at reflector, this is what the Find method looks like:
```
public T Find(Predicate<T> match)
{
if (match == null)
{
... |
415,234 | <p>I just found out (the hard way), that when you have a HTML form with <code>action=""</code>, Webkit browsers treat it differently to Firefox and Internet Explorer.</p>
<p>In FF and IE, these two form tags are equivalent:</p>
<pre><code><form method="post" action="">
<form method="post">
</code></pre>
... | [
{
"answer_id": 415246,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 3,
"selected": false,
"text": "<p>The best way in my opinion would be not to omit the action attribute (which would not validate) but to specify th... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | I just found out (the hard way), that when you have a HTML form with `action=""`, Webkit browsers treat it differently to Firefox and Internet Explorer.
In FF and IE, these two form tags are equivalent:
```
<form method="post" action="">
<form method="post">
```
They will both submit the form back to the same page... | I usually use
```
<form method='POST' action='?'>
```
This means the current URL but with no parameters. |
415,240 | <p>So I'm refactoring a legacy codebase I've inherited, and in the process I found a static class that encapsulates the logic for launching 3rd party applications. It essentially looks like this (shortened for brevity to only show one application):</p>
<pre><code>using System.IO;
using System.Configuration;
public sta... | [
{
"answer_id": 415266,
"author": "Jonathan Allen",
"author_id": 5274,
"author_profile": "https://Stackoverflow.com/users/5274",
"pm_score": 0,
"selected": false,
"text": "<p>Seems reasonable to me.</p>\n\n<p>I did something similar in the past, but I didn't have an abstract base class. I... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47580/"
] | So I'm refactoring a legacy codebase I've inherited, and in the process I found a static class that encapsulates the logic for launching 3rd party applications. It essentially looks like this (shortened for brevity to only show one application):
```
using System.IO;
using System.Configuration;
public static class Exte... | Here is another way of refactoring this:
```
using System.IO;
public class ExternalApplication
{
public ExternalApplication(string path)
{
this.Path = path;
}
public string Path { get; protected set; }
public bool Exists()
{
if(string.IsNullOrEmpty(this.Path))
throw new Config... |
415,279 | <p>I am trying to get PhysX working using Ubuntu.</p>
<p>First, I downloaded the SDK here:</p>
<ul>
<li><a href="http://developer.download.nvidia.com/PhysX/2.8.1/PhysX_2.8.1_SDK_CoreLinux_deb.tar.gz" rel="nofollow noreferrer">http://developer.download.nvidia.com/PhysX/2.8.1/PhysX_2.8.1_SDK_CoreLinux_deb.tar.gz</a></l... | [
{
"answer_id": 415487,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 3,
"selected": true,
"text": "<p>It looks like you're confusing header files with library files. NxPhysics.h is a source code header file. Header files... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48096/"
] | I am trying to get PhysX working using Ubuntu.
First, I downloaded the SDK here:
* <http://developer.download.nvidia.com/PhysX/2.8.1/PhysX_2.8.1_SDK_CoreLinux_deb.tar.gz>
---
Next, I extracted the files and installed each package with:
```
dpkg -i filename.deb
```
This gives me the following files located in /us... | It looks like you're confusing header files with library files. NxPhysics.h is a source code header file. Header files are needed when compiling source code (not when linking). It's probably located in a place like /usr/include or /usr/include/PhysX/v2.8.1, or similar. Find the real location of this file and make sure ... |
415,287 | <p>I'd like to know which is the preferred way to add records to a database table in a Rails Migration. I've read on Ola Bini's book (Jruby on Rails) that he does something like this:</p>
<pre><code>class CreateProductCategories < ActiveRecord::Migration
#defines the AR class
class ProductType < ActiveRecor... | [
{
"answer_id": 418678,
"author": "user52227",
"author_id": 52227,
"author_profile": "https://Stackoverflow.com/users/52227",
"pm_score": 2,
"selected": false,
"text": "<p>your migrations have access to all your models, so you shouldn't be creating a class inside the migration.</p>\n\n<p>... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7595/"
] | I'd like to know which is the preferred way to add records to a database table in a Rails Migration. I've read on Ola Bini's book (Jruby on Rails) that he does something like this:
```
class CreateProductCategories < ActiveRecord::Migration
#defines the AR class
class ProductType < ActiveRecord::Base; end
def ... | You could use fixtures for that. It means having a yaml file somewhere with the data you want to insert.
Here is a changeset I committed for this in one of my app:
`db/migrate/004_load_profiles.rb`
```
require 'active_record/fixtures'
class LoadProfiles < ActiveRecord::Migration
def self.up
down()
direct... |
415,291 | <p>I have 3 byte arrays in C# that I need to combine into one. What would be the most efficient method to complete this task?</p>
| [
{
"answer_id": 415307,
"author": "FryGuy",
"author_id": 28776,
"author_profile": "https://Stackoverflow.com/users/28776",
"pm_score": 5,
"selected": false,
"text": "<p>If you simply need a new byte array, then use the following:</p>\n\n<pre><code>byte[] Combine(byte[] a1, byte[] a2, byte... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20183/"
] | I have 3 byte arrays in C# that I need to combine into one. What would be the most efficient method to complete this task? | For primitive types (including bytes), use [`System.Buffer.BlockCopy`](https://learn.microsoft.com/en-us/dotnet/api/system.buffer.blockcopy) instead of [`System.Array.Copy`](https://learn.microsoft.com/en-us/dotnet/api/system.array.copy). It's faster.
I timed each of the suggested methods in a loop executed 1 million ... |
415,297 | <p>Let us ignore for a moment Damian Conway's best practice of no more than three positional parameters for any given subroutine.</p>
<p>Is there any difference between the two examples below in regards to performance or functionality?</p>
<p>Using <code>shift</code>:</p>
<pre><code>sub do_something_fantastical {
... | [
{
"answer_id": 415390,
"author": "Joe Casadonte",
"author_id": 45978,
"author_profile": "https://Stackoverflow.com/users/45978",
"pm_score": 3,
"selected": false,
"text": "<p>I would imagine the shift example is slower than using @_ because it's 6 function calls instead of 1. Whether or... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6406/"
] | Let us ignore for a moment Damian Conway's best practice of no more than three positional parameters for any given subroutine.
Is there any difference between the two examples below in regards to performance or functionality?
Using `shift`:
```
sub do_something_fantastical {
my $foo = shift;
my $bar = sh... | There's a functional difference. The [shift](http://perldoc.perl.org/functions/shift.html) modifies `@_`, and the assignment from `@_` does not. If you don't need to use `@_` afterward, that difference probably doesn't matter to you. I try to always use the list assignment, but I sometimes use `shift`.
However, if I ... |
415,302 | <pre><code><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
<script type="text/javascript">
function bigtosmalltriangle() {
$(this).siblings("div.break").removeClass('triangle3').addClass('triangle1');
setTimeout ( "smalltomediumtrian... | [
{
"answer_id": 415325,
"author": "Matthew Crumley",
"author_id": 2214,
"author_profile": "https://Stackoverflow.com/users/2214",
"pm_score": 3,
"selected": true,
"text": "<p>The problem is that \"this\" is not bound to the span you clicked on in the bigtosmalltriangle, smalltomediumtrian... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
<script type="text/javascript">
function bigtosmalltriangle() {
$(this).siblings("div.break").removeClass('triangle3').addClass('triangle1');
setTimeout ( "smalltomediumtriangle()", 400 );
}
... | The problem is that "this" is not bound to the span you clicked on in the bigtosmalltriangle, smalltomediumtriangle, and mediumtobigtriangle functions. You need to either pass in the element as a parameter, or set a variable that's in scope in all the functions through closures.
Parameter passing:
------------------
... |
415,313 | <p>Say I'm working with Sharepoint (this applies to other object models as well) and in the middle of my statement, I call a method, in this case "OpenWeb()", which creates an IDisposable SPWeb object. Now, I cannot call Dispose() on the SPWeb object because I don't have the reference to it. <strong>So do I need to be... | [
{
"answer_id": 415319,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": false,
"text": "<p>You should explicitly (or implicitly via <em>using</em> statement) call Dispose method . Another reasons to split code in mul... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48988/"
] | Say I'm working with Sharepoint (this applies to other object models as well) and in the middle of my statement, I call a method, in this case "OpenWeb()", which creates an IDisposable SPWeb object. Now, I cannot call Dispose() on the SPWeb object because I don't have the reference to it. **So do I need to be concerned... | "what happens to the IDisposable object that I cannot explicitly call Dispose() on?"
In general you can call Dispose (either implicitly with a using statement or explicitly) on all disposable objects, however in the hypothetical scenario where you **can not**, it **depends** on the way the object was implemented.
I... |
415,315 | <p>Is there a way to use fields_for with in a form without having a scope?</p>
<p>For example:</p>
<pre><code><% fields_for "user[]" do |x|
<%= x.text_field :name %>
<% end %>
</code></pre>
<p>Without the user model being loaded in memory?</p>
<p>I got it working using territory[user][][name], but ... | [
{
"answer_id": 415328,
"author": "Derek P.",
"author_id": 45615,
"author_profile": "https://Stackoverflow.com/users/45615",
"pm_score": 0,
"selected": false,
"text": "<p>is there any specific reason you need to use form_for specifically? Its really designed to be used with an instantiate... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10258/"
] | Is there a way to use fields\_for with in a form without having a scope?
For example:
```
<% fields_for "user[]" do |x|
<%= x.text_field :name %>
<% end %>
```
Without the user model being loaded in memory?
I got it working using territory[user][][name], but I would like to keep it in ERB. | I think the answer would be 'no', since those `form_for` and `fields_for` would try to determine default value from that given instance variable.
However, I think if you want to lower memory usage from loading that model, you might try to create a mock-up model to return nil values, and create a instance object from t... |
415,368 | <p>LCDs have 4 data lines. But the data to be displayed in the LCD is given in the ASCII form which is 7 bits. How is that possible?</p>
| [
{
"answer_id": 415379,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "<p>I answered a question from another user a while ago (<a href=\"https://stackoverflow.com/questions/248949/lcd-8-bit-m... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | LCDs have 4 data lines. But the data to be displayed in the LCD is given in the ASCII form which is 7 bits. How is that possible? | I answered a question from another user a while ago ([here](https://stackoverflow.com/questions/248949/lcd-8-bit-mode-to-4-bit-mode)) that referenced the following doc: [www.cloverlcd.com/pdf/S6A0069.pdf](http://www.cloverlcd.com/pdf/S6A0069.pdf). You can get an idea as to how it may work from that link (at least for t... |
415,407 | <p>I'm working on making a simple server application with python, and I'm trying to get the IP to bind the listening socket to. An example I looked at uses this: </p>
<pre><code>HOST = gethostbyaddr(gethostname())
</code></pre>
<p>With a little more processing after this, it should give me just the host IP as a strin... | [
{
"answer_id": 415417,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 5,
"selected": true,
"text": "<p>Getting your IP address is harder than you might think.</p>\n\n<p>Check <a href=\"https://stackoverflow.com/questi... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I'm working on making a simple server application with python, and I'm trying to get the IP to bind the listening socket to. An example I looked at uses this:
```
HOST = gethostbyaddr(gethostname())
```
With a little more processing after this, it should give me just the host IP as a string. This should return the ... | Getting your IP address is harder than you might think.
Check [this answer](https://stackoverflow.com/questions/270745/how-do-i-determine-all-of-my-ip-addresses-when-i-have-multiple-nics#274644) I gave for the one reliable way I've found.
Here's what the answer says in case you don't like clicking on things:
Use the... |
415,409 | <p>In order to run one application, a batch file has to be kicked off (which does things like start Jetty, display live logs, etc). The application will work only if this batch file is running. I am hence forced to have this batch file running and not logout from the Windows server.</p>
<p>Can this batch file be run a... | [
{
"answer_id": 415484,
"author": "lexu",
"author_id": 31472,
"author_profile": "https://Stackoverflow.com/users/31472",
"pm_score": 2,
"selected": false,
"text": "<p>As Doug Currie says use RunAsService. </p>\n\n<p>From my past experience you must remember that the Service you generate w... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28609/"
] | In order to run one application, a batch file has to be kicked off (which does things like start Jetty, display live logs, etc). The application will work only if this batch file is running. I am hence forced to have this batch file running and not logout from the Windows server.
Can this batch file be run as a servic... | [NSSM](http://nssm.cc/usage) is totally free and hyper-easy, running command prompt / terminal as administrator:
```
nssm install "YourCoolServiceNameLabel"
```
then a dialog will appear so you can choose where is the file you want to run.
to uninstall
```
nssm remove "YourCoolServiceNameLabel"
``` |
415,433 | <p>sometimes, git will spontaneously (during some, but not all, "pull" or "clone" operations) copy all of the remote branches of a repository into my local repository (and even set them all up to track the corresponding remote branches correctly). What causes this? Is there a way I can do this on purpose?</p>
| [
{
"answer_id": 415542,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 3,
"selected": false,
"text": "<p>If you just do a normal branch from a remote branch, it'll track by default:</p>\n\n<pre><code>git checkout -b somebranc... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13195/"
] | sometimes, git will spontaneously (during some, but not all, "pull" or "clone" operations) copy all of the remote branches of a repository into my local repository (and even set them all up to track the corresponding remote branches correctly). What causes this? Is there a way I can do this on purpose? | If you just do a normal branch from a remote branch, it'll track by default:
```
git checkout -b somebranch origin/somebranch
```
means roughly the same thing as
```
git checkout -t origin/somebranch
```
You pretty much have to explicitly tell it if you don't want such tracking. |
415,455 | <p>I have some old software (in a language that's not dead but is dead to me ;-)) that implements a basic pattern-matching and -rewriting system for source code. I am considering resurrecting this code, translating it into a modern language, and open-sourcing the project as a refactoring power-tool. Before I go much fu... | [
{
"answer_id": 415486,
"author": "Doug Currie",
"author_id": 33252,
"author_profile": "https://Stackoverflow.com/users/33252",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.txl.ca/\" rel=\"nofollow noreferrer\">TXL</a> is rule based rather than pattern based, so it h... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9345/"
] | I have some old software (in a language that's not dead but is dead to me ;-)) that implements a basic pattern-matching and -rewriting system for source code. I am considering resurrecting this code, translating it into a modern language, and open-sourcing the project as a refactoring power-tool. Before I go much furth... | [TXL](http://www.txl.ca/) is rule based rather than pattern based, so it has more capabilities but perhaps a steeper learning curve. |
415,483 | <p>I have a file input element that needs to be cloned after the user has browsed and selected a file to upload. I started by using obj.cloneNode() and everything worked fine, that is until I tried using it in IE. </p>
<p>I've since tried using jQuery's clone method as follows:</p>
<pre><code>var tmp = jQuery('#categ... | [
{
"answer_id": 415498,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>Editing the file form field is a security risk and thus is disabled on most browsers and <em>should</em> be disabled on fire... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42033/"
] | I have a file input element that needs to be cloned after the user has browsed and selected a file to upload. I started by using obj.cloneNode() and everything worked fine, that is until I tried using it in IE.
I've since tried using jQuery's clone method as follows:
```
var tmp = jQuery('#categoryImageFileInput_'+i... | Editing the file form field is a security risk and thus is disabled on most browsers and *should* be disabled on firefox. It is not a good idea to rely on this feature. Imagine if somebody was able, using javascript, to change a hidden file upload field to, lets say,
c:\Users\Person\Documents\Finances
Or
C:\Users\Pe... |
415,488 | <p>After reading this article <a href="http://www.codinghorror.com/blog/archives/000228.html" rel="noreferrer">http://www.codinghorror.com/blog/archives/000228.html</a> I understand the benefits of compiled regular expressions a little better, however in what personal scenarios would you consider mandates the use of a ... | [
{
"answer_id": 415499,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "<p>I would compile the RE when it has to be used more than two or three times and the cost of compiling is more than off... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41211/"
] | After reading this article <http://www.codinghorror.com/blog/archives/000228.html> I understand the benefits of compiled regular expressions a little better, however in what personal scenarios would you consider mandates the use of a compiled Reg Ex?
For instance, I am using a regex in a loop and the regular expressio... | In .NET, there are two ways to "compile" a regular expression. Regular expressions are always "compiled" before they can be used to find matches. When you instantiate the Regex class without the RegexOptions.Compiled flag, your regular expression is still converted into an internal data structure used by the Regex clas... |
415,511 | <p>How do I get the current time?</p>
| [
{
"answer_id": 415519,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 13,
"selected": true,
"text": "<p>Use <a href=\"https://docs.python.org/3/library/datetime.html\" rel=\"noreferrer\"><code>datetime</code></a>:</p>... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46646/"
] | How do I get the current time? | Use [`datetime`](https://docs.python.org/3/library/datetime.html):
```
>>> import datetime
>>> now = datetime.datetime.now()
>>> now
datetime.datetime(2009, 1, 6, 15, 8, 24, 78915)
>>> print(now)
2009-01-06 15:08:24.789150
```
For just the clock time without the date:
```
>>> now.time()
datetime.time(15, 8, 24, 789... |
415,515 | <p>Pretty self-explanatory, I tried google and got a lot of the dreaded expertsexchange, I searched here as well to no avail. An online tutorial or example would be best. Thanks guys.</p>
| [
{
"answer_id": 415547,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>This is a good exercise for yourself to work on :)</p>\n\n<p>You should break your library into three parts</p>\n\n<ul>\n<l... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50391/"
] | Pretty self-explanatory, I tried google and got a lot of the dreaded expertsexchange, I searched here as well to no avail. An online tutorial or example would be best. Thanks guys. | If what you're really doing is manipulating a CSV file itself, Nelson's answer makes sense. However, my suspicion is that the CSV is simply an artifact of the problem you're solving. In C++, that probably means you have something like this as your data model:
```
struct Customer {
int id;
std::string first_nam... |