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 |
|---|---|---|---|---|---|---|
327,576 | <p>How do you plot bar charts in gnuplot with text labels?</p>
| [
{
"answer_id": 327578,
"author": "tatwright",
"author_id": 40849,
"author_profile": "https://Stackoverflow.com/users/40849",
"pm_score": 5,
"selected": false,
"text": "<pre>\nplot \"data.dat\" using 2: xtic(1) with histogram\n</pre>\n\n<p>Here data.dat contains data of the form</p>\n\n<p... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40849/"
] | How do you plot bar charts in gnuplot with text labels? | Simple bar graph:

```
set boxwidth 0.5
set style fill solid
plot "data.dat" using 1:3:xtic(2) with boxes
```
data.dat:
```
0 label 100
1 label2 450
2 "bar label" 75
```
**If you want to style your bars differently, you can do something like:**
![multi... |
327,597 | <p>I'm giving my first steps on Python. I saw that we don't have switch case statement,
so I would you guys implement a text Menu in python?</p>
<p>Thanks</p>
| [
{
"answer_id": 327601,
"author": "Gonzalo Quero",
"author_id": 40996,
"author_profile": "https://Stackoverflow.com/users/40996",
"pm_score": 2,
"selected": false,
"text": "<p>You can use if...elif. If you have to choose a number, it would be like this:</p>\n\n<pre><code>n = chosenOption(... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41795/"
] | I'm giving my first steps on Python. I saw that we don't have switch case statement,
so I would you guys implement a text Menu in python?
Thanks | You might do something like this:
```
def action1():
pass # put a function here
def action2():
pass # blah blah
def action3():
pass # and so on
def no_such_action():
pass # print a message indicating there's no such action
def main():
actions = {"foo": action1, "bar": action2, "baz": action3}
... |
327,609 | <p>I have a working linker script. I want to add another data section whose contents is pulled directly from a file (ld shouldn't parse it and extract the sections and so on). How can I do that?</p>
<pre><code>OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
SECTIONS
{
.text 0x100000 : {
*(.multiboot)
*(.text)
*... | [
{
"answer_id": 328137,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 5,
"selected": false,
"text": "<p>You could try using <code>objcopy</code> to convert it to a normal object you can link in, and then reference its symbol... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/434760/"
] | I have a working linker script. I want to add another data section whose contents is pulled directly from a file (ld shouldn't parse it and extract the sections and so on). How can I do that?
```
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
SECTIONS
{
.text 0x100000 : {
*(.multiboot)
*(.text)
*(.code)
*(... | You could try using `objcopy` to convert it to a normal object you can link in, and then reference its symbols in the linker script like you would do to a normal object. From the [`objcopy` manual page](http://linux.die.net/man/1/objcopy):
>
> -B bfdarch
> --binary-architecture=bfdarch
> Useful when transforming a ... |
327,617 | <p>I'm trying to scrape a price from a web page using PHP and Regexes. The price will be in the format £123.12 or $123.12 (i.e., pounds or dollars).</p>
<p>I'm loading up the contents using libcurl. The output of which is then going into <code>preg_match_all</code>. So it looks a bit like this:</p>
<pre><code>$conten... | [
{
"answer_id": 327621,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 2,
"selected": true,
"text": "<p>Have you try to use \\ in front of £</p>\n\n<pre><code>preg_match_all('/(\\$|\\£)[0-9]+(\\.[0-9]{2})/', $cont... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to scrape a price from a web page using PHP and Regexes. The price will be in the format £123.12 or $123.12 (i.e., pounds or dollars).
I'm loading up the contents using libcurl. The output of which is then going into `preg_match_all`. So it looks a bit like this:
```
$contents = curl_exec($curl);
preg_mat... | Have you try to use \ in front of £
```
preg_match_all('/(\$|\£)[0-9]+(\.[0-9]{2})/', $contents, $matches);
```
I have try this expression with .Net with \£ and it works. I just edited it and removed some ":".
[](https://i.stack.imgur.com/DwYIJ.png)
(source: [clip2n... |
327,630 | <p>How do I calculate the time period between 2 dates in C (any library, etc.)? </p>
<p>The program should take two (local) dates as input and provide the duration period between them as output. </p>
<p>For example,</p>
<pre><code>startDate = OCT-09-1976 and endDate = OCT-09-2008
should show a duration of 32 years.... | [
{
"answer_id": 327637,
"author": "John Carter",
"author_id": 8331,
"author_profile": "https://Stackoverflow.com/users/8331",
"pm_score": 1,
"selected": false,
"text": "<p>I did something very similar recently using <a href=\"http://www.boost.org/doc/libs/1_37_0/doc/html/date_time/gregori... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17581/"
] | How do I calculate the time period between 2 dates in C (any library, etc.)?
The program should take two (local) dates as input and provide the duration period between them as output.
For example,
```
startDate = OCT-09-1976 and endDate = OCT-09-2008
should show a duration of 32 years.
startDate = OCT-09-1976 a... | Convert the dates into two struct tm structures with [strptime](http://www.manpagez.com/man/3/strptime/)
[Difftime](http://www.manpagez.com/man/3/difftime/) gives you the difference between the two in seconds.
Convert that into months etc with the code [here](http://www.daniweb.com/forums/post121350-7.html) (in C++, ... |
327,642 | <p>Is it possible to pump monochrome (graphical data with 1 bit image depth) texture into OpenGL?</p>
<p>I'm currently using this:</p>
<pre><code>glTexImage2D( GL_TEXTURE_2D, 0, 1, game->width, game->height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, game->culture[game->phase] );
</code></pre>
<p>I'm pumping it ... | [
{
"answer_id": 327648,
"author": "Nils Pipenbrinck",
"author_id": 15955,
"author_profile": "https://Stackoverflow.com/users/15955",
"pm_score": 4,
"selected": true,
"text": "<p>The smallest uncompressed texture-format for luminance images uses 8 bits per pixel.</p>\n\n<p>However, 1 bit p... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38256/"
] | Is it possible to pump monochrome (graphical data with 1 bit image depth) texture into OpenGL?
I'm currently using this:
```
glTexImage2D( GL_TEXTURE_2D, 0, 1, game->width, game->height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, game->culture[game->phase] );
```
I'm pumping it with square array of 8 bit unsigned integers ... | The smallest uncompressed texture-format for luminance images uses 8 bits per pixel.
However, 1 bit per pixel images can be compressed without loss to the S3TC or DXT format. This will still not be 1 bit per pixel but somewhere between 2 and 3 bits.
If you really need 1 bit per pixel you can do so with a little tric... |
327,643 | <p>I see the "More Action" drop-down box in gmail inbox page.
It has levels and some disabled item in the list.</p>
<p>How to do that in HTML+CSS?</p>
<p>Thank you</p>
| [
{
"answer_id": 327702,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 0,
"selected": false,
"text": "<p>You want an unordered list based popup/drop-down menu.</p>\n"
},
{
"answer_id": 327703,
"author": "Rob",... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41803/"
] | I see the "More Action" drop-down box in gmail inbox page.
It has levels and some disabled item in the list.
How to do that in HTML+CSS?
Thank you | You can group and disable elements in an HTML `<select>` element without resorting to the use of JavaScript. Something like the following should work:
```
<select name="foo">
<optgroup label="Odds">
<option value="1">1</option>
<option value="3">3</option>
<option value="5">5</option>
<... |
327,654 | <p>Hashtables have a syncroot property but generic dictionaries don't. If I have code that does this:</p>
<pre><code>lock (hashtable.Syncroot)
{
....
}
</code></pre>
<p>How do I replicate this if I am removing the hashtable and changing to generic dictionaries?</p>
| [
{
"answer_id": 327667,
"author": "Bryan Watts",
"author_id": 37815,
"author_profile": "https://Stackoverflow.com/users/37815",
"pm_score": 3,
"selected": false,
"text": "<pre><code>var dictionary = new Dictionary<int, string>();\n\nlock(((ICollection) dictionary).SyncRoot)\n{\n ... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | Hashtables have a syncroot property but generic dictionaries don't. If I have code that does this:
```
lock (hashtable.Syncroot)
{
....
}
```
How do I replicate this if I am removing the hashtable and changing to generic dictionaries? | If you are going strictly for compatability then Bryan is correct. This is the best way to maintain your current semantics on top of a Dictionary.
Expanding on it though. The reason the SyncRoot property was not directly added to the generic dictionary is that it's a dangerous way to do synchronization. It's only sli... |
327,656 | <p>I am trying to specify an alternative jre (my default is 1.6 and i need to run with jdk 1.4.2) in Eclipse, for an application that i shall launch from eclipse. I am not sure if I am doing the right thing in the following code:</p>
<pre><code>Path jreContainerPath = new Path("/usr/lib/jvm/j2sdk1.4.2_18/");
IVMInstal... | [
{
"answer_id": 327661,
"author": "Anand",
"author_id": 12649,
"author_profile": "https://Stackoverflow.com/users/12649",
"pm_score": 2,
"selected": false,
"text": "<p>Do you necessarily want to specify it in the program itself? Otherwise you could just go to the build path of the project... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23486/"
] | I am trying to specify an alternative jre (my default is 1.6 and i need to run with jdk 1.4.2) in Eclipse, for an application that i shall launch from eclipse. I am not sure if I am doing the right thing in the following code:
```
Path jreContainerPath = new Path("/usr/lib/jvm/j2sdk1.4.2_18/");
IVMInstall jre = JavaRu... | [`getVMInstall`](http://kickjava.com/src/org/eclipse/jdt/launching/JavaRuntime.java.htm) returns [`JREContainerInitializer`](http://kickjava.com/src/org/eclipse/jdt/internal/launching/JREContainerInitializer.java.htm)`.resolveVM(jreContainerPath)` which in turn calls `getExecutionEnvironmentId()`.
It takes the second ... |
327,673 | <p>I need to convert several million dates stored as wide strings into boost dates</p>
<p>The following code works. However, it generates a horrible compiler warning and does not seem efficient.</p>
<p>Is there a better way?</p>
<pre><code>#include "boost/date_time/gregorian/gregorian.hpp"
using namespace boost::gr... | [
{
"answer_id": 327680,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": true,
"text": "<p>efotinis found a good way using <strong>from_stream</strong> . </p>\n\n<hr>\n\n<p>I've looked into the ma... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16582/"
] | I need to convert several million dates stored as wide strings into boost dates
The following code works. However, it generates a horrible compiler warning and does not seem efficient.
Is there a better way?
```
#include "boost/date_time/gregorian/gregorian.hpp"
using namespace boost::gregorian;
#include <string>
u... | efotinis found a good way using **from\_stream** .
---
I've looked into the manual of `date_time` and found it supports facets:
```
#include <boost/date_time/gregorian/gregorian.hpp>
#include <iostream>
#include <sstream>
#include <locale>
int main() {
using namespace boost::gregorian;
std::wstringstream ... |
327,678 | <p>Given the following code,</p>
<pre><code>Choices choices = new Choices();
choices.Add(new GrammarBuilder(new SemanticResultValue("product", "<product/>")));
GrammarBuilder builder = new GrammarBuilder();
builder.Append(new SemanticResultKey("options", choices.ToGrammarBuilder()));
Grammar grammar = new Gram... | [
{
"answer_id": 327680,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": true,
"text": "<p>efotinis found a good way using <strong>from_stream</strong> . </p>\n\n<hr>\n\n<p>I've looked into the ma... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32498/"
] | Given the following code,
```
Choices choices = new Choices();
choices.Add(new GrammarBuilder(new SemanticResultValue("product", "<product/>")));
GrammarBuilder builder = new GrammarBuilder();
builder.Append(new SemanticResultKey("options", choices.ToGrammarBuilder()));
Grammar grammar = new Grammar(builder) { Name ... | efotinis found a good way using **from\_stream** .
---
I've looked into the manual of `date_time` and found it supports facets:
```
#include <boost/date_time/gregorian/gregorian.hpp>
#include <iostream>
#include <sstream>
#include <locale>
int main() {
using namespace boost::gregorian;
std::wstringstream ... |
327,681 | <p>I am using jquery and the getJSON method and I am wondering if there is a way to display a message saying loading before it loads my content. i know with the jquery ajax calls there is the before submit callbacks where you can have something but the getJSON only has like three options.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 327695,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 4,
"selected": true,
"text": "<p>there is the custom <code>.ajax</code> \"before\" and \"success\" events which you can trigger. </p>\n\n<p>Normally... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using jquery and the getJSON method and I am wondering if there is a way to display a message saying loading before it loads my content. i know with the jquery ajax calls there is the before submit callbacks where you can have something but the getJSON only has like three options.
Any ideas? | there is the custom `.ajax` "before" and "success" events which you can trigger.
Normally however, you would just do something like
```
showLoadingAnimation();
$.getJSON( ..... function(){
dontShowLoadingAnimation();
});
```
or something similar.
Your question is however somewhat vauge, and its h... |
327,682 | <p>I am loading JSON data to my page and using <code>appendTo()</code> but I am trying to fade in my results, any ideas?</p>
<pre><code>$("#posts").fadeIn();
$(content).appendTo("#posts");
</code></pre>
<p>I saw that there is a difference between <code>append</code> and <code>appendTo</code>, on the documents.</p>
<... | [
{
"answer_id": 327694,
"author": "Kevin Gorski",
"author_id": 35806,
"author_profile": "https://Stackoverflow.com/users/35806",
"pm_score": 8,
"selected": true,
"text": "<p>If you hide the content before you append it and chain the fadeIn method to that, you should get the effect that yo... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am loading JSON data to my page and using `appendTo()` but I am trying to fade in my results, any ideas?
```
$("#posts").fadeIn();
$(content).appendTo("#posts");
```
I saw that there is a difference between `append` and `appendTo`, on the documents.
I tried this as well:
```
$("#posts").append(content).fadeIn();... | If you hide the content before you append it and chain the fadeIn method to that, you should get the effect that you're looking for.
```
// Create the DOM elements
$(content)
// Sets the style of the elements to "display:none"
.hide()
// Appends the hidden elements to the "posts" element
.appendTo('#posts')
//... |
327,685 | <p>I would like to inject binary data into an object in JavaScript. Is there a way to do this? </p>
<p>i.e.</p>
<pre><code>var binObj = new BinaryObject('101010100101011');
</code></pre>
<p>Something to that effect. Any help would be great.</p>
| [
{
"answer_id": 327688,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 5,
"selected": false,
"text": "<p>You can use parseInt:</p>\n\n<p><code>var bin = parseInt('10101010', 2);</code></p>\n\n<p>The second argument (the radix) ... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to inject binary data into an object in JavaScript. Is there a way to do this?
i.e.
```
var binObj = new BinaryObject('101010100101011');
```
Something to that effect. Any help would be great. | You can use parseInt:
`var bin = parseInt('10101010', 2);`
The second argument (the radix) is the base of the input. |
327,718 | <p>How to list physical disks in Windows?
In order to obtain a list of <code>"\\\\.\PhysicalDrive0"</code> available.</p>
| [
{
"answer_id": 327724,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 6,
"selected": false,
"text": "<p>#WMIC\n<a href=\"http://www.ss64.com/nt/wmic.html\" rel=\"nofollow noreferrer\">wmic</a> is a very complete tool</p>\n<pre c... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2566/"
] | How to list physical disks in Windows?
In order to obtain a list of `"\\\\.\PhysicalDrive0"` available. | #WMIC
[wmic](http://www.ss64.com/nt/wmic.html) is a very complete tool
```none
wmic diskdrive list
```
provide a (too much) detailed list, for instance
for less info
```none
wmic diskdrive list brief
```
#C
[Sebastian Godelet](https://stackoverflow.com/users/281306/sebastian-godelet) mentions [in the comments](... |
327,722 | <p>I'm trying to get NAnt 0.86b1 running with VS2008 SP1 and x64 XP.</p>
<p>I have a basic build file (below) which gives the error
Solution format of file 'Solution.sln' is not supported.</p>
<p>
</p>
<pre><code><property name="nant.settings.currentframework" value="net-3.5" />
<target name="build" descr... | [
{
"answer_id": 327740,
"author": "Matt Campbell",
"author_id": 41110,
"author_profile": "https://Stackoverflow.com/users/41110",
"pm_score": 3,
"selected": false,
"text": "<p>You'll notice that the docs indicate that NAnt's <a href=\"http://nant.sourceforge.net/release/0.85/help/tasks/so... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34632/"
] | I'm trying to get NAnt 0.86b1 running with VS2008 SP1 and x64 XP.
I have a basic build file (below) which gives the error
Solution format of file 'Solution.sln' is not supported.
```
<property name="nant.settings.currentframework" value="net-3.5" />
<target name="build" description="Full Rebuild" depends="clean,com... | You'll notice that the docs indicate that NAnt's [`<solution`>](http://nant.sourceforge.net/release/0.85/help/tasks/solution.html) task doesn't support solution files newer than VS2003.
I recommend using [the `<msbuild>` task from nantcontrib](http://nantcontrib.sourceforge.net/release/0.85/help/tasks/msbuild.html) f... |
327,772 | <p>I have a Java object which is able to configure itself given an XML configuration description (it takes other descriptions as well, but I'm interested in the XML at the moment). I'm wondering if I can embed the XML description directly into a Spring application context description. I'm imagining something like:</p>
... | [
{
"answer_id": 328190,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 3,
"selected": true,
"text": "<p>Spring's <a href=\"http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\" rel=\"nofollow noreferrer\">XSD</a> ... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6716/"
] | I have a Java object which is able to configure itself given an XML configuration description (it takes other descriptions as well, but I'm interested in the XML at the moment). I'm wondering if I can embed the XML description directly into a Spring application context description. I'm imagining something like:
```
<b... | Spring's [XSD](http://www.springframework.org/schema/beans/spring-beans-2.5.xsd) allows `<constructor-arg>` to contain any XML through:
```
<xsd:element name="constructor-arg">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="description" minOccurs="0" />
<xsd:choice minOccurs="0" maxOccurs="1">
... |
327,776 | <p>Imagine I have a file with </p>
<pre><code>Xpto,50,30,60
Xpto,a,v,c
Xpto,1,9,0
Xpto,30,30,60
</code></pre>
<p>that txt file can be appended a lot of times and when I open the file I want only to get the values of the last line of the txt file... How can i do that on python? reading the last line?</p>
| [
{
"answer_id": 327784,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": -1,
"selected": false,
"text": "<p>Not sure about a python specific implementation, but in a more language agnostic fashion, what you would want to do is sk... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41795/"
] | Imagine I have a file with
```
Xpto,50,30,60
Xpto,a,v,c
Xpto,1,9,0
Xpto,30,30,60
```
that txt file can be appended a lot of times and when I open the file I want only to get the values of the last line of the txt file... How can i do that on python? reading the last line? | I think my answer from the [last time this came up](https://stackoverflow.com/questions/260273/most-efficient-way-to-search-the-last-x-lines-of-a-file-in-python) was sadly overlooked. :-)
>
> If you're on a unix box,
> `os.popen("tail -10 " +
> filepath).readlines()` will probably
> be the fastest way. Otherwise, ... |
327,777 | <p>I am fairly beginner level at shell scripts and following are the details..</p>
<p>Am looking for the best way to fire sql queries and and carry out some logic based on that data. I've used the following snippet..</p>
<p>shellvariable=<code>sqlplus $user/$passwd <<END
select count(1) from table1;
end
EOF</co... | [
{
"answer_id": 328617,
"author": "tardate",
"author_id": 6329,
"author_profile": "https://Stackoverflow.com/users/6329",
"pm_score": 3,
"selected": true,
"text": "<p>you're on the right track. sqlplus is the best way to interact with the database when you are shell scripting, but two thi... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31590/"
] | I am fairly beginner level at shell scripts and following are the details..
Am looking for the best way to fire sql queries and and carry out some logic based on that data. I've used the following snippet..
shellvariable=`sqlplus $user/$passwd <<END
select count(1) from table1;
end
EOF`
if[$shellvariable -ne 0] then... | you're on the right track. sqlplus is the best way to interact with the database when you are shell scripting, but two things to note:
1. use the "-S" parameter to stop
sqlplus from printing all its
application info
2. to read data directly into a variable, you will
need some sqlplus environment
settings to prune back... |
327,805 | <p>Sorry if this is a bit long whinded... consider this:</p>
<p>I have a COM+ application in a namespace called <strong>Company</strong> that exposes an object called <strong>Server</strong> which has the following methods:</p>
<pre><code>bool Server.Execute(IOptions options)
IOptions Server.CreateOptions()
</code><... | [
{
"answer_id": 327840,
"author": "x0n",
"author_id": 6920,
"author_profile": "https://Stackoverflow.com/users/6920",
"pm_score": 1,
"selected": false,
"text": "<p>Try looking at the COM server's remote activation permissions on the remote machine via dcomcnfg.exe (should open up MMC snap... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5449/"
] | Sorry if this is a bit long whinded... consider this:
I have a COM+ application in a namespace called **Company** that exposes an object called **Server** which has the following methods:
```
bool Server.Execute(IOptions options)
IOptions Server.CreateOptions()
```
IOptions simply has a couple of boolean read/writ... | I going to extrapolate some older experience with DCOM which may or may not be helpful. When you get access denied, you have to look at the DCOM configuration parameters on machine B.
On older OS's (Windows 2000) you would run **dcomcnfg**. But in XP, you run Component Services from the Control Panel -- Administrative... |
327,807 | <p>I have a model that looks like this:</p>
<pre><code>class Category(models.Model):
name = models.CharField(max_length=60)
class Item(models.Model):
name = models.CharField(max_length=60)
category = models.ForeignKey(Category)
</code></pre>
<p>I want select count (just the count) of items for each categ... | [
{
"answer_id": 327987,
"author": "Carl Meyer",
"author_id": 3207,
"author_profile": "https://Stackoverflow.com/users/3207",
"pm_score": 6,
"selected": false,
"text": "<p>(<strong>Update</strong>: Full ORM aggregation support is now included in <a href=\"http://docs.djangoproject.com/en/d... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26592/"
] | I have a model that looks like this:
```
class Category(models.Model):
name = models.CharField(max_length=60)
class Item(models.Model):
name = models.CharField(max_length=60)
category = models.ForeignKey(Category)
```
I want select count (just the count) of items for each category, so in SQL it would be... | Here, as I just discovered, is how to do this with the Django 1.1 aggregation API:
```
from django.db.models import Count
theanswer = Item.objects.values('category').annotate(Count('category'))
``` |
327,829 | <p>I have a button control style and I want to change the padding from whatever the data-bound version is to adjust for a glyph that needs a 2 pixel offset. I'll use SimpleButton from SimpleStyles.xaml as an example (... shows where the trigger code was removed for conciseness):</p>
<pre><code><Style x:Key="Simple... | [
{
"answer_id": 327962,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 2,
"selected": false,
"text": "<p>No, not in this version of XAML - use a Value Converter to do your math.</p>\n"
},
{
"answer_id": 327997,
"... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30505/"
] | I have a button control style and I want to change the padding from whatever the data-bound version is to adjust for a glyph that needs a 2 pixel offset. I'll use SimpleButton from SimpleStyles.xaml as an example (... shows where the trigger code was removed for conciseness):
```
<Style x:Key="SimpleButton" TargetType... | Currently XAML does not parse expressions in Binding syntax, etc. However, you can use an [IValueConverter](http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx) or [IMultiValueConverter](http://msdn.microsoft.com/en-us/library/system.windows.data.imultivalueconverter.aspx) to help yourself ... |
327,836 | <p>I have a multi file C program. I'd like the user to be able to specify different debugging levels at run time.</p>
<p>What is the best way to implement this?</p>
<p>I was thinking of having a debug(level, "message") type function exported and used everywhere. Any better/other ideas?</p>
| [
{
"answer_id": 327842,
"author": "csexton",
"author_id": 19839,
"author_profile": "https://Stackoverflow.com/users/19839",
"pm_score": 2,
"selected": false,
"text": "<p>There is a very good C port of log4j, <a href=\"http://log4c.sourceforge.net/\" rel=\"nofollow noreferrer\">log4c</a>.<... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a multi file C program. I'd like the user to be able to specify different debugging levels at run time.
What is the best way to implement this?
I was thinking of having a debug(level, "message") type function exported and used everywhere. Any better/other ideas? | Jonathan's suggestion is good but since C99 we have variadic macros so one doesn't need to use double braces for debug macro.
There is a light version of logging header I use:
```
#define LOG_FATAL (1)
#define LOG_ERR (2)
#define LOG_WARN (3)
#define LOG_INFO (4)
#define LOG_DBG (5)
#define LOG(... |
327,838 | <p>I have a Button style and can't seem to property databind the border's CornerRadius property to the template. This is a dependency property, so it should be data bindable. I wonder if I'm missing the right XAML syntax to use?</p>
<pre><code><Style TargetType="{x:Type Button}" BasedOn="{x:Null}">
... | [
{
"answer_id": 329150,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 4,
"selected": true,
"text": "<p>You're trying to set/bind a <code>CornerRadius</code> property on class <code>Button</code>, but there is no such pr... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30505/"
] | I have a Button style and can't seem to property databind the border's CornerRadius property to the template. This is a dependency property, so it should be data bindable. I wonder if I'm missing the right XAML syntax to use?
```
<Style TargetType="{x:Type Button}" BasedOn="{x:Null}">
<Setter Property="... | You're trying to set/bind a `CornerRadius` property on class `Button`, but there is no such property. So the error is expected. |
327,843 | <p>A simple problem: If i use escape characters for a property such as</p>
<pre><code><mx:Image id="img" toolTip="\\foo{\\bar}"
</code></pre>
<p>It wont validate toolTip and therefore not compile.</p>
<p>What is the solution ?</p>
| [
{
"answer_id": 340460,
"author": "Jérémy Reynaud",
"author_id": 43051,
"author_profile": "https://Stackoverflow.com/users/43051",
"pm_score": 2,
"selected": false,
"text": "<p>You can use ActionScipt for example in a creationComplete event handler and assign you tooltip and you won't hav... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32032/"
] | A simple problem: If i use escape characters for a property such as
```
<mx:Image id="img" toolTip="\\foo{\\bar}"
```
It wont validate toolTip and therefore not compile.
What is the solution ? | You can use ActionScipt for example in a creationComplete event handler and assign you tooltip and you won't have the same constraints as in MXML.
But you also can avoid these constraints in MXML by using CDATA:
```
<mx:Image id="img" source="foo.jpg" width="50" height="50">
<mx:toolTip>
<![CDATA[\foo{\bar} or an... |
327,857 | <p>I have a list of input words separated by comma. I want to sort these words by alphabetical and length. How can I do this without using the built-in sorting functions?</p>
| [
{
"answer_id": 327888,
"author": "codefin",
"author_id": 3745,
"author_profile": "https://Stackoverflow.com/users/3745",
"pm_score": 2,
"selected": false,
"text": "<p>There is an entire area of study built around <a href=\"http://en.wikipedia.org/wiki/Sorting_algorithm\" rel=\"nofollow n... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a list of input words separated by comma. I want to sort these words by alphabetical and length. How can I do this without using the built-in sorting functions? | Good question!! Sorting is probably the most important concept to learn as an up-and-coming computer scientist.
There are actually lots of different algorithms for sorting a list.
When you break all of those algorithms down, the most fundamental operation is the comparison of two items in the list, defining their "na... |
327,876 | <pre><code>1 Dim x as Integer? = Nothing
2 If x = Nothing Then
3 'this is what I think will happen
4 Else
5 'this is what really happens
6 End If
</code></pre>
<p>The proper way to write that is "If x Is Nothing".</p>
<p>Is there a FXCop rule that checks for this? Or better yet, can someone show... | [
{
"answer_id": 330874,
"author": "RS Conley",
"author_id": 7890,
"author_profile": "https://Stackoverflow.com/users/7890",
"pm_score": 0,
"selected": false,
"text": "<p>Your best bet to learn to write custom rules for FXCop is the forum <a href=\"http://social.msdn.microsoft.com/forums/e... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5274/"
] | ```
1 Dim x as Integer? = Nothing
2 If x = Nothing Then
3 'this is what I think will happen
4 Else
5 'this is what really happens
6 End If
```
The proper way to write that is "If x Is Nothing".
Is there a FXCop rule that checks for this? Or better yet, can someone show me how to write my own?
... | Another good resource for writing custom FxCop rules can be found here: [binarycoder](http://www.binarycoder.net/fxcop/index.html) |
327,885 | <p>In <a href="http://www.asp.net/mvc/" rel="noreferrer">ASP.NET MVC</a>, the <code>ActionResult</code> class, which is the base for all results returned by action methods from a controller, is defined as an abstract class with the single method (© Microsoft):</p>
<pre><code>public abstract void ExecuteResult(Con... | [
{
"answer_id": 327940,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>I'm gonna guess because they were anticipating the ActionResult to gain methods and properties over the life of the CTP/bet... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11963/"
] | In [ASP.NET MVC](http://www.asp.net/mvc/), the `ActionResult` class, which is the base for all results returned by action methods from a controller, is defined as an abstract class with the single method (© Microsoft):
```
public abstract void ExecuteResult(ControllerContext context);
```
Can you think of any specif... | Interfaces are great for allowing a class to implement multiple contracts, such as when you know that a type must be two different things. In some cases, this can encourage creating a type that has too many responsibilities.
Action results have a single responsibility and it didn't seem like there would be any scenar... |
327,893 | <p>I have a structure:</p>
<pre><code>struct pkt_
{
double x;
double y;
double alfa;
double r_kw;
};
typedef struct pkt_ pkt;
</code></pre>
<p>A table of these structures:</p>
<pre><code>pkt *tab_pkt;
tab_pkt = malloc(ilosc_pkt * sizeof(pkt));
</code></pre>
<p>What I want to do is to sort <code>tab_pkt</c... | [
{
"answer_id": 327925,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 1,
"selected": false,
"text": "<p>There are two parts to the problem - how to write the code, and how to compare the packet types. You must ens... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41839/"
] | I have a structure:
```
struct pkt_
{
double x;
double y;
double alfa;
double r_kw;
};
typedef struct pkt_ pkt;
```
A table of these structures:
```
pkt *tab_pkt;
tab_pkt = malloc(ilosc_pkt * sizeof(pkt));
```
What I want to do is to sort `tab_pkt` by `tab_pkt.alfa` and `tab_pkt.r`:
```
qsort(tab_pkt, ... | Something like this should work:
```
int porownaj(const void *p_a, const void *p_b)
{
/* Need to store arguments in appropriate type before using */
const pkt *pkt_a = p_a;
const pkt *pkt_b = p_b;
/* Return 1 or -1 if alfa members are not equal */
if (pkt_a->alfa > pkt_b->alfa) return 1;
if (pkt_a->alfa <... |
327,895 | <p>Currently I have to uninstall the old version of my service before I install the new version. I am pretty sure this has something to do with it not being smart enough to update or remove the old service entries before adding the new ones.</p>
<p>Is there a way to have the installer skip registering the service if it... | [
{
"answer_id": 327921,
"author": "jalf",
"author_id": 33213,
"author_profile": "https://Stackoverflow.com/users/33213",
"pm_score": 2,
"selected": false,
"text": "<p>Can't you just stop the service, and overwrite the service executable, and then restart the service?</p>\n"
},
{
"... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5274/"
] | Currently I have to uninstall the old version of my service before I install the new version. I am pretty sure this has something to do with it not being smart enough to update or remove the old service entries before adding the new ones.
Is there a way to have the installer skip registering the service if it already ... | I've done this with WiX, which generates .MSI files using the ServiceInstall & SeviceControl commands:
```
<Component Id='c_WSService' Guid='*'>
<File Id='f_WSService' Name='WSService.exe' Vital='yes' Source='..\wssvr\release\wsservice.exe' KeyPath="yes" />
<ServiceInstall Id='WSService.exe' Name='WSService' D... |
327,896 | <p>I would like to draw lines (of arbitrary position and length) onto a surface in pygame, which itself is an image loaded from a file on disk.</p>
<p>Can anyone point me to some example code that does this?</p>
| [
{
"answer_id": 327908,
"author": "chirag",
"author_id": 40596,
"author_profile": "https://Stackoverflow.com/users/40596",
"pm_score": 0,
"selected": false,
"text": "<p>Help on module pygame.draw in pygame:</p>\n\n<p>NAME\n pygame.draw - pygame module for drawing shapes</p>\n\n<p>FILE\... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045/"
] | I would like to draw lines (of arbitrary position and length) onto a surface in pygame, which itself is an image loaded from a file on disk.
Can anyone point me to some example code that does this? | This should do what you're asking for:
```
# load the image
image = pygame.image.load("some_image.png")
# draw a yellow line on the image
pygame.draw.line(image, (255, 255, 0), (0, 0), (100, 100))
```
Typically you don't draw to the original image, since you'll have to reload the image to get the original back (or ... |
327,904 | <p>In the application I'm writing, one of the methods allows for the numbers the user entered to be turned into letters.</p>
<p>For example, the user will be entering grades (as doubles) and the program will decide (when the criteria is met) to return the letter associated with the number. Initially, I had it written ... | [
{
"answer_id": 327923,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Your question is confusing. </p>\n\n<blockquote>\n <p>And since its in an array...</p>\n</blockquote>\n\n<p>but none of y... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29756/"
] | In the application I'm writing, one of the methods allows for the numbers the user entered to be turned into letters.
For example, the user will be entering grades (as doubles) and the program will decide (when the criteria is met) to return the letter associated with the number. Initially, I had it written like this:... | Your question is confusing.
>
> And since its in an array...
>
>
>
but none of your examples include an array. Your method would work fine as
```
public string ToGrade(double score)
{
if (score >= 95.0)
return "A+";
else if (score >= 90.0)
return "A";
/* snip */
else
return "... |
327,913 | <p>Ok, i have simple scenario:</p>
<p>have two pages:
login and welcome pages.
im using FormsAuthentication with my own table that has four columns: ID, UserName, Password, FullName</p>
<p>When pressed login im setting my username like:</p>
<pre><code>FormsAuthentication.SetAuthCookie(userName, rememberMe ?? false);... | [
{
"answer_id": 327978,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>Forms authentication works using cookies. You could construct your own auth cookie and put the full name in it, but... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2246271/"
] | Ok, i have simple scenario:
have two pages:
login and welcome pages.
im using FormsAuthentication with my own table that has four columns: ID, UserName, Password, FullName
When pressed login im setting my username like:
```
FormsAuthentication.SetAuthCookie(userName, rememberMe ?? false);
```
on the welcome page i... | I would store the user's full name in the session cookie after your call to FormsAuth
```
FormsAuth.SetAuthCookie(userName, rememberme);
// get the full name (ex "John Doe") from the datbase here during login
string fullName = "John Doe";
Response.Cookies["FullName"].Value = fullName;
Response.Cookies["FullName"].ex... |
327,984 | <p>Say I have an interface like this:</p>
<pre><code>public interface ISomeInterface
{
...
}
</code></pre>
<p>I also have a couple of classes implementing this interface;</p>
<pre><code>public class SomeClass : ISomeInterface
{
...
}
</code></pre>
<p>Now I have a WPF ListBox listing items of ISomeInterface, using a... | [
{
"answer_id": 327993,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 4,
"selected": false,
"text": "<p>The short answer is DataTemplate's do not support interfaces (think about multiple inheritance, explicit v. implicit, et... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2122/"
] | Say I have an interface like this:
```
public interface ISomeInterface
{
...
}
```
I also have a couple of classes implementing this interface;
```
public class SomeClass : ISomeInterface
{
...
}
```
Now I have a WPF ListBox listing items of ISomeInterface, using a custom DataTemplate.
The databinding engine wil... | In order to bind to explicit implemented interface members, all you need to do is to use the parentheses. For example:
implicit:
```
{Binding Path=MyValue}
```
explicit:
```
{Binding Path=(mynamespacealias:IMyInterface.MyValue)}
``` |
327,985 | <p>The last line of my file is:</p>
<blockquote>
<p>29-dez,40,</p>
</blockquote>
<p>How can I modify that line so that it reads:</p>
<blockquote>
<p>29-Dez,40,90,100,50</p>
</blockquote>
<p>Note: I don't want to write a new line. I want to take the same line and put new values after <code>29-Dez,40,</code></p>
... | [
{
"answer_id": 327992,
"author": "Toni Ruža",
"author_id": 6267,
"author_profile": "https://Stackoverflow.com/users/6267",
"pm_score": 0,
"selected": false,
"text": "<p>Don't work with files directly, make a data structure that fits your needs in form of a class and make read from/write ... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41795/"
] | The last line of my file is:
>
> 29-dez,40,
>
>
>
How can I modify that line so that it reads:
>
> 29-Dez,40,90,100,50
>
>
>
Note: I don't want to write a new line. I want to take the same line and put new values after `29-Dez,40,`
I'm new at python. I'm having a lot of trouble manipulating files and for m... | Unless the file is huge, you'll probably find it easier to read the entire file into a data structure (which might just be a list of lines), and then modify the data structure in memory, and finally write it back to the file.
On the other hand maybe your file *is* really huge - multiple GBs at least. In which case: th... |
327,986 | <p>I still have a large number of floppies. On some of them there probably is source code I don't want to lose. I also don't want to take look at each one individually, as that's going to take a lot of time. What software would be best for copying all data to a hard disk, preferably while creating an index at the same ... | [
{
"answer_id": 328009,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 0,
"selected": false,
"text": "<p>I am not too sure of your goal. Somehow, what you need is a robot, inserting the floppies, copying, etc. :-)</p>\n\n<p>I... | 2008/11/29 | [
"https://Stackoverflow.com/questions/327986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35306/"
] | I still have a large number of floppies. On some of them there probably is source code I don't want to lose. I also don't want to take look at each one individually, as that's going to take a lot of time. What software would be best for copying all data to a hard disk, preferably while creating an index at the same tim... | Here is a script I used on my Linux box to perform the same type of task. Basically I just a raw image of each disk to a folder. I had another script I ran later that mounted each and dumped a directory listing into a file.
```
#!/bin/bash
floppydev='/dev/sdb'
savepath='/srv/floppy_imgs'
while true
do
echo "Press a... |
328,005 | <p>If you have a C# function with Sqlaccess, is it mandatory to close all objects/handles, or is everything cleaned up automatically once you exit the function</p>
<p>For example:</p>
<pre><code>void DoSqlStuff()
{
SqlConnection sqlConn = new SqlConnection(...);
SqlCommand cmd = new SqlCommand(...);
SqlDa... | [
{
"answer_id": 328011,
"author": "Kevin Tighe",
"author_id": 39461,
"author_profile": "https://Stackoverflow.com/users/39461",
"pm_score": 6,
"selected": true,
"text": "<p>You should close the SqlConnection object as soon as you're done with it. If you don't then the connection will rem... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37955/"
] | If you have a C# function with Sqlaccess, is it mandatory to close all objects/handles, or is everything cleaned up automatically once you exit the function
For example:
```
void DoSqlStuff()
{
SqlConnection sqlConn = new SqlConnection(...);
SqlCommand cmd = new SqlCommand(...);
SqlDataReader sqlData= nul... | You should close the SqlConnection object as soon as you're done with it. If you don't then the connection will remain open, and will not be available to handle other requests.
The using statement is useful for this. It will call Dispose() on the object for you:
```
using (SqlConnection cn = new SqlConnection(connec... |
328,017 | <p>How can I programatically get the path to MSBuild from a machine where my .exe is running?</p>
<p>I can get the .NET version from the Environment but is there a way of getting the correct folder for a .NET version?</p>
| [
{
"answer_id": 328133,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 8,
"selected": true,
"text": "<p>Poking around the registry, it looks like</p>\n\n<pre><code>HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersion... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11755/"
] | How can I programatically get the path to MSBuild from a machine where my .exe is running?
I can get the .NET version from the Environment but is there a way of getting the correct folder for a .NET version? | Poking around the registry, it looks like
```
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\2.0
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\3.5
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
```
may be what you're after; fire up regedit.exe and have a look.
### Query v... |
328,020 | <p>I am trying to input data from a .txt file into a scheme structure. Each element is separated by a tab in the data file and each structure set is on a new line. I want to be able to read in the data from one line into a structure and make a list of each structure set in the file. Any suggestions?</p>
| [
{
"answer_id": 331048,
"author": "Nathan Shively-Sanders",
"author_id": 7851,
"author_profile": "https://Stackoverflow.com/users/7851",
"pm_score": 2,
"selected": false,
"text": "<p>Sounds like a CSV file with tabs instead of commas. If you're using PLT Scheme (DrScheme/mzscheme)\nneil's... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to input data from a .txt file into a scheme structure. Each element is separated by a tab in the data file and each structure set is on a new line. I want to be able to read in the data from one line into a structure and make a list of each structure set in the file. Any suggestions? | Not really sure what structures you had in mind, but say you had a text file like the following:
```
--> cat blah.txt
foo bar baz
1 2 3 4 5
aa bb cc dd ee
```
You could convert it directly into a list of lists in scheme using sed:
```
--> echo "(define mylist '("`sed -e 's/\(.*\)/(\1)/' blah.txt`"))" > foo.txt
... |
328,025 | <p>I have an enum </p>
<pre><code>public enum FileExtentions {
mp3,
mpeg
}
</code></pre>
<p>And I have a FileInfo of which I want to check if the extension is in the previous enum.
I was hoping I could do a </p>
<pre><code>FileExtensions.Any(e=>e.ToString().Equals(file.Extension));
</code></pre>
<p>But t... | [
{
"answer_id": 328031,
"author": "Boris Callens",
"author_id": 11333,
"author_profile": "https://Stackoverflow.com/users/11333",
"pm_score": 3,
"selected": false,
"text": "<p>While pressing submit I thought of the answer myself:</p>\n\n<pre><code>Enum.GetNames(typeof(FileExtensions)).Any... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | I have an enum
```
public enum FileExtentions {
mp3,
mpeg
}
```
And I have a FileInfo of which I want to check if the extension is in the previous enum.
I was hoping I could do a
```
FileExtensions.Any(e=>e.ToString().Equals(file.Extension));
```
But that would have been too awesome.
Any ideas? | What's the reason behind `Any` … `Equals`? Did you overlook `Contains`?
```
bool result = Enum.GetNames(typeof(FileExtensions)).Contains("mp3");
``` |
328,044 | <p>I have a database table with a large number of rows and one numeric column, and I want to represent this data in memory. I could just use one big integer array and this would be very fast, but the number of rows could be too large for this.</p>
<p>Most of the rows (more than 99%) have a value of zero. Is there an... | [
{
"answer_id": 328052,
"author": "Adam Byrtek",
"author_id": 36656,
"author_profile": "https://Stackoverflow.com/users/36656",
"pm_score": 2,
"selected": false,
"text": "<p>This is an example of a <em>sparse</em> data structure and there are multiple ways to implement such sparse arrays ... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14606/"
] | I have a database table with a large number of rows and one numeric column, and I want to represent this data in memory. I could just use one big integer array and this would be very fast, but the number of rows could be too large for this.
Most of the rows (more than 99%) have a value of zero. Is there an effective d... | I would expect that the map/dictionary/hashtable of the non-zero values should be a fast and economical solution.
In Java, using the Hashtable class would introduce locking because it is supposed to be thread-safe. Perhaps something similar has slowed down your implementation.
**--- update: using Google-fu suggests t... |
328,059 | <p>I'm trying to open a file and create a list with each line read from the file.</p>
<pre><code> i=0
List=[""]
for Line in inFile:
List[i]=Line.split(",")
i+=1
print List
</code></pre>
<p>But this sample code gives me an error because of the <code>i+=1</code> saying that <code>index is out of ... | [
{
"answer_id": 328066,
"author": "Din",
"author_id": 41214,
"author_profile": "https://Stackoverflow.com/users/41214",
"pm_score": -1,
"selected": false,
"text": "<p>I am not sure about Python but most languages have push/append function for arrays.</p>\n"
},
{
"answer_id": 32806... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41795/"
] | I'm trying to open a file and create a list with each line read from the file.
```
i=0
List=[""]
for Line in inFile:
List[i]=Line.split(",")
i+=1
print List
```
But this sample code gives me an error because of the `i+=1` saying that `index is out of range`.
What's my problem here? How can I ... | It's a lot easier than that:
```
List = open("filename.txt").readlines()
```
This returns a list of each line in the file. |
328,061 | <p>Can someone give me some example code that creates a surface with a transparent background in pygame?</p>
| [
{
"answer_id": 328067,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 7,
"selected": true,
"text": "<p>This should do it:</p>\n\n<pre><code>image = pygame.Surface([640,480], pygame.SRCALPHA, 32)\nimage = image.convert_alpha()... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045/"
] | Can someone give me some example code that creates a surface with a transparent background in pygame? | This should do it:
```
image = pygame.Surface([640,480], pygame.SRCALPHA, 32)
image = image.convert_alpha()
```
Make sure that the color depth (32) stays explicitly set else this will not work. |
328,107 | <p>Let's say you have a two dimensional plane with 2 points (called a and b) on it represented by an x integer and a y integer for each point.</p>
<p>How can you determine if another point c is on the line segment defined by a and b?</p>
<p>I use python most, but examples in any language would be helpful.</p>
| [
{
"answer_id": 328110,
"author": "Darius Bacon",
"author_id": 27024,
"author_profile": "https://Stackoverflow.com/users/27024",
"pm_score": 5,
"selected": false,
"text": "<p>Check if the cross product of <code>b-a</code> and <code>c-a</code> is<code>0</code>: that means all the points ar... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045/"
] | Let's say you have a two dimensional plane with 2 points (called a and b) on it represented by an x integer and a y integer for each point.
How can you determine if another point c is on the line segment defined by a and b?
I use python most, but examples in any language would be helpful. | Check if the **cross product** of (b-a) and (c-a) is 0, as tells Darius Bacon, tells you if the points a, b and c are aligned.
But, as you want to know if c is between a and b, you also have to check that the **dot product** of (b-a) and (c-a) is *positive* and is *less* than the square of the distance between a and b... |
328,123 | <p>I have one table that saves comments for a varied set of content types. These are saved in other tables (news, articles, users).
I wonder what's the best way to connect these tables?
In previous projects I used a second table for each kind of content. They held the id of the certain content mapped to ids of the com... | [
{
"answer_id": 328136,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>I would probably have a separate comments table for each content table so that I could take advantage of the foreign... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35903/"
] | I have one table that saves comments for a varied set of content types. These are saved in other tables (news, articles, users).
I wonder what's the best way to connect these tables?
In previous projects I used a second table for each kind of content. They held the id of the certain content mapped to ids of the commen... | There are a few obvious ways to design your table:
1) You can have a master Comments table, and intermediate tables to connect each comment to your Articles, News, and Users tables:
```
Comments
--------
ID
News NewsComments
---- ------------
ID NewsID
CommentID
Articles ArticleComments
... |
328,202 | <p>I'm considering using Annotations to define my Hibernate mappings but have run into a problem: I want to use a base entity class to define common fields (including the ID field) but I want different tables to have different ID generation strategies:</p>
<pre><code>@MappedSuperclass
public abstract class Base imple... | [
{
"answer_id": 328225,
"author": "David Crow",
"author_id": 2783,
"author_profile": "https://Stackoverflow.com/users/2783",
"pm_score": 3,
"selected": true,
"text": "<p>In the code above, it looks like you're mixing annotations on fields (superclass) and methods (subclass). The Hibernate... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41861/"
] | I'm considering using Annotations to define my Hibernate mappings but have run into a problem: I want to use a base entity class to define common fields (including the ID field) but I want different tables to have different ID generation strategies:
```
@MappedSuperclass
public abstract class Base implements Serializa... | In the code above, it looks like you're mixing annotations on fields (superclass) and methods (subclass). The Hibernate [reference documentation](http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#entity-mapping-entity) recommends avoiding this, and I suspect it might be causing the problem. In my ... |
328,215 | <p>I was hanging out in my profiler for a while trying to figure out how to speed up a common log parser which was bottlenecked around the date parsing, and I tried various algorithms to speed things up.</p>
<p>The thing I tried that was fastest for me was also by far the most readable, but potentially non-standard C.... | [
{
"answer_id": 328221,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 2,
"selected": false,
"text": "<p>I get warnings, but no errors (gcc). Seems to compile and operate fine. <strong>May not work for big-endian systems, ... | 2008/11/29 | [
"https://Stackoverflow.com/questions/328215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39975/"
] | I was hanging out in my profiler for a while trying to figure out how to speed up a common log parser which was bottlenecked around the date parsing, and I tried various algorithms to speed things up.
The thing I tried that was fastest for me was also by far the most readable, but potentially non-standard C.
This wor... | Solaris 10 - SPARC - SUN Compiler.
Test code:
```
#include <stdio.h>
static int parseMonth(const char *input) {
int rv=-1;
int inputInt=0;
int i=0;
for(i=0; i<4 && input[i]; i++) {
inputInt = (inputInt << 8) | input[i];
}
switch(inputInt) {
case 'Jan/': rv=0; break;
... |
328,249 | <p>How do you concatenate characters in java? Concatenating strings would only require a <code>+</code> between the strings, but concatenating chars using <code>+</code> will change the value of the char into ascii and hence giving a numerical output. I want to do <code>System.out.println(char1+char2+char3...</code> an... | [
{
"answer_id": 328253,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 6,
"selected": false,
"text": "<p>Do you want to make a string out of them?</p>\n\n<pre><code>String s = new StringBuilder().append(char1).append(char2).a... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do you concatenate characters in java? Concatenating strings would only require a `+` between the strings, but concatenating chars using `+` will change the value of the char into ascii and hence giving a numerical output. I want to do `System.out.println(char1+char2+char3...` and create a String word like this.
I... | Do you want to make a string out of them?
```
String s = new StringBuilder().append(char1).append(char2).append(char3).toString();
```
Note that
```
String b = "b";
String s = "a" + b + "c";
```
Actually compiles to
```
String s = new StringBuilder("a").append(b).append("c").toString();
```
**Edit**: as litb p... |
328,264 | <p>When I supply the script with the argument: hi[123].txt it will do exactly what I want.
But if I specify the wildcard character ( hi*.txt ) it will be re-reading some files.</p>
<p>I was wondering how to modify this script to fix that silly problem:</p>
<pre><code>#!/bin/sh
count="0"
total="0"
FILE="$1" #FILE sp... | [
{
"answer_id": 328286,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know what is wrong with it, but one little point i noticed:</p>\n\n<p>Change <code>for FILE in $... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40120/"
] | When I supply the script with the argument: hi[123].txt it will do exactly what I want.
But if I specify the wildcard character ( hi\*.txt ) it will be re-reading some files.
I was wondering how to modify this script to fix that silly problem:
```
#!/bin/sh
count="0"
total="0"
FILE="$1" #FILE specification is now $... | On error, exit with a non-zero status. Also on error, report errors to standard error, not standard output - though that may be a bit advanced for you as yet.
```
echo "$0: file $FILE not readable" 1>&2
```
The 1 is theoretically unnecessary (though I remember problems with a shell implementation on Windows if it wa... |
328,309 | <p>We run a relatively high volume content site. Like most content sites, the majority of each page is relatively static. The articles rarely change, making them good candidates for some form of static/edge caching. There are two big problems, though. Secondary page elements (nav, recent content lists, etc) change ... | [
{
"answer_id": 328461,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 2,
"selected": false,
"text": "<p>set Nginx as a front-end, and use SSI to pick the dynamic parts of the pages. dynamic source can be an HTTP server, lik... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35296/"
] | We run a relatively high volume content site. Like most content sites, the majority of each page is relatively static. The articles rarely change, making them good candidates for some form of static/edge caching. There are two big problems, though. Secondary page elements (nav, recent content lists, etc) change pretty ... | set Nginx as a front-end, and use SSI to pick the dynamic parts of the pages. dynamic source can be an HTTP server, like Apache, or a FastCGI server, for example PHP, or Django.
edit:
Many webservers support some form of SSI (Server Side Includes), this feature lets you add some tags into the HTML as a very limited f... |
328,343 | <p>I'm trying to use SharpZipLib to pull specified files from a zip archive. All of the examples I've seen always expect that you want to unzip the entire zip, and do something along the lines of:</p>
<pre><code> FileStream fileStreamIn = new FileStream (sourcePath, FileMode.Open, FileAccess.Read);
ZipI... | [
{
"answer_id": 328353,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 7,
"selected": true,
"text": "<p>ZipFile.GetEntry should do the trick:</p>\n\n<pre><code>using (var fs = new FileStream(sourcePath, FileMode.Open, Fi... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I'm trying to use SharpZipLib to pull specified files from a zip archive. All of the examples I've seen always expect that you want to unzip the entire zip, and do something along the lines of:
```
FileStream fileStreamIn = new FileStream (sourcePath, FileMode.Open, FileAccess.Read);
ZipInputStream zip... | ZipFile.GetEntry should do the trick:
```
using (var fs = new FileStream(sourcePath, FileMode.Open, FileAccess.Read))
using (var zf = new ZipFile(fs)) {
var ze = zf.GetEntry(fileName);
if (ze == null) {
throw new ArgumentException(fileName, "not found in Zip");
}
using (var s = zf.GetInputStream(ze)... |
328,352 | <p>I'd like to add a logo to the left of my title on my navigation bar. The title property seems to only take an NSString. What's the best way to add an image to the navigation bar?</p>
| [
{
"answer_id": 328363,
"author": "Adam Ernst",
"author_id": 79,
"author_profile": "https://Stackoverflow.com/users/79",
"pm_score": 2,
"selected": false,
"text": "<p>Set <code>UINavigationItem.titleView</code> to a <em>custom view</em> (or just a straight UIImageView).</p>\n"
},
{
... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | I'd like to add a logo to the left of my title on my navigation bar. The title property seems to only take an NSString. What's the best way to add an image to the navigation bar? | You can replace the title view with an image like this:
```
navigationItem.titleView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"title_bar.png"]];
``` |
328,381 | <p>I'm a php guy, but I have to do some small project in JSP.
I'm wondering if there's an equivalent to htmlentities function (of php) in JSP.</p>
| [
{
"answer_id": 328386,
"author": "Florin",
"author_id": 34565,
"author_profile": "https://Stackoverflow.com/users/34565",
"pm_score": 3,
"selected": true,
"text": "<pre><code>public static String stringToHTMLString(String string) {\n StringBuffer sb = new StringBuffer(string.length())... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] | I'm a php guy, but I have to do some small project in JSP.
I'm wondering if there's an equivalent to htmlentities function (of php) in JSP. | ```
public static String stringToHTMLString(String string) {
StringBuffer sb = new StringBuffer(string.length());
// true if last char was blank
boolean lastWasBlankChar = false;
int len = string.length();
char c;
for (int i = 0; i < len; i++)
{
c = string.charAt(i);
if ... |
328,382 | <p>What to do when after all probing, a reportedly valid object return 'undefined' for any attribute probed? I use jQuery, <code>$('selector').mouseover(function() { });</code> Everything returns 'undefined' for <code>$(this)</code> inside the function scope. The selector is a 'area' for a map tag and I'm looking for i... | [
{
"answer_id": 328418,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 6,
"selected": true,
"text": "<p>Your question is a bit vague, so maybe you can provide more details?</p>\n\n<p>As for finding out about an object an... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34565/"
] | What to do when after all probing, a reportedly valid object return 'undefined' for any attribute probed? I use jQuery, `$('selector').mouseover(function() { });` Everything returns 'undefined' for `$(this)` inside the function scope. The selector is a 'area' for a map tag and I'm looking for its parent attributes. | Your question is a bit vague, so maybe you can provide more details?
As for finding out about an object and the values of its properties, there are many ways to do it, including using Firebug or some other debug tools, etc. Here is a quick and dirty function that might help get you started until you can provide more d... |
328,384 | <p>I have an associative array, ie</p>
<pre><code>$primes = array(
2=>2,
3=>3,
5=>5,
7=>7,
11=>11,
13=>13,
17=>17,
// ...etc
);
</code></pre>
<p>then I do</p>
<pre><code>// seek to first prime greater than 10000
reset($primes);
while(next($primes) < 10000) {}
prev($primes);
/... | [
{
"answer_id": 328388,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 3,
"selected": false,
"text": "<p>You can \"save\" the state of the array:</p>\n\n<pre><code>$state = key($array);\n</code></pre>\n\n<p>And \"restore\" (... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33258/"
] | I have an associative array, ie
```
$primes = array(
2=>2,
3=>3,
5=>5,
7=>7,
11=>11,
13=>13,
17=>17,
// ...etc
);
```
then I do
```
// seek to first prime greater than 10000
reset($primes);
while(next($primes) < 10000) {}
prev($primes);
// iterate until target found
while($p = next($primes)) {
... | Don't rely on array pointers. Use iterators instead.
You can replace your outer code with:
```
foreach ($primes as $p) {
if ($p > 10000 && IsPrime(doSomeCalculationsOn($p))) {
return $p;
}
}
``` |
328,387 | <p>I need help to replace all \n (new line) caracters for <br /> in a String, but not those \n inside [code][/code] tags.
My brain is burning, I can't solve this by my own :(</p>
<p>Example:</p>
<pre><code>test test test
test test test
test
test
[code]some
test
code
[/code]
more text
</code></pre>
<p>Should be:</p... | [
{
"answer_id": 328392,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 4,
"selected": true,
"text": "<p>I would suggest a (simple) parser, and not a regular expression. Something like this (bad pseudocode):</p>\n\n<pre><cod... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] | I need help to replace all \n (new line) caracters for
in a String, but not those \n inside [code][/code] tags.
My brain is burning, I can't solve this by my own :(
Example:
```
test test test
test test test
test
test
[code]some
test
code
[/code]
more text
```
Should be:
```
test test test<br />
test test te... | I would suggest a (simple) parser, and not a regular expression. Something like this (bad pseudocode):
```
stack elementStack;
foreach(char in string) {
if(string-from-char == "[code]") {
elementStack.push("code");
string-from-char = "";
}
if(string-from-char == "[/code]") {
eleme... |
328,391 | <p>I have the following code which is trivial at first sight. I simply set want to set the font type to Georgia with a size of 14 if the cell is from the result of a search or if there is a count of zero in my students array. </p>
<p>However, with this particular code cell that's last in my <code>tableView</code> is t... | [
{
"answer_id": 328405,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not <i>quite</i> sure what you're asking, but I do note that you're only setting the font to Georgia 14 when you... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | I have the following code which is trivial at first sight. I simply set want to set the font type to Georgia with a size of 14 if the cell is from the result of a search or if there is a count of zero in my students array.
However, with this particular code cell that's last in my `tableView` is taking on the font of ... | I'm not *quite* sure what you're asking, but I do note that you're only setting the font to Georgia 14 when you have a search result; otherwise, you're ignoring it. If you have a cell with it's font set in the second if/then branch, and then retrieve that cell (using dequeueReusableCellWithIdentifier:), it will already... |
328,430 | <p>I've got jQuery Autocomplete (UI 1.6rc2) up and running fine and when the user picks an item, it updates a hidden form value with the associated ID. How do I set the hidden form value to '0' when the text entered does not match a result from the autocomplete list? In this case, I'll be creating a new entry.</p>
| [
{
"answer_id": 330078,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 0,
"selected": false,
"text": "<p>According to the comment thread <a href=\"http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/\" rel=\"n... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1786/"
] | I've got jQuery Autocomplete (UI 1.6rc2) up and running fine and when the user picks an item, it updates a hidden form value with the associated ID. How do I set the hidden form value to '0' when the text entered does not match a result from the autocomplete list? In this case, I'll be creating a new entry. | I did this in the autocomplete function:
```
change: function(event, ui){
$(this).next("input[id^=person_id]").val('');
return false;
```
After the user selects the option and it populates my hidden input with the item ID, if any changes occur to the visible input, the hidden input value is cleared. Works like ... |
328,463 | <p>I'm attempting to install phpMyAdmin, but I constantly get errors.</p>
<p>When I type this in the terminal:</p>
<pre><code>sudo dpkg --configure -a
</code></pre>
<p>The following message appears:</p>
<pre>
Setting up mysql-server-5.0 (5.0.45-1ubuntu3) ...
* Stopping MySQL database server mysqld ... | [
{
"answer_id": 328559,
"author": "Zoredache",
"author_id": 20267,
"author_profile": "https://Stackoverflow.com/users/20267",
"pm_score": 2,
"selected": false,
"text": "<p>The installer error is related to the <code>mysql-server-5.0</code> package. You probably should do an <code>apt-get ... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm attempting to install phpMyAdmin, but I constantly get errors.
When I type this in the terminal:
```
sudo dpkg --configure -a
```
The following message appears:
```
Setting up mysql-server-5.0 (5.0.45-1ubuntu3) ...
* Stopping MySQL database server mysqld [OK]
* Starting MySQL database se... | The installer error is related to the `mysql-server-5.0` package. You probably should do an `apt-get purge mysql-server-5.0` and then try reinstalling it. Once that has been installed, try and install phpmyadmin. |
328,468 | <p>I'm using PHP to generate thumbnails. The problem is that I have a set width and height the thumbnails need to be and often times the images are stretched.</p>
<p>What I'd like is the image to remain at the same proportions and just have black filler (or any color) either on the left & right for tall images or ... | [
{
"answer_id": 328483,
"author": "da5id",
"author_id": 14979,
"author_profile": "https://Stackoverflow.com/users/14979",
"pm_score": 0,
"selected": false,
"text": "<p>Have a look at this <a href=\"http://www.verot.net/php_class_upload.htm\" rel=\"nofollow noreferrer\">upload class</a>. I... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | I'm using PHP to generate thumbnails. The problem is that I have a set width and height the thumbnails need to be and often times the images are stretched.
What I'd like is the image to remain at the same proportions and just have black filler (or any color) either on the left & right for tall images or top & bottom f... | You'll need to calculate the new width & height to keep the image proportionat. Check out example 2 on this page:
<http://us3.php.net/imagecopyresampled> |
328,472 | <p>I am trying to send mail from a local iis app using localhost as my smtp server after installing free smtp but I am getting the following error:</p>
<pre><code>Mailbox unavailable. The server response was: Invalid
</code></pre>
<p>recipient: 'validAddress'@hotmail.com</p>
<p>Any idea what the problem could be?</... | [
{
"answer_id": 328476,
"author": "Pure.Krome",
"author_id": 30674,
"author_profile": "https://Stackoverflow.com/users/30674",
"pm_score": 1,
"selected": false,
"text": "<p>it sounds like your free (3rd party) smtp app is not leaving your network and might be trying to see if it has that ... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15059/"
] | I am trying to send mail from a local iis app using localhost as my smtp server after installing free smtp but I am getting the following error:
```
Mailbox unavailable. The server response was: Invalid
```
recipient: 'validAddress'@hotmail.com
Any idea what the problem could be? | it sounds like your free (3rd party) smtp app is not leaving your network and might be trying to see if it has that mailbox itself. Try and see if there is a setting to allow the smtp server to access external connections, etc. What is the name of the free smtp app, btw?
Alternatively, can u use the built in SMTP mail... |
328,475 | <p>So far I've seen many posts dealing with equality of floating point numbers. The standard answer to a question like "how should we decide if x and y are equal?" is</p>
<pre><code>abs(x - y) < epsilon
</code></pre>
<p>where epsilon is a <em>fixed</em>, small constant. This is because the "operands" x and y are o... | [
{
"answer_id": 328480,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 5,
"selected": true,
"text": "<p>It all depends on the specific problem domain. Yes, using relative error will be more correct in the general case... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18770/"
] | So far I've seen many posts dealing with equality of floating point numbers. The standard answer to a question like "how should we decide if x and y are equal?" is
```
abs(x - y) < epsilon
```
where epsilon is a *fixed*, small constant. This is because the "operands" x and y are often the results of some computation... | It all depends on the specific problem domain. Yes, using relative error will be more correct in the general case, but it can be significantly less efficient since it involves an extra floating-point division. If you know the approximate scale of the numbers in your problem, using an absolute error is acceptable.
[Thi... |
328,496 | <p>What are some <em>common</em>, <em>real world examples</em> of using the Builder Pattern? What does it buy you? Why not just use a Factory Pattern?</p>
| [
{
"answer_id": 328505,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 3,
"selected": false,
"text": "<p>You use it when you have lots of options to deal with. Think about things like jmock:</p>\n\n<pre><code>m.expects(once(... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7705/"
] | What are some *common*, *real world examples* of using the Builder Pattern? What does it buy you? Why not just use a Factory Pattern? | The key difference between a builder and factory IMHO, is that a builder is useful when you need to do lots of things to build an object. For example imagine a DOM. You have to create plenty of nodes and attributes to get your final object. A factory is used when the factory can easily create the entire object within o... |
328,525 | <p>How can I set default value in ActiveRecord?</p>
<p>I see a post from Pratik that describes an ugly, complicated chunk of code: <a href="http://m.onkey.org/2007/7/24/how-to-set-default-values-in-your-model" rel="noreferrer">http://m.onkey.org/2007/7/24/how-to-set-default-values-in-your-model</a></p>
<pre><code>cla... | [
{
"answer_id": 328678,
"author": "Milan Novota",
"author_id": 26123,
"author_profile": "https://Stackoverflow.com/users/26123",
"pm_score": 4,
"selected": false,
"text": "<p>The Phusion guys have some nice <a href=\"http://blog.phusion.nl/2008/10/03/47/\" rel=\"noreferrer\">plugin</a> fo... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2477/"
] | How can I set default value in ActiveRecord?
I see a post from Pratik that describes an ugly, complicated chunk of code: <http://m.onkey.org/2007/7/24/how-to-set-default-values-in-your-model>
```
class Item < ActiveRecord::Base
def initialize_with_defaults(attrs = nil, &block)
initialize_without_defaults(attr... | There are several issues with each of the available methods, but I believe that defining an `after_initialize` callback is the way to go for the following reasons:
1. `default_scope` will initialize values for new models, but then that will become the scope on which you find the model. If you just want to initialize s... |
328,549 | <p>I have an ASPX page where I am uploading an image to server for on a serverside button click event. In my page, it will show the available image if it exists. When I upload an image, it will replace the old one with the new one. Now after uploading also the same image is getting displayed. How can tackle this? I us... | [
{
"answer_id": 328565,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 2,
"selected": false,
"text": "<p>Your browser is probably caching the image. Either disable caching on the image or set up proper caching responses.</p... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40521/"
] | I have an ASPX page where I am uploading an image to server for on a serverside button click event. In my page, it will show the available image if it exists. When I upload an image, it will replace the old one with the new one. Now after uploading also the same image is getting displayed. How can tackle this? I used w... | It's being cached in the browser. To overcome this - alter the url of the image. This can be done by including a timestamp, version number, or guid in the image file name. |
328,568 | <p>I'm thinking how to arrange a deployed python application which will have a </p>
<ol>
<li>Executable script located in /usr/bin/ which will provide a CLI to functionality implemented in</li>
<li>A library installed to wherever the current site-packages directory is.</li>
</ol>
<p>Now, currently, I have the followi... | [
{
"answer_id": 328579,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 0,
"selected": false,
"text": "<p>You should call the executable just <code>foo</code>, not <code>foo.py</code>, then attempts to import foo will... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39167/"
] | I'm thinking how to arrange a deployed python application which will have a
1. Executable script located in /usr/bin/ which will provide a CLI to functionality implemented in
2. A library installed to wherever the current site-packages directory is.
Now, currently, I have the following directory structure in my sour... | [This article](http://jcalderone.livejournal.com/39794.html) is pretty good, and shows you a good way to do it. The second item from the *Do* list answers your question.
*shameless copy paste:*
>
> Filesystem structure of a Python project
> ========================================
>
>
> *by [Jp Calderone](http://j... |
328,600 | <p>I'm using LINQ to Entities (not LINQ to SQL) and I'm having trouble creating an 'IN' style query. Here is my query at the moment:</p>
<pre><code>var items = db.InventoryItem
.Include("Kind")
.Include("PropertyValues")
.Include("PropertyValues.KindProperty")
... | [
{
"answer_id": 328677,
"author": "liggett78",
"author_id": 19762,
"author_profile": "https://Stackoverflow.com/users/19762",
"pm_score": 4,
"selected": true,
"text": "<p>You need to either use this one:</p>\n\n<pre><code>.Where(string.Format(\"it.ID in {0}\", string.Join(\",\", valueIds.... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] | I'm using LINQ to Entities (not LINQ to SQL) and I'm having trouble creating an 'IN' style query. Here is my query at the moment:
```
var items = db.InventoryItem
.Include("Kind")
.Include("PropertyValues")
.Include("PropertyValues.KindProperty")
.Where(i... | You need to either use this one:
```
.Where(string.Format("it.ID in {0}", string.Join(",", valueIds.ToArray())));
```
or construct the WHERE part dynamically, as in [this](http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3917617&SiteID=1) post.
P.S. - Information has been updated and this answer updated as fo... |
328,623 | <p>UPDATE:
Thank you all for your input. Some additional information.</p>
<p>It's really just a small chunk of markup (20 lines) I'm working with and had aimed to to leverage a regex to do the work.</p>
<p>I also do have the ability to hack up the script (an ecommerce one) to insert the classes as the navigation is ... | [
{
"answer_id": 328626,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.jwz.org/\" rel=\"nofollow noreferrer\">Jamie Zawinski</a> would have <a href=\"http://fishbowl.past... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41903/"
] | UPDATE:
Thank you all for your input. Some additional information.
It's really just a small chunk of markup (20 lines) I'm working with and had aimed to to leverage a regex to do the work.
I also do have the ability to hack up the script (an ecommerce one) to insert the classes as the navigation is built. I wanted t... | [Jamie Zawinski](http://www.jwz.org/) would have [something to say about this](http://fishbowl.pastiche.org/2003/08/18/beware_regular_expressions/)...
Do you have a proper HTML parser? I don't know if there's anything like [hpricot](http://code.whytheluckystiff.net/hpricot/) available for PHP, but that's the right way... |
328,636 | <pre><code>SELECT NR_DZIALU, COUNT (NR_DZIALU) AS LICZ_PRAC_DZIALU
FROM PRACOWNICY
GROUP BY NR_DZIALU
HAVING NR_DZIALU = 30
</code></pre>
<p>or</p>
<pre><code>SELECT NR_DZIALU, COUNT (NR_DZIALU) AS LICZ_PRAC_DZIALU
FROM PRACOWNICY
WHERE NR_DZIALU = 30
GROUP BY NR_DZIALU
</code></pre>
| [
{
"answer_id": 328638,
"author": "ysth",
"author_id": 17389,
"author_profile": "https://Stackoverflow.com/users/17389",
"pm_score": 2,
"selected": false,
"text": "<p>I'd expect the WHERE clause would be faster, but it's possible they'd optimize to exactly the same.</p>\n"
},
{
"a... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9099/"
] | ```
SELECT NR_DZIALU, COUNT (NR_DZIALU) AS LICZ_PRAC_DZIALU
FROM PRACOWNICY
GROUP BY NR_DZIALU
HAVING NR_DZIALU = 30
```
or
```
SELECT NR_DZIALU, COUNT (NR_DZIALU) AS LICZ_PRAC_DZIALU
FROM PRACOWNICY
WHERE NR_DZIALU = 30
GROUP BY NR_DZIALU
``` | The theory (by theory I mean [SQL Standard](http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt)) says that WHERE restricts the result set before returning rows and HAVING restricts the result set after bringing all the rows. So WHERE is faster. On SQL Standard compliant DBMSs in this regard, only use HAVING wher... |
328,661 | <p>I used to use the implicit call of toString when wanting some debug info about an object, because in case of the object is null it does not throw an Exception.</p>
<p>For instance: </p>
<pre><code>System.out.println("obj: "+obj);
</code></pre>
<p>instead of:</p>
<pre><code>System.out.println("obj: "+obj.toStrin... | [
{
"answer_id": 328667,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 1,
"selected": false,
"text": "<p>No difference except, like you say, the null safety. Always prefer the former to the latter.</p>\n"
},
{
"answe... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12860/"
] | I used to use the implicit call of toString when wanting some debug info about an object, because in case of the object is null it does not throw an Exception.
For instance:
```
System.out.println("obj: "+obj);
```
instead of:
```
System.out.println("obj: "+obj.toString());
```
Is there any difference apart fro... | There's little difference. Use the one that's shorter and works more often.
If you actually want to get the string value of an object for other reasons, and want it to be null friendly, do this:
```
String s = String.valueOf(obj);
```
**Edit**: The question was extended, so I'll extend my answer.
In both cases, th... |
328,673 | <p>Is there an elegant way in Perl to find the newest file in a directory (newest by modification date)?</p>
<p>What I have so far is searching for the files I need, and for each one get it's modification time, push into an array containing the filename, modification time, then sort it.</p>
<p>There must be a better ... | [
{
"answer_id": 328686,
"author": "Nathan Fellman",
"author_id": 1084,
"author_profile": "https://Stackoverflow.com/users/1084",
"pm_score": 4,
"selected": false,
"text": "<p>you could try using the shell's <code>ls</code> command:</p>\n\n<pre><code>@list = `ls -t`;\n$newest = $list[0];\n... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] | Is there an elegant way in Perl to find the newest file in a directory (newest by modification date)?
What I have so far is searching for the files I need, and for each one get it's modification time, push into an array containing the filename, modification time, then sort it.
There must be a better way. | Your way is the "right" way if you need a sorted list (and not just the first, see Brian's answer for that). If you don't fancy writing that code yourself, use [this](http://search.cpan.org/~tpaba/File-DirList-0.04/lib/File/DirList.pm)
```
use File::DirList;
my @list = File::DirList::list('.', 'M');
```
Personally I... |
328,682 | <p>I am using RRDtool for storing data for displaying graphs. I update the RRD by RRDs::update and this fails when trying to rewrite the information, means update data for a time in the past (e.g. someone moved the system timer back). The error I get is: </p>
<pre><code>ERROR: Cannot update /opt/dashboard/rrd/Disk/19... | [
{
"answer_id": 328869,
"author": "genehack",
"author_id": 39933,
"author_profile": "https://Stackoverflow.com/users/39933",
"pm_score": 1,
"selected": false,
"text": "<p>According to the RRD documentation, that timestamp number <strong>must</strong> increase with each update. Given your ... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using RRDtool for storing data for displaying graphs. I update the RRD by RRDs::update and this fails when trying to rewrite the information, means update data for a time in the past (e.g. someone moved the system timer back). The error I get is:
```
ERROR: Cannot update /opt/dashboard/rrd/Disk/192.168.120.168_d... | rrdtool does not write your input into the rrd file. It rather samples what you enter and then stores the resulting datapoints. So providing 'old data' to rrdtool update will not work in the same way, as you can not easily skip back in a sound recording to 'fix' a few bad notes.
Obviously there are ways to alter old d... |
328,692 | <p>In my application, a user has_many tickets. Unfortunately, the tickets table does not have a user_id: it has a user_login (it is a legacy database). I am going to change that someday, but for now this change would have too many implications.</p>
<p>So how can I build a "user has_many :tickets" association through... | [
{
"answer_id": 328694,
"author": "dgtized",
"author_id": 34450,
"author_profile": "https://Stackoverflow.com/users/34450",
"pm_score": 1,
"selected": false,
"text": "<p>I think you are looking for the <code>:foreign_key</code> option on <code>has_many</code>. That should allow you to sp... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38626/"
] | In my application, a user has\_many tickets. Unfortunately, the tickets table does not have a user\_id: it has a user\_login (it is a legacy database). I am going to change that someday, but for now this change would have too many implications.
So how can I build a "user has\_many :tickets" association through the **l... | I think you want the `:primary_key` option to `has_many`. It allows you to specify the column on the current Table who's value is stored in the `:foreign_key` column on the other table.
```
has_many :tickets, :foreign_key => "user_login", :primary_key => "login"
```
I found this by reading the [has\_many](http://api... |
328,704 | <p>I use Netbeans IDE (6.5) and I have a SQLite 2.x database. I installed a JDBC SQLite driver from <a href="http://www.zentus.com/sqlitejdbc/" rel="nofollow noreferrer">zentus.com</a> and added a new driver in Nebeans services panel. Then tried to connect to my database file from Services > Databases using this URL fo... | [
{
"answer_id": 329698,
"author": "Doug Currie",
"author_id": 33252,
"author_profile": "https://Stackoverflow.com/users/33252",
"pm_score": 2,
"selected": true,
"text": "<p>The current version of Zentus SQLiteJDBC is v053, based on SQLite 3.6.1. It will not open a 2.x SQLite database. Per... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9394/"
] | I use Netbeans IDE (6.5) and I have a SQLite 2.x database. I installed a JDBC SQLite driver from [zentus.com](http://www.zentus.com/sqlitejdbc/) and added a new driver in Nebeans services panel. Then tried to connect to my database file from Services > Databases using this URL for my database:
jdbc:sqlite:/home/farza... | The current version of Zentus SQLiteJDBC is v053, based on SQLite 3.6.1. It will not open a 2.x SQLite database. Perhaps you can use SQLite 2.x command line tool to .dump your database, and the Sqlite3 command line tool to .load it. The use Zentus SQLiteJDBC to access the new SQLite 3.x database.
Alternatively, use a ... |
328,718 | <p>The <a href="http://code.google.com/p/v8/wiki/BuildingOnWindows" rel="nofollow noreferrer">build instructions of V8 JavaScript Engine</a> mention only Visual Studio 2005 and 2008. Has anybody been successful with <a href="http://mingw.org/" rel="nofollow noreferrer">MinGW</a> on Windows XP/Vista?</p>
| [
{
"answer_id": 641739,
"author": "kentaromiura",
"author_id": 27340,
"author_profile": "https://Stackoverflow.com/users/27340",
"pm_score": 0,
"selected": false,
"text": "<p>I've tried, but seems it automatically detect the WIN32 platform and tries to invoke the vc++ compiler, I tried to... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30289/"
] | The [build instructions of V8 JavaScript Engine](http://code.google.com/p/v8/wiki/BuildingOnWindows) mention only Visual Studio 2005 and 2008. Has anybody been successful with [MinGW](http://mingw.org/) on Windows XP/Vista? | You just need to change Scons a bit.
Take a look at C:\YourPythonFolder\Lib\site-packages\scons-YourSconsVersion\SCons\Script\_\_ init\_\_.py and go to line 560.
Change the linker to gnulink, the c compiler to mingw and the c++ compiler to g++.
Eventually it should look like this:
```
linkers = ['gnulink', 'm... |
328,722 | <p>My current code is this:</p>
<pre><code>int volume = Alert.getVolume(); // reads 100
Alert.setVolume(0);
</code></pre>
<p>It DOESN'T change the volume setting, like it would be supposed to do
Even calling <code>Alert.mute(true);</code> doesn't produce any good effect.
<code>Audio.setVolume(0);</code> also doesn't... | [
{
"answer_id": 328776,
"author": "Paul de Vrieze",
"author_id": 4100,
"author_profile": "https://Stackoverflow.com/users/4100",
"pm_score": 0,
"selected": false,
"text": "<p>Certain functions on the blackberry (but not the emulator) only work with signed code. I'm not sure if it is the c... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39680/"
] | My current code is this:
```
int volume = Alert.getVolume(); // reads 100
Alert.setVolume(0);
```
It DOESN'T change the volume setting, like it would be supposed to do
Even calling `Alert.mute(true);` doesn't produce any good effect.
`Audio.setVolume(0);` also doesn't work!
I am running this on a Curve 8310. I hav... | If you want to play sound with [Alert](http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/system/Alert.html):
```
class Scr extends MainScreen implements FieldChangeListener {
ButtonField mVolumeUp;
ButtonField mVolumeDown;
ButtonField mPlay;
LabelField mVolumeLabel;
int mVolumeValue = 50;... |
328,743 | <p>I have this code :-</p>
<pre><code>using (System.Security.Cryptography.SHA256 sha2 =
new System.Security.Cryptography.SHA256Managed())
{ .. }
</code></pre>
<p>Do I need to put this line of code, just BEFORE I leave that dispose scope .. or does the dispose 'call' that already.</p>
<pre><code>sha2.Clear();
</... | [
{
"answer_id": 328744,
"author": "Maxam",
"author_id": 15310,
"author_profile": "https://Stackoverflow.com/users/15310",
"pm_score": 3,
"selected": true,
"text": "<p>Since AFAIK the Clear() method just calls Dispose, the using block should be enough to ensure that the resources used are ... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I have this code :-
```
using (System.Security.Cryptography.SHA256 sha2 =
new System.Security.Cryptography.SHA256Managed())
{ .. }
```
Do I need to put this line of code, just BEFORE I leave that dispose scope .. or does the dispose 'call' that already.
```
sha2.Clear();
``` | Since AFAIK the Clear() method just calls Dispose, the using block should be enough to ensure that the resources used are released. |
328,747 | <p>I have problem with return statment >.< I want to store all magazine names into</p>
<pre><code>ArrayList<String> ListNameMagazine = new ArrayList<String>();
</code></pre>
<p>I have a DB; in the DB there is a table <code>name_magazine</code> and the data in <code>name_magazine</code> is</p>
<blockqu... | [
{
"answer_id": 328760,
"author": "xan",
"author_id": 15667,
"author_profile": "https://Stackoverflow.com/users/15667",
"pm_score": 4,
"selected": true,
"text": "<p>Your problem is that <strong>return</strong> returns only one thing, and it will <em>return immediately and the function wil... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41780/"
] | I have problem with return statment >.< I want to store all magazine names into
```
ArrayList<String> ListNameMagazine = new ArrayList<String>();
```
I have a DB; in the DB there is a table `name_magazine` and the data in `name_magazine` is
>
> Magazine1
>
>
> Magazine2
>
>
> Magazine3
>
>
> Magazine4
>
>
... | Your problem is that **return** returns only one thing, and it will *return immediately and the function will exit*! You are retuning the name of a magazine **just\_try**.
```
while (rs.next()) {
//System.out.println("Result:"+rs.getString(1));
just_try = rs.getString(1);
return just_try;
}
```
So, you... |
328,763 | <p><strong>Update:</strong> This turned into a blog post, with updated links and code, over at my blog: <a href="https://egilhansen.com/2008/12/01/how-to-take-control-of-style-sheets-in-asp-net-themes-with-the-styleplaceholder-and-style-control/" rel="nofollow noreferrer">https://egilhansen.com/2008/12/01/how-to-take-c... | [
{
"answer_id": 345036,
"author": "Egil Hansen",
"author_id": 32809,
"author_profile": "https://Stackoverflow.com/users/32809",
"pm_score": 3,
"selected": true,
"text": "<p>Found the answer to my own question.</p>\n\n<p>The reason for the rendering errors I am getting in design mode, is a... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32809/"
] | **Update:** This turned into a blog post, with updated links and code, over at my blog: <https://egilhansen.com/2008/12/01/how-to-take-control-of-style-sheets-in-asp-net-themes-with-the-styleplaceholder-and-style-control/>
---
The problem is pretty simple. When using ASP.NET Themes you do not have much say in how you... | Found the answer to my own question.
The reason for the rendering errors I am getting in design mode, is an apparent bug in Visual Studio SP1, [which Microsoft has yet to fix](http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361826).
So the above code works as expected, also in design m... |
328,765 | <p>I have a object of type <code>ICollection<string></code>. What is the best way to convert to <code>string[]</code>. </p>
<p>How can this be done in .NET 2?<BR>
How can this be done cleaner in later version of C#, perhaps using LINQ in C# 3?</p>
| [
{
"answer_id": 328767,
"author": "AdrianoKF",
"author_id": 27232,
"author_profile": "https://Stackoverflow.com/users/27232",
"pm_score": 6,
"selected": true,
"text": "<p>You could use the following snippet to convert it to an ordinary array:</p>\n\n<pre><code>string[] array = new string[... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | I have a object of type `ICollection<string>`. What is the best way to convert to `string[]`.
How can this be done in .NET 2?
How can this be done cleaner in later version of C#, perhaps using LINQ in C# 3? | You could use the following snippet to convert it to an ordinary array:
```
string[] array = new string[collection.Count];
collection.CopyTo(array, 0);
```
That should do the job :) |
328,768 | <p>After moving to .NET 2.0+ is there ever a reason to still use the systems.Collections namespace (besides maintaining legacy code)? Should the generics namespace always be used instead?</p>
| [
{
"answer_id": 328777,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 0,
"selected": false,
"text": "<p>In some circumstances the generic containers perform better than the old ones. They should at least perform as... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | After moving to .NET 2.0+ is there ever a reason to still use the systems.Collections namespace (besides maintaining legacy code)? Should the generics namespace always be used instead? | For the most part, the generic collections will perform faster than the non-generic counterpart and give you the benefit of having a strongly-typed collection. Comparing the collections available in System.Collections and System.Collections.Generic, you get the following "migration":
```
Non-Generic ... |
328,772 | <p>I have a class that inherits a generic dictionary and an inteface</p>
<pre><code>public class MyDictionary: Dictionary<string, IFoo>, IMyDictionary
{
}
</code></pre>
<p>the issue is that consumers of this class are looking for the '.Keys' and ".Values" properties of the interface so i added:</p>
<pre><code>... | [
{
"answer_id": 328782,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 2,
"selected": false,
"text": "<p>The reason is that your keys and values properties are hiding the implementation of the keys and values properties in th... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | I have a class that inherits a generic dictionary and an inteface
```
public class MyDictionary: Dictionary<string, IFoo>, IMyDictionary
{
}
```
the issue is that consumers of this class are looking for the '.Keys' and ".Values" properties of the interface so i added:
```
/// <summary>
///
/// </summar... | Another option would be to change the types on the interface to be:
```
public interface IMyDictionary
{
/// <summary>
///
/// </summary>
Dictionary<string, IFoo>.KeyCollection Keys { get; }
/// <summary>
///
/// </summary>
Dictionary<string, IFoo>.ValueCollection Values { get; }
}
... |
328,793 | <p>The <code>curses.ascii</code> module has some nice functions defined, that allow for example to recognize which characters are printable (<code>curses.ascii.isprint(ch)</code>).</p>
<p>But, diffrent character codes can be printable depending on which locale setting is being used. For example, there are certain poli... | [
{
"answer_id": 328807,
"author": "Ignacio Vazquez-Abrams",
"author_id": 20862,
"author_profile": "https://Stackoverflow.com/users/20862",
"pm_score": 3,
"selected": true,
"text": "<p>If you convert the character to a unicode then you can use unicodedata:</p>\n\n<pre><code>>>> un... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4172/"
] | The `curses.ascii` module has some nice functions defined, that allow for example to recognize which characters are printable (`curses.ascii.isprint(ch)`).
But, diffrent character codes can be printable depending on which locale setting is being used. For example, there are certain polish characters:
```
>>> ord('a')... | If you convert the character to a unicode then you can use unicodedata:
```
>>> unicodedata.category(u'ą')[0] in 'LNPS'
True
``` |
328,834 | <ol>
<li><p>Consider:</p>
<pre><code>char *p=NULL;
free(p) // or
delete p;
</code></pre>
<p>What will happen if I use <code>free</code> and <code>delete</code> on <code>p</code>?</p></li>
<li><p>If a program takes a long time to execute, say 10 minutes, is there any way to reduce its running time to 5 minutes?</p></l... | [
{
"answer_id": 328841,
"author": "activout.se",
"author_id": 20444,
"author_profile": "https://Stackoverflow.com/users/20444",
"pm_score": 4,
"selected": false,
"text": "<p>Answer 1: Both <code>free(p)</code> and <code>delete p</code> work fine with a NULL pointer.</p>\n\n<p>Answer 2: Im... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41522/"
] | 1. Consider:
```
char *p=NULL;
free(p) // or
delete p;
```
What will happen if I use `free` and `delete` on `p`?
2. If a program takes a long time to execute, say 10 minutes, is there any way to reduce its running time to 5 minutes? | Some performance notes about new/delete and malloc/free:
malloc and free **do not** call the constructor and deconstructor, respectively. This means your classes won't get initalized or deinitialized automatically, which could be bad (e.g. uninitalized pointers)! This doesn't matter for POD data types like char and do... |
328,851 | <p>With a class in Python, how do I define a function to print every single instance of the class in a format defined in the function?</p>
| [
{
"answer_id": 328856,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": false,
"text": "<p>Same as almost all other OO languages, keep all instances of the class in a collection of some kind.</p>\n\n<p>You can t... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33061/"
] | With a class in Python, how do I define a function to print every single instance of the class in a format defined in the function? | I see two options in this case:
Garbage collector
-----------------
```
import gc
for obj in gc.get_objects():
if isinstance(obj, some_class):
dome_something(obj)
```
This has the disadvantage of being very slow when you have a lot of objects, but works with types over which you have no control.
Use a ... |
328,857 | <p>How to run NAnt scripts in command line and get the timings of each task on the log file?</p>
<pre><code>using nant <record> task or
NAnt -buildfile:testscript.build testnanttarget
</code></pre>
<p>This produces console output but I can't see any timing information.</p>
<p>All I want each log message prefi... | [
{
"answer_id": 329162,
"author": "wimh",
"author_id": 33499,
"author_profile": "https://Stackoverflow.com/users/33499",
"pm_score": 4,
"selected": true,
"text": "<p>You can use the <a href=\"http://nant.sourceforge.net/release/0.85-rc3/help/tasks/tstamp.html\" rel=\"noreferrer\">tstamp t... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32670/"
] | How to run NAnt scripts in command line and get the timings of each task on the log file?
```
using nant <record> task or
NAnt -buildfile:testscript.build testnanttarget
```
This produces console output but I can't see any timing information.
All I want each log message prefixed with datatime. | You can use the [tstamp task](http://nant.sourceforge.net/release/0.85-rc3/help/tasks/tstamp.html) to display the current date/time. Just include it everywhere where you want timing information. It will not prefix each line with a timestamp, but at least you can time some strategic points.
```
<tstamp />
``` |
328,914 | <p>How should I check if my ISP blocks port 25?</p>
| [
{
"answer_id": 328916,
"author": "Bruno",
"author_id": 17648,
"author_profile": "https://Stackoverflow.com/users/17648",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://www.canyouseeme.org/\" rel=\"noreferrer\">http://www.canyouseeme.org/</a></p>\n"
},
{
"answer_id... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16039/"
] | How should I check if my ISP blocks port 25? | ```
cmd> telnet <some well known email provider IP> 25
```
to determine which exactly host (subdomain) is listening port 25:
```
nslookup -q=MX <top-level domain>
```
For example:
```
cmd> nslookup -q=MX gmail.com
gmail.com MX preference = 50, mail exchanger = gsmtp147.google.com
gmail.com MX prefere... |
328,915 | <p>I've been using the following snippet in developements for years. Now all of a sudden I get a DB Error: no such field warning</p>
<pre><code>$process = "process";
$create = $connection->query
(
"INSERT INTO summery (process) VALUES($process)"
);
if (DB::isError($create)) die($create->getMessage($create));... | [
{
"answer_id": 329223,
"author": "Zan Lynx",
"author_id": 13422,
"author_profile": "https://Stackoverflow.com/users/13422",
"pm_score": 3,
"selected": false,
"text": "<p>It's always better to use prepared queries and parameter placeholders. Like this in Perl DBI:</p>\n\n<pre><code>my $p... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've been using the following snippet in developements for years. Now all of a sudden I get a DB Error: no such field warning
```
$process = "process";
$create = $connection->query
(
"INSERT INTO summery (process) VALUES($process)"
);
if (DB::isError($create)) die($create->getMessage($create));
```
but it's fine... | It's always better to use prepared queries and parameter placeholders. Like this in Perl DBI:
```
my $process=1234;
my $ins_process = $dbh->prepare("INSERT INTO summary (process) values(?)");
$ins_process->execute($process);
```
For best performance, prepare all your often-used queries right after opening the databa... |
328,922 | <p>I have a <code>mysql</code> database filled up and running on a <em>Windows</em> computer, is there any tool to transfer the database to another computer (running <em>Ubuntu</em>)?</p>
<p>Else I'll just write a <code>script</code> to take all the data base into <code>SQL</code> and <em>insert</em> it on the other c... | [
{
"answer_id": 328927,
"author": "Gonzalo Quero",
"author_id": 40996,
"author_profile": "https://Stackoverflow.com/users/40996",
"pm_score": 0,
"selected": false,
"text": "<p>You can make a backup using any gui tool, like Mysql Administrator (<a href=\"http://dev.mysql.com/downloads/gui-... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26004/"
] | I have a `mysql` database filled up and running on a *Windows* computer, is there any tool to transfer the database to another computer (running *Ubuntu*)?
Else I'll just write a `script` to take all the data base into `SQL` and *insert* it on the other computer. Just trying to save some time :)
Thank you all. | The tool you speak of already exists: mysqldump
It dumps out to sql, which you can then copy to another machine and re-load.
eg:
on source:
```
mysqldump -u username -p databasename > dumpfile.sql
```
Then use ftp/rsync/whatever to move the file to the destination machine, and on there, create an empty database t... |
328,925 | <p>When I code like this: </p>
<pre><code>ServerSocketChannel ssc = ServerSocketChannel.open();
InetSocketAddress sa = new InetSocketAddress("localhost",8888);
ssc.socket().bind(sa);
ssc.configureBlocking(false);
ssc.socket().accept();
</code></pre>
<p>the <code>ServerSocket.accept()</code> method throws <code>j... | [
{
"answer_id": 328937,
"author": "Yoni Roit",
"author_id": 34161,
"author_profile": "https://Stackoverflow.com/users/34161",
"pm_score": 2,
"selected": false,
"text": "<p>Because that's what javadoc for serversocket.accept() says?</p>\n\n<p>IllegalBlockingModeException - if this socket h... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41940/"
] | When I code like this:
```
ServerSocketChannel ssc = ServerSocketChannel.open();
InetSocketAddress sa = new InetSocketAddress("localhost",8888);
ssc.socket().bind(sa);
ssc.configureBlocking(false);
ssc.socket().accept();
```
the `ServerSocket.accept()` method throws `java.nio.channels.IllegalBlockingModeException`.... | Because that's what javadoc for serversocket.accept() says?
IllegalBlockingModeException - if this socket has an associated channel, and the channel is in non-blocking mode. |
328,944 | <p>How do i check in C++ if a file is a regular file (and is not a directory, a pipe, etc.)? I need a function isFile(). </p>
<pre><code>DIR *dp;
struct dirent *dirp;
while ((dirp = readdir(dp)) != NULL) {
if ( isFile(dirp)) {
cout << "IS A FILE!" << endl;
i++;
}
</code></pre>
<p>I've tried comparin... | [
{
"answer_id": 328948,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 4,
"selected": true,
"text": "<p>You need to call stat(2) on the file, and then use the S_ISREG macro on st_mode.</p>\n\n<p>Something like (adapt... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39796/"
] | How do i check in C++ if a file is a regular file (and is not a directory, a pipe, etc.)? I need a function isFile().
```
DIR *dp;
struct dirent *dirp;
while ((dirp = readdir(dp)) != NULL) {
if ( isFile(dirp)) {
cout << "IS A FILE!" << endl;
i++;
}
```
I've tried comparing dirp->d\_type with (unsigned char)0x... | You need to call stat(2) on the file, and then use the S\_ISREG macro on st\_mode.
Something like (adapted from [this answer](https://stackoverflow.com/a/3828537/6451573)):
```
#include <sys/stat.h>
struct stat sb;
if (stat(pathname, &sb) == 0 && S_ISREG(sb.st_mode))
{
// file exists and it's a regular file
}
... |
328,946 | <p>On researching another question I noted that the <code>stat</code> function in Perl can take a dirhandle as its argument (instead of a filehandle or filename).</p>
<p>However I can't find any examples of correct use of this - there are none in the Perl manual.</p>
<p>Can anyone show an example of how to use it?</p... | [
{
"answer_id": 328971,
"author": "genehack",
"author_id": 39933,
"author_profile": "https://Stackoverflow.com/users/39933",
"pm_score": 2,
"selected": false,
"text": "<p>You use it just like you would <code>stat</code> on a filehandle:</p>\n\n<pre><code><~> $ mkdir -v foo ; perl -e... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6782/"
] | On researching another question I noted that the `stat` function in Perl can take a dirhandle as its argument (instead of a filehandle or filename).
However I can't find any examples of correct use of this - there are none in the Perl manual.
Can anyone show an example of how to use it? | You use it in the same way you do for a file or filehandle:
```
#!/usr/bin/perl
use strict;
my $dir = shift;
opendir(DIR, $dir) or die "Failed to open $dir: $!\n";
my @stats = stat DIR;
closedir(DIR);
my $atime = scalar localtime $stats[8];
print "Last access time on $dir: $atime\n";
```
The ability to use stat on... |
328,955 | <p>Thanks for a <a href="https://stackoverflow.com/questions/327893/how-to-write-a-compare-function-for-qsort-from-stdlib">solution in C</a>,
now I would like to achieve this in C++ using std::sort and vector:</p>
<pre><code>typedef struct
{
double x;
double y;
double alfa;
} pkt;
</code></pre>
<p><code>vector&... | [
{
"answer_id": 328959,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 6,
"selected": true,
"text": "<p><code>std::sort</code> takes a different compare function from that used in <code>qsort</code>. Instead of returnin... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41839/"
] | Thanks for a [solution in C](https://stackoverflow.com/questions/327893/how-to-write-a-compare-function-for-qsort-from-stdlib),
now I would like to achieve this in C++ using std::sort and vector:
```
typedef struct
{
double x;
double y;
double alfa;
} pkt;
```
`vector< pkt > wektor;` filled up using push\_back... | `std::sort` takes a different compare function from that used in `qsort`. Instead of returning –1, 0 or 1, this function is expected to return a `bool` value indicating whether the first element is less than the second.
You have two possibilites: implement `operator <` for your objects; in that case, the default `sort... |
328,962 | <p>I wrote a Win Forms app to test how a LinkLabel class works. It appears to be fine until I click on the changed LinkLabel. The Form1.cs code is below:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using Syste... | [
{
"answer_id": 7297967,
"author": "Chamika Sandamal",
"author_id": 880434,
"author_profile": "https://Stackoverflow.com/users/880434",
"pm_score": 1,
"selected": false,
"text": "<p>The following sample code shows how you can set a link label's color from a <code>ColorDialog</code>:</p>\n... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I wrote a Win Forms app to test how a LinkLabel class works. It appears to be fine until I click on the changed LinkLabel. The Form1.cs code is below:
```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Sy... | The following sample code shows how you can set a link label's color from a `ColorDialog`:
```
using (var colorDlg = new ColorDialog())
{
if (colorDlg.ShowDialog() == DialogResult.OK)
{
llblinkLabel1.LinkColor = colorDlg.Color;
}
}
``` |
328,964 | <p>Is there any lib that convert very long numbers to string just copying the data?</p>
<p>These one-liners are too slow:</p>
<pre><code>def xlong(s):
return sum([ord(c) << e*8 for e,c in enumerate(s)])
def xstr(x):
return chr(x&255) + xstr(x >> 8) if x else ''
print xlong('abcd'*1024) % 666... | [
{
"answer_id": 328967,
"author": "ironfroggy",
"author_id": 19687,
"author_profile": "https://Stackoverflow.com/users/19687",
"pm_score": 2,
"selected": false,
"text": "<p>You want the struct module.</p>\n\n<pre><code>packed = struct.pack('l', 123456)\nassert struct.unpack('l', packed)[0... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there any lib that convert very long numbers to string just copying the data?
These one-liners are too slow:
```
def xlong(s):
return sum([ord(c) << e*8 for e,c in enumerate(s)])
def xstr(x):
return chr(x&255) + xstr(x >> 8) if x else ''
print xlong('abcd'*1024) % 666
print xstr(13**666)
``` | You want the struct module.
```
packed = struct.pack('l', 123456)
assert struct.unpack('l', packed)[0] == 123456
``` |
328,965 | <p>Does anyone know how to auto-mount an <a href="http://aws.amazon.com/ebs/" rel="nofollow noreferrer">Elastic Block Storage</a> (EBS) volume when starting a Windows 2003 instance in Amazon's <a href="http://aws.amazon.com/ec2/" rel="nofollow noreferrer">Elastic Compute Cloud</a> (EC2)?</p>
| [
{
"answer_id": 422575,
"author": "Chris Markle",
"author_id": 1505846,
"author_profile": "https://Stackoverflow.com/users/1505846",
"pm_score": 2,
"selected": false,
"text": "<p>I found the following Ruby code at <a href=\"http://www.ioncannon.net/system-administration/199/automounting-a... | 2008/11/30 | [
"https://Stackoverflow.com/questions/328965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16997/"
] | Does anyone know how to auto-mount an [Elastic Block Storage](http://aws.amazon.com/ebs/) (EBS) volume when starting a Windows 2003 instance in Amazon's [Elastic Compute Cloud](http://aws.amazon.com/ec2/) (EC2)? | Setup:
* Make sure the EBS volume is formatted and labeled (in the example I used the label PDRIVE).
* Setup a drive mapping using Ec2ConfigServiceSettings.exe
* Install Java on the instance
* Install the EC2 API command line tools
* Install a copy of your cert and private key
* Install a copy of curl.exe (open source... |
329,020 | <p>I have set up a sort of introspection-enabling C++ library that allows, using minimum macros and a fair amount of template trickery, to declare structures and classes that get enriched with some meta-information.</p>
<p>This meta-information captures all important details about each field of the struct/class that y... | [
{
"answer_id": 334544,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>/*\nsmarc's keeping it simple\n*/</p>\n\n<pre><code> class xmlstream\n {\n ...\n };\n\n class ibase\n {\n void read(... | 2008/11/30 | [
"https://Stackoverflow.com/questions/329020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41789/"
] | I have set up a sort of introspection-enabling C++ library that allows, using minimum macros and a fair amount of template trickery, to declare structures and classes that get enriched with some meta-information.
This meta-information captures all important details about each field of the struct/class that you declare... | /\*
smarc's keeping it simple
\*/
```
class xmlstream
{
...
};
class ibase
{
void read( xmlstream& rStream ) = 0;
void write( xmlstream& rStream ) = 0;
};
class classfactory
{
void produce( xmlstream& rStream );
void consume( xmlstream& rStream );
ibase* create( xmlstream& rStream );
... |
329,029 | <p>The title basically spells it out. What interfaces have you written that makes you proud and you use a lot. I guess the guys that wrote <code>IEnumerable<T></code> and not least <code>IQueryable<T></code> had a good feeling after creating those.</p>
| [
{
"answer_id": 329045,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>I guess the guys that wrote IEnumerable … had a good feeling after creating [it].</p>\n</blockquot... | 2008/11/30 | [
"https://Stackoverflow.com/questions/329029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29519/"
] | The title basically spells it out. What interfaces have you written that makes you proud and you use a lot. I guess the guys that wrote `IEnumerable<T>` and not least `IQueryable<T>` had a good feeling after creating those. | I'm pleased with the design of the interface at the heart of [Push LINQ](http://msmvps.com/blogs/jon_skeet/archive/2008/01/04/quot-push-quot-linq-revisited-next-attempt-at-an-explanation.aspx). It's a very simple interface, but with it you can do all kinds of interesting things. Here's the definition (from memory, but ... |
329,043 | <p>I need a conditional compilation switch that knows if I am compiling for the mono or MS .NET runtime. How can I do this? </p>
| [
{
"answer_id": 329072,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 7,
"selected": true,
"text": "<p>The Mono compiler defines <code>__MonoCS__</code></p>\n\n<p><strong>BUT, BUT, BUT</strong>, the whole point of Mono is tha... | 2008/11/30 | [
"https://Stackoverflow.com/questions/329043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3024/"
] | I need a conditional compilation switch that knows if I am compiling for the mono or MS .NET runtime. How can I do this? | The Mono compiler defines `__MonoCS__`
**BUT, BUT, BUT**, the whole point of Mono is that you can take an assembly that you built with VS and run it on Mono, or vice versa.
It seems to me that if you need to have Mono vs MS.NET differences, then you need to be making those decisions at run-time.
The standard way to ... |
329,044 | <p>I'm using the following as a way of seeing listing the various methods in my developement</p>
<pre><code>print basename(__FILE__) . "::serve_table()"
</code></pre>
<p>is there any function that's able to return the name of a class method so I don't have to trpe it each time?</p>
| [
{
"answer_id": 329047,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 3,
"selected": false,
"text": "<p>Use <code>__FUNCTION__</code> and <code>__LINE__</code> and <code>__CLASS__</code> and <code>__METHOD__</code></p>\n... | 2008/11/30 | [
"https://Stackoverflow.com/questions/329044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using the following as a way of seeing listing the various methods in my developement
```
print basename(__FILE__) . "::serve_table()"
```
is there any function that's able to return the name of a class method so I don't have to trpe it each time? | Use `__FUNCTION__` and `__LINE__` and `__CLASS__` and `__METHOD__` |