qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
523,181
<p>Any ideas how to echo or type the last 10 lines of a txt file?</p> <p>I'm running a server change log script to prompt admins to state what they're doing, so we can track changes. I'm trying to get the script to show the last 10 entries or so to give an idea of what's been happening recently. I've found a script th...
[ { "answer_id": 523186, "author": "Phil", "author_id": 62789, "author_profile": "https://Stackoverflow.com/users/62789", "pm_score": 2, "selected": false, "text": "<p>There are several windows implementations of the tail command. It should be exactly what you want.</p>\n\n<p>This one soun...
2009/02/07
[ "https://Stackoverflow.com/questions/523181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Any ideas how to echo or type the last 10 lines of a txt file? I'm running a server change log script to prompt admins to state what they're doing, so we can track changes. I'm trying to get the script to show the last 10 entries or so to give an idea of what's been happening recently. I've found a script that deals w...
Hopefully this will save Joel's eyes :) ``` @echo OFF :: Get the number of lines in the file set LINES=0 for /f "delims==" %%I in (data.txt) do ( set /a LINES=LINES+1 ) :: Print the last 10 lines (suggestion to use more courtsey of dmityugov) set /a LINES=LINES-10 more +%LINES% < data.txt ```
523,185
<p>The program needs to take in a simple string from the user and display it back. I have gotten the program to take input from the user but I can't seem to store it. Here is what I have so far:</p> <pre><code>BITS 32 global _main section .data prompt db "Enter a string: ", 13, 10, '$' input resd 1 ; something I can ...
[ { "answer_id": 523186, "author": "Phil", "author_id": 62789, "author_profile": "https://Stackoverflow.com/users/62789", "pm_score": 2, "selected": false, "text": "<p>There are several windows implementations of the tail command. It should be exactly what you want.</p>\n\n<p>This one soun...
2009/02/07
[ "https://Stackoverflow.com/questions/523185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63585/" ]
The program needs to take in a simple string from the user and display it back. I have gotten the program to take input from the user but I can't seem to store it. Here is what I have so far: ``` BITS 32 global _main section .data prompt db "Enter a string: ", 13, 10, '$' input resd 1 ; something I can using to store...
Hopefully this will save Joel's eyes :) ``` @echo OFF :: Get the number of lines in the file set LINES=0 for /f "delims==" %%I in (data.txt) do ( set /a LINES=LINES+1 ) :: Print the last 10 lines (suggestion to use more courtsey of dmityugov) set /a LINES=LINES-10 more +%LINES% < data.txt ```
523,194
<p>Is there a way to do <code>foreach</code> style iteration over parallel enumerables in C#? For subscriptable lists, I know one could use a regular <code>for</code> loop iterating an int over the index range, but I really prefer <code>foreach</code> to <code>for</code> for a number of reasons.</p> <p>Bonus points i...
[ { "answer_id": 523236, "author": "Zooba", "author_id": 891, "author_profile": "https://Stackoverflow.com/users/891", "pm_score": 4, "selected": true, "text": "<p>Short answer, no. <code>foreach</code> works on only one enumerable at a time.</p>\n\n<p>However, if you combine your parallel...
2009/02/07
[ "https://Stackoverflow.com/questions/523194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44743/" ]
Is there a way to do `foreach` style iteration over parallel enumerables in C#? For subscriptable lists, I know one could use a regular `for` loop iterating an int over the index range, but I really prefer `foreach` to `for` for a number of reasons. Bonus points if it works in C# 2.0
Short answer, no. `foreach` works on only one enumerable at a time. However, if you combine your parallel enumerables into a single one, you can `foreach` over the combined. I am not aware of any easy, built in method of doing this, but the following should work (though I have not tested it): ``` public IEnumerable<T...
523,195
<p>I have a strange encoding situation, whereby the html page itself displays as it should (with all the accénted chäracters properly displayed), but all the popup dojo dialogs fail to use the correct encoding.</p> <p>Here is the setup:</p> <ul> <li>Java web project with Hibernate/Spring/Struts2 running on Tomcat6.0....
[ { "answer_id": 523236, "author": "Zooba", "author_id": 891, "author_profile": "https://Stackoverflow.com/users/891", "pm_score": 4, "selected": true, "text": "<p>Short answer, no. <code>foreach</code> works on only one enumerable at a time.</p>\n\n<p>However, if you combine your parallel...
2009/02/07
[ "https://Stackoverflow.com/questions/523195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53747/" ]
I have a strange encoding situation, whereby the html page itself displays as it should (with all the accénted chäracters properly displayed), but all the popup dojo dialogs fail to use the correct encoding. Here is the setup: * Java web project with Hibernate/Spring/Struts2 running on Tomcat6.0.18; the pages are gen...
Short answer, no. `foreach` works on only one enumerable at a time. However, if you combine your parallel enumerables into a single one, you can `foreach` over the combined. I am not aware of any easy, built in method of doing this, but the following should work (though I have not tested it): ``` public IEnumerable<T...
523,221
<p>i have a large list of static data from a server that i load on startup. I load this into a hashtable of foo objects. the user has a dropdown where they can choose one of these object. by default there are 50,000 objects which take up a lot of memory. i am trying to reduce memory</p> <p>after monitoring usage, it...
[ { "answer_id": 523228, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 1, "selected": false, "text": "<p>You have a dropdown with 50000 items in it? That seems a trifle excessive. Perhaps a list view control? Also you...
2009/02/07
[ "https://Stackoverflow.com/questions/523221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
i have a large list of static data from a server that i load on startup. I load this into a hashtable of foo objects. the user has a dropdown where they can choose one of these object. by default there are 50,000 objects which take up a lot of memory. i am trying to reduce memory after monitoring usage, it turns out t...
I'm assuming you're filtering this list elsewhere...otherwise that's quite a list. The easiest way to hit your new, leaner static cache before hitting the DB will be to pass all requests through a single method: ``` public yourClass GetDesiredObject(string lkupValue) { if (yourCachedHashtable.ContainsKey(lkupValue))...
523,243
<p>You will notice the :hover CSS for the links in the main nav area (grey bar under logo) for the site testing.ksischool.com works fine in Firefox, but IE7 chops off the bottom few padding pixels. Why?</p>
[ { "answer_id": 523288, "author": "Samantha Branham", "author_id": 62590, "author_profile": "https://Stackoverflow.com/users/62590", "pm_score": 0, "selected": false, "text": "<p>Try adding display: inline-block to the a element. I'm not sure how compatible that is, but it works in IE7 a...
2009/02/07
[ "https://Stackoverflow.com/questions/523243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56145/" ]
You will notice the :hover CSS for the links in the main nav area (grey bar under logo) for the site testing.ksischool.com works fine in Firefox, but IE7 chops off the bottom few padding pixels. Why?
I assume you're talking about the top navigation; you're padding an inline element (the `<a>` tag). When placing padding on an inline element, horizontal padding will push against other elements, but vertical padding will just increase the size of the element without affecting the layout around it. Likely Firefox is re...
523,245
<p>This is my first time using XML Serialization and this is driving me absolutely <strong>nuts</strong> after 2 days of trying to troubleshoot this.</p> <p>I get this error when the deserialization kicks in:</p> <pre><code>The XML element 'name' from namespace '' is already present in the current scope. Use XML attr...
[ { "answer_id": 519130, "author": "Dimi Takis", "author_id": 52039, "author_profile": "https://Stackoverflow.com/users/52039", "pm_score": 1, "selected": false, "text": "<p>Well,</p>\n\n<p>there is a <a href=\"http://msdn.microsoft.com/en-us/library/ms946381.aspx\" rel=\"nofollow noreferr...
2009/02/07
[ "https://Stackoverflow.com/questions/523245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/93468/" ]
This is my first time using XML Serialization and this is driving me absolutely **nuts** after 2 days of trying to troubleshoot this. I get this error when the deserialization kicks in: ``` The XML element 'name' from namespace '' is already present in the current scope. Use XML attributes to specify another XML name...
Personally, I wouldn't use constants here - they make it hard to spot errors (and since you probably aren't re-using them, don't add much). For example: ``` [XmlElement (ElementName = ElementConstants.AlbumName, DataType = "string")] public string AlbumID { get; set; } ... [XmlElement(ElementName = Element...
523,246
<p>I am using GDI+ on the server-side to create an image which is streamed to the user's browser. None of the standard fonts fit my requirements and so I want to load a TrueType font and use this font for drawing my strings to the graphics object:</p> <pre><code>using (var backgroundImage = new Bitmap(backgroundPath))...
[ { "answer_id": 523388, "author": "Llyle", "author_id": 27765, "author_profile": "https://Stackoverflow.com/users/27765", "pm_score": 6, "selected": true, "text": "<p>I've found a solution to using custom fonts.</p>\n\n<pre><code>// 'PrivateFontCollection' is in the 'System.Drawing.Text' ...
2009/02/07
[ "https://Stackoverflow.com/questions/523246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27765/" ]
I am using GDI+ on the server-side to create an image which is streamed to the user's browser. None of the standard fonts fit my requirements and so I want to load a TrueType font and use this font for drawing my strings to the graphics object: ``` using (var backgroundImage = new Bitmap(backgroundPath)) using (var av...
I've found a solution to using custom fonts. ``` // 'PrivateFontCollection' is in the 'System.Drawing.Text' namespace var foo = new PrivateFontCollection(); // Provide the path to the font on the filesystem foo.AddFontFile("..."); var myCustomFont = new Font((FontFamily)foo.Families[0], 36f); ``` Now `myCustomFont`...
523,247
<p>Well I am using the following code to redirect users who don't have my IP to a coming soon page:</p> <pre><code>rewritebase / rewritecond %{REMOTE_HOST} !(^1\.2\.3\.4) rewritecond %{REQUEST_URI} !/comingsoon\.html$ rewriterule .* http://www.andrew-g-johnson.com/comingsoon.html [R=302,L] </code></pre> <p>I want to...
[ { "answer_id": 523270, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 1, "selected": false, "text": "<p>You could specify a regular expression like:</p>\n\n<pre><code>(1\\.2\\.3\\.4|5\\.6\\.7\\.8)\n</code></pre>\n\n<p>but th...
2009/02/07
[ "https://Stackoverflow.com/questions/523247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428190/" ]
Well I am using the following code to redirect users who don't have my IP to a coming soon page: ``` rewritebase / rewritecond %{REMOTE_HOST} !(^1\.2\.3\.4) rewritecond %{REQUEST_URI} !/comingsoon\.html$ rewriterule .* http://www.andrew-g-johnson.com/comingsoon.html [R=302,L] ``` I want to make it so that I have tw...
I'd actually recommend Cletus' suggestion, but an alternative if you wanted to stick with .htaccess would also be to just add on more lines of conditions (benefit is it's more legible than concatenating them all into one long regex): ``` rewritebase / rewritecond %{REMOTE_HOST} !(^1\.2\.3\.4) rewritecond %{REMOTE_HOST...
523,266
<p>If I had a URL such as</p> <pre><code>http://localhost/search.php?year=2008 </code></pre> <p>How would I write a JavaScript function to grab the variable <em>year</em> and see if it contains anything?</p> <p>I know it can be done with <code>location.search</code> but I can’t figure out how it grabs parameters.</p...
[ { "answer_id": 523287, "author": "Luca Matteis", "author_id": 50394, "author_profile": "https://Stackoverflow.com/users/50394", "pm_score": 3, "selected": false, "text": "<pre><code>function gup( name ) {\n name = name.replace(/[\\[]/,\"\\\\\\[\").replace(/[\\]]/,\"\\\\\\]\");\n va...
2009/02/07
[ "https://Stackoverflow.com/questions/523266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If I had a URL such as ``` http://localhost/search.php?year=2008 ``` How would I write a JavaScript function to grab the variable *year* and see if it contains anything? I know it can be done with `location.search` but I can’t figure out how it grabs parameters.
A non-regex approach, you can simply split by the character '&' and iterate through the key/value pair: ``` function getParameter(paramName) { var searchString = window.location.search.substring(1), i, val, params = searchString.split("&"); for (i=0;i<params.length;i++) { val = params[i].split("="); ...
523,292
<p>What is the best way to make things center properly? Once I start messing around with tables, things either start shifting left or right, destroying the balance. How can make it so everything is always centered?</p> <p>Right now this will lead to the table being messed up, and have the right edge go off the screen...
[ { "answer_id": 775032, "author": "juckobee", "author_id": 87994, "author_profile": "https://Stackoverflow.com/users/87994", "pm_score": 2, "selected": false, "text": "<p>You haven't provided more information about features you expect from such a VPL environment, but I think that \"Tersus...
2009/02/07
[ "https://Stackoverflow.com/questions/523292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34395/" ]
What is the best way to make things center properly? Once I start messing around with tables, things either start shifting left or right, destroying the balance. How can make it so everything is always centered? Right now this will lead to the table being messed up, and have the right edge go off the screen. What can ...
I am sure you are aware of [VPL On Wikipedia](http://en.wikipedia.org/wiki/Visual_programming_language) that lists many different VPL languages. You have not supplied information on what you are trying to achieve but another site is [Synopsis](http://www.codemorphis.com/). This is a commercial product. From their webs...
523,310
<p>I know at first glance (due to the title) this looks like one of the "Did you try searching Google before posting?" questions, but I can't seem to find an answer for the specific issue I'm experiencing. Sorry if I'm a noob.... still learning :)</p> <p>I need to simulate a pause in javascript, but the setTimeout(f...
[ { "answer_id": 523319, "author": "Samantha Branham", "author_id": 62590, "author_profile": "https://Stackoverflow.com/users/62590", "pm_score": 3, "selected": true, "text": "<p>Have you tried cumulatively setting the timeout? Stick a variable outside of your loop and initialize it to 0....
2009/02/07
[ "https://Stackoverflow.com/questions/523310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23869/" ]
I know at first glance (due to the title) this looks like one of the "Did you try searching Google before posting?" questions, but I can't seem to find an answer for the specific issue I'm experiencing. Sorry if I'm a noob.... still learning :) I need to simulate a pause in javascript, but the setTimeout(function\_cal...
Have you tried cumulatively setting the timeout? Stick a variable outside of your loop and initialize it to 0. Let's call it timeout for now. Add a random amount of time to this variable at the beginning of each iteration of your loop, and make the timeout work off of that. This way, you are ensured that functions are ...
523,312
<p>I'm trying to send data from a form to an external script prior to submitting the form, yet I cannot seem to get the data to reach the external script unless I <code>return false;</code> on the form itself.</p> <pre class="lang-js prettyprint-override"><code>$(document).ready(function () { // Handle Form-Submiss...
[ { "answer_id": 523330, "author": "Peter J", "author_id": 56018, "author_profile": "https://Stackoverflow.com/users/56018", "pm_score": 4, "selected": true, "text": "<p>I ran into the exact same problem today. Like Marc says, it's because the ajax call is asynchronous. The simplest fix ...
2009/02/07
[ "https://Stackoverflow.com/questions/523312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54680/" ]
I'm trying to send data from a form to an external script prior to submitting the form, yet I cannot seem to get the data to reach the external script unless I `return false;` on the form itself. ```js $(document).ready(function () { // Handle Form-Submission $("#mainForm").submit(function () { // Reset Erro...
I ran into the exact same problem today. Like Marc says, it's because the ajax call is asynchronous. The simplest fix is to make it synchronous. Use .ajaxSetup() before any ajax calls like such: ``` $.ajaxSetup({async: false}); ```
523,331
<p>I'm trying to learn LaTeX, currently because otherwise, my professors will be nearly unable to read my homework assignments. I've come across something I want to do, but don't seem to be able to, ie. I have searched google (possibly with a poor keyword set) and not found a solution. </p> <p>The specific case is a...
[ { "answer_id": 523421, "author": "Will Robertson", "author_id": 4161, "author_profile": "https://Stackoverflow.com/users/4161", "pm_score": 0, "selected": false, "text": "<p>You might find something to help you in the empheq and mathtools packages. empheq allows you to box equations and ...
2009/02/07
[ "https://Stackoverflow.com/questions/523331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52310/" ]
I'm trying to learn LaTeX, currently because otherwise, my professors will be nearly unable to read my homework assignments. I've come across something I want to do, but don't seem to be able to, ie. I have searched google (possibly with a poor keyword set) and not found a solution. The specific case is as follows: I...
I'm not sure exactly what you're trying to achieve, but amsmath's align\* environment might do what you want (without resorting to minipages): ``` \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x&=y & X&=Y & a&=b+c & mn&=ab\\ x’&=y’ & X’&=Y’ & a’&=b & m'n'&=a'b...
523,345
<p>I have a sql table which have the following data,</p> <pre><code>Id City Country --- ------ ------------ 1 Delhi India 2 New York United States 3 Karachi Pakistan 4 Mumbai India 5 Lahore Pakistan 6 Kanpur India 7 Delhi India 8 Mumbai India </code></pre> <p...
[ { "answer_id": 523364, "author": "Saif Khan", "author_id": 23667, "author_profile": "https://Stackoverflow.com/users/23667", "pm_score": 3, "selected": true, "text": "<p>Your SQL should be </p>\n\n<pre>\n\nselect country,city,count(city)\nfrom dbo.location \ngroup by country,city order b...
2009/02/07
[ "https://Stackoverflow.com/questions/523345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45261/" ]
I have a sql table which have the following data, ``` Id City Country --- ------ ------------ 1 Delhi India 2 New York United States 3 Karachi Pakistan 4 Mumbai India 5 Lahore Pakistan 6 Kanpur India 7 Delhi India 8 Mumbai India ``` Now, I want to display th...
Your SQL should be ``` select country,city,count(city) from dbo.location group by country,city order by country ``` Then use datarepeter to display your data. Follow this [link](http://www.eggheadcafe.com/tutorials/aspnet/d89d1d96-03f1-4784-bbb2-a3db1af393f5/aspnet-datalist-and-data.aspx)
523,349
<p>When I run the following jQuery animation sequence:</p> <pre><code>$('#task').animate({ backgroundColor: fadeColor }, 50) .animate({ opacity: 1.0 }, 1000) .animate({ backgroundColor: originalBG }, 1000); </code></pre> <p>It leaves unneeded styles on my table row when complete (below)</p> <pre>...
[ { "answer_id": 523362, "author": "Samantha Branham", "author_id": 62590, "author_profile": "https://Stackoverflow.com/users/62590", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://docs.jquery.com/UI/Effects/addClass\" rel=\"nofollow noreferrer\">http://docs.jquery.com/UI/E...
2009/02/07
[ "https://Stackoverflow.com/questions/523349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51247/" ]
When I run the following jQuery animation sequence: ``` $('#task').animate({ backgroundColor: fadeColor }, 50) .animate({ opacity: 1.0 }, 1000) .animate({ backgroundColor: originalBG }, 1000); ``` It leaves unneeded styles on my table row when complete (below) ``` <tr id="task29" onclick="TaskEd...
For what you want to do i think is more appropriate to use jquery UI and pulsate/highlight effect :)
523,356
<p>How do I accomplish a simple redirect (e.g. <code>cflocation</code> in ColdFusion, or <code>header(location:http://)</code> for PHP) in Django?</p>
[ { "answer_id": 523366, "author": "Baishampayan Ghose", "author_id": 8024, "author_profile": "https://Stackoverflow.com/users/8024", "pm_score": 9, "selected": true, "text": "<p>It's simple:</p>\n\n<pre><code>from django.http import HttpResponseRedirect\n\ndef myview(request):\n ...\n ...
2009/02/07
[ "https://Stackoverflow.com/questions/523356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58843/" ]
How do I accomplish a simple redirect (e.g. `cflocation` in ColdFusion, or `header(location:http://)` for PHP) in Django?
It's simple: ``` from django.http import HttpResponseRedirect def myview(request): ... return HttpResponseRedirect("/path/") ``` More info in the [official Django docs](https://docs.djangoproject.com/en/1.4/ref/request-response/#django.http.HttpResponseRedirect) **Update: Django 1.0** There is apparently ...
523,360
<p>I need to crawl a web board, which uses ajax for dynamic update/hide/show of comments without reloading the corresponding post. I am blocked by this comment area.</p> <p>In Ajax.request, url is specified with a path without host name like this :</p> <pre><code>new Ajax(**'/bbs/comment_db/load.php'**, { update ...
[ { "answer_id": 523418, "author": "Pete Jordan", "author_id": 22959, "author_profile": "https://Stackoverflow.com/users/22959", "pm_score": 0, "selected": false, "text": "<pre><code>method:'post'\n</code></pre>\n\n<p>might well be your problem: the host serving the request likely rejects...
2009/02/07
[ "https://Stackoverflow.com/questions/523360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to crawl a web board, which uses ajax for dynamic update/hide/show of comments without reloading the corresponding post. I am blocked by this comment area. In Ajax.request, url is specified with a path without host name like this : ``` new Ajax(**'/bbs/comment_db/load.php'**, { update : $('comment_re...
Cross site XMLHttpRequest are forbidden by most browsers. If you want to crawl different sites, you will need to do it in a server side script.
523,363
<p>I am trying to find a simple way to layout a 3 pane window using wxPython.</p> <p>I want to have a tree list in the left pane, then have a right pane that is split into two - with an edit component in the top part and a grid component in the bottom part.</p> <p>Something along the lines of:</p> <pre> ------------...
[ { "answer_id": 523377, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 2, "selected": false, "text": "<p>You should use wxSplitter, <a href=\"http://wiki.wxpython.org/ProportionalSplitterWindow\" rel=\"nofollow noreferre...
2009/02/07
[ "https://Stackoverflow.com/questions/523363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2661/" ]
I am trying to find a simple way to layout a 3 pane window using wxPython. I want to have a tree list in the left pane, then have a right pane that is split into two - with an edit component in the top part and a grid component in the bottom part. Something along the lines of: ``` ----------------------------------...
First of all download [wxGlade](http://wxglade.sourceforge.net/) a gui builder for wxPython (alternative [XRCed](http://xrced.sourceforge.net/), i prefere wxGlade). Then you have to decide if you want to use a [GridSizer](http://www.wxpython.org/docs/api/wx.GridSizer-class.html) or a [Splitter](http://www.wxpython.org...
523,385
<p>I have a program that I would like to run on just one CPU so it doesn't take up too much system resources. The problem is, it makes a call into an external DLL that automatically uses all available CPU cores. I do not have the source code to the external DLL. How can I limit the DLL to only using one CPU?</p> <p>ED...
[ { "answer_id": 523391, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 3, "selected": false, "text": "<p>You could set the CPU affinity of your program. Try the <a href=\"http://msdn.microsoft.com/en-us/library/ms686223(V...
2009/02/07
[ "https://Stackoverflow.com/questions/523385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18476/" ]
I have a program that I would like to run on just one CPU so it doesn't take up too much system resources. The problem is, it makes a call into an external DLL that automatically uses all available CPU cores. I do not have the source code to the external DLL. How can I limit the DLL to only using one CPU? EDIT: Thanks...
Setting processor affinity is the wrong approach. Let the OS handle scheduling. If the machine is sitting idle, you want to use as much processor as you can. Otherwise you're doing less work for no reason. If the machine is busy, then you want to make use of "free" cycles and not adversely affect other processes. Win...
523,403
<p>I really like being able to use =~ and !~ in Perl to evaluate a string against a regular expression. I'd like to port this functionality over to C#, but it appears that, while you can overload operators, you can't create new ones.</p> <p>I'm considering extending the string type to provide a Match() method that wil...
[ { "answer_id": 523407, "author": "Brian Rasmussen", "author_id": 38206, "author_profile": "https://Stackoverflow.com/users/38206", "pm_score": 0, "selected": false, "text": "<p>In my experience .NET supports the same features as Perl regular expressions, but the syntax is much more verbo...
2009/02/07
[ "https://Stackoverflow.com/questions/523403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63623/" ]
I really like being able to use =~ and !~ in Perl to evaluate a string against a regular expression. I'd like to port this functionality over to C#, but it appears that, while you can overload operators, you can't create new ones. I'm considering extending the string type to provide a Match() method that will allow me...
Try creating an extension method to the string class that acts a "shortcut" to Regex.Match. Something like this: ``` public static class RegexExtensions { public static bool Match(this string text, Regex re) { return Regex.Match(text, re); } } ```
523,405
<p>I'm trying to use SendMessage to Notepad, so that I can insert written text without making Notepad the active window.</p> <p>I have done something like this in the past using <code>SendText</code>, but that required giving Notepad focus.</p> <p>Now, first I'm retrieving the Windows handle:</p> <pre><code>Process[...
[ { "answer_id": 523438, "author": "Stefan", "author_id": 48003, "author_profile": "https://Stackoverflow.com/users/48003", "pm_score": 3, "selected": false, "text": "<p>You first have to find the child window where the text is entered. You can do this by finding the child window with the ...
2009/02/07
[ "https://Stackoverflow.com/questions/523405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63229/" ]
I'm trying to use SendMessage to Notepad, so that I can insert written text without making Notepad the active window. I have done something like this in the past using `SendText`, but that required giving Notepad focus. Now, first I'm retrieving the Windows handle: ``` Process[] processes = Process.GetProcessesByNam...
``` [DllImport("user32.dll", EntryPoint = "FindWindowEx")] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam); privat...
523,409
<p>Example Interface:</p> <pre><code>public Interface IEntity Property ID() as Integer end Interface </code></pre> <p>I want all my EF objects to implement this interface on there Primary Keys.</p> <p>Is this possible?</p>
[ { "answer_id": 525530, "author": "Frans Bouma", "author_id": 44991, "author_profile": "https://Stackoverflow.com/users/44991", "pm_score": 0, "selected": false, "text": "<p>The classes are partial, so it should be very easy to do. </p>\n" }, { "answer_id": 526090, "author": "...
2009/02/07
[ "https://Stackoverflow.com/questions/523409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59452/" ]
Example Interface: ``` public Interface IEntity Property ID() as Integer end Interface ``` I want all my EF objects to implement this interface on there Primary Keys. Is this possible?
This seems very easy to do in CSharp but in VB you have to specifically declare which Properties/Functions/Subs are Implementing the Interface: ``` public Property Id() as Integer Implements IEntity.Id ``` Unfortunately I had to Rip out the designer file and modify the generated properties. I ended up getting rid of...
523,413
<p><strong>Pointless Dribble</strong><hr /> </p> <p>Okay This is another weird one from me, i want to thank <a href="https://stackoverflow.com/users/36175/ois">OIS</a> for helping me out on my last question... which deals with this same kind of funky array manipulation... i studied that code in depth and i feel it has...
[ { "answer_id": 523445, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": true, "text": "<p>I think this should work... I wasn't able to test on your example array but it seems to work on a smaller array I made.<...
2009/02/07
[ "https://Stackoverflow.com/questions/523413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45592/" ]
**Pointless Dribble** --- Okay This is another weird one from me, i want to thank [OIS](https://stackoverflow.com/users/36175/ois) for helping me out on my last question... which deals with this same kind of funky array manipulation... i studied that code in depth and i feel it has helped me become better with recurs...
I think this should work... I wasn't able to test on your example array but it seems to work on a smaller array I made. **Edit:** Changed the function now that you've removed the 'depth' keys from your example array. Now it finds the depth on its own. I've also added my test code and output: ``` <?php function array...
523,415
<p>I have a jQuery function that I'm having a minor problem with:</p> <pre><code>$(function() { $("a.CompletedCheckBox").click(function() { if($(this).hasClass("CheckedCompletedCheckBox")) { $(this).removeClass("CheckedCompletedCheckBox"); } else { $(this).addClass("CheckedCompletedCheckBox"); ...
[ { "answer_id": 523422, "author": "youdontmeanmuch", "author_id": 45592, "author_profile": "https://Stackoverflow.com/users/45592", "pm_score": 0, "selected": false, "text": "<p>Is this the exact code that your executing? So the a.CompletedCheckBox will also have a class of CheckedComplet...
2009/02/07
[ "https://Stackoverflow.com/questions/523415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21461/" ]
I have a jQuery function that I'm having a minor problem with: ``` $(function() { $("a.CompletedCheckBox").click(function() { if($(this).hasClass("CheckedCompletedCheckBox")) { $(this).removeClass("CheckedCompletedCheckBox"); } else { $(this).addClass("CheckedCompletedCheckBox"); } $.ge...
IE is likely caching the result of the $.get() request. Try adding a timestamp to the URL of the get request, as such: ``` var myDate = new Date(); var timestamp = myDate.getTime(); $.get("/Tasks/Complete/" + this.id + '?t=' + timestamp); ```
523,425
<p>Okay here's the program I have typed up(stdio.h is included also):</p> <pre><code>/* function main begins program execution */ int main (int argc, char *argv[]) { int x; /*first number input*/ int y; /*second number input*/ int sum; /* variable in which sum will be stored */ int product; /* variable...
[ { "answer_id": 523429, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 1, "selected": false, "text": "<p><code>argv[2]</code> gives you a <code>char *</code>. You need conversion to an <code>int</code>:</p>\n\n<pre><code>...
2009/02/07
[ "https://Stackoverflow.com/questions/523425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/74994/" ]
Okay here's the program I have typed up(stdio.h is included also): ``` /* function main begins program execution */ int main (int argc, char *argv[]) { int x; /*first number input*/ int y; /*second number input*/ int sum; /* variable in which sum will be stored */ int product; /* variable in which prod...
The compiler error was due to you assigning text to a number. You actually need to call a function to convert between the 2 atoi. The most important runtime error is the seg fault, this is caused by using the wrong indexes into the array, c has 0 based arrays so the first element is 0, this means the 2 arguments you w...
523,430
<p>How do I retrieve a multi-column PK in MySQL?</p> <p>For example I have my primary key setup as PRIMARY KEY (<code>donor_id</code>,<code>country_id</code>)</p> <p>Now if I want to get the primary key value without concatenating those 2 fields in a select query, how do I do that? I want to use this in a view (o...
[ { "answer_id": 523439, "author": "kquinn", "author_id": 54486, "author_profile": "https://Stackoverflow.com/users/54486", "pm_score": 3, "selected": true, "text": "<p>It's not clear what you mean by \"without concatenating\". A simple</p>\n\n<pre><code>SELECT donor_id, country_id FROM ta...
2009/02/07
[ "https://Stackoverflow.com/questions/523430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63625/" ]
How do I retrieve a multi-column PK in MySQL? For example I have my primary key setup as PRIMARY KEY (`donor_id`,`country_id`) Now if I want to get the primary key value without concatenating those 2 fields in a select query, how do I do that? I want to use this in a view (or better yet, directly in phpmaker).
It's not clear what you mean by "without concatenating". A simple ``` SELECT donor_id, country_id FROM table WHERE ...; ``` will retrieve the records; you don't need to apply a `CONCATENATE()` function or anything like that. This is the Right Way to select two records from a table; the fact that they both happen to ...
523,507
<p>Say I have 2 tables, A and B, each A entity can possibly have multiple B entities, in one case if I want to get all B's of some certain A's, I might do it with a simple left join </p> <pre><code>select A.id aid,B.id bid from A left join B on B.aid = A.id where A.id = 1 </code></pre> <p>and it will return a result ...
[ { "answer_id": 523521, "author": "benlumley", "author_id": 39161, "author_profile": "https://Stackoverflow.com/users/39161", "pm_score": 3, "selected": true, "text": "<p>What DBMS are you using? </p>\n\n<p>I can't speak for others, but in MySQL, starting from 4.1, you can use GROUP_CONCA...
2009/02/07
[ "https://Stackoverflow.com/questions/523507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58743/" ]
Say I have 2 tables, A and B, each A entity can possibly have multiple B entities, in one case if I want to get all B's of some certain A's, I might do it with a simple left join ``` select A.id aid,B.id bid from A left join B on B.aid = A.id where A.id = 1 ``` and it will return a result set like ``` aid bid 1...
What DBMS are you using? I can't speak for others, but in MySQL, starting from 4.1, you can use GROUP\_CONCAT <http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat> EG: ``` select A.id aid, GROUP_CONCAT(DISTINCT B.id) bid from A left join B on B.aid = A.id where A.id = 1 GROUP BY a...
523,510
<p>I'm looking for something like the individual parts of the date picker dialog. A view that allows you to input integers (and only integers) that you can limit (between 1 and 10 for example), where you can use the keyboard or the arrows in the view itself. Does it exists?</p> <p>It is for a dialog. A ready-made dial...
[ { "answer_id": 524191, "author": "Will", "author_id": 53498, "author_profile": "https://Stackoverflow.com/users/53498", "pm_score": 6, "selected": true, "text": "<p>The <strong><code>NumberPicker</code></strong> widget is probably what you want. Unfortunately it's located in <code>com.a...
2009/02/07
[ "https://Stackoverflow.com/questions/523510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6068/" ]
I'm looking for something like the individual parts of the date picker dialog. A view that allows you to input integers (and only integers) that you can limit (between 1 and 10 for example), where you can use the keyboard or the arrows in the view itself. Does it exists? It is for a dialog. A ready-made dialog to requ...
The **`NumberPicker`** widget is probably what you want. Unfortunately it's located in `com.android.internal.Widget.NumberPicker` which we cannot get to through normal means. There are two ways to use it: 1. Copy the code from android source 2. Use reflection to access the widget Here's the xml for using it in a lay...
523,531
<p>Since the trigonometric functions in java.lang.Math are quite slow: is there a library that does a quick and good approximation? It seems possible to do a calculation several times faster without losing much precision. (On my machine a multiplication takes 1.5ns, and java.lang.Math.sin 46ns to 116ns). Unfortunately ...
[ { "answer_id": 523542, "author": "Peter Lawrey", "author_id": 57695, "author_profile": "https://Stackoverflow.com/users/57695", "pm_score": 0, "selected": false, "text": "<p>The java.lang.Math functions call the hardware functions. There should be simple appromiations you can make but t...
2009/02/07
[ "https://Stackoverflow.com/questions/523531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21499/" ]
Since the trigonometric functions in java.lang.Math are quite slow: is there a library that does a quick and good approximation? It seems possible to do a calculation several times faster without losing much precision. (On my machine a multiplication takes 1.5ns, and java.lang.Math.sin 46ns to 116ns). Unfortunately the...
[Computer Approximations](https://rads.stackoverflow.com/amzn/click/com/0882756427) by Hart. Tabulates [Chebyshev-economized](http://en.wikipedia.org/wiki/Approximation_theory) approximate formulas for a bunch of functions at different precisions. **Edit:** Getting my copy off the shelf, it turned out to be [a differe...
523,540
<p>How is a JUMP and CALL instruction different? How does it relate to the higher level concepts such as a GOTO or a procedure call? (Am I correct in the comparison?)</p> <p>This is what I think: </p> <p>JUMP or GOTO is a transfer of the control to another location and the control does not automatically return to the...
[ { "answer_id": 523550, "author": "Anteru", "author_id": 39912, "author_profile": "https://Stackoverflow.com/users/39912", "pm_score": 6, "selected": true, "text": "<p>You're mostly right, if you are talking about CALL/JMP in x86 assembly or something similar. The main difference is:</p>\...
2009/02/07
[ "https://Stackoverflow.com/questions/523540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How is a JUMP and CALL instruction different? How does it relate to the higher level concepts such as a GOTO or a procedure call? (Am I correct in the comparison?) This is what I think: JUMP or GOTO is a transfer of the control to another location and the control does not automatically return to the point from where...
You're mostly right, if you are talking about CALL/JMP in x86 assembly or something similar. The main difference is: * JMP performs a jump to a location, without doing anything else * CALL pushes the current instruction pointer on the stack (rather: one after the current instruction), and then JMPs to the location. Wi...
523,571
<p>I draw a line on a Canvas object with the moveTo and lineTo graphics methods. If one end of the line lies outside the Canvas, the line spills out and is drawn over or under other elements in the application.</p> <p>How do I make the Canvas keep the line contained within itself?</p> <p>Thanks!</p>
[ { "answer_id": 523608, "author": "seanhodges", "author_id": 43662, "author_profile": "https://Stackoverflow.com/users/43662", "pm_score": 2, "selected": false, "text": "<p>I had a similar problem some time ago. You need to embed another container inside the canvas, and draw the primitive...
2009/02/07
[ "https://Stackoverflow.com/questions/523571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I draw a line on a Canvas object with the moveTo and lineTo graphics methods. If one end of the line lies outside the Canvas, the line spills out and is drawn over or under other elements in the application. How do I make the Canvas keep the line contained within itself? Thanks!
``` <mx:Canvas id="canvas" top="0" right="51" left="0" bottom="32"> <mx:Canvas x="-1" y="0" width="0" height="0"> <!-- This is a HACK to make the canvas clip --> </mx:Canvas> </mx:Canvas> ```
523,579
<p>I got a little question here:</p> <p>Some time ago I implemented HTTP Streaming using PHP code, something similar to what is on this page:</p> <p><a href="http://my.opera.com/WebApplications/blog/show.dml/438711#comments" rel="nofollow noreferrer">http://my.opera.com/WebApplications/blog/show.dml/438711#comments</...
[ { "answer_id": 524133, "author": "ionelmc", "author_id": 23658, "author_profile": "https://Stackoverflow.com/users/23658", "pm_score": 1, "selected": false, "text": "<p>That looks like a cgi code - I imagine the web server buffers the response from the cgi handlers. So it's really a matt...
2009/02/07
[ "https://Stackoverflow.com/questions/523579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58260/" ]
I got a little question here: Some time ago I implemented HTTP Streaming using PHP code, something similar to what is on this page: <http://my.opera.com/WebApplications/blog/show.dml/438711#comments> And I get data with very similar solution. Now I tried to use second code from this page (in Python), but no matter w...
Its highly likely App Engine buffers output. A quick search found this: <http://code.google.com/appengine/docs/python/tools/webapp/buildingtheresponse.html> > > The out stream buffers all output in memory, then sends the final output when the handler exits. webapp does not support streaming data to the client. > > ...
523,597
<p>I have some(say 9, no not definite) unique strings from database(A,B,C,D,E,F,G,H) and I want to create unique combination of these fields to populate the listbox so that user can select single or different combination of these string fields like A,B,C,D,E,F,G,H, AB,AC,AD,AE,AF,AG,AH,AC,AD,AE,AF,AG,AG,AH,... ABC,ABD...
[ { "answer_id": 523602, "author": "vrdhn", "author_id": 414441, "author_profile": "https://Stackoverflow.com/users/414441", "pm_score": 0, "selected": false, "text": "<p>This is like counting integers in base 'n' .. should not be difficult.</p>\n" }, { "answer_id": 523605, "a...
2009/02/07
[ "https://Stackoverflow.com/questions/523597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have some(say 9, no not definite) unique strings from database(A,B,C,D,E,F,G,H) and I want to create unique combination of these fields to populate the listbox so that user can select single or different combination of these string fields like A,B,C,D,E,F,G,H, AB,AC,AD,AE,AF,AG,AH,AC,AD,AE,AF,AG,AG,AH,... ABC,ABD,AB...
My first choice would be "use a `CheckedListBox` and let the user make their picks themselves" - this will save their sanity... would you want to look for "ABCEFH" in a long list?). If you want the strings: How about just using binary arithmetic? i.e. use a number (bit-length as per the number of elements), and simply...
523,619
<p>I have a Visual Studio setup project that has an Installer class. In the installer class I set a setting as follows:</p> <pre><code>MessageBox.Show(Properties.Settings.Default.MySetting); Properties.Settings.Default.MySetting = "Foo"; Properties.Settings.Default.Save(); MessageBox.Show(Properties.Settings.Default...
[ { "answer_id": 523620, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>I honestly don't know if this is supported during an installer - but if it is, make sure you're calling <code>Save...
2009/02/07
[ "https://Stackoverflow.com/questions/523619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445/" ]
I have a Visual Studio setup project that has an Installer class. In the installer class I set a setting as follows: ``` MessageBox.Show(Properties.Settings.Default.MySetting); Properties.Settings.Default.MySetting = "Foo"; Properties.Settings.Default.Save(); MessageBox.Show(Properties.Settings.Default.MySetting); ...
What I do for my installers is to use the "file" attribute in App.Config. The appSettings block takes a "file" attribute, like so: ``` <appSettings file="user.config"> <add key="foo" value="some value unchanged by setup"/> </appSettings> ``` The "file" attribute is sort of like CSS, in that the most specific set...
523,629
<p>I'm considering ditching PHP's <code>$_SESSION</code> (i.e. the server-side session handling, to add some language-agnostic flavor) and using signed cookies instead, since I've heard so much good about them (Flickr uses them, so they ought to be good enough for me too).</p> <p>I understand the basic context of the ...
[ { "answer_id": 523638, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 6, "selected": true, "text": "<h2>Why bother?</h2>\n\n<p>I wouldn't use this technique for sensitive data. It can be useful in combination with a regula...
2009/02/07
[ "https://Stackoverflow.com/questions/523629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2238/" ]
I'm considering ditching PHP's `$_SESSION` (i.e. the server-side session handling, to add some language-agnostic flavor) and using signed cookies instead, since I've heard so much good about them (Flickr uses them, so they ought to be good enough for me too). I understand the basic context of the technique: Use cookie...
Why bother? ----------- I wouldn't use this technique for sensitive data. It can be useful in combination with a regular session though - you can give the client a cookie with a normal session id, but also include all those key/value pairs that your application needs on every page. This way, you can avoid hitting your...
523,636
<p>I wonder if someone could help me out with an issue I'm experiencing trying to get my site up and running on Goddaddy. I'm trying to get extension-less url rewriting working using the ManagedFusion Rewriter (<a href="http://www.codeplex.com/urlrewriter/" rel="nofollow noreferrer">http://www.codeplex.com/urlrewriter/...
[ { "answer_id": 976894, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 0, "selected": false, "text": "<p>This is actually a known issue with GoDaddy's Medium Trust environment. However with the latest release of <a href=\"ht...
2009/02/07
[ "https://Stackoverflow.com/questions/523636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I wonder if someone could help me out with an issue I'm experiencing trying to get my site up and running on Goddaddy. I'm trying to get extension-less url rewriting working using the ManagedFusion Rewriter (<http://www.codeplex.com/urlrewriter/>) Unfortunately I'm getting the following error: > > Server Error in '/'...
I hit this same exception on a new install, changing the App pool identity to NetworkService / aspnet fixed it. Additionally, enabling Load User Profile on the app pool also worked.
523,641
<p>My webpage with diffrent sites should just load one .js file for cache optimizing. The problem comes up, when the file is loaded. It applies the listener on every page to the form elements (for example) so, just the last page's form acts like it should, the others does not cause their actions were overwritten.</p> ...
[ { "answer_id": 523675, "author": "smack0007", "author_id": 26566, "author_profile": "https://Stackoverflow.com/users/26566", "pm_score": 0, "selected": false, "text": "<p>Wrap each page in different divs with a simple id like \"page1\" and \"page2\". Then in your javascript grab the elem...
2009/02/07
[ "https://Stackoverflow.com/questions/523641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63371/" ]
My webpage with diffrent sites should just load one .js file for cache optimizing. The problem comes up, when the file is loaded. It applies the listener on every page to the form elements (for example) so, just the last page's form acts like it should, the others does not cause their actions were overwritten. So my q...
Your attempt at optimizing for the browser is conflicting w/ your varying page-by-page behavior. I wouldn't jam it all into one js file. Think about maintainability, modularization. You could put common/shared code into one js file, and include it in all pages. The browser will still cache it all, it will just have to...
523,690
<p>i wanna find some text for example "Joe" and remove it from where it is in Excel Worksheet with C# ?</p>
[ { "answer_id": 523805, "author": "David Morton", "author_id": 45916, "author_profile": "https://Stackoverflow.com/users/45916", "pm_score": 4, "selected": true, "text": "<p>You would need to use the Range.Replace method, and simply replace with an empty string. </p>\n\n<pre class=\"lang-...
2009/02/07
[ "https://Stackoverflow.com/questions/523690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50985/" ]
i wanna find some text for example "Joe" and remove it from where it is in Excel Worksheet with C# ?
You would need to use the Range.Replace method, and simply replace with an empty string. ```cs static void ReplaceTextInExcelFile(string filename, string replace, string replacement) { object m = Type.Missing; // open excel. Application app = new ApplicationClass(); // open the workbook. Workbo...
523,695
<p><strong>Rewritten:</strong> My original post seemed to be misunderstood. I have since reported it as a bug with the following description. My original post for this question can be found below the second <code>&lt;HR</code>>.</p> <hr> <p>I have a major issue with POST in a user control. </p> <ul> <li><p>I have a ...
[ { "answer_id": 523711, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p><strong>EDIT2</strong>: I just noticed that you are using RenderAction instead of RenderPartial. I suspect what is h...
2009/02/07
[ "https://Stackoverflow.com/questions/523695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
**Rewritten:** My original post seemed to be misunderstood. I have since reported it as a bug with the following description. My original post for this question can be found below the second `<HR`>. --- I have a major issue with POST in a user control. * I have a UserControl which has a controller containing two Ac...
**EDIT2**: I just noticed that you are using RenderAction instead of RenderPartial. I suspect what is happening is that it is using the RequestContext of the posted form to choose which ContactUsForm method to choose when the RenderAction is invoked. This is arguably correct behavior since the action **is** being invok...
523,710
<p>I'm working with a 3rd pary app where I can't alter the tables. We built custom matching "Monthly" tables with an additional datetime column "AsOfDate" where we dump the data at the end of the month and flag those data with the date of last day of the month.</p> <p>I want to be able to create a single Stored Proced...
[ { "answer_id": 523725, "author": "Gumbo", "author_id": 53114, "author_profile": "https://Stackoverflow.com/users/53114", "pm_score": 6, "selected": true, "text": "<p>My understanding is of the internal session handling process is the following:</p>\n\n<p>When <a href=\"http://php.net/ses...
2009/02/07
[ "https://Stackoverflow.com/questions/523710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61339/" ]
I'm working with a 3rd pary app where I can't alter the tables. We built custom matching "Monthly" tables with an additional datetime column "AsOfDate" where we dump the data at the end of the month and flag those data with the date of last day of the month. I want to be able to create a single Stored Procedure (Appli...
My understanding is of the internal session handling process is the following: When [`session_start`](http://php.net/session_start) is called, PHP is looking for a parameter from the client that was sent via POST, GET, or in a cookie (depending on the configuration; see [*session.use\_cookies*](http://php.net/manual/e...
523,724
<pre><code>int temp = 0x5E; // in binary 0b1011110. </code></pre> <p>Is there such a way to check if bit 3 in temp is 1 or 0 without bit shifting and masking.</p> <p>Just want to know if there is some built in function for this, or am I forced to write one myself.</p>
[ { "answer_id": 523731, "author": "yawmark", "author_id": 45204, "author_profile": "https://Stackoverflow.com/users/45204", "pm_score": 3, "selected": false, "text": "<p>You can use a Bitset - <a href=\"http://www.cppreference.com/wiki/stl/bitset/start\" rel=\"noreferrer\">http://www.cppr...
2009/02/07
[ "https://Stackoverflow.com/questions/523724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62570/" ]
``` int temp = 0x5E; // in binary 0b1011110. ``` Is there such a way to check if bit 3 in temp is 1 or 0 without bit shifting and masking. Just want to know if there is some built in function for this, or am I forced to write one myself.
In C, if you want to hide bit manipulation, you can write a macro: ``` #define CHECK_BIT(var,pos) ((var) & (1<<(pos))) ``` and use it this way to check the nth bit from the right end: ``` CHECK_BIT(temp, n - 1) ``` In C++, you can use [std::bitset](http://www.cppreference.com/wiki/stl/bitset/start).
523,727
<p>In Expression Blend you can create a font-size of say 18 and then create a "font-size resource".</p> <p>Coming at this from HTML/CSS, I cannot think of when I would want to make a style for a "font-size" and one for a "font-style" and one for a "font-weight". Instead I want to make a font called "CompanyHeader" and...
[ { "answer_id": 523807, "author": "Phil Wright", "author_id": 6276, "author_profile": "https://Stackoverflow.com/users/6276", "pm_score": 2, "selected": false, "text": "<p>It allows you to reuse the font details at am more granular level than having to define all elements of the font defi...
2009/02/07
[ "https://Stackoverflow.com/questions/523727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
In Expression Blend you can create a font-size of say 18 and then create a "font-size resource". Coming at this from HTML/CSS, I cannot think of when I would want to make a style for a "font-size" and one for a "font-style" and one for a "font-weight". Instead I want to make a font called "CompanyHeader" and have 10 d...
I have no experience with Blend, but styles in XAML can include more than one attribute, more then that, since unlike css you can only apply one style to an element you can't combine multiple one-attribute styles. Here is an example for a style that set multiple properties: ``` <Page xmlns="http://schemas.microsoft.c...
523,767
<p>I am developing a simple platform game using Java using BlueJ as the IDE. Right now I have player/enemy sprites, platforms and other items in the game drawn using polygons and simple shapes. Eventually I hope to replace them with actual images.</p> <p>For now I would like to know what is the simplest solution to se...
[ { "answer_id": 523818, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 6, "selected": true, "text": "<p>The answer will vary slightly depending on whether the application or applet is using <a href=\"http://java.sun.com/java...
2009/02/07
[ "https://Stackoverflow.com/questions/523767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63666/" ]
I am developing a simple platform game using Java using BlueJ as the IDE. Right now I have player/enemy sprites, platforms and other items in the game drawn using polygons and simple shapes. Eventually I hope to replace them with actual images. For now I would like to know what is the simplest solution to setting an i...
The answer will vary slightly depending on whether the application or applet is using [AWT](http://java.sun.com/javase/6/docs/technotes/guides/awt/) or [Swing](http://java.sun.com/docs/books/tutorial/uiswing/index.html). (Basically, classes that start with `J` such as `JApplet` and `JFrame` are Swing, and `Applet` and...
523,771
<p>According to <a href="http://guides.rubyonrails.org/testing_rails_applications.html#_the_low_down_on_fixtures" rel="nofollow noreferrer">this Rails guide</a>, if you create a fixture, it becomes available in your test class.</p> <p>I have this fixture in <code>users.yml</code>:</p> <pre><code>&lt;% stan = User.n...
[ { "answer_id": 523780, "author": "Jarin Udom", "author_id": 574, "author_profile": "https://Stackoverflow.com/users/574", "pm_score": 3, "selected": false, "text": "<p>Make sure you have</p>\n\n<pre><code>fixtures :all\n</code></pre>\n\n<p>In your test_helper.rb</p>\n" }, { "answ...
2009/02/07
[ "https://Stackoverflow.com/questions/523771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
According to [this Rails guide](http://guides.rubyonrails.org/testing_rails_applications.html#_the_low_down_on_fixtures), if you create a fixture, it becomes available in your test class. I have this fixture in `users.yml`: ``` <% stan = User.new stan.username = 'stan' stan.set_hashed_password('mysterio') sta...
Thanks for the help guys. I realized that I had various declarations and calls structured incorrectly. This isn't clearly explained in the guide I cited, but apparently `users(:stan)` only works inside a `should` block, or in pure Test::Unit inside a `test_` method.
523,773
<p>Suppose you're given an URL, <a href="http://site.com" rel="nofollow noreferrer">http://site.com</a> . How do you find out what it's content type is without downloading it? Can Perl's <a href="http://search.cpan.org/dist/WWW-Mechanize" rel="nofollow noreferrer">WWW::Mechanize</a> or <a href="http://search.cpan.org/d...
[ { "answer_id": 523779, "author": "Rutesh Makhijani", "author_id": 57686, "author_profile": "https://Stackoverflow.com/users/57686", "pm_score": 4, "selected": true, "text": "<p>You can use <code>head()</code> method of LWP in following manner</p>\n\n<pre><code>use LWP::UserAgent;\n$ua = ...
2009/02/07
[ "https://Stackoverflow.com/questions/523773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
Suppose you're given an URL, <http://site.com> . How do you find out what it's content type is without downloading it? Can Perl's [WWW::Mechanize](http://search.cpan.org/dist/WWW-Mechanize) or [LWP](http://search.cpan.org/dist/libwww-perl) issue a HEAD request?
You can use `head()` method of LWP in following manner ``` use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->head('<url>'); ```
523,796
<p>I have two arrays in PHP as follows:</p> <p><em>People:</em></p> <pre><code>Array ( [0] =&gt; 3 [1] =&gt; 20 ) </code></pre> <p><em>Wanted Criminals:</em></p> <pre><code>Array ( [0] =&gt; 2 [1] =&gt; 4 [2] =&gt; 8 [3] =&gt; 11 [4] =&gt; 12 [5] =&gt; 13 [6] =&gt; 14 [7] =&g...
[ { "answer_id": 523798, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 9, "selected": true, "text": "<p>You can use <a href=\"http://www.php.net/array_intersect\" rel=\"noreferrer\"><code>array_intersect()</code></a>.</p>\n\n<p...
2009/02/07
[ "https://Stackoverflow.com/questions/523796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21709/" ]
I have two arrays in PHP as follows: *People:* ``` Array ( [0] => 3 [1] => 20 ) ``` *Wanted Criminals:* ``` Array ( [0] => 2 [1] => 4 [2] => 8 [3] => 11 [4] => 12 [5] => 13 [6] => 14 [7] => 15 [8] => 16 [9] => 17 [10] => 18 [11] => 19 [12] => 20 ) ``` H...
You can use [`array_intersect()`](http://www.php.net/array_intersect). ``` $result = !empty(array_intersect($people, $criminals)); ```
523,800
<p>I'm looking for a way to generate combinations of objects ordered by a single attribute. I don't think lexicographical order is what I'm looking for... I'll try to give an example. Let's say I have a list of objects A,B,C,D with the attribute values I want to order by being 3,3,2,1. This gives A3, B3, C2, D1 objects...
[ { "answer_id": 523835, "author": "simon", "author_id": 6040, "author_profile": "https://Stackoverflow.com/users/6040", "pm_score": 0, "selected": false, "text": "<p>Check out this question in stackoverflow: <a href=\"https://stackoverflow.com/questions/127704/algorithm-to-return-all-comb...
2009/02/07
[ "https://Stackoverflow.com/questions/523800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61299/" ]
I'm looking for a way to generate combinations of objects ordered by a single attribute. I don't think lexicographical order is what I'm looking for... I'll try to give an example. Let's say I have a list of objects A,B,C,D with the attribute values I want to order by being 3,3,2,1. This gives A3, B3, C2, D1 objects. N...
Actually, I think you *do* want lexicographic order, but descending rather than ascending. In addition: * It's not clear to me from your description that A, B, ... D play any role in your answer (except possibly as the container for the values). * I think your question example is simply "For each integer at least 5, u...
523,811
<p>I am currently building a small admin section for a website using Zend Framework, this is only my second time of using the framework so I am a little unsure on something things. for example are I have an archive option for news articles where the user will hopefully click a link and the article will be archived howe...
[ { "answer_id": 523819, "author": "Jack Sleight", "author_id": 39428, "author_profile": "https://Stackoverflow.com/users/39428", "pm_score": 0, "selected": false, "text": "<h2>Orignal Answer:</h2>\n\n<p>Your call to:</p>\n\n<pre><code>$this-&gt;_redirect();\n</code></pre>\n\n<p>Calls the ...
2009/02/07
[ "https://Stackoverflow.com/questions/523811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am currently building a small admin section for a website using Zend Framework, this is only my second time of using the framework so I am a little unsure on something things. for example are I have an archive option for news articles where the user will hopefully click a link and the article will be archived however...
I use this with calls to AJAX-only actions that I either don't want output or I'm using some other output, like XML or JSON: ``` // Disable the main layout renderer $this->_helper->layout->disableLayout(); // Do not even attempt to render a view $this->_helper->viewRenderer->setNoRender(true); ``` This has the added...
523,836
<p>I'm using the excellent <a href="http://jalbum.net/" rel="nofollow noreferrer">Jalbum</a> to create a photo album for a website. Each page of the generated photo album is a complete webpage, so the recommended way to embed the album within a website is to use an iframe.</p> <p>A problem arises when I want to style ...
[ { "answer_id": 523970, "author": "airportyh", "author_id": 5304, "author_profile": "https://Stackoverflow.com/users/5304", "pm_score": 2, "selected": false, "text": "<p>You could use JavaScript code to insert a CSS include into the document of the iframe.</p>\n" }, { "answer_id":...
2009/02/07
[ "https://Stackoverflow.com/questions/523836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I'm using the excellent [Jalbum](http://jalbum.net/) to create a photo album for a website. Each page of the generated photo album is a complete webpage, so the recommended way to embed the album within a website is to use an iframe. A problem arises when I want to style the images contained within the embedded iframe...
You could use JavaScript code to insert a CSS include into the document of the iframe.
523,837
<p>I have multiple switch statements in on one of the pages in order to pass different variables to the URL, as well as different case. I need these different switch statements because I need the different variables.</p> <p>However, when I put a "default" in one of the switch statements, that default applies to every ...
[ { "answer_id": 523858, "author": "MattBelanger", "author_id": 655, "author_profile": "https://Stackoverflow.com/users/655", "pm_score": 2, "selected": false, "text": "<p>This might be way off, but I think you need something like this:</p>\n\n<pre><code>if (isset($_POST['myvar'])) {\n s...
2009/02/07
[ "https://Stackoverflow.com/questions/523837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have multiple switch statements in on one of the pages in order to pass different variables to the URL, as well as different case. I need these different switch statements because I need the different variables. However, when I put a "default" in one of the switch statements, that default applies to every other swit...
This might be way off, but I think you need something like this: ``` if (isset($_POST['myvar'])) { switch ($_POST['myvar'] { case 1: .... break; default: .... break; } } else if (isset($_POST['myvar2'])) { switch ($_POST['myvar2'] { case 1: .... break; ...
523,843
<p>I'd like to create a link in a view within a Rails application that does this...</p> <pre><code>DELETE /sessions </code></pre> <p>How would I do that.</p> <p>Added complication:</p> <p>The "session" resource has no model because it represents a user login session. <code>CREATE</code> means the user logs in, <cod...
[ { "answer_id": 523856, "author": "Mario", "author_id": 63414, "author_profile": "https://Stackoverflow.com/users/63414", "pm_score": 1, "selected": false, "text": "<p>Correct me if I'm wrong, but I believe you can only send POST and GET requests with a browser (in HTML).</p>\n" }, { ...
2009/02/07
[ "https://Stackoverflow.com/questions/523843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
I'd like to create a link in a view within a Rails application that does this... ``` DELETE /sessions ``` How would I do that. Added complication: The "session" resource has no model because it represents a user login session. `CREATE` means the user logs in, `DESTROY` means logs out. That's why there's no ID par...
Correct, browsers don't actually support sending delete requests. The accepted convention of many web frameworks is to send a \_method parameter set to 'DELETE', and use a POST request. Here's an example in Rails: ``` <%= link_to 'log out', session_path, :method => :delete %> ``` You may want to have a look at [Res...
523,861
<p>suppose I have a vector:</p> <pre><code> 0 1 2 3 4 5 [45,89,22,31,23,76] </code></pre> <p>And a permutation of its indices:</p> <pre><code>[5,3,2,1,0,4] </code></pre> <p>Is there an efficient way to resort it according to the permutation thus obtaining:</p> <pre><code>[76,31,22,89,45,23] </code></pre> <p>...
[ { "answer_id": 523870, "author": "Zach Scrivena", "author_id": 20029, "author_profile": "https://Stackoverflow.com/users/20029", "pm_score": 5, "selected": true, "text": "<p>Yes. Starting from the leftmost position, we put the <em>element</em> there in its correct <em>position</em> i by ...
2009/02/07
[ "https://Stackoverflow.com/questions/523861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25418/" ]
suppose I have a vector: ``` 0 1 2 3 4 5 [45,89,22,31,23,76] ``` And a permutation of its indices: ``` [5,3,2,1,0,4] ``` Is there an efficient way to resort it according to the permutation thus obtaining: ``` [76,31,22,89,45,23] ``` Using at most O(1) additional space?
Yes. Starting from the leftmost position, we put the *element* there in its correct *position* i by swapping it with the (other) misplaced element at that position i. This is where we need the O(1) additional space. We keep swapping pairs of elements around until the element in this position is correct. Only then do we...
523,871
<p>What is the best way to concatenate a list of String objects? I am thinking of doing this way:</p> <pre><code>List&lt;String&gt; sList = new ArrayList&lt;String&gt;(); // add elements if (sList != null) { String listString = sList.toString(); listString = listString.subString(1, listString.length() - 1); ...
[ { "answer_id": 523881, "author": "Kevin", "author_id": 26620, "author_profile": "https://Stackoverflow.com/users/26620", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>I somehow found this to be neater than\n using the StringBuilder/StringBuffer\n approach.</p>\n</blockq...
2009/02/07
[ "https://Stackoverflow.com/questions/523871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4406/" ]
What is the best way to concatenate a list of String objects? I am thinking of doing this way: ``` List<String> sList = new ArrayList<String>(); // add elements if (sList != null) { String listString = sList.toString(); listString = listString.subString(1, listString.length() - 1); } ``` I somehow found th...
Your approach is dependent on Java's ArrayList#toString() implementation. While the implementation is documented in the Java API and very unlikely to change, there's a chance it could. It's far more reliable to implement this yourself (loops, StringBuilders, recursion whatever you like better). Sure this approach may...
523,872
<p>I have a small hierarchy of objects that I need to serialize and transmit via a socket connection. I need to both serialize the object, then deserialize it based on what type it is. Is there an easy way to do this in C++ (as there is in Java)?</p> <p>Just to be clear, I'm looking for methods on converting an object ...
[ { "answer_id": 523882, "author": "newgre", "author_id": 62459, "author_profile": "https://Stackoverflow.com/users/62459", "pm_score": 7, "selected": true, "text": "<p>Talking about serialization, the <a href=\"http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/index.html\" rel=\...
2009/02/07
[ "https://Stackoverflow.com/questions/523872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
I have a small hierarchy of objects that I need to serialize and transmit via a socket connection. I need to both serialize the object, then deserialize it based on what type it is. Is there an easy way to do this in C++ (as there is in Java)? Just to be clear, I'm looking for methods on converting an object into an a...
Talking about serialization, the [boost serialization API](http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/index.html) comes to my mind. As for transmitting the serialized data over the net, I'd either use Berkeley sockets or the [asio library](http://tenermerx.com/Asio/). If you want to serialize your obj...
523,874
<p>With Test::Unit, I can run:</p> <pre><code>ruby path/to/test.rb --name=test_name_that_i_want_to_run </code></pre> <p>Thus far, I have not been able to figure out how to do this with test/spec specifications. I am wondering if the way that specifications are automatically named does not allow me to do something lik...
[ { "answer_id": 524883, "author": "dj2", "author_id": 23850, "author_profile": "https://Stackoverflow.com/users/23850", "pm_score": 2, "selected": false, "text": "<p>Take the following spec for example:</p>\n\n<pre><code> require 'rubygems' \n require 'spec' \n\n describe 'tests' do ...
2009/02/07
[ "https://Stackoverflow.com/questions/523874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5830/" ]
With Test::Unit, I can run: ``` ruby path/to/test.rb --name=test_name_that_i_want_to_run ``` Thus far, I have not been able to figure out how to do this with test/spec specifications. I am wondering if the way that specifications are automatically named does not allow me to do something like this.
After contacting the gem maintainer, Christian Neukirchen, I found out how to do this, so I am documenting it here for future reference. ``` specrb path/to/test.rb --name ".*should behave this way.*" ``` I needed to use the specrb test runner, an extended version Test::Unit's test runner, rather than just the ruby c...
523,878
<p>I have a Cygwin bash script that I need to watch and terminate under certain conditions - specifically, after a certain file has been created. I'm having difficulty figuring out how exactly to terminate the script with the same level of completeness that Ctrl+C does, however.</p> <p>Here's a simple script (called <...
[ { "answer_id": 523934, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://unix.derkeiler.com/Newsgroups/comp.unix.shell/2004-05/1108.html\" rel=\"nofollow noreferrer\">Th...
2009/02/07
[ "https://Stackoverflow.com/questions/523878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3712/" ]
I have a Cygwin bash script that I need to watch and terminate under certain conditions - specifically, after a certain file has been created. I'm having difficulty figuring out how exactly to terminate the script with the same level of completeness that Ctrl+C does, however. Here's a simple script (called **`test1`**...
/bin/kill (the program, not the bash builtin) interprets a *negative* PID as “kill the process group” which will get all the children too. Changing ``` kill %1 ``` to ``` /bin/kill -- -$$ ``` works for me.
523,885
<p>I'm starting to lose my head with this one.</p> <p>I have a class that extends BaseHTTPRequestHandler. It works fine on Python 2.5. And yesterday I was curious and decided to install Python 3.0 on my Mac (I followed this tutorial, to be sure I wasn't messing things up: <a href="http://farmdev.com/thoughts/66/python...
[ { "answer_id": 524363, "author": "BobbyShaftoe", "author_id": 38426, "author_profile": "https://Stackoverflow.com/users/38426", "pm_score": 2, "selected": false, "text": "<p>From <a href=\"http://social.msdn.microsoft.com/Forums/en-US/netfxsetup/thread/f56cc6e4-c2bf-490c-b87b-3e22b1e6b93...
2009/02/07
[ "https://Stackoverflow.com/questions/523885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/261019/" ]
I'm starting to lose my head with this one. I have a class that extends BaseHTTPRequestHandler. It works fine on Python 2.5. And yesterday I was curious and decided to install Python 3.0 on my Mac (I followed this tutorial, to be sure I wasn't messing things up: <http://farmdev.com/thoughts/66/python-3-0-on-mac-os-x-a...
From [this](http://social.msdn.microsoft.com/Forums/en-US/netfxsetup/thread/f56cc6e4-c2bf-490c-b87b-3e22b1e6b935/): > > The .NET Runtime Optimization Service > attempts to re-try compilation of > assemblies when it runs into what it > believes are transient errors; > examples include RPC errors, > out-of-memory ...
523,890
<p>Background:</p> <p>I needed to split a string of numerous words into an array which separates the words for me for further use later on in my code. However, I needed to get rid of any numbers which might be present in the string so I declared a string contaning characters which I wanted to use as separators/delimit...
[ { "answer_id": 524363, "author": "BobbyShaftoe", "author_id": 38426, "author_profile": "https://Stackoverflow.com/users/38426", "pm_score": 2, "selected": false, "text": "<p>From <a href=\"http://social.msdn.microsoft.com/Forums/en-US/netfxsetup/thread/f56cc6e4-c2bf-490c-b87b-3e22b1e6b93...
2009/02/07
[ "https://Stackoverflow.com/questions/523890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45402/" ]
Background: I needed to split a string of numerous words into an array which separates the words for me for further use later on in my code. However, I needed to get rid of any numbers which might be present in the string so I declared a string contaning characters which I wanted to use as separators/delimiters as fol...
From [this](http://social.msdn.microsoft.com/Forums/en-US/netfxsetup/thread/f56cc6e4-c2bf-490c-b87b-3e22b1e6b935/): > > The .NET Runtime Optimization Service > attempts to re-try compilation of > assemblies when it runs into what it > believes are transient errors; > examples include RPC errors, > out-of-memory ...
523,894
<p>Say I have three window classes, one for each OS I want to support: </p> <ul> <li>WindowsWindow</li> <li>OSXWindow</li> <li>LinuxWindow</li> </ul> <p>They all inherit from the <strong>Window</strong> class. This is also the class you instantiate. The Window class have the . -> and :: operators overloaded, and dep...
[ { "answer_id": 523901, "author": "Harper Shelby", "author_id": 21196, "author_profile": "https://Stackoverflow.com/users/21196", "pm_score": 1, "selected": false, "text": "<p>What you should probably do is have a factory method, and use the PIMPL idiom. Your factory creates 2 classes - a...
2009/02/07
[ "https://Stackoverflow.com/questions/523894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56763/" ]
Say I have three window classes, one for each OS I want to support: * WindowsWindow * OSXWindow * LinuxWindow They all inherit from the **Window** class. This is also the class you instantiate. The Window class have the . -> and :: operators overloaded, and depending on which OS were running on (based on IFDEFs) it...
You can't overload the scope resolution operator :: at all. You could overload the -> operator, but when you invoke that operator, you already have to have an object of the requisite type. For creating your windows, just use a simple factory method: ``` class Window { public: static Window *CreateWindow(...) {...
523,912
<p>I know it's not easy to find a master in GINA, but my question is most near to Interprocess Communication(IPC), I wrote my custom GINA in unmanaged c++, I included it a method that checks for validity of a fingerprint for the user try to login, this function will call some method in a running system windows service ...
[ { "answer_id": 523950, "author": "Stephen Martin", "author_id": 12845, "author_profile": "https://Stackoverflow.com/users/12845", "pm_score": 1, "selected": false, "text": "<p>I'd strongly recommend that you use named pipes. They are fast, easy to use from the C# side, provided you are u...
2009/02/07
[ "https://Stackoverflow.com/questions/523912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32718/" ]
I know it's not easy to find a master in GINA, but my question is most near to Interprocess Communication(IPC), I wrote my custom GINA in unmanaged c++, I included it a method that checks for validity of a fingerprint for the user try to login, this function will call some method in a running system windows service wri...
The canonical method for communicating with a service (or most IPC that potentially needs to cross a session/desktop boundary) is a named pipe. You can use mailslots as well, but you have to deal with duplication issues because mailslot messages get duped across all installed protocols, so you need some kind of tagging...
523,930
<p>I'm trying to replace this:</p> <pre><code>void ProcessRequest(object listenerContext) { var context = (HttpListenerContext)listenerContext; Uri URL = new Uri(context.Request.RawUrl); HttpWebRequest.DefaultWebProxy = null; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(URL); h...
[ { "answer_id": 523989, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 2, "selected": false, "text": "<p>Socket, by definition, is the low level to access the network. You can even use datagram protocols with a socket. In that c...
2009/02/07
[ "https://Stackoverflow.com/questions/523930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4386/" ]
I'm trying to replace this: ``` void ProcessRequest(object listenerContext) { var context = (HttpListenerContext)listenerContext; Uri URL = new Uri(context.Request.RawUrl); HttpWebRequest.DefaultWebProxy = null; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(URL); httpWebRequest....
Here's some code that works for me. ``` using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Sockets; using System.Text; using System.IO.Compression; namespace HttpUsingSockets { public class Program { private static readonly Encoding DefaultEncoding = Encodi...
523,937
<p>WHen submitting data to Data Layer when userID is not a field in the object being passed, but will still need to cross reference tables with userID when submitting data, should I call the the membership class to get the UserID at the datalayer, or should I pass UserID from level to level as a parameter? (ie from th...
[ { "answer_id": 523953, "author": "Lee Harold", "author_id": 56091, "author_profile": "https://Stackoverflow.com/users/56091", "pm_score": 1, "selected": false, "text": "<p>In general I'd prefer to see GetUser() in SaveObject(), since that would allow the business layer to be abstracted a...
2009/02/07
[ "https://Stackoverflow.com/questions/523937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49632/" ]
WHen submitting data to Data Layer when userID is not a field in the object being passed, but will still need to cross reference tables with userID when submitting data, should I call the the membership class to get the UserID at the datalayer, or should I pass UserID from level to level as a parameter? (ie from the bu...
Whilst this is indeed a cross-cutting concern, my personal preference is that code such as: ``` MembershipUser user = Membership.GetUser(); Guid userID = (Guid)user.ProviderUserKey; ``` should NOT be in the data layer. I like to see this kind of code in a layer higher than the data layer, usually the business layer...
523,957
<p>My MIPS Assembly class required me to read in an expression of unknown size into a Parse Tree. I've never had to deal with trees, so this is how I went around storing values:</p> <p>Lets say the user entered the expression 1 + 3 - 4 (each operand could only be a digit 1-9)</p> <p>My leftmost child node would be t...
[ { "answer_id": 523982, "author": "sykora", "author_id": 53850, "author_profile": "https://Stackoverflow.com/users/53850", "pm_score": 2, "selected": false, "text": "<p>In general you should construct a tree in such a way that all the leaf nodes (those with no children) are operands, and ...
2009/02/07
[ "https://Stackoverflow.com/questions/523957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14013/" ]
My MIPS Assembly class required me to read in an expression of unknown size into a Parse Tree. I've never had to deal with trees, so this is how I went around storing values: Lets say the user entered the expression 1 + 3 - 4 (each operand could only be a digit 1-9) My leftmost child node would be the starting point ...
Your parse tree should look something like this: ``` '-' | +---+---+ | | '+' '4' | +---+---+ | | '1' '3' ``` Each node has two pointers. One to its left child and one to its right child. There is no need for pointers to parent nodes, when using recursive tra...
524,019
<p>I'm having a problem right now where I can't see where my child threads are spitting out error messages which is making it difficult to debug.</p> <p>eg:</p> <pre><code>Thread.new{ a = 1/0 } </code></pre> <p>Is there any way to have all thread errors print out at stderr?</p>
[ { "answer_id": 524080, "author": "Morendil", "author_id": 61168, "author_profile": "https://Stackoverflow.com/users/61168", "pm_score": 5, "selected": true, "text": "<p>Set the Thread class' <code>abort_on_exception</code> flag to true.</p>\n\n<p>Alternately, wrap the thread body in a th...
2009/02/07
[ "https://Stackoverflow.com/questions/524019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14559/" ]
I'm having a problem right now where I can't see where my child threads are spitting out error messages which is making it difficult to debug. eg: ``` Thread.new{ a = 1/0 } ``` Is there any way to have all thread errors print out at stderr?
Set the Thread class' `abort_on_exception` flag to true. Alternately, wrap the thread body in a throw/catch block and dump the exception in the catch.
524,022
<p>I want to download a sound file from a short URL (like: <code>www.adjix.com</code>) When I try from normal link, it's OK, but from short URL, how first redirect and then download</p> <p>I use this part of code to create request:</p> <pre><code>NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[...
[ { "answer_id": 524035, "author": "Samantha Branham", "author_id": 62590, "author_profile": "https://Stackoverflow.com/users/62590", "pm_score": 2, "selected": false, "text": "<p>I have used Aptana/RadRails in the past and thouroghly enjoyed it. I suggest giving it a try. There is a sta...
2009/02/07
[ "https://Stackoverflow.com/questions/524022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32034/" ]
I want to download a sound file from a short URL (like: `www.adjix.com`) When I try from normal link, it's OK, but from short URL, how first redirect and then download I use this part of code to create request: ``` NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlToSound]]...
Try the [Dynamic Languages Toolkit](http://www.eclipse.org/dltk/) for Ruby. It's available from Eclipse's Software Updates panel. Update May 2020: Ruby support was dropped in DLTK 6.0 in favour of [Eclipse Solargraph](https://github.com/PyvesB/eclipse-solargraph).
524,028
<p>Im trying to write a small class to better understand bit flags in c++. But something isnt working out. It prints the wrong values. Where is the problem? Have I misunderstood how to add flags? Or check if the bit field has them?</p> <p>Heres the code:</p> <pre><code>#include &lt;iostream&gt; enum flag { A = 1...
[ { "answer_id": 524042, "author": "Hans Passant", "author_id": 17034, "author_profile": "https://Stackoverflow.com/users/17034", "pm_score": 2, "selected": false, "text": "<p>There's a bug in your remove_flag() method, it should be flags |= i; </p>\n\n<p>But, do it O(1) like this:</p>\n\...
2009/02/07
[ "https://Stackoverflow.com/questions/524028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56763/" ]
Im trying to write a small class to better understand bit flags in c++. But something isnt working out. It prints the wrong values. Where is the problem? Have I misunderstood how to add flags? Or check if the bit field has them? Heres the code: ``` #include <iostream> enum flag { A = 1, B = 2, C = 4 }; class Ho...
personally I would use std::vector< bool > to handle flags, since it is a specialization that packs bools into bit. However: I think your remove flag is a bit complex, try this instead ``` void remove_flag( flag f ) { if ( has_flag( f ) == true ) { m_flags ^= f; // toggle the bit leaving all other unc...
524,033
<p>Is there a way to write OO-like code in the <code>C</code> programming language?</p> <hr> <p>See also:</p> <ul> <li><a href="https://stackoverflow.com/questions/351733/can-you-write-object-oriented-code-in-c">Can you write object-oriented code in C?</a></li> <li><a href="https://stackoverflow.com/questions/415452...
[ { "answer_id": 524056, "author": "Peter Štibraný", "author_id": 47190, "author_profile": "https://Stackoverflow.com/users/47190", "pm_score": 6, "selected": false, "text": "<p>Common approach is to define struct with pointers to functions. This defines 'methods' which can be called on an...
2009/02/07
[ "https://Stackoverflow.com/questions/524033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49628/" ]
Is there a way to write OO-like code in the `C` programming language? --- See also: * [Can you write object-oriented code in C?](https://stackoverflow.com/questions/351733/can-you-write-object-oriented-code-in-c) * [Object-orientation in C](https://stackoverflow.com/questions/415452/object-orientation-in-c) Found b...
The first C++ compiler ("C with classes") would actually generate C code, so that's definitely doable. Basically, your base class is a struct; derived structs must include the base struct at the first position, so that a pointer to the "derived" struct will also be a valid pointer to the base struct. ``` typedef stru...
524,039
<p>I'm having trouble consistently setting the width and height of an img tag. The img src is pulled dynamically from a database. The images being pulled from the database can have varying widths and heights so I need to set the img control. Sometimes the width and height are set properly and sometimes they aren't. I c...
[ { "answer_id": 524056, "author": "Peter Štibraný", "author_id": 47190, "author_profile": "https://Stackoverflow.com/users/47190", "pm_score": 6, "selected": false, "text": "<p>Common approach is to define struct with pointers to functions. This defines 'methods' which can be called on an...
2009/02/07
[ "https://Stackoverflow.com/questions/524039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30921/" ]
I'm having trouble consistently setting the width and height of an img tag. The img src is pulled dynamically from a database. The images being pulled from the database can have varying widths and heights so I need to set the img control. Sometimes the width and height are set properly and sometimes they aren't. I can'...
The first C++ compiler ("C with classes") would actually generate C code, so that's definitely doable. Basically, your base class is a struct; derived structs must include the base struct at the first position, so that a pointer to the "derived" struct will also be a valid pointer to the base struct. ``` typedef stru...
524,062
<p>The basic problem...</p> <p>I have a method which executes the following code:</p> <pre><code>IList&lt;Gig&gt; gigs = GetGigs().WithArtist(artistId).ToList(); </code></pre> <p>The GetGigs() method gets Gigs from my database via LinqToSql...</p> <p>So, when GetGigs().WithArtist(artistId).ToList() is executed I ge...
[ { "answer_id": 524102, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>I don't see anything in your classes to indicate how LINQ to SQL is meant to work out which column is which, etc.</p>...
2009/02/07
[ "https://Stackoverflow.com/questions/524062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46616/" ]
The basic problem... I have a method which executes the following code: ``` IList<Gig> gigs = GetGigs().WithArtist(artistId).ToList(); ``` The GetGigs() method gets Gigs from my database via LinqToSql... So, when GetGigs().WithArtist(artistId).ToList() is executed I get the following exception: ``` Member access ...
I think the problem is the 'let' statement in GetGigs. Using 'let' means that you define a part of the final query separately from the main set to fetch. the problem is that 'let', if it's not a scalar, results in a nested query. Nested queries are not really Linq to sql's strongest point as they're executed deferred a...
524,075
<p>I have seen numerous examples of lazy loading - what's your choice?</p> <p>Given a model class for example:</p> <pre><code>public class Person { private IList&lt;Child&gt; _children; public IList&lt;Child&gt; Children { get { if (_children == null) LoadChildren(); ...
[ { "answer_id": 524088, "author": "Dmitri Nesteruk", "author_id": 9476, "author_profile": "https://Stackoverflow.com/users/9476", "pm_score": 0, "selected": false, "text": "<p>I'm thinking that this is <em>precisely</em> the kind of problem that is best handled by AOP (e.g., PostSharp). H...
2009/02/07
[ "https://Stackoverflow.com/questions/524075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31412/" ]
I have seen numerous examples of lazy loading - what's your choice? Given a model class for example: ``` public class Person { private IList<Child> _children; public IList<Child> Children { get { if (_children == null) LoadChildren(); return _children; ...
The best lazy loading is avoiding it ;) Thread safety is an immediate problem you'll have to handle. I have no count of how often I have seen production systems with 8 cpu cores run lazy loading 8 times for *every single* lazy loading pattern in use. At least on server startups all server cores have a tendency to end u...
524,081
<p>I want to distribute a command-line application written in Java on Windows. </p> <p>My application is distributed as a zip file, which has a lib directory entry which has the .jar files needed for invoking my main class. Currently, for Unix environments, I have a shell script which invokes the java command with a C...
[ { "answer_id": 524096, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": false, "text": "<p>Why would you use find? Presumably you know all the libraries your jar file needs ahead of time, so why not just list...
2009/02/07
[ "https://Stackoverflow.com/questions/524081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3973/" ]
I want to distribute a command-line application written in Java on Windows. My application is distributed as a zip file, which has a lib directory entry which has the .jar files needed for invoking my main class. Currently, for Unix environments, I have a shell script which invokes the java command with a CLASSPATH c...
You want to use the for loop in Batch script ``` @echo off setLocal EnableDelayedExpansion set CLASSPATH=" for /R ./lib %%a in (*.jar) do ( set CLASSPATH=!CLASSPATH!;%%a ) set CLASSPATH=!CLASSPATH!" echo !CLASSPATH! ``` This really helped me when I was looking for a batch script to iterate through all the ...
524,099
<p>If I use a custom panel to layout my ListBoxItems, the ListBox won't respect their combined Height (it does respect their combined Width though) - even when my ArrangeOverride returns a size that surrounds all the items. </p> <p>Setting the ListBox's Height explicitly makes everything work, but I want it to work t...
[ { "answer_id": 524091, "author": "Jim Petkus", "author_id": 38053, "author_profile": "https://Stackoverflow.com/users/38053", "pm_score": 6, "selected": true, "text": "<p>There is actually a third approach. The asp.net membership functionality is based on the provider model. You can writ...
2009/02/07
[ "https://Stackoverflow.com/questions/524099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1177/" ]
If I use a custom panel to layout my ListBoxItems, the ListBox won't respect their combined Height (it does respect their combined Width though) - even when my ArrangeOverride returns a size that surrounds all the items. Setting the ListBox's Height explicitly makes everything work, but I want it to work that out for...
There is actually a third approach. The asp.net membership functionality is based on the provider model. You can write a custom provider, thus being able to provide your own implementation for how the data is stored, but retaining much of the benefit of asp.net membership. Some articles on the subject: <http://msdn.m...
524,137
<p>I want to get the icons of common file types in my dll. I am using vc++. I only have the file extension and mime type of the file based on which I want to get the icon for the file.</p> <p>Can someone please tell me how I can do that? (The method available in vc++ needs the user to give the path of the file for whi...
[ { "answer_id": 524155, "author": "Priyank Bolia", "author_id": 61821, "author_profile": "https://Stackoverflow.com/users/61821", "pm_score": -1, "selected": false, "text": "<p>Identify the icon information from the registry, the associate file type and program that handles the file and e...
2009/02/07
[ "https://Stackoverflow.com/questions/524137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46297/" ]
I want to get the icons of common file types in my dll. I am using vc++. I only have the file extension and mime type of the file based on which I want to get the icon for the file. Can someone please tell me how I can do that? (The method available in vc++ needs the user to give the path of the file for which the ico...
### Shell API You can get them from the shell by calling [`SHGetFileInfo()`](http://msdn.microsoft.com/en-us/library/bb762179(VS.85).aspx) along with the `SHGFI_USEFILEATTRIBUTES` flag - this flag allows the routine to work without requiring the filename passed in to actually exist, so if you have a file extension jus...
524,145
<p>how can I replace 2 strings in the same time? for example let's say I have string like this:</p> <p>str1 = "AAAA BBBB CCCC DDDD"</p> <p>i want to replace every "AAAA" with "CCCC" and every "CCCC" with "AAAA" but if i did:</p> <p>str1.gsub("AAAA","CCCC") # <strong>CCCC</strong> BBBB CCCC DDDD</p> <p>str1.gsub("CC...
[ { "answer_id": 524153, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>General answer:<br>\nUse a regex to match both AAAA and CCCC, then substitute each match with CCCC and AAAA respectively.</p...
2009/02/07
[ "https://Stackoverflow.com/questions/524145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
how can I replace 2 strings in the same time? for example let's say I have string like this: str1 = "AAAA BBBB CCCC DDDD" i want to replace every "AAAA" with "CCCC" and every "CCCC" with "AAAA" but if i did: str1.gsub("AAAA","CCCC") # **CCCC** BBBB CCCC DDDD str1.gsub("CCCC","AAAA") # **AAAA** BBBB **AAAA** DDDD w...
General answer: Use a regex to match both AAAA and CCCC, then substitute each match with CCCC and AAAA respectively. **edit** to clear up the confusion ``` str1.gsub(/(AAAA|CCCC)/) { $1 == 'AAAA' ? 'CCCC' : 'AAAA' } ``` **edit** i thought of a more elegant way too :) ``` str1.gsub(/((AAAA)|(CCCC))/) { $2 ? 'CCC...
524,196
<p>Is there a #define in C# that allows me to know, at compile time, if I'm compiling for x86 (Win32) or x64 (Win64)?</p>
[ { "answer_id": 524218, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>Not that I know of. You would have to declare your own in different project configurations.</p>\n" }, { "a...
2009/02/07
[ "https://Stackoverflow.com/questions/524196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62572/" ]
Is there a #define in C# that allows me to know, at compile time, if I'm compiling for x86 (Win32) or x64 (Win64)?
By default there is no way to do this. The reason is that C# code is not designed to target a particular platform as it runs on the CLR. It is possible to hand roll this though. You can use the project configuration settings in Visual Studio to define your own constants. Or if you want it a little more streamline you...
524,222
<p>The HTML standard for forms appears to be such that disabled input elements do not contribute to the form name/value collection.</p> <p>Is there ANY way to get around this? I need to be able to toggle disable on and off but still return whatever the value is when the form is submitted.</p> <p>I realize that I can...
[ { "answer_id": 524236, "author": "Ian G", "author_id": 31765, "author_profile": "https://Stackoverflow.com/users/31765", "pm_score": -1, "selected": false, "text": "<p>Can you use <code>Visible=false</code> and/or <code>ReadOnly=true</code> instead of <code>Enabled=false</code>?</p>\n\n<...
2009/02/07
[ "https://Stackoverflow.com/questions/524222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The HTML standard for forms appears to be such that disabled input elements do not contribute to the form name/value collection. Is there ANY way to get around this? I need to be able to toggle disable on and off but still return whatever the value is when the form is submitted. I realize that I can use JavaScript to...
You should use the `readOnly` flag rather than `disabled`. Read-only fields cannot be edited by the user, but are still submitted with the form. ``` <input type="text" value="blah" readonly="true"/> ```
524,223
<p>It's easy enough to set up a table view to allow editing. Just add one line to your UITableViewController:</p> <pre><code>self.navigationItem.rightBarButtonItem = self.editButtonItem; </code></pre> <p>This line adds an edit button on the nav bar that will change the table to editing mode and change its button text...
[ { "answer_id": 524437, "author": "Can Berk Güder", "author_id": 2119, "author_profile": "https://Stackoverflow.com/users/2119", "pm_score": 2, "selected": true, "text": "<p>Yes, you can add UIBarButtonItems in Interface Builder, and they should work.</p>\n\n<p>The identifier lets you use...
2009/02/07
[ "https://Stackoverflow.com/questions/524223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63706/" ]
It's easy enough to set up a table view to allow editing. Just add one line to your UITableViewController: ``` self.navigationItem.rightBarButtonItem = self.editButtonItem; ``` This line adds an edit button on the nav bar that will change the table to editing mode and change its button text to "Done" while editing. ...
Yes, you can add UIBarButtonItems in Interface Builder, and they should work. The identifier lets you use a preset button (like Edit or Reload), or you can choose Custom and make your own button. **EDIT:** I may be able to help further if you could explain how UIBarButtonItems added through IB don't work. **UPDATE:*...
524,224
<p>Mail for my domain is handled by google apps service, all required DNS MX records entered correctly. Also I have webserver that handles HTTP requests for the domain. And I can't send mail from that server to my mail domain, sendmail ignores MX records and always trying to deliver all messages for my domain locally.<...
[ { "answer_id": 524250, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 1, "selected": false, "text": "<p>Ditch sendmail and get postfix. Sendmail is difficult to configure correctly, and difficult to keep secure. Postfi...
2009/02/07
[ "https://Stackoverflow.com/questions/524224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15958/" ]
Mail for my domain is handled by google apps service, all required DNS MX records entered correctly. Also I have webserver that handles HTTP requests for the domain. And I can't send mail from that server to my mail domain, sendmail ignores MX records and always trying to deliver all messages for my domain locally. Lo...
Well. Found a solution for my case. Just add the following line to your source .mc-file and recreate sendmail.cf ``` define(`confDONT_PROBE_INTERFACES', `true') ```
524,265
<p>Which query would run faster?</p> <pre><code>SELECT * FROM topic_info LEFT JOIN topic_data ON topic_info.id = topic_data.id WHERE id = ? </code></pre> <p>or</p> <pre><code>SELECT * FROM topic_info LEFT JOIN topic_data ON topic_data.id = topic_info.id WHERE id = ? </code></pre> <p>The difference is the or...
[ { "answer_id": 524277, "author": "Samantha Branham", "author_id": 62590, "author_profile": "https://Stackoverflow.com/users/62590", "pm_score": 3, "selected": true, "text": "<p>I don't think it should make a difference. Pick a convention and stick with it.</p>\n" }, { "answer_id...
2009/02/07
[ "https://Stackoverflow.com/questions/524265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23107/" ]
Which query would run faster? ``` SELECT * FROM topic_info LEFT JOIN topic_data ON topic_info.id = topic_data.id WHERE id = ? ``` or ``` SELECT * FROM topic_info LEFT JOIN topic_data ON topic_data.id = topic_info.id WHERE id = ? ``` The difference is the order of expressions on the "ON" clause: the first ...
I don't think it should make a difference. Pick a convention and stick with it.
524,274
<p>I am setting the locale of my .net application via: </p> <pre><code> string userLocale = Web.Helpers.LocaleHelpers.GetBestRFC3066Locale(this.Context.Request.UserLanguages); if (userLocale != String.Empty) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Global...
[ { "answer_id": 524289, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 2, "selected": false, "text": "<p>Store the date as a <code>datetime</code> value in SQL Server. Then you don't run into a conversion problem.</p>\n" },...
2009/02/07
[ "https://Stackoverflow.com/questions/524274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46616/" ]
I am setting the locale of my .net application via: ``` string userLocale = Web.Helpers.LocaleHelpers.GetBestRFC3066Locale(this.Context.Request.UserLanguages); if (userLocale != String.Empty) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.Cultur...
Store the date as a `datetime` value in SQL Server. Then you don't run into a conversion problem.
524,275
<p>I'm making a fair amount of calls to database tables via ADO. In the spirit of keeping things DRY, I wrote the following functions to return an array of values from a recordset. Is this hare brained? I use it mainly for grabbing a set of combo-box values and the like, never for enormous values. Example Usage (erro...
[ { "answer_id": 524296, "author": "Morendil", "author_id": 61168, "author_profile": "https://Stackoverflow.com/users/61168", "pm_score": 0, "selected": false, "text": "<p>Yes, it makes sense to factor out common tasks. I don't see anything wrong with the general idea. I'm wondering why yo...
2009/02/07
[ "https://Stackoverflow.com/questions/524275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53594/" ]
I'm making a fair amount of calls to database tables via ADO. In the spirit of keeping things DRY, I wrote the following functions to return an array of values from a recordset. Is this hare brained? I use it mainly for grabbing a set of combo-box values and the like, never for enormous values. Example Usage (error h...
I wonder why you are not using GetRows? It returns an array, you will find more details here: <http://www.w3schools.com/ado/met_rs_getrows.asp> A few notes on GetRows: ``` Set objRS = Server.CreateObject ("ADODB.Recordset") objRS.Open cmd, , adOpenForwardOnly, adLockReadOnly If Not objRS.EOF Then astrEmployees = ...
524,286
<p><strong>Objective</strong>: Make a progress bar where users can check how much of a file has been downloaded by my server.</p> <p><strong>Scenario</strong>:I have a PHP script that executes a python script via popen. I have done this like so:</p> <pre><code>$handle = popen('python last', 'r'); $read = fread($hand...
[ { "answer_id": 524359, "author": "user52875", "author_id": 52875, "author_profile": "https://Stackoverflow.com/users/52875", "pm_score": 3, "selected": true, "text": "<p>First thing that comes into my mind: maybe the program detects that it is not executed on a TTY and therefore does not...
2009/02/07
[ "https://Stackoverflow.com/questions/524286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51649/" ]
**Objective**: Make a progress bar where users can check how much of a file has been downloaded by my server. **Scenario**:I have a PHP script that executes a python script via popen. I have done this like so: ``` $handle = popen('python last', 'r'); $read = fread($handle, 4096); pclose($handle); ``` This python ...
First thing that comes into my mind: maybe the program detects that it is not executed on a TTY and therefore does not show the last line, which probably involves ugly control characters because that line seems to update itself? What happens when you redirect the output to a file (in the shell), or pipe it through les...
524,291
<p>I have created a Python file to generate a Mandelbrot set image. The original maths code was not mine, so I do not understand it - I only heavily modified it to make it about 250x faster (Threads rule!).</p> <p>Anyway, I was wondering how I could modify the maths part of the code to make it render one specific bit....
[ { "answer_id": 524312, "author": "Ian Hopkinson", "author_id": 19172, "author_profile": "https://Stackoverflow.com/users/19172", "pm_score": 5, "selected": true, "text": "<p>The line:</p>\n\n<pre><code>box=((-2,1.25),(0.5,-1.25))\n</code></pre>\n\n<p>is the bit that defines the area of c...
2009/02/07
[ "https://Stackoverflow.com/questions/524291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42584/" ]
I have created a Python file to generate a Mandelbrot set image. The original maths code was not mine, so I do not understand it - I only heavily modified it to make it about 250x faster (Threads rule!). Anyway, I was wondering how I could modify the maths part of the code to make it render one specific bit. Here is t...
The line: ``` box=((-2,1.25),(0.5,-1.25)) ``` is the bit that defines the area of coordinate space that is being rendered, so you just need to change this line. First coordinate pair is the top-left of the area, the second is the bottom right. To get a new coordinate from the image should be quite straightforward....
524,295
<p>I have heard people state that Code Generators and T4 templates should not be used. The logic behind that is that if you are generating code with a generator then there is a better more efficient way to build the code through generics and templating. </p> <p>While I slightly agree with this statement above, I have ...
[ { "answer_id": 524341, "author": "Peter Morris", "author_id": 61311, "author_profile": "https://Stackoverflow.com/users/61311", "pm_score": 5, "selected": true, "text": "<p>You can do new T(); if you do this</p>\n\n<pre><code>public class Meh&lt;T&gt;\n where T : new()\n{\n public stat...
2009/02/07
[ "https://Stackoverflow.com/questions/524295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49415/" ]
I have heard people state that Code Generators and T4 templates should not be used. The logic behind that is that if you are generating code with a generator then there is a better more efficient way to build the code through generics and templating. While I slightly agree with this statement above, I have not really...
You can do new T(); if you do this ``` public class Meh<T> where T : new() { public static T CreateOne() { return new T(); } } ``` As for code-generators. I use one every day without any problems. I'm using one right now in fact :-) Generics solve one problem, code-generators solve another. For example,...
524,308
<p>I've just started to learn about <strong>tie</strong>. I have a class named Link which I would like to do the following thing:</p> <ul> <li>if fetched, return the link's address</li> <li>if stored, store the new address</li> <li>be able to call methods on it</li> </ul> <p>So far, my code is :</p> <pre><code> pack...
[ { "answer_id": 524449, "author": "John Siracusa", "author_id": 164, "author_profile": "https://Stackoverflow.com/users/164", "pm_score": 3, "selected": false, "text": "<p>I suggest making a normal Perl object and then <a href=\"http://perldoc.perl.org/overload.html\" rel=\"noreferrer\">o...
2009/02/07
[ "https://Stackoverflow.com/questions/524308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
I've just started to learn about **tie**. I have a class named Link which I would like to do the following thing: * if fetched, return the link's address * if stored, store the new address * be able to call methods on it So far, my code is : ``` package Link; sub FETCH { my $this = shift; return $this->{"s...
Tie is the wrong tool for this job. You use ties when you want the same interface as normal data types but want to customize how the operations do their work. Since you want to access and store a string just like a scalar already does, tie doesn't do anything for you. It looks like you want the [URI](http://search.cpa...
524,330
<p>So, I got this idea that I'd try to prototype an experimental user interface using OpenGL and some physics. I know little about either of the topics, but am pretty experienced with programming languages such as C++, Java and C#. After some initial research, I decided on using Python (with Eclipse/PyDev) and Qt, both...
[ { "answer_id": 524355, "author": "Ron Warholic", "author_id": 22780, "author_profile": "https://Stackoverflow.com/users/22780", "pm_score": 1, "selected": false, "text": "<p>The only real alternative if you desire all those things is to use Java, but honestly you're being a bit picky abo...
2009/02/07
[ "https://Stackoverflow.com/questions/524330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9116/" ]
So, I got this idea that I'd try to prototype an experimental user interface using OpenGL and some physics. I know little about either of the topics, but am pretty experienced with programming languages such as C++, Java and C#. After some initial research, I decided on using Python (with Eclipse/PyDev) and Qt, both ne...
It seems you aren't mainly having a problem with Python itself, but instead with the IDE. *"Bad API documentation"* To what API? Python itself, Qt or some other library you are using? *"lacking code completion (due to dynamic typing)"* As long as you are not doing anything magic, I find that PyDev is pretty darn go...
524,369
<p>The following C++ code compiles and runs correctly for GNU g++, LLVM and every other C++ compiler I threw at it except for Microsoft VC6 and VC7:</p> <pre><code>template&lt;typename A, typename B&gt; int HasVoidReturnType(A(*)(B)) { return 0; } template&lt;typename B&gt; int HasVoidReturnType(void(*)(B)) { return 1...
[ { "answer_id": 524382, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Instead of creating two templates, have you tried just using the first one and using template specialization to define the ...
2009/02/07
[ "https://Stackoverflow.com/questions/524369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The following C++ code compiles and runs correctly for GNU g++, LLVM and every other C++ compiler I threw at it except for Microsoft VC6 and VC7: ``` template<typename A, typename B> int HasVoidReturnType(A(*)(B)) { return 0; } template<typename B> int HasVoidReturnType(void(*)(B)) { return 1; } void f(double) {} int ...
Try this on for size ``` template<typename FuncPtrType> struct DecomposeFuncPtr; template<typename ReturnType, typename ArgType> struct DecomposeFuncPtr<ReturnType(*)(ArgType)> { typedef ReturnType return_type; }; template<typename T> struct is_void { enum { value = 0 }; }; template<> struct is_void<void> { e...
524,392
<p>I'm trying to do this, and failing. Is there any reason why it wouldn't work in Django template syntax? I'm using the latest version of Django.</p> <pre><code>{% ifequal entry.created_at|timesince "0 minutes" %} </code></pre>
[ { "answer_id": 524411, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 0, "selected": false, "text": "<p>I think you can, though I don't see any uses of it my code base. Maybe <code>entry.created_at|timesince</code> ...
2009/02/07
[ "https://Stackoverflow.com/questions/524392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/326176/" ]
I'm trying to do this, and failing. Is there any reason why it wouldn't work in Django template syntax? I'm using the latest version of Django. ``` {% ifequal entry.created_at|timesince "0 minutes" %} ```
It doesn't work because it's not supposed to work. What you're asking for is not part of the template language. You can't apply a filter in the middle of tag like `{% ifequal`. When a template tag uses a variable, it doesn't expect an expression, it expects a variable, nothing more. That kind of logic -- extracting t...
524,398
<p>I want to Extract the Members Home sites links from a site. Looks like this</p> <pre><code>&lt;a href="http://www.ptop.se" target="_blank"&gt; </code></pre> <p>i tested with it this site</p> <p><a href="http://www.rubular.com/" rel="nofollow noreferrer">http://www.rubular.com/</a></p> <pre><code>&lt;a href="(.*...
[ { "answer_id": 700422, "author": "dmondark", "author_id": 53582, "author_profile": "https://Stackoverflow.com/users/53582", "pm_score": 1, "selected": false, "text": "<p>Several issues with your code</p>\n\n<ol start=\"2\">\n<li>I don't know what you mean by using\n\n<h1>{link}. But if y...
2009/02/07
[ "https://Stackoverflow.com/questions/524398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to Extract the Members Home sites links from a site. Looks like this ``` <a href="http://www.ptop.se" target="_blank"> ``` i tested with it this site <http://www.rubular.com/> ``` <a href="(.*?)" target="_blank"> ``` Shall output <http://www.ptop.se>, Here comes the code ``` require 'open-uri' ...
I would suggest that you use one of the good ruby HTML/XML parsing libraries e.g. [Hpricot](http://wiki.github.com/why/hpricot) or [Nokogiri](http://wiki.github.com/tenderlove/nokogiri). If you need to log in on the site you might be interested in a library like [WWW::Mechanize](http://rubyforge.org/projects/mechanize...
524,413
<p>I recall reviewing someone else's PHP code once and he had a function or class method that rolled all GET and POST variables into a single plain old object that could then be passed around. If the same name-value pair appeared in both GET and POST, POST would win.</p> <p>Is there a well-coded PHP add-on out there o...
[ { "answer_id": 524427, "author": "farzad", "author_id": 9394, "author_profile": "https://Stackoverflow.com/users/9394", "pm_score": 0, "selected": false, "text": "<p>you can use $_REQUEST global variable. it is defined by the PHP interpreted by default when your application is running in...
2009/02/07
[ "https://Stackoverflow.com/questions/524413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42223/" ]
I recall reviewing someone else's PHP code once and he had a function or class method that rolled all GET and POST variables into a single plain old object that could then be passed around. If the same name-value pair appeared in both GET and POST, POST would win. Is there a well-coded PHP add-on out there of any sort...
You could use [`$_REQUEST`](http://php.net/manual/reserved.variables.request.php), but be aware that it contains the contents of `$_GET`, `$_POST` and `$_COOKIE`, and that the presence (and order, for overwriting purposes) of variables in this superglobal is subject to configuration in the execution environment. If th...
524,416
<p>I am reporting on data that lets say has 10 columns. Now some of my clients have data in all 10 of the columns whereas some may only use 7 or 5... you get the idea. Of course I dont want to have to build a new rdl for each possibiliy. Well in the tabular report I can hide the columns fine if no data exists by usi...
[ { "answer_id": 524427, "author": "farzad", "author_id": 9394, "author_profile": "https://Stackoverflow.com/users/9394", "pm_score": 0, "selected": false, "text": "<p>you can use $_REQUEST global variable. it is defined by the PHP interpreted by default when your application is running in...
2009/02/07
[ "https://Stackoverflow.com/questions/524416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47576/" ]
I am reporting on data that lets say has 10 columns. Now some of my clients have data in all 10 of the columns whereas some may only use 7 or 5... you get the idea. Of course I dont want to have to build a new rdl for each possibiliy. Well in the tabular report I can hide the columns fine if no data exists by using the...
You could use [`$_REQUEST`](http://php.net/manual/reserved.variables.request.php), but be aware that it contains the contents of `$_GET`, `$_POST` and `$_COOKIE`, and that the presence (and order, for overwriting purposes) of variables in this superglobal is subject to configuration in the execution environment. If th...
524,420
<p>Given a list of arrays and lots of setup time I need to quickly find the smallest value in some sub-span of each array. In concept:</p> <pre><code>class SpanThing { int Data; SpanThing(int[][] data) /// must be rectangulare { Data = data; //// process, can take a while } ...
[ { "answer_id": 524489, "author": "Ryan Graham", "author_id": 62525, "author_profile": "https://Stackoverflow.com/users/62525", "pm_score": 2, "selected": false, "text": "<p>Your described approach sounds like you're trying to do some sort of <a href=\"http://en.wikipedia.org/wiki/Memoiza...
2009/02/07
[ "https://Stackoverflow.com/questions/524420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
Given a list of arrays and lots of setup time I need to quickly find the smallest value in some sub-span of each array. In concept: ``` class SpanThing { int Data; SpanThing(int[][] data) /// must be rectangulare { Data = data; //// process, can take a while } int[] MinsBrut...
Your proposed solution appears to give the answer using constant space overhead, constant time setup, and logarithmic time for queries. If you are willing to pay quadratic space (i.e., compute all intervals in advance) you can get answers in constant time. Your logarithmic scheme is almost certain to be preferred. It ...
524,421
<p>I have a website which consists of a bunch of static HTML pages. Obviously there's a lot of duplication among these (header, menu, etc). The hosting company I plan to use supports PHP, which I know nothing about. Presumably PHP provides some sort of #include mechanism, but what changes to I need to make to my HTML p...
[ { "answer_id": 524429, "author": "Erik Funkenbusch", "author_id": 61164, "author_profile": "https://Stackoverflow.com/users/61164", "pm_score": 3, "selected": false, "text": "<p>You don't need to use PHP to get this functionality, and it's generally a bad idea to do so due to potential s...
2009/02/07
[ "https://Stackoverflow.com/questions/524421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I have a website which consists of a bunch of static HTML pages. Obviously there's a lot of duplication among these (header, menu, etc). The hosting company I plan to use supports PHP, which I know nothing about. Presumably PHP provides some sort of #include mechanism, but what changes to I need to make to my HTML page...
You don't need to use PHP to get this functionality, and it's generally a bad idea to do so due to potential security concerns. Essentially, you're swatting a gnat with a nuclear bomb. If you're not using a dynamic language, then you're looking for server side includes. In IIS, for instance: ``` <!--#include virtual=...
524,428
<p>This is a compiler error (slightly changed for readability).</p> <p>This one always puzzled me. FxCop tells that this is a bad thing to return <code>List&lt;T&gt;</code> and classes that are derived from <code>Collection&lt;T&gt;</code> should be preferable as return types.</p> <p>Also, FxCop says that it is OK to u...
[ { "answer_id": 524436, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "<p><code>List&lt;T&gt;</code> doesn't derive from <code>Collection&lt;T&gt;</code> - it does, however, implement <code>IC...
2009/02/07
[ "https://Stackoverflow.com/questions/524428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/430254/" ]
This is a compiler error (slightly changed for readability). This one always puzzled me. FxCop tells that this is a bad thing to return `List<T>` and classes that are derived from `Collection<T>` should be preferable as return types. Also, FxCop says that it is OK to use `List<T>` for internal data storage/manipulati...
`List<T>` doesn't derive from `Collection<T>` - it does, however, implement `ICollection<T>`. That would be a better choice of return type. As for the `new List<int>(some collection<int>)` question - it partly depends on what the collection is. If it implements `ICollection<T>` (at execution time) then the constructor...
524,457
<p>I am using <a href="http://www.hanselman.com/blog/ASPNETMVCSessionAtMix08TDDAndMvcMockHelpers.aspx" rel="noreferrer">shanselmann's MvcMockHelper</a> class to mock up some HttpContext stuff using Moq but the issue I am having is being able to assign something to my mocked session object in my MVC controller and then ...
[ { "answer_id": 537070, "author": "Sean Chambers", "author_id": 2993, "author_profile": "https://Stackoverflow.com/users/2993", "pm_score": 0, "selected": false, "text": "<p>I think you can set an expectation on the mock with a specific value it should return whatever. Mocks are not used ...
2009/02/07
[ "https://Stackoverflow.com/questions/524457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6523/" ]
I am using [shanselmann's MvcMockHelper](http://www.hanselman.com/blog/ASPNETMVCSessionAtMix08TDDAndMvcMockHelpers.aspx) class to mock up some HttpContext stuff using Moq but the issue I am having is being able to assign something to my mocked session object in my MVC controller and then being able to read that same va...
I started with Scott Hanselman's [MVCMockHelper](http://www.hanselman.com/blog/ASPNETMVCSessionAtMix08TDDAndMvcMockHelpers.aspx), added a small class and made the modifications shown below to allow the controller to use Session normally and the unit test to verify the values that were set by the controller. ``` /// <s...
524,462
<p>i want to know how can we select more than one option from a select box like given below:</p> <pre><code>&lt;label for="color"&gt;Colors&lt;/label&gt; &lt;select class="inputbox" name="color" id="color" style="width:180px;"&gt; &lt;option value="Black"&gt;Black&lt;/option&gt; &lt;option value="White"&gt;Whi...
[ { "answer_id": 524465, "author": "nickohrn", "author_id": 59907, "author_profile": "https://Stackoverflow.com/users/59907", "pm_score": 4, "selected": false, "text": "<p>All you have to do is use the multiple attribute on the select box.</p>\n\n<pre><code>&lt;select name=\"some-select\" ...
2009/02/07
[ "https://Stackoverflow.com/questions/524462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63700/" ]
i want to know how can we select more than one option from a select box like given below: ``` <label for="color">Colors</label> <select class="inputbox" name="color" id="color" style="width:180px;"> <option value="Black">Black</option> <option value="White">White</option> <option value="Tan">Tan</option> ...
All you have to do is use the multiple attribute on the select box. ``` <select name="some-select" id="some-select" multiple="multiple"> <option>Black</option> <option>White</option> <option>Other</option> </select> ```
524,468
<p>I'm trying to select elements of the page that have been added after the page has loaded. See the before and after example below. Before is the page source, and after is the generated source. For some reason I can't select anything that has been generated.</p> <p>This seems odd to me as I'm pretty sure I've done th...
[ { "answer_id": 524473, "author": "rp.", "author_id": 2536, "author_profile": "https://Stackoverflow.com/users/2536", "pm_score": -1, "selected": false, "text": "<p>You need to double-check all of your code. jQuery can access all parts of the DOM, whether they are statically or dynamicall...
2009/02/07
[ "https://Stackoverflow.com/questions/524468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to select elements of the page that have been added after the page has loaded. See the before and after example below. Before is the page source, and after is the generated source. For some reason I can't select anything that has been generated. This seems odd to me as I'm pretty sure I've done this before....
All these comments about binding after append are helpful. But if you switch to jQuery 1.3, you can use "live" instead of "bind" when you first set up the page, then you'll get your event even on added elements. <http://docs.jquery.com/Events/live>
524,483
<p>I am trying to use the .NET Backgroundworker Object in an application I am developing.</p> <p>All the material on the internet say that this object runs in the "background" but <strong>nowhere have I been able to confirm that this background thread indeed runs in a "low priority" mode</strong>. This question arises...
[ { "answer_id": 524496, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>It doesn't claim to be low priority - background means a: not the UI thread, and b: it won't keep a process alive....
2009/02/07
[ "https://Stackoverflow.com/questions/524483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63731/" ]
I am trying to use the .NET Backgroundworker Object in an application I am developing. All the material on the internet say that this object runs in the "background" but **nowhere have I been able to confirm that this background thread indeed runs in a "low priority" mode**. This question arises because in Windows (I ...
Just to add to what Jon and Marc have already said: Background threads do not have lower priority. The difference between foreground and background threads is that the CLR will shutdown the process once no more foreground threads are running. Thread pool threads are background threads. You can actually set the prior...
524,495
<p>I'm writing some code where the UI thread need to communicate with the background thread doing network communication. The code works, but would it be considered thread safe?</p> <p>I would feel a lot better if someone experienced could lead me on to the right path on this...</p> <pre><code>static Mutex^ mut_curren...
[ { "answer_id": 524507, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>If you're using threads within a process and you only want mutual exclusion, use Monitor instead of a Mutex - it's mo...
2009/02/07
[ "https://Stackoverflow.com/questions/524495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37583/" ]
I'm writing some code where the UI thread need to communicate with the background thread doing network communication. The code works, but would it be considered thread safe? I would feel a lot better if someone experienced could lead me on to the right path on this... ``` static Mutex^ mut_currentPage = gcnew Mutex; ...
It looks thread-safe, but you might want to think about exception handling; setting a field shouldn't error (except perhaps `ThreadAbortException`), but if the code was more complex, you'd want to ensure you release the mutex upon exception. I'd also look at `Monitor` ("lock" in C#) One other thought: even if you loc...