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 |
|---|---|---|---|---|---|---|
109,464 | <p>I have a report that I built for a client where I need to plot x 0-100, y 0-100. Let's imagine I have these points:</p>
<pre><code> 0, 0
2, 24
50, 70
100, 100
</code></pre>
<p>I need to represent these as a smoothed line chart, as the application of it is a dot gain graph for printing presses.</p>
<p>Here... | [
{
"answer_id": 109537,
"author": "bkane",
"author_id": 17097,
"author_profile": "https://Stackoverflow.com/users/17097",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://img140.imageshack.us/img140/1279/smoothlinebezierxl0.jpg\" rel=\"nofollow noreferrer\">alt text http://i... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14642/"
] | I have a report that I built for a client where I need to plot x 0-100, y 0-100. Let's imagine I have these points:
```
0, 0
2, 24
50, 70
100, 100
```
I need to represent these as a smoothed line chart, as the application of it is a dot gain graph for printing presses.
Here's the problem. The line draws fi... | [alt text http://img140.imageshack.us/img140/1279/smoothlinebezierxl0.jpg](http://img140.imageshack.us/img140/1279/smoothlinebezierxl0.jpg)
(Providing a picture of the behaviour to help you get a better answer).
For those with a theory, you can try this out in Excel as well (not just Reporting Services).
You mentio... |
109,480 | <p>I've created a forum, and we're implementing an apc and memcache caching solution to save the database some work.</p>
<p>I started implementing the cache layer with keys like "Categories::getAll", and if I had user-specific data, I'd append the keys with stuff like the user ID, so you'd get <code>"User::getFavorite... | [
{
"answer_id": 109532,
"author": "Brent",
"author_id": 10680,
"author_profile": "https://Stackoverflow.com/users/10680",
"pm_score": 2,
"selected": false,
"text": "<p>You're essentially trying to cache a view, which is always going to get tricky. You should instead try to cache data onl... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11167/"
] | I've created a forum, and we're implementing an apc and memcache caching solution to save the database some work.
I started implementing the cache layer with keys like "Categories::getAll", and if I had user-specific data, I'd append the keys with stuff like the user ID, so you'd get `"User::getFavoriteThreads|1471"`.... | You might also want to have a look at the cost of storing the cache data, in terms of your effort and CPU cost, against how what the cache will buy you.
If you find that 80% of your forum views are looking at the first page of threads, then you could decide to cache that page only. That would mean both cache reads an... |
109,488 | <p>I keep hearing that <code>div</code> tags should be used for layout purposes and not <code>table</code> tags. So does that also apply to form layout? I know a form layout is still a layout, but it seems like creating form layouts with <code>div</code>s requires more <code>html</code> and <code>css</code>. So with th... | [
{
"answer_id": 109493,
"author": "John Fiala",
"author_id": 9143,
"author_profile": "https://Stackoverflow.com/users/9143",
"pm_score": 2,
"selected": false,
"text": "<p>It's certainly easier to use table than div to layout a table, but keep in mind that a table is supposed to mean somet... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708/"
] | I keep hearing that `div` tags should be used for layout purposes and not `table` tags. So does that also apply to form layout? I know a form layout is still a layout, but it seems like creating form layouts with `div`s requires more `html` and `css`. So with that in mind, should forms layouts use `div` tags instead? | Yes, it does apply for form layouts. Keep in mind that there are also tags like FIELDSET and LABEL which exist specifically for adding structure to a form, so it's not really a question of just using DIV. You should be able to markup a form with pretty minimal HTML, and let CSS do the rest of the work. E.g.:
```
<fiel... |
109,491 | <p>I keep getting compiler errors when I try to access flashVars in an AS3 class.</p>
<p>Here's a stripped version of the code:</p>
<pre><code>package myPackage {
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
public class myClass {
public function CTrafficHandler(... | [
{
"answer_id": 109505,
"author": "Michael Pliskin",
"author_id": 9777,
"author_profile": "https://Stackoverflow.com/users/9777",
"pm_score": 0,
"selected": false,
"text": "<p>I think you should extend from Sprite, but be sure to initialize it first and maybe put to the stage. Try to enab... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18790/"
] | I keep getting compiler errors when I try to access flashVars in an AS3 class.
Here's a stripped version of the code:
```
package myPackage {
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
public class myClass {
public function CTrafficHandler() {
var myVar... | I found what the problem was. The class in question wasn't the main class used in the project, but rather a secondary class.
I've moved the code to the main class to get the parameters and after I got them, I sent them to the class constructor function. |
109,520 | <p>I've got my Rails (2.1) app setup to send email via Gmail, however whenever I send an email no matter what I set the from address to in my ActionMailer the emails always come as if sent from my Gmail email address. Is this a security restriction they've put in place at Gmail to stop spammers using their SMTP?</p>
<... | [
{
"answer_id": 109539,
"author": "ColinD",
"author_id": 13792,
"author_profile": "https://Stackoverflow.com/users/13792",
"pm_score": 4,
"selected": true,
"text": "<p>I believe it's just something Gmail does when mail is sent through its SMTP, as it was mentioned that they do this on a t... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6432/"
] | I've got my Rails (2.1) app setup to send email via Gmail, however whenever I send an email no matter what I set the from address to in my ActionMailer the emails always come as if sent from my Gmail email address. Is this a security restriction they've put in place at Gmail to stop spammers using their SMTP?
Note: I'... | I believe it's just something Gmail does when mail is sent through its SMTP, as it was mentioned that they do this on a tutorial about using their SMTP to send mail. |
109,580 | <p>I'm looking to grab cookie values for the same domain within a Flash movie. Is this possible?</p>
<p>Let's see I let a user set a variable foo and I store it using any web programming language. I can access it easily via that language, but I would like to access it via the Flash movie without passing it in via pr... | [
{
"answer_id": 109597,
"author": "davenpcj",
"author_id": 4777,
"author_profile": "https://Stackoverflow.com/users/4777",
"pm_score": 0,
"selected": false,
"text": "<p>I believe flash objects have functions accessible through javascript, so if there's no easier way, you could at least us... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/497/"
] | I'm looking to grab cookie values for the same domain within a Flash movie. Is this possible?
Let's see I let a user set a variable foo and I store it using any web programming language. I can access it easily via that language, but I would like to access it via the Flash movie without passing it in via printing it wi... | If you just want to store and retrieve data, you probably want to use the SharedObject class. See [Adobe's SharedObject reference](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html) for more details of that.
If you want to access the HTTP cookies, you'll need to use ExternalInterfac... |
109,592 | <p>In tomcat 6 i have a servlet running openbluedragon, everything compiles and servers up quik, with the exception of images, they really lag significantly. Any suggestions optimization for image serving?</p>
<p>Here is my server.xml:</p>
<pre><code> <Service name="Catalina">
<Connector port="800... | [
{
"answer_id": 109679,
"author": "user19113",
"author_id": 19113,
"author_profile": "https://Stackoverflow.com/users/19113",
"pm_score": 2,
"selected": false,
"text": "<p>If you have the option, you could add a reverse proxy in advance of your application. At work I have an Apache web s... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18159/"
] | In tomcat 6 i have a servlet running openbluedragon, everything compiles and servers up quik, with the exception of images, they really lag significantly. Any suggestions optimization for image serving?
Here is my server.xml:
```
<Service name="Catalina">
<Connector port="8009" protocol="AJP/1.3" />
... | Another option is to use apache as a frontend, connecting tomcat with mod\_jk. This way you can let apache serve static content (e.g. images, css, javascript) and let tomcat generate the dynamic content. Might leave a bit of work to separate the static content from the dynamic ones, but works great for me.
On Unix, ha... |
109,608 | <p>When I place a control on a tabpage in Silverlight the control is placed ~10 pixels down and ~10 pixels right. For example, the following xaml:</p>
<pre><code><System_Windows_Controls:TabControl x:Name=TabControlMain Canvas.Left="0" Canvas.Top="75" Width="800" Height="525" Background="Red" HorizontalContentAlign... | [
{
"answer_id": 110046,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 2,
"selected": false,
"text": "<p>Check the control template of your TabItem , it might have some default Margin of 10. Just a guess</p>\n"
},
{
"... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4244/"
] | When I place a control on a tabpage in Silverlight the control is placed ~10 pixels down and ~10 pixels right. For example, the following xaml:
```
<System_Windows_Controls:TabControl x:Name=TabControlMain Canvas.Left="0" Canvas.Top="75" Width="800" Height="525" Background="Red" HorizontalContentAlignment="Left" Verti... | Look at the control template, it has a margin of that size. Use blend to modify the a copy of the tab control's template. |
109,618 | <p>I want the following layout to appear on the screen:</p>
<pre><code>FieldName 1 [Field input 1]
FieldName 2 is longer [Field input 2]
. .
. .
FieldName N [Field input N]
</code></pre>
<p>Requirements:</p>
<ul>
<li>Field names and fi... | [
{
"answer_id": 109628,
"author": "Héctor Ramos",
"author_id": 19617,
"author_profile": "https://Stackoverflow.com/users/19617",
"pm_score": -1,
"selected": false,
"text": "<p>FieldName objects should be contained in SPANs with style attributes of float: left and a width that is wide enou... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2284/"
] | I want the following layout to appear on the screen:
```
FieldName 1 [Field input 1]
FieldName 2 is longer [Field input 2]
. .
. .
FieldName N [Field input N]
```
Requirements:
* Field names and field inputs must align on the left edg... | I think most of the answers are missing the point that the original questioner wanted the columns widths to depend on the width of the content. I believe the only way to do this with pure CSS is by using 'display: table', 'display: table-row' and 'display: table-cell', but that isn't supported by IE. But I'm not sure t... |
109,644 | <p><code>temp2</code>, <code>temp1</code> are pointers to some struct x:</p>
<pre><code>struct FunkyStruct x;
struct FunkyStruct *temp1 = &x, *temp2 = &x;
</code></pre>
<p>Now, after execution of following lines:</p>
<pre><code>temp2=temp1;
temp1=temp1->nxt;
</code></pre>
<p>...Will <code>temp2</code> an... | [
{
"answer_id": 109649,
"author": "terminus",
"author_id": 9232,
"author_profile": "https://Stackoverflow.com/users/9232",
"pm_score": 2,
"selected": false,
"text": "<p>temp2 will not be updated, but temp1 will point to the next item. So if temp1 is 0x89abcdef and temp1->next is 0x89b0000... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19790/"
] | `temp2`, `temp1` are pointers to some struct x:
```
struct FunkyStruct x;
struct FunkyStruct *temp1 = &x, *temp2 = &x;
```
Now, after execution of following lines:
```
temp2=temp1;
temp1=temp1->nxt;
```
...Will `temp2` and `temp1` still point to the same memory location? If not, please explain why they would be d... | Initially, `temp1` and `temp2` both contain the memory address of `x`.
`temp2 = temp1` means "assign the value of `temp1` to `temp2`". Since they have the same value to start with, this command does nothing.
The expression `temp1->next` means "Look inside the data structure that `temp1` points to, and return the valu... |
109,705 | <p>The following program is very simple: it outputs a single dot each half a second. If it recieves a <strong>SIGQUIT</strong>, it proceeds to output ten <strong>Q</strong>s. If it recieves a <strong>SIGTSTP</strong> <em>(<kbd>Ctrl</kbd>-<kbd>Z</kbd>)</em>, it outputs ten <strong>Z</strong>s.</p>
<p>If it recieves a <s... | [
{
"answer_id": 109783,
"author": "mbac32768",
"author_id": 18446,
"author_profile": "https://Stackoverflow.com/users/18446",
"pm_score": 4,
"selected": true,
"text": "<p>Your larger problem is blocking in signal handlers.</p>\n\n<p>This is usually discouraged since it can lead to strange... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The following program is very simple: it outputs a single dot each half a second. If it recieves a **SIGQUIT**, it proceeds to output ten **Q**s. If it recieves a **SIGTSTP** *(`Ctrl`-`Z`)*, it outputs ten **Z**s.
If it recieves a **SIGTSTP** while printing **Q**s, it will print ten **Z**s after it's done with the ten... | Your larger problem is blocking in signal handlers.
This is usually discouraged since it can lead to strange timing conditions. But it's not quite the cause of your problem since the timing condition you're vulnerable to exists because of your choice of signal handlers.
Anyway, here's how to at least minimize the tim... |
109,710 | <p>I've been digging through some parts of the Linux kernel, and found calls like this:</p>
<pre><code>if (unlikely(fd < 0))
{
/* Do something */
}
</code></pre>
<p>or</p>
<pre><code>if (likely(!err))
{
/* Do something */
}
</code></pre>
<p>I've found the definition of them:</p>
<pre><code>#define likel... | [
{
"answer_id": 109718,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 1,
"selected": false,
"text": "<p>They're hints to the compiler to generate the hint prefixes on branches. On x86/x64, they take up one byte, so... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9232/"
] | I've been digging through some parts of the Linux kernel, and found calls like this:
```
if (unlikely(fd < 0))
{
/* Do something */
}
```
or
```
if (likely(!err))
{
/* Do something */
}
```
I've found the definition of them:
```
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __bu... | They are hint to the compiler to emit instructions that will cause branch prediction to favour the "likely" side of a jump instruction. This can be a big win, if the prediction is correct it means that the jump instruction is basically free and will take zero cycles. On the other hand if the prediction is wrong, then i... |
109,717 | <p>In C#, if you have multiple constructors, you can do something like this:</p>
<pre><code>public MyClass(Guid inputId, string inputName){
// do something
}
public MyClass(Guid inputId): this(inputId, "foo") {}
</code></pre>
<p>The idea is of course code reuse. However, what is the best approach when there is a... | [
{
"answer_id": 109728,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 1,
"selected": false,
"text": "<p>The object would only be automatically disposed when garbage collection runs. If you want the dispose to run as ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | In C#, if you have multiple constructors, you can do something like this:
```
public MyClass(Guid inputId, string inputName){
// do something
}
public MyClass(Guid inputId): this(inputId, "foo") {}
```
The idea is of course code reuse. However, what is the best approach when there is a bit of complex logic need... | The most common pattern used to solve this problem is to have an Initialize() method that your constructors call, but in the example you just gave, adding a static method that you called like the code below, would do the trick.
```
public MyClass(MyOtherClass inputObject): this(inputObject.ID, GetHelperText(inputObjec... |
109,759 | <p>I've just switched an application to use ar_mailer and when I run ar_sendmail (after a long pause) I get the following error:</p>
<pre><code>Unhandled exception 530 5.7.0 Must issue a STARTTLS command first. h7sm16260325nfh.4
</code></pre>
<p>I am using Gmail SMTP to send the emails and I haven't changed any of th... | [
{
"answer_id": 109763,
"author": "workmad3",
"author_id": 16035,
"author_profile": "https://Stackoverflow.com/users/16035",
"pm_score": 0,
"selected": false,
"text": "<p>What version of ar_mailer are you using? A gmail specific bug was fixed in 1.3.1, as shown here:</p>\n\n<p><a href=\"h... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6432/"
] | I've just switched an application to use ar\_mailer and when I run ar\_sendmail (after a long pause) I get the following error:
```
Unhandled exception 530 5.7.0 Must issue a STARTTLS command first. h7sm16260325nfh.4
```
I am using Gmail SMTP to send the emails and I haven't changed any of the ActionMailer::Base.smt... | Did some digging in the lib and it seems that if you want to use TLS (as you do with Gmail) then it adds a new option to the ActionMailer::Base.smtp\_settings of :tls (default of which is false) which you should set to true.
The only thing the installation instructions mention regarding TLS is to remove any other smtp... |
109,761 | <p>I have the following config in my lighttpd.conf:</p>
<pre><code>$HTTP["host"] == "trac.domain.tld" {
server.document-root = "/usr/home/daniels/trac/htdocs/"
fastcgi.server = ( "/trac" =>
( "trac" =>
( "socket" => "/tmp/trac-fastcgi.s... | [
{
"answer_id": 109841,
"author": "Milen A. Radev",
"author_id": 15785,
"author_profile": "https://Stackoverflow.com/users/15785",
"pm_score": 1,
"selected": true,
"text": "<p>Look for \"For top level setup: ...\" <a href=\"http://trac.lighttpd.net/trac/wiki/HowToSetupTrac\" rel=\"nofollo... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789/"
] | I have the following config in my lighttpd.conf:
```
$HTTP["host"] == "trac.domain.tld" {
server.document-root = "/usr/home/daniels/trac/htdocs/"
fastcgi.server = ( "/trac" =>
( "trac" =>
( "socket" => "/tmp/trac-fastcgi.sock",
... | Look for "For top level setup: ..." [here](http://trac.lighttpd.net/trac/wiki/HowToSetupTrac). |
109,769 | <p>I am looking for an enhancement to JSON that will also serialize methods. I have an object that acts as a collection of objects, and would like to serialize the methods of the collection object as well. So far I've located <a href="http://www.thomasfrank.se/classier_json.html" rel="nofollow noreferrer">ClassyJSON<... | [
{
"answer_id": 109785,
"author": "moonshadow",
"author_id": 11834,
"author_profile": "https://Stackoverflow.com/users/11834",
"pm_score": 2,
"selected": false,
"text": "<p>Try to get away without serializing javascript code. That way lies a world of pain. Debugging will be much easier if... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | I am looking for an enhancement to JSON that will also serialize methods. I have an object that acts as a collection of objects, and would like to serialize the methods of the collection object as well. So far I've located [ClassyJSON](http://www.thomasfrank.se/classier_json.html). Any thoughts? | I don't think serializing methods is ever a good idea. If you intend to run the code serverside, you open yourself to attacks. If you want to run it client side, you are better off just the local methods, possibly referencing the name of the method you are going to use in the serialized objects.
I do believe though th... |
109,776 | <p>What's the best way to create recurring tasks?</p>
<p>Should I create some special syntax and parse it, kind of similar to Cronjobs on Linux or should I much rather just use a cronjob that runs every hour to create more of those recurring tasks with no end?</p>
<p>Keep in mind, that you can have endless recurring ... | [
{
"answer_id": 109785,
"author": "moonshadow",
"author_id": 11834,
"author_profile": "https://Stackoverflow.com/users/11834",
"pm_score": 2,
"selected": false,
"text": "<p>Try to get away without serializing javascript code. That way lies a world of pain. Debugging will be much easier if... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9535/"
] | What's the best way to create recurring tasks?
Should I create some special syntax and parse it, kind of similar to Cronjobs on Linux or should I much rather just use a cronjob that runs every hour to create more of those recurring tasks with no end?
Keep in mind, that you can have endless recurring tasks and tasks w... | I don't think serializing methods is ever a good idea. If you intend to run the code serverside, you open yourself to attacks. If you want to run it client side, you are better off just the local methods, possibly referencing the name of the method you are going to use in the serialized objects.
I do believe though th... |
109,781 | <p>What's the most elegant way to select out objects in an array that are unique with respect to one or more attributes?</p>
<p>These objects are stored in ActiveRecord so using AR's methods would be fine too. </p>
| [
{
"answer_id": 109794,
"author": "Alex M",
"author_id": 9652,
"author_profile": "https://Stackoverflow.com/users/9652",
"pm_score": 3,
"selected": false,
"text": "<p>I had originally suggested using the <code>select</code> method on Array. To wit:</p>\n\n<p><code>[1, 2, 3, 4, 5, 6, 7].se... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1227001/"
] | What's the most elegant way to select out objects in an array that are unique with respect to one or more attributes?
These objects are stored in ActiveRecord so using AR's methods would be fine too. | Use [`Array#uniq`](http://ruby-doc.org/core-1.9.2/Array.html#method-i-uniq) with a block:
```
@photos = @photos.uniq { |p| p.album_id }
``` |
109,859 | <p>I am reading a .NET book, and in one of the code examples there is a class definition with this field:</p>
<pre><code>private DateTime? startdate
</code></pre>
<p>What does <code>DateTime?</code> mean?</p>
| [
{
"answer_id": 109862,
"author": "Daniel Auger",
"author_id": 1644,
"author_profile": "https://Stackoverflow.com/users/1644",
"pm_score": 5,
"selected": false,
"text": "<p>It's a nullable DateTime. <code>?</code> after a primitive type/structure indicates that it is the nullable version.... | 2008/09/21 | [
"https://Stackoverflow.com/questions/109859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7148/"
] | I am reading a .NET book, and in one of the code examples there is a class definition with this field:
```
private DateTime? startdate
```
What does `DateTime?` mean? | Since `DateTime` is a `struct`, not a `class`, you get a `DateTime` *object*, not a *reference*, when you declare a field or variable of that type.
And, in the same way as an `int` cannot be `null`, so this `DateTime` object can never be `null`, because it's not a reference.
Adding the question mark turns it into a ... |
109,880 | <p>Has anybody found a good solution for lazily-evaluated lists in Perl? I've tried a number of ways to turn something like </p>
<pre><code>for my $item ( map { ... } @list ) {
}
</code></pre>
<p>into a lazy evaluation--by tie-ing @list, for example. I'm trying to avoid breaking down and writing a source filter to ... | [
{
"answer_id": 109899,
"author": "jkramer",
"author_id": 12523,
"author_profile": "https://Stackoverflow.com/users/12523",
"pm_score": 2,
"selected": false,
"text": "<p>If I remember correctly, for/foreach do get the whole list first anyways, so a lazily evaluated list would be read comp... | 2008/09/21 | [
"https://Stackoverflow.com/questions/109880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11289/"
] | Has anybody found a good solution for lazily-evaluated lists in Perl? I've tried a number of ways to turn something like
```
for my $item ( map { ... } @list ) {
}
```
into a lazy evaluation--by tie-ing @list, for example. I'm trying to avoid breaking down and writing a source filter to do it, because they mess wi... | As mentioned previously, for(each) is an eager loop, so it wants to evaluate the entire list before starting.
For simplicity, I would recommend using an iterator object or closure rather than trying to have a lazily evaluated array. While you *can* use a tie to have a lazily evaluated infinite list, you can run into t... |
109,916 | <p>To see what file to invoke the unrar command on, one needs to determine which file is the first in the file set.</p>
<p>Here are some sample file names, of which - naturally - only the first group should be matched:</p>
<pre><code>yes.rar
yes.part1.rar
yes.part01.rar
yes.part001.rar
no.part2.rar
no.part02.rar
no.... | [
{
"answer_id": 110120,
"author": "Matthew Encinas",
"author_id": 14433,
"author_profile": "https://Stackoverflow.com/users/14433",
"pm_score": 0,
"selected": false,
"text": "<p>I am no regex expert but here is my attempt</p>\n\n<pre><code>^(yes|no)\\.(rar|part0*1\\.rar)$\n</code></pre>\n... | 2008/09/21 | [
"https://Stackoverflow.com/questions/109916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19392/"
] | To see what file to invoke the unrar command on, one needs to determine which file is the first in the file set.
Here are some sample file names, of which - naturally - only the first group should be matched:
```
yes.rar
yes.part1.rar
yes.part01.rar
yes.part001.rar
no.part2.rar
no.part02.rar
no.part002.rar
no.part01... | The short answer is that it's not possible to construct a single regex to satisfy your problem. Ruby 1.8 does not have lookaround assertions (the (?<! stuff in your example regex) which is why your regex doesn't work. This leaves you with two options.
1) Use more than one regex to do it.
```
def is_first_rar(filename... |
109,934 | <p>I've got a generic<> function that takes a linq query ('items') and enumerates through it adding additional properties. How can I select all the properties of the original 'item' rather than the item itself (as the code below does)?</p>
<p>So equivalent to the sql: select *, 'bar' as Foo from items</p>
<pre><co... | [
{
"answer_id": 109967,
"author": "Esteban Araya",
"author_id": 781,
"author_profile": "https://Stackoverflow.com/users/781",
"pm_score": 0,
"selected": false,
"text": "<pre><code>from item in items\nwhere someConditionOnItem\nselect\n{\n propertyOne,\n propertyTwo\n};\n</code></p... | 2008/09/21 | [
"https://Stackoverflow.com/questions/109934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14072/"
] | I've got a generic<> function that takes a linq query ('items') and enumerates through it adding additional properties. How can I select all the properties of the original 'item' rather than the item itself (as the code below does)?
So equivalent to the sql: select \*, 'bar' as Foo from items
```
foreach (var item in... | There's no easy way of doing what you're suggesting, as all types in C# are strong-typed, even the anonymous ones like you're using. However it's not impossible to pull it off. To do it you would have to utilize reflection and emit your own assembly in memory, adding a new module and type that contains the specific pro... |
109,948 | <p>just a quick question:</p>
<p>I am a CS undergrad and have only had experience with the Eclipse, and Net Beans IDEs. I have recently acquired a Macbook and was wanting to recompile a recent school project in Xcode just to test it out. Right after the line where I declare a new instance of an ArrayList: </p>
<pre... | [
{
"answer_id": 109957,
"author": "user7305",
"author_id": 7305,
"author_profile": "https://Stackoverflow.com/users/7305",
"pm_score": 0,
"selected": false,
"text": "<p>Generics are introduced in Java 5, so you can't use generics with -source 1.3 option.</p>\n"
},
{
"answer_id": 1... | 2008/09/21 | [
"https://Stackoverflow.com/questions/109948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14013/"
] | just a quick question:
I am a CS undergrad and have only had experience with the Eclipse, and Net Beans IDEs. I have recently acquired a Macbook and was wanting to recompile a recent school project in Xcode just to test it out. Right after the line where I declare a new instance of an ArrayList:
```
dictionary = new... | Java support in Xcode is obsolete and unmaintained; it's the only bit of Xcode that still uses the "old" build system inherited from Project Builder. Even Apple suggests using Eclipse instead. For Java, both Eclipse and NetBeans work quite well on the Mac; if you want to try native Mac programming, use Objective-C and ... |
110,078 | <p>I need to store app specific configuration in rails. But it has to be:</p>
<ul>
<li>reachable in any file (model, view, helpers and controllers</li>
<li>environment specified (or not), that means each environment can overwrite the configs specified in environment.rb</li>
</ul>
<p>I've tried to use environment.rb a... | [
{
"answer_id": 110103,
"author": "Ricardo Acras",
"author_id": 19224,
"author_profile": "https://Stackoverflow.com/users/19224",
"pm_score": 0,
"selected": false,
"text": "<p>I found a good way <a href=\"http://kpumuk.info/ruby-on-rails/flexible-application-configuration-in-ruby-on-rails... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19224/"
] | I need to store app specific configuration in rails. But it has to be:
* reachable in any file (model, view, helpers and controllers
* environment specified (or not), that means each environment can overwrite the configs specified in environment.rb
I've tried to use environment.rb and put something like
```
USE_USER... | I was helping a friend set up [the solution mentioned by Ricardo](http://kpumuk.info/ruby-on-rails/flexible-application-configuration-in-ruby-on-rails/) yesterday. We hacked it a bit by loading the YAML file with something similar to this (going from memory here):
```
require 'ostruct'
require 'yaml'
require 'erb'
#co... |
110,083 | <pre><code>String s = "";
for(i=0;i<....){
s = some Assignment;
}
</code></pre>
<p>or</p>
<pre><code>for(i=0;i<..){
String s = some Assignment;
}
</code></pre>
<p>I don't need to use 's' outside the loop ever again.
The first option is perhaps better since a new String is not initialized each time. Th... | [
{
"answer_id": 110090,
"author": "Esteban Araya",
"author_id": 781,
"author_profile": "https://Stackoverflow.com/users/781",
"pm_score": 5,
"selected": false,
"text": "<p>In <em>theory</em>, it's a waste of resources to declare the string inside the loop. \nIn <em>practice</em>, however,... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16485/"
] | ```
String s = "";
for(i=0;i<....){
s = some Assignment;
}
```
or
```
for(i=0;i<..){
String s = some Assignment;
}
```
I don't need to use 's' outside the loop ever again.
The first option is perhaps better since a new String is not initialized each time. The second however would result in the scope of th... | ### Limited Scope is Best
Use your second option:
```
for ( ... ) {
String s = ...;
}
```
### Scope Doesn't Affect Performance
If you disassemble code the compiled from each (with the JDK's `javap` tool), you will see that the loop compiles to the exact same JVM instructions in both cases. Note also that [Brian ... |
110,121 | <p>Everything inherits from object. It's the basis of inheritance. Everything can be implicitly cast up the inheritance tree, ie.</p>
<pre><code>object me = new Person();
</code></pre>
<p>Therefore, following this through to its logical conclusion, a group of People would also be a group of objects:</p>
<pre><code>L... | [
{
"answer_id": 110136,
"author": "mattlant",
"author_id": 14642,
"author_profile": "https://Stackoverflow.com/users/14642",
"pm_score": 2,
"selected": false,
"text": "<p>you can use linq to cast it:</p>\n\n<pre><code>IEnumerable<Person> oldList = someIenumarable;\nIEnumerable<ob... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] | Everything inherits from object. It's the basis of inheritance. Everything can be implicitly cast up the inheritance tree, ie.
```
object me = new Person();
```
Therefore, following this through to its logical conclusion, a group of People would also be a group of objects:
```
List<Person> people = new List<Person>... | OK, everyone who has used generics in .net must have run into this at one point or another.
Yes, intuitively it should work. No, in the current version of the C# compiler it doesn't.
Eric Lippert has a really good explanation of this issue (it's in eleven parts or something and will bend you mind in places, but it's ... |
110,123 | <p>I'm using ASP.NET Web Forms for blog style comments. </p>
<p>Edit 1: This looks way more complicated then I first thought. How do you filter the src?<br>
I would prefer to still use real html tags but if things get too complicated that way, I might go a custom route. I haven't done any XML yet, so do I need to l... | [
{
"answer_id": 110146,
"author": "Thomas",
"author_id": 14637,
"author_profile": "https://Stackoverflow.com/users/14637",
"pm_score": 1,
"selected": false,
"text": "<p>Use an XML parser to validate your input, and drop or encode all elements, and attributes, that you do not want to allow... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10352/"
] | I'm using ASP.NET Web Forms for blog style comments.
Edit 1: This looks way more complicated then I first thought. How do you filter the src?
I would prefer to still use real html tags but if things get too complicated that way, I might go a custom route. I haven't done any XML yet, so do I need to learn more abou... | If IMG is the only thing you'd allow, I'd suggest you use a simple square-bracket syntax to allow it. This would eliminate the need for a parser and reduce a load of other dangerous edge cases with the parser as well. Say, something like:
```
Look at this! [http://a.b.c/m.jpg]
```
Which would get converted to
```
L... |
110,157 | <p>This is one of the possible ways I come out:</p>
<pre><code>struct RetrieveKey
{
template <typename T>
typename T::first_type operator()(T keyValuePair) const
{
return keyValuePair.first;
}
};
map<int, int> m;
vector<int> keys;
// Retrieve all keys
transform(m.begin(), m.e... | [
{
"answer_id": 110170,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": false,
"text": "<p>The SGI STL has an extension called <a href=\"http://www.sgi.com/tech/stl/select1st.html\" rel=\"noreferrer\"><code>selec... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18638/"
] | This is one of the possible ways I come out:
```
struct RetrieveKey
{
template <typename T>
typename T::first_type operator()(T keyValuePair) const
{
return keyValuePair.first;
}
};
map<int, int> m;
vector<int> keys;
// Retrieve all keys
transform(m.begin(), m.end(), back_inserter(keys), Retr... | While your solution should work, it can be difficult to read depending on the skill level of your fellow programmers. Additionally, it moves functionality away from the call site. Which can make maintenance a little more difficult.
I'm not sure if your goal is to get the keys into a vector or print them to cout so I'm... |
110,163 | <p>I have a rails model that looks something like this:</p>
<pre><code>class Recipe < ActiveRecord::Base
has_many :ingredients
attr_accessor :ingredients_string
attr_accessible :title, :directions, :ingredients, :ingredients_string
before_save :set_ingredients
def ingredients_string
ingredien... | [
{
"answer_id": 110170,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": false,
"text": "<p>The SGI STL has an extension called <a href=\"http://www.sgi.com/tech/stl/select1st.html\" rel=\"noreferrer\"><code>selec... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] | I have a rails model that looks something like this:
```
class Recipe < ActiveRecord::Base
has_many :ingredients
attr_accessor :ingredients_string
attr_accessible :title, :directions, :ingredients, :ingredients_string
before_save :set_ingredients
def ingredients_string
ingredients.join("\n")
... | While your solution should work, it can be difficult to read depending on the skill level of your fellow programmers. Additionally, it moves functionality away from the call site. Which can make maintenance a little more difficult.
I'm not sure if your goal is to get the keys into a vector or print them to cout so I'm... |
110,175 | <p>How can you automatically import the latest build/revision number in subversion?</p>
<p>The goal would be to have that number visible on your webpage footer like SO does.</p>
| [
{
"answer_id": 110182,
"author": "coppro",
"author_id": 16855,
"author_profile": "https://Stackoverflow.com/users/16855",
"pm_score": 1,
"selected": false,
"text": "<p>Well, you can run 'svn info' to determine the current revision number, and you could probably extract that pretty easily... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] | How can you automatically import the latest build/revision number in subversion?
The goal would be to have that number visible on your webpage footer like SO does. | ```
svn info <Repository-URL>
```
or
```
svn info --xml <Repository-URL>
```
Then look at the result. For xml, parse /info/entry/@revision for the revision of the repository (151 in this example) or /info/entry/commit/@revision for the revision of the last commit against this path (133, useful when working with ta... |
110,205 | <p>I want to download this open source application, and they are using Git. What do I need to download the code base?</p>
<p><b>Update</b>
How do I change the working directory when I am using Git Bash? (I want to download the repo at a certain directory, using pwd tells me I will be downloading the repo where I don... | [
{
"answer_id": 110209,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 8,
"selected": true,
"text": "<p>Download <a href=\"http://code.google.com/p/msysgit/\" rel=\"noreferrer\">Git on Msys</a>. Then:</p>\n\n<pre><code>git ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] | I want to download this open source application, and they are using Git. What do I need to download the code base?
**Update**
How do I change the working directory when I am using Git Bash? (I want to download the repo at a certain directory, using pwd tells me I will be downloading the repo where I don't want it. | Download [Git on Msys](http://code.google.com/p/msysgit/). Then:
```
git clone git://project.url.here
``` |
110,232 | <p>I am creating a website in CakePHP and I am kind of new on it. I couldn't find good resources on this matter, so there you go:</p>
<p>I have a three table structure for registering users: <code>Users</code>, <code>Addresses</code> and <code>Contacts</code>. I have to build a view with info of all three tables like:... | [
{
"answer_id": 110432,
"author": "gizmo",
"author_id": 9396,
"author_profile": "https://Stackoverflow.com/users/9396",
"pm_score": 2,
"selected": false,
"text": "<p>CakePHP allows you to easily maintains link between your models using relationship, see <a href=\"http://book.cakephp.org/v... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2274/"
] | I am creating a website in CakePHP and I am kind of new on it. I couldn't find good resources on this matter, so there you go:
I have a three table structure for registering users: `Users`, `Addresses` and `Contacts`. I have to build a view with info of all three tables like:
```
Full Name: [ ] (fro... | If your using the latest 1.2 code, check out Model::saveAll in the api
eg. Your view might look something like this:
```
echo $form->create('User', array('action' => 'add');
echo $form->input('User.name');
echo $form->input('Address.line_1');
echo $form->input('Contact.tel');
echo $form->end('Save');
```
Then in yo... |
110,249 | <p>Since VS 2005, I see that it is not possible to simply build a dll against MS runtime and deploy them together (<a href="http://www.ddj.com/windows/184406482" rel="nofollow noreferrer">http://www.ddj.com/windows/184406482</a>). I am deeply confused by manifest, SxS and co: MSDN documentation is really poor, with cir... | [
{
"answer_id": 110266,
"author": "Brian",
"author_id": 18192,
"author_profile": "https://Stackoverflow.com/users/18192",
"pm_score": 2,
"selected": false,
"text": "<p>Well, I've encountered some of these issues, so perhaps some of my comments will be helpful.</p>\n\n<ol>\n<li>The manifes... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11465/"
] | Since VS 2005, I see that it is not possible to simply build a dll against MS runtime and deploy them together (<http://www.ddj.com/windows/184406482>). I am deeply confused by manifest, SxS and co: MSDN documentation is really poor, with circular references; specially since I am more a Unix guy, I find all those uninf... | We use a simple include file in all our applications & DLL's, vcmanifest.h, then set all projects to embedded the manifest file.
vcmanifest.h
```
/*----------------------------------------------------------------------------*/
#if _MSC_VER >= 1400
/*------------------------------------------------------------------... |
110,259 | <p>I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory.
Google search shows a commercial one is <a href="http://www.softwareverify.com/python/memory/index.html" rel="noreferrer">Python Memory Validator</a> (Windows only).<... | [
{
"answer_id": 110272,
"author": "sanxiyn",
"author_id": 18382,
"author_profile": "https://Stackoverflow.com/users/18382",
"pm_score": 6,
"selected": false,
"text": "<p>I recommend <a href=\"http://www.aminus.net/wiki/Dowser\" rel=\"noreferrer\">Dowser</a>. It is very easy to setup, and ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6946/"
] | I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory.
Google search shows a commercial one is [Python Memory Validator](http://www.softwareverify.com/python/memory/index.html) (Windows only).
And open source ones are [PySi... | [guppy3](https://github.com/zhuyifei1999/guppy3/) is quite simple to use. At some point in your code, you have to write the following:
```
from guppy import hpy
h = hpy()
print(h.heap())
```
This gives you some output like this:
```
Partition of a set of 132527 objects. Total size = 8301532 bytes.
Index Count % ... |
110,281 | <p>How can I make a style have all of the properties of the style defined in <code>.a .b .c</code> except for <code>background-color</code> (or some other property)? This does not seem to work.</p>
<pre><code>.a .b .c
{
background-color: #0000FF;
color: #ffffff;
border: 1px solid #c0c0c0;
margin-top: 4... | [
{
"answer_id": 110287,
"author": "micahwittman",
"author_id": 11181,
"author_profile": "https://Stackoverflow.com/users/11181",
"pm_score": 2,
"selected": false,
"text": "<pre><code>.a, .b, .c {color: #ffffff; border: 1px solid #c0c0c0; margin-top: 4px; padding: 3px; text-align: center; ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15059/"
] | How can I make a style have all of the properties of the style defined in `.a .b .c` except for `background-color` (or some other property)? This does not seem to work.
```
.a .b .c
{
background-color: #0000FF;
color: #ffffff;
border: 1px solid #c0c0c0;
margin-top: 4px;
padding: 3px;
text-align... | You would add the .d class selector as a selector for your first rule, then add a rule to redefine the background color for .d:
```
.a .b .c,
.d {
background-color: #0000FF;
color: #ffffff;
border: 1px solid #c0c0c0;
margin-top: 4px;
padding: 3px;
text-align: center;
font-weight: bold;
}
.d {
backgr... |
110,305 | <p>I'm working on a page has an ol with nested p's, div's, and li's. Internet Explorer 6 and 7 both render the numbers for the ol tag after the p element at the end (at the very, very bottom of the li tag) rather than at the top of the outermost li as expected. I'm working on a PowerPC Mac and can't do any testing. Is ... | [
{
"answer_id": 110331,
"author": "Abhi Beckert",
"author_id": 19851,
"author_profile": "https://Stackoverflow.com/users/19851",
"pm_score": 0,
"selected": false,
"text": "<p>I just tested your example html in firefox 3/webkit nightly/internet explorer 7 and all of them rendered exactly t... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10140/"
] | I'm working on a page has an ol with nested p's, div's, and li's. Internet Explorer 6 and 7 both render the numbers for the ol tag after the p element at the end (at the very, very bottom of the li tag) rather than at the top of the outermost li as expected. I'm working on a PowerPC Mac and can't do any testing. Is the... | Congratulations, you are the victim of IE's [hasLayout](http://msdn.microsoft.com/en-us/library/ms533776.aspx) property.
Short version: You've got it easy this time. Changes these rules:
```
...
ol {
font-size: 1.1em;
}
...
li.main_item {
width: 700px;
clear: right;
}
...
```
To this:
```
...
ol {... |
110,313 | <p>If our organisation were to switch from a central-server VCS like subversion to a distributed VCS like git, how do I make sure that all my code is safe from hardware failure?</p>
<p>With a central-server VCS I just need to backup the repository every day. If we were using a DVCS then there'd be loads of code branch... | [
{
"answer_id": 110319,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 1,
"selected": false,
"text": "<p>It's not uncommon to use a \"central\" server as an authority in DVCS, which also provides you the place to do your b... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6408/"
] | If our organisation were to switch from a central-server VCS like subversion to a distributed VCS like git, how do I make sure that all my code is safe from hardware failure?
With a central-server VCS I just need to backup the repository every day. If we were using a DVCS then there'd be loads of code branches on all ... | I think that you will find that in practice developers will prefer to use a central repository than pushing and pulling between each other's local repositories. Once you've cloned a central repository, while working on any tracking branches, fetching and pushing are trivial commands. Adding half a dozen remotes to all ... |
110,314 | <p>So, I am using the Linq entity framework. I have 2 entities: <code>Content</code> and <code>Tag</code>. They are in a many-to-many relationship with one another. <code>Content</code> can have many <code>Tags</code> and <code>Tag</code> can have many <code>Contents</code>. So I am trying to write a query to select al... | [
{
"answer_id": 110348,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 1,
"selected": false,
"text": "<pre><code>tags.Select(testTag => testTag.Name)\n</code></pre>\n\n<p>Where does the tags variable gets initialized from? ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19854/"
] | So, I am using the Linq entity framework. I have 2 entities: `Content` and `Tag`. They are in a many-to-many relationship with one another. `Content` can have many `Tags` and `Tag` can have many `Contents`. So I am trying to write a query to select all contents where any tags names are equal to `blah`
The entities bot... | After reading about the [PredicateBuilder](http://www.albahari.com/nutshell/predicatebuilder.aspx), reading all of the wonderful posts that people sent to me, posting on other sites, and then reading more on [Combining Predicates](http://blogs.msdn.com/meek/archive/2008/05/02/linq-to-entities-combining-predicates.aspx)... |
110,325 | <p>Obviously I can use BCP but here is the issue. If one of the records in a Batch have an invalid date I want to redirect that to a separate table/file/whatever, but keep the batch processing running. I don't think SSIS can be installed on the server which would have helped.</p>
| [
{
"answer_id": 110372,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 4,
"selected": true,
"text": "<p>Create a trigger that processes on INSERT. This trigger will do a validation check on your date field. If it fail... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19857/"
] | Obviously I can use BCP but here is the issue. If one of the records in a Batch have an invalid date I want to redirect that to a separate table/file/whatever, but keep the batch processing running. I don't think SSIS can be installed on the server which would have helped. | Create a trigger that processes on INSERT. This trigger will do a validation check on your date field. If it fails the validation, then do an insert into your separate table, and you can also choose to continue the insert or not allow it to go through.
an **important** note: by default triggers do not fire on bulk ins... |
110,332 | <p>I have an <code>NSArray</code> and I'd like to create a new <code>NSArray</code> with objects from the original array that meet certain criteria. The criteria is decided by a function that returns a <code>BOOL</code>.</p>
<p>I can create an <code>NSMutableArray</code>, iterate through the source array and copy over... | [
{
"answer_id": 110343,
"author": "lajos",
"author_id": 3740,
"author_profile": "https://Stackoverflow.com/users/3740",
"pm_score": 8,
"selected": true,
"text": "<p><code>NSArray</code> and <code>NSMutableArray</code> provide methods to filter array contents. <code>NSArray</code> provides... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3740/"
] | I have an `NSArray` and I'd like to create a new `NSArray` with objects from the original array that meet certain criteria. The criteria is decided by a function that returns a `BOOL`.
I can create an `NSMutableArray`, iterate through the source array and copy over the objects that the filter function accepts and then... | `NSArray` and `NSMutableArray` provide methods to filter array contents. `NSArray` provides **filteredArrayUsingPredicate:** which returns a new array containing objects in the receiver that match the specified predicate. `NSMutableArray` adds **filterUsingPredicate:** which evaluates the receiver’s content against the... |
110,336 | <p>Here's my issue: I need to close a process, already running, from a C# program.
The problem is that the process now runs as an icon (minimized to taskbar), and unless the user opens it at least once (which will never happen on unattended machines), it'll never
have a main window. </p>
<p>The other requirement that... | [
{
"answer_id": 110401,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 1,
"selected": false,
"text": "<p>If it's on the taskbar, it'll have a window. Or did you mean that it's in the taskbar notification area (aka the ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19856/"
] | Here's my issue: I need to close a process, already running, from a C# program.
The problem is that the process now runs as an icon (minimized to taskbar), and unless the user opens it at least once (which will never happen on unattended machines), it'll never
have a main window.
The other requirement that I have is... | Here are some answers and clarifications:
**rpetrich**:
Tried your method before and the problem is, I don't know the window name, it differs from user to user, version to version - just the exe name remains constant. All I have is the process name. And as you can see in the code above the MainWindowHandle of the proc... |
110,341 | <p>Ok, I realize this situation is somewhat unusual, but I need to establish a TCP connection (the 3-way handshake) using only raw sockets (in C, in linux) -- i.e. I need to construct the IP headers and TCP headers myself. I'm writing a server (so I have to first respond to the incoming SYN packet), and for whatever r... | [
{
"answer_id": 110349,
"author": "bmdhacks",
"author_id": 14032,
"author_profile": "https://Stackoverflow.com/users/14032",
"pm_score": 1,
"selected": false,
"text": "<p>I don't have a tutorial, but I recently used <a href=\"http://www.wireshark.org/\" rel=\"nofollow noreferrer\">Wiresha... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19860/"
] | Ok, I realize this situation is somewhat unusual, but I need to establish a TCP connection (the 3-way handshake) using only raw sockets (in C, in linux) -- i.e. I need to construct the IP headers and TCP headers myself. I'm writing a server (so I have to first respond to the incoming SYN packet), and for whatever reaso... | You want to implement part of a TCP stack in userspace... this is ok, some other apps do this.
One problem you will come across is that the kernel will be sending out (generally negative, unhelpful) replies to incoming packets. This is going to screw up any communication you attempt to initiate.
One way to avoid this... |
110,354 | <p>I want to do this:</p>
<pre><code>e.className = t;
</code></pre>
<p>Where t is the name of a style I have defined in a stylesheet.</p>
| [
{
"answer_id": 110357,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, that works (with the class name as a string, as jonah mentioned). Also, you can set style attributes directly on an ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15059/"
] | I want to do this:
```
e.className = t;
```
Where t is the name of a style I have defined in a stylesheet. | If `e` is a reference to a DOM element and you have a class like this: `.t {color:green;}` then you want reference the class name as a string:
```
e.className = 't';
``` |
110,378 | <p>How can I change the width of a textarea form element if I used ModelForm to create it?</p>
<p>Here is my product class:</p>
<pre><code>class ProductForm(ModelForm):
long_desc = forms.CharField(widget=forms.Textarea)
short_desc = forms.CharField(widget=forms.Textarea)
class Meta:
model = Produc... | [
{
"answer_id": 110414,
"author": "zuber",
"author_id": 9812,
"author_profile": "https://Stackoverflow.com/users/9812",
"pm_score": 8,
"selected": true,
"text": "<p><strong>The easiest way for your use case is to use CSS</strong>. It's a language meant for defining presentation. Look at t... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] | How can I change the width of a textarea form element if I used ModelForm to create it?
Here is my product class:
```
class ProductForm(ModelForm):
long_desc = forms.CharField(widget=forms.Textarea)
short_desc = forms.CharField(widget=forms.Textarea)
class Meta:
model = Product
```
And the templ... | **The easiest way for your use case is to use CSS**. It's a language meant for defining presentation. Look at the code generated by form, take note of the ids for fields that interest you, and change appearance of these fields through CSS.
Example for `long_desc` field in your ProductForm (when your form does not have... |
110,384 | <p>I am looking to set the result action from a failed IAuthorizationFilter. However I am unsure how to create an ActionResult from inside the Filter. The controller doesn't seem to be accible from inside the filter so my usual View("SomeView") isn't working. Is there a way to get the controler or else another way o... | [
{
"answer_id": 110630,
"author": "Jeremy Skinner",
"author_id": 8560,
"author_profile": "https://Stackoverflow.com/users/8560",
"pm_score": 2,
"selected": true,
"text": "<p>You can instantiate the appropriate ActionResult directly, then set it on the context. For example:</p>\n\n<pre><co... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/361/"
] | I am looking to set the result action from a failed IAuthorizationFilter. However I am unsure how to create an ActionResult from inside the Filter. The controller doesn't seem to be accible from inside the filter so my usual View("SomeView") isn't working. Is there a way to get the controler or else another way of crea... | You can instantiate the appropriate ActionResult directly, then set it on the context. For example:
```
public void OnAuthorization(AuthorizationContext context)
{
if (!context.HttpContext.User.Identity.IsAuthenticated)
{
context.Result = new ViewResult { ViewName = "Whatever" };
}
}
``` |
110,385 | <p>I have a group of checkboxes that I only want to allow a set amount to be checked at any one time. If the newly checked checkbox pushes the count over the limit, I'd like the oldest checkbox to be automatically unchecked. The group of checkboxes all use the same event handler shown below.</p>
<p>I have achieved the... | [
{
"answer_id": 110398,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 3,
"selected": true,
"text": "<p>I think you are looking for a <a href=\"http://msdn.microsoft.com/en-us/library/he2s3bh7.aspx\" rel=\"nofollow noreferrer\... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1880/"
] | I have a group of checkboxes that I only want to allow a set amount to be checked at any one time. If the newly checked checkbox pushes the count over the limit, I'd like the oldest checkbox to be automatically unchecked. The group of checkboxes all use the same event handler shown below.
I have achieved the functiona... | I think you are looking for a [LinkedList](http://msdn.microsoft.com/en-us/library/he2s3bh7.aspx).
Use `AddLast` instead of `Enqueue` and `RemoveFirst` instead of `Dequeue` and for removing something in the middle, just use a normal `Remove`. |
110,430 | <p>Do you write one test per function/method, with multiple checks in the test, or a test for each check?</p>
| [
{
"answer_id": 110434,
"author": "TraumaPony",
"author_id": 18658,
"author_profile": "https://Stackoverflow.com/users/18658",
"pm_score": 2,
"selected": false,
"text": "<p>A test case for each check. It's more granular. It makes it much easier to see what specific test case failed.</p>\n... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19863/"
] | Do you write one test per function/method, with multiple checks in the test, or a test for each check? | One test per check and super descriptive names, per instance:
```
@Test
public void userCannotVoteDownWhenScoreIsLessThanOneHundred() {
...
}
```
Both only one assertion and using good names gives me a better report when a test fails. They scream to me: "You broke THAT rule!". |
110,436 | <p>Any recommended practices for cleaning up "header spaghetti" which is causing extremely
slow compilation times (Linux/Unix)?</p>
<p>Is there any equvalent to "#pragma once" with GCC?<br>
(found conflicting messages regarding this)</p>
<p>Thanks.</p>
| [
{
"answer_id": 110448,
"author": "andreas buykx",
"author_id": 19863,
"author_profile": "https://Stackoverflow.com/users/19863",
"pm_score": 1,
"selected": false,
"text": "<p>In headers: include headers only if you can't use forward declaration, but always #include any file that you need... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Any recommended practices for cleaning up "header spaghetti" which is causing extremely
slow compilation times (Linux/Unix)?
Is there any equvalent to "#pragma once" with GCC?
(found conflicting messages regarding this)
Thanks. | Assuming you're familiar with "include guards" (#ifdef at the begining of the header..), an additional way of speeding up build time is by using external include guards.
It was discussed in "[Large Scale C++ Software Design](http://vig.pearsoned.com/store/product/1,1207,store-15080_isbn-0201633620,00.html)". The idea i... |
110,451 | <p>I am working through the book Learning WCF by Michele Bustamante, and trying to do it using Visual Studio C# Express 2008. The instructions say to use WCF project and item templates, which are not included with VS C# Express. There <em>are</em> templates for these types included with Visual Studio Web Developer Ex... | [
{
"answer_id": 110502,
"author": "adondai",
"author_id": 19713,
"author_profile": "https://Stackoverflow.com/users/19713",
"pm_score": 2,
"selected": false,
"text": "<p>If you are a student you could get the full Visual Studio 2008 from <a href=\"http://dreamspark.com\" rel=\"nofollow no... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14607/"
] | I am working through the book Learning WCF by Michele Bustamante, and trying to do it using Visual Studio C# Express 2008. The instructions say to use WCF project and item templates, which are not included with VS C# Express. There *are* templates for these types included with Visual Studio Web Developer Express, and I... | If you have both Visual Web Developer (VWD) 2008 and Visual C# (VC#) 2008 installed you can copy templates between them. The VWD template files live in (by default):
```
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\VWDExpress
```
The VC# templates live in:
```
C:\Program Files\Microsoft Visual Studio 9.... |
110,498 | <p>Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively complicated) work to do what seems like it should be pretty simple.</p>
| [
{
"answer_id": 110547,
"author": "olt",
"author_id": 19759,
"author_profile": "https://Stackoverflow.com/users/19759",
"pm_score": 5,
"selected": false,
"text": "<p><a href=\"https://linux.die.net/diveintopython/html/http_web_services/redirects.html\" rel=\"nofollow noreferrer\">Dive Int... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build\_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively complicated) work to do what seems like it should be pretty simple. | Here is the [Requests](http://docs.python-requests.org/en/latest/) way:
```
import requests
r = requests.get('http://github.com', allow_redirects=False)
print(r.status_code, r.headers['Location'])
``` |
110,512 | <p>I'm currently running mongrel clusters with monit watching over them for 8 Rails applications on one server.</p>
<p>I'd like to move 7 of these applications to mod_rails, with one remaining on mongrel. The 7 smaller applications are low-volume, while the one I'd like to remain on mongrel is a high volume, app.</p>
... | [
{
"answer_id": 110799,
"author": "tomtaylor",
"author_id": 19079,
"author_profile": "https://Stackoverflow.com/users/19079",
"pm_score": 3,
"selected": true,
"text": "<p>I would probably just move all the apps to mod_rails, as the performance seems comparable to Mongrel and there's less ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10596/"
] | I'm currently running mongrel clusters with monit watching over them for 8 Rails applications on one server.
I'd like to move 7 of these applications to mod\_rails, with one remaining on mongrel. The 7 smaller applications are low-volume, while the one I'd like to remain on mongrel is a high volume, app.
As I underst... | I would probably just move all the apps to mod\_rails, as the performance seems comparable to Mongrel and there's less administration overhead.
With regards to configuration gotchas, just make sure that you allow your public directory, or you'll find static assets failing:
```
<Directory "/var/www/app/current/public"... |
110,536 | <p>I have the following code:</p>
<pre><code>string prefix = "OLD:";
Func<string, string> prependAction = (x => prefix + x);
prefix = "NEW:";
Console.WriteLine(prependAction("brownie"));
</code></pre>
<p>Because the compiler replaces the prefix variable with a closure "NEW:brownie" is printed to the console.... | [
{
"answer_id": 110540,
"author": "Dested",
"author_id": 11137,
"author_profile": "https://Stackoverflow.com/users/11137",
"pm_score": -1,
"selected": false,
"text": "<p>What about this</p>\n\n<pre><code>string prefix = \"OLD:\";\nstring _prefix=prefix;\nFunc<string, string> prepend... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6600/"
] | I have the following code:
```
string prefix = "OLD:";
Func<string, string> prependAction = (x => prefix + x);
prefix = "NEW:";
Console.WriteLine(prependAction("brownie"));
```
Because the compiler replaces the prefix variable with a closure "NEW:brownie" is printed to the console.
Is there an easy way to prevent t... | I see the underlying problem now. It is deeper than I first thought. Basically the solution is to modify the expression tree before serializing it, by replacing all subtrees that do not depend on the parameters with constant nodes. This is apparently called "funcletization".
There is an explanation of it [here](http://... |
110,562 | <p>I need to write a function that receives a property as a parameter and execute its getter.</p>
<p>If I needed to pass a function/delegate I would have used:</p>
<pre><code>delegate RET FunctionDelegate<T, RET>(T t);
void func<T, RET>(FunctionDelegate function, T param, ...)
{
...
return functi... | [
{
"answer_id": 110569,
"author": "Martijn",
"author_id": 17439,
"author_profile": "https://Stackoverflow.com/users/17439",
"pm_score": 2,
"selected": false,
"text": "<p>Properties are simply syntactic sugar for methods.</p>\n\n<p>I don't think you can modify a property such that it becom... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11361/"
] | I need to write a function that receives a property as a parameter and execute its getter.
If I needed to pass a function/delegate I would have used:
```
delegate RET FunctionDelegate<T, RET>(T t);
void func<T, RET>(FunctionDelegate function, T param, ...)
{
...
return function.Invoke(param);
}
```
Is ther... | You can use reflection, you can get a MethodInfo object for the get/set accessors and call it's Invoke method.
The code example assumes you have both a get and set accessors and you really have to add error handling if you want to use this in production code:
For example to get the value of property Foo of object obj... |
110,575 | <p>Earlier today a question was asked regarding <a href="https://stackoverflow.com/questions/110458/what-percentage-of-my-time-will-be-spent-in-user-input-verfication-during-web-d">input validation strategies in web apps</a>.</p>
<p>The top answer, at time of writing, suggests in <code>PHP</code> just using <code>html... | [
{
"answer_id": 110576,
"author": "Cheekysoft",
"author_id": 1820,
"author_profile": "https://Stackoverflow.com/users/1820",
"pm_score": 9,
"selected": true,
"text": "<p>When it comes to database queries, always try and use prepared parameterised queries. The <code>mysqli</code> and <code... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1820/"
] | Earlier today a question was asked regarding [input validation strategies in web apps](https://stackoverflow.com/questions/110458/what-percentage-of-my-time-will-be-spent-in-user-input-verfication-during-web-d).
The top answer, at time of writing, suggests in `PHP` just using `htmlspecialchars` and `mysql_real_escape_... | When it comes to database queries, always try and use prepared parameterised queries. The `mysqli` and `PDO` libraries support this. This is infinitely safer than using escaping functions such as `mysql_real_escape_string`.
Yes, `mysql_real_escape_string` is effectively just a string escaping function. It is not a mag... |
110,584 | <p>I have a document library with about 50 available content types. This document library is divided into several folders. When a user cliks the "New" button in a folder, all available content types are offered. I need to limit the content types according to the folder. For example, in the folder "Legal" a want to hav... | [
{
"answer_id": 110711,
"author": "Magnus Johansson",
"author_id": 3584,
"author_profile": "https://Stackoverflow.com/users/3584",
"pm_score": 3,
"selected": true,
"text": "<p>Have you looked at <a href=\"http://www.tonstegeman.com/Blog/Lists/Posts/Post.aspx?List=70640fe5%2D28d9%2D464f%2D... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19884/"
] | I have a document library with about 50 available content types. This document library is divided into several folders. When a user cliks the "New" button in a folder, all available content types are offered. I need to limit the content types according to the folder. For example, in the folder "Legal" a want to have on... | Have you looked at [this](http://www.tonstegeman.com/Blog/Lists/Posts/Post.aspx?List=70640fe5%2D28d9%2D464f%2Db1c9%2D91e07c8f7e47&ID=56) article by Ton Stegeman? |
110,587 | <p>in a DB2 trigger, I need to compare the value of a CLOB field.
Something like:</p>
<pre><code>IF OLD_ROW.CLOB_FIELD != UPDATED_ROW.CLOB_FIELD
</code></pre>
<p>but "!=" does not work for comparing CLOBs.</p>
<p>What is the way to compare it?</p>
<p><strong>Edited to add:</strong></p>
<p>My trigger needs to do s... | [
{
"answer_id": 110797,
"author": "Mat Mannion",
"author_id": 6282,
"author_profile": "https://Stackoverflow.com/users/6282",
"pm_score": 1,
"selected": false,
"text": "<p>I believe it's not possible to use these kind of operators on CLOB fields, because of the way they're stored.</p>\n"
... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11710/"
] | in a DB2 trigger, I need to compare the value of a CLOB field.
Something like:
```
IF OLD_ROW.CLOB_FIELD != UPDATED_ROW.CLOB_FIELD
```
but "!=" does not work for comparing CLOBs.
What is the way to compare it?
**Edited to add:**
My trigger needs to do some action if the Clob field was changed during an update. T... | Calculate the md5 (or other) hash of the clobs and then compare these. Initial calculation will be slow but comparison is fast and easy. This could be a good method if the bulk of your data doesn't change very often.
One way to calculate md5 is through a java statement in your trigger. Save these in the same table (if... |
110,749 | <p>How would you write a regular expression to convert mark down into HTML? For example, you would type in the following:</p>
<pre><code>This would be *italicized* text and this would be **bold** text
</code></pre>
<p>This would then need to be converted to:</p>
<pre><code>This would be <em>italicized</em&... | [
{
"answer_id": 110754,
"author": "jop",
"author_id": 11830,
"author_profile": "https://Stackoverflow.com/users/11830",
"pm_score": 3,
"selected": false,
"text": "<p>A single regex won't do. Every text markup will have it's own html translator. Better look into how the existing converters... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] | How would you write a regular expression to convert mark down into HTML? For example, you would type in the following:
```
This would be *italicized* text and this would be **bold** text
```
This would then need to be converted to:
```
This would be <em>italicized</em> text and this would be <strong>bold</strong> t... | The best way is to find a version of the Markdown library ported to whatever language you are using (you did not specify in your question).
---
Now that you have clarified that you only want STRONG and EM to be processed, and that you are using C#, I recommend you take a look at [Markdown.NET](http://www.aspnetresou... |
110,763 | <p>I've built a wrapper over NumbericUpDown control.
The wrapper is generic and can support int? and double?</p>
<p>I would like to write a method that will do the following.</p>
<pre><code>public partial class NullableNumericUpDown<T> : UserControl where T : struct
{
private NumbericUpDown numericUpDown;
... | [
{
"answer_id": 110772,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 3,
"selected": false,
"text": "<p>It's not clear how you gonna use it.\nIf you want double create GetDouble() method, for integers - GetInteger()</p>\n\n<p>EDI... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11659/"
] | I've built a wrapper over NumbericUpDown control.
The wrapper is generic and can support int? and double?
I would like to write a method that will do the following.
```
public partial class NullableNumericUpDown<T> : UserControl where T : struct
{
private NumbericUpDown numericUpDown;
private T? Getvalue()
{
... | It's not clear how you gonna use it.
If you want double create GetDouble() method, for integers - GetInteger()
EDIT:
Ok, now I think I understand your use case
Try this:
```
using System;
using System.ComponentModel;
static Nullable<T> ConvertFromString<T>(string value) where T:struct
{
TypeConverter converter... |
110,801 | <p>I've tried cpan and cpanp shell and I keep getting:</p>
<pre><code>ExtUtils::PkgConfig requires the pkg-config utility, but it doesn't
seem to be in your PATH. Is it correctly installed?
</code></pre>
<p>What is the pkg-config utility and how do I install it? </p>
<p>Updates: </p>
<ul>
<li>OS: Windows</li>
<li... | [
{
"answer_id": 110840,
"author": "Thilo",
"author_id": 14955,
"author_profile": "https://Stackoverflow.com/users/14955",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://pkgconfig.freedesktop.org/wiki/\" rel=\"nofollow noreferrer\">http://pkgconfig.freedesktop.org/wiki/</a>... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9411/"
] | I've tried cpan and cpanp shell and I keep getting:
```
ExtUtils::PkgConfig requires the pkg-config utility, but it doesn't
seem to be in your PATH. Is it correctly installed?
```
What is the pkg-config utility and how do I install it?
Updates:
* OS: Windows
* This module is a prerequisite for the File::Extract... | look here:
<http://gtk2-perl.sourceforge.net/win32/howto_build_gtk2perl_win32.html>
I found this page by googling for ExtUtils::PkgConfig and "PPM" (Actvestates Perl Package Manager). |
110,867 | <p>I have a public property set in my form of type <code>ListE<T></code> where:</p>
<pre><code>public class ListE<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable
</code></pre>
<p>Yeah, it's a mouthful, but that's what the Designer requires for it to show up... | [
{
"answer_id": 111065,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 0,
"selected": false,
"text": "<p>One place to start would be that it may be doing math with your ListE`1::Count property. If that has some subtle flaw (i... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] | I have a public property set in my form of type `ListE<T>` where:
```
public class ListE<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable
```
Yeah, it's a mouthful, but that's what the Designer requires for it to show up as an editable collection in the Properties window. Which it does!... | I can't understand what's motivating you to attempt to reinvent the List<T> wheel in that way, but to answer your question: I would add a line "System.Diagnostics.Debugger.Break()" to the constructor of your class.
Then try to use it in the designer, and you'll get a popup asking you if you want to attach a debugger. ... |
110,887 | <p>Is there a way to read a module's configuration ini file? </p>
<p>For example I installed php-eaccelerator (<a href="http://eaccelerator.net" rel="nofollow noreferrer">http://eaccelerator.net</a>) and it put a <code>eaccelerator.ini</code> file in <code>/etc/php.d</code>. My PHP installation wont read this <code>.i... | [
{
"answer_id": 110899,
"author": "Alister Bulman",
"author_id": 6216,
"author_profile": "https://Stackoverflow.com/users/6216",
"pm_score": 1,
"selected": false,
"text": "<p>The standard way in this instance is to copy the relevant .ini lines to the bottom of the php.ini file. There is ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3983/"
] | Is there a way to read a module's configuration ini file?
For example I installed php-eaccelerator (<http://eaccelerator.net>) and it put a `eaccelerator.ini` file in `/etc/php.d`. My PHP installation wont read this `.ini` file because the `--with-config-file-scan-dir` option wasn't used when compiling PHP. Is there ... | This is just a wild guess, but try to add all the directives from eaccelerator.ini to php.ini. First create a `<?php phpinfo(); ?>` and check where it's located.
For example, try this:
```
[eAccelerator]
extension="eaccelerator.so"
eaccelerator.shm_size="32"
eaccelerator.cache_dir="/tmp"
eaccelerator.enable="1"
eacce... |
110,894 | <p>I've got C# code that accesses MySQL through ODBC.</p>
<p>It creates a transaction, does a few thousand insert commands, and then commits.
Now my question is how many "round trips", so to speak, happen against the DB server? I mean, does it simply transmit every insert command to the DB server, or does it cache/buf... | [
{
"answer_id": 110915,
"author": "Sam Saffron",
"author_id": 17174,
"author_profile": "https://Stackoverflow.com/users/17174",
"pm_score": 0,
"selected": false,
"text": "<p>It's hard to say without seeing your code, but I'm assuming you are executing the statements one at a time. So, you... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11208/"
] | I've got C# code that accesses MySQL through ODBC.
It creates a transaction, does a few thousand insert commands, and then commits.
Now my question is how many "round trips", so to speak, happen against the DB server? I mean, does it simply transmit every insert command to the DB server, or does it cache/buffer them a... | MySQL has an extended SQL style that can be used, where mass inserts are put in several at a time:
```
INSERT INTO `table` (`id`, `event`) VALUES (1, 94263), (2, 75015), (3, 75015);
```
I will usually collect a few hundred insert-parts into a string before running the SQL query itself. This will reduce the overhead... |
110,923 | <p>How do I end a Tkinter program? Let's say I have this code:</p>
<pre><code>from Tkinter import *
def quit():
# code to exit
root = Tk()
Button(root, text="Quit", command=quit).pack()
root.mainloop()
</code></pre>
<p>How should I define the <code>quit</code> function to exit my application?</p>
| [
{
"answer_id": 110929,
"author": "Matt Gregory",
"author_id": 10577,
"author_profile": "https://Stackoverflow.com/users/10577",
"pm_score": 6,
"selected": false,
"text": "<pre><code>def quit()\n root.quit()\n</code></pre>\n\n<p>or</p>\n\n<pre><code>def quit()\n root.destroy()\n</co... | 2008/09/21 | [
"https://Stackoverflow.com/questions/110923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10577/"
] | How do I end a Tkinter program? Let's say I have this code:
```
from Tkinter import *
def quit():
# code to exit
root = Tk()
Button(root, text="Quit", command=quit).pack()
root.mainloop()
```
How should I define the `quit` function to exit my application? | **You should use `destroy()` to close a Tkinter window.**
```py
from Tkinter import *
#use tkinter instead of Tkinter (small, not capital T) if it doesn't work
#as it was changed to tkinter in newer Python versions
root = Tk()
Button(root, text="Quit", command=root.destroy).pack() #button to close the window
root.ma... |
111,026 | <p>Which is the best way to store a 2D array in c# in order to optimize performance when performing lots of arithmetic on the elements in the array?</p>
<p>We have large (approx 1.5G) arrays, which for example we want to multiply with each other element by element. Performance is critical. The context in which this is... | [
{
"answer_id": 111046,
"author": "Cameron MacFarland",
"author_id": 3820,
"author_profile": "https://Stackoverflow.com/users/3820",
"pm_score": 3,
"selected": false,
"text": "<p>For best array performance, make sure you're using a single dimension array with lower index of 0.</p>\n\n<p>T... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4044/"
] | Which is the best way to store a 2D array in c# in order to optimize performance when performing lots of arithmetic on the elements in the array?
We have large (approx 1.5G) arrays, which for example we want to multiply with each other element by element. Performance is critical. The context in which this is done is i... | For best array performance, make sure you're using a single dimension array with lower index of 0.
To access the elements of the array as fast as possible, you can use unsafe pointers like so:
```
int[] array = Enumerable.Range(0, 1000).ToArray();
int count = 0;
unsafe {
fixed (int* pArray = array) {
for... |
111,097 | <p><strong>EDIT:</strong> This was formerly more explicitly titled: - "<strong>Best solution to stop Kontiki's KHOST.EXE from loading automatically at start-up on Windows XP?</strong>"</p>
<p>Essentially, whenever the <strong><a href="http://www.channel4.com/4od/index.html" rel="nofollow noreferrer">40D</a></strong> a... | [
{
"answer_id": 111134,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 1,
"selected": false,
"text": "<p>Why not just copy the executable to some other name, and put a do-nothing exe in its place. Then change your shortcut... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17759/"
] | **EDIT:** This was formerly more explicitly titled: - "**Best solution to stop Kontiki's KHOST.EXE from loading automatically at start-up on Windows XP?**"
Essentially, whenever the **[40D](http://www.channel4.com/4od/index.html)** application is run it sets up **khost.exe** to automatically start-up with Windows. Thi... | for the vb script you would use something like this:
```
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
'repeat the line below for each key to delete
WSHShell.RegDelete "[Location of Key]"
```
Just drop the code into a text file and re-name it something like shutdown,vbs.
As for when to run it, ... |
111,102 | <p>How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves?</p>
<p>I have seen <a href="http://en.wikipedia.org/wiki/Scheme_%28programming_language%29" rel="noreferrer">the Scheme ... | [
{
"answer_id": 111111,
"author": "Joel Anair",
"author_id": 7441,
"author_profile": "https://Stackoverflow.com/users/7441",
"pm_score": 14,
"selected": true,
"text": "<p>A closure is a pairing of:</p>\n<ol>\n<li>A function and</li>\n<li>A reference to that function's outer scope (lexical... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9951/"
] | How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves?
I have seen [the Scheme example](http://en.wikipedia.org/wiki/Scheme_%28programming_language%29) given on Wikipedia, but un... | A closure is a pairing of:
1. A function and
2. A reference to that function's outer scope (lexical environment)
A lexical environment is part of every execution context (stack frame) and is a map between identifiers (i.e. local variable names) and values.
Every function in JavaScript maintains a reference to its ou... |
111,129 | <p>I have a table which is referenced by foreign keys on many other tables. In my program if I want to delete one of these rows I need to first search for dependencies and present them to the user - "This object depends on x from table y, z from table q, etc". I also expect the number of tables which have foreign keys ... | [
{
"answer_id": 111146,
"author": "dvorak",
"author_id": 19235,
"author_profile": "https://Stackoverflow.com/users/19235",
"pm_score": 2,
"selected": false,
"text": "<p>I think this is exactly the sort of thing that INFORMATION_SCHEMA is intended for.</p>\n"
},
{
"answer_id": 1111... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15004/"
] | I have a table which is referenced by foreign keys on many other tables. In my program if I want to delete one of these rows I need to first search for dependencies and present them to the user - "This object depends on x from table y, z from table q, etc". I also expect the number of tables which have foreign keys to ... | Dvorak is right, INFORMATION\_SCHEMA is intended for that.
Concerning your performance concerns, there are several ways you can improve the performance
* Easy way, but not much improvement will come from it:
Store the info in a static variable. At least the query will occur only once per page
* Use persistent caching... |
111,135 | <p>I write my app in VS 2008 and so use all the fanciful stuffs such as LINQ, object initializers etc. Now can my app run on machines that have only .Net 2.0 runtime, but no .Net 3.5 runtime? .Net 3.5 runtime is a huge download, as all of you might know.</p>
| [
{
"answer_id": 111143,
"author": "Ian P",
"author_id": 10853,
"author_profile": "https://Stackoverflow.com/users/10853",
"pm_score": -1,
"selected": false,
"text": "<p>No, they can not.</p>\n"
},
{
"answer_id": 111145,
"author": "aku",
"author_id": 1196,
"author_profi... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | I write my app in VS 2008 and so use all the fanciful stuffs such as LINQ, object initializers etc. Now can my app run on machines that have only .Net 2.0 runtime, but no .Net 3.5 runtime? .Net 3.5 runtime is a huge download, as all of you might know. | What you can use is for example the *var* keyword, auto-getters and auto-setters, object initializers. I.e. syntactic sugar that is compiled to 2.0 code.
What you can't use is functionality that resides in .Net framework 3.0 and 3.5 library. For example LINQ.
You can try for yourself what you can and can't use by set... |
111,155 | <p>How do I handle the window close event (user clicking the 'X' button) in a Python Tkinter program?</p>
| [
{
"answer_id": 111160,
"author": "Matt Gregory",
"author_id": 10577,
"author_profile": "https://Stackoverflow.com/users/10577",
"pm_score": 8,
"selected": false,
"text": "<p>Tkinter supports a mechanism called <a href=\"http://web.archive.org/web/20201111215134/http://effbot.org/tkinterb... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10577/"
] | How do I handle the window close event (user clicking the 'X' button) in a Python Tkinter program? | Tkinter supports a mechanism called [*protocol handlers*](http://web.archive.org/web/20201111215134/http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm#protocols). Here, the term *protocol* refers to the interaction between the application and the window manager. The most commonly used protocol is called `WM_... |
111,194 | <p>I have a web app which connects to a server using a TCP connection and reads a binary document which it then writes to its response object. In other words it's transferring a file from a backend server using a custom protocol and returning that file to its client through HTTP.</p>
<p>The server sends a status code ... | [
{
"answer_id": 111212,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "<p>Here's what I do. Usually the content length is desired to know when to end the data storing loop. If your protoc... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] | I have a web app which connects to a server using a TCP connection and reads a binary document which it then writes to its response object. In other words it's transferring a file from a backend server using a custom protocol and returning that file to its client through HTTP.
The server sends a status code and a mime... | I would use the `OutputStream` directly with a general-purpose function. With the `Stream`, you can control `Flush`.
```
public void WriteDocument(HttpResponse response) {
StreamCopy(response.OutputStream, stream_);
response.End();
}
public static void StreamCopy(Stream dest, Stream src) {... |
111,234 | <p>Now that it's clear <a href="https://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python">what a metaclass is</a>, there is an associated concept that I use all the time without knowing what it really means. </p>
<p>I suppose everybody made once a mistake with parenthesis, resulting in an "object is n... | [
{
"answer_id": 111251,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 4,
"selected": false,
"text": "<p>A Callable is an object that has the <code>__call__</code> method. This means you can fake callable ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9951/"
] | Now that it's clear [what a metaclass is](https://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python), there is an associated concept that I use all the time without knowing what it really means.
I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception... | A callable is anything that can be called.
The [built-in *callable* (PyCallable\_Check in objects.c)](http://svn.python.org/projects/python/trunk/Objects/object.c) checks if the argument is either:
* an instance of a class with a `__call__` method or
* is of a type that has a non null *tp\_call* (c struct) member wh... |
111,281 | <ul>
<li>VMware server 1.0.7 installed with vmware-package</li>
<li>Debian GNU/Linux testing (lenny)</li>
<li>Kernel 2.6.26-1-686</li>
</ul>
<p>There were several compile problems when trying to build the binary kernel modules from the vmware-server-kernel-source package made by vmware-package from the VMware server t... | [
{
"answer_id": 111309,
"author": "bk1e",
"author_id": 8090,
"author_profile": "https://Stackoverflow.com/users/8090",
"pm_score": 0,
"selected": false,
"text": "<p>Did you try searching the <a href=\"http://www.vmware.com/support/\" rel=\"nofollow noreferrer\">VMware support website</a>?... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10682/"
] | * VMware server 1.0.7 installed with vmware-package
* Debian GNU/Linux testing (lenny)
* Kernel 2.6.26-1-686
There were several compile problems when trying to build the binary kernel modules from the vmware-server-kernel-source package made by vmware-package from the VMware server tarball. Recently VMware has updated... | I wrote a support request to VMware, and they assured me that my patch will reach the VMware server team. |
111,282 | <p>I'm modifying some code in which the original author built a web page by using an array thusly:</p>
<pre><code> $output[]=$stuff_from_database;
$output[]='more stuff';
// etc
echo join('',$output);
</code></pre>
<p>Can anyone think of a reason why this would be preferable (or vice versa) to:</p>
<pre><code> $o... | [
{
"answer_id": 111289,
"author": "dvorak",
"author_id": 19235,
"author_profile": "https://Stackoverflow.com/users/19235",
"pm_score": 0,
"selected": false,
"text": "<p>The bottom will reallocate the $output string repeatedly, whereas I believe the top will just store each piece in an arr... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm modifying some code in which the original author built a web page by using an array thusly:
```
$output[]=$stuff_from_database;
$output[]='more stuff';
// etc
echo join('',$output);
```
Can anyone think of a reason why this would be preferable (or vice versa) to:
```
$output =$stuff_from_database;
$output... | It was probably written by someone who comes from a language where strings are immutable and thus concatenation is expensive. PHP is not one of them as the following tests show. So the second approach is performance wise, better. The only other reason that I can think of to use the first approach is to be able to repla... |
111,287 | <p>Is it possible to put the results from more than one query on more than one table into a TClientDataset?</p>
<p>Just something like</p>
<pre><code>SELECT * from t1;
SELECT * from t2;
SELECT * from t3;
</code></pre>
<p>I can't seem to figure out a way to get a data provider (SetProvider) to pull in results from mo... | [
{
"answer_id": 111305,
"author": "Chris Woodruff",
"author_id": 7001,
"author_profile": "https://Stackoverflow.com/users/7001",
"pm_score": 1,
"selected": true,
"text": "<p>There is not a way to have multiple table data in the same TClientDataSet like you referenced. The TClientDataSet h... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19658/"
] | Is it possible to put the results from more than one query on more than one table into a TClientDataset?
Just something like
```
SELECT * from t1;
SELECT * from t2;
SELECT * from t3;
```
I can't seem to figure out a way to get a data provider (SetProvider) to pull in results from more than one table at a time. | There is not a way to have multiple table data in the same TClientDataSet like you referenced. The TClientDataSet holds a single cursor for a single dataset. |
111,341 | <p>I've got two tables:</p>
<pre><code>TableA
------
ID,
Name
TableB
------
ID,
SomeColumn,
TableA_ID (FK for TableA)
</code></pre>
<p>The relationship is one row of <code>TableA</code> - many of <code>TableB</code>.</p>
<p>Now, I want to see a result like this:</p>
<pre><code>ID Name SomeColumn
1. A... | [
{
"answer_id": 111347,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 4,
"selected": false,
"text": "<p>I think you are on the right track with COALESCE. See here for an example of building a comma-delimited string:</p... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6939/"
] | I've got two tables:
```
TableA
------
ID,
Name
TableB
------
ID,
SomeColumn,
TableA_ID (FK for TableA)
```
The relationship is one row of `TableA` - many of `TableB`.
Now, I want to see a result like this:
```
ID Name SomeColumn
1. ABC X, Y, Z (these are three different rows)
2. MNO ... | ### 1. Create the UDF:
```
CREATE FUNCTION CombineValues
(
@FK_ID INT -- The foreign key from TableA which is used
-- to fetch corresponding records
)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @SomeColumnList VARCHAR(8000);
SELECT @SomeColumnList =
COALESCE(@SomeColumnList + ', ', '') + CAST(Some... |
111,345 | <p>Is there a cheap way to get the dimensions of an image (jpg, png, ...)? Preferably, I would like to achieve this using only the standard class library (because of hosting restrictions). I know that it should be relatively easy to read the image header and parse it myself, but it seems that something like this should... | [
{
"answer_id": 111349,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 4,
"selected": false,
"text": "<p>Have you tried using the WPF Imaging classes? <code>System.Windows.Media.Imaging.BitmapDecoder</code>, etc.?</p>\n\n<... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15716/"
] | Is there a cheap way to get the dimensions of an image (jpg, png, ...)? Preferably, I would like to achieve this using only the standard class library (because of hosting restrictions). I know that it should be relatively easy to read the image header and parse it myself, but it seems that something like this should be... | Your best bet as always is to find a well tested library. However, you said that is difficult, so here is some dodgy largely untested code that should work for a fair number of cases:
```
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
namespace ImageDimension... |
111,405 | <p>I have some problems with Miktex installed on Windows Vista Business SP1/32 bit. I use miktex 2.7, ghostscript, and texniccenter 1 beta 7.50. When I compile a document with the following profiles: Latex=>DVI, Latex=>PDF everything works fine; the system crashes when I compile with profiles Latex=>PS and Latex=>PS=>P... | [
{
"answer_id": 111506,
"author": "finrod",
"author_id": 8295,
"author_profile": "https://Stackoverflow.com/users/8295",
"pm_score": 2,
"selected": true,
"text": "<p>If everything you need is images, you could still compile directly to PDF. You only need to have an image in PNG or JPG for... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11464/"
] | I have some problems with Miktex installed on Windows Vista Business SP1/32 bit. I use miktex 2.7, ghostscript, and texniccenter 1 beta 7.50. When I compile a document with the following profiles: Latex=>DVI, Latex=>PDF everything works fine; the system crashes when I compile with profiles Latex=>PS and Latex=>PS=>PDF.... | If everything you need is images, you could still compile directly to PDF. You only need to have an image in PNG or JPG format, and use the following code:
```
%in the document preamble
\usepackage{graphicx}
%in the document, in the place where you want to put your image
\includegraphics{image_filename_without_extens... |
111,407 | <p>I have a simple unordered list that I want to show and hide on click using the jQuery slideUp and slideDown effect. Everything seems to work fine, however in IE6 the list will slide up, flicker for a split second, and then disappear.</p>
<p>Does anyone know of a fix for this?</p>
<p>Thanks!</p>
| [
{
"answer_id": 111409,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 3,
"selected": false,
"text": "<pre><code>$(document).ready(function() {\n // Fix background image caching problem\n if (jQuery.browser.msie) {\n ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1396/"
] | I have a simple unordered list that I want to show and hide on click using the jQuery slideUp and slideDown effect. Everything seems to work fine, however in IE6 the list will slide up, flicker for a split second, and then disappear.
Does anyone know of a fix for this?
Thanks! | Apologies for the extra comment (I can't upvote or comment on Pavel's answer), but adding a DOCTYPE fixed this issue for me, and the slideUp/Down/Toggle effects now work correctly in IE7.
See [A List Apart](http://www.alistapart.com/articles/doctype/) for more information on DOCTYPES, or you can try specifying the fai... |
111,426 | <p>I'm taking a course in computational complexity and have so far had an impression that it won't be of much help to a developer. </p>
<p>I might be wrong but if you have gone down this path before, could you please provide an example of how the complexity theory helped you in your work? Tons of thanks.</p>
| [
{
"answer_id": 111444,
"author": "David Ameller",
"author_id": 19689,
"author_profile": "https://Stackoverflow.com/users/19689",
"pm_score": 0,
"selected": false,
"text": "<p>A good example could be when your boss tells you to do some program and you can demonstrate by using the computat... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8203/"
] | I'm taking a course in computational complexity and have so far had an impression that it won't be of much help to a developer.
I might be wrong but if you have gone down this path before, could you please provide an example of how the complexity theory helped you in your work? Tons of thanks. | O(1): Plain code without loops. Just flows through. Lookups in a lookup table are O(1), too.
O(log(n)): efficiently optimized algorithms. Example: binary tree algorithms and binary search. Usually doesn't hurt. You're lucky if you have such an algorithm at hand.
O(n): a single loop over data. Hurts for very large n.
... |
111,436 | <p>I want to have my PHP application labeled with the revision number which it uses, but I don't want to use <a href="http://en.wikipedia.org/wiki/CruiseControl" rel="nofollow noreferrer">CruiseControl</a> or update a file and upload it every time. How should I do it?</p>
| [
{
"answer_id": 111459,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 4,
"selected": false,
"text": "<p>Assuming your webroot is a checked-out copy of the subversion tree, you could parse the /.svn/entries file and hook out the... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19929/"
] | I want to have my PHP application labeled with the revision number which it uses, but I don't want to use [CruiseControl](http://en.wikipedia.org/wiki/CruiseControl) or update a file and upload it every time. How should I do it? | SVN keywords is not a good solution. As others pointed out adding $Revision$ in a file only affects **the specific file**, which may not change for a long time.
Remembering to "edit" a file (by adding or removing a blank line) before every commit is pointless. You could as well just type the revision by hand.
One goo... |
111,460 | <p>I'm working on serial port, transmitting and receiving data to some hardware at 8bit data. I would like to store it as string to facilitate comparison, and preset data are stored as string or hex format in xml file. I found out that only when using Encoding.Default which is ANSI encoding then the 8bit data is conver... | [
{
"answer_id": 111468,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 3,
"selected": false,
"text": "<p>Why not just use an array of bytes instead? It would have none of the encoding problems you're likely to suffer wi... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20007/"
] | I'm working on serial port, transmitting and receiving data to some hardware at 8bit data. I would like to store it as string to facilitate comparison, and preset data are stored as string or hex format in xml file. I found out that only when using Encoding.Default which is ANSI encoding then the 8bit data is converted... | Latin-1 aka ISO-8859-1 aka codepage 28591 is a useful codepage for this scenario, as it maps values in the range 128-255 unchanged. The following are interchangeable:
```
Encoding.GetEncoding(28591)
Encoding.GetEncoding("Latin1")
Encoding.GetEncoding("iso-8859-1")
```
The following code illustrates the fact that for... |
111,461 | <p>I see a lot of example code for C# classes that does this:</p>
<pre><code>public class Point {
public int x { get; set; }
public int y { get; set; }
}
</code></pre>
<p>Or, in older code, the same with an explicit private backing value and without the new auto-implemented properties:</p>
<pre><code>public ... | [
{
"answer_id": 111474,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 3,
"selected": false,
"text": "<p>It encapsulates setting and accessing of those members. If some time from now a developer for the code needs to chang... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19688/"
] | I see a lot of example code for C# classes that does this:
```
public class Point {
public int x { get; set; }
public int y { get; set; }
}
```
Or, in older code, the same with an explicit private backing value and without the new auto-implemented properties:
```
public class Point {
private int _x;
... | I tend to agree (that it seems needlessly verbose), although this has been an issue our team hasn't yet resolved and so our coding standards still insist on verbose properties for all classes.
[Jeff Atwood](https://blog.codinghorror.com/properties-vs-public-variables/) dealt with this a few years ago. The most importa... |
111,478 | <p>Why is it wrong to use <code>std::auto_ptr<></code> with standard containers?</p>
| [
{
"answer_id": 111492,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 6,
"selected": false,
"text": "<p>The <strong>copy semantics</strong> of <code>auto_ptr</code> are not compatible with the containers.</p>\n\n<p>Specif... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19129/"
] | Why is it wrong to use `std::auto_ptr<>` with standard containers? | The C++ Standard says that an STL element must be "copy-constructible" and "assignable." In other words, an element must be able to be assigned or copied and the two elements are logically independent. `std::auto_ptr` does not fulfill this requirement.
Take for example this code:
```
class X
{
};
std::vector<std::au... |
111,504 | <p>I'm trying to create a UDF in <code>SQL Server 2005 Express</code> as below:</p>
<pre><code>CREATE FUNCTION [CombineValues] ()
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @CuisineList VARCHAR(8000);
RETURN
(
SELECT @CuisineList = COALESCE(@CuisineList + ', ', '') +
CAST(Cuisine AS varchar(20))
FR... | [
{
"answer_id": 111509,
"author": "Per Hornshøj-Schierbeck",
"author_id": 11619,
"author_profile": "https://Stackoverflow.com/users/11619",
"pm_score": 0,
"selected": false,
"text": "<p>try changing SELECT to SET and then end your function by SELECT (ing) your @CuisineList</p>\n"
},
{... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6939/"
] | I'm trying to create a UDF in `SQL Server 2005 Express` as below:
```
CREATE FUNCTION [CombineValues] ()
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @CuisineList VARCHAR(8000);
RETURN
(
SELECT @CuisineList = COALESCE(@CuisineList + ', ', '') +
CAST(Cuisine AS varchar(20))
FROM Cuisines
)
END
``... | This answer is from the original poster, Wild Thing. Please do not vote it up or down.
```
CREATE FUNCTION [CombineValues] ()
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @CuisineList VARCHAR(8000);
SELECT @CuisineList = COALESCE(@CuisineList + ', ', '') + CAST(Cuisine AS varchar(20)) FROM Cuisines;
RETURN
(
SELECT @Cui... |
111,529 | <p>Is there any way to create the <em>query parameters</em> for doing a <em>GET request</em> in JavaScript?</p>
<p>Just like in Python you have <a href="http://web.archive.org/web/20080926234926/http://docs.python.org:80/lib/module-urllib.html" rel="noreferrer"><code>urllib.urlencode()</code></a>, which takes in a dic... | [
{
"answer_id": 111533,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 3,
"selected": false,
"text": "<p>If you are using <a href=\"http://www.prototypejs.org\" rel=\"noreferrer\">Prototype</a> there is <a href=\"ht... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448/"
] | Is there any way to create the *query parameters* for doing a *GET request* in JavaScript?
Just like in Python you have [`urllib.urlencode()`](http://web.archive.org/web/20080926234926/http://docs.python.org:80/lib/module-urllib.html), which takes in a dictionary (or list of two tuples) and creates a string like `'var... | Here you go:
```
function encodeQueryData(data) {
const ret = [];
for (let d in data)
ret.push(encodeURIComponent(d) + '=' + encodeURIComponent(data[d]));
return ret.join('&');
}
```
Usage:
```
const data = { 'first name': 'George', 'last name': 'Jetson', 'age': 110 };
const querystring = encodeQueryD... |
111,587 | <p>How do I name a result group in a Regex? (.Net)</p>
| [
{
"answer_id": 111594,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 2,
"selected": false,
"text": "<pre><code>(?<NameOfGroup>[a-z]*)\n</code></pre>\n\n<p>Use the ? syntax like in the sample above.</p>\n"
},
{
"a... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14484/"
] | How do I name a result group in a Regex? (.Net) | ```
(?<NAME>EXPRESSION) or (?'NAME'EXPRESSION)
``` |
111,630 | <p>Some of the controls I've created seem to default to the old Windows 95 theme, how do I prevent this? Here's an example of a button that does not retain the Operating System's native appearance (I'm using Vista as my development environment):</p>
<pre><code>HWND button = CreateWindowEx(NULL, L"BUTTON", L"OK", WS_VI... | [
{
"answer_id": 111661,
"author": "Milan Babuškov",
"author_id": 14690,
"author_profile": "https://Stackoverflow.com/users/14690",
"pm_score": 3,
"selected": true,
"text": "<p>I believe it has got nothing to do with your code, but you need to set up a proper <strong>manifest</strong> file... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1467/"
] | Some of the controls I've created seem to default to the old Windows 95 theme, how do I prevent this? Here's an example of a button that does not retain the Operating System's native appearance (I'm using Vista as my development environment):
```
HWND button = CreateWindowEx(NULL, L"BUTTON", L"OK", WS_VISIBLE | WS_CHI... | I believe it has got nothing to do with your code, but you need to set up a proper **manifest** file to get the themed controls.
Some info here: [@msdn.com](http://msdn.microsoft.com/en-us/library/aa374191(VS.85).aspx) and here: [@blogs.msdn.com](http://blogs.msdn.com/cheller/archive/2006/08/24/718757.aspx)
You can s... |
111,687 | <p>Is it absolutely critical that I always close Syslog when I'm done using it? Is there a huge negative impact from not doing so?</p>
<p>If it turns out that I definitely need to, what's a good way to do it? I'm opening Syslog in my class constructor and I don't see a way to do class destructors in Ruby, and currentl... | [
{
"answer_id": 111724,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 3,
"selected": true,
"text": "<p>The open method accepts a block. Do something like this:</p>\n\n<pre><code>class Foo\n def do_something\n Sy... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] | Is it absolutely critical that I always close Syslog when I'm done using it? Is there a huge negative impact from not doing so?
If it turns out that I definitely need to, what's a good way to do it? I'm opening Syslog in my class constructor and I don't see a way to do class destructors in Ruby, and currently have som... | The open method accepts a block. Do something like this:
```
class Foo
def do_something
Syslog.open do
# work with the syslog here
end
end
end
``` |
111,700 | <p>It's the weekend, so I relax from spending all week programming by writing a hobby project.</p>
<p>I wrote the framework of a MOS 6502 CPU emulator yesterday, the registers, stack, memory and all the opcodes are implemented. (Link to source below)</p>
<p>I can manually run a series of operations in the debugger I ... | [
{
"answer_id": 111737,
"author": "Brendan Kidwell",
"author_id": 13958,
"author_profile": "https://Stackoverflow.com/users/13958",
"pm_score": 1,
"selected": false,
"text": "<p>This book might help: <a href=\"http://www.atariarchives.org/mlb/\" rel=\"nofollow noreferrer\">http://www.atar... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | It's the weekend, so I relax from spending all week programming by writing a hobby project.
I wrote the framework of a MOS 6502 CPU emulator yesterday, the registers, stack, memory and all the opcodes are implemented. (Link to source below)
I can manually run a series of operations in the debugger I wrote, but I'd li... | The opcode takes one byte, and the operands are in the following bytes. Check out the byte size column [here](http://www.atariarchives.org/2bml/chapter_10.php), for instance. |
111,769 | <p>I searched the net and handbook, but I only managed to learn what is the masked package, and not how to install it. I did find some commands, but they don't seem to work on 2008 (looking at it, it seems those are for earlier versions). I have something like this:</p>
<pre><code>localhost ~ # emerge flamerobin
Calcu... | [
{
"answer_id": 111779,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>Simply mkdir /etc/portage and edit as mentioned here: <a href=\"http://gentoo-wiki.com/TIP_Dealing_with_masked_packages#But_... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14690/"
] | I searched the net and handbook, but I only managed to learn what is the masked package, and not how to install it. I did find some commands, but they don't seem to work on 2008 (looking at it, it seems those are for earlier versions). I have something like this:
```
localhost ~ # emerge flamerobin
Calculating depende... | Simply mkdir /etc/portage and edit as mentioned here: <http://gentoo-wiki.com/TIP_Dealing_with_masked_packages#But_you_want_to_install_the_package_anyway>... |
111,792 | <p>For example:</p>
<pre><code>root.Nodes.Add(new TNode() { Foo1 = bar1, Foo2 = bar2, Foo3 = bar3 });
</code></pre>
<p>or:</p>
<pre><code>root.Nodes.Add(new TNode() { Foo1 = bar1,
Foo2 = bar2,
Foo3 = bar3 });
</code></pre>
| [
{
"answer_id": 111803,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 3,
"selected": true,
"text": "<p>I've done it both ways.. IMO it depends on the complexity of the initialization.</p>\n\n<p>If it is simple 2 or... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14484/"
] | For example:
```
root.Nodes.Add(new TNode() { Foo1 = bar1, Foo2 = bar2, Foo3 = bar3 });
```
or:
```
root.Nodes.Add(new TNode() { Foo1 = bar1,
Foo2 = bar2,
Foo3 = bar3 });
``` | I've done it both ways.. IMO it depends on the complexity of the initialization.
If it is simple 2 or 3 properties I will initialize on one line generally, but if i'm setting up an object with values for insertion into a database or something that has alot of properties i'll break it out like your second example.
```... |
111,866 | <p>In Cocoa, if I want to loop through an NSMutableArray and remove multiple objects that fit a certain criteria, what's the best way to do this without restarting the loop each time I remove an object?</p>
<p>Thanks,</p>
<p>Edit: Just to clarify - I was looking for the best way, e.g. something more elegant than manu... | [
{
"answer_id": 111890,
"author": "Nathan Kinsinger",
"author_id": 20045,
"author_profile": "https://Stackoverflow.com/users/20045",
"pm_score": 3,
"selected": false,
"text": "<p>Add the objects you want to remove to a second array and, after the loop, use -removeObjectsInArray:.</p>\n"
... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1043/"
] | In Cocoa, if I want to loop through an NSMutableArray and remove multiple objects that fit a certain criteria, what's the best way to do this without restarting the loop each time I remove an object?
Thanks,
Edit: Just to clarify - I was looking for the best way, e.g. something more elegant than manually updating the... | For clarity I like to make an initial loop where I collect the items to delete. Then I delete them. Here's a sample using Objective-C 2.0 syntax:
```
NSMutableArray *discardedItems = [NSMutableArray array];
for (SomeObjectClass *item in originalArrayOfItems) {
if ([item shouldBeDiscarded])
[discardedItems... |
111,928 | <p>I can print with <code>printf</code> as a hex or octal number. Is there a format tag to print as binary, or arbitrary base?</p>
<p>I am running gcc.</p>
<pre><code>printf("%d %x %o\n", 10, 10, 10); //prints "10 A 12\n"
print("%b\n", 10); // prints "%b\n"
</code></pre>
| [
{
"answer_id": 111938,
"author": "Florian Bösch",
"author_id": 19435,
"author_profile": "https://Stackoverflow.com/users/19435",
"pm_score": 3,
"selected": false,
"text": "<p>There is no formatting function in the C standard library to output binary like that. All the format operations t... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8959/"
] | I can print with `printf` as a hex or octal number. Is there a format tag to print as binary, or arbitrary base?
I am running gcc.
```
printf("%d %x %o\n", 10, 10, 10); //prints "10 A 12\n"
print("%b\n", 10); // prints "%b\n"
``` | Hacky but works for me:
```
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
#define BYTE_TO_BINARY(byte) \
(byte & 0x80 ? '1' : '0'), \
(byte & 0x40 ? '1' : '0'), \
(byte & 0x20 ? '1' : '0'), \
(byte & 0x10 ? '1' : '0'), \
(byte & 0x08 ? '1' : '0'), \
(byte & 0x04 ? '1' : '0'), \
(byte & 0x02 ? '1' : ... |
111,934 | <p>I want to create some text in a canvas:</p>
<pre><code>myText = self.canvas.create_text(5, 5, anchor=NW, text="TEST")
</code></pre>
<p>Now how do I find the width and height of <code>myText</code>?</p>
| [
{
"answer_id": 111974,
"author": "skymt",
"author_id": 18370,
"author_profile": "https://Stackoverflow.com/users/18370",
"pm_score": 5,
"selected": true,
"text": "<pre><code>bounds = self.canvas.bbox(myText) # returns a tuple like (x1, y1, x2, y2)\nwidth = bounds[2] - bounds[0]\nheight ... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10577/"
] | I want to create some text in a canvas:
```
myText = self.canvas.create_text(5, 5, anchor=NW, text="TEST")
```
Now how do I find the width and height of `myText`? | ```
bounds = self.canvas.bbox(myText) # returns a tuple like (x1, y1, x2, y2)
width = bounds[2] - bounds[0]
height = bounds[3] - bounds[1]
```
See the [TkInter reference](https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/canvas-methods.html). |
111,945 | <p>I need to upload some data to a server using HTTP <code>PUT</code> in python. From my brief reading of the urllib2 docs, it only does HTTP <code>POST</code>. Is there any way to do an HTTP <code>PUT</code> in python?</p>
| [
{
"answer_id": 111952,
"author": "William Keller",
"author_id": 17095,
"author_profile": "https://Stackoverflow.com/users/17095",
"pm_score": 2,
"selected": false,
"text": "<p>Have you taken a look at <a href=\"http://inamidst.com/proj/put/put.py\" rel=\"nofollow noreferrer\">put.py</a>?... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/161922/"
] | I need to upload some data to a server using HTTP `PUT` in python. From my brief reading of the urllib2 docs, it only does HTTP `POST`. Is there any way to do an HTTP `PUT` in python? | I've used a variety of python HTTP libs in the past, and I've settled on [requests](https://requests.readthedocs.io/) as my favourite. Existing libs had pretty useable interfaces, but code can end up being a few lines too long for simple operations. A basic PUT in requests looks like:
```
payload = {'username': 'bob',... |
111,954 | <p>You can use ftplib for full FTP support in Python. However the preferred way of getting a directory listing is:</p>
<pre><code># File: ftplib-example-1.py
import ftplib
ftp = ftplib.FTP("www.python.org")
ftp.login("anonymous", "ftplib-example-1")
data = []
ftp.dir(data.append)
ftp.quit()
for line in data:
... | [
{
"answer_id": 111966,
"author": "William Keller",
"author_id": 17095,
"author_profile": "https://Stackoverflow.com/users/17095",
"pm_score": 8,
"selected": true,
"text": "<p>Try using <a href=\"https://docs.python.org/3/library/ftplib.html#ftplib.FTP.nlst\" rel=\"noreferrer\"><code>ftp.... | 2008/09/21 | [
"https://Stackoverflow.com/questions/111954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/432/"
] | You can use ftplib for full FTP support in Python. However the preferred way of getting a directory listing is:
```
# File: ftplib-example-1.py
import ftplib
ftp = ftplib.FTP("www.python.org")
ftp.login("anonymous", "ftplib-example-1")
data = []
ftp.dir(data.append)
ftp.quit()
for line in data:
print "-", li... | Try using [`ftp.nlst(dir)`](https://docs.python.org/3/library/ftplib.html#ftplib.FTP.nlst).
However, note that if the folder is empty, it might throw an error:
```
files = []
try:
files = ftp.nlst()
except ftplib.error_perm as resp:
if str(resp) == "550 No files found":
print "No files in this direct... |
112,036 | <p>I'm using the AdvancedDataGrid widget and I want two columns to be radio buttons, where each column is it's own RadioButtonGroup. I thought I had all the necessary mxxml, but I'm running into a strange behavior issue. When I scroll up and down, the button change values! The selected button becomes deselected, and... | [
{
"answer_id": 112822,
"author": "Simon Buchan",
"author_id": 20135,
"author_profile": "https://Stackoverflow.com/users/20135",
"pm_score": 0,
"selected": false,
"text": "<p>Reproduced this. Likely to be a ADG bug, we've run into a few here. (Didn't find this one on bugs.adobe.com, but t... | 2008/09/21 | [
"https://Stackoverflow.com/questions/112036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7536/"
] | I'm using the AdvancedDataGrid widget and I want two columns to be radio buttons, where each column is it's own RadioButtonGroup. I thought I had all the necessary mxxml, but I'm running into a strange behavior issue. When I scroll up and down, the button change values! The selected button becomes deselected, and unsel... | What's happening here is that Flex only creates itemRenderer instances for the *visible* columns. When you scroll around, those instances get recycled. So if you scroll down, the RadioButton object that was drawing the first column of the first row may now have changed to instead be drawing the first column of the seve... |
112,055 | <p>I'm looking at a batch file which defines the following variables:</p>
<pre><code>set _SCRIPT_DRIVE=%~d0
set _SCRIPT_PATH=%~p0
</code></pre>
<ul>
<li>What do <code>%~d0</code> or <code>%~p0</code> actually mean?</li>
<li>Is there a set of well-known values for things like current directory, drive, parameters to a ... | [
{
"answer_id": 112071,
"author": "William Keller",
"author_id": 17095,
"author_profile": "https://Stackoverflow.com/users/17095",
"pm_score": 4,
"selected": false,
"text": "<p>From <em><a href=\"http://www.rgagnon.com/gp/gp-0008.html\" rel=\"noreferrer\" title=\"Filename parsing in batch... | 2008/09/21 | [
"https://Stackoverflow.com/questions/112055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/322/"
] | I'm looking at a batch file which defines the following variables:
```
set _SCRIPT_DRIVE=%~d0
set _SCRIPT_PATH=%~p0
```
* What do `%~d0` or `%~p0` actually mean?
* Is there a set of well-known values for things like current directory, drive, parameters to a script?
* Are there any other similar shortcuts I could use... | The magic variables `%`*n* contains the arguments used to invoke the file: `%0` is the path to the bat-file itself, `%1` is the first argument after, `%2` is the second and so on.
Since the arguments are often file paths, there is some additional syntax to extract parts of the path. `~d` is drive, `~p` is the path (wi... |
112,085 | <p>Instead of having to remember to initialize a simple 'C' structure, I might derive from it and zero it in the constructor like this:</p>
<pre><code>struct MY_STRUCT
{
int n1;
int n2;
};
class CMyStruct : public MY_STRUCT
{
public:
CMyStruct()
{
memset(this, 0, sizeof(MY_STRUCT));
}
};
<... | [
{
"answer_id": 112099,
"author": "Florian Bösch",
"author_id": 19435,
"author_profile": "https://Stackoverflow.com/users/19435",
"pm_score": 2,
"selected": false,
"text": "<p>Precise layout of a class or structure is not guaranteed in C++, which is why you should not make assumptions abo... | 2008/09/21 | [
"https://Stackoverflow.com/questions/112085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | Instead of having to remember to initialize a simple 'C' structure, I might derive from it and zero it in the constructor like this:
```
struct MY_STRUCT
{
int n1;
int n2;
};
class CMyStruct : public MY_STRUCT
{
public:
CMyStruct()
{
memset(this, 0, sizeof(MY_STRUCT));
}
};
```
This tric... | PREAMBLE:
---------
While my answer is still Ok, I find [litb's answer](https://stackoverflow.com/questions/112085/is-this-c-structure-initialization-trick-safe/1315024#1315024) quite superior to mine because:
1. It teaches me a trick that I did not know (litb's answers usually have this effect, but this is the first... |
112,093 | <p>I have a simple list I am using for a horizontal menu:</p>
<pre><code><ul>
<h1>Menu</h1>
<li>
<a href="/" class="selected">Home</a>
</li>
<li>
<a href="/Home">Forum</a>
</li>
</ul>
</code></pre>
<p>When I add a ... | [
{
"answer_id": 112106,
"author": "Justin Poliey",
"author_id": 6967,
"author_profile": "https://Stackoverflow.com/users/6967",
"pm_score": 5,
"selected": true,
"text": "<p>The a element is an inline element, meaning it only applies to the text it encloses. If you want the background colo... | 2008/09/21 | [
"https://Stackoverflow.com/questions/112093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] | I have a simple list I am using for a horizontal menu:
```
<ul>
<h1>Menu</h1>
<li>
<a href="/" class="selected">Home</a>
</li>
<li>
<a href="/Home">Forum</a>
</li>
</ul>
```
When I add a background color to the selected class, only the text gets the color, I want it to stretch the ent... | The a element is an inline element, meaning it only applies to the text it encloses. If you want the background color to stretch across horizontally, apply the selected class to a block level element. Applying the class to the li element should work fine.
Alternatively, you could add this to the selected class' CSS:
... |