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 |
|---|---|---|---|---|---|---|
346,116 | <p>As the subject says I want to insert an image into the 2nd column of grid
defined with 2 columndefintions.</p>
<p>Programmatically that is???</p>
<p>I cannot see how to select the column using grid.Children.insert(1, img)
does not work.</p>
<p>Malcolm</p>
| [
{
"answer_id": 346166,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": false,
"text": "<p>The row/column index on an element in WPF is an attached property. You set it using a static method on Grid, like thi... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40568/"
] | As the subject says I want to insert an image into the 2nd column of grid
defined with 2 columndefintions.
Programmatically that is???
I cannot see how to select the column using grid.Children.insert(1, img)
does not work.
Malcolm | ```
Image imgControl = new Image();
Grid.SetColumn(imgControl, 1);
gridContainer.Children.Add(imgControl);
```
Objects contained in a grid are positioned based on the attached dependency properties Column Row ColumnSpan and RowSpan which are set as shown above. |
346,127 | <p>Here is a VB.NET code snippet</p>
<pre><code>Public Class OOPDemo
Private _strtString as String
Public Function Func(obj as OOPDemo) as boolean
obj._strString = "I can set value to private member using a object"
End Function
End Class
</code></pre>
<p>I thought we cannot access the private me... | [
{
"answer_id": 346166,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": false,
"text": "<p>The row/column index on an element in WPF is an attached property. You set it using a static method on Grid, like thi... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38997/"
] | Here is a VB.NET code snippet
```
Public Class OOPDemo
Private _strtString as String
Public Function Func(obj as OOPDemo) as boolean
obj._strString = "I can set value to private member using a object"
End Function
End Class
```
I thought we cannot access the private members using the object, bu... | ```
Image imgControl = new Image();
Grid.SetColumn(imgControl, 1);
gridContainer.Children.Add(imgControl);
```
Objects contained in a grid are positioned based on the attached dependency properties Column Row ColumnSpan and RowSpan which are set as shown above. |
346,132 | <p>I have unevenly distributed data (wrt <code>date</code>) for a few years (2003-2008). I want to query data for a given set of start and end date, grouping the data by any of the supported intervals (day, week, month, quarter, year) in <a href="https://www.postgresql.org/docs/8.3/functions-datetime.html#FUNCTIONS-DAT... | [
{
"answer_id": 346187,
"author": "ng.mangine",
"author_id": 37784,
"author_profile": "https://Stackoverflow.com/users/37784",
"pm_score": 0,
"selected": false,
"text": "<p>You could create a temporary table at runtime and left join on that. That seems to make the most sense.</p>\n"
},... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33612/"
] | I have unevenly distributed data (wrt `date`) for a few years (2003-2008). I want to query data for a given set of start and end date, grouping the data by any of the supported intervals (day, week, month, quarter, year) in [PostgreSQL 8.3](https://www.postgresql.org/docs/8.3/functions-datetime.html#FUNCTIONS-DATETIME-... | You can create the list of all first days of the last year (say) with
```
select distinct date_trunc('month', (current_date - offs)) as date
from generate_series(0,365,28) as offs;
date
------------------------
2007-12-01 00:00:00+01
2008-01-01 00:00:00+01
2008-02-01 00:00:00+01
2008-03-01 00:00:00+01
... |
346,138 | <p>I tried to combined tables which is <strong>fus_shift and root table</strong> into a new table which is <strong>final table</strong> but it outputs like "<strong>ERROR at line 2:
ORA-01789: query block has incorrect number of result columns</strong>". I tried also joining table as my alternative but it also outputs ... | [
{
"answer_id": 346145,
"author": "MOZILLA",
"author_id": 38997,
"author_profile": "https://Stackoverflow.com/users/38997",
"pm_score": 2,
"selected": false,
"text": "<p>You certainly cannot apply \"Union\" to your tables. It can be applied only if both queries return same number (and of ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28607/"
] | I tried to combined tables which is **fus\_shift and root table** into a new table which is **final table** but it outputs like "**ERROR at line 2:
ORA-01789: query block has incorrect number of result columns**". I tried also joining table as my alternative but it also outputs "**ERROR at line 3: ORA-00918: column amb... | You certainly cannot apply "Union" to your tables. It can be applied only if both queries return same number (and of similar type) of columns.
You can join the two tables but would have to use "table alias" while joining since "record\_num" field is common in both the tables. Here is the query that would work for you
... |
346,175 | <p>In 64 bit versions of windows, 32 bit software is installed in "c:\program files (x86)". This means you cannot use $(programfiles) to get the path to (32 bit) software. So I need a $(ProgramFiles32) to overcome this in my MSBuild project. I don't want to change the project depending on the os it is running on.</p>
... | [
{
"answer_id": 346176,
"author": "wimh",
"author_id": 33499,
"author_profile": "https://Stackoverflow.com/users/33499",
"pm_score": 4,
"selected": false,
"text": "<p>My solution is to look whether \"c:\\program files (x86)\" exists, if it exists, asume this is a 64 bit os. Otherwise use ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33499/"
] | In 64 bit versions of windows, 32 bit software is installed in "c:\program files (x86)". This means you cannot use $(programfiles) to get the path to (32 bit) software. So I need a $(ProgramFiles32) to overcome this in my MSBuild project. I don't want to change the project depending on the os it is running on.
I have ... | In MSBuild 4.0+, there's [a `$(MSBuildProgramFiles32)` property](http://msdn.microsoft.com/en-us/library/ms164309.aspx) for it, which you can confidently employ directly (especially if you're prepared to put a `ToolsVersion="4.0"` at the top of the file to guarantee it's going to be available and [Fail Fast](http://en.... |
346,211 | <p>I used to have a Tests folders in my main project where a unit test had this line of code:</p>
<pre><code>Foo foo = new Foo(Environment.CurrentDirectory + @"\XML\FooData.xml" );
</code></pre>
<p>I have an XML directory in the Foo project that has a FooData.xml</p>
<p>In the post build event of my projects i have ... | [
{
"answer_id": 346214,
"author": "J c",
"author_id": 25837,
"author_profile": "https://Stackoverflow.com/users/25837",
"pm_score": 1,
"selected": false,
"text": "<p>I believe you need to update the post build event for the Foo.Tests project to be:</p>\n\n<p>\"$(ProjectDir)Foo.Test\\Curre... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | I used to have a Tests folders in my main project where a unit test had this line of code:
```
Foo foo = new Foo(Environment.CurrentDirectory + @"\XML\FooData.xml" );
```
I have an XML directory in the Foo project that has a FooData.xml
In the post build event of my projects i have the following line
copy "$(Projec... | Rather than having a post-build step, can you not just make it a "content" item in Visual Studio, telling it to copy it to the target directory? I usually either do that, or make it an embedded resource and use streams and Assembly.GetManifestResourceStream. |
346,226 | <p>I am totally new to XSLT and can't work out where I am going wrong with the following code.</p>
<pre><code><xsl:variable name="var" select="boolean('false')"/>
<xsl:if test="$var'">variable is true</xsl:if>
</code></pre>
<p>It is always returning true when it is meant to be false. Why?</p>
| [
{
"answer_id": 346227,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 4,
"selected": false,
"text": "<p>The boolean() function you are using is indeed doing it's job. For using explicit true and false values you should u... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5838/"
] | I am totally new to XSLT and can't work out where I am going wrong with the following code.
```
<xsl:variable name="var" select="boolean('false')"/>
<xsl:if test="$var'">variable is true</xsl:if>
```
It is always returning true when it is meant to be false. Why? | The value of the $var variable as defined in:
`<xsl:variable name="var" select="boolean('false')"/>`
is
**`true()`**
This is because in XPath "`false`" is an ordinary string, as opposed to `false()`, which is the constructor for the `boolean` value `false()`
**The two boolean values in XPath are** (note tha... |
346,243 | <p>If i have the following directory structure:</p>
<p>Project1/bin/debug<br>
Project2/xml/file.xml</p>
<p>I am trying to refer to file.xml from Project1/bin/debug directory</p>
<p>I am essentially trying to do the following:</p>
<pre><code>string path = Environment.CurrentDirectory + @"..\..\Project2\xml\File.xml"... | [
{
"answer_id": 346248,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 2,
"selected": false,
"text": "<p>Use:</p>\n\n<pre><code>System.IO.Path.GetFullPath(@\"..\\..\\Project2\\xml\\File.xml\")\n</code></pre>\n"
},
{
... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | If i have the following directory structure:
Project1/bin/debug
Project2/xml/file.xml
I am trying to refer to file.xml from Project1/bin/debug directory
I am essentially trying to do the following:
```
string path = Environment.CurrentDirectory + @"..\..\Project2\xml\File.xml":
```
what is the correct syntax f... | It's probably better to manipulate path components as path components, rather than strings:
```
string path = System.IO.Path.Combine(Environment.CurrentDirectory,
@"..\..\..\Project2\xml\File.xml");
``` |
346,267 | <p>I have a string like this that I need to parse into a 2D array:</p>
<pre><code> str = "'813702104[813702106]','813702141[813702143]','813702172[813702174]'"
</code></pre>
<p>the array equiv would be:</p>
<pre><code>arr[0][0] = 813702104
arr[0][1] = 813702106
arr[1][0] = 813702141
arr[1][1] = 813702143
#...... | [
{
"answer_id": 346276,
"author": "stesch",
"author_id": 41860,
"author_profile": "https://Stackoverflow.com/users/41860",
"pm_score": 4,
"selected": true,
"text": "<p>I would try <code>findall</code> or <code>finditer</code> instead of <code>match</code>.</p>\n\n<p>Edit by Oli: Yeah <cod... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] | I have a string like this that I need to parse into a 2D array:
```
str = "'813702104[813702106]','813702141[813702143]','813702172[813702174]'"
```
the array equiv would be:
```
arr[0][0] = 813702104
arr[0][1] = 813702106
arr[1][0] = 813702141
arr[1][1] = 813702143
#... etc ...
```
I'm trying to do this by REGE... | I would try `findall` or `finditer` instead of `match`.
Edit by Oli: Yeah `findall` work brilliantly but I had to simplify the regex to:
```
r"'(?P<main>\d+)\[(?P<thumb>\d+)\]',?"
``` |
346,297 | <p>Hi all I've just started a new project using Visual Web Developer 2008 Express and all my code behinds are not in any namespace. How can I set the default namespace for the project?</p>
<p>In VisualStudioPro it used to be in project properties, the website properties in Visual Web Developer 2008 Express seem very ... | [
{
"answer_id": 346337,
"author": "The Alpha Nerd",
"author_id": 43350,
"author_profile": "https://Stackoverflow.com/users/43350",
"pm_score": 0,
"selected": false,
"text": "<p>Do Find and Replace to find your namespace and replace it with what you want.</p>\n"
},
{
"answer_id": 3... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12148/"
] | Hi all I've just started a new project using Visual Web Developer 2008 Express and all my code behinds are not in any namespace. How can I set the default namespace for the project?
In VisualStudioPro it used to be in project properties, the website properties in Visual Web Developer 2008 Express seem very ... express... | Visual Web Developer (prior to 2008 SP1) does not support Web Application projects. Default namespace is only available in Web Application projects.
If you really want to add your classes to a namespace, you should do it manually (the namespace surround with code snippet can prove pretty useful) by enclosing them in a... |
346,301 | <p>Frequently I come across the following statements in C/C++ source code:</p>
<pre><code>$Id: lzio.c,v 1.24 2003/03/20 16:00:56 roberto Exp $
$Id: file name, version, timestamp, creator Exp $
</code></pre>
<p>Have you got any idea which software produces those "signatures"?</p>
| [
{
"answer_id": 346303,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 4,
"selected": true,
"text": "<p>Version control systems such as CVS can produce such tags.</p>\n"
},
{
"answer_id": 346304,
"author": "... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6619/"
] | Frequently I come across the following statements in C/C++ source code:
```
$Id: lzio.c,v 1.24 2003/03/20 16:00:56 roberto Exp $
$Id: file name, version, timestamp, creator Exp $
```
Have you got any idea which software produces those "signatures"? | Version control systems such as CVS can produce such tags. |
346,313 | <p>I'm trying to do a JOIN in Linq using lambda expressions ... and running into some problems. </p>
<p>I have two entities, Comments and CommentSources. CommentSources are associated to Comments. I have the following code, which does work:</p>
<pre><code>01 IQueryable<Data.Comment> query = ctx.DataContext.C... | [
{
"answer_id": 346346,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>You need to specify five things (at least):</p>\n\n<ul>\n<li>The \"outer\" sequence (Comments) (this is the implicit f... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] | I'm trying to do a JOIN in Linq using lambda expressions ... and running into some problems.
I have two entities, Comments and CommentSources. CommentSources are associated to Comments. I have the following code, which does work:
```
01 IQueryable<Data.Comment> query = ctx.DataContext.Comments;
02
03
04 if (criteria... | You need to specify five things (at least):
* The "outer" sequence (Comments) (this is the implicit first parameter)
* The "inner" sequence (CommentSource)
* How to get from a CommentSource to a key
* How to get from a Comment to a key
* What you want the result to be for a CommentSource/Comment pair
For example:
``... |
346,349 | <p>I want to create a program that requests from the user 10 grades and then filters them to pass and fail, then prints the number of passes and fails. I did the program but the output is wrong.</p>
<pre><code>int pass,fail,grade,studentcounter;
pass=0;
fail=0;
grade=0;
studentcounter=10;
while (studentcounter!=0)
{... | [
{
"answer_id": 346354,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 0,
"selected": false,
"text": "<p>you need to keep the count of pass/fails inside the while loop, the grade variable will be overwritten at every input.... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to create a program that requests from the user 10 grades and then filters them to pass and fail, then prints the number of passes and fails. I did the program but the output is wrong.
```
int pass,fail,grade,studentcounter;
pass=0;
fail=0;
grade=0;
studentcounter=10;
while (studentcounter!=0)
{
printf("... | You are entering a grade number. A switch statement tests that grade against the cases, and i am pretty sure the grades are not 1 percent or 2 percent. An if statement would be a more logical choice in this situation.
Second of all, you have a code block which is never used. First you set studentcounter to zero, then ... |
346,352 | <p>Can somebody give some clear explanation of the meaning of the SIZE and RSS values we get from prstat in Solaris?</p>
<p>I wrote a testing C++ application that allocates memory with <code>new[]</code>, fills it and frees it with <code>delete[]</code>.</p>
<p>As I understood, the SIZE value should be related to how... | [
{
"answer_id": 346570,
"author": "Saiyine",
"author_id": 38238,
"author_profile": "https://Stackoverflow.com/users/38238",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Size</strong> is the total virtual memory size of the process, including all mapped files and devices, and <st... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41789/"
] | Can somebody give some clear explanation of the meaning of the SIZE and RSS values we get from prstat in Solaris?
I wrote a testing C++ application that allocates memory with `new[]`, fills it and frees it with `delete[]`.
As I understood, the SIZE value should be related to how much virtual memory has been "reserved... | RSS is (AFAIK reliably) representing how much physical memory a process is using. Using Solaris default memory allocator, freeing memory doesn't do anything about RSS as it just changes some pointers and values to tell that memory is free to be reused.
If you don't use again that memory by allocating it again, it will ... |
346,361 | <p>I'm developing a experimental <strong>Linux Kernel module</strong>, so...</p>
<p>How to <strong>UDP Broadcast</strong> from Linux Kernel?</p>
| [
{
"answer_id": 346709,
"author": "CJ Bryan",
"author_id": 43896,
"author_profile": "https://Stackoverflow.com/users/43896",
"pm_score": 1,
"selected": false,
"text": "<p>Mm, I wish I had more time to help you out.</p>\n\n<p>To get UDP multicasting to work, it has to be baked into your ke... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1100/"
] | I'm developing a experimental **Linux Kernel module**, so...
How to **UDP Broadcast** from Linux Kernel? | -13 is -EACCES. Do you have SO\_BROADCAST set? I believe sock\_sendmsg returns -EACCES if SO\_BROADCAST isn't set and you're sending to a broadcast address.
---
You're looking for <errno.h> for error codes.
---
What kernel version are you developing under? I'd like to browse thru the kernel source briefly. I'm not ... |
346,362 | <p>I have several templates that match various nodes in an xml document. If I do just an<br>
<xsl:apply-templates/>
it somehow recursively outputs the text of all the nodes beneath. I just want it to recursively match any template I have defined. How do I do that ? </p>
| [
{
"answer_id": 346396,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 2,
"selected": false,
"text": "<p>you could set a mode to apply only your own templates:</p>\n\n<pre><code><xsl:template match=\"* | /\" >\n ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43940/"
] | I have several templates that match various nodes in an xml document. If I do just an
<xsl:apply-templates/>
it somehow recursively outputs the text of all the nodes beneath. I just want it to recursively match any template I have defined. How do I do that ? | >
> This is happening because of the
> built-in templates in XSLT. XSLT has a
> couple of built in templates, which
> say:
>
>
> * when you apply templates to an element, process its child elements
> * when you apply templates to a text node, give its value
>
>
> Together, it means that if you apply
> template... |
346,365 | <p>The following is okay:</p>
<pre><code>try
{
Console.WriteLine("Before");
yield return 1;
Console.WriteLine("After");
}
finally
{
Console.WriteLine("Done");
}
</code></pre>
<p>The <code>finally</code> block runs when the whole thing has finished executing (<code>IEnumer... | [
{
"answer_id": 346410,
"author": "Radu094",
"author_id": 3263,
"author_profile": "https://Stackoverflow.com/users/3263",
"pm_score": 2,
"selected": false,
"text": "<p>I would speculate that because of the way the call stack gets wound/unwound when you yield return from an enumerator it b... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27423/"
] | The following is okay:
```
try
{
Console.WriteLine("Before");
yield return 1;
Console.WriteLine("After");
}
finally
{
Console.WriteLine("Done");
}
```
The `finally` block runs when the whole thing has finished executing (`IEnumerator<T>` supports `IDisposable` to provide a way to ensure this even w... | I suspect this is a matter of practicality rather than feasibility. I suspect there are very, very few times where this restriction is *actually* an issue that can't be worked around - but the added complexity in the compiler would be very significant.
There are a few things like this that I've already encountered:
*... |
346,380 | <p>In Ruby you can reference variables inside strings and they are interpolated at runtime. </p>
<p>For example if you declare a variable <code>foo</code> equals <code>"Ted"</code> and you declare a string <code>"Hello, #{foo}"</code> it interpolates to <code>"Hello, Ted"</code>. </p>
<p>I've not been able to figur... | [
{
"answer_id": 346413,
"author": "stesch",
"author_id": 41860,
"author_profile": "https://Stackoverflow.com/users/41860",
"pm_score": 5,
"selected": true,
"text": "<p>Instead of interpolating, you could use <a href=\"http://ruby-doc.org/stdlib-2.1.1/libdoc/erb/rdoc/ERB.html\" rel=\"nofol... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4061/"
] | In Ruby you can reference variables inside strings and they are interpolated at runtime.
For example if you declare a variable `foo` equals `"Ted"` and you declare a string `"Hello, #{foo}"` it interpolates to `"Hello, Ted"`.
I've not been able to figure out how to perform the magic `"#{}"` interpolation on data re... | Instead of interpolating, you could use [`erb`](http://ruby-doc.org/stdlib-2.1.1/libdoc/erb/rdoc/ERB.html). [This blog](https://web.archive.org/web/20160401113123/http://www.rrn.dk/rubys-erb-templating-system) gives simple example of ERB usage,
```
require 'erb'
name = "Rasmus"
template_string = "My name is <%= name %... |
346,411 | <p>Where should I put the .html files in a wicket Application?</p>
<p>my current project layout is as follows:</p>
<pre><code>src/myproject
--classes+ duplicated html files
web
--numerous .html files - previewed
web/img
--resource files such as css/png/js files
</code></pre>
<p>i want to avoid putting the html fil... | [
{
"answer_id": 346509,
"author": "Mads Hansen",
"author_id": 14419,
"author_profile": "https://Stackoverflow.com/users/14419",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"https://stackoverflow.com/questions/273721/should-i-put-html-and-java-files-in-the-same-package-folder-in... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16542/"
] | Where should I put the .html files in a wicket Application?
my current project layout is as follows:
```
src/myproject
--classes+ duplicated html files
web
--numerous .html files - previewed
web/img
--resource files such as css/png/js files
```
i want to avoid putting the html files on dupliate locations. what is... | so after gathering some experience with wicket, it turned out that the default location for the html files is just fine. no need to reinvent the wheel.
you can link resources without troubles with relative paths, and still preserve the preview ability. |
346,426 | <p>I am having problems using <a href="http://code.google.com/p/django-tagging/" rel="nofollow noreferrer">django-tagging</a>. I try to follow the <a href="http://code.google.com/p/django-tagging/source/browse/trunk/docs/overview.txt" rel="nofollow noreferrer">documentation</a> but it fails at the second step</p>
<blo... | [
{
"answer_id": 346435,
"author": "Josh Smeaton",
"author_id": 10583,
"author_profile": "https://Stackoverflow.com/users/10583",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://code.djangoproject.com/ticket/7680\" rel=\"nofollow noreferrer\">http://code.djangoproject.com/tic... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24946/"
] | I am having problems using [django-tagging](http://code.google.com/p/django-tagging/). I try to follow the [documentation](http://code.google.com/p/django-tagging/source/browse/trunk/docs/overview.txt) but it fails at the second step
>
> Once you've installed Django Tagging and want to use it in your Django applicati... | <http://code.djangoproject.com/ticket/7680>
parse\_lookup has been removed. Not sure how this will affect tagging. Might want to do some searching.
Update: apparently it's been fixed in the trunk version of tagging. Download the latest SVN build of tagging. |
346,445 | <p>I've been banging my head against for wall for a while with this one.</p>
<p>I want to SSH into a set of machines and check whether they are available (accepting connections and not being used). I have created a small script, tssh, which does just that:</p>
<pre><code>#!/bin/bash
host=$1
timeout=${2:-1}
ssh -qo ... | [
{
"answer_id": 346455,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 3,
"selected": true,
"text": "<p>Don't know if it would help, but a cleaner way of writing that would be</p>\n\n<pre><code>for nu in `ruby -e '(0..20)... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've been banging my head against for wall for a while with this one.
I want to SSH into a set of machines and check whether they are available (accepting connections and not being used). I have created a small script, tssh, which does just that:
```
#!/bin/bash
host=$1
timeout=${2:-1}
ssh -qo "ConnectTimeout $time... | Don't know if it would help, but a cleaner way of writing that would be
```
for nu in `ruby -e '(0..20).each { |i| puts i}'`; do
tssh "MYBOXES$nu"
done
``` |
346,446 | <p>I've inherited a database that has a structure with a table of products, a table consisting of some product attributes and another table to build the relationship between these attributes and a given product.</p>
<p>A user can filter the products by a combination of these attributes, meaning that if more than one a... | [
{
"answer_id": 346461,
"author": "benlumley",
"author_id": 39161,
"author_profile": "https://Stackoverflow.com/users/39161",
"pm_score": 1,
"selected": false,
"text": "<p>I think that looks pretty good already. Aside from the obligatory mention of \"don't do select *\", it looks ok to me... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29538/"
] | I've inherited a database that has a structure with a table of products, a table consisting of some product attributes and another table to build the relationship between these attributes and a given product.
A user can filter the products by a combination of these attributes, meaning that if more than one attribute i... | The query seems fine, except that you possibly could remove the DISTINCT modifier, since you're already grouping by id. Regarding the new requirement, can't you solve it in your code, before it reaches the SQL query?
Edit: An alternative would be to construct the query with one inner join for each required attribute, ... |
346,449 | <p>I'm looking for a free templating engine to generate simple reports. I want some basic features such as :</p>
<ul>
<li>Ability to Write Loops (with any IEnumerable)</li>
<li>Passing Variables</li>
<li>Passing Templates Files (main template, footer, header)</li>
</ul>
<p>I'll use this to generate reports in HTML an... | [
{
"answer_id": 346468,
"author": "H-Man2",
"author_id": 43814,
"author_profile": "https://Stackoverflow.com/users/43814",
"pm_score": 2,
"selected": false,
"text": "<p>I would recommend StringTemplate (<a href=\"http://www.stringtemplate.org\" rel=\"nofollow noreferrer\">http://www.strin... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40322/"
] | I'm looking for a free templating engine to generate simple reports. I want some basic features such as :
* Ability to Write Loops (with any IEnumerable)
* Passing Variables
* Passing Templates Files (main template, footer, header)
I'll use this to generate reports in HTML and XML. I'm not looking for a ASP.NET Templ... | I second not recommending nVelocity. It is a horrible port.
.NET actually has built in templating abilities by using CodeDOM.
Here is a pretty good walkthrough of how to do it:
<http://www.codeproject.com/KB/cs/smarttemplateengine.aspx>
With some minor coding, you'll be able to create templates that have inline C#:... |
346,467 | <p>I'm trying to format numbers. Examples:</p>
<pre><code>1 => 1
12 => 12
123 => 123
1234 => 1,234
12345 => 12,345
</code></pre>
<p>It strikes as a fairly common thing to do but I can't figure out which filter I'm supposed to use.</p>
<p>Edit: If you've a generic Python way to do this, I'm h... | [
{
"answer_id": 346476,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 2,
"selected": false,
"text": "<p>Well I couldn't find a Django way, but I did find a python way from inside my model:</p>\n\n<pre><code>def format_price(sel... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] | I'm trying to format numbers. Examples:
```
1 => 1
12 => 12
123 => 123
1234 => 1,234
12345 => 12,345
```
It strikes as a fairly common thing to do but I can't figure out which filter I'm supposed to use.
Edit: If you've a generic Python way to do this, I'm happy adding a formatted field in my model. | Django's contributed [humanize](http://docs.djangoproject.com/en/dev/ref/contrib/humanize/#ref-contrib-humanize) application does this:
```
{% load humanize %}
{{ my_num|intcomma }}
```
Be sure to add `'django.contrib.humanize'` to your `INSTALLED_APPS` list in the `settings.py` file. |
346,499 | <p>I want to store a string in memory and read it later:</p>
<pre><code>$$->desc.constant->base.id = (char*)malloc(200);
sprintf($$->desc.constant->base.id, "%f", $1);
printf("->%s\n", $$->desc.constant->base.id); //LINE A
printf("->%i\n", $$->desc.constant); //LINE B
//SOME OTHER CODE
//... | [
{
"answer_id": 346507,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": true,
"text": "<pre><code>printf(\"->%i\\n\", $$->desc.constant); //LINE B\n</code></pre>\n\n<p>That is invalid. As y... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] | I want to store a string in memory and read it later:
```
$$->desc.constant->base.id = (char*)malloc(200);
sprintf($$->desc.constant->base.id, "%f", $1);
printf("->%s\n", $$->desc.constant->base.id); //LINE A
printf("->%i\n", $$->desc.constant); //LINE B
//SOME OTHER CODE
//Then, later on in a function call:
print... | ```
printf("->%i\n", $$->desc.constant); //LINE B
```
That is invalid. As you show the line prior to it that `constant` is actually a pointer, you cannot treat it as if it were of type `int`. They don't necassarily have the same sizeof and alignment. Use the format used for `void*`. It will output memory addresses pr... |
346,512 | <p>On AS400 in interactive SQL in a 5250 session,</p>
<pre><code>select * from myfile
</code></pre>
<p>returns rows from one member only when myfile has more than one member.</p>
<p>How can I get rows from a specific member?</p>
<p>Important: in the end I'd like to do this over JDBC with jt400 so really I want a so... | [
{
"answer_id": 347539,
"author": "Kwebble",
"author_id": 4167,
"author_profile": "https://Stackoverflow.com/users/4167",
"pm_score": 3,
"selected": false,
"text": "<p>Create an SQL alias for the member and query the alias, see <a href=\"http://searchdatamanagement.techtarget.com/tip/0,28... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29574/"
] | On AS400 in interactive SQL in a 5250 session,
```
select * from myfile
```
returns rows from one member only when myfile has more than one member.
How can I get rows from a specific member?
Important: in the end I'd like to do this over JDBC with jt400 so really I want a solution that'll work there.
Thanks. | You can create an alias using the create alias command:
```
CREATE ALIAS myLibrary/myAlias FOR memberLibrary/memberFile(memberName)
```
This will allow you to run sql against that member using the alias like you would any other file:
```
SELECT * FROM myLibrary/myAlias
```
Just remember that the alias will stick ... |
346,516 | <p>I am trying to add a link into the pop-up text bubble of a marker in Google Maps through the API. I have successfully run the below code:</p>
<pre><code>echo '<marker lat="43.91892" lng="-78.89231" html="Albertus Magnus College&lt;br&gt;Link to Admissions" label="Albertus Magnus College" />';
</code>... | [
{
"answer_id": 346530,
"author": "friol",
"author_id": 23034,
"author_profile": "https://Stackoverflow.com/users/23034",
"pm_score": 1,
"selected": false,
"text": "<p>Seems you are putting an apostrophe (') inside the string.\nYou should use an escape character (may be \"\\\", I don't kn... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33194/"
] | I am trying to add a link into the pop-up text bubble of a marker in Google Maps through the API. I have successfully run the below code:
```
echo '<marker lat="43.91892" lng="-78.89231" html="Albertus Magnus College<br>Link to Admissions" label="Albertus Magnus College" />';
```
But once I actually try to add... | This is the answer:
```
$window2a_url = '<a
href='http://www.albertus.edu/admission/index.shtml'>Admissions';
echo '<marker lat="41.331304" lng="-72.921438" html=" Albertus Magnus College<br>';
echo $window2a_url;
echo '" label="Albertus Magnus College" />';
```
I had to escape the apostrophes.... |
346,523 | <p>I have an expression tree I have created by parsing an Xml using the expression class in C#. <a href="https://stackoverflow.com/questions/344741/how-do-i-create-an-expression-tree-by-parsing-xml-in-c">See this question</a>.</p>
<p>I only have Add, Subtract, Divide, Multiply, Parameters, And and Or in my Expression ... | [
{
"answer_id": 346532,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": false,
"text": "<p>You need to create a lambda - i.e.</p>\n\n<pre><code>var lambda = Expression.Lambda<Func<float,int>>(b... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21586/"
] | I have an expression tree I have created by parsing an Xml using the expression class in C#. [See this question](https://stackoverflow.com/questions/344741/how-do-i-create-an-expression-tree-by-parsing-xml-in-c).
I only have Add, Subtract, Divide, Multiply, Parameters, And and Or in my Expression Tree.
Is there a way ... | Here's an example of both approaches. If I have missed something, or you want more information, just let me know.
```
static void Main()
{
// try to do "x + (3 * x)"
var single = BuildSingle<decimal>();
var composite = BuildComposite<decimal>();
Console.WriteLine("{0} vs {1}", single(13.2M), composit... |
346,531 | <p>I'm migrating my WordPress blog and phpBB Forum into a new hosting server. I am using phpMyAdmin to import the SQL script from the database in the previous site. </p>
<p>When I open the .sql script with Kate, it says it uses UTF8 as encoding. When I import the sql in the new server, I have the option in phpMyAdmin ... | [
{
"answer_id": 346552,
"author": "markus",
"author_id": 11995,
"author_profile": "https://Stackoverflow.com/users/11995",
"pm_score": 4,
"selected": true,
"text": "<p>Have you tried adding</p>\n\n<pre><code>SET NAMES 'utf8';\n</code></pre>\n\n<p>to your sql dump?</p>\n\n<p>The thing with... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1492/"
] | I'm migrating my WordPress blog and phpBB Forum into a new hosting server. I am using phpMyAdmin to import the SQL script from the database in the previous site.
When I open the .sql script with Kate, it says it uses UTF8 as encoding. When I import the sql in the new server, I have the option in phpMyAdmin to choose ... | Have you tried adding
```
SET NAMES 'utf8';
```
to your sql dump?
The thing with utf8 or encodings in general is that in order to be successfull, you have to make sure that:
* the file is encoded utf8 without signature
* the default encoding of the mysql server is set to utf8
* the connection is utf8 (that's why y... |
346,536 | <p>Is there any good example to give the difference between a <code>struct</code> and a <code>union</code>?
Basically I know that <code>struct</code> uses all the memory of its member and <code>union</code> uses the largest members memory space. Is there any other OS level difference? </p>
| [
{
"answer_id": 346539,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 3,
"selected": false,
"text": "<p>A structure allocates the total size of all elements in it.</p>\n\n<p>A union only allocates as much memory ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35416/"
] | Is there any good example to give the difference between a `struct` and a `union`?
Basically I know that `struct` uses all the memory of its member and `union` uses the largest members memory space. Is there any other OS level difference? | With a union, you're only supposed to use one of the elements, because they're all stored at the same spot. This makes it useful when you want to store something that could be one of several types. A struct, on the other hand, has a separate memory location for each of its elements and they all can be used at once.
To... |
346,542 | <p>Thanks for reading this</p>
<p>I thought I could use find(), but couldn't make it work. I know I can add IDs or classnames, but would like to know how with the current markup.</p>
<p>Thanks</p>
<p>Here is the HTML</p>
<pre><code><input name="keywordCheckbox" type="checkbox" value="S" />
<input name="key... | [
{
"answer_id": 346556,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 3,
"selected": false,
"text": "<p>Or you could do:</p>\n\n<pre><code>$(\"input[name='keywordCheckbox']\").filter(\"input[value='A']\")\n</code></pre>\n... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2755/"
] | Thanks for reading this
I thought I could use find(), but couldn't make it work. I know I can add IDs or classnames, but would like to know how with the current markup.
Thanks
Here is the HTML
```
<input name="keywordCheckbox" type="checkbox" value="S" />
<input name="keywordCheckbox" type="checkbox" value="C" />
<... | You should be able to chain the attribute selectors:
```
$('input[name="keywordCheckbox"][value="A"]').attr("checked",false);
```
Will set checked to false for the input with name keywordCheckbox and value of A.
```
$('input[name="keywordCheckbox"][value!="A"]').attr("checked",false);
```
will set checked to fa... |
346,544 | <p>I have a remote JS that must appear in the head of the document. If the server is slow to respond or inaccessible, obviously this slows or prevents the page from loading. I have been searching for a simple way to set a limit of say 3 seconds (probably less) for it to give up and simply not load the functionality.<... | [
{
"answer_id": 346561,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 2,
"selected": false,
"text": "<p>Include the .JS file after the page is done loading:</p>\n\n<pre><code><script type='text/javascript'>\nwindow.... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43962/"
] | I have a remote JS that must appear in the head of the document. If the server is slow to respond or inaccessible, obviously this slows or prevents the page from loading. I have been searching for a simple way to set a limit of say 3 seconds (probably less) for it to give up and simply not load the functionality.
Does... | Include the .JS file after the page is done loading:
```
<script type='text/javascript'>
window.onload = function(){
document.write("<script type='text/javascript' src='http://domain.com/file.js'></script>");
}
</script>
```
Place that in the HEAD of your document, then the file will start loading when the page has... |
346,546 | <p>Not sure exactly how to word this question ... so edits are welcomed! Anyway ... here goes.</p>
<p>I am currently use Crystal Reports to generated Pdfs and just stream the output to the user. My code looks like the following:</p>
<pre><code>System.IO.MemoryStream stream = new System.IO.MemoryStream();
stream = ... | [
{
"answer_id": 346550,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>Usually, via the content-disposition header - i.e.</p>\n\n<pre><code>Content-Disposition: inline; filename=foo.pdf\... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] | Not sure exactly how to word this question ... so edits are welcomed! Anyway ... here goes.
I am currently use Crystal Reports to generated Pdfs and just stream the output to the user. My code looks like the following:
```
System.IO.MemoryStream stream = new System.IO.MemoryStream();
stream = (System.IO.MemoryStream... | Usually, via the content-disposition header - i.e.
```
Content-Disposition: inline; filename=foo.pdf
```
So just use Headers.Add, or AddHeader, or whatever it is, with:
response.Headers.Add("Content-Disposition", "inline; filename=foo.pdf");
(inline is "show in browser", attachment is "save as a file") |
346,567 | <p>Given a document written with normal quotes, e.g.</p>
<pre><code>Ben said "buttons, dear sir".
I replied "Did you say 'buttons'?" to him.
</code></pre>
<p>What ways can one turn these sort of things into LaTeX quotes, with the appropriate semantics. i.e.</p>
<pre><code>Ben said ``buttons, dear sir''.
I replied ``... | [
{
"answer_id": 346606,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 4,
"selected": true,
"text": "<p>In general, this problem is harder than it looks.</p>\n\n<p>The simplest cases <em>can</em> be trea... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19212/"
] | Given a document written with normal quotes, e.g.
```
Ben said "buttons, dear sir".
I replied "Did you say 'buttons'?" to him.
```
What ways can one turn these sort of things into LaTeX quotes, with the appropriate semantics. i.e.
```
Ben said ``buttons, dear sir''.
I replied ``Did you say `buttons'?'' to him.
```... | In general, this problem is harder than it looks.
The simplest cases *can* be treated with regular expressions, but for more general situations you will almost certainly need to build a recursive parser: regular expression will only work if there is no nesting.
The big problem is going to be associated with identifyi... |
346,568 | <p>On my blog, I want to display the all the posts from the last month. But if that is less than 10 posts, I want to show the ten most recent posts (in other words, there should never be less than 10 posts on the front page). I am wondering if there is a way to do this in a single query?</p>
<p>Currently, I first ru... | [
{
"answer_id": 346584,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": false,
"text": "<pre><code>(SELECT * FROM posts\nWHERE `timestamp` >= NOW() - INTERVAL 30 DAY)\nUNION\n(SELECT * FROM posts\nORDER ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | On my blog, I want to display the all the posts from the last month. But if that is less than 10 posts, I want to show the ten most recent posts (in other words, there should never be less than 10 posts on the front page). I am wondering if there is a way to do this in a single query?
Currently, I first run this query... | Just do this:
```
select * from posts order by timestamp desc limit 100
```
And filter the results further in memory. (assumes 100 is a practical upper limit for "posts in a month" that people would want to see in a single page)
This is a "more efficient single query". |
346,572 | <p>We are developing a port of the GNU Assembler for a client architecture.
Now the problem being faced is that:</p>
<p>If an immediate operand to an instruction is an expression involving more than one relocatable symbols, how is it handled in output file in elf format. What will be the relocation information produce... | [
{
"answer_id": 346652,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 0,
"selected": false,
"text": "<p>I know jack about ELF and only a little more about linking but...</p>\n\n<p>I would expect that each operand is handled the s... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35416/"
] | We are developing a port of the GNU Assembler for a client architecture.
Now the problem being faced is that:
If an immediate operand to an instruction is an expression involving more than one relocatable symbols, how is it handled in output file in elf format. What will be the relocation information produced in such ... | ELF doesn't know about instructions, per se. It knows about particular encodings of symbol offsets within instructions. In the assembler, you would need to output two relocation records, each with the corresponding [address,type,symbol] triplet to properly patch that portion of the instruction. The linker wouldn't nece... |
346,589 | <p>I am writing an application in C# which is going to do extensive calculations. Everything is going around basic struct - Value. It is basically double with some additional parameters (accuracy etc.)
It has to be a struct, because there will be too many of them created to afford heap allocation.
Now, I need to make s... | [
{
"answer_id": 346608,
"author": "Aaron",
"author_id": 31304,
"author_profile": "https://Stackoverflow.com/users/31304",
"pm_score": 0,
"selected": false,
"text": "<p>Are you hoping to initialize the accuracy to -1 with a default constructor? I don't think you can stop someone from using... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38325/"
] | I am writing an application in C# which is going to do extensive calculations. Everything is going around basic struct - Value. It is basically double with some additional parameters (accuracy etc.)
It has to be a struct, because there will be too many of them created to afford heap allocation.
Now, I need to make sure... | I don't think C# allows you to create default constructors on value types.
There are several questions related to your issue:
* [Why can’t I define a default constructor for a struct in .NET?](https://stackoverflow.com/questions/333829)
* [How do I enforce using a factory on a struct in C#?](https://stackoverflow.com/... |
346,594 | <p>I have a client application that once in while notifies about its progress a service.
The method call to the service is marked with IsOneWay=true, because the notification doesn't need any return value and I don't want to delay.</p>
<p>The client may notify about errors to the service, and afterward it terminates.... | [
{
"answer_id": 346673,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 1,
"selected": false,
"text": "<p>You can't \"make sure the notification is sent\" ... and \"keep the method oneway\". That kinda goes against wha... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a client application that once in while notifies about its progress a service.
The method call to the service is marked with IsOneWay=true, because the notification doesn't need any return value and I don't want to delay.
The client may notify about errors to the service, and afterward it terminates.
The ques... | Good question. Before client application calls a method it opens the channel. The channel is used for all data communication. There are two ways of sending: 1) reliable session - when your packets are deleveried reliably and cracked packets are resent, 2) ordering - when requests on the service are computed in the orde... |
346,613 | <p>How can you prematurely exit from a function without returning a value if it is a void function? I have a void method that needs to not execute its code if a certain condition is true. I really don't want to have to change the method to actually return a value.</p>
| [
{
"answer_id": 346616,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 9,
"selected": true,
"text": "<p>Use a return statement!</p>\n\n<pre><code>return;\n</code></pre>\n\n<p>or</p>\n\n<pre><code>if (condition) return;\n</code><... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43875/"
] | How can you prematurely exit from a function without returning a value if it is a void function? I have a void method that needs to not execute its code if a certain condition is true. I really don't want to have to change the method to actually return a value. | Use a return statement!
```
return;
```
or
```
if (condition) return;
```
You don't need to (and can't) specify any values, if your method returns `void`. |
346,622 | <p>I'm curious about conventions for type-punning pointers/arrays in C++. Here's the use case I have at the moment:</p>
<blockquote>
Compute a simple 32-bit checksum over a binary blob of data by treating it as an array of 32-bit integers (we know its total length is a multiple of 4), and then summing up all values a... | [
{
"answer_id": 346764,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 5,
"selected": true,
"text": "<p>As far as the C++ standard is concerned, <a href=\"https://stackoverflow.com/questions/346622/opinions-on-type-pun... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40620/"
] | I'm curious about conventions for type-punning pointers/arrays in C++. Here's the use case I have at the moment:
>
> Compute a simple 32-bit checksum over a binary blob of data by treating it as an array of 32-bit integers (we know its total length is a multiple of 4), and then summing up all values and ignoring over... | As far as the C++ standard is concerned, [litb](https://stackoverflow.com/questions/346622/opinions-on-type-punning-in-c#346675)'s answer is completely correct and the most portable. Casting `const char *data` to a `const uint3_t *`, whether it be via a C-style cast, `static_cast`, or `reinterpret_cast`, breaks the str... |
346,644 | <p>The following code will generate a link to the page I want to get to.</p>
<pre><code><%= Html.ActionLink(image.Title, image.Id.ToString(), "Image") %>
</code></pre>
<p>The following code will cause the correct url to be rendered on the page.</p>
<pre><code><%= Url.Action("Index", "Image", new { id = imag... | [
{
"answer_id": 346657,
"author": "liggett78",
"author_id": 19762,
"author_profile": "https://Stackoverflow.com/users/19762",
"pm_score": 3,
"selected": true,
"text": "<p>This should work actually. ASP.NET MVC will substitute all <%= ... %> or similar tags, it does not recognize whe... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18107/"
] | The following code will generate a link to the page I want to get to.
```
<%= Html.ActionLink(image.Title, image.Id.ToString(), "Image") %>
```
The following code will cause the correct url to be rendered on the page.
```
<%= Url.Action("Index", "Image", new { id = image.Id })%>
```
But when I try to use it in ja... | This should work actually. ASP.NET MVC will substitute all <%= ... %> or similar tags, it does not recognize whether it's a html definition or javascript. What is the output of your view? Is the "strange error" coming from Javascript or ASP.NET?
**EDIT**: regarding your update: make sure your Index.aspx has the "Codeb... |
346,649 | <p>I have two constructor :</p>
<pre><code>function clsUsagerEmailUserName($nickName, $email)
{
$this->nickName = $nickName;
$this->email = $email;
}
function clsUsagerEmailUserName($email)
{
$this->email = $email;
}
</code></pre>
<p>But this is not work... | [
{
"answer_id": 346651,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 3,
"selected": true,
"text": "<p>PHP5 doesn't allow overloaded constructor.</p>\n\n<p>Alternativly you can use function to set or you can use ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21386/"
] | I have two constructor :
```
function clsUsagerEmailUserName($nickName, $email)
{
$this->nickName = $nickName;
$this->email = $email;
}
function clsUsagerEmailUserName($email)
{
$this->email = $email;
}
```
But this is not working? What's wrong, isn't supposed t... | PHP5 doesn't allow overloaded constructor.
Alternativly you can use function to set or you can use this trick (found at EE):
```
function __construct ($var1, $var2 = null)
{
if (isset($var2))
{
//Do one thing
}
else
{
//Do another
}
}
``` |
346,659 | <p>All of us who work with relational databases have learned (or are learning) that SQL is different. Eliciting the desired results, and doing so efficiently, involves a tedious process partly characterized by learning unfamiliar paradigms, and finding out that some of our most familiar programming patterns don't wor... | [
{
"answer_id": 346665,
"author": "stesch",
"author_id": 41860,
"author_profile": "https://Stackoverflow.com/users/41860",
"pm_score": 6,
"selected": false,
"text": "<p>Don't have to dig deep for it: Not using prepared statements.</p>\n"
},
{
"answer_id": 346668,
"author": "Os... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31641/"
] | All of us who work with relational databases have learned (or are learning) that SQL is different. Eliciting the desired results, and doing so efficiently, involves a tedious process partly characterized by learning unfamiliar paradigms, and finding out that some of our most familiar programming patterns don't work her... | I am consistently disappointed by most programmers' tendency to mix their UI-logic in the data access layer:
```
SELECT
FirstName + ' ' + LastName as "Full Name",
case UserRole
when 2 then "Admin"
when 1 then "Moderator"
else "User"
end as "User's Role",
case SignedIn
wh... |
346,692 | <p>I have written a very simple bash script to help me migrate from dev to staging. What it does is it deletes all files in staging, copies the files over from dev to stage.</p>
<p>However, the config.inc.php file needs to have the first instance of "dev" to be changed to "stage", and no other instance changed.</p>
... | [
{
"answer_id": 346699,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 0,
"selected": false,
"text": "<p>The first part (editing your file) can be done well with the stream editor utility <code>sed</code>:</p>\n\n<pre><... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43980/"
] | I have written a very simple bash script to help me migrate from dev to staging. What it does is it deletes all files in staging, copies the files over from dev to stage.
However, the config.inc.php file needs to have the first instance of "dev" to be changed to "stage", and no other instance changed.
Second, everyti... | This will change only the first appearance of "dev" to "stage"
```
sed -i '0,/dev/ s/dev/stage/' config.inc.php
```
Be aware that it changes "devel" into "stageel". This version behaves just like you want, only a "dev" is searched, not a "devel" (in fact, `s/\<dev\>/stage/` as the substitution expression should work... |
346,708 | <p>I'm trying to do project Euler number <a href="http://projecteuler.net/index.php?section=problems&id=219" rel="nofollow noreferrer">219</a> but am failing to get a grasp of it. I'm trying to use Python which according to project Euler should be able to do it within a minute! This leads me to think that they can'... | [
{
"answer_id": 346714,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 4,
"selected": true,
"text": "<p>Brute-force is not the right way to do it. This is one of those problems where, if you know a certain thing, it's... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to do project Euler number [219](http://projecteuler.net/index.php?section=problems&id=219) but am failing to get a grasp of it. I'm trying to use Python which according to project Euler should be able to do it within a minute! This leads me to think that they can't possibly want me to compute each individua... | Brute-force is not the right way to do it. This is one of those problems where, if you know a certain thing, it's not that hard, but if you've never heard of that thing, it's practically impossible. That thing is [Huffman trees](http://en.wikipedia.org/wiki/Huffman_tree).
[Edit] Upon further review, it seems that you ... |
346,718 | <p>I am trying to make a combined image of all images added to a modell in django with inline editing and a ForeignKey. Ive got these models (simplified):</p>
<pre><code>class Modell(models.Model):
title = models.CharField('beskrivelse', max_length=200)
slug = models.SlugField()
is_public = models.BooleanF... | [
{
"answer_id": 346763,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "https://Stackoverflow.com/users/32638",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>Modell</code> instance isn't being saved when you add a new image; only the <code>Image</code> instance i... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42546/"
] | I am trying to make a combined image of all images added to a modell in django with inline editing and a ForeignKey. Ive got these models (simplified):
```
class Modell(models.Model):
title = models.CharField('beskrivelse', max_length=200)
slug = models.SlugField()
is_public = models.BooleanField('publiser... | `Modell` and `Image` are two seperate models connected with a `ForeignKey`. Even though they both seem to be saved *together*, they don't. They are saved one by one (first the `Modell` or first the `Image`s).
Now logically `Image`s are saved **after** `Modell`. Because they have a `ForeignKey` pointing to `Modell` and... |
346,723 | <p>Say I only needed to use findall() from the re module, is it more efficient to do:</p>
<pre><code>from re import findall
</code></pre>
<p>or </p>
<pre><code>import re
</code></pre>
<p>Is there actually any difference in speed/memory usage etc?</p>
| [
{
"answer_id": 346741,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>There is no difference, except for what names from re are visible in you local namespace after the import.</p>\n"
},
{
... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32933/"
] | Say I only needed to use findall() from the re module, is it more efficient to do:
```
from re import findall
```
or
```
import re
```
Is there actually any difference in speed/memory usage etc? | There is no difference on the import, however there is a small difference on access.
When you access the function as
```
re.findall()
```
python will need to first find the module in the global scope and then find findall in modules dict. May make a difference if you are calling it inside a loop thousands of times... |
346,730 | <p>I want to change member of structure under double pointer. Do you know how?</p>
<p>Example code</p>
<pre><code>typedef struct {
int member;
} Ttype;
void changeMember(Ttype **foo) {
//I don`t know how to do it
//maybe
*foo->member = 1;
}
</code></pre>
| [
{
"answer_id": 346738,
"author": "mepcotterell",
"author_id": 43312,
"author_profile": "https://Stackoverflow.com/users/43312",
"pm_score": 1,
"selected": false,
"text": "<p>maybe (*foo)->member = 1 (if it's dynamically allocated)</p>\n"
},
{
"answer_id": 346739,
"author": "J... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43975/"
] | I want to change member of structure under double pointer. Do you know how?
Example code
```
typedef struct {
int member;
} Ttype;
void changeMember(Ttype **foo) {
//I don`t know how to do it
//maybe
*foo->member = 1;
}
``` | Try
```
(*foo)->member = 1;
```
You need to explicitly use the \* first. Otherwise it's an attempt to dereference member. |
346,760 | <p>I want to find (not generate) 2 text strings such that, after removing all non letters and ucasing, one string can be translated to the other by simple substitution.</p>
<p>The motivation for this comes from a project I known of that is testing methods for attacking cyphers via probability distributions. I'd like t... | [
{
"answer_id": 348162,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 0,
"selected": false,
"text": "<p>I think you're asking a bit much to generate a substitution that is also \"coherent\". That is an AI problem for the e... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | I want to find (not generate) 2 text strings such that, after removing all non letters and ucasing, one string can be translated to the other by simple substitution.
The motivation for this comes from a project I known of that is testing methods for attacking cyphers via probability distributions. I'd like to find a l... | There are 26! different substitution ciphers. That works out to a bit over 88 bits of choice:
```
>>> math.log(factorial(26), 2)
88.381953327016262
```
The entropy of English text is something like 2 bits per character at least. So it seems to me you can't reasonably expect to find passages of more than 45-50 charac... |
346,762 | <p>In the constructor of my class, I map the current object (<em>this</em>), along with its key (a string entered as a parameter in the constructor) into a static LinkedHashMap so I can reference the object by the string anywhere I might need it later.</p>
<p>Here's the code (if it helps):</p>
<pre><code>public class... | [
{
"answer_id": 346768,
"author": "Morten Christiansen",
"author_id": 4055,
"author_profile": "https://Stackoverflow.com/users/4055",
"pm_score": 1,
"selected": false,
"text": "<p>What you want to use seems to be a weak reference. The concept is that weak references are not strong enough ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19825/"
] | In the constructor of my class, I map the current object (*this*), along with its key (a string entered as a parameter in the constructor) into a static LinkedHashMap so I can reference the object by the string anywhere I might need it later.
Here's the code (if it helps):
```
public class DataEntry {
/** Interna... | Making an object visible to others before its constructor is complete is not thread safe.
It's not clear how the map is being used in this case, but suppose there's a static method like this in the class:
```
public static DataEntry getEntry(String name) {
return _INTERNAL_LIST.get(name);
}
```
Another thread, ru... |
346,770 | <p>Some issues with timezones in PHP have been in the back of my mind for a while now, and I was wondering if there are better ways to handle it than what I'm currently doing.</p>
<p>All of the issues revolve around reformating database stored dates:</p>
<p>When dealing with a site that has to support multiple timezo... | [
{
"answer_id": 346791,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>You could try forcing MySQL to use UTC everywhere using <a href=\"http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10585/"
] | Some issues with timezones in PHP have been in the back of my mind for a while now, and I was wondering if there are better ways to handle it than what I'm currently doing.
All of the issues revolve around reformating database stored dates:
When dealing with a site that has to support multiple timezones (for users), ... | Few months ago we spent some time thinking about this. The technique we ended up with is pretty simple:
1. Store dates in GMT/UTC (e.g. 0 timezone offset).
2. Apply current user timezone offset after retrieval from the database (e.g. before showing to the user or whenever you want).
We use Unix timestamps format. But... |
346,777 | <p>how can I check at runtime home many parameters a method or a function have in PHP.</p>
<p>example</p>
<pre>
class foo {
function bar ( arg1, arg2 ){
.....
}
}
</pre>
<p>I will need to know if there is a way to run something like</p>
<pre>
get_func_arg_number ( "foo", "bar" )
</pre>
<p>and the result... | [
{
"answer_id": 346786,
"author": "gnud",
"author_id": 27204,
"author_profile": "https://Stackoverflow.com/users/27204",
"pm_score": 2,
"selected": false,
"text": "<p>You're looking for the reflection capabilities in PHP5 -- documentation <a href=\"http://php.net/oop5.reflection\" rel=\"n... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43991/"
] | how can I check at runtime home many parameters a method or a function have in PHP.
example
```
class foo {
function bar ( arg1, arg2 ){
.....
}
}
```
I will need to know if there is a way to run something like
```
get_func_arg_number ( "foo", "bar" )
```
and the result to be
```
2
``` | You need to use [reflection](http://php.net/oop5.reflection) to do that.
```
$method = new ReflectionMethod('foo', 'bar');
$num = $method->getNumberOfParameters();
``` |
346,793 | <p>The people on this website seem to know everything so I figured I would ask this just in case:</p>
<p>Is there a method/function in prototype that converts a JSON object to a string that you can store in a cookie?</p>
<p>If not,..i'll just use another external library.</p>
<p>Thanks,
Andrww</p>
| [
{
"answer_id": 346795,
"author": "P Arrayah",
"author_id": 33459,
"author_profile": "https://Stackoverflow.com/users/33459",
"pm_score": 0,
"selected": false,
"text": "<p>Assuming you're speaking of <a href=\"http://www.prototypejs.org/\" rel=\"nofollow noreferrer\">Prototype JavaScript ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The people on this website seem to know everything so I figured I would ask this just in case:
Is there a method/function in prototype that converts a JSON object to a string that you can store in a cookie?
If not,..i'll just use another external library.
Thanks,
Andrww | Sure there is: [Prototype JSON](http://www.prototypejs.org/learn/json)
```
var data = {name: 'Violet', occupation: 'character', age: 25 };
var myString = Object.toJSON(data);
// myString = '{"name": "Violet", "occupation": "character", "age": 25}'
```
Then shove myString into your cookie |
346,811 | <p>I am making a game in JAVA where I want to come up with a list of files in a certain directory in my jar so I can make sure to have a list of those classes to be used in the game.</p>
<p>For example say in my jar I have a directory </p>
<pre><code>mtd/entity/creep/
</code></pre>
<p>I want to get a list of all the... | [
{
"answer_id": 346853,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 4,
"selected": true,
"text": "<p>Old java1.4 code, but that would give you the idea:</p>\n\n<pre><code>private static List getClassesFromJARFile(String jar, S... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43994/"
] | I am making a game in JAVA where I want to come up with a list of files in a certain directory in my jar so I can make sure to have a list of those classes to be used in the game.
For example say in my jar I have a directory
```
mtd/entity/creep/
```
I want to get a list of all the .class files in that directory *... | Old java1.4 code, but that would give you the idea:
```
private static List getClassesFromJARFile(String jar, String packageName) throws Error
{
final List classes = new ArrayList();
JarInputStream jarFile = null;
try
{
jarFile = new JarInputStream(new FileInputStream(jar));
JarEntry ja... |
346,823 | <p>I am trying to figure out the following problem.
I am building Yet another math function grapher, The function is drawn on its predefined x,y range, that's all good.</p>
<p>Now I am working on the background and the ticking of X, Y axes (if any axes are shown).</p>
<p>I worked out the following.
I have a fixed wid... | [
{
"answer_id": 346873,
"author": "coulix",
"author_id": 32032,
"author_profile": "https://Stackoverflow.com/users/32032",
"pm_score": 0,
"selected": false,
"text": "<p>Using deltaX</p>\n\n<p>if deltax between 2 and 10 half increment\nif deltax between 10 and 20 unit increment\nif smaller... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32032/"
] | I am trying to figure out the following problem.
I am building Yet another math function grapher, The function is drawn on its predefined x,y range, that's all good.
Now I am working on the background and the ticking of X, Y axes (if any axes are shown).
I worked out the following.
I have a fixed width of 250 p
The t... | One way to do this would be to "normalise" the difference between the minimum and maximum and do a case distinction on that value. In python:
```
delta = maximum - minimum
factor = 10**math.ceil(math.log(delta,10)) # smallest power of 10 greater than delta
normalised_delta = delta / factor # 0.1 <= normalis... |
346,834 | <p>Does anyone have any best practices, tips & tricks, or recommendations for how to create modal Alert Views with Cocoa Touch?</p>
<p>I like to think there is a way to make this difficult task trivial or at least easier.</p>
| [
{
"answer_id": 346944,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 1,
"selected": false,
"text": "<p>I just use UIAlertView to display modal alerts. What additional functionality are you looking for?</p>\n"
},
{
... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23294/"
] | Does anyone have any best practices, tips & tricks, or recommendations for how to create modal Alert Views with Cocoa Touch?
I like to think there is a way to make this difficult task trivial or at least easier. | You can use something like this:
```
void AlertWithMessage(NSString *message)
{
/* open an alert with an OK button */
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Name of the Application"
message:message
delegate:nil
... |
346,842 | <p>Well I have a videos website and a few of its tables are:</p>
<p><strong>tags</strong></p>
<pre><code>id ~ int(11), auto-increment [PRIMARY KEY]
tag_name ~ varchar(255)
</code></pre>
<p><strong>videotags</strong></p>
<pre><code>tag_id ~ int(11) [PRIMARY KEY]
video_id ~ int(11) [PRIMARY KEY]
</code></pre>
<p><st... | [
{
"answer_id": 346851,
"author": "MarkR",
"author_id": 13724,
"author_profile": "https://Stackoverflow.com/users/13724",
"pm_score": 0,
"selected": false,
"text": "<p>I think your best bet is to create some kind of summary table which you maintain when things change.</p>\n\n<p>The query ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | Well I have a videos website and a few of its tables are:
**tags**
```
id ~ int(11), auto-increment [PRIMARY KEY]
tag_name ~ varchar(255)
```
**videotags**
```
tag_id ~ int(11) [PRIMARY KEY]
video_id ~ int(11) [PRIMARY KEY]
```
**videos**
```
id ~ int(11), auto-increment [PRIMARY KEY]
video_name ~ varchar(255)
... | [MarkR](https://stackoverflow.com/questions/346842/mysql-query-takes-15-seconds-to-run-what-can-i-do-to-cacheimprove-it-php#346851) mentioned the index. Make sure you:
```
create index videotags_tag_id on videotags(tag_id);
``` |
346,855 | <p>The following loop takes about 700 seconds to run in octave and 22 seconds to run in matlab when the DJI matrix has 21000 rows. How can I increase the efficiency of this?</p>
<pre>
for i=1:length(DJI)
DJI2(i,1)=datenum(char(DJI(i,2)),'yyyy-mm-dd');
end
</pre>
| [
{
"answer_id": 346851,
"author": "MarkR",
"author_id": 13724,
"author_profile": "https://Stackoverflow.com/users/13724",
"pm_score": 0,
"selected": false,
"text": "<p>I think your best bet is to create some kind of summary table which you maintain when things change.</p>\n\n<p>The query ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744/"
] | The following loop takes about 700 seconds to run in octave and 22 seconds to run in matlab when the DJI matrix has 21000 rows. How can I increase the efficiency of this?
```
for i=1:length(DJI)
DJI2(i,1)=datenum(char(DJI(i,2)),'yyyy-mm-dd');
end
``` | [MarkR](https://stackoverflow.com/questions/346842/mysql-query-takes-15-seconds-to-run-what-can-i-do-to-cacheimprove-it-php#346851) mentioned the index. Make sure you:
```
create index videotags_tag_id on videotags(tag_id);
``` |
346,858 | <p>I'm trying to parse a simple string in C++. I know the string contains some text with a colon, followed immediately by a space, then a number. I'd like to extract just the number part of the string. I can't just tokenize on the space (using sstream and <<) because the text in front of the colon may or may n... | [
{
"answer_id": 346867,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 5,
"selected": true,
"text": "<pre><code>std::string strInput = \"Total disk space: 9852465\";\nstd::string strNumber = \"0\";\nsize_t iIndex = strI... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] | I'm trying to parse a simple string in C++. I know the string contains some text with a colon, followed immediately by a space, then a number. I'd like to extract just the number part of the string. I can't just tokenize on the space (using sstream and <<) because the text in front of the colon may or may not have spac... | ```
std::string strInput = "Total disk space: 9852465";
std::string strNumber = "0";
size_t iIndex = strInput.rfind(": ");
if(iIndex != std::string::npos && strInput.length() >= 2)
{
strNumber = strInput.substr(iIndex + 2, strInput.length() - iIndex - 2)
}
``` |
346,913 | <p>I'm currently developing a little hobby project to display health information in a game on my G15 keyboard through VB.NET.</p>
<p>When I use ReadProcessMemory via an API call, it keeps returning zero. The MSDN documentation referred me to use the Marshal.GetLastWin32Error() call to find out what is wrong and it ret... | [
{
"answer_id": 346935,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 3,
"selected": true,
"text": "<p>First, your method signature is wrong, Single=Float while the original parameter is of the LPBUF type.</p>\n\n<p>Use this m... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20900/"
] | I'm currently developing a little hobby project to display health information in a game on my G15 keyboard through VB.NET.
When I use ReadProcessMemory via an API call, it keeps returning zero. The MSDN documentation referred me to use the Marshal.GetLastWin32Error() call to find out what is wrong and it returns 1400:... | First, your method signature is wrong, Single=Float while the original parameter is of the LPBUF type.
Use this method signature:
```
<DllImport("kernel32.dll", SetLastError=true)> _
Public Shared Function ReadProcessMemory( _
ByVal hProcess As IntPtr, _
ByVal lpBaseAddress As IntPtr, _
<Out()>ByVal lpBuffer() As Byt... |
346,914 | <p>I'm new to ASP.NET MVC and I'm trying to get the full url to a action when working in a view. I need this to submit to a third party API as a callback. For example what I need is</p>
<blockquote>
<p><a href="http://myserver.com/controller/action" rel="noreferrer">http://myserver.com/controller/action</a></p>
</bl... | [
{
"answer_id": 346921,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 2,
"selected": false,
"text": "<p>Edit: for any view/controller combo, not sure you'll find anything simpler than this.</p>\n\n<pre><code>http://<%... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42278/"
] | I'm new to ASP.NET MVC and I'm trying to get the full url to a action when working in a view. I need this to submit to a third party API as a callback. For example what I need is
>
> <http://myserver.com/controller/action>
>
>
>
When I use
```
<%= Url.Action("action", "controller") %>
```
I get
>
> /contro... | In order to catch variations in the protocol (http / https), diffrent ports and virtual paths (can't always assume we will be in server root) I ended up with the following solution:
```
<%= Request.Url.GetLeftPart(System.UriPartial.Authority) + Url.Action("action", "controller")%>
```
I'm working on moving this to a... |
346,926 | <p>I have a website with a form that uses TinyMCE; independently, I use jQuery. When I load the form from staging server on Firefox 3 (MacOS X, Linux), TinyMCE doesn't finish loading. There is an error in Firefox console, saying that <code>t.getBody()</code> returned <code>null</code>. <code>t.getBody()</code>, as f... | [
{
"answer_id": 347174,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 3,
"selected": false,
"text": "<p>The browser executes scripts in the order they're loaded, not written. Your <strong>immediate</strong> script... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16390/"
] | I have a website with a form that uses TinyMCE; independently, I use jQuery. When I load the form from staging server on Firefox 3 (MacOS X, Linux), TinyMCE doesn't finish loading. There is an error in Firefox console, saying that `t.getBody()` returned `null`. `t.getBody()`, as far as I understand from TinyMCE docs, i... | The browser executes scripts in the order they're loaded, not written. Your **immediate** scripts -- `tinyMCE.init(...)` and `$(document.ready(...));` -- can execute before the files finish loading.
So, the problem is probably network latency -- especially with 6 separate scripts (each requiring a different HTTP conve... |
346,940 | <p>I have two tables on a page that I want to display side by side, and then center them within the page (actually within another div, but this is the simplest I could come up with):</p>
<pre><code><style>
#outer { text-align: center; }
#inner { text-align: left; margin: 0 auto; }
.t { float: left; }
tab... | [
{
"answer_id": 346948,
"author": "Jim Nelson",
"author_id": 32168,
"author_profile": "https://Stackoverflow.com/users/32168",
"pm_score": 2,
"selected": false,
"text": "<p>Off the top of my head, you might try using the \"margin: 0 auto\" for #outer rather than #inner.</p>\n\n<p>I often ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18625/"
] | I have two tables on a page that I want to display side by side, and then center them within the page (actually within another div, but this is the simplest I could come up with):
```
<style>
#outer { text-align: center; }
#inner { text-align: left; margin: 0 auto; }
.t { float: left; }
table { border: 1px sol... | If it was me - I would do with the table something like this:
```html
<style type="text/css" media="screen">
table {
border: 1px solid black;
float: left;
width: 148px;
}
#table_container {
width: 300px;
margin: 0 auto;
}
</style>
<div id="table_container">
<table>
<tr>... |
346,954 | <p>I saw a link to find out if AD was running, but am not too sure if the same applies to AD/AM.
One caveat is that I should be able to check about any AD/AM instance (any domain) assuming I have permissions.</p>
| [
{
"answer_id": 348507,
"author": "jwmiller5",
"author_id": 7824,
"author_profile": "https://Stackoverflow.com/users/7824",
"pm_score": 1,
"selected": false,
"text": "<p>the same approach applies to AD or to AD LDS (lightweight directory services, new name for ADAM). .NET examples at <a h... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43999/"
] | I saw a link to find out if AD was running, but am not too sure if the same applies to AD/AM.
One caveat is that I should be able to check about any AD/AM instance (any domain) assuming I have permissions. | Performing LDAP queries against AD/AM and AD are very close in functionality. You just need to include a DNS prefix in your bind string as well as the port (if it's not the default 389):
```
LDAP://ADAMServer:50000/DC=domain,DC=local
```
One major pain is the default absence of RootDSE in AD/AM. You can add it manua... |
346,957 | <p>I want to write Html format, but I can not even get a simple MSDN example of it to work.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/tbfb3z56.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/tbfb3z56.aspx</a></p>
<p>Does this console app, a clipboard round tripper, work for anyon... | [
{
"answer_id": 346969,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>I can reproduce that it doesn't work... the <code>var text2 = Clipboard.GetText();</code> returns <code>\"\"</code... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14841/"
] | I want to write Html format, but I can not even get a simple MSDN example of it to work.
<http://msdn.microsoft.com/en-us/library/tbfb3z56.aspx>
Does this console app, a clipboard round tripper, work for anyone?
```
using System;
using System.Windows; //Need to add a PresentationCore or System.Windows.Forms referen... | When you copy data from a browser onto the clipboard, it puts the same data onto the clipboard in multiple formats, including both text and HTML. So you can read the data back out in either text or HTML format. However, when you call SetText here, you are ONLY passing in HTML format, so when you use the regular GetText... |
346,960 | <p>i am trying to use an ASP conditional here:</p>
<pre><code>if (Request.Cookies("username")) and
(Request.Cookies("password")) <> ""
Then
</code></pre>
<p>And i keep getting this error:</p>
<blockquote>
<p>Type mismatch: '[string: ""]'</p>
</blockquote>
<p>Any ideas what I am getting that?</p>
| [
{
"answer_id": 346965,
"author": "hmcclungiii",
"author_id": 24333,
"author_profile": "https://Stackoverflow.com/users/24333",
"pm_score": 3,
"selected": true,
"text": "<p>try</p>\n\n<pre><code>if (Request.Cookies(\"username\") <> \"\") and (Request.Cookies(\"password\") <> \... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i am trying to use an ASP conditional here:
```
if (Request.Cookies("username")) and
(Request.Cookies("password")) <> ""
Then
```
And i keep getting this error:
>
> Type mismatch: '[string: ""]'
>
>
>
Any ideas what I am getting that? | try
```
if (Request.Cookies("username") <> "") and (Request.Cookies("password") <> "") Then
``` |
346,973 | <p>Is there a simple way to tell what triggered Click event of a Button apart from setting multiple flags in Mouse/Key Up/Down event handlers? I'm currently only interested in distinguishing mouse from everything else, but it would be nice to handle Stylus and other input types if possible. Do I have to create my own b... | [
{
"answer_id": 347178,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 0,
"selected": false,
"text": "<p>You should instead handle specifically the MouseXXX, StylusXXx, and KeyboardXXX events.</p>\n"
},
{
"answer_id": ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10757/"
] | Is there a simple way to tell what triggered Click event of a Button apart from setting multiple flags in Mouse/Key Up/Down event handlers? I'm currently only interested in distinguishing mouse from everything else, but it would be nice to handle Stylus and other input types if possible. Do I have to create my own butt... | ```
if (InputManager.Current.MostRecentInputDevice is KeyboardDevice)
``` |
347,010 | <p>I currently am trying to write a Python program using scheme semantics so I can later translate it into Scheme without relying on a lot of Pythonic stuff.</p>
<p>I'm trying solve the sliding puzzle problem (where you have 9 slots and 8 tiles arranged in a square) using a*, depth first, and breadth first search algo... | [
{
"answer_id": 347059,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 2,
"selected": false,
"text": "<p>I wrote an 8-puzzle solver in Lisp about a year ago. I just used a list of 3 lists, each sublist with 3 elements being ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/347010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I currently am trying to write a Python program using scheme semantics so I can later translate it into Scheme without relying on a lot of Pythonic stuff.
I'm trying solve the sliding puzzle problem (where you have 9 slots and 8 tiles arranged in a square) using a\*, depth first, and breadth first search algorithm. I ... | I wrote an 8-puzzle solver in Lisp about a year ago. I just used a list of 3 lists, each sublist with 3 elements being the numbers. It's not constant time, but it is portable.
Anyways, if you are really interested in doing this functionally (Scheme doesn't require you to) what is easiest to do is to create some helper... |
347,031 | <p>When you have an array like this:</p>
<pre><code>int foo[3][2][2];
</code></pre>
<p>and you make:</p>
<pre><code>int *bar = &foo[0][0][0];
</code></pre>
<p>Is this the way it works?</p>
<pre><code>*bar == foo[0][0][0];
*(bar+1) == foo[0][0][1];
*(bar+2) == foo[0][1][0];
*(bar+3) == foo[0][1][1];
*(bar+4) ==... | [
{
"answer_id": 347037,
"author": "Stefan Mai",
"author_id": 13257,
"author_profile": "https://Stackoverflow.com/users/13257",
"pm_score": 0,
"selected": false,
"text": "<p>On most systems, yes.</p>\n"
},
{
"answer_id": 347041,
"author": "rob",
"author_id": 43927,
"aut... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26004/"
] | When you have an array like this:
```
int foo[3][2][2];
```
and you make:
```
int *bar = &foo[0][0][0];
```
Is this the way it works?
```
*bar == foo[0][0][0];
*(bar+1) == foo[0][0][1];
*(bar+2) == foo[0][1][0];
*(bar+3) == foo[0][1][1];
*(bar+4) == foo[1][0][0];
```
I'm not sure and have a bit of code depende... | Yes, that's called [row major ordering](http://en.wikipedia.org/wiki/Row-major_order), and is what C is using. |
347,056 | <p>While there appears to some documentation on how to expose JMX through various firewall and tunneling schemes, I sort of want the opposite. I want to ensure that JMX is only accessible to local machine. Unfortunately it appears that the "out of the box" management options do not allow restricting the ports to a lo... | [
{
"answer_id": 347095,
"author": "navicore",
"author_id": 7223,
"author_profile": "https://Stackoverflow.com/users/7223",
"pm_score": 1,
"selected": false,
"text": "<p>Can't help with the sun way of doing it. Even after jmx adapters started coming with the jdk (6 i think?) I kept using ... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | While there appears to some documentation on how to expose JMX through various firewall and tunneling schemes, I sort of want the opposite. I want to ensure that JMX is only accessible to local machine. Unfortunately it appears that the "out of the box" management options do not allow restricting the ports to a local i... | A bit late answer but if it is still a problem for you (or someone else), I think this will do the trick:
```java
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.net.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.RMISocketFactory;
import javax.management.MBea... |
347,093 | <p>I have been programming in Perl, off and on, for years now, although only sporadically is it my primary language. Because I often go months without writing any perl, I rely heavily on my dog-eared Camel Book to remind me how to do things. However, when I copy recipes verbatim with no understanding, this bothers me. ... | [
{
"answer_id": 347117,
"author": "D.Shawley",
"author_id": 41747,
"author_profile": "https://Stackoverflow.com/users/41747",
"pm_score": 6,
"selected": true,
"text": "<p>Hmmm... <code>($lotr=$hobbit) =~ s/Bilbo/Frodo/g</code> is one of the many magicks of Perl. Now for some answers.</p>\... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41194/"
] | I have been programming in Perl, off and on, for years now, although only sporadically is it my primary language. Because I often go months without writing any perl, I rely heavily on my dog-eared Camel Book to remind me how to do things. However, when I copy recipes verbatim with no understanding, this bothers me. Thi... | Hmmm... `($lotr=$hobbit) =~ s/Bilbo/Frodo/g` is one of the many magicks of Perl. Now for some answers.
Q1) `$lotr` is being assigned the value contained in `$hobbit`. After the assignment, we can forget about the source variable. Treat `($lotr = $hobbit)` as it's own statement as-if we had written:
```
$lotr = $hobbi... |
347,096 | <p>Consider the following code:</p>
<pre><code>template <int dim>
struct vec
{
vec normalize();
};
template <>
struct vec<3>
{
vec cross_product(const vec& second);
vec normalize();
};
template <int dim>
vec<dim> vec<dim>::normalize()
{
// code to normalize ve... | [
{
"answer_id": 347101,
"author": "jalf",
"author_id": 33213,
"author_profile": "https://Stackoverflow.com/users/33213",
"pm_score": 2,
"selected": false,
"text": "<p>You haven't supplied a definition of vec<3>::normalize, so the linker obviously can't link to it.</p>\n\n<p>The entire ... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2222/"
] | Consider the following code:
```
template <int dim>
struct vec
{
vec normalize();
};
template <>
struct vec<3>
{
vec cross_product(const vec& second);
vec normalize();
};
template <int dim>
vec<dim> vec<dim>::normalize()
{
// code to normalize vector here
return *this;
}
int main()
{
vec<3> ... | You can't :) What you want is to specialize the member functions instead:
```
template <int dim>
struct vec
{
// leave the function undefined for everything except dim==3
vec cross_product(const vec& second);
vec normalize();
};
template<>
vec<3> vec<3>::cross_product(const vec& second) {
// ...
}
te... |
347,109 | <p>I'm implementing unit tests for a family of functions that all share a number of invariants. For example, calling the function with two matrices produce a matrix of known shape.</p>
<p>I would like to write unit tests to test the entire family of functions for this property, without having to write an individual te... | [
{
"answer_id": 347175,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 4,
"selected": true,
"text": "<p>You could use a metaclass to dynamically insert the tests. This works fine for me:</p>\n\n<pre><code>import unittest\n\n... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37984/"
] | I'm implementing unit tests for a family of functions that all share a number of invariants. For example, calling the function with two matrices produce a matrix of known shape.
I would like to write unit tests to test the entire family of functions for this property, without having to write an individual test case fo... | You could use a metaclass to dynamically insert the tests. This works fine for me:
```
import unittest
class UnderTest(object):
def f1(self, i):
return i + 1
def f2(self, i):
return i + 2
class TestMeta(type):
def __new__(cls, name, bases, attrs):
funcs = [t for t in dir(UnderT... |
347,111 | <p>In a CF8 form, I'm using a tag such as the following:</p>
<pre><code><cfinput
type = "Text"
name = "Num"
value = "0"
validate = "range,integer"
range = "0,1000"
validateAt="onBlur,onSubmit"
required = "yes"
message = "Invalid Value"
>
</code></pre>
<p>When the field l... | [
{
"answer_id": 347224,
"author": "JoelFan",
"author_id": 16012,
"author_profile": "https://Stackoverflow.com/users/16012",
"pm_score": 0,
"selected": false,
"text": "<p>From the generated JS, it definitely looks like it's trying to honor both validations. If it's not working, you may wa... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26428/"
] | In a CF8 form, I'm using a tag such as the following:
```
<cfinput
type = "Text"
name = "Num"
value = "0"
validate = "range,integer"
range = "0,1000"
validateAt="onBlur,onSubmit"
required = "yes"
message = "Invalid Value"
>
```
When the field loses focus (onBlur), the input i... | Looking at the JavaScript this created, there is an error in the logic.
Currently, it is:
```
if (!has_value && !in_range || !is_integer) show_error()
```
but I think it really should be:
```
if (!has_value || !in_range || !is_integer) show_error()
```
Since JavaScript short-circuits logical expressions and `&&`... |
347,132 | <p>How would you append an integer to a <code>char*</code> in c++?</p>
| [
{
"answer_id": 347140,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 6,
"selected": true,
"text": "<p>First convert the int to a <code>char*</code> using <code>sprintf()</code>:</p>\n\n<pre><code>char integer_string[32];\n... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37875/"
] | How would you append an integer to a `char*` in c++? | First convert the int to a `char*` using `sprintf()`:
```
char integer_string[32];
int integer = 1234;
sprintf(integer_string, "%d", integer);
```
Then to append it to your other char\*, use `strcat()`:
```
char other_string[64] = "Integer: "; // make sure you allocate enough space to append the other string
strc... |
347,196 | <p>I have only this in my mxml source code:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:comp="components.*"
width="770" height="330">
<mx:Label x="185.5" y="150"
text="Placeholder for Future UI." fontSize="... | [
{
"answer_id": 347225,
"author": "William Holroyd",
"author_id": 43973,
"author_profile": "https://Stackoverflow.com/users/43973",
"pm_score": 0,
"selected": false,
"text": "<p>It sounds like it's not liking the \"Canvas\" element. I've never used Flex, but in the example of doing an WPF... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20165/"
] | I have only this in my mxml source code:
```
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:comp="components.*"
width="770" height="330">
<mx:Label x="185.5" y="150"
text="Placeholder for Future UI." fontSize="30" color="#93A8AD"/>
</mx:C... | I solved this problem already. The problem was I created my multi module project with maven and imported the projects to eclipse. So by default the flex project wasn't recognized by eclipse as a flex project. What I did was I deleted the flex project, and recreated it with
'File -> New -> Flex Project' option, and the... |
347,210 | <p>How do you execute a JavaScript function without <code>onclick</code> like "Grippie" in a new post on SOF, like the <code><div class="grippie" style="margin-right: 59px;"/</code>> on Stack Overflow when you post a question or answer? I get a nice CSS cursor which lets me know of t... | [
{
"answer_id": 347218,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://plugins.jquery.com/project/TextAreaResizer\" rel=\"nofollow noreferrer\">http://plugins.jquery.com/... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36076/"
] | How do you execute a JavaScript function without `onclick` like "Grippie" in a new post on SOF, like the `<div class="grippie" style="margin-right: 59px;"/`> on Stack Overflow when you post a question or answer? I get a nice CSS cursor which lets me know of the movable edge, but how is the JavaScript which resizes the ... | <http://plugins.jquery.com/project/TextAreaResizer> |
347,219 | <p>I'm using an NSTimer to do some rendering in an OpenGL based iPhone app. I have a modal dialog box that pops up and requests user input. While the user is providing input I'd like to "pause" i.e. something like this:</p>
<pre><code>[myNSTimer pause];
</code></pre>
<p>I'm using this syntax because I've been doing... | [
{
"answer_id": 347223,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 6,
"selected": true,
"text": "<p>From here:</p>\n\n<p><a href=\"http://discussions.apple.com/thread.jspa?threadID=1811475&tstart=75\" rel=\"nore... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] | I'm using an NSTimer to do some rendering in an OpenGL based iPhone app. I have a modal dialog box that pops up and requests user input. While the user is providing input I'd like to "pause" i.e. something like this:
```
[myNSTimer pause];
```
I'm using this syntax because I've been doing things like:
```
[myNSTime... | From here:
<http://discussions.apple.com/thread.jspa?threadID=1811475&tstart=75>
"You can store the amount of time that has passed since the timer started... When the timer starts store the date in an NSDate variable. Then when the user switches... use the method timeIntervalSinceNow in the NSDate class to store how ... |
347,226 | <p>I've created a table in Microsoft Sql CE that I'm using to hold some data. I've generated an ORM via SqlMetal and I've pulled the datasource into my WPF project.</p>
<p>I want to create a simple WPF form that can be used to edit a record in the table via the ORM-generated classes. I want this form to support typi... | [
{
"answer_id": 347230,
"author": "Greg D",
"author_id": 6932,
"author_profile": "https://Stackoverflow.com/users/6932",
"pm_score": 1,
"selected": false,
"text": "<p>One possible solution would be to look for a cancel result from the dialog and, using the ORM object's primary key, retrie... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6932/"
] | I've created a table in Microsoft Sql CE that I'm using to hold some data. I've generated an ORM via SqlMetal and I've pulled the datasource into my WPF project.
I want to create a simple WPF form that can be used to edit a record in the table via the ORM-generated classes. I want this form to support typical OK/Cance... | Paul Stovell has a brilliant article about creating an adapter for the IEditableObject interface that allows you to databind and allow apply/revert behaviour.
<http://www.paulstovell.com/blog/runtime-ui-binding-behavior-ieditableobject-adapter>
The adapter wraps around your ORM object and automatically caches changes... |
347,248 | <p>Can I do it with reflection or something like that?</p>
| [
{
"answer_id": 347258,
"author": "Zhichao",
"author_id": 43443,
"author_profile": "https://Stackoverflow.com/users/43443",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, the first step is to identify "all" the classes that you cared about. If you already have this informat... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1356709/"
] | Can I do it with reflection or something like that? | I have been searching for a while and there seems to be different approaches, here is a summary:
1. **[reflections](https://github.com/ronmamo/reflections)** library is pretty popular if u don't mind adding the dependency. It would look like this:
```
Reflections reflections = new Reflections("firstdeveloper.examples... |
347,250 | <p>I need to generate a tone that I can manipulate frequency and wave. The overall goal is to create a basic piano. Does anyone know how I can achieve this?</p>
<p>My development platform is the iPhone 2.x</p>
| [
{
"answer_id": 347662,
"author": "Roland Rabien",
"author_id": 39138,
"author_profile": "https://Stackoverflow.com/users/39138",
"pm_score": 2,
"selected": false,
"text": "<p>Check out <a href=\"http://mda.smartelectronix.com/\" rel=\"nofollow noreferrer\">http://mda.smartelectronix.com/... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44048/"
] | I need to generate a tone that I can manipulate frequency and wave. The overall goal is to create a basic piano. Does anyone know how I can achieve this?
My development platform is the iPhone 2.x | You could always start with `sin` waves. :-)
```
#include <cmath>
typedef double Sample;
typedef double Time;
class MonoNote {
protected:
Time start, duration;
virtual void internalRender(double now, Sample *mono) = 0;
public:
MonoNote(Time s, Time d) : start(s), duration(d) {}
virtual ~MonoNote() {}... |
347,254 | <p>Is there a way to log(/var/log) commands executed by users in the Unix shell?</p>
| [
{
"answer_id": 347272,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 0,
"selected": false,
"text": "<p>Dumb idea off the top of my head:</p>\n\n<p><code>script</code> will copy the session to a file. Y... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15474/"
] | Is there a way to log(/var/log) commands executed by users in the Unix shell? | Process accounting is the way to go, despite it sucking up lots of disk space. It's not something I'd leave running unless you have a very grunty box but it's very useful for problem solving since it basically tracks every process, a claim the simpler "snapshot of ps" tools can't match.
You basically turn it on with `... |
347,274 | <p>I have written a <a href="http://osirisdevelopment.com/BatteryBar" rel="nofollow noreferrer">toolbar</a> that runs on the taskbar. Unfortunately, after it is installed, the user has to enable it manually. Is there a way to tell explorer to open (or close) a given toolbar?</p>
<p>I would like for the installer, NS... | [
{
"answer_id": 347293,
"author": "Ben Childs",
"author_id": 2925,
"author_profile": "https://Stackoverflow.com/users/2925",
"pm_score": 2,
"selected": false,
"text": "<p>I can't find the exact url right now, but I remember there being some discussion of this around PDC2008 where basicall... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5982/"
] | I have written a [toolbar](http://osirisdevelopment.com/BatteryBar) that runs on the taskbar. Unfortunately, after it is installed, the user has to enable it manually. Is there a way to tell explorer to open (or close) a given toolbar?
I would like for the installer, NSIS, to turn on the toolbar when the installation ... | * [This CodeProject comment does it by simulating key presses](http://www.codeproject.com/KB/atl/rbdeskband.aspx?display=PrintAll&select=1659628#xx1659628xx)
* Vista+ has API to do this, with [ShowDeskBand](http://msdn.microsoft.com/en-us/library/bb774485(VS.85).aspx) and [HideDeskBand](http://msdn.microsoft.com/en-us/... |
347,277 | <p>I have a dataset in MySQL where using limit is already an expensive query, and finding the number of results is expensive as well. Thus, I'd like to avoid doing another query to find the number of results. I cannot use MYSQL_CALC_FOUND_ROWS because the limit is inside a subquery:</p>
<pre><code>SELECT * FROM item... | [
{
"answer_id": 347299,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "<p>Here's a summary of an article by MySQL guru Baron Schwartz:</p>\n\n<p><a href=\"http://www.mysqlperformanceblog.com... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43005/"
] | I have a dataset in MySQL where using limit is already an expensive query, and finding the number of results is expensive as well. Thus, I'd like to avoid doing another query to find the number of results. I cannot use MYSQL\_CALC\_FOUND\_ROWS because the limit is inside a subquery:
```
SELECT * FROM items,
(
SELECT... | Here's a summary of an article by MySQL guru Baron Schwartz:
<http://www.mysqlperformanceblog.com/2008/09/24/four-ways-to-optimize-paginated-displays/>
Four Ways to Optimize Paginated Displays
----------------------------------------
1. On the first query, fetch and cache all the results.
2. Don't show all results. ... |
347,281 | <p>After trying to setup my site for Google Webmaster Tools I found that my Custom ASP.NET 404 page was not returning the 404 status code. It displayed the correct custom page and told the browser that everything is OK. This is consider a soft 404 or false 404. Google doesn't like this. So I found many articles on the ... | [
{
"answer_id": 347304,
"author": "Ryan Cook",
"author_id": 43029,
"author_profile": "https://Stackoverflow.com/users/43029",
"pm_score": 7,
"selected": true,
"text": "<p><strong>Solution:</strong></p>\n\n<p>The problem, it turned out, was the use of the master page. I got it to work by s... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43976/"
] | After trying to setup my site for Google Webmaster Tools I found that my Custom ASP.NET 404 page was not returning the 404 status code. It displayed the correct custom page and told the browser that everything is OK. This is consider a soft 404 or false 404. Google doesn't like this. So I found many articles on the iss... | **Solution:**
The problem, it turned out, was the use of the master page. I got it to work by setting the status code later in the pages lifecycle, obviously the rendering of the master page was resetting it, so I overrode the render method and set it after the render was complete.
```
protected override void Render(... |
347,286 | <p>So I'm having a path issue on OS X Leopard. It seems OS X is adding other paths that I'm not stating and it's messing with my path priority. I only have a <code>.bash_login</code> file, I don't have a <code>.bashrc</code> or a .profile file. My <code>.bash_login</code> file is as such:</p>
<pre><code>export PATH="/... | [
{
"answer_id": 347291,
"author": "Brian C. Lane",
"author_id": 27461,
"author_profile": "https://Stackoverflow.com/users/27461",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like your changes aren't being applied. Note no /usr/local/mysql/bin</p>\n\n<p>Read the bash manpage sec... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43043/"
] | So I'm having a path issue on OS X Leopard. It seems OS X is adding other paths that I'm not stating and it's messing with my path priority. I only have a `.bash_login` file, I don't have a `.bashrc` or a .profile file. My `.bash_login` file is as such:
```
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/... | Have you looked inside these two directories:
```
/etc/paths.d/
/etc/manpaths.d
```
Any paths defined in files in those directories get appended automatically to PATH variable -- I mostly use those two directories to put third-party installed applications in the PATH. Also, do have a look at the man page of `path_he... |
347,294 | <p>So I'm trying to take a bilinear interpolation algorithm for resizing images and add in alpha values as well. I'm using Actionscript 3 to do this, but I don't really think the language is relevant.</p>
<p>The code I have below actually works really well, but edges around "erased" regions seem to get darker. Is ther... | [
{
"answer_id": 347376,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 4,
"selected": true,
"text": "<p>You need to multiply each of your r,g,b values by the corresponding alpha before working with them, then divide the va... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10680/"
] | So I'm trying to take a bilinear interpolation algorithm for resizing images and add in alpha values as well. I'm using Actionscript 3 to do this, but I don't really think the language is relevant.
The code I have below actually works really well, but edges around "erased" regions seem to get darker. Is there an easy ... | You need to multiply each of your r,g,b values by the corresponding alpha before working with them, then divide the values by the final alpha when you're done. It's easy to imagine the effect this will have when one of the pixels has an alpha of zero - each of the r,g,b values will be multiplied by zero, so it won't ma... |
347,306 | <p>Whenever we have to update the database; we delete the values from the table first and then add the latest values. This ensures that everything is updated correctly.</p>
<p>This adds little bit overhead to the system but we haven't faced any performance issues because of this.</p>
<p>Is this always the best thing ... | [
{
"answer_id": 347313,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 3,
"selected": true,
"text": "<p>No.</p>\n\n<p>Use the UPDATE statement. </p>\n\n<p>Additionally, if you worried about integrity, scope it within a transac... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38997/"
] | Whenever we have to update the database; we delete the values from the table first and then add the latest values. This ensures that everything is updated correctly.
This adds little bit overhead to the system but we haven't faced any performance issues because of this.
Is this always the best thing to do? | No.
Use the UPDATE statement.
Additionally, if you worried about integrity, scope it within a transaction:
```
BEGIN TRAN T1
-- This update is part of T1
UPDATE Table1 SET Col1='New Value' WHERE Col2 = @Id;
-- Time to commit your changes.
-- If for any reason something fails,
-- everything gets rolled back
COMM... |
347,311 | <p>need help in Fortran...</p>
<p>This is the main loop of the program..</p>
<pre><code>do iStep=0,nStep
write(7,*)iStep
!* Compute new temperature using FTCS scheme.
do i=1,N
if( istep==0) then !only for t=0
tt_new(i)=250
write(7,*)tt_new(i)
else
if(i==1) the... | [
{
"answer_id": 347331,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 2,
"selected": false,
"text": "<p>Try formatting your inner <code>IF ELSE</code> in a more readable way:</p>\n\n<pre><code>if( istep==0) then !only for t=0\... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | need help in Fortran...
This is the main loop of the program..
```
do iStep=0,nStep
write(7,*)iStep
!* Compute new temperature using FTCS scheme.
do i=1,N
if( istep==0) then !only for t=0
tt_new(i)=250
write(7,*)tt_new(i)
else
if(i==1) then
tt_... | For `i=1` and `i=N`, you are printing `tt(i)` instead of `tt_new(i)` - the calculation is being performed correctly, but the results will not be displayed properly. Stepping through the code with a debugger is quite helpful in cases like this.
I would also suggest restructuring your `if` statement, but I wouldn't go q... |
347,316 | <p>how do you encode words using the huffman code such as NEED</p>
| [
{
"answer_id": 347321,
"author": "Schwern",
"author_id": 14660,
"author_profile": "https://Stackoverflow.com/users/14660",
"pm_score": 1,
"selected": false,
"text": "<p>I think you mean <a href=\"https://secure.wikimedia.org/wikipedia/en/wiki/Huffman_encoding\" rel=\"nofollow noreferrer\... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | how do you encode words using the huffman code such as NEED | Huffman encoding basically uses variable-length bit strings to represent tokens (generally characters with a couple of exceptions). The more common a token is, the shorter it's bit-length is and this is (usually) dynamic as the stream is processed.
There are usually two special tokens, ESCAPE and END-STREAM.
Encoding... |
347,325 | <p>I need to get a file into memory in my app from a secured web location. I have the URL of the file to capture, but can't seem to get the security issue resolved. Here's the code from the <a href="http://groovy.codehaus.org/Simple+file+download+from+URL" rel="nofollow noreferrer">Cookbook samples page</a>:</p>
<pr... | [
{
"answer_id": 347397,
"author": "Ted Naleid",
"author_id": 8912,
"author_profile": "https://Stackoverflow.com/users/8912",
"pm_score": 2,
"selected": false,
"text": "<p>Depending on the kind of auth for the server, you could put the creds on the url itself:</p>\n\n<pre><code>def address... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13824/"
] | I need to get a file into memory in my app from a secured web location. I have the URL of the file to capture, but can't seem to get the security issue resolved. Here's the code from the [Cookbook samples page](http://groovy.codehaus.org/Simple+file+download+from+URL):
```
def download(address)
{
def file = new Fi... | If creds on url doesn't work, you can use this. It works for Basic Authentication.
```
new File(localPath).withOutputStream { out ->
def url = new URL(remoteUrl).openConnection()
def remoteAuth = "Basic " + "${user}:${passwd}".bytes.encodeBase64()
url.setRequestProperty("Authorization", remoteAuth);
ou... |
347,358 | <p>Why does this code:</p>
<pre><code>class A
{
public:
explicit A(int x) {}
};
class B: public A
{
};
int main(void)
{
B *b = new B(5);
delete b;
}
</code></pre>
<p>Result in these errors:</p>
<pre>
main.cpp: In function ‘int main()’:
main.cpp:13: error: no matching function for call to ‘B::B... | [
{
"answer_id": 347361,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 4,
"selected": false,
"text": "<p>You have to explicitly define the constructor in B and explicitly call the constructor for the parent.</p>\n\n<pre><... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43496/"
] | Why does this code:
```
class A
{
public:
explicit A(int x) {}
};
class B: public A
{
};
int main(void)
{
B *b = new B(5);
delete b;
}
```
Result in these errors:
```
main.cpp: In function ‘int main()’:
main.cpp:13: error: no matching function for call to ‘B::B(int)’
main.cpp:8: note: candid... | If your compiler supports C++11 standard, there is a constructor inheritance using `using` (pun intended). For more see [Wikipedia C++11 article](http://en.wikipedia.org/wiki/C%2B%2B11#Object_construction_improvement). You write:
```
class A
{
public:
explicit A(int x) {}
};
class B: public A
{
usin... |
347,365 | <p>I am using Delphi TApplication.OnException Event to catch unhandled exceptions</p>
<p>This works well but does not give sufficient information about where the exception happened
i.e. ‘Catastrophic failure’ </p>
<p>How can I find out which procedure made the error happened?</p>
<pre><code>procedure TFrmMain.For... | [
{
"answer_id": 347381,
"author": "Mihai Limbășan",
"author_id": 14444,
"author_profile": "https://Stackoverflow.com/users/14444",
"pm_score": 3,
"selected": false,
"text": "<p>The simplest and quickest way would be to use the <a href=\"http://jcl.sf.net/\" rel=\"noreferrer\">JCL</a> exce... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17560/"
] | I am using Delphi TApplication.OnException Event to catch unhandled exceptions
This works well but does not give sufficient information about where the exception happened
i.e. ‘Catastrophic failure’
How can I find out which procedure made the error happened?
```
procedure TFrmMain.FormCreate(Sender: TObject);
begi... | You can get the memory address where the exception was thrown by using the ExceptAddr variable (System unit). But if you want a stack trace you could use one of the 3rdParty tools MadExcept, EurekaLog or the open source JCLDebug (part of the JCL). |
347,372 | <p>I don't know how to save object with where clause. I need it to prevent saving object with range of dates overlapping on others.</p>
<pre><code>public class TaskEvent
{
public DateTime StartDate {get;set;}
public DateTime EndDate {get;set;}
}
</code></pre>
<p>I want to check overlaping in criteria within s... | [
{
"answer_id": 347680,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 2,
"selected": false,
"text": "<p>You need to figure out in code which objects need saving, then save those. This is business logic and should not be ... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3644960/"
] | I don't know how to save object with where clause. I need it to prevent saving object with range of dates overlapping on others.
```
public class TaskEvent
{
public DateTime StartDate {get;set;}
public DateTime EndDate {get;set;}
}
```
I want to check overlaping in criteria within saving operation but I don'... | You can use HQL for ad hoc update queries
```
session.CreateQuery("UPDATE TaskEvent SET ... WHERE ID = :ID and ...")
.SetInt32("ID", ID)
//.SetDateTime("", )
//.SetDateTime("", )
.ExecuteUpdate();
```
or to do in a more NHibernate kind of way...fetch the required TaskEvents(where clause), update their properties, an... |
347,390 | <p>I'm trying to write a program to calculate the quadratic formula. When I run it, I get 2 error messages:</p>
<pre>error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
fatal error LNK1120: 1 unresolved externals</pre>
<p>this is after I changed the last line of code from ... | [
{
"answer_id": 347385,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 2,
"selected": false,
"text": "<p>yes, unit testing can be taken to excess/extremes</p>\n\n<p>keep in mind that <em>it is only <strong>necessary</st... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to write a program to calculate the quadratic formula. When I run it, I get 2 error messages:
```
error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
fatal error LNK1120: 1 unresolved externals
```
this is after I changed the last line of code from
...:
```
<< ... | **[Update:]** Found the concise answer to this question in TDD ByExample - Pg194.
>
> The simple answer, supplied by Phlip
> is, "Write tests until fear is
> transformed into boredom."
>
>
>
[/**Update**]
I think the problem prevalent in the current times is the lack of unit testing... not excessive testing. I... |
347,396 | <p>I'm using the Accessibility API to detect when a certain application opens windows, closes windows, when the windows are moved or resized, or made main and/or focused. However the client app seems to move a window to front without an Accessibility API notification being
fired.</p>
<p>How can my application detect w... | [
{
"answer_id": 624866,
"author": "Nick Haddad",
"author_id": 2813,
"author_profile": "https://Stackoverflow.com/users/2813",
"pm_score": 3,
"selected": false,
"text": "<p>I've been unable to subscribe to current window changes, but you can ask the accessibility API for the current applic... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2959/"
] | I'm using the Accessibility API to detect when a certain application opens windows, closes windows, when the windows are moved or resized, or made main and/or focused. However the client app seems to move a window to front without an Accessibility API notification being
fired.
How can my application detect when anothe... | I've been unable to subscribe to current window changes, but you can ask the accessibility API for the current application, and the current applications most foreground window.
Imagine you have a class called CurrentAppData, with the following data:
```
@interface CurrentAppData : NSObject {
NSString* _title;
... |
347,404 | <p>I am currently doing IE-hacks on a website I'm working on:
<a href="http://www.timkjaerlange.com/wip/co2penhagen/" rel="nofollow noreferrer">http://www.timkjaerlange.com/wip/co2penhagen/</a></p>
<p>I got a problem with this unordered list. IE seems to add extra top-margin for every li-element, making my navigation ... | [
{
"answer_id": 347424,
"author": "Andrew G. Johnson",
"author_id": 428190,
"author_profile": "https://Stackoverflow.com/users/428190",
"pm_score": 2,
"selected": false,
"text": "<p>top-margin isn't a CSS attribute. You're looking for margin-top</p>\n\n<p>Change:</p>\n\n<pre><code>ul#mai... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24218/"
] | I am currently doing IE-hacks on a website I'm working on:
<http://www.timkjaerlange.com/wip/co2penhagen/>
I got a problem with this unordered list. IE seems to add extra top-margin for every li-element, making my navigation look like a flight of stairs:
<http://dl.getdropbox.com/u/228089/ie-prob.jpg>
I'm using cond... | To get the behavior your looking for try "display: inline" instead of the "float: left". Add both:
>
> ul#mainnav { display: inline }
>
>
> ul#mainnav li { display: inline }
>
>
>
A great resource for info on customizing lists can be found on [A List Apart](http://www.alistapart.com/articles/taminglists/). |
347,439 | <p>I have a mouseenter and mouseleave event for a Panel control that changes the backcolor when the mouse enters and goes back to white when it leaves.</p>
<p>I have Label control within this panel as well but when the mouse enters the Label control, the mouseleave event for the panel fires.</p>
<p>This makes sense b... | [
{
"answer_id": 347461,
"author": "ng5000",
"author_id": 36860,
"author_profile": "https://Stackoverflow.com/users/36860",
"pm_score": 0,
"selected": false,
"text": "<p>You could add a MouseEnter event for the label which also sets the Panel's back colour. You wouldn't need a MouseLeave ... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] | I have a mouseenter and mouseleave event for a Panel control that changes the backcolor when the mouse enters and goes back to white when it leaves.
I have Label control within this panel as well but when the mouse enters the Label control, the mouseleave event for the panel fires.
This makes sense but how do I keep ... | You can use GetChildAtPoint() to determine if the mouse is over a child control.
```
private void panel1_MouseLeave(object sender, EventArgs e)
{
if (panel1.GetChildAtPoint(panel1.PointToClient(MousePosition)) == null)
{
panel1.BackColor = Color.Gray;
}
}
```
If the control isn't actually a child... |
347,441 | <p>I want to clear a element from a vector using the erase method. But the problem here is that the element is not guaranteed to occur only once in the vector. It may be present multiple times and I need to clear all of them. My code is something like this:</p>
<pre><code>void erase(std::vector<int>& myNumbe... | [
{
"answer_id": 347445,
"author": "dalle",
"author_id": 19100,
"author_profile": "https://Stackoverflow.com/users/19100",
"pm_score": 6,
"selected": false,
"text": "<p>Calling erase will invalidate iterators, you could use:</p>\n<pre><code>void erase(std::vector<int>& myNumbers_... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39742/"
] | I want to clear a element from a vector using the erase method. But the problem here is that the element is not guaranteed to occur only once in the vector. It may be present multiple times and I need to clear all of them. My code is something like this:
```
void erase(std::vector<int>& myNumbers_in, int number_in)
{
... | Use the [remove/erase idiom](http://www.codeguru.com/forum/archive/index.php/t-231045.html):
```
std::vector<int>& vec = myNumbers; // use shorter name
vec.erase(std::remove(vec.begin(), vec.end(), number_in), vec.end());
```
What happens is that `remove` compacts the elements that differ from the value to be remove... |
347,449 | <p>I'll be using the <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=4004" rel="nofollow noreferrer">AdventureWorks Database</a> to illustrate my problem.</p>
<p>I need to show for a particular customer a list of OrderDate with the most Orders.</p>
<p>My intial attempt was as... | [
{
"answer_id": 347456,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 1,
"selected": false,
"text": "<p>I don't have a copy of AdventureWorks handy to test with, but could the WITH TIES clause help out? You could do somet... | 2008/12/07 | [
"https://Stackoverflow.com/questions/347449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19582/"
] | I'll be using the [AdventureWorks Database](http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=4004) to illustrate my problem.
I need to show for a particular customer a list of OrderDate with the most Orders.
My intial attempt was as follows:
```
SELECT CustomerID, OrderDate, COUNT(1) ... | You should use `TOP` *`n`* `WITH TIES` clause to accomplish the task:
```
SELECT TOP 1 WITH TIES CustomerID, OrderDate, COUNT(*) Cnt
FROM Sales.SalesOrderHeader
WHERE CustomerID = 11300
GROUP BY CustomerID, OrderDate
ORDER BY Cnt DESC
```
Alternatively, you can use a *common table expression (CTE)* to solve the prob... |