qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
163,760 | <p>I have a Form being launched from another form on a different thread. Most of the time it works perfectly, but I get the below error from time to time. Can anyone help?</p>
<pre><code>at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
at System.Drawing.Icon.ToBitmap()
at System.Windows.Forms.ThreadExceptionDialog..ctor(Exception t)
at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
at System.Windows.Forms.Control.WndProcException(Exception e)
at System.Windows.Forms.Control.ControlNativeWindow.OnThreadException(Exception e)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
</code></pre>
| [
{
"answer_id": 167171,
"author": "joek1975",
"author_id": 4770,
"author_profile": "https://Stackoverflow.com/users/4770",
"pm_score": 0,
"selected": false,
"text": "Thread = New Thread(AddressOf ShowForm)\nThread.SetApartmentState(ApartmentState.STA)\nThread.IsBackground = True\n"
},
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4770/"
] |
163,761 | <p>I have a hidden embedded QuickTime object on my page that I'm trying to control via JavaScript, but it's not working. The object looks like this:</p>
<pre><code><object id="myPlayer" data="" type="audio/mpeg" pluginspage="http://www.apple.com/quicktime/download" width="0" height="0">
<param name="autoPlay" value="false" />
<param name="controller" value="false" />
<param name="enablejavascript" value="true" />
</object>
</code></pre>
<p>There is nothing in the data parameter because at render time, I don't know the URL that's going to be loaded. I set it like this:</p>
<pre><code>var player = document.getElementById("myPlayer");
player.SetURL(url);
</code></pre>
<p>The audio will later be played back with:</p>
<pre><code>player.Play();
</code></pre>
<p>Firefox 3.0.3 produces no error in the JavaScript console, but no playback occurs when <code>Play()</code> is called. Safari 3.0.4 produces the following error in the console:</p>
<pre><code>"Value undefined (result of expression player.SetURL) is not object."
</code></pre>
<p>Internet Explorer 7.0.5730.11 gives the following extremely helpful error message:</p>
<pre><code>"Unspecified error."
</code></pre>
<p>I have QuickTime version 7.4 installed on my machine. <a href="http://developer.apple.com/documentation/QuickTime/Conceptual/QTScripting_JavaScript/bQTScripting_JavaScri_Document/chapter_1000_section_5.html" rel="nofollow noreferrer">Apple's documentation</a> says that <code>SetURL()</code> is correct, so why does it not work?</p>
| [
{
"answer_id": 429916,
"author": "Kev",
"author_id": 16777,
"author_profile": "https://Stackoverflow.com/users/16777",
"pm_score": 0,
"selected": false,
"text": "player.attributes.getNamedItem('data').value = 'http://yoururlhere';\n"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/163761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4287/"
] |
163,783 | <p>Here's the problem I'm having, I've got a set of logs that can grow fairly quickly. They're split into individual files every day, and the files can easily grow up to a gig in size. To help keep the size down, entries older than 30 days or so are cleared out.</p>
<p>The problem is when I want to search these files for a certain string. Right now, a Boyer-Moore search is unfeasibly slow. I know that applications like dtSearch can provide a really fast search using indexing, but I'm not really sure how to implement that without taking up twice the space a log already takes up.</p>
<p>Are there any resources I can check out that can help? I'm really looking for a standard algorithm that'll explain what I should do to build an index and use it to search.</p>
<p>Edit:<br>
Grep won't work as this search needs to be integrated into a cross-platform application. There's no way I'll be able to swing including any external program into it.</p>
<p>The way it works is that there's a web front end that has a log browser. This talks to a custom C++ web server backend. This server needs to search the logs in a reasonable amount of time. Currently searching through several gigs of logs takes ages.</p>
<p>Edit 2:
Some of these suggestions are great, but I have to reiterate that I can't integrate another application, it's part of the contract. But to answer some questions, the data in the logs varies from either received messages in a health-care specific format or messages relating to these. I'm looking to rely on an index because while it may take up to a minute to rebuild the index, searching currently takes a very long time (I've seen it take up to 2.5 minutes). Also, a lot of the data IS discarded before even recording it. Unless some debug logging options are turned on, more than half of the log messages are ignored.</p>
<p>The search basically goes like this: A user on the web form is presented with a list of the most recent messages (streamed from disk as they scroll, yay for ajax), usually, they'll want to search for messages with some information in it, maybe a patient id, or some string they've sent, and so they can enter the string into the search. The search gets sent asychronously and the custom web server linearly searches through the logs 1MB at a time for some results. This process can take a very long time when the logs get big. And it's what I'm trying to optimize.</p>
| [
{
"answer_id": 163806,
"author": "changelog",
"author_id": 5646,
"author_profile": "https://Stackoverflow.com/users/5646",
"pm_score": 3,
"selected": false,
"text": "grep"
},
{
"answer_id": 164317,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://St... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4218/"
] |
163,796 | <p>I have a lot of XML files and I'd like to generate a report from them. The report should provide information such as:</p>
<pre><code>root 100%
a*1 90%
b*1 80%
c*5 40%
</code></pre>
<p>meaning that all documents have a root element, 90% have one <strong>a</strong> element in the root, 80% have one <strong>b</strong> element in the root, 40% have 5 <strong>c</strong> elements in <strong>b</strong>.</p>
<p>If for example some documents have 4 <strong>c</strong> elements, some 5 and some 6, it should say something like: </p>
<pre><code>c*4.3 4 6 40%
</code></pre>
<p>meaning that 40% have between 4 and 6 <strong>c</strong> elements there, and the average is 4.3.</p>
<p>I am looking for free software, if it doesn't exist I'll write it. I was about to do it, but I thought about checking it. I may not be the first one to have to analyze and get an structural overview of thousand of XML files.</p>
| [
{
"answer_id": 164830,
"author": "JeniT",
"author_id": 6739,
"author_profile": "https://Stackoverflow.com/users/6739",
"pm_score": 4,
"selected": false,
"text": "$docs"
},
{
"answer_id": 172142,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackover... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] |
163,803 | <p>I would like to override the use of the standard app.config by passing a command line parameter. How do I change the default application configuration file so that when I access ConfigurationManager.AppSettings I am accessing the config file specified on the command line?</p>
<p>Edit:</p>
<p>It turns out that the correct way to load a config file that is different than the name of the EXE plus .config is to use OpenMappedExeConfiguration. E.g. </p>
<pre><code>ExeConfigurationFileMap configFile = new ExeConfigurationFileMap();
configFile.ExeConfigFilename = Path.Combine(Environment.CurrentDirectory, "Shell2.exe.config");
currentConfiguration = ConfigurationManager.OpenMappedExeConfiguration(configFile,ConfigurationUserLevel.None);
</code></pre>
<p>This partially works. I can see all of the keys in the appSettings section but all the values are null.</p>
| [
{
"answer_id": 163829,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 1,
"selected": false,
"text": "ConfigurationManager"
},
{
"answer_id": 164221,
"author": "Darrel Miller",
"author_id": 6819,
"a... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6819/"
] |
163,809 | <p>I'm looking for an example algorithm of smart pagination. By smart, what I mean is that I only want to show, for example, 2 adjacent pages to the current page, so instead of ending up with a ridiculously long page list, I truncate it.</p>
<p>Here's a quick example to make it clearer... this is what I have now:</p>
<pre><code>Pages: 1 2 3 4 [5] 6 7 8 9 10 11
</code></pre>
<p>This is what I want to end up with:</p>
<pre><code>Pages: ... 3 4 [5] 6 7 ...
</code></pre>
<p>(In this example, I'm only showing 2 adjacent pages to the current page)</p>
<p>I'm implementing it in PHP/Mysql, and the "basic" pagination (no trucating) is already coded, I'm just looking for an example to optimize it... It can be an example in any language, as long as it gives me an idea as to how to implement it...</p>
| [
{
"answer_id": 163825,
"author": "changelog",
"author_id": 5646,
"author_profile": "https://Stackoverflow.com/users/5646",
"pm_score": 6,
"selected": true,
"text": "[1] 2 3 4 5 6 ... 100\n1 [2] 3 4 5 6 ... 100\n...\n1 2 ... 14 15 [16] 17 18 ... 100\n...\n1 2 ... 97 [98] 99 100\n"
},
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14981/"
] |
163,823 | <p>I have a <code>Person</code> model that has a foreign key relationship to <code>Book</code>, which has a number of fields, but I'm most concerned about <code>author</code> (a standard CharField).</p>
<p>With that being said, in my <code>PersonAdmin</code> model, I'd like to display <code>book.author</code> using <code>list_display</code>:</p>
<pre><code>class PersonAdmin(admin.ModelAdmin):
list_display = ['book.author',]
</code></pre>
<p>I've tried all of the obvious methods for doing so, but nothing seems to work.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 163968,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 5,
"selected": false,
"text": "__unicode__"
},
{
"answer_id": 164631,
"author": "imjoevasquez",
"author_id": 24630,
"author_prof... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10040/"
] |
163,834 | <p>What's the most elegant templating (preferably in pure PHP!) solution you've seen?</p>
<p>Specifically i'm interested in handling:</p>
<ol>
<li>Detecting in a repeating block whether it's the first or last element</li>
<li>Easy handling of odd/even cases, like a zebra striped table, or similar</li>
<li>Other modulos logic, where you'd do something every n'th time.</li>
</ol>
<p>I'm looking for something that makes this less of a pain:</p>
<pre><code><?php
$persons = array('John', 'Jack', 'Jill', 'Jason');
?>
<?php $i = 0; ?>
<?php if (isset($persons)): ?>
<ul>
<?php foreach ($persons as $name): ?>
<li class="<?= ($i++ % 2 === 0) ? 'odd' : 'even' ?>"><?= $name ?></li>
<?php endforeach ?>
</ul>
<?php endif ?>
</code></pre>
<p>Does it really take the mess above to create something like this below?</p>
<pre><code><ul>
<li class="odd">John</li>
<li class="even">Jack</li>
<li class="odd">Jill</li>
<li class="even">Jason</li>
</ul>
</code></pre>
<p>Is it only me that find the above near hideous? </p>
<p>All those starting and closing of php-tags makes me cringe.</p>
| [
{
"answer_id": 163860,
"author": "Cruachan",
"author_id": 7315,
"author_profile": "https://Stackoverflow.com/users/7315",
"pm_score": 3,
"selected": false,
"text": "$TBS->MergeBlock('blk1',$sqlconnect, \"SELECT name from people \");\n"
},
{
"answer_id": 163894,
"author": "fij... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20538/"
] |
163,837 | <p>I'm involved in building a donation form for non-profits. We recently got hit by a fast round of low dollar submissions. Many were invalid cards, but a few went through. Obviously someone wrote a script to check a bunch of card numbers for validity, possibly so they can sell them later.</p>
<p>Any ideas on how to prevent or limit the impact of this in the future?</p>
<p>We have control over all aspects of the system (code, webserver, etc). Yes the form runs over https.</p>
| [
{
"answer_id": 1160012,
"author": "tomjen",
"author_id": 21133,
"author_profile": "https://Stackoverflow.com/users/21133",
"pm_score": 2,
"selected": false,
"text": "<noscript>"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/163837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3756/"
] |
163,887 | <p>Suppose I have a "tags" table with two columns: <strong>tagid</strong> and <strong>contentid</strong>. Each row represents a tag assigned to a piece of content. I want a query that will give me the contentid of every piece of content which is tagged with tagids 334, 338, and 342.</p>
<p>The "easy" way to do this would be (<em>pseudocode</em>):</p>
<pre><code>select contentid from tags where tagid = 334 and contentid in (
select contentid from tags where tagid = 338 and contentid in (
select contentid from tags where tagid = 342
)
)
</code></pre>
<p>However, my gut tells me that there's a better, faster, more extensible way to do this. For example, what if I needed to find the intersection of 12 tags? This could quickly get horrendous. Any ideas?</p>
<p><strong>EDIT</strong>: Turns out that this is also covered in <a href="http://weblogs.sqlteam.com/jeffs/jeffs/archive/2007/06/12/60230.aspx" rel="noreferrer">this excellent blog post</a>.</p>
| [
{
"answer_id": 163902,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 1,
"selected": false,
"text": "select a.contentid from tags a\ninner join tags b on a.contentid = b.contentid and b.tagid=334\ninner join tags c on a.c... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16034/"
] |
163,900 | <p>I'm putting together a little tool that some business people can run on their local filesystems, since we don't want to setup a host for it.</p>
<p>Basically, its just HTML + Javascript (using jQuery) to pull some reports using REST from a 3rd party.</p>
<p>The problem is, FF3 and IE don't allow the ajax call, I get:</p>
<pre><code>Access to restricted URI denied" code: "1012
</code></pre>
<p>Obviously its an XSS issue...how do I work around it? The data returned is in XML format.</p>
<p>I was trying to do it this way:</p>
<pre><code>$.get(productUrl, function (data){
alert (data);
});
</code></pre>
<p><strong>EDIT</strong>: To be clear...I'm not setting up an internal host for this(Way to much red tape), and we CANNOT host this externally due to the data being retrieved.</p>
<p><strong>EDIT #2</strong>: A little testing shows that I can use an IFRAME to make the request. Does anyone know if there any downsides to using a hidden IFRAME?</p>
| [
{
"answer_id": 163950,
"author": "Greg",
"author_id": 13009,
"author_profile": "https://Stackoverflow.com/users/13009",
"pm_score": -1,
"selected": false,
"text": "python -c “import SimpleHTTPServer;SimpleHTTPServer.test()”\n"
},
{
"answer_id": 166502,
"author": "Morgan ARR A... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
163,917 | <p>I have never clearly understood the usage of <code>MAXDOP</code>. I do know that it makes the query faster and that it is the last item that I can use for Query Optimization.</p>
<p>However, my question is, when and where it is best suited to use in a query?</p>
| [
{
"answer_id": 167435,
"author": "Jeremiah Peschka",
"author_id": 11780,
"author_profile": "https://Stackoverflow.com/users/11780",
"pm_score": 5,
"selected": false,
"text": "MAXDOP(n)"
},
{
"answer_id": 36506677,
"author": "LCJ",
"author_id": 696627,
"author_profile"... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21968/"
] |
163,938 | <p>How many bytes would an int contain and how many would a long contain?</p>
<p>Context:</p>
<ul>
<li>C++</li>
<li>32 bit computer</li>
<li>Any difference on a 64-bit computer?</li>
</ul>
| [
{
"answer_id": 163976,
"author": "Dave Turvey",
"author_id": 18966,
"author_profile": "https://Stackoverflow.com/users/18966",
"pm_score": 1,
"selected": false,
"text": "int intBytes;\nlong longBytes;\nintBytes= sizeof(int);\nlongBytes = sizeof(long);\n"
},
{
"answer_id": 164013,... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
163,957 | <p>I know that you can do this in SQL Server 2005, but I'm at a loss for 2000.</p>
| [
{
"answer_id": 166421,
"author": "AJ.",
"author_id": 7211,
"author_profile": "https://Stackoverflow.com/users/7211",
"pm_score": 0,
"selected": false,
"text": "SELECT crdate\nFROM sysobjects \nWHERE name = 'proc name here' \nAND type = 'P' \n"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/163957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24602/"
] |
163,962 | <p>Up until now I have been using std::string in my C++ applications for embedded system (routers, switches, telco gear, etc.).</p>
<p>For the next project, I am considering to switch from std::string to std::wstring for Unicode support. This would, for example, allow end-users to use Chinese characters in the command line interface (CLI).</p>
<p>What complications / headaches / surprises should I expect? What, for example, if I use a third-party library which still uses std::string?</p>
<p>Since support for international strings isn't that strong of a requirement for the type of embedded systems that I work on, I would only do it if it isn't going to cause major headaches.</p>
| [
{
"answer_id": 166421,
"author": "AJ.",
"author_id": 7211,
"author_profile": "https://Stackoverflow.com/users/7211",
"pm_score": 0,
"selected": false,
"text": "SELECT crdate\nFROM sysobjects \nWHERE name = 'proc name here' \nAND type = 'P' \n"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/163962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21435/"
] |
163,994 | <p>I have a very large table (8gb) with information about files, and i need to run a report against it that would would look something like this:</p>
<pre><code>(select * from fs_walk_scan where file_path like '\\\\server1\\groot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file_path like '\\\\server1\\hroot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file_path like '\\\\server1\\iroot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file_path like '\\\\server2\\froot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file_path like '\\\\server2\\groot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file_path like '\\\\server3\\hroot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file_path like '\\\\server4\\iroot$\\%' order by file_size desc limit 0,30)
UNION ALL
(select * from fs_walk_scan where file_path like '\\\\server5\\iroot$\\%' order by file_size desc limit 0,30)
[...]
order by substring_index(file_path,'\\',4), file_size desc
</code></pre>
<p>This method accomplishes what I need to do: Get a list of the 30 biggest files for each volume. However, this is deathly slow, and the 'like' searches are hardcoded even though they are sitting in another table and can be gotten that way.</p>
<p>What I'm looking for is a way to do this without going through the huge table several times. Anyone have any ideas?</p>
<p>Thanks.</p>
<p>P.S. I cant change the structure of the huge source table in any way.</p>
<p>Update: There are indexes on file_path and file_size, but each one of those sub(?)queries still takes about 10 mins, and I have to do 22 minimum.</p>
| [
{
"answer_id": 164009,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 0,
"selected": false,
"text": "select * from fs_walk_scan where file_path like '\\\\\\\\server' and file_path like 'root$\\\\%' order by file_size desc \n"
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17785/"
] |
163,998 | <p>Is there any built-in functionality for classical set operations on the java.util.Collection class? My specific implementation would be for ArrayList, but this sounds like something that should apply for all subclasses of Collection. I'm looking for something like:</p>
<pre><code>ArrayList<Integer> setA ...
ArrayList<Integer> setB ...
ArrayList<Integer> setAintersectionB = setA.intersection(setB);
ArrayList<Integer> setAminusB = setA.subtract(setB);
</code></pre>
<p>After some searching, I was only able to find home-grown solutions. Also, I realize I may be confusing the idea of a "Set" with the idea of a "Collection", not allowing and allowing duplicates respectively. Perhaps this is really just functionality for the Set interface?</p>
<p>In the event that nobody knows of any built-in functionality, perhaps we could use this as a repository for standard practice Java set operation code? I imagine this wheel has been reinvented numerous times.</p>
| [
{
"answer_id": 164145,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 8,
"selected": true,
"text": "Collection.retainAll"
},
{
"answer_id": 34439881,
"author": "mhstnsc",
"author_id": 736533,
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/163998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19147/"
] |
164,002 | <p>I am writing a C library that reads a file into memory. It skips the first 54 bytes of the file (header) and then reads the remainder as data. I use fseek to determine the length of the file, and then use fread to read in the file.</p>
<p>The loop runs once and then ends because the EOF is reached (no errors). At the end, bytesRead = 10624, ftell(stream) = 28726, and the buffer contains 28726 values. I expect fread to read 30,000 bytes and the file position to be 30054 when EOF is reached.</p>
<p>C is not my native language so I suspect I've got a dumb beginner mistake somewhere.</p>
<p>Code is as follows:</p>
<pre><code>const size_t headerLen = 54;
FILE * stream;
errno_t ferrno = fopen_s( &stream, filename.c_str(), "r" );
if(ferrno!=0) {
return -1;
}
fseek( stream, 0L, SEEK_END );
size_t bytesTotal = (size_t)(ftell( stream )) - headerLen; //number of data bytes to read
size_t bytesRead = 0;
BYTE* localBuffer = new BYTE[bytesTotal];
fseek(stream,headerLen,SEEK_SET);
while(!feof(stream) && !ferror(stream)) {
size_t result = fread(localBuffer+bytesRead,sizeof(BYTE),bytesTotal-bytesRead,stream);
bytesRead+=result;
}
</code></pre>
<hr>
<p>Depending on the reference you use, it's quite apparent that adding a "b" to the mode flag is the answer. Seeking nominations for the bonehead-badge. :-)</p>
<p><a href="http://www.cplusplus.com/reference/clibrary/cstdio/fopen.html" rel="noreferrer">This reference</a> talks about it in the second paragraph, second sentence (though not in their table).</p>
<p><a href="http://msdn.microsoft.com/en-us/library/z5hh6ee9(VS.80).aspx" rel="noreferrer">MSDN</a> doesn't discuss the binary flag until halfway down the page.</p>
<p><a href="http://www.opengroup.org/onlinepubs/009695399/functions/fopen.html" rel="noreferrer">OpenGroup</a> mentions the existance of the "b" tag, but states that it "shall have no effect".</p>
| [
{
"answer_id": 164012,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 7,
"selected": true,
"text": "\"r+b\""
},
{
"answer_id": 24431357,
"author": "Kumar Pushkar",
"author_id": 3779460,
"author_profil... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17871/"
] |
164,008 | <p>Is there a connection limit on Sql Server 2005 Developers Edition. We have many threads grabbing connections, and I know ADO.NET does connection pooling, but I get OutOfMemory exceptions. We take out the db connections and it works fine. </p>
| [
{
"answer_id": 164016,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 2,
"selected": false,
"text": "using (SqlConnection conn = new SqlConnection(\"connectionstring\"))\n{\n conn.Open();\n\n // database access co... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11907/"
] |
164,026 | <p>I'd like to make sure that a thread is moved to a specific CPU core and can never be moved from it by the scheduler.</p>
<p>There's a <code>SetThreadAffinityMask()</code> call but there's no <code>GetThreadAffinityMask()</code>.</p>
<p>The reason I need this is because high resolution timers will get messed up if the scheduler moves that thread to another CPU.</p>
| [
{
"answer_id": 165641,
"author": "bk1e",
"author_id": 8090,
"author_profile": "https://Stackoverflow.com/users/8090",
"pm_score": 2,
"selected": false,
"text": "SetThreadAffinityMask()"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1841/"
] |
164,039 | <p>How can I dock a CControlBar derived window to the middle of a splitter window (CSplitterWnd)? I would like the bar to be repositioned whenever the splitter is moved.</p>
<p>To make it a little clearer as to what I'm after, imagine the vertical ruler in the Dialog Editor in Visual Studio (MFC only). It gets repositioned whenever the tree view is resized.</p>
| [
{
"answer_id": 169239,
"author": "Alf Zimmerman",
"author_id": 24612,
"author_profile": "https://Stackoverflow.com/users/24612",
"pm_score": 0,
"selected": false,
"text": "m_wndSplitter.CreateStatic(this, 1, 3);\n\nm_wndLeftPane.Create(&m_wndSplitter,WS_CHILD|WS_VISIBLE,m_wndSplitter.IdF... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24612/"
] |
164,048 | <p>I'm about to start (with fellow programmers) a programming & algorithms club in my high school. The language of choice is C++ - sorry about that, I can't change this. We can assume students have little to no experience in the aforementioned topics.</p>
<p>What do you think are the most basic concepts I should focus on?</p>
<p>I know that teaching something that's already obvious to me isn't an easy task. I realize that the very first meeting should be given an extreme attention - to not scare students away - hence I ask you.</p>
<p><strong>Edit:</strong> I noticed that probably the main difference between programmers and beginners is "programmer's way of thinking" - I mean, conceptualizing problems as, you know, algorithms. I know it's just a matter of practice, but do you know any kind of exercises/concepts/things that could stimulate development in this area?</p>
| [
{
"answer_id": 164470,
"author": "m_pGladiator",
"author_id": 446104,
"author_profile": "https://Stackoverflow.com/users/446104",
"pm_score": 1,
"selected": false,
"text": "1) Go to the Fridge \n2) Open the fridge door \n3) Search for eggs \n4) If there are no eggs - go to the shop to bu... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19082/"
] |
164,053 | <p>Should log classes open/close a log file stream on each write to the log file or should it keep the log file stream open throughout the application's lifetime until all logging is complete? </p>
<p>I'm asking in context of a desktop application. I have seen people do it both ways and was wondering which approach yields the best all-around results for a logger.</p>
| [
{
"answer_id": 164770,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 4,
"selected": false,
"text": "fstat()"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20133/"
] |
164,073 | <p>I've been thinking about this problem for a while and have yet to come up with any stable/elegant ideas.</p>
<p>I know with MyISAM tables, you can get the table def update time but thats not so true with InnoDB and I've found its not even reliable to look at the .frm file for an idea of when the definition might have been modified.... nevermind if the dataset has been changed.</p>
<p>I had an idea of every 30 minutes mysqldumping the contents of a schema, breaking that apart with an AWK script, then diffing that to the last version... but that seems a little excessive and could be a problem if the dataset involved is large.</p>
| [
{
"answer_id": 164318,
"author": "Gary Richardson",
"author_id": 2506,
"author_profile": "https://Stackoverflow.com/users/2506",
"pm_score": 2,
"selected": false,
"text": "mysqldump -d"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9908/"
] |
164,085 | <p>I need to execute a callback when an IFRAME has finished loading. I have no control over the content in the IFRAME, so I can't fire the callback from there.</p>
<p>This IFRAME is programmaticly created, and I need to pass its data as a variable in the callback, as well as destroy the iframe.</p>
<p>Any ideas?</p>
<p><strong>EDIT:</strong></p>
<p>Here is what I have now:</p>
<pre><code>function xssRequest(url, callback)
{
var iFrameObj = document.createElement('IFRAME');
iFrameObj.src = url;
document.body.appendChild(iFrameObj);
$(iFrameObj).load(function()
{
document.body.removeChild(iFrameObj);
callback(iFrameObj.innerHTML);
});
}
</code></pre>
<p>This callsback before the iFrame has loaded, so the callback has no data returned.</p>
| [
{
"answer_id": 204781,
"author": "Pier Luigi",
"author_id": 27789,
"author_profile": "https://Stackoverflow.com/users/27789",
"pm_score": 1,
"selected": false,
"text": "function xssRequest(url, callback)\n{\n var iFrameObj = document.createElement('IFRAME');\n iFrameObj.id = 'myUni... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
164,088 | <p>When designing a collection class, is there any reason not to implement locking privately to make it thread safe? Or should I leave that responsibility up to the consumer of the collection?</p>
| [
{
"answer_id": 3798398,
"author": "Ohad Schneider",
"author_id": 67824,
"author_profile": "https://Stackoverflow.com/users/67824",
"pm_score": 3,
"selected": false,
"text": "static int GetFirstOrDefault(ThreadSafeList<int> list) {\n if (list.Count > 0) {\n return list[0];\n ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11574/"
] |
164,093 | <p>in a C program I have an long* that I want to serialize (thus converting to chars). A long doesn't fit in a single char, and the size varies depending of the processor (can be 4 bytes or 8 bytes).</p>
<p>Theres a good way to make the serialization and de-serialization? </p>
| [
{
"answer_id": 164115,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 0,
"selected": false,
"text": "long list[MAX];\nchar *serial = list;\nint chunk = sizeof(long);\nint k;\nfor(k=0; k<(MAX*chunk); k++){\n // do something wi... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18403/"
] |
164,095 | <p>I'm writing a DSL in Ruby to control an Arduino project I'm working on; Bardino. It's a bar monkey that will be software controlled to serve drinks. The Arduino takes commands via the serial port to tell the Arduino what pumps to turn on and for how long.</p>
<p>It currently reads a recipe (see below) and prints it back out. The code for serial communications still need to be worked in as well as some other ideas that I have mentioned below.</p>
<p>This is my first DSL and I'm working off of a previous example so it's very rough around the edges. Any critiques, code improvements (are there any good references for Ruby DSL best practices or idioms?) or any general comments.</p>
<p>I currently have a rough draft of the DSL so a drink recipe looks like the following (<a href="http://github.com/mwilliams/barduino-tender/tree/571fb9128c02ce72b1f891d841930bf526f1432c/examples/water.rb" rel="nofollow noreferrer">Github link</a>):</p>
<pre><code>desc "Simple glass of water"
recipe "water" do
ingredients(
"Water" => 2.ounces
)
end
</code></pre>
<p>This in turn is interpreted and currently results with the following (<a href="http://github.com/mwilliams/barduino-tender/tree/571fb9128c02ce72b1f891d841930bf526f1432c/barduino-tender.rb" rel="nofollow noreferrer">Github link</a>):</p>
<pre><code>[mwilliams@Danzig barduino-tender]$ ruby barduino-tender.rb examples/water.rb
Preparing: Simple glass of water
Ingredients:
Water: 2 ounces
</code></pre>
<p>This is a good start for the DSL, however, I do think it could be implemented a little bit better. Some ideas I had below:</p>
<ol>
<li>Defining what "ingredients" are available using the name of the ingredient and the number pump that it's connected to. Maybe using a hash? ingredients = {"water" => 1, "vodka" => 2}. This way, when an ingredient is interpreted it can either a) send the pump number over the serial port followed by the number of ounces for the Arduino to dispense b) tell the user that ingredient does not exist and abort so nothing is dispensed c) easily have the capability to change or add new ingredients if they're changed.</li>
<li>Making the recipe look less code like, which is the main purpose of a DSL, maybe build a recipe builder? Using the available ingredients to prompt the user for a drink name, ingredients involved and how much?</li>
</ol>
<p>The Github project is <a href="http://github.com/mwilliams/barduino-tender/tree/master" rel="nofollow noreferrer">here</a>, feel free to fork and make pull requests, or post your code suggestions and examples here for other users to see. And if you're at all curious, the Arduino code, using the Ruby Arduino Development framework is <a href="http://github.com/mwilliams/barduino/tree/master" rel="nofollow noreferrer">here</a>.</p>
<p><strong>Update</strong></p>
<p>I modified and cleaned things up a bit to reflect Orion Edwards suggestion for a recipe. It now looks like the following.</p>
<pre><code>description 'Screwdriver' do
serve_in 'Highball Glass'
ingredients do
2.ounces :vodka
5.ounces :orange_juice
end
end
</code></pre>
<p>I also added a hash (key being the ingredient and the value the pump number it's hooked up to). I think this provided much progress. I'll leave the question open for any further suggestions for now, but will ultimately select Orion's answer. The updated DSL code is <a href="http://github.com/mwilliams/barduino-tender/tree/master/barduino-tender.rb" rel="nofollow noreferrer">here</a>.</p>
| [
{
"answer_id": 164358,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": true,
"text": "describe \"Long Island Iced Tea\" do\n serve_in 'Highball Glass'\n\n ingredients do\n half.ounce.of :vodka\n half... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23909/"
] |
164,102 | <p>For example, suppose I have a class:</p>
<pre><code>class Foo
{
public:
std::string& Name()
{
m_maybe_modified = true;
return m_name;
}
const std::string& Name() const
{
return m_name;
}
protected:
std::string m_name;
bool m_maybe_modified;
};
</code></pre>
<p>And somewhere else in the code, I have something like this:</p>
<pre><code>Foo *a;
// Do stuff...
std::string name = a->Name(); // <-- chooses the non-const version
</code></pre>
<p>Does anyone know why the compiler would choose the non-const version in this case?</p>
<p>This is a somewhat contrived example, but the actual problem we are trying to solve is periodically auto-saving an object if it has changed, and the pointer must be non-const because it might be changed at some point. </p>
| [
{
"answer_id": 164130,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "a"
},
{
"answer_id": 164139,
"author": "Lev",
"author_id": 7224,
"author_profile": "https://Stackoverflow.c... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9876/"
] |
164,105 | <p>I'm trying to write a Selenium test for a web page that uses an onbeforeunload event to prompt the user before leaving. Selenium doesn't seem to recognize the confirmation dialog that comes up, or to provide a way to hit OK or Cancel. Is there any way to do this? I'm using the Java Selenium driver, if that's relevant.</p>
| [
{
"answer_id": 26787603,
"author": "Louis",
"author_id": 1906307,
"author_profile": "https://Stackoverflow.com/users/1906307",
"pm_score": 1,
"selected": false,
"text": "onbeforeunload"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13210/"
] |
164,144 | <p>I have two DataTables, <code>A</code> and <code>B</code>, produced from CSV files. I need to be able to check which rows exist in <code>B</code> that do not exist in <code>A</code>.</p>
<p>Is there a way to do some sort of query to show the different rows or would I have to iterate through each row on each DataTable to check if they are the same? The latter option seems to be very intensive if the tables become large.</p>
| [
{
"answer_id": 164200,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 3,
"selected": false,
"text": "A.Merge(B); // this will add to A any records that are in B but not A\nreturn A.GetChanges(); // returns records origi... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6486/"
] |
164,147 | <p>As far as I can tell there's no simple way of retrieving a character offset from a TextRange object in Internet Explorer. The W3C Range object has a node, and the offset into the text within that node. IE seems to just have pixel offsets. There are methods to create, extend and compare ranges, so it would be possible to write an algorithm to calculate the character offset, but I feel I must be missing something.</p>
<p>So, what's the easiest way to calculate the character offset of the start of an Internet Explorer TextRange?</p>
| [
{
"answer_id": 164347,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 1,
"selected": false,
"text": "TextRange.text"
},
{
"answer_id": 198456,
"author": "Borgar",
"author_id": 27388,
"author_profile": ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24618/"
] |
164,154 | <p>I want to tune a production SQL server. After making adjustments (such as changing the degree of parallelism) I want to know if it helped or hurt query execution times.</p>
<p>This seems like an obvious performance counter, but for the last half hour I've been searching Google and the counter list in perfmon, and I have not been able to find a performance counter for SQL server to give me the average execution time for all queries hitting a server. The SQL Server equivalent of the ASP.NET Request Execution Time.</p>
<p>Does one exist that I'm missing? Is there another effective way of monitoring the average query times for a server?</p>
| [
{
"answer_id": 6338261,
"author": "Jason Jong",
"author_id": 209254,
"author_profile": "https://Stackoverflow.com/users/209254",
"pm_score": 1,
"selected": false,
"text": "File"
},
{
"answer_id": 60148054,
"author": "Joscelyn Gainié",
"author_id": 4015058,
"author_pro... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15118/"
] |
164,163 | <p>When implementing Quicksort, one of the things you have to do is to choose a pivot. But when I look at pseudocode like the one below, it is not clear how I should choose the pivot. First element of list? Something else?</p>
<pre><code> function quicksort(array)
var list less, greater
if length(array) ≤ 1
return array
select and remove a pivot value pivot from array
for each x in array
if x ≤ pivot then append x to less
else append x to greater
return concatenate(quicksort(less), pivot, quicksort(greater))
</code></pre>
<p>Can someone help me grasp the concept of choosing a pivot and whether or not different scenarios call for different strategies.</p>
| [
{
"answer_id": 237070,
"author": "mindvirus",
"author_id": 31455,
"author_profile": "https://Stackoverflow.com/users/31455",
"pm_score": 4,
"selected": false,
"text": "T(n) = O(n) (find the median) + O(n) (partition) + 2T(n/2) (recurse left and right)\n"
},
{
"answer_id": 5254733... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20032/"
] |
164,167 | <p>Warning: this is the actual code generated from my system:</p>
<pre><code>;WITH RESULTS AS (
SELECT 1174 AS BatchRunID, 'STATINV' AS Program, m.APPL_CD, m.ALBASE, 'CountFocusRecords' AS Measure, COUNT(*) AS Value
FROM [MISWork].[SX_FOCUS_NATIVE_200806] AS m WITH(NOLOCK)
INNER JOIN MISProcess.SXProcessCatalog AS cat WITH(NOLOCK)
ON cat.APPL_CD = m.APPL_CD
AND cat.ALBASE = m.ALBASE
AND COALESCE(cat.ProcessName, 'STATINV') = 'STATINV'
GROUP BY m.APPL_CD, m.ALBASE
UNION
SELECT 1174 AS BatchRunID, 'STATINV' AS Program, c.APPL_CD, c.ALBASE, 'CountBiminiRecords' AS Measure, COUNT(*) AS Value
FROM [MISWork].[SX_STATINV] AS c WITH(NOLOCK)
INNER JOIN MISProcess.SXProcessCatalog AS cat WITH(NOLOCK)
ON cat.APPL_CD = c.APPL_CD
AND cat.ALBASE = c.ALBASE
AND COALESCE(cat.ProcessName, 'STATINV') = 'STATINV'
GROUP BY c.APPL_CD, c.ALBASE
UNION
SELECT 1174 AS BatchRunID, 'STATINV' AS Program, m.APPL_CD, m.ALBASE, 'RecordsInFocusMissingInBimini' AS Measure, COUNT(*) AS Value
FROM [MISWork].[SX_FOCUS_NATIVE_200806] AS m WITH(NOLOCK)
LEFT JOIN [MISWork].[SX_STATINV] AS c WITH(NOLOCK)
ON m.[YEAR] = c.[YEAR]
AND m.[MONTH] = c.[MONTH]
AND m.[BANK_NO] = c.[BANK_NO]
AND m.[COST_CENTER] = c.[COST_CENTER]
AND m.[GLACCOUNT_NO] = c.[GLACCOUNT_NO]
AND m.[CUSTACCOUNT] = c.[CUSTACCOUNT]
AND m.[APPL_CD] = c.[APPL_CD]
AND m.[ALBASE] = c.[ALBASE]
INNER JOIN MISProcess.SXProcessCatalog AS cat WITH(NOLOCK)
ON cat.APPL_CD = m.APPL_CD
AND cat.ALBASE = m.ALBASE
AND COALESCE(cat.ProcessName, 'STATINV') = 'STATINV'
WHERE c.[YEAR] IS NULL
GROUP BY m.APPL_CD, m.ALBASE
UNION
SELECT 1174 AS BatchRunID, 'STATINV' AS Program, c.APPL_CD, c.ALBASE, 'RecordsInBiminiMissingInFocus' AS Measure, COUNT(*) AS Value
FROM [MISWork].[SX_FOCUS_NATIVE_200806] AS m WITH(NOLOCK)
RIGHT JOIN [MISWork].[SX_STATINV] AS c WITH(NOLOCK)
ON m.[YEAR] = c.[YEAR]
AND m.[MONTH] = c.[MONTH]
AND m.[BANK_NO] = c.[BANK_NO]
AND m.[COST_CENTER] = c.[COST_CENTER]
AND m.[GLACCOUNT_NO] = c.[GLACCOUNT_NO]
AND m.[CUSTACCOUNT] = c.[CUSTACCOUNT]
AND m.[APPL_CD] = c.[APPL_CD]
AND m.[ALBASE] = c.[ALBASE]
INNER JOIN MISProcess.SXProcessCatalog AS cat WITH(NOLOCK)
ON cat.APPL_CD = c.APPL_CD
AND cat.ALBASE = c.ALBASE
AND COALESCE(cat.ProcessName, 'STATINV') = 'STATINV'
WHERE m.[YEAR] IS NULL
GROUP BY c.APPL_CD, c.ALBASE
) SELECT * FROM RESULTS ORDER BY Program, APPL_CD, ALBASE, Measure
</code></pre>
<p>The code just sits there, no locking or blocking.</p>
<p>The individual components of the UNION return in a few seconds each. The code works in general for checking the output results of all the other programs in the STAT group, but just halts for this one.</p>
<p>Remove the CTE, no effect, sits there for 30 minutes/an hour, however long you care to wait before cancelling.</p>
<p>Remove the UNION, and the 4 result sets return in 11 seconds, total of 19 records accross all 4 result sets.</p>
<p>Run just the first two together - works fine, run just the last 2 together, also fine. First 3 together, fine, too.</p>
<p>I've already modified the code to output these to a #temp table, for other requirements, so I'm just going to change it to output each to the #temp table in sequence, but I have never seen SQL just stop like that with no evidence of blocking or anything.</p>
| [
{
"answer_id": 219012,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 0,
"selected": false,
"text": "<?xml version=\"1.0\"?>\n<ShowPlanXML xmlns=\"http://schemas.microsoft.com/sqlserver/2004/07/showplan\" Version=\"1.0\" ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18255/"
] |
164,168 | <p>If I want to construct a std::string with a line like:</p>
<pre><code>std::string my_string("a\0b");
</code></pre>
<p>Where i want to have three characters in the resulting string (a, null, b), I only get one. What is the proper syntax?</p>
| [
{
"answer_id": 164185,
"author": "17 of 26",
"author_id": 2284,
"author_profile": "https://Stackoverflow.com/users/2284",
"pm_score": 4,
"selected": false,
"text": "std::string my_string(\"a\\0b\", 3);\n"
},
{
"answer_id": 164211,
"author": "Jurney",
"author_id": 2642,
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17958/"
] |
164,181 | <p>How can I fetch images from a server?</p>
<p>I've got this bit of code which allows me to draw some images on a canvas.</p>
<pre><code><html>
<head>
<script type="text/javascript">
function draw(){
var canvas = document.getElementById('canv');
var ctx = canvas.getContext('2d');
for (i=0;i<document.images.length;i++){
ctx.drawImage(document.images[i],i*150,i*130);
}
}
</script>
</head>
<body onload="draw();">
<canvas id="canv" width="1024" height="1024"></canvas>
<img src="http://www.google.com/intl/en_ALL/images/logo.gif">
<img src="http://l.yimg.com/a/i/ww/beta/y3.gif">
<img src="http://static.ak.fbcdn.net/images/welcome/welcome_page_map.png">
</body>
</html>
</code></pre>
<p>Instead of looping over document.images, i would like to continually fetch images from a server.</p>
<pre><code>for (;;) {
/* how to fetch myimage??? */
myimage = fetch???('http://myserver/nextimage.cgi');
ctx.drawImage(myimage, x, y);
}
</code></pre>
| [
{
"answer_id": 164191,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 6,
"selected": true,
"text": "myimage = new Image();\nmyimage.src = 'http://myserver/nextimage.cgi';\n"
},
{
"answer_id": 164210,
"auth... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] |
164,194 | <p>The following code receives seg fault on line 2:</p>
<pre><code>char *str = "string";
str[0] = 'z'; // could be also written as *str = 'z'
printf("%s\n", str);
</code></pre>
<p>While this works perfectly well:</p>
<pre><code>char str[] = "string";
str[0] = 'z';
printf("%s\n", str);
</code></pre>
<p>Tested with MSVC and GCC.</p>
| [
{
"answer_id": 164227,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "\"whatever\""
},
{
"answer_id": 164229,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "htt... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24622/"
] |
164,197 | <p>I am working on an ASP.Net web application that must print dynamically created labels on standard Avery-style label sheets (one particular size, so only one overall layout). The labels have a variable number of lines (3-6) and may contain either lines of text or a graphic barcode image.</p>
<p>Our first cut, that I inherited, used monospaced fonts to reduce the formatting issues, but that did not allow enough text to the fit on the labels and the customer was dissatisfied. Basically it was formatted text.</p>
<p>My next version used TABLEs, DIVs, CSS, and a bit of JavaScript calculations to format the labels using proportional fonts. It still required a bit of tweaking (the user had to set their print margins correctly and turn off the print headers and footers), but it seemed to work. </p>
<p>However, it seems that there are some variations on how different printers render the text (WYS ain't WYG), so even though we tested on different browsers using at least two different printers (an inkjet and a laser printer), some user's labels don't line up. Slight margin variations can be adjusted by adjusting the margins on the page setup dialog, but the harder problem is that the inter-label spacing can be off by a tiny fraction of an inch, so that if the first label is pretty well centered, by the end of the page the label text and images have crawled off the top or bottom of the labels.</p>
<p>We are about to the point of switching to generating Word, Excel, or PDF output which is going to take quite a bit of development time and possible add extra steps in the printing process.</p>
<p>So, does anyone have any suggestions on how to do an HTML/CSS layout that will precisely render on different types of printers? I don't really care if the line/word breaks are a bit different, but I need to be able to predictably position the upper left corners of each label area.</p>
<p>Right now the labels flow down the page in a table and we have been tweaking the box model of the cells and internal DIVs to make them a uniform height. I suspect that using absolute positioning of each element may be the best answer, but that is going to be tricky as well due to the ASP.Net generation of the label elements. If I knew for sure that would work, I would rather try it than throw away everything we have to go to a different generation method.</p>
<p>Slight Update:
Right now I'm doing some tests with absolute positioning - setting only the top and left coordinate of a containing block element. So far there are minor variations on the offset onto the page (margins, paper alignment, etc.), but all browsers and printers tested put the elements in <strong><em>exactly</em></strong> the right spots relative to each other. I appreciate the PDF tips, but does anyone know of additional "gotchas" on using absolute positioning this way?</p>
<p><strong>Update:</strong>
For the record, I rewrote the label printing portion using iTextSharp and it works perfectly - definitely the way to do this in the future...</p>
| [
{
"answer_id": 33681423,
"author": "Bill Rawlinson",
"author_id": 7329,
"author_profile": "https://Stackoverflow.com/users/7329",
"pm_score": 2,
"selected": false,
"text": "LabelDefinition"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14894/"
] |
164,282 | <p>Specifically, we've got some external JavaScript tracking code on our sites that throws itself into an infinite loop each time an anchor is clicked on.</p>
<p>We don't maintain the tracking code, so we don't know exactly how it works. Since the code causes the browser to lock up almost immediately, I was wondering if there's anyway to log the results of Firebug's 'profile' functionality to an external file for review?</p>
| [
{
"answer_id": 33681423,
"author": "Bill Rawlinson",
"author_id": 7329,
"author_profile": "https://Stackoverflow.com/users/7329",
"pm_score": 2,
"selected": false,
"text": "LabelDefinition"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22468/"
] |
164,284 | <p>I would like to transfer a text file to a webserver using wininet as if the file was being transferred using a web form that posts the file to the server.</p>
<p>Based on answers I've received I've tried the following code:</p>
<pre><code> static TCHAR hdrs[] = "Content-Type: multipart/form-data\nContent-Length: 25";
static TCHAR frmdata[] = "file=filename.txt\ncontent";
HINTERNET hSession = InternetOpen("MyAgent",
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
HINTERNET hConnect = InternetConnect(hSession, "example.com",
INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);
HINTERNET hRequest = HttpOpenRequest(hConnect, "POST", "test.php", NULL, NULL, NULL, 0, 1);
HttpSendRequest(hRequest, hdrs, strlen(hdrs), frmdata, strlen(frmdata));");
</code></pre>
<p>The test.php script is being run, but it doesn't appear to be getting the correct data.</p>
<p>Could anyone give me any additional help or somewhere to look? Thanks.</p>
| [
{
"answer_id": 164502,
"author": "Gustavo Carreno",
"author_id": 8167,
"author_profile": "https://Stackoverflow.com/users/8167",
"pm_score": 2,
"selected": false,
"text": "POST /file_upload.php HTTP/1.0\nContent-type: multipart/form-data\nContent-length: <calculated string's length: inte... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24628/"
] |
164,305 | <p>I'm using CodeSynthesis XSD C++/Tree Mapping utility to convert an existing xsd into c++ code we can populate the values in. This was we always make sure we follow the schema.</p>
<p>After doing the conversion, I'm trying to get it to work so I can test it. Problem is, I'm not used to doing this in c++ and it's my first time with this tool.</p>
<p>I start with a class called ABSTRACTNETWORKMODEL with types <code>versno_type</code> and <code>fromtime_type</code>
typedef'd inside. Here is the constructor I am trying to use as well as the typedefs</p>
<pre><code>ABSTRACTNETWORKMODEL(const versno_type&, const fromtime_type&);
typedef ::xml_schema::double_ versno_type;
typedef ::xml_schema::time fromtime_type;
</code></pre>
<p>all these are in the ABSTRACTNETWORKMODEL class and the definitions for double_ and time are:</p>
<pre><code>typedef ::xsd::cxx::tree::time<char, simple_type> time;
typedef double double_;
</code></pre>
<p>where the definition for time is a class with multiple constructors:</p>
<pre><code>template<typename C, typename B>
class time: public B, public time_zone
{
public:
time(unsigned short hours, unsigned short minutes, double seconds);
...
}
</code></pre>
<p>I know I'm not correctly creating a new ABSTRACTNETWORKMODEL but I don't know what I need to do this. Here is all I'm trying to do at this point:</p>
<pre><code> ::xml_schema::time t();
ABSTRACTNETWORKMODEL anm(1234, t);
</code></pre>
<p>This, of course, throws an error about converting the second parameter, but can somebody tell me what it is that is incorrect? Or at least point me down the right path, as one of the things I'm trying to do right now is learn more c++.</p>
| [
{
"answer_id": 168157,
"author": "Max Lybbert",
"author_id": 10593,
"author_profile": "https://Stackoverflow.com/users/10593",
"pm_score": 3,
"selected": true,
"text": "::xml_schema::time t();\n"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23553/"
] |
164,307 | <p>With the MacPorts version of ImageMagick 6.4.4 installed, I'm getting an error installing the RMagick gem.</p>
<pre><code>/opt/local/bin/ruby extconf.rb update rmagick
checking for Ruby version >= 1.8.2... yes
checking for /usr/bin/gcc-4.0... yes
checking for Magick-config... no
Can't install RMagick 2.7.0. Can't find Magick-config in
/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands:
/Users/jason/.bin:/opt/local/bin:/usr/local/bin:/usr/local/mysql/bin:
/usr/local/ec2-api-tools/bin:/opt/local/bin:/usr/bin:
/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
</code></pre>
<p>I've installed older versions of rmagick successfully. I've seen references to a dev package of ImageMagick, but it doesn't seem to be available from MacPorts.</p>
<p>How can I install RMagick 2.7 on Mac OS X with ImageMagick 6.4.4 from MacPorts?</p>
| [
{
"answer_id": 165656,
"author": "user6325",
"author_id": 6325,
"author_profile": "https://Stackoverflow.com/users/6325",
"pm_score": 3,
"selected": false,
"text": "sudo port install tiff -macosx imagemagick +q8 +gs +wmf\n"
},
{
"answer_id": 1476485,
"author": "ehaselwanter",... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11078/"
] |
164,319 | <p>I learned something simple about SQL the other day:</p>
<pre><code>SELECT c FROM myTbl GROUP BY C
</code></pre>
<p>Has the same result as:</p>
<pre><code>SELECT DISTINCT C FROM myTbl
</code></pre>
<p>What I am curious of, is there anything different in the way an SQL engine processes the command, or are they truly the same thing? </p>
<p>I personally prefer the distinct syntax, but I am sure it's more out of habit than anything else.</p>
<p>EDIT: This is not a question about aggregates. The use of <code>GROUP BY</code> with aggregate functions is understood.</p>
| [
{
"answer_id": 164329,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 8,
"selected": false,
"text": "GROUP BY"
},
{
"answer_id": 164331,
"author": "jkramer",
"author_id": 12523,
"author_profile": "htt... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5836/"
] |
164,324 | <p>I need to get the Folder size and display the info on a report (SSRS). I need to do this for a number of Databases (loop!). These DB's are websites' backends.</p>
<p>Are any samples available for this? Does xp_filesize and the like the right solution?</p>
| [
{
"answer_id": 179648,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "System.IO.Directory"
},
{
"answer_id": 186836,
"author": "Meff",
"author_id": 9647,
"author_profile": ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10385/"
] |
164,335 | <p>Any XPath like /NodeName/position() would give you the position of the Node w.r.t it's parent node.</p>
<p>There is no method on the XElement (Linq to XML) object that can get the position of the Element. Is there?</p>
| [
{
"answer_id": 164444,
"author": "Michael Damatov",
"author_id": 23372,
"author_profile": "https://Stackoverflow.com/users/23372",
"pm_score": 0,
"selected": false,
"text": "static int Position(this XNode node) {\n var position = 0;\n foreach(var n in node.Parent.Nodes()) {\n if(n =... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1747/"
] |
164,342 | <p>I'm considering one of two IRepository interfaces, one that is a descendant of IQueryable and one that contains IQueryable. </p>
<p>Like this:</p>
<pre><code>public interface IRepository<T> : IQueryable<T>
{
T Save(T entity);
void Delete(T entity);
}
</code></pre>
<p>Or this:</p>
<pre><code>public interface IRepository<T>
{
T Save(T entity);
void Delete(T entity);
IQueryable<T> Query();
}
</code></pre>
<p>LINQ usage would be:</p>
<pre><code>from dos
in ServiceLocator.Current.GetInstance<IRepository<DomainObject>>()
where dos.Id == id
select dos
</code></pre>
<p>Or...</p>
<pre><code>from dos
in ServiceLocator.Current.GetInstance<IRepository<DomainObject>>().Query
where dos.Id == id
select dos
</code></pre>
<p>I kinda like the first one, but it's problematic to mock. How have other people implemented LINQable, mockable repositories?</p>
| [
{
"answer_id": 5319662,
"author": "Pure.Krome",
"author_id": 30674,
"author_profile": "https://Stackoverflow.com/users/30674",
"pm_score": 3,
"selected": false,
"text": "Repository Pattern"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3759/"
] |
164,343 | <p>I'm playing around with BCEL. I'm not using it to generate bytecode, but instead I'm trying to inspect the structure of existing compiled classes.</p>
<p>I need to be able to point to an arbitrary .class file anywhere on my hard drive and load a <a href="http://jakarta.apache.org/bcel/apidocs/org/apache/bcel/classfile/JavaClass.html" rel="noreferrer">JavaClass</a> object based on that. Ideally I'd like to avoid having to add the given class to my classpath.</p>
| [
{
"answer_id": 10858280,
"author": "ILOVEPIE",
"author_id": 1164259,
"author_profile": "https://Stackoverflow.com/users/1164259",
"pm_score": 2,
"selected": false,
"text": "new ClassParser(classfilebytearrayhere).parse()\n"
},
{
"answer_id": 32984765,
"author": "JITHIN_PATHRO... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1247/"
] |
164,344 | <p>How can I make my <code>std::fstream</code> object start reading a text file from the second line?</p>
| [
{
"answer_id": 164353,
"author": "Doug T.",
"author_id": 8123,
"author_profile": "https://Stackoverflow.com/users/8123",
"pm_score": 5,
"selected": false,
"text": "ifstream stream(\"filename.txt\");\nstring dummyLine;\ngetline(stream, dummyLine);\n// Begin reading your stream here\nwhile... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
164,356 | <p>For example, I'm writing a multi-threaded time-critical application that processes and streams audio in real-time. Interruptions in the audio are totally unacceptable. Does this mean I cannot use the STL because of the potential slow down when an exception is thrown? </p>
| [
{
"answer_id": 164423,
"author": "Henk",
"author_id": 4613,
"author_profile": "https://Stackoverflow.com/users/4613",
"pm_score": 1,
"selected": false,
"text": "std::vector::at()"
},
{
"answer_id": 1281627,
"author": "paercebal",
"author_id": 14089,
"author_profile": ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13760/"
] |
164,369 | <p>While I'm googling/reading for this answer I thought I would also ask here. </p>
<p>I have a class that is a wrapper for a SDK. The class accepts an ILoader object and uses the ILoader object to create an ISBAObject which is cast into an ISmallBusinessInstance object. I am simply trying to mock this behavior using Moq.</p>
<pre><code> [TestMethod]
public void Test_Customer_GetByID()
{
var mock = new Mock<ILoader>();
var sbainst = new Mock<ISbaObjects>();
mock.Expect(x => x.GetSbaObjects("")).Returns(sbainst);
}
</code></pre>
<p>The compiler error reads: Error 1 The best overloaded method match for 'Moq.Language.IReturns.Returns(Microsoft.BusinessSolutions.SmallBusinessAccounting.Loader.ISbaObjects)' has some invalid arguments</p>
<p>What is going on here? I expected the Mock of ISbaObjects to be able to be returned without a problem.</p>
| [
{
"answer_id": 169182,
"author": "Trevor Abell",
"author_id": 2916,
"author_profile": "https://Stackoverflow.com/users/2916",
"pm_score": 2,
"selected": false,
"text": "[TestMethod]\npublic void Test_Customer_GetByID()\n{\n var mock = new Mock<ILoader>();\n\n var sbainst = new Mock... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2916/"
] |
164,382 | <p>We've been creating banners using the getURL linking method (in a blank window). For many people, it works just fine. You click the banner and are taken to our site. For others (me included), clicking the flash object triggers a pop-up warning in FireFox (both 2 and 3, default settings). The weird thing is that it doesn't happen for everyone. It happens on my main machine (vista 64, FF3) but not on my secondary machine (XP 64, FF3). I have other people running Vista/FF3 just like me, and it's working fine for them...but not me. </p>
<p>An example is the 300x250 banner on the left side of this page:
<a href="http://www.jguitar.com/" rel="nofollow noreferrer">http://www.jguitar.com/</a></p>
<p>We're pretty stumped and have no idea why this is happening. Any feedback would be greatly appreicated.</p>
| [
{
"answer_id": 615018,
"author": "Pascal Immerzeel",
"author_id": 1729,
"author_profile": "https://Stackoverflow.com/users/1729",
"pm_score": 0,
"selected": false,
"text": "private function click(event : MouseEvent) : void {\n getURL(LoaderInfo(root.loaderInfo).parameters.clic kTag);\... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24632/"
] |
164,393 | <p>In the quest for localization I need to find all the string literals littered amongst our source code. I was looking for a way to script this into a post-modification source repository check. (I.E. after some one checks something in have a box setup to check this stat) I'll probably use NAnt and CruiseControl or something to handle the management of the CVS (Well StarTeam in my case :( ) But do you know of any scriptable (or command line) utility to accurately cycle through source code looking for string literals? I realize I could do simple string look up based on regular expressions but want a little more bang for my buck. (Maybe analyze the string or put it into categories) Because a lot of times the string may not necessarily require translation. Any ideas?</p>
| [
{
"answer_id": 164439,
"author": "Duncan Smart",
"author_id": 1278,
"author_profile": "https://Stackoverflow.com/users/1278",
"pm_score": 6,
"selected": true,
"text": ":q"
},
{
"answer_id": 29919882,
"author": "gleichdanke",
"author_id": 715724,
"author_profile": "htt... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13688/"
] |
164,395 | <p>I'm wondering if its possible to add new class data members at run-time in PHP?</p>
| [
{
"answer_id": 164418,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 5,
"selected": true,
"text": "$prop = 'newname';\n$obj->$prop = 42;\n"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708/"
] |
164,397 | <p>How can I print a message to the error console, preferably including a variable? </p>
<p>For example, something like:</p>
<pre><code>print('x=%d', x);
</code></pre>
| [
{
"answer_id": 164408,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 10,
"selected": true,
"text": "console.log(...)"
},
{
"answer_id": 3060267,
"author": "Ivo Danihelka",
"author_id": 101097,
"author_profi... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] |
164,414 | <p>I'm processing a file, line-by-line, and I'd like to do an inverse match. For instance, I want to match lines where there is a string of six letters, but only if these six letters are not '<em>Andrea</em>'. How should I do that?</p>
<p>I'm using <a href="https://en.wikipedia.org/wiki/RegexBuddy" rel="noreferrer">RegexBuddy</a>, but still having trouble.</p>
| [
{
"answer_id": 164419,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 8,
"selected": true,
"text": "(?!Andrea).{6}\n"
},
{
"answer_id": 164440,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21384/"
] |
164,425 | <p>I am building a fun little app to determine if I should bike to work.</p>
<p>I would like to test to see if it is either Raining or Thunderstorm(ing).</p>
<pre><code>public enum WeatherType : byte
{ Sunny = 0, Cloudy = 1, Thunderstorm = 2, Raining = 4, Snowing = 8, MostlyCloudy = 16 }
</code></pre>
<p>I was thinking I could do something like: </p>
<pre><code>WeatherType _badWeatherTypes = WeatherType.Thunderstorm | WeatherType.Raining;
if(currentWeather.Type == _badWeatherTypes)
{
return false;//don't bike
}
</code></pre>
<p>but this doesn't work because _badWeatherTypes is a combination of both types. I would like to keep them separated out because this is supposed to be a learning experience and having it separate may be useful in other situations (IE, Invoice not paid reason's etc...).</p>
<p>I would also rather not do: (this would remove the ability to be configured for multiple people)</p>
<pre><code>if(WeatherType.Thunderstorm)
{
return false; //don't bike
}
etc...
</code></pre>
| [
{
"answer_id": 164455,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "if ((currentWeather.Type & _badWeatherTypes) == _badWeatherTypes)\n"
},
{
"answer_id": 164466,
"author": "Sco... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18821/"
] |
164,427 | <p>I've made a Django site, but I've drank the Koolaid and I want to make an <em>IPhone</em> version. After putting much thought into I've come up with two options:</p>
<ol>
<li>Make a whole other site, like i.xxxx.com. Tie it into the same database using Django's sites framework.</li>
<li>Find some time of middleware that reads the user-agent, and changes the template directories dynamically.</li>
</ol>
<p>I'd really prefer option #2, however; I have some reservations, mainly because the Django documentation <a href="http://docs.djangoproject.com/en/dev/topics/settings/" rel="noreferrer">discourages changing settings on the fly</a>. I found a <a href="http://www.djangosnippets.org/snippets/1098/" rel="noreferrer">snippet</a> that would do the what I'd like. My main issue is having it as seamless as possible, I'd like it to be automagic and transparent to the user.</p>
<p>Has anyone else come across the same issue? Would anyone care to share about how they've tackled making IPhone versions of Django sites?</p>
<p><strong>Update</strong></p>
<p>I went with a combination of middleware and tweaking the template call.</p>
<p>For the middleware, I used <a href="http://code.google.com/p/minidetector/" rel="noreferrer">minidetector</a>. I like it because it detects a <a href="http://www.youtube.com/watch?v=b6E682C7Jj4" rel="noreferrer">plethora</a> of mobile user-agents. All I have to do is check request.mobile in my views.</p>
<p>For the template call tweak:</p>
<pre><code> def check_mobile(request, template_name):
if request.mobile:
return 'mobile-%s'%template_name
return template_name
</code></pre>
<p>I use this for any view that I know I have both versions.</p>
<p><strong>TODO:</strong></p>
<ul>
<li>Figure out how to access <em>request.mobile</em> in an extended version of render_to_response so I don't have to use check_mobile('template_name.html')</li>
<li>Using the previous automagically fallback to the regular template if no mobile version exists.</li>
</ul>
| [
{
"answer_id": 3487254,
"author": "Aneil Mallavarapu",
"author_id": 305149,
"author_profile": "https://Stackoverflow.com/users/305149",
"pm_score": 4,
"selected": false,
"text": "import re\nMOBILE_AGENT_RE=re.compile(r\".*(iphone|mobile|androidtouch)\",re.IGNORECASE)\nclass MobileMiddlew... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24630/"
] |
164,460 | <p>The standalone flashplayer takes no arguments other than a .swf file when you launch it from the command line. I need the player to go full screen, no window borders and such. This can be accomplished by hitting ctrl+f once the program has started. I want to do this programmatically as I need it to launch into full screen without any human interaction.</p>
<p>My guess is that I need to some how get a handle to the window and then send it an event that looks like the "ctrl+f" keystroke. </p>
<p>If it makes any difference, it looks like flashplayer is a gtk application and I have python with pygtk installed.</p>
<p><b>UPDATE</b> (the solution I used... thanks to ypnos' answer):</p>
<pre><code>./flashplayer http://example.com/example.swf & sleep 3 && ~/xsendkey -window "Adobe Flash Player 10" Control+F
</code></pre>
| [
{
"answer_id": 277865,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "nspluginplayer --fullscreen src=path/to/flashfile.swf\n"
},
{
"answer_id": 3994891,
"author": "Daniel",
"autho... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11176/"
] |
164,468 | <p>The IT department of a subsidiary of ours had a consulting company write them an ASP.NET application. Now it's having intermittent problems with mixing up who the current user is and has been known to show Joe some of Bob's data by mistake.</p>
<p>The consultants were brought back to troubleshoot and we were invited to listen in on their explanation. Two things stuck out.</p>
<p>First, the consultant lead provided this pseudo-code:</p>
<pre><code>void MyFunction()
{
Session["UserID"] = SomeProprietarySessionManagementLookup();
Response.Redirect("SomeOtherPage.aspx");
}
</code></pre>
<p>He went on to say that the assignment of the session variable is asynchronous, which seemed untrue. Granted the call into the lookup function could do something asynchronously, but this seems unwise.</p>
<p>Given that alleged asynchronousness, his theory was that the session variable was not being assigned before the redirect's inevitable ThreadAbort exception was raised. This faulure then prevented SomeOtherPage from displaying the correct user's data.</p>
<p>Second, he gave an example of a coding best practice he recommends. Rather than writing:</p>
<pre><code>int MyFunction(int x, int x)
{
try
{
return x / y;
}
catch(Exception ex)
{
// log it
throw;
}
}
</code></pre>
<p>the technique he recommended was:</p>
<pre><code> int MyFunction(int x, int y, out bool isSuccessful)
{
isSuccessful = false;
if (y == 0)
return 0;
isSuccessful = true;
return x / y;
}
</code></pre>
<p>This will certainly work and could be better from a performance perspective in some situations.</p>
<p>However, from these and other discussion points it just seemed to us that this team was not well-versed technically.</p>
<p>Opinions?</p>
| [
{
"answer_id": 164530,
"author": "Duncan Smart",
"author_id": 1278,
"author_profile": "https://Stackoverflow.com/users/1278",
"pm_score": 0,
"selected": false,
"text": "try..catch"
},
{
"answer_id": 164565,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12260/"
] |
164,496 | <p>I've been reading about thread-safe singleton patterns here:</p>
<p><a href="http://en.wikipedia.org/wiki/Singleton_pattern#C.2B.2B_.28using_pthreads.29" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Singleton_pattern#C.2B.2B_.28using_pthreads.29</a></p>
<p>And it says at the bottom that the only safe way is to use pthread_once - which isn't available on Windows.</p>
<p>Is that the <strong>only</strong> way of guaranteeing thread safe initialisation?</p>
<p>I've read this thread on SO:</p>
<p><a href="https://stackoverflow.com/questions/6915/thread-safe-lazy-contruction-of-a-singleton-in-c">Thread safe lazy construction of a singleton in C++</a></p>
<p>And seems to hint at an atomic OS level swap and compare function, which I assume on Windows is:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms683568.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms683568.aspx</a></p>
<p>Can this do what I want?</p>
<p><strong>Edit:</strong> I would like lazy initialisation and for there to only ever be one instance of the class.</p>
<p>Someone on another site mentioned using a global inside a namespace (and he described a singleton as an anti-pattern) - how can it be an "anti-pattern"?</p>
<p><strong>Accepted Answer:</strong><br>
I've accepted <a href="https://stackoverflow.com/questions/164496/how-can-i-create-a-thread-safe-singleton-pattern-in-windows#164640">Josh's answer</a> as I'm using Visual Studio 2008 - NB: For future readers, if you aren't using this compiler (or 2005) - Don't use the accepted answer!!</p>
<p><strong>Edit:</strong>
<strong>The code works fine except the return statement - I get an error:
error C2440: 'return' : cannot convert from 'volatile Singleton *' to 'Singleton *'.
Should I modify the return value to be volatile Singleton *?</strong></p>
<p><strong>Edit:</strong> Apparently const_cast<> will remove the volatile qualifier. Thanks again to Josh.</p>
| [
{
"answer_id": 164534,
"author": "Matthew Murdoch",
"author_id": 4023,
"author_profile": "https://Stackoverflow.com/users/4023",
"pm_score": 4,
"selected": false,
"text": "// A critical section guard - create on the stack to provide \n// automatic locking/unlocking even in the face of un... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] |
164,520 | <p><strong>Premise:</strong>
Usually during preparation of a new Ruby on Rails App, I draw out models and relations regarding user navigations. Usually I hit a place where I need to ask myself, whether or not I should go beyond the usual "rule of thumb" of nesting no more 1 level deep. Sometimes I feel the need to nest, rather than creating another namespace route and duplicating work.
<br/>Here's an example:<br/></p>
<p><strong>Models:</strong> User, Company, Location <br/>
User has and belongs to many Companies (many to many) <br/>
User has and belongs to many Locations (many to many) <br/>
Company has and belongs to many Locations (many to many) <br/></p>
<p><strong>Routes:</strong><br/>
<strong><em>1 level nesting</em></strong> <br/>
users/:user_id/companies/ - list all companies related to a user<br/>
users/:user_id/locations/ - list all locations related to a user<br/>
<strong><em>more than 1 level nesting</em></strong><br/>
users/:user_id/companies/:company_id/locations/ - list all company-locations of a user</p>
<p><strong>So, my question is whether or not it is appropriate to nest more than 1 level deep in RoR? Yes or no? And why?</strong></p>
| [
{
"answer_id": 164875,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 2,
"selected": false,
"text": "users/:user_id/companies/:company_id/locations/\n"
},
{
"answer_id": 165537,
"author": "Dave Smylie",
"a... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24393/"
] |
164,527 | <p>In .NET, if a class contains a member that is a class object, should that member be exposed as a property or with a method?</p>
| [
{
"answer_id": 164553,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 5,
"selected": false,
"text": "public string Name\nget \n{\n return name;\n}\nset \n{\n name = value;\n}\n"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19065/"
] |
164,564 | <p>Edit: Ryan raised a good point. I specifically want to be able to map to and from while still storing human-readable values in the database. That is, I don't want a bunch of enumeration integers in my database.</p>
| [
{
"answer_id": 214276,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 0,
"selected": false,
"text": "<property name=\"EnumProperty\" Type=\"string\" Length=\"50\" NotNull=\"true\" />\n"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] |
164,575 | <p>I'm writing out XML files using the MSXML parser, with a wrapper I downloaded from here: <a href="http://www.codeproject.com/KB/XML/JW_CXml.aspx" rel="noreferrer">http://www.codeproject.com/KB/XML/JW_CXml.aspx</a>. Works great except that when I create a new document from code (so not load from file and modify), the result is all in one big line. I'd like elements to be indented nicely so that I can read it easily in a text editor.</p>
<p>Googling shows many people with the same question - asked around 2001 or so. Replies usually say 'apply an XSL transformation' or 'add your own whitespace nodes'. Especially the last one makes me go %( so I'm hoping that in 2008 there's an easier way to pretty MSXML output. So my question; is there, and how do I use it?</p>
| [
{
"answer_id": 164662,
"author": "Torlack",
"author_id": 5243,
"author_profile": "https://Stackoverflow.com/users/5243",
"pm_score": 3,
"selected": true,
"text": "#include <msxml2.h>\n\nbool FormatDOMDocument (IXMLDOMDocument *pDoc, IStream *pStream)\n{\n\n // Create the writer\n\n ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11449/"
] |
164,585 | <p>I'm serializing an object in a C# VS2003 / .Net 1.1 application. I need it serialized without the processing instruction, however. The XmlSerializer class puts out something like this:</p>
<pre><code><?xml version="1.0" encoding="utf-16" ?>
<MyObject>
<Property1>Data</Property1>
<Property2>More Data</Property2>
</MyObject>
</code></pre>
<p>Is there any way to get something like the following, without processing the resulting text to remove the tag?</p>
<pre><code><MyObject>
<Property1>Data</Property1>
<Property2>More Data</Property2>
</MyObject>
</code></pre>
<p>For those that are curious, my code looks like this...</p>
<pre><code>XmlSerializer serializer = new XmlSerializer(typeof(MyObject));
StringBuilder builder = new StringBuilder();
using ( TextWriter stringWriter = new StringWriter(builder) )
{
serializer.Serialize(stringWriter, comments);
return builder.ToString();
}
</code></pre>
| [
{
"answer_id": 164604,
"author": "harpo",
"author_id": 4525,
"author_profile": "https://Stackoverflow.com/users/4525",
"pm_score": 0,
"selected": false,
"text": "XmlSerializer serializer = new XmlSerializer(typeof(MyObject));\nStringBuilder builder = new StringBuilder();\nXmlWriterSettin... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24222/"
] |
164,594 | <p>I have a c# application that interfaces with the database only through stored procedures. I have tried various techniques for calling stored procedures. At the root is the SqlCommand class, however I would like to achieve several things:</p>
<ul>
<li>make the interface between c# and sql smoother, so that procedure calls look more like c# function calls</li>
<li>have an easy way to determine whether a given stored procedure is called anywhere in code.</li>
<li>make the creation of a procedure call quick and easy.</li>
</ul>
<p>I have explored various avenues. In one, I had a project that with its namespace structure mirrored the name structure of stored procedures, that way I could generate the name of the stored procedure from the name of the class, and I could tell whether a given stored procedure was in use by fining it in the namespace tree. What are some other experiences?</p>
| [
{
"answer_id": 164637,
"author": "Micky McQuade",
"author_id": 12908,
"author_profile": "https://Stackoverflow.com/users/12908",
"pm_score": 2,
"selected": false,
"text": "Public Shared Function GetOrg(ByVal OrgID As Integer) As System.Data.DataSet\n Return db.ExecuteDataSet(\"dbo.cp_... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13855/"
] |
164,597 | <p>My server has both Subversion and Apache installed, and the Apache web directory is also a Subversion working copy. The reason for this is that the simple command <code>svn update /server/staging</code> will deploy the latest source to the staging server.</p>
<p>Apache public web directory: <code>/server/staging</code> <em>— (This is an SVN working copy.)</em></p>
<p>I have two users on my server, 'richard' and 'austin'. They both are members of the 'developers' group. I recursively set permissions on the /server directory to richard:developers, using "sudo chown -R richard:developers /server".</p>
<p>I then set the permissions to read, write and execute for both 'richard' and the 'developers' group.</p>
<p>So surely, 'austin' should now be able to use the <code>svn update /server/staging</code> command? However, when he tries, he gets the error:</p>
<pre><code>svn: Can't open file '/server/staging/.svn/lock': Permission denied
</code></pre>
<p>If I recursively change the owner of /server to austin:developers, he can run the command just fine, but then 'richard' can't.</p>
<p>How do I fix the problem? I want to create a post-commit hook with to automatically deploy the staging site when files are committed, but I can't see a way for that to work for both users. The hook would be:</p>
<pre><code>/usr/bin/svn update /server/staging
</code></pre>
<p>Using the same user account for both of them wouldn't really be an acceptable solution, and I'm not aware of any way to run the command inside the hook as 'root'.</p>
<p>Any help is appreciated!</p>
| [
{
"answer_id": 164646,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 0,
"selected": false,
"text": "svnserve"
},
{
"answer_id": 164654,
"author": "zappan",
"author_id": 4723,
"author_profile": "https:/... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/326176/"
] |
164,613 | <p>I've heard the advice that you should avoid try catch blocks if possible since they're expensive.</p>
<p>My question is specifically about the .NET platform: Why are try blocks expensive?</p>
<p><strong>Summary of Responses:</strong></p>
<p>There are clearly two camps on this issue: those that say that try blocks are expensive, and those that say "maybe a tiny little bit".</p>
<p>Those that say try blocks are expensive normally mention the "high cost" of unwinding the call stack. Personally, I'm not convinced by that argument - specially after reading about how exceptions handlers are stored <a href="http://www.yoda.arachsys.com/csharp/exceptions2.html" rel="nofollow noreferrer">here</a>.</p>
<p>Jon Skeet sits on the "maybe a tiny little bit" camp, and has written two articles on exceptions and performance which you can find <a href="https://jonskeet.uk/csharp/exceptions2.html" rel="nofollow noreferrer">here</a>.</p>
<p>There was one article that I found extremely interesting: it talked about "other" performance implications of try blocks (not necessarily memory or cpu consumption). Peter Ritchie mentions that he found that code inside try blocks is not optimized as it'd otherwise be by the compiler. You can read about his findings <a href="http://msmvps.com/blogs/peterritchie/archive/2007/06/22/performance-implications-of-try-catch-finally.aspx" rel="nofollow noreferrer">here</a>.</p>
<p>Finally, there's a blog entry about the issue from the man that implemented exceptions in the CLR. Go take a look at Chris Brumme's article <a href="https://cbrumme.dev/the-exception-model" rel="nofollow noreferrer">here</a>.</p>
| [
{
"answer_id": 165352,
"author": "Michael Petrotta",
"author_id": 23897,
"author_profile": "https://Stackoverflow.com/users/23897",
"pm_score": 2,
"selected": false,
"text": "using System;\nusing System.Diagnostics;\n\nnamespace Test\n{\n class Program\n {\n static void Main... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/781/"
] |
164,621 | <p>I need to create reports in a C# .NET Windows app. I've got an SQL Server 2005 database, Visual Studio 2005 and am quite OK with creating stored procedures and datasets.</p>
<p>Can someone please point me in the right direction for creating reports? I just can't seem work it out. Some examples would be a good start, or a simple How-to tutorial... anything really that is a bit better explained than the MSDN docs.</p>
<p>I'm using the CrystalDecisions.Windows.Forms.CrystalReportViewer control to display the reports, I presume this is correct.</p>
<p>If I'm about to embark on a long and complex journey, what's the simplest way to create and display reports that can also be printed?</p>
| [
{
"answer_id": 165003,
"author": "SeaDrive",
"author_id": 19267,
"author_profile": "https://Stackoverflow.com/users/19267",
"pm_score": 1,
"selected": false,
"text": "AcctStatement oRpt = new AcctStatement() ;\noRpt.Database.Tables[0].SetDataSource(dsRpt.Tables[0]);\noRpt.SetParameterVal... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18854/"
] |
164,630 | <p>My app open file in subdirectory of directory where it is executed, subdirectory is called <code>sample</code> and it contains files:</p>
<ul>
<li><code>example.raf</code> (example extension, non significant)</li>
<li><code>background.gif</code></li>
</ul>
<p><code>example.raf</code> contains relative path to <code>background.gif</code> (in this case only file name cause the files is in same directory as raf) and opening of RAF causes application to read and display <code>background.gif</code>.</p>
<p>When I use <code>OpenFileDialog</code> to load RAF file everything is alright, image loads correctly. I know that open file dialog changes in some way current working directory but i was unable to recreate this without calling open file dialog</p>
<p>Unfortunately in case when i call <strong>raf reading</strong> method directly from code, without supplying path to file form <code>OpenFileDialog</code> like this</p>
<pre><code>LoadRAF("sample\\example.raf");
</code></pre>
<p>in this case i got problem, app try to load image from <strong>ExecutablePath</strong> and not from subdirectory which contains <strong>RAF</strong> file and <strong>image</strong>. Ofcourse it is normal behavior but in this case it is highkly unwanted. It is required to handle both relative and absolute type of paths in my app, so what should i do to solve this, how to <strong>change ExecutablePath</strong> or what other thing i can do to make this work at least as in case of <code>OpenFileDialog</code>?</p>
| [
{
"answer_id": 164667,
"author": "Bob King",
"author_id": 6897,
"author_profile": "https://Stackoverflow.com/users/6897",
"pm_score": 1,
"selected": false,
"text": "string parentPath = Directory.GetParent(rafFilePath);\nstring imagePath = Path.Combine(parentPath, imageFileNameFromRaf);\n... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
164,642 | <p>How do I create a grails war file so that it doesn't have the version number</p>
<p>(e.g. foo-0.1.war) </p>
<p>attached to the end when I execute the 'grails war' command?</p>
| [
{
"answer_id": 164702,
"author": "Instantsoup",
"author_id": 9861,
"author_profile": "https://Stackoverflow.com/users/9861",
"pm_score": 6,
"selected": true,
"text": "grails war foo.war\n"
},
{
"answer_id": 223603,
"author": "Ken Gentle",
"author_id": 8709,
"author_pr... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
164,643 | <p>In my C# source code I may have declared integers as:</p>
<pre><code>int i = 5;
</code></pre>
<p>or</p>
<pre><code>Int32 i = 5;
</code></pre>
<p>In the currently prevalent 32-bit world they are equivalent. However, as we move into a 64-bit world, am I correct in saying that the following will become the same?</p>
<pre><code>int i = 5;
Int64 i = 5;
</code></pre>
| [
{
"answer_id": 164650,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "int"
},
{
"answer_id": 164692,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https:/... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
164,645 | <p>Is there any way that I can change how a Literal of a code snippet renders when it is used in the code that the snippet generates?</p>
<p>Specifically I'd like to know if I can have a literal called say, $PropertyName$ and then get the snippet engine to render "_$PropertyName$ where the first character is made lowercase.</p>
<p>I can't afford R#. Please help :)</p>
| [
{
"answer_id": 18289183,
"author": "fred",
"author_id": 2692059,
"author_profile": "https://Stackoverflow.com/users/2692059",
"pm_score": 3,
"selected": false,
"text": "string m_$name$;\nstring $name$\n{\n get{return m_$name$;}\n set{m_$name$=value;}\n};\n"
},
{
"answer_id": 4778... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19452/"
] |
164,697 | <p>I am a little confused about null values and variables in .NET. (VB preferred)</p>
<p>Is there any way to check the "nullness" of ANY given variable regardless of whether it was an object or a value type? Or does my null check have to always anticipate whether it's checking a value type (e.g. System.Integer) or an object? </p>
<p>I guess what I'm looking for is a function that checks all possible kind of null-ness. That is, any type of variables that </p>
<p>a) were never assigned a value since declared</p>
<p>b) were assigned a null value from a data object (that came from a database)</p>
<p>c) were set equals to another variable value which was null</p>
<p>d) were set to an ASP.NET session/application variable that was never set or expired.</p>
<p>Is there a general best-practice when it comes to handling null scenarios in .NET?</p>
<p><strong>UPDATE:</strong> When I talk about a value type being "null", what I really mean is a value type that was either never set or was at some point set equal to or cast from a null object. </p>
| [
{
"answer_id": 164706,
"author": "Bob King",
"author_id": 6897,
"author_profile": "https://Stackoverflow.com/users/6897",
"pm_score": 2,
"selected": false,
"text": "Dim i as Nullable(Of Integer) = Nothing '.NET 2.0/3.0'\nDim j as Integer? = Nothing '.NET 3.5'\n"
},
{
"answer_id":... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17235/"
] |
164,714 | <p>I just want to know the best way to emulate a C# style enumeration in Ruby.</p>
| [
{
"answer_id": 164810,
"author": "Ris Adams",
"author_id": 15683,
"author_profile": "https://Stackoverflow.com/users/15683",
"pm_score": 2,
"selected": false,
"text": "class WindowState\n Open = 1\n Closed = 2\n Max = 3\n Min = 4\nend\n"
},
{
"answer_id": 164833,
"author"... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20714/"
] |
164,727 | <p>How do you return values or structures from a Popup window in Powerbuilder 9.0? The CloseWithReturn is only valid for Response windows and thus is not available. When I set a value to the Message.PowerObjectParm, the value becomes null when the Popup window closes. I need to use a Popup window so the user can click back to the caller window and scroll through rows. </p>
<p>Program flow:
1) Window A OpenWithParm
2) Window B is now open
3) User interacts with both windows
3) User closes Window B
4) Window B needs to pass a structure back to window A</p>
| [
{
"answer_id": 165584,
"author": "Doug Porter",
"author_id": 4311,
"author_profile": "https://Stackoverflow.com/users/4311",
"pm_score": 3,
"selected": true,
"text": "w_my_parent_window_name.istr_my_structure = lstr_my_structure\n"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4466/"
] |
164,736 | <p>I am trying to call php-cgi.exe from a .NET program. I use RedirectStandardOutput to get the output back as a stream but the whole thing is very slow.</p>
<p>Do you have any idea on how I can make that faster? Any other technique?</p>
<pre><code> Dim oCGI As ProcessStartInfo = New ProcessStartInfo()
oCGI.WorkingDirectory = "C:\Program Files\Application\php"
oCGI.FileName = "php-cgi.exe"
oCGI.RedirectStandardOutput = True
oCGI.RedirectStandardInput = True
oCGI.UseShellExecute = False
oCGI.CreateNoWindow = True
Dim oProcess As Process = New Process()
oProcess.StartInfo = oCGI
oProcess.Start()
oProcess.StandardOutput.ReadToEnd()
</code></pre>
| [
{
"answer_id": 2268137,
"author": "Jader Dias",
"author_id": 48465,
"author_profile": "https://Stackoverflow.com/users/48465",
"pm_score": 4,
"selected": false,
"text": "private void Redirect(StreamReader input, TextBox output)\n{\n new Thread(a =>\n {\n var buffer = new cha... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508/"
] |
164,751 | <p>I have a dialog that resizes. It also has a custom background which I paint in response to a WM_ERASEBKGND call (currently a simple call to FillSolidRect). </p>
<p>When the dialog is resized, there is tremendous flickering going on. To try and reduce the flickering I enumerate all child windows and add them to the clipping region. That seems to help a little -- now the flickering is mostly evident in all of the child controls as they repaint.</p>
<p>How can I make the dialog flicker-free while resizing? I suspect double-buffering must play a part, but I'm not sure how to do that with a dialog with child controls (without making all child controls owner-draw or something like that).</p>
<p>I should note that I'm using C++ (not .NET), and MFC, although pure Win32-based solutions are welcomed :)</p>
<p>NOTE: One thing I tried but which didn't work (not sure why) was:</p>
<pre><code>CDC memDC;
memDC.CreateCompatibleDC(pDC);
memDC.FillSolidRect(rect, backgroundColor);
pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);
</code></pre>
| [
{
"answer_id": 164766,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "CLIPCHILDREN"
},
{
"answer_id": 164977,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile"... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7442/"
] |
164,767 | <pre><code>$array = explode(".", $row[copy]);
$a = $array.length -1;
</code></pre>
<p>I want to return the last element of this array but all i get from this is -1.</p>
| [
{
"answer_id": 164781,
"author": "benzado",
"author_id": 10947,
"author_profile": "https://Stackoverflow.com/users/10947",
"pm_score": 0,
"selected": false,
"text": "$index = count($array) - 1;\n$a = $array[$index];\n"
},
{
"answer_id": 164785,
"author": "Jonathan Lonowski",
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
164,789 | <p>I am trying to do a Windows Forms application in an MVP style and - not having done much with threading before - am getting all confused.</p>
<p>My UI is a set of very simple forms. Each of the forms implements an interface and contains a reference to a mediator class which lives in the Business Logic Layer and vice versa.
So as simplified diagram looks like this:</p>
<pre><code>CheckInForm : ICheckIn <-------> CheckInMediator : ICheckInMediator
----------------------------------------------------------------------------------------
CheckInForm.Show() <--------
--------> AttemptCheckIn(CheckInInfo)
CheckInForm.DisplayCheckInInfo(DisplayInfo) <--------
--------> CompleteCheckIn(AdditionalCheckInInfo)
PleaseWaitDialog.Show() <--------
PleaseWaitDialog.Close() <--------
CheckInForm.Close() <--------
</code></pre>
<p>As you can see, the mediator classes control the UI, telling it when to display data, start up, close, etc. They even signify when a modal dialog should appear and when it should close (ie the PleaseWaitDialog above) The only thing the UI does is show data on the screen and relay input back to the mediator. </p>
<p>This architecture is nice and decoupled and has been super-easy to test and prototype. Now that I'm putting it all together however I'm starting to run into threading issues. For example, if I want my PleaseWaitDialog to appear as a modal form (using ShowDialog()) over the CheckInForm until a timer controlled by the mediator counts out 5 seconds (remember, this is a simplification) I will get a cross-threading error if I call PleaseWaitDialog.Close() from the timer's callback. In a similar vein, if I have a modal dialog block the user from interacting with the UI I don't want that to block activity in the business layer unless I specify otherwise (such as with a confirmation dialog).</p>
<p>What I think I would like to do is to run the mediators and business logic on the main thread and the UI on a completely separate thread and my first question is does this make sense to do?</p>
<p>My second question is, how do I do something like have a class run in a separate thread? And how do I have the two communicate? I am making my way through the reading on .NET threading but I have a deadline and some examples for how to have a class on the main thread spawn a thread containing the UI and have them objects talk to each other could really help.</p>
| [
{
"answer_id": 166782,
"author": "McKenzieG1",
"author_id": 3776,
"author_profile": "https://Stackoverflow.com/users/3776",
"pm_score": 0,
"selected": false,
"text": "Control.Invoke()"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
164,792 | <p>From the documentation, I would expect adModeShareDenyWrite to be the way, but it's not working right.</p>
<p>I'm using an Access database via ADO. My connection string says Mode=8, which is adModeShareDenyWrite. But when I try to delete a row from a table, I get:</p>
<p>Unspecified error, Description:Could not delete from specified tables., Source:Microsoft JET Database Engine</p>
<p>In other words, the setting is preventing ME from updating the database using my OWN connection.</p>
<p>I found a couple other posts on the web reporting the same thing, the adModeShareDenyWrite setting used with Access not working as documented.</p>
<p>I am looking for a solution that doesn't involve an administrator changing permissions. It needs to be something that my program can control. </p>
<p>My motivation here is to minimize the chances of database corruption. One of the causes of mdb file corruption documented by Microsoft is two apps writing to the same db. So, I want to make sure that only one app can have a write connection to the db. Others can read, but should fail when they try to write. Whoever makes a connection first wins.</p>
| [
{
"answer_id": 164900,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 0,
"selected": false,
"text": "(where you have a user object with a '.role' property, or anything equivalent ...)\nif activeUser.role = \"admin... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] |
164,808 | <p>I've got an issue when accessing a web site, I can access it by using the NetBIOS name, but when accessing with the FQDN i get an error. </p>
<p>Any ideas on how to troubleshoot this?</p>
<p>(There is no DNS configured yet, we have modified the Hosts file to enter the related names and IP.)</p>
| [
{
"answer_id": 164907,
"author": "dragonmantank",
"author_id": 204,
"author_profile": "https://Stackoverflow.com/users/204",
"pm_score": 0,
"selected": false,
"text": "192.168.100.5 othermachine othermachine.mydomain.local\n"
},
{
"answer_id": 1207527,
"author": "Jason Musgro... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19159/"
] |
164,839 | <p>Every time I try to create a new project or solution in visual studio (2005 and 2008), I get an error saying, "Project Creation failed." I even tried running vs in administrative mode, but I still get the same answer. Anyone have any suggestions, in short of uninstalling all of VS and reinstalling it?</p>
| [
{
"answer_id": 164860,
"author": "Forgotten Semicolon",
"author_id": 1960,
"author_profile": "https://Stackoverflow.com/users/1960",
"pm_score": 1,
"selected": false,
"text": "devenv.exe /SafeMode\n"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21745/"
] |
164,847 | <p>Vi and Vim allow for really awesome customization, typically stored inside a <code>.vimrc</code> file. Typical features for a programmer would be syntax highlighting, smart indenting and so on.</p>
<p><strong>What other tricks for productive programming have you got, hidden in your .vimrc?</strong></p>
<p>I am mostly interested in refactorings, auto classes and similar productivity macros, especially for C#.</p>
| [
{
"answer_id": 164866,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 6,
"selected": false,
"text": "]p"
},
{
"answer_id": 164867,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "http... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7028/"
] |
164,855 | <p>I have a an HTML form which contains the YAHOO rich text editor on it.</p>
<p>When I display the form I want the YAHOO editor to have focus so that the cursor is ready to accept input without the user having to click on it or tab into it</p>
| [
{
"answer_id": 174050,
"author": "pmg",
"author_id": 25324,
"author_profile": "https://Stackoverflow.com/users/25324",
"pm_score": 0,
"selected": false,
"text": "window.onload"
},
{
"answer_id": 227958,
"author": "Benry",
"author_id": 28408,
"author_profile": "https:/... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15352/"
] |
164,858 | <p>The following snippet of C# code:</p>
<pre><code> int i = 1;
string result = String.Format("{0},{1},{2}", i++, i++, i++);
Console.WriteLine(result);
</code></pre>
<p>writes out: 1,2,3</p>
<p>Before I tried this in the compiler I was expecting the assignments to take place and then the evaluations, so my expected output was: 1,1,1</p>
<p>So my question is: Does this "pattern" (is it called a pattern?) of assign and then evaluate each parameter have a name?</p>
<p>EDIT: I'm referring to the pattern of evaluating and assigning the parameters to the String.Format() function. Not the incrementing of i.</p>
<p>(I may be incorrectly using the word evaluate in the question above because if the parameter was say (i + j) then we know that it would be evaluated before it was assigned. When using the word evaluate in that context I'm referring to the incrementing of i.)</p>
| [
{
"answer_id": 164908,
"author": "Jacob Krall",
"author_id": 3140,
"author_profile": "https://Stackoverflow.com/users/3140",
"pm_score": 3,
"selected": true,
"text": "i++"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
164,865 | <p>Here at work, we are working on a newsletter system that our clients can use. As an intern one of my jobs is to help with the smaller pieces of the puzzle. In this case what I need to do is scan the logs of the email server for bounced messages and add the emails and the reason the email bounced to a "bad email database".</p>
<p>The bad emails table has two columns: 'email' and 'reason'
I use the following statement to get the information from the logs and send it to the Perl script</p>
<pre><code>grep " 550 " /var/log/exim/main.log | awk '{print $5 "|" $23 " " $24 " " $25 " " $26 " " $27 " " $28 " " $29 " " $30 " " $31 " " $32 " " $33}' | perl /devl/bademails/getbademails.pl
</code></pre>
<p>If you have sugestions on a more efficient awk script, then I would be glad to hear those too but my main focus is the Perl script. The awk pipes "foo@bar.com|reason for bounce" to the Perl script. I want to take in these strings, split them at the | and put the two different parts into their respective columns in the database. Here's what I have:</p>
<pre><code>#!usr/bin/perl
use strict;
use warnings;
use DBI;
my $dbpath = "dbi:mysql:database=system;host=localhost:3306";
my $dbh = DBI->connect($dbpath, "root", "******")
or die "Can't open database: $DBI::errstr";
while(<STDIN>) {
my $line = $_;
my @list = # ? this is where i am confused
for (my($i) = 0; $i < 1; $i++)
{
if (defined($list[$i]))
{
my @val = split('|', $list[$i]);
print "Email: $val[0]\n";
print "Reason: $val[1]";
my $sth = $dbh->prepare(qq{INSERT INTO bademails VALUES('$val[0]', '$val[1]')});
$sth->execute();
$sth->finish();
}
}
}
exit 0;
</code></pre>
| [
{
"answer_id": 164892,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 3,
"selected": false,
"text": "#!/ust/bin/perl -w\nuse strict;\n\nwhile (<>) {\n next unless / 550 /;\n my @tokens = split ' ', $_;\n my $addr = $tokens[... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] |
164,879 | <p>How can I write from Java to the Windows Event Log?</p>
| [
{
"answer_id": 164898,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 6,
"selected": true,
"text": "NTEventLogAppender"
},
{
"answer_id": 2215876,
"author": "Andrew",
"author_id": 242615,
"author_profil... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8934/"
] |
164,896 | <p>In the installation documentation to RoR it mentions that there are many limitations to running Ruby on Rails on Windows, and in some cases, whole libraries do not work.</p>
<p>How bad are these limitations, should I always default to Linux to code / run RoR, and is Iron Ruby expected to fix these limitations or are they core to the OS itself?</p>
<p><strong><em>EDIT</em></strong> Thanks for the answer around installation and running on Linux, but I am really trying to understand the limitations in functionality as referenced in the installation documentation, and non-working libraries - I am trying to find a link to the comment, but it was referenced in an installation read me when I installed the msi package I think</p>
<p><strong><em>EDIT</em></strong>
Thanks for the references to IronRuby lately, it is certainly a project to watch, and as it, obviously, is a .NET language, it will be invaluable if it lives up to the promises. Eventually, however, in my case, I just bit the bullet and installed an Ubuntu server. </p>
<p><bias> I should've done it years ago </bias></p>
| [
{
"answer_id": 166548,
"author": "Charles Roper",
"author_id": 1944,
"author_profile": "https://Stackoverflow.com/users/1944",
"pm_score": 8,
"selected": true,
"text": "gem install rails"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] |
164,901 | <p>Currently I am hosting a Django app I developed myself for my clients, but I am now starting to look at selling it to people for them to host themselves.</p>
<p>My question is this: How can I package up and sell a Django app, while protecting its code from pirating or theft? Distributing a bunch of .py files doesn't sound like a good idea as the people I sell it to too could just make copies of them and pass them on.</p>
<p>I think for the purpose of this problem it would be safe to assume that everyone who buys this would be running the same (LAMP) setup.</p>
| [
{
"answer_id": 164987,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 7,
"selected": true,
"text": "#"
}
] | 2008/10/02 | [
"https://Stackoverflow.com/questions/164901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] |
164,903 | <p>How can I capture enter keypresses anywhere on my form and force it to fire the submit button event?</p>
| [
{
"answer_id": 164917,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 8,
"selected": false,
"text": "Form"
},
{
"answer_id": 16124122,
"author": "sanjeev",
"author_id": 2240266,
"author_profile": "http... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
164,926 | <p>When displaying the value of a decimal currently with <code>.ToString()</code>, it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 decimal places. </p>
<p>Do I use a variation of <code>.ToString()</code> for this?</p>
| [
{
"answer_id": 164932,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 11,
"selected": true,
"text": "decimalVar.ToString(\"#.##\"); // returns \".5\" when decimalVar == 0.5m\n"
},
{
"answer_id": 164934,
"autho... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1692/"
] |
164,927 | <p>What is the best way to find out if a primary key with a certain value already exists in a table?</p>
<p>I can think of:</p>
<pre><code>SELECT key FROM table WHERE key = 'value';
</code></pre>
<p>and count the results, or:</p>
<pre><code>SELECT SQL_CALC_FOUND_ROWS key FROM table WHERE key = 'value' LIMIT 1;
SELECT FOUND_ROWS();
</code></pre>
| [
{
"answer_id": 164950,
"author": "Brian",
"author_id": 700,
"author_profile": "https://Stackoverflow.com/users/700",
"pm_score": 0,
"selected": false,
"text": "Select count(key) into :result from table where key = :theValue\n"
},
{
"answer_id": 164952,
"author": "Brian Matthe... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3740/"
] |
164,931 | <p>I'm looking at introducing multi-lingual support to a mature CGI application written in Perl. I had originally considered rolling my own solution using a Perl hash (stored on disk) for translation files but then I came across a CPAN module which appears to do just what I want (<a href="http://search.cpan.org/~audreyt/i18n-0.10/lib/i18n.pm" rel="noreferrer" title="i18n">i18n</a>). </p>
<p>Does anyone have any experience with internationalization (specifically the i18n CPAN module) in Perl? Is the i18n module the preferred method for multi-lingual support or should I reconsider a custom solution?</p>
<p>Thanks</p>
| [
{
"answer_id": 164970,
"author": "pjf",
"author_id": 19422,
"author_profile": "https://Stackoverflow.com/users/19422",
"pm_score": 5,
"selected": true,
"text": "Locale::Maketext"
},
{
"answer_id": 191130,
"author": "EvdB",
"author_id": 5349,
"author_profile": "https:/... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20790/"
] |
164,964 | <p>I'm trying to determine the asymptotic run-time of one of my algorithms, which uses exponents, but I'm not sure of how exponents are calculated programmatically.</p>
<p>I'm specifically looking for the pow() algorithm used for double-precision, floating point numbers.</p>
| [
{
"answer_id": 164972,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 1,
"selected": false,
"text": "result = 1\nwhile b > 0\n if b is odd\n result *= a\n b -= 1\n b /= 2\n a = a * a\n"
},
{
"answer_id":... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55/"
] |
164,967 | <p>I have an Excel application in which I want to present the user with a list of the Data Source Names (ie: DSN's), whereby s/he can choose what data source to use.</p>
<p>Hopefully once I've got the list, I can easily access the DSN properties to connect to the appropriate database.</p>
<p>Please note, I do <em>not</em> want to use a DSN-less connection.</p>
| [
{
"answer_id": 165044,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 5,
"selected": true,
"text": " Option Explicit\n\n Private Declare Function RegOpenKeyEx Lib \"advapi32.dll\" _\n Alias \"RegOpenKeyExA\" _\n... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1354/"
] |
164,979 | <p>I'm after a regex that will validate a full complex UK postcode only within an input string. All of the uncommon postcode forms must be covered as well as the usual. For instance:</p>
<p><strong>Matches</strong></p>
<ul>
<li>CW3 9SS</li>
<li>SE5 0EG</li>
<li>SE50EG</li>
<li>se5 0eg</li>
<li>WC2H 7LT</li>
</ul>
<p><strong>No Match</strong></p>
<ul>
<li>aWC2H 7LT</li>
<li>WC2H 7LTa</li>
<li>WC2H</li>
</ul>
<p>How do I solve this problem?</p>
| [
{
"answer_id": 164992,
"author": "Dan",
"author_id": 230,
"author_profile": "https://Stackoverflow.com/users/230",
"pm_score": 5,
"selected": false,
"text": "^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$\n"
},
{
"answer_id":... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5777/"
] |
164,981 | <p>I have a PHP script that uses the <code>system()</code> call to execute other (potentially long-running) programs (for interest: NCBI BLAST, phrap, primer3 and other programs for doing DNA sequence analysis and assembly).</p>
<p>I'm running under Windows XP, using the CLI version of PHP from a command prompt, or as a service. (In either case I communicate with it via a queue of tasks in a database table).</p>
<p>Under PHP4: when I hit <kbd>Ctrl</kbd>+<kbd>C</kbd> the script is stopped and any child process running at the time is also stopped.
Under PHP5: when I hit <kbd>Ctrl</kbd>+<kbd>C</kbd> the script stops, but the child is left running.</p>
<p>Similarly, when running the script as a service, stopping the service when running it with PHP4 stops the child, with PHP5 the child continues to run.</p>
<p>I have tried writing a minimal test application, and found the same behaviour. The test PHP script just uses system() to execute a C program (that just sleeps for 30 seconds) and then waits for a key to be pressed.</p>
<p>I had a look at the source for PHP 4.4.9 and 5.2.6 but could see no differences in the system() code that looked like they would cause this. I also had a quick look at the startup code for the CLI application and didn't see any differences in signal handling.</p>
<p>Any hints on what might have caused this, or a workaround, would be appreciated.</p>
<p>Thanks.</p>
| [
{
"answer_id": 164992,
"author": "Dan",
"author_id": 230,
"author_profile": "https://Stackoverflow.com/users/230",
"pm_score": 5,
"selected": false,
"text": "^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$\n"
},
{
"answer_id":... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
164,990 | <p>This is a continuation question from a previous question <a href="https://stackoverflow.com/questions/142237/integrating-external-sources-in-a-build.">I have asked</a></p>
<p>I now have a /externals directory in the root of my project tree. Inside this I have a reference to another project. I'm able to script the build of all my externals in the main project NAnt script. The result of these builds are as follows:</p>
<p>/externals/external-project1/build/buildartifacts/{dlls|html|js}</p>
<p>/externals/external-project2/build/buildartifacts/{dlls|html|js}</p>
<p>This is all well and good, but now I'm curious as to how my main project should reference these build artifacts. For example, let's say that external project builds a DLL that some of my codebase depends on. Should I simply reference the DLL in the build artifacts directory or should I implement another NAnt task that copies these to a /thirdparty/libs/ folder?</p>
<p>This means that my build is now dependent on the ability to build this external project (which could either be internal, or thirdparty). Is it a good idea to check in the latest set of build artifacts to ensure that the main build won't break because of dependent builds breaking?</p>
<p>Hope that's clear enough. Just writing this down has a least clarified the problem for me :-).</p>
<p>--Edit--</p>
<p>Thanks guys. I think I'm going to implement the "checkout a revision", but since the builds are so quick I'm not going to check in any build artifiacts. Also going to have to figure out how to deal with the dependencies of the external project (eg: prototype, swfobject, etc).</p>
| [
{
"answer_id": 164992,
"author": "Dan",
"author_id": 230,
"author_profile": "https://Stackoverflow.com/users/230",
"pm_score": 5,
"selected": false,
"text": "^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$\n"
},
{
"answer_id":... | 2008/10/02 | [
"https://Stackoverflow.com/questions/164990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1894/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.