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 |
|---|---|---|---|---|---|---|
106,963 | <p>I'm building the world's simplest library application. All I want to be able to do is scan in a book's UPC (barcode) using a typical scanner (which just types the numbers of the barcode into a field) and then use it to look up data about the book... at a minimum, title, author, year published, and either the Dewey D... | [
{
"answer_id": 106987,
"author": "Philip Rieck",
"author_id": 12643,
"author_profile": "https://Stackoverflow.com/users/12643",
"pm_score": 3,
"selected": false,
"text": "<p><strong>Edit</strong> It would be pretty easy if you had ISBN. but converting from UPC to ISBN is not as easy as ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4/"
] | I'm building the world's simplest library application. All I want to be able to do is scan in a book's UPC (barcode) using a typical scanner (which just types the numbers of the barcode into a field) and then use it to look up data about the book... at a minimum, title, author, year published, and either the Dewey Deci... | There's a very straightforward web based solution over at ISBNDB.com that you may want to look at.
**Edit:** Updated API documentation link, now there's version 2 available as well
[Link to prices and tiers here](https://isbndb.com/isbn-database)
You can be up and running in just a few minutes (these examples are fr... |
106,965 | <p>Is there a way to read a locked file across a network given that you are the machine admin on the remote machine? I haven't been able to read the locked file locally, and attempting it over the network adds another layer of difficulty.</p>
| [
{
"answer_id": 106987,
"author": "Philip Rieck",
"author_id": 12643,
"author_profile": "https://Stackoverflow.com/users/12643",
"pm_score": 3,
"selected": false,
"text": "<p><strong>Edit</strong> It would be pretty easy if you had ISBN. but converting from UPC to ISBN is not as easy as ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2712/"
] | Is there a way to read a locked file across a network given that you are the machine admin on the remote machine? I haven't been able to read the locked file locally, and attempting it over the network adds another layer of difficulty. | There's a very straightforward web based solution over at ISBNDB.com that you may want to look at.
**Edit:** Updated API documentation link, now there's version 2 available as well
[Link to prices and tiers here](https://isbndb.com/isbn-database)
You can be up and running in just a few minutes (these examples are fr... |
106,979 | <p>I have two threads, one needs to poll a bunch of separate static resources looking for updates. The other one needs to get the data and store it in the database. How can thread 1 tell thread 2 that there is something to process?</p>
| [
{
"answer_id": 106982,
"author": "Nescio",
"author_id": 14484,
"author_profile": "https://Stackoverflow.com/users/14484",
"pm_score": 3,
"selected": false,
"text": "<p>I use Monitor.Wait / Pulse on a Queue of work items.</p>\n"
},
{
"answer_id": 106994,
"author": "1800 INFORM... | 2008/09/20 | [
"https://Stackoverflow.com/questions/106979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] | I have two threads, one needs to poll a bunch of separate static resources looking for updates. The other one needs to get the data and store it in the database. How can thread 1 tell thread 2 that there is something to process? | If the pieces of data are independant then treat the pieces of data as work items to be processed by a pool of threads. Use the thread pool and `QueueUserWorkItem` to post the data to the thread(s). You should get better scalability using a pool of symmetric threads and limiting the amount of synchronisation that has t... |
107,018 | <p>There are a couple of different .NET XSLT functions that I see used in the out of the box SharePoint web parts (RSS Viewer and Data View web part).</p>
<pre><code><xsl:stylesheet
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:rssaggwrt="http://schemas.microsoft.com/WebPar... | [
{
"answer_id": 107021,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 1,
"selected": false,
"text": "<p>Here is some documentation I found that describes the ddwrt (<a href=\"http://schemas.microsoft.com/WebParts/v2/D... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | There are a couple of different .NET XSLT functions that I see used in the out of the box SharePoint web parts (RSS Viewer and Data View web part).
```
<xsl:stylesheet
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:rssaggwrt="http://schemas.microsoft.com/WebParts/v3/rssagg/runt... | I have been wanting more info on ddwrt as well. The most information I have been able to find is from Serge van den Oever that was later turned into the MSDN article referenced in the previous answer.
<http://weblogs.asp.net/soever/archive/2005/01/03/345535.aspx>
As he noted in his blog post, this article contains s... |
107,049 | <p>We have a rather simple site (minimal JS) with plain html and CSS. It is a simple mobile interface for our main application.</p>
<p>We are running into trouble because we have more than one column and several browsers seem to force single columns.</p>
<p>Through some searching I ran into 2 meta tags.</p>
<pre><c... | [
{
"answer_id": 107366,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>My recommendation would be to create two or three versions of the site:</p>\n\n<ul>\n<li>Full blown site for modern desktop... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4923/"
] | We have a rather simple site (minimal JS) with plain html and CSS. It is a simple mobile interface for our main application.
We are running into trouble because we have more than one column and several browsers seem to force single columns.
Through some searching I ran into 2 meta tags.
```
<meta name="MobileOptimiz... | I wouldn't bother making a "medium" version for the iPhone etc, iPhone users can just look at your real web page easily enough. Have your full version and a single column version, and you'll reach the largest audience with minimal work.
To answer your question though, there's no good way to make the Blackberry do anyt... |
107,054 | <p>I'm trying to implement an outdent of the first letter of the first paragraph of the body text. Where I'm stuck is in getting consistent spacing between the first letter and the rest of the paragraph. </p>
<p>For example, there is a huge difference in spacing between a "W" and an "I"</p>
<p><img src="https://i.sta... | [
{
"answer_id": 107111,
"author": "Matthew Rapati",
"author_id": 15000,
"author_profile": "https://Stackoverflow.com/users/15000",
"pm_score": 0,
"selected": false,
"text": "<p>I tried using a fix-width font like 'courier new' and since the characters are more or less the same width it ma... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11577/"
] | I'm trying to implement an outdent of the first letter of the first paragraph of the body text. Where I'm stuck is in getting consistent spacing between the first letter and the rest of the paragraph.
For example, there is a huge difference in spacing between a "W" and an "I"
</p>\n\n<p>I can't specifically answer the question, except that the Is... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] | I noticed that you can call Queue.Synchronize to get a thread-safe queue object, but the same method isn't available on Queue<T>. Does anyone know why? Seems kind of weird. | **Update** - in .NET 4, there now is `ConcurrentQueue<T>` in System.Collections.Concurrent, as documented here <http://msdn.microsoft.com/en-us/library/dd267265.aspx>. It's interesting to note that its IsSynchronized method (rightly) returns false.
`ConcurrentQueue<T>` is a complete ground up rewrite, creating copies ... |
107,132 | <p>As a follow up to "<a href="https://stackoverflow.com/questions/105400/what-are-indexes-and-how-can-i-use-them-to-optimize-queries-in-my-database">What are indexes and how can I use them to optimise queries in my database?</a>" where I am attempting to learn about indexes, what columns are good index candidates? Spe... | [
{
"answer_id": 107142,
"author": "Zooba",
"author_id": 891,
"author_profile": "https://Stackoverflow.com/users/891",
"pm_score": 3,
"selected": false,
"text": "<p>In general (I don't use mssql so can't comment specifically), primary keys make good indexes. They are unique and must have a... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | As a follow up to "[What are indexes and how can I use them to optimise queries in my database?](https://stackoverflow.com/questions/105400/what-are-indexes-and-how-can-i-use-them-to-optimize-queries-in-my-database)" where I am attempting to learn about indexes, what columns are good index candidates? Specifically for ... | Indexes can play an important role in query optimization and searching the results speedily from tables. The most important step is to select which columns are to be indexed. There are two major places where we can consider indexing: columns referenced in the WHERE clause and columns used in JOIN clauses. In short, suc... |
107,150 | <p>How do I capture the event of the clicking the Selected Node of a TreeView?
It doesn't fire the <strong>SelectedNodeChanged</strong> since the selection has obviously not changed but then what event can I catch so I know that the Selected Node was clicked?</p>
<p><strong>UPDATE</strong>:
When I have some time, I'm ... | [
{
"answer_id": 107298,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 3,
"selected": false,
"text": "<p>Easiest way - if it doesn't interfere with the rest of your code - is to simply set the node as not selected in the Selecte... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19377/"
] | How do I capture the event of the clicking the Selected Node of a TreeView?
It doesn't fire the **SelectedNodeChanged** since the selection has obviously not changed but then what event can I catch so I know that the Selected Node was clicked?
**UPDATE**:
When I have some time, I'm going to have to dive into the bowel... | Easiest way - if it doesn't interfere with the rest of your code - is to simply set the node as not selected in the SelectedNodeChanged method.
```
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e){
// Do whatever you're doing
TreeView1.SelectedNode.Selected = false;
}
``` |
107,160 | <p>I recently started work on a personal coding project using C++ and KDevelop. Although I started out by just hacking around, I figure it'll be better in the long run if I set up a proper unit test suite before going too much further. I've created a seperate test-runner executable as a sub project, and the tests I'v... | [
{
"answer_id": 108086,
"author": "vog",
"author_id": 19163,
"author_profile": "https://Stackoverflow.com/users/19163",
"pm_score": 3,
"selected": true,
"text": "<p>\nAlthough you <i>could</i> manipulate the default `make` target to run your tests,\nit is generally not recommended, becaus... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19491/"
] | I recently started work on a personal coding project using C++ and KDevelop. Although I started out by just hacking around, I figure it'll be better in the long run if I set up a proper unit test suite before going too much further. I've created a seperate test-runner executable as a sub project, and the tests I've add... | Although you *could* manipulate the default `make` target to run your tests,
it is generally not recommended, because every invocation of
```
make
```
would run all the tests.
You should use the "check" target instead,
which is an accepted quasi-standard among software packages.
By doing that,
the tests are only star... |
107,196 | <p>When I do a clean build my C# project, the produced dll is different then the previously built one (which I saved separately). No code changes were made, just clean and rebuild. </p>
<p>Diff shows some bytes in the DLL have changes -- few near the beginning and few near the end, but I can't figure out what these re... | [
{
"answer_id": 107202,
"author": "Slapout",
"author_id": 19072,
"author_profile": "https://Stackoverflow.com/users/19072",
"pm_score": -1,
"selected": false,
"text": "<p>Could be that the build or revision numbers have changed. </p>\n"
},
{
"answer_id": 107435,
"author": "Mag... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/838/"
] | When I do a clean build my C# project, the produced dll is different then the previously built one (which I saved separately). No code changes were made, just clean and rebuild.
Diff shows some bytes in the DLL have changes -- few near the beginning and few near the end, but I can't figure out what these represent. D... | My best guess would be the changed bytes you're seeing are the internally-used metadata columns that are automatically generated at build-time.
Some of the Ecma-335 Partition II (CLI Specification Metadata Definition) columns that can change per-build, even if the source code doesn't change at all:
* Module.Mvid: A b... |
107,292 | <p>We are starting a new SOA project with a lot of shared .net assemblies. The code for these assemblies will be stored in SVN.</p>
<p>In development phase, we would like to be able to code these assemblies as an entire solution with as little SVN 'friction' as possible. </p>
<p>When the project enters more of a ma... | [
{
"answer_id": 107308,
"author": "Vaibhav",
"author_id": 380,
"author_profile": "https://Stackoverflow.com/users/380",
"pm_score": 0,
"selected": false,
"text": "<p>What we did with shared assemblies during development phase (in a project which had loads of these), is that we put them on... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6354/"
] | We are starting a new SOA project with a lot of shared .net assemblies. The code for these assemblies will be stored in SVN.
In development phase, we would like to be able to code these assemblies as an entire solution with as little SVN 'friction' as possible.
When the project enters more of a maintenance mode, the... | What we did at our company was to set up a **tools** repository, and then a **project** repository. The **tools** repository is a Subversion repository, organized as follows:
```
/svn/tools/
vendor1/
too11/
1.0/
1.1/
latest = a copy of vendor1/tool1/1.1
tool2/
1.0/
1.5/
... |
107,294 | <p>I understand the overall meaning of pointers and references(or at least I think i do), I also understand that when I use <b>new</b> I am dynamically allocating memory.</p>
<p>My question is the following:</p>
<p>If i were to use <code>cout << &p</code>, it would display the "virtual memory location" of <... | [
{
"answer_id": 107301,
"author": "KTC",
"author_id": 12868,
"author_profile": "https://Stackoverflow.com/users/12868",
"pm_score": 4,
"selected": true,
"text": "<p>Sure, you can manipulate the pointer to access the different elements in the array, but you will need to manipulate the cont... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17162/"
] | I understand the overall meaning of pointers and references(or at least I think i do), I also understand that when I use **new** I am dynamically allocating memory.
My question is the following:
If i were to use `cout << &p`, it would display the "virtual memory location" of `p`.
Is there a way in which I could manip... | Sure, you can manipulate the pointer to access the different elements in the array, but you will need to manipulate the content of the pointer (i.e. the address of what p is pointing to), rather than the address of the pointer itself.
```
int *p = new int[3];
p[0] = 13;
p[1] = 54;
p[2] = 42;
cout << *p << ' ' << *(p+... |
107,314 | <p>We've been using selenium with great success to handle high-level website testing (in addition to extensive python doctests at a module level). However now we're using extjs for a lot of pages and its proving difficult to incorporate Selenium tests for the complex components like grids. </p>
<p>Has anyone had succ... | [
{
"answer_id": 107369,
"author": "Ryan Guest",
"author_id": 1811,
"author_profile": "https://Stackoverflow.com/users/1811",
"pm_score": 2,
"selected": false,
"text": "<p>Can you provide more insight into the types of problems you're having with extjs testing?</p>\n\n<p>One Selenium exten... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19506/"
] | We've been using selenium with great success to handle high-level website testing (in addition to extensive python doctests at a module level). However now we're using extjs for a lot of pages and its proving difficult to incorporate Selenium tests for the complex components like grids.
Has anyone had success writing... | The biggest hurdle in testing ExtJS with Selenium is that ExtJS doesn't render standard HTML elements and the Selenium IDE will naively (and rightfully) generate commands targeted at elements that just act as decor -- superfluous elements that help ExtJS with the whole desktop-look-and-feel. Here are a few tips and tri... |
107,382 | <p>I am wondering if it is possible to extract the index position in a given string where a Regex failed when trying to match it? </p>
<p>For example, if my regex was "abc" and I tried to match that with "abd" the match would fail at index 2.</p>
<p>Edit for clarification. The reason I need this is to allow me to s... | [
{
"answer_id": 107410,
"author": "Max Galkin",
"author_id": 2351099,
"author_profile": "https://Stackoverflow.com/users/2351099",
"pm_score": 1,
"selected": false,
"text": "<p>I guess such an index would only have meaning in some simple case, like in your example.</p>\n\n<p>If you'll tak... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15075/"
] | I am wondering if it is possible to extract the index position in a given string where a Regex failed when trying to match it?
For example, if my regex was "abc" and I tried to match that with "abd" the match would fail at index 2.
Edit for clarification. The reason I need this is to allow me to simplify the parsing... | I agree with Colin Younger, I don't think it is possible with the existing Regex class. However, I think it is doable if you are willing to sweat a little:
1. Get the Regex class source code
(e.g.
<http://www.codeplex.com/NetMassDownloader>
to download the .Net source).
2. Change the code to have a readonly
property w... |
107,405 | <p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin... | [
{
"answer_id": 107427,
"author": "Eevee",
"author_id": 17875,
"author_profile": "https://Stackoverflow.com/users/17875",
"pm_score": 8,
"selected": true,
"text": "<p><strong>edit</strong>: This answer works, but nowadays you should just use the <a href=\"http://docs.python-requests.org/e... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708/"
] | What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if `http://somedomain/foo/` will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without having to download ... | **edit**: This answer works, but nowadays you should just use the [requests](http://docs.python-requests.org/en/latest/index.html) library as mentioned by other answers below.
---
Use [httplib](https://docs.python.org/2/library/httplib.html).
```
>>> import httplib
>>> conn = httplib.HTTPConnection("www.google.com")... |
107,414 | <p>As a base SAS programmer, you know the drill:</p>
<p>You submit your SAS code, which contains an unbalanced quote, so now you've got not only and unclosed quote, but also unclosed comments, macro function definitions, and a missing run; or quit; statement.</p>
<p>What's your best trick for not having those unbalan... | [
{
"answer_id": 107443,
"author": "Martin Bøgelund",
"author_id": 18968,
"author_profile": "https://Stackoverflow.com/users/18968",
"pm_score": 3,
"selected": false,
"text": "<p>As for myself, I usually <a href=\"http://www.google.dk/search?q=sas+unbalanced+quote&ie=utf-8&oe=utf-8... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18968/"
] | As a base SAS programmer, you know the drill:
You submit your SAS code, which contains an unbalanced quote, so now you've got not only and unclosed quote, but also unclosed comments, macro function definitions, and a missing run; or quit; statement.
What's your best trick for not having those unbalanced quotes bother... | enterprise guide 3 used to put the following line at the top of its automatically generated code:
```
*';*";*/;run;
```
however, the only way to really "reset" from all kinds of something unbalanced problems is to quit the sas session, and balance whatever is unbalanced before re-submitting the code. Using this kind... |
107,464 | <p>There have been some questions about whether or not JavaScript is an object-oriented language. Even a statement, "just because a language has objects doesn't make it OO."</p>
<p>Is JavaScript an object-oriented language?</p>
| [
{
"answer_id": 107470,
"author": "Eli Bendersky",
"author_id": 8206,
"author_profile": "https://Stackoverflow.com/users/8206",
"pm_score": 5,
"selected": false,
"text": "<p>The short answer is Yes. For more information:</p>\n\n<p>From <a href=\"http://en.wikipedia.org/wiki/Javascript\" r... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1538/"
] | There have been some questions about whether or not JavaScript is an object-oriented language. Even a statement, "just because a language has objects doesn't make it OO."
Is JavaScript an object-oriented language? | IMO (and it is only an opinion) **the** key characteristic of an object orientated language would be that it would support [*polymorphism*](http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming). Pretty much all dynamic languages do that.
The next characteristic would be [*encapsulation*](http://en.... |
107,546 | <p>I need to implement auto-capitalization inside of a Telerik RadEditor control on an ASPX page as a user types.</p>
<p>This can be an IE specific solution (IE6+).</p>
<p>I currently capture every keystroke (down/up) as the user types to support a separate feature called "macros" that are essentially short keywords ... | [
{
"answer_id": 107632,
"author": "OJ.",
"author_id": 611,
"author_profile": "https://Stackoverflow.com/users/611",
"pm_score": 3,
"selected": false,
"text": "<p>Have you tried to apply the <a href=\"http://www.w3.org/TR/CSS2/text.html#caps-prop\" rel=\"noreferrer\">text-transform</a> CSS... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2742/"
] | I need to implement auto-capitalization inside of a Telerik RadEditor control on an ASPX page as a user types.
This can be an IE specific solution (IE6+).
I currently capture every keystroke (down/up) as the user types to support a separate feature called "macros" that are essentially short keywords that expand into ... | I'm not sure if this is what you're trying to do, but here is a function ([reference](http://individed.com/code/to-title-case/js/to-title-case.js)) to convert a given string to title case:
```
function toTitleCase(str) {
return str.replace(/([\w&`'‘’"“.@:\/\{\(\[<>_]+-? *)/g, function(match, p1, index, title... |
107,549 | <p>When we compile a dll using __stdcall inside visual studio 2008 the compiled function names inside the dll are.</p>
<p>FunctionName</p>
<p>Though when we compile the same dll using GCC using wx-dev-cpp GCC appends the number of paramers the function has, so the name of the function using Dependency walker looks li... | [
{
"answer_id": 107564,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 4,
"selected": true,
"text": "<p>__stdcall decorates the function name by adding an underscore to the start, and the number of bytes of parameters ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17382/"
] | When we compile a dll using \_\_stdcall inside visual studio 2008 the compiled function names inside the dll are.
FunctionName
Though when we compile the same dll using GCC using wx-dev-cpp GCC appends the number of paramers the function has, so the name of the function using Dependency walker looks like.
FunctionNa... | \_\_stdcall decorates the function name by adding an underscore to the start, and the number of bytes of parameters to the end (separated by @).
So, a function:
```
void __stdcall Foo(int a, int b);
```
...would become \_Foo@8.
If you list the function name (undecorated) in the EXPORTS section of your .DEF file, i... |
107,562 | <p>I'm trying to install faac and am running into errors. Here are the errors I get when trying to build it:</p>
<hr>
<pre><code>[root@test faac]# ./bootstrap
configure.in:11: warning: underquoted definition of MY_DEFINE
run info '(automake)Extending aclocal'
or see http://sources.redhat.com/automake/automake.ht... | [
{
"answer_id": 107592,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 2,
"selected": false,
"text": "<p>I think the first thing to check is that you have libtool installed.</p>\n\n<p>Edit:</p>\n\n<p>This is what I get ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to install faac and am running into errors. Here are the errors I get when trying to build it:
---
```
[root@test faac]# ./bootstrap
configure.in:11: warning: underquoted definition of MY_DEFINE
run info '(automake)Extending aclocal'
or see http://sources.redhat.com/automake/automake.html#Extending-acl... | I think the first thing to check is that you have libtool installed.
Edit:
This is what I get on Ubuntu 8.04:
```
$ ./bootstrap
configure.in:11: warning: underquoted definition of MY_DEFINE
configure.in:11: run info '(automake)Extending aclocal'
configure.in:11: or see http://sources.redhat.com/automake/automak... |
107,611 | <p>I need to load some fonts temporarily in my program. Preferably from a dll resource file.</p>
| [
{
"answer_id": 107702,
"author": "Brian Matthews",
"author_id": 1969,
"author_profile": "https://Stackoverflow.com/users/1969",
"pm_score": 2,
"selected": false,
"text": "<p>I found <a href=\"http://www.eggheadcafe.com/software/aspnet/30018713/load-font-from-resource.aspx\" rel=\"nofollo... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13219/"
] | I need to load some fonts temporarily in my program. Preferably from a dll resource file. | And here a Delphi version:
```
procedure LoadFontFromDll(const DllName, FontName: PWideChar);
var
DllHandle: HMODULE;
ResHandle: HRSRC;
ResSize, NbFontAdded: Cardinal;
ResAddr: HGLOBAL;
begin
DllHandle := LoadLibrary(DllName);
if DllHandle = 0 then
RaiseLastOSError;
ResHandle := FindResource(DllHandl... |
107,660 | <p>What is the best (regarding performance) way to compute the critical path of a directional acyclic graph when the nodes of the graph have weight?</p>
<p>For example, if I have the following structure:</p>
<pre><code> Node A (weight 3)
/ \
Node B (weight 4) Node D (wei... | [
{
"answer_id": 107680,
"author": "Aleksandar Dimitrov",
"author_id": 11797,
"author_profile": "https://Stackoverflow.com/users/11797",
"pm_score": 3,
"selected": true,
"text": "<p>I have no clue about \"critical paths\", but I assume you mean <a href=\"http://en.wikipedia.org/wiki/Critic... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19331/"
] | What is the best (regarding performance) way to compute the critical path of a directional acyclic graph when the nodes of the graph have weight?
For example, if I have the following structure:
```
Node A (weight 3)
/ \
Node B (weight 4) Node D (weight 7)
/ ... | I have no clue about "critical paths", but I assume you mean [this](http://en.wikipedia.org/wiki/Critical_path_method).
Finding the longest path in an acyclic graph with weights is only possible by traversing the whole tree and then comparing the lengths, as you never really know how the rest of the tree is weighted. ... |
107,674 | <p>I'd like to build a real quick and dirty administrative backend for a Ruby on Rails application I have been attached to at the last minute. I've looked at activescaffold and streamlined and think they are both very attractive and they should be simple to get running, but I don't quite understand how to set up either... | [
{
"answer_id": 107715,
"author": "Toby Hede",
"author_id": 14971,
"author_profile": "https://Stackoverflow.com/users/14971",
"pm_score": 3,
"selected": false,
"text": "<p>I have used Streamlined pretty extensively.</p>\n\n<p>To get Streamline working you create your own controllers - so ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6805/"
] | I'd like to build a real quick and dirty administrative backend for a Ruby on Rails application I have been attached to at the last minute. I've looked at activescaffold and streamlined and think they are both very attractive and they should be simple to get running, but I don't quite understand how to set up either on... | I think namespaces is the solution to the problem you have here:
```
map.namespace :admin do |admin|
admin.resources :customers
end
```
Which will create routes `admin_customers`, `new_admin_customers`, etc.
Then inside the `app/controller` directory you can have an `admin` directory. Inside your admin director... |
107,675 | <p>I'd like to unit test responses from the Google App Engine webapp.WSGIApplication, for example request the url '/' and test that the responses status code is 200, using <a href="http://code.google.com/p/gaeunit" rel="noreferrer">GAEUnit</a>. How can I do this? </p>
<p>I'd like to use the webapp framework and GAEUni... | [
{
"answer_id": 107753,
"author": "David Coffin",
"author_id": 13049,
"author_profile": "https://Stackoverflow.com/users/13049",
"pm_score": 2,
"selected": false,
"text": "<p>Actually WebTest does work within the sandbox, as long as you comment out </p>\n\n<pre><code>import webbrowser\n</... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13049/"
] | I'd like to unit test responses from the Google App Engine webapp.WSGIApplication, for example request the url '/' and test that the responses status code is 200, using [GAEUnit](http://code.google.com/p/gaeunit). How can I do this?
I'd like to use the webapp framework and GAEUnit, which runs within the App Engine sa... | I have added a [sample application](http://code.google.com/p/gaeunit/source/browse/#svn/trunk/sample_app) to the GAEUnit project which demonstrates how to write and execute a web test using GAEUnit. The sample includes a slightly modified version of the '[webtest](http://pythonpaste.org/webtest/index.html)' module ('im... |
107,693 | <p>I'm having trouble with global variables in php. I have a <code>$screen</code> var set in one file, which requires another file that calls an <code>initSession()</code> defined in yet another file. The <code>initSession()</code> declares <code>global $screen</code> and then processes $screen further down using the v... | [
{
"answer_id": 107698,
"author": "finnw",
"author_id": 12048,
"author_profile": "https://Stackoverflow.com/users/12048",
"pm_score": 3,
"selected": false,
"text": "<p>You need to put \"global $screen\" in every function that references it, not just at the top of each file.</p>\n"
},
... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10583/"
] | I'm having trouble with global variables in php. I have a `$screen` var set in one file, which requires another file that calls an `initSession()` defined in yet another file. The `initSession()` declares `global $screen` and then processes $screen further down using the value set in the very first script.
How is this... | `Global` DOES NOT make the variable global. I know it's tricky :-)
`Global` says that a local variable will be used *as if it was a variable with a higher scope*.
E.G :
```
<?php
$var = "test"; // this is accessible in all the rest of the code, even an included one
function foo2()
{
global $var;
echo $var;... |
107,701 | <p>How can I remove those annoying Mac OS X <code>.DS_Store</code> files from a Git repository?</p>
| [
{
"answer_id": 107703,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 3,
"selected": false,
"text": "<p>This will work:</p>\n\n<pre><code>find . -name \"*.DS_Store\" -type f -exec git-rm {} \\;\n</code></pre>\n\n<p>It del... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1450/"
] | How can I remove those annoying Mac OS X `.DS_Store` files from a Git repository? | Remove existing `.DS_Store` files from the repository:
```
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
```
Add this line:
```
.DS_Store
```
to the file `.gitignore`, which can be found at the top level of your repository (or create the file if it isn't there already). You can do this easi... |
107,705 | <p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p>
<p>If the answer is positive, what are all the ways to disable it?</p>
<p>Suggestions so far:</p>
<ol>
<li>Use the <code>-u</code> command line switch</li>
<li>Wrap <code>sys.stdout</code> in an object that flushes aft... | [
{
"answer_id": 107717,
"author": "Seb",
"author_id": 189,
"author_profile": "https://Stackoverflow.com/users/189",
"pm_score": 10,
"selected": true,
"text": "<p>From <a href=\"http://mail.python.org/pipermail/tutor/2003-November/026645.html\" rel=\"nofollow noreferrer\">Magnus Lycka answ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] | Is output buffering enabled by default in Python's interpreter for `sys.stdout`?
If the answer is positive, what are all the ways to disable it?
Suggestions so far:
1. Use the `-u` command line switch
2. Wrap `sys.stdout` in an object that flushes after every write
3. Set `PYTHONUNBUFFERED` env var
4. `sys.stdout = ... | From [Magnus Lycka answer on a mailing list](http://mail.python.org/pipermail/tutor/2003-November/026645.html):
>
> You can skip buffering for a whole
> python process using `python -u`
> or by
> setting the environment variable
> PYTHONUNBUFFERED.
>
>
> You could also replace sys.stdout with
> some other stream li... |
107,772 | <p>From my understanding the XMPP protocol is based on an always-on connection where you have no, immediate, indication of when an XML message ends.</p>
<p>This means you have to evaluate the stream as it comes. This also means that, probably, you have to deal with asynchronous connections since the socket can block ... | [
{
"answer_id": 107820,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Igniterealtime.org provides an open source XMPP-server and client written in java</p>\n"
},
{
"answer_id": 108307,
... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167/"
] | From my understanding the XMPP protocol is based on an always-on connection where you have no, immediate, indication of when an XML message ends.
This means you have to evaluate the stream as it comes. This also means that, probably, you have to deal with asynchronous connections since the socket can block in the midd... | Are you wanting to deal with multiple connections at once? Good asynch socket processing is a must in that case, to avoid one thread per connection.
Otherwise, you just need an XML parser that can deal with a chunk of bytes at a time. [Expat](http://expat.sourceforge.net/) is the canonical example; if you're in Java, ... |
107,823 | <p>(Jeopardy-style question, I wish the answer had been online when I had this issue)</p>
<p>Using Java 1.4, I have a method that I want to run as a thread some of the time, but not at others. So I declared it as a subclass of Thread, then either called start() or run() depending on what I needed.</p>
<p>But I found ... | [
{
"answer_id": 107832,
"author": "slim",
"author_id": 7512,
"author_profile": "https://Stackoverflow.com/users/7512",
"pm_score": 7,
"selected": true,
"text": "<p>This is a known bug in Java 1.4:\n<a href=\"http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=5869e03fee226ffffffffc40d4... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7512/"
] | (Jeopardy-style question, I wish the answer had been online when I had this issue)
Using Java 1.4, I have a method that I want to run as a thread some of the time, but not at others. So I declared it as a subclass of Thread, then either called start() or run() depending on what I needed.
But I found that my program w... | This is a known bug in Java 1.4:
<http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=5869e03fee226ffffffffc40d4fa881a86e3:WuuT?bug_id=4533087>
It's fixed in Java 1.5 but Sun doesn't intend to fix it in 1.4.
The issue is that, at construction time, a `Thread` is added to a list of references in an internal thread ... |
107,828 | <p>I don't want <code>PHP</code> errors to display /html, but I want them to display in <code>/html/beta/usercomponent</code>. Everything is set up so that errors do not display at all. How can I get errors to just show up in that one folder (and its subfolders)?</p>
| [
{
"answer_id": 107841,
"author": "Internet Friend",
"author_id": 18037,
"author_profile": "https://Stackoverflow.com/users/18037",
"pm_score": 0,
"selected": false,
"text": "<p><strike>I don't believe there's a simple answer to this</strike>, but I'd certainly want to be proven wrong.</... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I don't want `PHP` errors to display /html, but I want them to display in `/html/beta/usercomponent`. Everything is set up so that errors do not display at all. How can I get errors to just show up in that one folder (and its subfolders)? | In `.htaccess`:
```none
php_value error_reporting 2147483647
```
This number, according to documentation should enable 'all' errors irrespective of version, if you want a more granular setting, manually OR the values together, or run
```bash
php -r 'echo E_ALL | E_STRICT ;'
```
to let php compute the value for y... |
107,872 | <p>I have <a href="http://laconi.ca/trac/" rel="nofollow noreferrer">Laconica</a> (self hosted <a href="http://twitter.com/home" rel="nofollow noreferrer">twitter</a>) configured on my local intranet and would like to integrate the public stream into SharePoint site with a web part. How can I do this?</p>
| [
{
"answer_id": 107874,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 4,
"selected": true,
"text": "<p>You can point an RSS Viewer web part at the laconi.ca public stream RSS feed and use this XSLT to ensure attractiv... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | I have [Laconica](http://laconi.ca/trac/) (self hosted [twitter](http://twitter.com/home)) configured on my local intranet and would like to integrate the public stream into SharePoint site with a web part. How can I do this? | You can point an RSS Viewer web part at the laconi.ca public stream RSS feed and use this XSLT to ensure attractive output.
**Result screen shot:**
[](https://i.stack.imgur.com/dMlja.jpg)
**XSL transform:**
```
<xsl:... |
107,903 | <p>On Mac OS X, you can create a zip archive from the Finder by selecting some files and selecting "Compress" from the contextual menu or the File menu. Unfortunately, the resulting file is not identical to the archive created by the <code>zip</code> command (with the default options).</p>
<p>This distinction matters... | [
{
"answer_id": 107920,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>The clue's in the tag 'automation'.</p>\n\n<p>Create an action in Automator.app that uses the 'Create Archive' action, invo... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10947/"
] | On Mac OS X, you can create a zip archive from the Finder by selecting some files and selecting "Compress" from the contextual menu or the File menu. Unfortunately, the resulting file is not identical to the archive created by the `zip` command (with the default options).
This distinction matters to at least one servi... | Use the ditto command-line tool as follows:
```
ditto -ck --rsrc --sequesterRsrc folder file.zip
```
See the [ditto man page](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/ditto.1.html) for more. |
107,936 | <p>Is there a way to add some custom font on a website without using images, <a href="http://en.wikipedia.org/wiki/Adobe_Flash" rel="noreferrer">Flash</a> or some other graphics?</p>
<p>For example, I was working on a wedding website, and I found a lot of nice fonts for that subject. But I can't find the right way to ... | [
{
"answer_id": 107945,
"author": "Casper",
"author_id": 18729,
"author_profile": "https://Stackoverflow.com/users/18729",
"pm_score": 3,
"selected": false,
"text": "<p>Or you could try <a href=\"http://en.wikipedia.org/wiki/Scalable_Inman_Flash_Replacement\" rel=\"nofollow noreferrer\">s... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16039/"
] | Is there a way to add some custom font on a website without using images, [Flash](http://en.wikipedia.org/wiki/Adobe_Flash) or some other graphics?
For example, I was working on a wedding website, and I found a lot of nice fonts for that subject. But I can't find the right way to add that font on the server. And how d... | This could be done via CSS:
```
<style type="text/css">
@font-face {
font-family: "My Custom Font";
src: url(http://www.example.org/mycustomfont.ttf) format("truetype");
}
p.customfont {
font-family: "My Custom Font", Verdana, Tahoma;
}
</style>
<p class="customfont">Hello world!</p>
```
It is [supporte... |
107,964 | <p>I am using YUI reset/base, after the reset it sets the <code>ul</code> and <code>li</code> tags to list-style: disc outside;</p>
<p>My markup looks like this:</p>
<pre><code><div id="nav">
<ul class="links">
<li><a href="">Testing</a></li>
</ul>
</di... | [
{
"answer_id": 107965,
"author": "Matt",
"author_id": 17759,
"author_profile": "https://Stackoverflow.com/users/17759",
"pm_score": 1,
"selected": false,
"text": "<p>shouldn't it be:</p>\n\n<pre><code>#nav ul.links\n</code></pre>\n"
},
{
"answer_id": 107969,
"author": "unexis... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] | I am using YUI reset/base, after the reset it sets the `ul` and `li` tags to list-style: disc outside;
My markup looks like this:
```
<div id="nav">
<ul class="links">
<li><a href="">Testing</a></li>
</ul>
</div>
```
My CSS is:
```
#nav {}
#nav ul li {
list-style: none;
}
```
Now that ma... | I think that Dan was close with his answer, but this isn't an issue of specificity. **You can set the list-style on the list (the UL) but you can also override that list-style for individual list items (the LIs).**
You are telling the browser to not use bullets on the list, but YUI tells the browser to use them on ind... |
107,971 | <p>I'm using the following JavaScript code:</p>
<pre><code><script language="JavaScript1.2" type="text/javascript">
function CreateBookmarkLink(title, url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {
window.external.AddFavorite( url, tit... | [
{
"answer_id": 107985,
"author": "Per Hornshøj-Schierbeck",
"author_id": 11619,
"author_profile": "https://Stackoverflow.com/users/11619",
"pm_score": 0,
"selected": false,
"text": "<p>You have a special case for </p>\n\n<pre><code>if (window.sidebar) \n</code></pre>\n\n<p>and then a bra... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18922/"
] | I'm using the following JavaScript code:
```
<script language="JavaScript1.2" type="text/javascript">
function CreateBookmarkLink(title, url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {
window.external.AddFavorite( url, title); }
else if(w... | I think that's the only solution for Firefox... I have a better function for that action, it works even for Opera and shows a message for other "unsupported" browsers.
```
<script type="text/javascript">
function addBookmark(url,name){
if(window.sidebar && window.sidebar.addPanel) {
window.sidebar.addPanel... |
107,972 | <p>Is it possible under any set of circumstances to be able to accomplish this?</p>
<p>My current circumstances are this:</p>
<pre><code>public class CustomForm : Form
{
public class CustomGUIElement
{
...
public event MouseEventHandler Click;
// etc, and so forth.
...
}
priva... | [
{
"answer_id": 107978,
"author": "Per Hornshøj-Schierbeck",
"author_id": 11619,
"author_profile": "https://Stackoverflow.com/users/11619",
"pm_score": 1,
"selected": false,
"text": "<p>You really should wrap the code you want to be able to execute from the outside in a method. That metho... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] | Is it possible under any set of circumstances to be able to accomplish this?
My current circumstances are this:
```
public class CustomForm : Form
{
public class CustomGUIElement
{
...
public event MouseEventHandler Click;
// etc, and so forth.
...
}
private List<CustomGUIElem... | You just need to add a public method for invoking the event. Microsoft already does this for some events such as *PerformClick* for controls that expose a *Click* event.
```
public class CustomGUIElement
{
public void PerformClick()
{
OnClick(EventArgs.Empty);
}
protected virtual void OnCl... |
107,984 | <p>In toad, I can see unicode characters that are coming from oracle db. But when I click one of the fields in the data grid into the edit mode, the unicode characters are converted to meaningless symbols, but this is not the big issue.</p>
<p>While editing this field, the unicode characters are displayed correctly as... | [
{
"answer_id": 107978,
"author": "Per Hornshøj-Schierbeck",
"author_id": 11619,
"author_profile": "https://Stackoverflow.com/users/11619",
"pm_score": 1,
"selected": false,
"text": "<p>You really should wrap the code you want to be able to execute from the outside in a method. That metho... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | In toad, I can see unicode characters that are coming from oracle db. But when I click one of the fields in the data grid into the edit mode, the unicode characters are converted to meaningless symbols, but this is not the big issue.
While editing this field, the unicode characters are displayed correctly as I type. B... | You just need to add a public method for invoking the event. Microsoft already does this for some events such as *PerformClick* for controls that expose a *Click* event.
```
public class CustomGUIElement
{
public void PerformClick()
{
OnClick(EventArgs.Empty);
}
protected virtual void OnCl... |
107,995 | <p>The <code>unzip</code> command doesn't have an option for recursively unzipping archives.</p>
<p>If I have the following directory structure and archives:</p>
<pre>
/Mother/Loving.zip
/Scurvy/Sea Dogs.zip
/Scurvy/Cures/Limes.zip
</pre>
<p>And I want to unzip all of the archives into directories with the same name... | [
{
"answer_id": 107999,
"author": "chuckrector",
"author_id": 10645,
"author_profile": "https://Stackoverflow.com/users/10645",
"pm_score": 5,
"selected": false,
"text": "<p>Here's one solution that extracts all zip files to the <em>working directory</em> and involves the find command and... | 2008/09/20 | [
"https://Stackoverflow.com/questions/107995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10645/"
] | The `unzip` command doesn't have an option for recursively unzipping archives.
If I have the following directory structure and archives:
```
/Mother/Loving.zip
/Scurvy/Sea Dogs.zip
/Scurvy/Cures/Limes.zip
```
And I want to unzip all of the archives into directories with the same name as each archive:
```
/Mother... | If you want to extract the files to the respective folder you can try this
```
find . -name "*.zip" | while read filename; do unzip -o -d "`dirname "$filename"`" "$filename"; done;
```
A multi-processed version for systems that can handle high I/O:
```
find . -name "*.zip" | xargs -P 5 -I fileName sh -c 'unzip -o -... |
108,005 | <p>first question here. I'm developing a program in C# (.NET 3.5) that displays files in a listview. I'd like to have the "large icon" view display the icon that Windows Explorer uses for that filetype, otherwise I'll have to use some existing code like this:</p>
<pre><code> private int getFileTypeIconIndex(str... | [
{
"answer_id": 108015,
"author": "blowdart",
"author_id": 2525,
"author_profile": "https://Stackoverflow.com/users/2525",
"pm_score": 3,
"selected": false,
"text": "<p>The file icons are held in the registry. It's a little convoluted but it works something like</p>\n\n<ul>\n<li>Take the ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14333/"
] | first question here. I'm developing a program in C# (.NET 3.5) that displays files in a listview. I'd like to have the "large icon" view display the icon that Windows Explorer uses for that filetype, otherwise I'll have to use some existing code like this:
```
private int getFileTypeIconIndex(string fileName)
... | You might find the use of [Icon.ExtractAssociatedIcon](http://msdn.microsoft.com/en-us/library/system.drawing.icon.extractassociatedicon.aspx) a much simpler (an managed) approach than using SHGetFileInfo. But watch out: two files with the same extension may have different icons. |
108,009 | <p>I'm writing a C parser using PLY, and recently ran into a problem.
This code:</p>
<pre><code>typedef int my_type;
my_type x;
</code></pre>
<p>Is correct C code, because my_type is defined as a type previously to
being used as such. I handle it by filling a type symbol table in the
parser that gets used by the lexe... | [
{
"answer_id": 108033,
"author": "Mike G.",
"author_id": 18901,
"author_profile": "https://Stackoverflow.com/users/18901",
"pm_score": 1,
"selected": false,
"text": "<p>I think you need to move the check for whether an ID is a TYPEID from c_lexer.py to c_parser.py.</p>\n\n<p>As you said,... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] | I'm writing a C parser using PLY, and recently ran into a problem.
This code:
```
typedef int my_type;
my_type x;
```
Is correct C code, because my\_type is defined as a type previously to
being used as such. I handle it by filling a type symbol table in the
parser that gets used by the lexer to differentiate betwee... | With [some help](http://groups.google.com/group/ply-hack/tree/browse_frm/thread/cf31e8334801eabd/b9cdf4a6682635c1?rnum=1&_done=%2Fgroup%2Fply-hack%2Fbrowse_frm%2Fthread%2Fcf31e8334801eabd%3F#doc_5c415da045e77a6e) from Dave Beazley (PLY's creator), my problem was solved.
The idea is to use special sub-rules and do the ... |
108,010 | <p>Greetings.</p>
<p>I'm looking for a way to parse a number of XML files in a particular directory with ASP.NET (C#). I'd like to be able to return content from particular elements, but before that, need to find those that have a certain value between an element.</p>
<p>Example XML file 1:</p>
<pre><code><file&g... | [
{
"answer_id": 108012,
"author": "Per Hornshøj-Schierbeck",
"author_id": 11619,
"author_profile": "https://Stackoverflow.com/users/11619",
"pm_score": 1,
"selected": false,
"text": "<p>Use XPath?<br>\n<a href=\"http://www.w3schools.com/XPath/default.asp\" rel=\"nofollow noreferrer\">http... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11912/"
] | Greetings.
I'm looking for a way to parse a number of XML files in a particular directory with ASP.NET (C#). I'd like to be able to return content from particular elements, but before that, need to find those that have a certain value between an element.
Example XML file 1:
```
<file>
<title>Title 1</title>
... | If you are using .Net 3.5, this is extremely easy with LINQ:
```
//get the files
XElement xe1 = XElement.Load(string_file_path_1);
XElement xe2 = XElement.Load(string_file_path_2);
//Give me all XML that has a filter of 'filter'.
var filter_elements1 = from p in xe1.Descendants("filter") select p;
var filter_elements... |
108,081 | <p>Are there any good, cross platform (SBCL and CLISP at the very least) easy to install GUI libraries?</p>
| [
{
"answer_id": 108142,
"author": "Matthias Benkard",
"author_id": 15517,
"author_profile": "https://Stackoverflow.com/users/15517",
"pm_score": 6,
"selected": true,
"text": "<p><a href=\"http://www.peter-herth.de/ltk/\" rel=\"noreferrer\">Ltk</a> is quite popular, very portable, and reas... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7780/"
] | Are there any good, cross platform (SBCL and CLISP at the very least) easy to install GUI libraries? | [Ltk](http://www.peter-herth.de/ltk/) is quite popular, very portable, and reasonably well documented through the Tk docs. Installation on SBCL is as easy as saying:
```
(require :asdf-install)
(asdf-install:install :ltk)
```
There's also [Cells-Gtk](http://common-lisp.net/project/cells-gtk/), which is reported to b... |
108,094 | <p>Is there anyway to disable the rather annoying feature that Visual Studio (2008 in my case) has of copying the line (with text on it) the cursor is on when <kbd>CTRL</kbd>-<kbd>C</kbd> is pressed and no selection is made?</p>
<p>I know of the option to disable copying blank lines. But this is driving me crazy as we... | [
{
"answer_id": 108139,
"author": "devinmoore",
"author_id": 15950,
"author_profile": "https://Stackoverflow.com/users/15950",
"pm_score": 1,
"selected": false,
"text": "<p>I'm pretty sure the way to do it in 2008 is the same as the way in 2005... check out this tutorial on 'customizing k... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4192/"
] | Is there anyway to disable the rather annoying feature that Visual Studio (2008 in my case) has of copying the line (with text on it) the cursor is on when `CTRL`-`C` is pressed and no selection is made?
I know of the option to disable copying blank lines. But this is driving me crazy as well.
ETA: I'm not looking to... | If you aren't willing to customize the keyboard settings, then `Ctrl`+`C` will always be Edit.Copy, which will copy the current line if nothing is selected. If you aren't willing to use the tools VS provides to customize the interface, then you can't do it.
However, the following works:
Assign this macro to `Ctrl`+`C... |
108,104 | <p>Once again one of those: "Is there an easier built-in way of doing things instead of my helper method?"</p>
<p>So it's easy to get the underlying type from a nullable type, but how do I get the nullable version of a .NET type?</p>
<p>So I have</p>
<pre><code>typeof(int)
typeof(DateTime)
System.Type t = something;... | [
{
"answer_id": 108122,
"author": "Alex Lyman",
"author_id": 5897,
"author_profile": "https://Stackoverflow.com/users/5897",
"pm_score": 8,
"selected": true,
"text": "<p>Here is the code I use:</p>\n\n<pre><code>Type GetNullableType(Type type) {\n // Use Nullable.GetUnderlyingType() to... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5790/"
] | Once again one of those: "Is there an easier built-in way of doing things instead of my helper method?"
So it's easy to get the underlying type from a nullable type, but how do I get the nullable version of a .NET type?
So I have
```
typeof(int)
typeof(DateTime)
System.Type t = something;
```
and I want
```
int? ... | Here is the code I use:
```
Type GetNullableType(Type type) {
// Use Nullable.GetUnderlyingType() to remove the Nullable<T> wrapper if type is already nullable.
type = Nullable.GetUnderlyingType(type) ?? type; // avoid type becoming null
if (type.IsValueType)
return typeof(Nullable<>).MakeGenericTy... |
108,134 | <p>I am using <code>pyexcelerator</code> Python module to generate Excel files.
I want to apply bold style to part of cell text, but not to the whole cell.
How to do it?</p>
| [
{
"answer_id": 108204,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 2,
"selected": false,
"text": "<p>This is an example from Excel documentation:</p>\n\n<pre><code>With Worksheets(\"Sheet1\").Range(\"B1\")\n .Value = \"New... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19607/"
] | I am using `pyexcelerator` Python module to generate Excel files.
I want to apply bold style to part of cell text, but not to the whole cell.
How to do it? | This is an example from Excel documentation:
```
With Worksheets("Sheet1").Range("B1")
.Value = "New Title"
.Characters(5, 5).Font.Bold = True
End With
```
So the Characters property of the cell you want to manipulate is the answer to your question. It's used as Characters(*start*, *length*).
PS: I've never... |
108,169 | <p>Given a list, how would I select a new list, containing a slice of the original list (Given offset and number of elements) ?</p>
<h3>EDIT:</h3>
<p>Good suggestions so far. Isn't there something specified in one of the SRFI's? This appears to be a very fundamental thing, so I'm surprised that I need to implement it i... | [
{
"answer_id": 108248,
"author": "dsm",
"author_id": 7780,
"author_profile": "https://Stackoverflow.com/users/7780",
"pm_score": 4,
"selected": true,
"text": "<p>The following code will do what you want:</p>\n\n<pre><code>(define get-n-items\n (lambda (lst num)\n (if (> num ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18180/"
] | Given a list, how would I select a new list, containing a slice of the original list (Given offset and number of elements) ?
### EDIT:
Good suggestions so far. Isn't there something specified in one of the SRFI's? This appears to be a very fundamental thing, so I'm surprised that I need to implement it in user-land. | The following code will do what you want:
```
(define get-n-items
(lambda (lst num)
(if (> num 0)
(cons (car lst) (get-n-items (cdr lst) (- num 1)))
'()))) ;'
(define slice
(lambda (lst start count)
(if (> start 1)
(slice (cdr lst) (- start 1) count)
... |
108,183 | <p>I have a small server program that accepts connections on a TCP or local UNIX socket, reads a simple command and (depending on the command) sends a reply.</p>
<p>The problem is that the client may have no interest in the answer and sometimes exits early. So writing to that socket will cause a <code>SIGPIPE</code> a... | [
{
"answer_id": 108190,
"author": "Sam Reynolds",
"author_id": 9192,
"author_profile": "https://Stackoverflow.com/users/9192",
"pm_score": 3,
"selected": false,
"text": "<blockquote>\n <p>Or should I just catch the SIGPIPE with a handler and ignore it?</p>\n</blockquote>\n\n<p>I believe ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12523/"
] | I have a small server program that accepts connections on a TCP or local UNIX socket, reads a simple command and (depending on the command) sends a reply.
The problem is that the client may have no interest in the answer and sometimes exits early. So writing to that socket will cause a `SIGPIPE` and make my server cra... | You generally want to ignore the `SIGPIPE` and handle the error directly in your code. This is because signal handlers in C have many restrictions on what they can do.
The most portable way to do this is to set the `SIGPIPE` handler to `SIG_IGN`. This will prevent any socket or pipe write from causing a `SIGPIPE` sign... |
108,193 | <pre><code>class Tag(models.Model):
name = models.CharField(maxlength=100)
class Blog(models.Model):
name = models.CharField(maxlength=100)
tags = models.ManyToManyField(Tag)
</code></pre>
<p>Simple models just to ask my question.</p>
<p>I wonder how can i query blogs using tags in two different ways.</p>
<u... | [
{
"answer_id": 108404,
"author": "Clint Ecker",
"author_id": 13668,
"author_profile": "https://Stackoverflow.com/users/13668",
"pm_score": 6,
"selected": true,
"text": "<p>You could use Q objects for #1:</p>\n\n<pre><code># Blogs who have either hockey or django tags.\nfrom django.db.mod... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12785/"
] | ```
class Tag(models.Model):
name = models.CharField(maxlength=100)
class Blog(models.Model):
name = models.CharField(maxlength=100)
tags = models.ManyToManyField(Tag)
```
Simple models just to ask my question.
I wonder how can i query blogs using tags in two different ways.
* Blog entries that are tagged w... | You could use Q objects for #1:
```
# Blogs who have either hockey or django tags.
from django.db.models import Q
Blog.objects.filter(
Q(tags__name__iexact='hockey') | Q(tags__name__iexact='django')
)
```
Unions and intersections, I believe, are a bit outside the scope of the Django ORM, but its possible to to t... |
108,200 | <p>I need to store the timezone an email was sent from. Which is the best way to extract it from the email's 'Date:' header (an RFC822 date)? And what is the recommended format to store it in the database (I'm using hibernate)?</p>
| [
{
"answer_id": 108220,
"author": "Joshua",
"author_id": 6013,
"author_profile": "https://Stackoverflow.com/users/6013",
"pm_score": 0,
"selected": false,
"text": "<p>Extract the data from the header using some sort of substring or regular expression. Parse the date with a SimpleDateForma... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15231/"
] | I need to store the timezone an email was sent from. Which is the best way to extract it from the email's 'Date:' header (an RFC822 date)? And what is the recommended format to store it in the database (I'm using hibernate)? | Probably easiest to parse with JodaTime as it supports ISO8601 see [Date and Time Parsing and Formatting in Java with Joda Time](http://johannburkard.de/blog/programming/java/date-time-parsing-formatting-joda-time.html).
```
DateTimeFormatter parser2 = ISODateTimeFormat.dateTimeNoMillis();
System.out.println(parser2.p... |
108,207 | <p>I want the search box on my web page to display the word "Search" in gray italics. When the box receives focus, it should look just like an empty text box. If there is already text in it, it should display the text normally (black, non-italics). This will help me avoid clutter by removing the label.</p>
<p>BTW, thi... | [
{
"answer_id": 108218,
"author": "levik",
"author_id": 4465,
"author_profile": "https://Stackoverflow.com/users/4465",
"pm_score": 4,
"selected": false,
"text": "<p>You can add and remove a special CSS class and modify the input value <code>onfocus</code>/<code>onblur</code> with JavaScr... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7668/"
] | I want the search box on my web page to display the word "Search" in gray italics. When the box receives focus, it should look just like an empty text box. If there is already text in it, it should display the text normally (black, non-italics). This will help me avoid clutter by removing the label.
BTW, this is an on... | Another option, if you're happy to have this feature only for newer browsers, is to use the support offered by HTML 5's **placeholder** attribute:
```
<input name="email" placeholder="Email Address">
```
In the absence of any styles, in Chrome this looks like:
[ I want to then initia... | [
{
"answer_id": 108227,
"author": "Simon Johnson",
"author_id": 854,
"author_profile": "https://Stackoverflow.com/users/854",
"pm_score": 9,
"selected": true,
"text": "<p>This will depend on the database but for SQL Server, this could be achieved as follows:</p>\n\n<pre><code>alter table ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/384/"
] | I want to add a *column* to an existing legacy *database* and write a *procedure* by which I can assign each record a different value. Something like adding a *column* and autogenerate the data for it.
Like, if I add a new *column* called "ID" (number) I want to then initialize a unique value to each of the records. S... | This will depend on the database but for SQL Server, this could be achieved as follows:
```
alter table Example
add NewColumn int identity(1,1)
``` |
108,251 | <p>On my VPS server (Fedora 9), mingetty keeps respawning itself because of a "permission denied" error on tty[1-6], even though:</p>
<pre>
root# ls -la /dev/tty1
crw------- 1 root root 4, 1 Sep 19 14:22 /dev/tty1
</pre>
<p>Even weirder, this doesn't work:</p>
<pre>
root# cat </dev/tty1
bash: /dev/tty1: Permissio... | [
{
"answer_id": 108442,
"author": "Martin OConnor",
"author_id": 18233,
"author_profile": "https://Stackoverflow.com/users/18233",
"pm_score": 1,
"selected": false,
"text": "<p>I suspect that SELinux may be the problem. Try temporarily disabling it to see if it works.</p>\n"
},
{
... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19627/"
] | On my VPS server (Fedora 9), mingetty keeps respawning itself because of a "permission denied" error on tty[1-6], even though:
```
root# ls -la /dev/tty1
crw------- 1 root root 4, 1 Sep 19 14:22 /dev/tty1
```
Even weirder, this doesn't work:
```
root# cat </dev/tty1
bash: /dev/tty1: Permission denied
```
I am g... | I suspect that SELinux may be the problem. Try temporarily disabling it to see if it works. |
108,276 | <p>I have a project with a bunch of external sounds to a SWF. I want to play them, but any time I attempt load a new URL into the sound object it fails with either,</p>
<blockquote>
<p>Error #2068: Invalid Sound</p>
</blockquote>
<p>or raises an ioError with </p>
<blockquote>
<p>Error #2032 Stream Error</p>
</b... | [
{
"answer_id": 108698,
"author": "ZorroDeLaArena",
"author_id": 19696,
"author_profile": "https://Stackoverflow.com/users/19696",
"pm_score": 2,
"selected": false,
"text": "<p>Unless you're going to put a full url, don't use http:// or file://</p>\n\n<p>Sound can load an mp3 file from a ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14747/"
] | I have a project with a bunch of external sounds to a SWF. I want to play them, but any time I attempt load a new URL into the sound object it fails with either,
>
> Error #2068: Invalid Sound
>
>
>
or raises an ioError with
>
> Error #2032 Stream Error
>
>
>
// Tried with path prefixed with "http://.." "f... | Well, I've just done a test by putting an mp3 in a directory: `soundTest/assets/song.mp3` then creating a swf that calls the mp3 in another directory: `soundTest/swfs/soundTest.swf` and when I use `var path:String = "../assets/song.mp3";` then it compiles with no errors.
What is your actual directory structure? |
108,281 | <p>I have a table <code>y</code> Which has two columns <code>a</code> and <code>b</code></p>
<p>Entries are:</p>
<pre><code>a b
1 2
1 3
1 4
0 5
0 2
0 4
</code></pre>
<p>I want to get 2,3,4 if I search column <code>a</code> for 1, and 5,2,4 if I search column <code>a</code>.</p>
<p>So, if I searc... | [
{
"answer_id": 108313,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 0,
"selected": false,
"text": "<p>You can do all this in a single stored procedure with a single parameter.</p>\n\n<p>I have to run out, but I'll try t... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144/"
] | I have a table `y` Which has two columns `a` and `b`
Entries are:
```
a b
1 2
1 3
1 4
0 5
0 2
0 4
```
I want to get 2,3,4 if I search column `a` for 1, and 5,2,4 if I search column `a`.
So, if I search A for something that is in A, (1) I get those rows, and if there are no entries A for given v... | I think I have it:
```
SELECT b FROM y where a=if(@value IN (select a from y group by a),@value,0);
```
It checks if @value exists in the table, if not, then it uses 0 as a default.
@value can be a php value too.
Hope it helps :) |
108,292 | <p>When developing an application that sends out notification email messages, what are the best practices for </p>
<ol>
<li>not getting flagged as a spammer by your hosting company. (Cover any of:)
<ul>
<li>best technique for not flooding a mail server</li>
<li>best mail server products, if you were to set up your o... | [
{
"answer_id": 112607,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>best technique for not flooding a mail server</p>\n</blockquote>\n\n<p>not a lot you can do about this beyond... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16099/"
] | When developing an application that sends out notification email messages, what are the best practices for
1. not getting flagged as a spammer by your hosting company. (Cover any of:)
* best technique for not flooding a mail server
* best mail server products, if you were to set up your own
* sending messages as i... | >
> best technique for not flooding a mail server
>
>
>
not a lot you can do about this beyond checking with your mail server admin (if it's a shared hosting account / not in your control). but if the requirement is one email to a single recipient per event, that shouldn't be too much of an issue. the things that ... |
108,301 | <p>I was going to ask what the best way to do this is, but then decided I should ask whether or not it is even necessary. I have never seen it done in <code>JSP</code> development, but it appears to be common practice in <code>PHP</code>. What is the reasoning behind this, and if I do not protect against this, what els... | [
{
"answer_id": 108309,
"author": "Issac Kelly",
"author_id": 144,
"author_profile": "https://Stackoverflow.com/users/144",
"pm_score": 1,
"selected": false,
"text": "<p>Well, This is to prevent sensitive includes from being sent to the web-server directly. It's certainly not an all-incl... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I was going to ask what the best way to do this is, but then decided I should ask whether or not it is even necessary. I have never seen it done in `JSP` development, but it appears to be common practice in `PHP`. What is the reasoning behind this, and if I do not protect against this, what else should I be taking into... | The reason this is more common in PHP than other similar languages has to do with PHP's history. Early versions of PHP had the "register\_globals" setting on as a default (in fact, it may not have even been a setting in really early versions). Register\_globals tells PHP to define global variables according to the quer... |
108,318 | <p>I need a function like this:</p>
<pre><code>// return true if 'n' is a power of 2, e.g.
// is_power_of_2(16) => true
// is_power_of_2(3) => false
bool is_power_of_2(int n);
</code></pre>
<p>Can anyone suggest how I could write this?</p>
| [
{
"answer_id": 108329,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 6,
"selected": false,
"text": "<p>A power of two will have just one bit set (for unsigned numbers). Something like</p>\n\n<pre><code>bool powerOfTwo = ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19641/"
] | I need a function like this:
```
// return true if 'n' is a power of 2, e.g.
// is_power_of_2(16) => true
// is_power_of_2(3) => false
bool is_power_of_2(int n);
```
Can anyone suggest how I could write this? | `(n & (n - 1)) == 0` is best. However, note that it will incorrectly return true for n=0, so if that is possible, you will want to check for it explicitly.
<http://www.graphics.stanford.edu/~seander/bithacks.html> has a large collection of clever bit-twiddling algorithms, including this one. |
108,346 | <p>Something i've never really done before, but what is the best way to make sure that any external assemblies/dll's that my application uses are available, and possibly the correct version.</p>
<p>I wrote an app that relies on the System.Data.SQLite.dll, i went to test it on a machine where that dll was missing, and ... | [
{
"answer_id": 108372,
"author": "Nescio",
"author_id": 14484,
"author_profile": "https://Stackoverflow.com/users/14484",
"pm_score": 0,
"selected": false,
"text": "<p>You should trap the error outside of your main loop.<br>\nOr if you want to ship/locate your own assemblies you can try ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19638/"
] | Something i've never really done before, but what is the best way to make sure that any external assemblies/dll's that my application uses are available, and possibly the correct version.
I wrote an app that relies on the System.Data.SQLite.dll, i went to test it on a machine where that dll was missing, and my app jus... | What you want to do is use reflection to check and see if the assembly can be loaded into memory. Wrap that up in a try..catch block and handle any of the specific exceptions that come from it.
```
Try
Assembly.Load("System.Data.SQLite, Version=1.0.22.0, Culture=neutral, PublicKeyToken=DB937BC2D44FF139");
Catch ex... |
108,389 | <pre><code>class MyContainedClass {
};
class MyClass {
public:
MyContainedClass * getElement() {
// ...
std::list<MyContainedClass>::iterator it = ... // retrieve somehow
return &(*it);
}
// other methods
private:
std::list<MyContainedClass> m_contained;
};
</code></pre>
<p>Though ... | [
{
"answer_id": 108409,
"author": "Andrew Queisser",
"author_id": 18321,
"author_profile": "https://Stackoverflow.com/users/18321",
"pm_score": 0,
"selected": false,
"text": "<p>I think the bigger problem is that you're hiding the type of collection so even if you use a collection that do... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14535/"
] | ```
class MyContainedClass {
};
class MyClass {
public:
MyContainedClass * getElement() {
// ...
std::list<MyContainedClass>::iterator it = ... // retrieve somehow
return &(*it);
}
// other methods
private:
std::list<MyContainedClass> m_contained;
};
```
Though msdn says `std::list` should not pe... | I don't see the use of encapsulating this, but that may be just me. In any case, returning a reference instead of a pointer makes a lot more sense to me. |
108,396 | <p>I am using Fluent NHibernate and having some issues getting a many to many relationship setup with one of my classes. It's probably a stupid mistake but I've been stuck for a little bit trying to get it working. Anyways, I have a couple classes that have Many-Many relationships. </p>
<pre><code>public class Person
... | [
{
"answer_id": 108694,
"author": "emeryc",
"author_id": 3900,
"author_profile": "https://Stackoverflow.com/users/3900",
"pm_score": 0,
"selected": false,
"text": "<p>Are you making sure to add the Person to the Groups.Admin? You have to make both links.</p>\n"
},
{
"answer_id": 1... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1385358/"
] | I am using Fluent NHibernate and having some issues getting a many to many relationship setup with one of my classes. It's probably a stupid mistake but I've been stuck for a little bit trying to get it working. Anyways, I have a couple classes that have Many-Many relationships.
```
public class Person
{
public P... | The fact that it is adding two records to the table looks like you are missing an [inverse attribute](http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#example-many-to-many-mapping-file). Since both the person and the group are being changed, NHibernate is persisting the relation twice (once for each ob... |
108,403 | <p>Assume a table structure of <code>MyTable(KEY, datafield1, datafield2...)</code>.</p>
<p>Often I want to either update an existing record, or insert a new record if it doesn't exist.</p>
<p>Essentially:</p>
<pre><code>IF (key exists)
run update command
ELSE
run insert command
</code></pre>
<p>What's the best... | [
{
"answer_id": 108408,
"author": "Clint Ecker",
"author_id": 13668,
"author_profile": "https://Stackoverflow.com/users/13668",
"pm_score": -1,
"selected": false,
"text": "<p>Do a select, if you get a result, update it, if not, create it.</p>\n"
},
{
"answer_id": 108410,
"auth... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18907/"
] | Assume a table structure of `MyTable(KEY, datafield1, datafield2...)`.
Often I want to either update an existing record, or insert a new record if it doesn't exist.
Essentially:
```
IF (key exists)
run update command
ELSE
run insert command
```
What's the best performing way to write this? | don't forget about transactions. Performance is good, but simple (IF EXISTS..) approach is very dangerous.
When multiple threads will try to perform Insert-or-update you can easily
get primary key violation.
Solutions provided by @Beau Crawford & @Esteban show general idea but error-prone.
To avoid deadlocks and ... |
108,439 | <p>I'm looking to get the result of a command as a variable in a Windows batch script (see <a href="https://stackoverflow.com/questions/58207/using-the-result-of-a-command-as-an-argument-in-bash#58214">how to get the result of a command in bash</a> for the bash scripting equivalent). A solution that will work in a .ba... | [
{
"answer_id": 108462,
"author": "Jack B Nimble",
"author_id": 3800,
"author_profile": "https://Stackoverflow.com/users/3800",
"pm_score": -1,
"selected": false,
"text": "<p>Please refer to this <a href=\"http://technet.microsoft.com/en-us/library/bb490982.aspx\" rel=\"nofollow noreferre... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3535/"
] | I'm looking to get the result of a command as a variable in a Windows batch script (see [how to get the result of a command in bash](https://stackoverflow.com/questions/58207/using-the-result-of-a-command-as-an-argument-in-bash#58214) for the bash scripting equivalent). A solution that will work in a .bat file is prefe... | If you have to capture all the command output you can use a batch like this:
```
@ECHO OFF
IF NOT "%1"=="" GOTO ADDV
SET VAR=
FOR /F %%I IN ('DIR *.TXT /B /O:D') DO CALL %0 %%I
SET VAR
GOTO END
:ADDV
SET VAR=%VAR%!%1
:END
```
All output lines are stored in VAR separated with "!".
But if only a single-line console... |
108,443 | <p>I'm planning to create a data structure optimized to hold assembly code. That way I can be totally responsible for the optimization algorithms that will be working on this structure. If I can compile while running. It will be kind of dynamic execution. Is this possible? Have any one seen something like this?</p>
<p... | [
{
"answer_id": 108493,
"author": "Nils Pipenbrinck",
"author_id": 15955,
"author_profile": "https://Stackoverflow.com/users/15955",
"pm_score": 3,
"selected": false,
"text": "<p>It is possible. Dynamic code generation is even mainstream in some areas like software rendering and graphics.... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15054/"
] | I'm planning to create a data structure optimized to hold assembly code. That way I can be totally responsible for the optimization algorithms that will be working on this structure. If I can compile while running. It will be kind of dynamic execution. Is this possible? Have any one seen something like this?
Should I ... | It is possible. Dynamic code generation is even mainstream in some areas like software rendering and graphics. You find a lot of use in all kinds of script languages, in dynamic compilation of byte-code in machine code (.NET, Java, as far as I know Perl. Recently JavaScript joined the club as well).
You also find it u... |
108,461 | <p>I have a small gallery of thumbnails. When I place my mouse pointer over a thumbnail image I'd like to have a full size image pop up in a div in the top right of the screen. I've seen this done using just CSS and I'd like to go down that route rather than use javascript if possible.</p>
| [
{
"answer_id": 108479,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 0,
"selected": false,
"text": "<p>Eric Meyer's <a href=\"http://meyerweb.com/eric/css/edge/popups/demo2.html\" rel=\"nofollow noreferrer\">Pure CSS Po... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18748/"
] | I have a small gallery of thumbnails. When I place my mouse pointer over a thumbnail image I'd like to have a full size image pop up in a div in the top right of the screen. I've seen this done using just CSS and I'd like to go down that route rather than use javascript if possible. | [Pure CSS Popups2](http://meyerweb.com/eric/css/edge/popups/demo2.html), from the same site that brings us Complexspiral. Note that this example is using actual navigational links as the rolled-over element. If you don't want that, it may cause some stickiness regarding versions of IE.
The basic technique is to stick ... |
108,523 | <p>I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations?</p>
<p>Class code here:</p>
<pre><code>class Enum(object):
'''Simple Enum Class
Example Usage:
>>> codes = Enum('FOO BAR BAZ') # codes.BAZ will be 2 and so on... | [
{
"answer_id": 108547,
"author": "Ycros",
"author_id": 10495,
"author_profile": "https://Stackoverflow.com/users/10495",
"pm_score": 3,
"selected": false,
"text": "<p>Enums have been proposed for inclusion into the language before, but were rejected (see <a href=\"http://www.python.org/d... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9127/"
] | I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations?
Class code here:
```
class Enum(object):
'''Simple Enum Class
Example Usage:
>>> codes = Enum('FOO BAR BAZ') # codes.BAZ will be 2 and so on ...'''
def __init__(self, nam... | There's a lot of good discussion [here](https://stackoverflow.com/questions/36932/whats-the-best-way-to-implement-an-enum-in-python). |
108,558 | <p>Can a cookie be shared between two sites on the same top level domain? Say <code>www.example.com</code> and <code>secure.example.com</code> ?
We are looking into implementing a cache for non-secure content, and need to segregate secure content to another domain.
What parameters does the cookie need? I'm using asp.ne... | [
{
"answer_id": 108569,
"author": "Rich Bradshaw",
"author_id": 16511,
"author_profile": "https://Stackoverflow.com/users/16511",
"pm_score": 6,
"selected": true,
"text": "<p>Yes, you can. Use:</p>\n\n<pre><code>Response.Cookies(\"UID\").Domain = \".myserver.com\"\n</code></pre>\n"
},
... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7277/"
] | Can a cookie be shared between two sites on the same top level domain? Say `www.example.com` and `secure.example.com` ?
We are looking into implementing a cache for non-secure content, and need to segregate secure content to another domain.
What parameters does the cookie need? I'm using asp.net | Yes, you can. Use:
```
Response.Cookies("UID").Domain = ".myserver.com"
``` |
108,567 | <p>I have a SVN structure like this:</p>
<pre><code>/Projects
/Project1
/Project2
/someFolder
/Project3
/Project4
</code></pre>
<p>I would like to move all the projects into the /Projects folder, which means I want to move Projects 3 and 4 from /someFolder into the /projects folder.</p>
<p>The caveat... | [
{
"answer_id": 108571,
"author": "Eli Bendersky",
"author_id": 8206,
"author_profile": "https://Stackoverflow.com/users/8206",
"pm_score": 2,
"selected": false,
"text": "<p>Moving directories in Subversion doesn't destroy history, AFAIK.</p>\n"
},
{
"answer_id": 108573,
"auth... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | I have a SVN structure like this:
```
/Projects
/Project1
/Project2
/someFolder
/Project3
/Project4
```
I would like to move all the projects into the /Projects folder, which means I want to move Projects 3 and 4 from /someFolder into the /projects folder.
The caveat: I'd like to keep the full histo... | ```
svn help rename
```
Moving/renaming in subversion keeps history intact. |
108,586 | <p>Data: a dependency list, already verified to be acyclic. So here, 'a' depends on 'b','c' (c depends on d), etc... </p>
<pre><code>A = { 'a' : dict(b=1, c=1),
'c' : dict(d=1),
'd' : dict(e=1,f=1,g=1),
'h' : dict(j=1)
}
</code></pre>
<p>I'd like to have a top-down, recursive solution to let's say... | [
{
"answer_id": 108606,
"author": "freespace",
"author_id": 8297,
"author_profile": "https://Stackoverflow.com/users/8297",
"pm_score": 3,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>#!/usr/bin/env python\n\ndef get_all(D, k):\n yield k\n for ii in D.get(k, []):\n ... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15842/"
] | Data: a dependency list, already verified to be acyclic. So here, 'a' depends on 'b','c' (c depends on d), etc...
```
A = { 'a' : dict(b=1, c=1),
'c' : dict(d=1),
'd' : dict(e=1,f=1,g=1),
'h' : dict(j=1)
}
```
I'd like to have a top-down, recursive solution to let's say, find the chain starting at ... | Try this:
```
#!/usr/bin/env python
def get_all(D, k):
yield k
for ii in D.get(k, []):
for jj in get_all(D, ii):
yield jj
A = { 'a' : dict(b=1, c=1),
'c' : dict(d=1),
'd' : dict(e=1,f=1,g=1),
'h' : dict(j=1)
}
for ii in get_all(A,'a'):
print ii
```
Gives me
```
s... |
108,598 | <p>Considering the following architecture:</p>
<ul>
<li>a base object 'Entity'</li>
<li>a derived object 'Entry:Base'</li>
<li>and a further derived object 'CancelledEntry:Entry'</li>
</ul>
<p>In EntitySQL I can write the following: </p>
<pre><code>[...] where it is of (only MyEntities.Entry) [...]
</code></pre>
<p... | [
{
"answer_id": 108644,
"author": "ADB",
"author_id": 3610,
"author_profile": "https://Stackoverflow.com/users/3610",
"pm_score": 1,
"selected": false,
"text": "<p>Ok, I have found a partial solution:</p>\n\n<pre><code>EntityContext.EntitySet.OfType<Entry>().Where( obj => !(obj i... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3610/"
] | Considering the following architecture:
* a base object 'Entity'
* a derived object 'Entry:Base'
* and a further derived object 'CancelledEntry:Entry'
In EntitySQL I can write the following:
```
[...] where it is of (only MyEntities.Entry) [...]
```
to return only objects of type Entry and no Entity or CancelledE... | Why don't you apply an extension method on IQueryable< Entry > called ApplyBaseEntryFilter() which would apply this filter and return an IQueryable< Entry >.
This is an example of how to reuse linq query fragments. Using extension methods on IQueryable< Entity > is a great way to re-use queries as you should neve rne... |
108,682 | <p><a href="http://svnbook.red-bean.com/nightly/en/svn.tour.importing.html#svn.tour.importing.layout" rel="nofollow noreferrer"><em>Version Control with Subversion</em></a> recommends the following layout for (single-project) repositories (complemented by <a href="https://stackoverflow.com/questions/49356/what-is-a-goo... | [
{
"answer_id": 108700,
"author": "neu242",
"author_id": 13365,
"author_profile": "https://Stackoverflow.com/users/13365",
"pm_score": 0,
"selected": false,
"text": "<p>Whenever you deal with real live environments, you would want your developers to be able to understand your repository a... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9634/"
] | [*Version Control with Subversion*](http://svnbook.red-bean.com/nightly/en/svn.tour.importing.html#svn.tour.importing.layout) recommends the following layout for (single-project) repositories (complemented by [*this question*](https://stackoverflow.com/questions/49356/what-is-a-good-repository-layout-for-releases-and-p... | The main difference between the recommended layout and your proposed layout is that the recommended layout is somewhat self-documenting as to where to commit things, and how it behaves.
For example, in the recommended layout, it's obvious that all new development is committed to trunk, and most branches are made from ... |
108,687 | <p>I want to create a box shape and I am having trouble.
I want the box to have a background color, and then different color inside the box.<br>
The box will then have a list of items using ul and li, and each list item will have a background of white, and the list item's background color is too stretch the entire dist... | [
{
"answer_id": 108708,
"author": "Mike Tunnicliffe",
"author_id": 13956,
"author_profile": "https://Stackoverflow.com/users/13956",
"pm_score": 2,
"selected": false,
"text": "<p>So if you have source:</p>\n\n<pre><code><div class=\"panel\">\n <div>Some other stuff</div>... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] | I want to create a box shape and I am having trouble.
I want the box to have a background color, and then different color inside the box.
The box will then have a list of items using ul and li, and each list item will have a background of white, and the list item's background color is too stretch the entire distance... | You can do this pretty cleanly with this css:
```
.box {
width: 100px;
border: solid #884400;
border-width: 8px 3px 8px 3px;
background-color: #ccaa77;
}
.box ul {
margin: 0px;
padding: 0px;
padding-top: 50px; /* presuming the non-list header space at the top of... |
108,768 | <p>I got a comment to my answer on this thread:</p>
<p><a href="https://stackoverflow.com/questions/105477">Malloc inside a function call appears to be getting freed on return?</a></p>
<p>In short I had code like this:</p>
<pre><code>int * somefunc (void)
{
int * temp = (int*) malloc (sizeof (int));
temp[0] = 0;... | [
{
"answer_id": 108780,
"author": "DGentry",
"author_id": 4761,
"author_profile": "https://Stackoverflow.com/users/4761",
"pm_score": 0,
"selected": false,
"text": "<p>Casting a function which returns (void *) to instead be an (int *) is harmless: you're casting one type of pointer to ano... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15955/"
] | I got a comment to my answer on this thread:
[Malloc inside a function call appears to be getting freed on return?](https://stackoverflow.com/questions/105477)
In short I had code like this:
```
int * somefunc (void)
{
int * temp = (int*) malloc (sizeof (int));
temp[0] = 0;
return temp;
}
```
I got this comm... | It seems fitting I post an answer, since I left the comment :P
Basically, if you forget to include `stdlib.h` the compiler will assume `malloc` returns an `int`. Without casting, you will get a warning. With casting you won't.
So by casting you get nothing, and run the risk of suppressing legitimate warnings.
Much i... |
108,813 | <p>How can I Handler 404 errors without the framework throwing an Exception 500 error code?</p>
| [
{
"answer_id": 108830,
"author": "dave",
"author_id": 14355,
"author_profile": "https://Stackoverflow.com/users/14355",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"http://jason.whitehorn.ws/2008/06/17/Friendly-404-Errors-In-ASPNET-MVC.aspx\" rel=\"noreferrer\">http://jason.whi... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19710/"
] | How can I Handler 404 errors without the framework throwing an Exception 500 error code? | <http://jason.whitehorn.ws/2008/06/17/Friendly-404-Errors-In-ASPNET-MVC.aspx> gives the following explanation:
Add a wildcard routing rule as your final rule:
```
routes.MapRoute("Error",
"{*url}",
new { controller = "Error", action = "Http404" });
```
Any request that doesn't matc... |
108,819 | <p>What is the best way to randomize an array of strings with .NET? My array contains about 500 strings and I'd like to create a new <code>Array</code> with the same strings but in a random order.</p>
<p>Please include a C# example in your answer.</p>
| [
{
"answer_id": 108828,
"author": "Nick",
"author_id": 1490,
"author_profile": "https://Stackoverflow.com/users/1490",
"pm_score": 1,
"selected": false,
"text": "<p>Generate an array of random floats or ints of the same length. Sort that array, and do corresponding swaps on your target a... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16440/"
] | What is the best way to randomize an array of strings with .NET? My array contains about 500 strings and I'd like to create a new `Array` with the same strings but in a random order.
Please include a C# example in your answer. | If you're on .NET 3.5, you can use the following IEnumerable coolness:
```
Random rnd=new Random();
string[] MyRandomArray = MyArray.OrderBy(x => rnd.Next()).ToArray();
```
Edit: and here's the corresponding VB.NET code:
```
Dim rnd As New System.Random
Dim MyRandomArray = MyArray.OrderBy(Function() rnd.Next())... |
108,853 | <p>I have some code in a javascript file that needs to send queries back to the server. The question is, how do I find the url for the script that I am in, so I can build a proper request url for ajax.</p>
<p>I.e., the same script is included on <code>/</code>, <code>/help</code>, <code>/whatever</code>, and so on, wh... | [
{
"answer_id": 108860,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 2,
"selected": false,
"text": "<p><code>document.location.href</code> will give you the current URL, which you can then manipulate using JavaScript's s... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355/"
] | I have some code in a javascript file that needs to send queries back to the server. The question is, how do I find the url for the script that I am in, so I can build a proper request url for ajax.
I.e., the same script is included on `/`, `/help`, `/whatever`, and so on, while it will always need to request from `/d... | For this I like to put `<link>` elements in the page's `<head>`, containing the URLs to use for requests. They can be generated by your server-side language so they always point to the right view:
```
<link id="link-action-1" href="${reverse_url ('action_1')}"/>
```
becomes
```
<link id="link-action-1" href="/my/we... |
108,866 | <p>Is there a version of memset() which sets a value that is larger than 1 byte (char)? For example, let's say we have a memset32() function, so using it we can do the following:</p>
<pre><code>int32_t array[10];
memset32(array, 0xDEADBEEF, sizeof(array));
</code></pre>
<p>This will set the value 0xDEADBEEF in all th... | [
{
"answer_id": 108876,
"author": "Alex M",
"author_id": 9652,
"author_profile": "https://Stackoverflow.com/users/9652",
"pm_score": 3,
"selected": false,
"text": "<p><code>wmemset(3)</code> is the wide (16-bit) version of memset. I think that's the closest you're going to get in C, witho... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7748/"
] | Is there a version of memset() which sets a value that is larger than 1 byte (char)? For example, let's say we have a memset32() function, so using it we can do the following:
```
int32_t array[10];
memset32(array, 0xDEADBEEF, sizeof(array));
```
This will set the value 0xDEADBEEF in all the elements of array. Curre... | ```
void memset64( void * dest, uint64_t value, uintptr_t size )
{
uintptr_t i;
for( i = 0; i < (size & (~7)); i+=8 )
{
memcpy( ((char*)dest) + i, &value, 8 );
}
for( ; i < size; i++ )
{
((char*)dest)[i] = ((char*)&value)[i&7];
}
}
```
(Explanation, as requested in the comments: when you ass... |
108,892 | <p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p>
<p>If not, it should be pretty easy to write.. Easiest way would be to..</p>
<ol>
<li>run <code>python-autotest myfile1.py myfile2.py etc.py</code>
<ul>
<li>Check if files-to-be-monito... | [
{
"answer_id": 108911,
"author": "macarthy",
"author_id": 17232,
"author_profile": "https://Stackoverflow.com/users/17232",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe buildbot would be useful <a href=\"http://buildbot.net/trac\" rel=\"nofollow noreferrer\">http://buildbot.net/tr... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] | Basically, growl notifications (or other callbacks) when tests break or pass. **Does anything like this exist?**
If not, it should be pretty easy to write.. Easiest way would be to..
1. run `python-autotest myfile1.py myfile2.py etc.py`
* Check if files-to-be-monitored have been modified (possibly just if they've be... | I found [autonose](https://github.com/gfxmonk/autonose) to be pretty unreliable but [sniffer](http://pypi.python.org/pypi/sniffer/0.2.3) seems to work very well.
```
$ pip install sniffer
$ cd myproject
```
Then instead of running "nosetests", you run:
```
$ sniffer
```
Or instead of `nosetests --verbose --with-d... |
108,900 | <p>How do I go about programmatically updating the FILEVERSION string in an MFC app? I have a build process that I use to generate a header file which contains the SVN rev for a given release. I'm using SvnRev from <a href="http://www.compuphase.com/svnrev.htm" rel="nofollow noreferrer">http://www.compuphase.com/svnrev... | [
{
"answer_id": 108963,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 1,
"selected": false,
"text": "<p>In your application.rc file there is a version block. This block controls the version info displayed in the filesy... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17259/"
] | How do I go about programmatically updating the FILEVERSION string in an MFC app? I have a build process that I use to generate a header file which contains the SVN rev for a given release. I'm using SvnRev from <http://www.compuphase.com/svnrev.htm> to update a header file which I use to set the caption bar of my MFC ... | An `.rc` file can `#include` header files just like `.c` files can. I have an auto-generated `version.h` file, which defines things like:
```
#define MY_PRODUCT_VERSION "0.47"
#define MY_PRODUCT_VERSION_NUM 0,47,0,0
```
Then I just have my `.rc` file `#include "version.h"` and use those defines.
```
VS_VERSION_I... |
108,938 | <p>Rails comes with a handy session hash into which we can cram stuff to our heart's content. I would, however, like something like ASP's application context, which instead of sharing data only within a single session, will share it with all sessions in the same application. I'm writing a simple dashboard app, and woul... | [
{
"answer_id": 108948,
"author": "p3t0r",
"author_id": 16685,
"author_profile": "https://Stackoverflow.com/users/16685",
"pm_score": 2,
"selected": false,
"text": "<p>You should have a look at memcached: <a href=\"http://wiki.rubyonrails.org/rails/pages/MemCached\" rel=\"nofollow norefer... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2041950/"
] | Rails comes with a handy session hash into which we can cram stuff to our heart's content. I would, however, like something like ASP's application context, which instead of sharing data only within a single session, will share it with all sessions in the same application. I'm writing a simple dashboard app, and would l... | **Right answer**: memcached . Fast, clean, supports multiple processes, integrates **very** cleanly with Rails these days. Not even that bad to set up, but it is one more thing to keep running.
**90% Answer**: There are probably multiple Rails processes running around -- one for each Mongrel you have, for example. Dep... |
108,940 | <p>I am trying to evaluate the answer <a href="https://stackoverflow.com/questions/108081/are-there-any-high-level-easy-to-install-gui-libraries-for-common-lisp">provided here</a>, and am getting the error: <code>"A file with name ASDF-INSTALL does not exist"</code> when using clisp:</p>
<pre><code>dsm@localhost:~$ cl... | [
{
"answer_id": 109028,
"author": "Attila Lendvai",
"author_id": 14464,
"author_profile": "https://Stackoverflow.com/users/14464",
"pm_score": 2,
"selected": false,
"text": "<p>try this before anything else:</p>\n\n<pre><code>(require :asdf)\n</code></pre>\n\n<p>you can steal some ideas f... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7780/"
] | I am trying to evaluate the answer [provided here](https://stackoverflow.com/questions/108081/are-there-any-high-level-easy-to-install-gui-libraries-for-common-lisp), and am getting the error: `"A file with name ASDF-INSTALL does not exist"` when using clisp:
```
dsm@localhost:~$ clisp -q
[1]> (require :asdf-install)
... | use clc:clc-require in clisp. Refer to 'man common-lisp-controller'. I had the same error in clisp and resolved it by using clc:clc-require. sbcl works fine with just require though. |
108,971 | <p>We have two versions of a managed C++ assembly, one for x86 and one for x64. This assembly is called by a .net application complied for AnyCPU. We are deploying our code via a file copy install, and would like to continue to do so.</p>
<p>Is it possible to use a Side-by-Side assembly manifest to loading a x86 or ... | [
{
"answer_id": 108998,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the <a href=\"http://msdn.microsoft.com/en-us/library/ms164699(VS.80).aspx\" rel=\"nofollow noreferrer\">c... | 2008/09/20 | [
"https://Stackoverflow.com/questions/108971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6156/"
] | We have two versions of a managed C++ assembly, one for x86 and one for x64. This assembly is called by a .net application complied for AnyCPU. We are deploying our code via a file copy install, and would like to continue to do so.
Is it possible to use a Side-by-Side assembly manifest to loading a x86 or x64 assembly... | I created a simple solution that is able to load platform-specific assembly from an executable compiled as AnyCPU. The technique used can be summarized as follows:
1. Make sure default .NET assembly loading mechanism ("Fusion" engine) can't find either x86 or x64 version of the platform-specific assembly
2. Before the... |
109,000 | <p>My C application uses 3rd libraries, which do their own memory management.
In order to be robust, my application has code to deal with failures of library functions due to lack of free memory.</p>
<p>I would like to test this code, and for this, I need to simulate failures due to lack of memory.</p>
<p>What tool/s... | [
{
"answer_id": 109004,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": false,
"text": "<p>Create your own malloc wrapper which will randomly return null instead of a valid pointer. Well, or which fails c... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11886/"
] | My C application uses 3rd libraries, which do their own memory management.
In order to be robust, my application has code to deal with failures of library functions due to lack of free memory.
I would like to test this code, and for this, I need to simulate failures due to lack of memory.
What tool/s are recommended ... | You can use `ulimit` to limit the amount of resources a user can use, including memory. So you create a test user, limit their memory use to something just enough to launch your program, and watch it die :)
Example:
```
ulimit -m 64
```
Sets a memory limit of 64kb. |
109,023 | <p>8 bits representing the number 7 look like this:</p>
<pre><code>00000111
</code></pre>
<p>Three bits are set.</p>
<p>What are the algorithms to determine the number of set bits in a 32-bit integer?</p>
| [
{
"answer_id": 109025,
"author": "Matt Howells",
"author_id": 16881,
"author_profile": "https://Stackoverflow.com/users/16881",
"pm_score": 11,
"selected": true,
"text": "<p>This is known as the '<a href=\"https://en.wikipedia.org/wiki/Hamming_weight\" rel=\"nofollow noreferrer\">Hamming... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16881/"
] | 8 bits representing the number 7 look like this:
```
00000111
```
Three bits are set.
What are the algorithms to determine the number of set bits in a 32-bit integer? | This is known as the '[Hamming Weight](https://en.wikipedia.org/wiki/Hamming_weight)', 'popcount' or 'sideways addition'.
Some CPUs have a single built-in instruction to do it and others have parallel instructions which act on bit vectors. Instructions like x86's [`popcnt`](https://www.felixcloutier.com/x86/popcnt) (o... |
109,044 | <p>I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7 and as we all know, IIS6 needs the ".mvc"-naming in the URL.</p>
<p>Will this code work to make sure it works on all IIS-versions? Without having to make special adjustments in code, global.asax or config-files for the different IIS-ver... | [
{
"answer_id": 109103,
"author": "alex",
"author_id": 19268,
"author_profile": "https://Stackoverflow.com/users/19268",
"pm_score": 0,
"selected": false,
"text": "<p>You can use an ISAPI filter to rewrite URLs which will allow you to have the nice URLs while still on IIS 6. </p>\n\n<p>Lo... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2429/"
] | I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7 and as we all know, IIS6 needs the ".mvc"-naming in the URL.
Will this code work to make sure it works on all IIS-versions? Without having to make special adjustments in code, global.asax or config-files for the different IIS-versions.
``... | That should fix the .mvc problem since the integrated pipeline is IIS7 strictly.
But remember to change settings on the IIS7 website to use "2.0 Integrated Pipeline" otherwhise it will return false aswell.
Also ofcouse setup the mapping of .mvc to the asp.net isapi dll, but Im guessing that you already know this.
Some... |
109,064 | <p>Could you recommend me a way to place a coundown timer on ASP.NET page?</p>
<p>Now I use this code:</p>
<p><strong>Default.aspx</strong></p>
<pre><code><asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTempla... | [
{
"answer_id": 109096,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 2,
"selected": false,
"text": "<p>You might add something like this in your .aspx page</p>\n\n<pre><code><form name=\"counter\"><input type=\"text... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] | Could you recommend me a way to place a coundown timer on ASP.NET page?
Now I use this code:
**Default.aspx**
```
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server">60</asp:Label>
... | OK, finally I ended with
```
<span id="timerLabel" runat="server"></span>
<script type="text/javascript">
function countdown()
{
seconds = document.getElementById("timerLabel").innerHTML;
if (seconds > 0)
{
document.getElementById("timerLabel").innerHTML = seconds - 1;
... |
109,066 | <p>I found this guide for using the flash parameters, thought it might be useful to post here, since Flash CS3 lacks a usage example for reading these parameters.</p>
<p>See answers for the link</p>
| [
{
"answer_id": 109067,
"author": "Eliram",
"author_id": 18790,
"author_profile": "https://Stackoverflow.com/users/18790",
"pm_score": 1,
"selected": false,
"text": "<pre><code>var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;\n</code></pre>\n\n<p>The entire article is at... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18790/"
] | I found this guide for using the flash parameters, thought it might be useful to post here, since Flash CS3 lacks a usage example for reading these parameters.
See answers for the link | Not sure why [his example](http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html) calls LoaderInfo. The [DisplayObject](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html) class has its own (readonly) [loaderinfo](http://livedocs.adobe.com/flash/9.0/ActionScr... |
109,086 | <p>I am using <code>setInterval(fname, 10000);</code> to call a function every 10 seconds in JavaScript. Is it possible to stop calling it on some event? </p>
<p>I want the user to be able to stop the repeated refresh of data.</p>
| [
{
"answer_id": 109091,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 12,
"selected": true,
"text": "<p><code>setInterval()</code> returns an interval ID, which you can pass to <code>clearInterval()</code>:</p>\n<pre><c... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448/"
] | I am using `setInterval(fname, 10000);` to call a function every 10 seconds in JavaScript. Is it possible to stop calling it on some event?
I want the user to be able to stop the repeated refresh of data. | `setInterval()` returns an interval ID, which you can pass to `clearInterval()`:
```
var refreshIntervalId = setInterval(fname, 10000);
/* later */
clearInterval(refreshIntervalId);
```
See the docs for [`setInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval) and [`c... |
109,087 | <p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p>
<pre><code>class hi:
def __init__(self):
self.ii = "foo"
self.kk = "bar"
</code></pre>
<p>Is there a way for me to do this:</p>
<pre><code>>>> mystery_method(hi)
["ii",... | [
{
"answer_id": 109106,
"author": "cnu",
"author_id": 1448,
"author_profile": "https://Stackoverflow.com/users/1448",
"pm_score": 9,
"selected": true,
"text": "<p>Every object has a <code>__dict__</code> variable containing all the variables and its values in it.</p>\n<p>Try this</p>\n<pr... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] | Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:
```
class hi:
def __init__(self):
self.ii = "foo"
self.kk = "bar"
```
Is there a way for me to do this:
```
>>> mystery_method(hi)
["ii", "kk"]
```
Edit: I originally had asked for ... | Every object has a `__dict__` variable containing all the variables and its values in it.
Try this
```
>>> hi_obj = hi()
>>> hi_obj.__dict__.keys()
```
Output
```
dict_keys(['ii', 'kk'])
``` |
109,134 | <p>How do I change the style (color) of a div such as the following? </p>
<pre><code>"<div id=foo class="ed" style="display: <%= ((foo.isTrue) ? string.Empty : "none") %>">
<%= ((foo.isTrue) ? foo.Name: "false foo") %>"`
</code></pre>
| [
{
"answer_id": 109140,
"author": "unexist",
"author_id": 18179,
"author_profile": "https://Stackoverflow.com/users/18179",
"pm_score": 0,
"selected": false,
"text": "<p>That code fragment doesn't say much - if the code is server-side why don't you change e.g. the class of the HTML elemen... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15059/"
] | How do I change the style (color) of a div such as the following?
```
"<div id=foo class="ed" style="display: <%= ((foo.isTrue) ? string.Empty : "none") %>">
<%= ((foo.isTrue) ? foo.Name: "false foo") %>"`
``` | If you want to alter the color of the div with client side code (javascript) running in the browser, you do something like the following:
```
<script>
var fooElement = document.getElementById("foo");
fooElement.style.color = "red"; //to change the font color
</script>
``` |
109,232 | <p>What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?</p>
| [
{
"answer_id": 109258,
"author": "Horcrux7",
"author_id": 12631,
"author_profile": "https://Stackoverflow.com/users/12631",
"pm_score": -1,
"selected": false,
"text": "<p>You didn't specify the language nor which driver you are using. Therefore I'm describing it abstractly.</p>\n\n<ul>\n... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19331/"
] | What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)? | Getting the total number of results and paginating are two different operations. For the sake of this example, let's assume that the query you're dealing with is
```
SELECT * FROM Orders WHERE OrderDate >= '1980-01-01' ORDER BY OrderDate
```
In this case, you would determine the total number of results using:
```
S... |
109,249 | <p>Why doesn't have the c standard a memswap function, which would probably look like:</p>
<pre><code>int memswap(void *ptr1, void *ptr2, size_t nbytes)?
</code></pre>
<p>I know it'd be easy to write, but i think the libc could do some awesome tricks to speed it up like some implementations do it for memcpy.</p>
| [
{
"answer_id": 109259,
"author": "Colen",
"author_id": 13500,
"author_profile": "https://Stackoverflow.com/users/13500",
"pm_score": 2,
"selected": false,
"text": "<p>Probably because it's not needed very often - I memset and memcpy reasonably often, but I don't know that I'd ever have u... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18687/"
] | Why doesn't have the c standard a memswap function, which would probably look like:
```
int memswap(void *ptr1, void *ptr2, size_t nbytes)?
```
I know it'd be easy to write, but i think the libc could do some awesome tricks to speed it up like some implementations do it for memcpy. | This isn't something that is routinely required.
The ideas may have been considered and discarded because it is quite difficult to come up with an algorithm that is general purpose. Don't forget that C is an old language and extensions need to be generally useful.
Possible error conditions :-
* behaviour when the ra... |
109,284 | <p>Is it possible to test the use of a given layout using RSpec with Rails, for example I'd like a matcher that does the following:</p>
<pre><code>response.should use_layout('my_layout_name')
</code></pre>
<p>I found a use_layout matcher when Googling but it doesn't work as neither the response or controller seem to ... | [
{
"answer_id": 110301,
"author": "Otto",
"author_id": 9594,
"author_profile": "https://Stackoverflow.com/users/9594",
"pm_score": 4,
"selected": true,
"text": "<p>I found an example of <a href=\"http://rubyforge.org/pipermail/rspec-users/2007-May/001816.html\" rel=\"noreferrer\">how to w... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6432/"
] | Is it possible to test the use of a given layout using RSpec with Rails, for example I'd like a matcher that does the following:
```
response.should use_layout('my_layout_name')
```
I found a use\_layout matcher when Googling but it doesn't work as neither the response or controller seem to have a layout property th... | I found an example of [how to write a `use_layout` matcher](http://rubyforge.org/pipermail/rspec-users/2007-May/001816.html) that will do just that. Here's the code in case that link goes away:
```
# in spec_helper.rb
class UseLayout
def initialize(expected)
@expected = 'layouts/' + expected
end
def mat... |
109,305 | <p>I have an ASP.Net GridView control that I need to remain a fixed size whether there are 0 records or <em>n</em> records in the grid. The header and the footer should remain in the same position regardless of the amount of data in the grid. Obviously, I need to implement paging for larger datasets but how would I a... | [
{
"answer_id": 109496,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 1,
"selected": false,
"text": "<p>You may have to drop the headers and footers from the GridView altogether and add them to the page as separate table elemen... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7215/"
] | I have an ASP.Net GridView control that I need to remain a fixed size whether there are 0 records or *n* records in the grid. The header and the footer should remain in the same position regardless of the amount of data in the grid. Obviously, I need to implement paging for larger datasets but how would I achieve this ... | You may have to drop the headers and footers from the GridView altogether and add them to the page as separate table elements. You will need to make sure each table cell in the header and footer tables have fixed widths that correspond to the widths of the cells in your GridView.
The GridView itself would probably be... |
109,325 | <p>How do you perform the equivalent of Oracle's <code>DESCRIBE TABLE</code> in PostgreSQL (using the psql command)?</p>
| [
{
"answer_id": 109329,
"author": "Mr. Muskrat",
"author_id": 2657951,
"author_profile": "https://Stackoverflow.com/users/2657951",
"pm_score": 5,
"selected": false,
"text": "<p>The psql equivalent of <code>DESCRIBE TABLE</code> is <code>\\d table</code>.</p>\n\n<p>See the psql portion of... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657951/"
] | How do you perform the equivalent of Oracle's `DESCRIBE TABLE` in PostgreSQL (using the psql command)? | Try this (in the `psql` command-line tool):
```
\d+ tablename
```
See [the manual](http://www.postgresql.org/docs/current/interactive/app-psql.html#APP-PSQL-META-COMMANDS) for more info. |
109,343 | <p>With web services it is considered a good practice to batch several service calls into one message to reduce a number of remote calls. Is there any way to do this with RESTful services?</p>
| [
{
"answer_id": 109479,
"author": "Aaron Jensen",
"author_id": 11229,
"author_profile": "https://Stackoverflow.com/users/11229",
"pm_score": -1,
"selected": false,
"text": "<p>Of course there is a way but it would require server-side support. There is no magical one size fits all methodol... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19268/"
] | With web services it is considered a good practice to batch several service calls into one message to reduce a number of remote calls. Is there any way to do this with RESTful services? | I don't see how batching requests makes any sense in REST. Since the URL in a REST-based service represents the operation to perform and the data on which to perform it, making batch requests would seriously break the conceptual model.
An exception would be if you were performing the same operation on the same data mu... |
109,383 | <p>I am relatively new to Java, and often find that I need to sort a <code>Map<Key, Value></code> on the values.</p>
<p>Since the values are not unique, I find myself converting the <code>keySet</code> into an <code>array</code>, and sorting that array through <strong>array sort</strong> with a <strong>custom co... | [
{
"answer_id": 109389,
"author": "devinmoore",
"author_id": 15950,
"author_profile": "https://Stackoverflow.com/users/15950",
"pm_score": 8,
"selected": false,
"text": "<p>From <a href=\"http://www.programmersheaven.com/download/49349/download.aspx\" rel=\"noreferrer\">http://www.program... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9466/"
] | I am relatively new to Java, and often find that I need to sort a `Map<Key, Value>` on the values.
Since the values are not unique, I find myself converting the `keySet` into an `array`, and sorting that array through **array sort** with a **custom comparator** that sorts on the value associated with the key.
Is ther... | Here's a generic-friendly version:
```
public class MapUtil {
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
List<Entry<K, V>> list = new ArrayList<>(map.entrySet());
list.sort(Entry.comparingByValue());
Map<K, V> result = new LinkedHashMap<>();
... |
109,417 | <p>I populated a datagridview from a datatable. How do I read from the datagridview when the application is running?</p>
| [
{
"answer_id": 109452,
"author": "Hamish Smith",
"author_id": 15572,
"author_profile": "https://Stackoverflow.com/users/15572",
"pm_score": 3,
"selected": true,
"text": "<p>how did you populate it? is the DataSource something useful like a BindlingList? \nIf it is then something like:</p... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I populated a datagridview from a datatable. How do I read from the datagridview when the application is running? | how did you populate it? is the DataSource something useful like a BindlingList?
If it is then something like:
```
BindingSource bindingSource = this.dataGridView1.DataSource as BindingSource;
//substitute your business object type for T
T entity = bindingSource.Current as T;
```
would get you the entity bound to ... |
109,444 | <p>Okay so im working on this php image upload system but for some reason internet explorer turns my basepath into the same path, but with double backslashes instead of one; ie:</p>
<pre><code>C:\\Documents and Settings\\kasper\\Bureaublad\\24.jpg
</code></pre>
<p>This needs to become C:\Documents and Settings\kaspe... | [
{
"answer_id": 109454,
"author": "The.Anti.9",
"author_id": 2128,
"author_profile": "https://Stackoverflow.com/users/2128",
"pm_score": 3,
"selected": true,
"text": "<p>Use the <a href=\"http://us.php.net/manual/en/function.stripslashes.php\" rel=\"nofollow noreferrer\"><code>stripslashe... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18671/"
] | Okay so im working on this php image upload system but for some reason internet explorer turns my basepath into the same path, but with double backslashes instead of one; ie:
```
C:\\Documents and Settings\\kasper\\Bureaublad\\24.jpg
```
This needs to become C:\Documents and Settings\kasper\Bureaublad\24.jpg. | Use the [`stripslashes`](http://us.php.net/manual/en/function.stripslashes.php) function.
That should make them all single slashes. |
109,449 | <p>Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream ?</p>
<p>The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*.</p>
| [
{
"answer_id": 109476,
"author": "Mike G.",
"author_id": 18901,
"author_profile": "https://Stackoverflow.com/users/18901",
"pm_score": 2,
"selected": false,
"text": "<p>Well, you can get the file descriptor - I forget whether the method is fd() or getfd(). <em>The implementations I've u... | 2008/09/20 | [
"https://Stackoverflow.com/questions/109449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a (cross-platform) way to get a C FILE\* handle from a C++ std::fstream ?
The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE\*. | The short answer is no.
The reason, is because the `std::fstream` is not required to use a `FILE*` as part of its implementation. So even if you manage to extract file descriptor from the `std::fstream` object and manually build a FILE object, then you will have other problems because you will now have two buffered ob... |