qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
168,924
<p>Let's say I've got two strings in JavaScript:</p> <pre><code>var date1 = '2008-10-03T20:24Z' var date2 = '2008-10-04T12:24Z' </code></pre> <p>How would I come to a result like so:</p> <pre><code>'4 weeks ago' </code></pre> <p>or</p> <pre><code>'in about 15 minutes' </code></pre> <p>(should support past and future).</p> <p>There are solutions out there for the past diffs, but I've yet to find one with support for future time diffs as well.</p> <p>These are the solutions I tried:</p> <p><a href="http://ejohn.org/blog/javascript-pretty-date/#postcomment" rel="nofollow noreferrer">John Resig's Pretty Date</a> and <a href="http://www.zachleat.com/web/2008/03/23/yet-another-pretty-date-javascript/" rel="nofollow noreferrer">Zach Leatherman's modification</a></p> <p>Bonus points for a jQuery solution.</p>
[ { "answer_id": 169009, "author": "moonshadow", "author_id": 11834, "author_profile": "https://Stackoverflow.com/users/11834", "pm_score": 4, "selected": true, "text": " function humane_date(date_str){\n var time_formats = [\n [60, 'Just Now'],\n [90, '1 Minute'], ...
2008/10/03
[ "https://Stackoverflow.com/questions/168924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22468/" ]
168,926
<p>Ok, I'm using the term "Progressive Enhancement" kind of loosely here but basically I have a Flash-based website that supports deep linking and loads content dynamically - what I'd like to do is provide alternate content (text) for those either not having Flash and for search engine bots. So, for a user with flash they would navigate to:</p> <pre><code>http://www.samplesite.com/#specific_page </code></pre> <p>and they would see a flash site that would navigate to the "<code>specific_page</code>." Those without flash would see the "<code>specific_page</code>" rendered in text in the alternative content section.</p> <p>Basically, I would use php/mysql to create a backend to handle all of this since the swf is also using dynamic data. The question is, does something out there that does this already exist?</p>
[ { "answer_id": 169009, "author": "moonshadow", "author_id": 11834, "author_profile": "https://Stackoverflow.com/users/11834", "pm_score": 4, "selected": true, "text": " function humane_date(date_str){\n var time_formats = [\n [60, 'Just Now'],\n [90, '1 Minute'], ...
2008/10/03
[ "https://Stackoverflow.com/questions/168926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3435/" ]
168,931
<p>When you guys are unit testing an application that relies on values from an app.config file? How do you test that those values are read in correctly and how your program reacts to incorrect values entered into a config file?</p> <p>It would be ridiculous to have to modify the config file for the NUnit app, but I can't read in the values from the app.config I want to test.</p> <p>Edit: I think I should clarify perhaps. I'm not worried about the ConfigurationManager failing to read the values, but I am concerned with testing how my program reacts to the values read in.</p>
[ { "answer_id": 168936, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 4, "selected": false, "text": "app.config" }, { "answer_id": 255712, "author": "Community", "author_id": -1, "author_profile": "...
2008/10/03
[ "https://Stackoverflow.com/questions/168931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7856/" ]
168,946
<p>Here's my scenario. I created an application which uses Integrated Windows Authentication in order to work. In <code>Application_AuthenticateRequest()</code>, I use <code>HttpContext.Current.User.Identity</code> to get the current <code>WindowsPrincipal</code> of the user of my website.</p> <p>Now here's the funny part. Some of our users have recently gotten married, and their names change. (i.e. the user's NT Login changes from <code>jsmith</code> to <code>jjones</code>) and when my application authenticates them, IIS passes me their OLD LOGIN . I continue to see <code>jsmith</code> passed to my application until I reboot my SERVER! Logging off the client does not work. Restarting the app pool does not work. Only a full reboot. </p> <p>Does anyone know what's going on here? Is there some sort of command I can use to flush whatever cache is giving me this problem? Is my server misconfigured?</p> <p>Note: I definitely do NOT want to restart IIS, my application pools, or the machine. As this is a production box, these are not really viable options.</p> <hr> <p>AviD -</p> <p>Yes, their UPN was changed along with their login name. And Mark/Nick... This is a production enterprise server... It can't just be rebooted or have IIS restarted. </p> <hr> <p><strong>Follow up (for posterity):</strong></p> <p>Grhm's answer was spot-on. This problem pops up in low-volume servers where you don't have a lot of people using your applications, but enough requests are made to keep the users' identity in the cache. The key part of the <a href="http://support.microsoft.com/kb/946358" rel="noreferrer">KB</a> which seems to describe why the cache item is not refreshed after the default of 10 minutes is:</p> <blockquote> <p>The cache entries do time out, however chances are that recurring queries by applications keep the existing cache entry alive for the maximum lifetime of the cache entry.</p> </blockquote> <p>I'm not exactly sure what in our code was causing this (the recurring queries), but the resolution which worked for us was to cut the <code>LsaLookupCacheExpireTime</code> value from the seemingly obscene default of 1 week to just a few hours. This, for us, cut the probability that a user would be impacted in the real world to essentially zero, and yet at the same time doesn't cause an extreme number of SID-Name lookups against our directory servers. An even better solution IMO would be if applications looked up user information by SID instead of mapping user data to textual login name. (Take note, vendors! If you're relying on AD authentication in your application, you'll want to put the SID in your authentication database!)</p>
[ { "answer_id": 7685602, "author": "Grhm", "author_id": 204690, "author_profile": "https://Stackoverflow.com/users/204690", "pm_score": 6, "selected": true, "text": "LookupAccountName()\n\nLookupAccountSid()\n\nLsaOpenPolicy()\n" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/168946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24995/" ]
168,951
<hr /> <p><strong> The <a href="http://docs.php.net/manual/en/class.httprequestpool.php" rel="noreferrer">HttpRequestPool</a> class provides a solution. Many thanks to those who pointed this out.</p> <p>A brief tutorial can be found at: <a href="http://www.phptutorial.info/?HttpRequestPool-construct" rel="noreferrer">http://www.phptutorial.info/?HttpRequestPool-construct</a></strong></p> <hr /> <p><strong>Problem</strong></p> <p>I'd like to make concurrent/parallel/simultaneous HTTP requests in PHP. I'd like to avoid consecutive requests as:</p> <ul> <li>a set of requests will take too long to complete; the more requests the longer</li> <li>the timeout of one request midway through a set may cause later requests to not be made (if a script has an execution time limit)</li> </ul> <p>I have managed to find details for making <a href="http://www.phpied.com/simultaneuos-http-requests-in-php-with-curl/" rel="noreferrer">simultaneuos [sic] HTTP requests in PHP with cURL</a>, however I'd like to explicitly use PHP's <a href="http://php.net/manual/en/book.http.php" rel="noreferrer">HTTP functions</a> if at all possible.</p> <p>Specifically, I need to POST data concurrently to a set of URLs. The URLs to which data are posted are beyond my control; they are user-set.</p> <p>I don't mind if I need to wait for all requests to finish before the responses can be processed. If I set a timeout of 30 seconds on each request and requests are made concurrently, I know I must wait a maximum of 30 seconds (perhaps a little more) for all requests to complete.</p> <p>I can find no details of how this might be achieved. However, I did recently notice a mention in the PHP manual of PHP5+ being able to handle concurrent HTTP requests - I intended to make a note of it at the time, forgot, and cannot find it again.</p> <p><strong>Single request example (works fine)</strong></p> <pre><code>&lt;?php $request_1 = new HttpRequest($url_1, HTTP_METH_POST); $request_1-&gt;setRawPostData($dataSet_1); $request_1-&gt;send(); ?&gt; </code></pre> <p><strong>Concurrent request example (incomplete, clearly)</strong></p> <pre><code>&lt;?php $request_1 = new HttpRequest($url_1, HTTP_METH_POST); $request_1-&gt;setRawPostData($dataSet_1); $request_2 = new HttpRequest($url_2, HTTP_METH_POST); $request_2-&gt;setRawPostData($dataSet_2); // ... $request_N = new HttpRequest($url_N, HTTP_METH_POST); $request_N-&gt;setRawPostData($dataSet_N); // Do something to send() all requests at the same time ?&gt; </code></pre> <p>Any thoughts would be most appreciated!</p> <p><strong>Clarification 1</strong>: I'd like to stick to the PECL HTTP functions as:</p> <ul> <li>they offer a nice OOP interface</li> <li>they're used extensively in the application in question and sticking to what's already in use should be beneficial from a maintenance perspective</li> <li>I generally have to write fewer lines of code to make an HTTP request using the PECL HTTP functions compared to using cURL - fewer lines of code should also be beneficial from a maintenance perspective</li> </ul> <p><strong>Clarification 2</strong>: I realise PHP's HTTP functions aren't built in and perhaps I worded things wrongly there, which I shall correct. I have no concerns about people having to install extra stuff - this is not an application that is to be distributed, it's a web app with a server to itself.</p> <p><strong>Clarification 3</strong>: I'd be perfectly happy if someone authoritatively states that the PECL HTTP cannot do this.</p>
[ { "answer_id": 195806, "author": "Willem", "author_id": 15447, "author_profile": "https://Stackoverflow.com/users/15447", "pm_score": 2, "selected": false, "text": "$request_list = array(\n # address => http request string\n #\n '127.0.0.1' => \"HTTP/1.1 GET /index.html\\nServer: we...
2008/10/03
[ "https://Stackoverflow.com/questions/168951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5343/" ]
168,956
<p>I need a (php) regex to match Yahoo's username rules:</p> <blockquote> <p>Use 4 to 32 characters and start with a letter. You may use letters, numbers, underscores, and one dot (.).</p> </blockquote>
[ { "answer_id": 168965, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "[A-Za-z][A-Za-z0-9_.]{3,31}\n" }, { "answer_id": 168971, "author": "Randy", "author_id": 9361, "au...
2008/10/03
[ "https://Stackoverflow.com/questions/168956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24999/" ]
168,961
<p>I'm trying to add the lucene sandbox contribution called <a href="http://lucene.apache.org/java/docs/lucene-sandbox/index.html#Term%20Highlighter" rel="nofollow noreferrer">term-highlighter</a> to my pom.xml. I'm not really that familiar with Maven, but the code has a <a href="http://svn.apache.org/repos/asf/lucene/java/trunk/contrib/highlighter/pom.xml.template" rel="nofollow noreferrer">pom.xml.template</a> which seems to imply if I add a dependency that looks like:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.apache.lucene&lt;/groupId&gt; &lt;artifactId&gt;lucene-highlighter&lt;/artifactId&gt; &lt;/dependency&gt; </code></pre> <p>It might work. Can someone help me out in adding a lucene-community project to my pom.xml file?</p> <p>Thanks for the comments, it turns out that adding the version was all I needed, and I just guessed it should match the lucene-core version I was using.:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.apache.lucene&lt;/groupId&gt; &lt;artifactId&gt;lucene-highlighter&lt;/artifactId&gt; &lt;version&gt;2.3.1&lt;/version&gt; &lt;/dependency&gt; </code></pre>
[ { "answer_id": 168990, "author": "Sam Merrell", "author_id": 782, "author_profile": "https://Stackoverflow.com/users/782", "pm_score": 1, "selected": false, "text": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schema...
2008/10/03
[ "https://Stackoverflow.com/questions/168961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459/" ]
168,963
<p>I have the following code making a GET request on a URL:</p> <pre><code>$('#searchButton').click(function() { $('#inquiry').load('/portal/?f=searchBilling&amp;pid=' + $('#query').val()); }); </code></pre> <p>But the returned result is not always reflected. For example, I made a change in the response that spit out a stack trace but the stack trace did not appear when I clicked on the search button. I looked at the underlying PHP code that controls the ajax response and it had the correct code and visiting the page directly showed the correct result but the output returned by .load was old.</p> <p>If I close the browser and reopen it it works once and then starts to return the stale information. Can I control this by jQuery or do I need to have my PHP script output headers to control caching?</p>
[ { "answer_id": 168972, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 5, "selected": false, "text": "$('#inquiry').load('/portal/?f=searchBilling&pid=' + $('#query').val()+'&uid='+uniqueId());\n" }, { "answer_id": ...
2008/10/03
[ "https://Stackoverflow.com/questions/168963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/204/" ]
168,979
<p>In C++, static library A is linked into dynamic libraries B and C. If a class, Foo, is used in A which is defined in B, will C link if it doesn't use Foo?</p> <p>I thought the answer was yes, but I am now running into a problem with xlc_r7 where library C says Foo is an undefined symbol, which it is as far as C is concerned. My problem with that is Library C isn't using the class referencing it. This links in Win32 (VC6) and OpenVMS.</p> <p>Is this a linker discrepancy or a PBCAK?</p> <p><strong>New info:</strong> </p> <ol> <li><p>B depends on C, but not visa-versa.</p></li> <li><p>I'm not using /OPT:REF to link on Windows and it links without issue. </p></li> </ol>
[ { "answer_id": 170163, "author": "xtofl", "author_id": 6610, "author_profile": "https://Stackoverflow.com/users/6610", "pm_score": 0, "selected": false, "text": "__declspec( dllexport )" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/168979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24638/" ]
168,991
<p>I'd like to be able to (effectively) sort a database view - I know that conceptually order in a db view is invalid, but I have the following scenario to deal with:</p> <ul> <li>a third-party legacy application, that reads data from database tables using a select(*) from tablename statement</li> <li>the legacy application is very sensitive to the order of the records</li> <li>an application I've written to allow users to manage the data in the tables more easily, but inserts and deletes from the table naturally upset the order of the records.</li> </ul> <p>Changing the statement in the legacy application to select (*) from tablename order by field would fix my problem, but isn't an option.</p> <p>So - I've set up a staging table into which the data can be exported in the right order, but this is a resource-hungry option, means that the data isn't 'live' in the legacy application and is additional work for users.</p> <p>I'd like to be able to get at an ordered version of the table with these contraints. Any ideas how?</p> <hr> <p>Update - I'm working with Sybase 12.5, but I'd like to avoid a tightly coupled solution with a specific RDBMS - it might change.</p> <p>I cannot add an 'order by' clause to a view, because of SQL standards as referred to in <a href="http://en.wikipedia.org/wiki/View_(database)" rel="nofollow noreferrer">this Wikipedia entry</a></p>
[ { "answer_id": 168995, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 1, "selected": false, "text": "CREATE VIEW OrderedTable\nAS SELECT TOP (Select Count(*) from UnorderedTable) *\nFROM UnorderedTable Order By field\n" ...
2008/10/03
[ "https://Stackoverflow.com/questions/168991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2362/" ]
168,992
<p>I'm trying to display a series of titles varying from 60 characters to 160 or so and the capitalization varies, some of it all caps, some half caps. When it's mostly lowercase the whole 160 characters of text fits in the width I want, but when it starts getting more caps (they must be wider), it starts over flowing.</p> <p>Is there a way to use an attractive fixed witdh font (upper and lowercase widths the same too), or dynamically shrink the text to fit, or otherwise recognize how much space the text is going to take on the server side, and cut off the end dynamically? Or do you folks have a better solution?</p>
[ { "answer_id": 168997, "author": "Zebra North", "author_id": 17440, "author_profile": "https://Stackoverflow.com/users/17440", "pm_score": 1, "selected": false, "text": "style=\"width: Xpx; overflow: hidden;\"" }, { "answer_id": 169000, "author": "David Heggie", "author_i...
2008/10/03
[ "https://Stackoverflow.com/questions/168992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13009/" ]
169,008
<p>I'm trying to write a regex that will parse out the <strong>directory and filename</strong> of a fully qualified path using matching groups.</p> <p>so...</p> <pre><code>/var/log/xyz/10032008.log </code></pre> <p>would recognize <code>group 1 to be "/var/log/xyz"</code> and <code>group 2 to be "10032008.log"</code></p> <p>Seems simple but I can't get the matching groups to work for the life of me.</p> <p>NOTE: As pointed out by some of the respondents this is probably not a good use of regular expressions. Generally I'd prefer to use the file API of the language I was using. What I'm actually trying to do is a little more complicated than this but would have been much more difficult to explain, so I chose a domain that everyone would be familiar with in order to most succinctly describe the root problem.</p>
[ { "answer_id": 169014, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 3, "selected": false, "text": "^(.*)/([^/]*)$\n" }, { "answer_id": 169021, "author": "Paige Ruten", "author_id": 813, "author_profile": "h...
2008/10/03
[ "https://Stackoverflow.com/questions/169008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1247/" ]
169,034
<p>Every time I call this method my NSMutableData is leaking and I cannot figure out how to plug it. theData's retain count is upped by one after the decoder is allocated and initialized and I have no idea why. I am stuck with a retain count of 2 at the end of the method and attempting to release it causes an app crash.</p> <pre><code>- (void)readVenueArchiveFile:(NSString *)inFile key:(NSString *)inKey { NSMutableData *theData; NSKeyedUnarchiver *decoder; theData = [NSData dataWithContentsOfFile:inFile]; decoder = [[NSKeyedUnarchiver alloc] initForReadingWithData:theData]; venueIOList = [[decoder decodeObjectForKey:inKey] mutableCopy]; [decoder finishDecoding]; [decoder release]; } </code></pre>
[ { "answer_id": 169247, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 2, "selected": false, "text": "venueIOList" }, { "answer_id": 169709, "author": "mmalc", "author_id": 23233, "author_profile": "http...
2008/10/03
[ "https://Stackoverflow.com/questions/169034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25004/" ]
169,044
<p>My development environment is running in JDK1.6, and I need to compile some classes so they are compatible with a client running JDK1.5. How would I do this with the 'javac' ant target?</p>
[ { "answer_id": 169055, "author": "Tom Feiner", "author_id": 13523, "author_profile": "https://Stackoverflow.com/users/13523", "pm_score": 2, "selected": false, "text": "< javac srcdir=\"${src} destdir=\"${build}\" target=\"1.5\" />" }, { "answer_id": 169065, "author": "Darron...
2008/10/03
[ "https://Stackoverflow.com/questions/169044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
169,058
<p>I've got a Win32 C++ app with a suite of unit tests. After the unit tests have finished running, I'd like a human-readable report on any unfreed memory to be automatically generated. Ideally, the report will have a stack with files &amp; line number info for each unfreed allocation. It would be nice to have them generated in a consistent order to make it easy to diff it from one run to the next. (Basically, I would like the results of valgrind --leak-check=full, but on windows). </p> <p>I've had success with UMDH getting this kind of info from running processes, but that tool only seems to work if you attach to an existing process. I want this to happen automatically every time I run my unit tests.</p> <p>Is there a tool that can do this? If so, how do I use it? </p> <p>Thanks!</p>
[ { "answer_id": 169088, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 1, "selected": false, "text": "_CrtSetReportMode\n_CrtSetReportFile\n_CrtMemState \n_CrtMemCheckpoint\n_CrtMemDumpStatistics\n_CrtSetReportFile\n...
2008/10/03
[ "https://Stackoverflow.com/questions/169058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23524/" ]
169,070
<p>How do I write a decorator that restores the current working directory to what it was before the decorated function was called? In other words, if I use the decorator on a function that does an <code>os.chdir()</code>, the cwd will not be changed after the function is called.</p>
[ { "answer_id": 169079, "author": "Daryl Spitzer", "author_id": 4766, "author_profile": "https://Stackoverflow.com/users/4766", "pm_score": 2, "selected": false, "text": "def preserve_cwd(function):\n def decorator(*args, **kwargs):\n cwd = os.getcwd()\n result = function(*arg...
2008/10/03
[ "https://Stackoverflow.com/questions/169070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766/" ]
169,080
<p>I'd like to be able to toggle easily between two values for "maximum number of parallel project builds" in Visual Studio 2008 (in Tools->Options->Projects and Solutions->Build and Run). (When I'm planning on doing concurrent work I'd like to reduce it from 4 to 3.) I'm not too well versed in writing macros for the IDE. When I try recording a macro, and perform all the actions (open the dialog, change the setting, click OK), the only thing that gets recorded is this:</p> <pre><code>DTE.ExecuteCommand ("Tools.Options") </code></pre> <p>Is my goal unattainable?</p>
[ { "answer_id": 169093, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 3, "selected": true, "text": "Dim p = DTE.Properties(\"ProjectsAndSolutions\",\"BuildAndRun\")\np.Item(\"MaxNumParallelBuilds\")\n" }, { "answe...
2008/10/03
[ "https://Stackoverflow.com/questions/169080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4790/" ]
169,107
<p>I'm in a situation where I would to generate a script for a database that I could run on another server and get a database identical to the original one, but without any of the data. In essence, I want to end up with a big create script that captures the database schema. </p> <p>I am working in an environment that has SQL Server 2000 installed, and I am unable to install the 2005 client tools (in the event that they would help). I can't afford RedGate, but I really would like to have a database with identical schema on another server.</p> <p>Any suggestions? Any simple .exe (no installation required) tools, tips, or T-SQL tricks would be much appreciated.</p> <p><strong>Update:</strong> The database I'm working with has 200+ tables and several foreign-key relationships and constraints, so manually scripting each table and pasting together the script is not a viable option. I'm looking for something better than this manual solution</p> <p><strong>Additional Update</strong> Unless I'm completely missing something, this is not a viable solution using the SQL 2000 tools. When I select the option to generate a create script on a database. I end up with a script that contains a CREATE DATABASE command, and creates none of the objects - the tables, the constraints, etc. SQL 2005's Management studio may handle the objects as well, but the database is in an environment where there is no way for me to connect an installation of Management Studio to it.</p>
[ { "answer_id": 169135, "author": "BoltBait", "author_id": 20848, "author_profile": "https://Stackoverflow.com/users/20848", "pm_score": 5, "selected": true, "text": "Script Database as > Create to > file" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/169107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19452/" ]
169,116
<p>I have a type (System.Type) of an enum and a string containing enumeration value to set.</p> <p>E.g. given: </p> <pre><code>enum MyEnum { A, B, C }; </code></pre> <p>I have typeof(MyEnum) and "B".</p> <p>How do I create MyEnum object set to MyEnum.B?</p>
[ { "answer_id": 169120, "author": "Yuval", "author_id": 23202, "author_profile": "https://Stackoverflow.com/users/23202", "pm_score": 4, "selected": false, "text": "MyEnum enumValue = (MyEnum)Enum.Parse(typeof(MyEnum), \"B\");\n" }, { "answer_id": 169181, "author": "Pavel Chuc...
2008/10/03
[ "https://Stackoverflow.com/questions/169116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
169,121
<p>When I try to bind port 80 to a socket in c, i always get the error, that I don't have permission to use this port. is there an easy way to get this permission?</p>
[ { "answer_id": 169147, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 3, "selected": false, "text": "winsock" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/169121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25017/" ]
169,146
<p>I'm getting an unexpected T_CONCAT_EQUAL error on a line of the following form:</p> <pre><code>$arg1 .= "arg2".$arg3."arg4"; </code></pre> <p>I'm using PHP5. I could simply go an do the following:</p> <pre><code>$arg1 = $arg1."arg2".$arg3."arg4"; </code></pre> <p>but I'd like to know whats going wrong in the first place. Any ideas?</p> <p>Thanks, sweeney</p>
[ { "answer_id": 169187, "author": "Brian Sweeney", "author_id": 2170994, "author_profile": "https://Stackoverflow.com/users/2170994", "pm_score": 1, "selected": false, "text": "$arg1 .= \"arg2\".$arg3.\"arg4\";\n" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/169146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2170994/" ]
169,150
<p>How can I configure an application, or even an entire machine, to use either the server or workstation flavor of the CLR's garbage collection? </p>
[ { "answer_id": 260139, "author": "Justin R.", "author_id": 4593, "author_profile": "https://Stackoverflow.com/users/4593", "pm_score": 0, "selected": false, "text": "GCSettings.LatencyMode" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/169150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4593/" ]
169,155
<p>I am using SetCursor to set the system cursor to my own image. The code looks something like this:</p> <pre><code>// member on some class HCURSOR _cursor; // at init time _cursor = LoadCursorFromFile("somefilename.cur"); // in some function SetCursor(_cursor); </code></pre> <p>When I do this the cursor does change, but on the first mouse move message it changes back to the default system arrow cursor. This is the only code in the project that is setting the cursor. What do I need to do to make the cursor stay the way I set it?</p>
[ { "answer_id": 169280, "author": "Joe Ludwig", "author_id": 1031, "author_profile": "https://Stackoverflow.com/users/1031", "pm_score": 4, "selected": true, "text": "WM_SETCURSOR" }, { "answer_id": 1592563, "author": "Heinz Traub", "author_id": 192841, "author_profile...
2008/10/03
[ "https://Stackoverflow.com/questions/169155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1031/" ]
169,170
<p>I am looking for a way to do a keep alive check in .NET. The scenario is for both UDP and TCP.</p> <p>Currently in TCP what I do is that one side connects and when there is no data to send it sends a keep alive every X seconds.</p> <p>I want the other side to check for data, and if non was received in X seconds, to raise an event or so.</p> <p>One way i tried to do was do a blocking receive and set the socket's RecieveTimeout to X seconds. But the problem was whenever the Timeout happened, the socket's Receive would throw an SocketExeception and the socket on this side would close, is this the correct behaviour ? why does the socket close/die after the timeout instead of just going on ?</p> <p>A check if there is data and sleep isn't acceptable (since I might be lagging on receiving data while sleeping).</p> <p>So what is the best way to go about this, and why is the method i described on the other side failing ?</p>
[ { "answer_id": 171344, "author": "Greg Dean", "author_id": 1200558, "author_profile": "https://Stackoverflow.com/users/1200558", "pm_score": 4, "selected": false, "text": " public static void SetTcpKeepAlive(Socket socket, uint keepaliveTime, uint keepaliveInterval)\n {\n /*...
2008/10/03
[ "https://Stackoverflow.com/questions/169170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
169,186
<p>I am having a very hard time finding a standard pattern / best practice that deals with rendering child controls inside a composite based on a property value.</p> <p>Here is a basic scenario. I have a Composite Control that has two child controls, a textbox and a dropdown. Lets say there is a property that toggles which child to render.</p> <p>so:</p> <pre><code>myComposite.ShowDropdown = true; </code></pre> <p>If true, it shows a dropdown, otherwise it shows the textbox.</p> <p>The property value should be saved across postbacks, and the the correct control should be displayed based on the postback value. </p> <p>Any good examples out there?</p>
[ { "answer_id": 169205, "author": "ckramer", "author_id": 20504, "author_profile": "https://Stackoverflow.com/users/20504", "pm_score": 0, "selected": false, "text": "public bool ShowDropDown\n{\n get{ return (bool)ViewState[\"ShowDropDown\"]; }\n set{ ViewState[\"ShowDropDown\"]; }...
2008/10/03
[ "https://Stackoverflow.com/questions/169186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25020/" ]
169,193
<p>There is a way to keep the scroll on bottom for a multi line textbox?</p> <p>Something like in the vb6 </p> <pre><code>txtfoo.selstart=len(txtfoo.text) </code></pre> <p>I'm trying with txtfoo.selectionstart=txtfoo.text.length without success.</p> <p>Regards.</p>
[ { "answer_id": 169210, "author": "MazarD", "author_id": 22672, "author_profile": "https://Stackoverflow.com/users/22672", "pm_score": 4, "selected": true, "text": "txtfoo.AppendText \n" }, { "answer_id": 169219, "author": "Matthew Scharley", "author_id": 15537, "autho...
2008/10/03
[ "https://Stackoverflow.com/questions/169193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22672/" ]
169,201
<p>In ActionScript 3.0, is there an automatic way to calculate the number of days, hours, minutes and seconds between two specified dates?</p> <p>Basicly, what I need is the ActionScript equivalent of the .NET Timespan class.</p> <p>Any idea?</p>
[ { "answer_id": 169218, "author": "Russell Myers", "author_id": 18194, "author_profile": "https://Stackoverflow.com/users/18194", "pm_score": 4, "selected": false, "text": "var someDate:Date = new Date(...);\nvar anotherDate:Date = new Date(...);\nvar millisecondDifference:int = anotherDa...
2008/10/03
[ "https://Stackoverflow.com/questions/169201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
169,216
<p>As kind of a follow up to <a href="https://stackoverflow.com/questions/111605/what-kind-of-prefix-do-you-use-for-member-variables">this question about prefixes</a>, I agree with most people on the thread that prefixes are bad. But what about if you are using getters and setters? Then you need to differeniate the publicly accessible getter name from the privately stored variable. I normally just use an underscore, but is there a better way?</p>
[ { "answer_id": 169238, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 1, "selected": false, "text": "private int myValue;\n\npublic int MyValue\n{\n get { return myValue; }\n}\n" }, { "answer_id": 169243, ...
2008/10/03
[ "https://Stackoverflow.com/questions/169216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11911/" ]
169,217
<p>In SQL Server you can use the <code>IsNull()</code> function to check if a value is null, and if it is, return another value. Now I am wondering if there is anything similar in C#.</p> <p>For example, I want to do something like:</p> <pre><code>myNewValue = IsNull(myValue, new MyValue()); </code></pre> <p>instead of:</p> <pre><code>if (myValue == null) myValue = new MyValue(); myNewValue = myValue; </code></pre> <p>Thanks.</p>
[ { "answer_id": 169226, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 9, "selected": true, "text": "??" }, { "answer_id": 169415, "author": "Robert Rossney", "author_id": 19403, "author_profile": "ht...
2008/10/03
[ "https://Stackoverflow.com/questions/169217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11989/" ]
169,220
<p>I'm used to writing classes like this:</p> <pre><code>public class foo { private string mBar = "bar"; public string Bar { get { return mBar; } set { mBar = value; } } //... other methods, no constructor ... } </code></pre> <p>Converting Bar to an auto-property seems convenient and concise, but how can I retain the initialization without adding a constructor and putting the initialization in there?</p> <pre><code>public class foo2theRevengeOfFoo { //private string mBar = "bar"; public string Bar { get; set; } //... other methods, no constructor ... //behavior has changed. } </code></pre> <p>You could see that adding a constructor isn't inline with the effort savings I'm supposed to be getting from auto-properties.</p> <p>Something like this would make more sense to me:</p> <pre><code>public string Bar { get; set; } = "bar"; </code></pre>
[ { "answer_id": 169232, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 2, "selected": false, "text": "public foo() {\n Bar = \"bar\";\n}\n" }, { "answer_id": 169237, "author": "Aaron Powell", "aut...
2008/10/03
[ "https://Stackoverflow.com/questions/169220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459/" ]
169,233
<p><a href="http://thedailywtf.com/Articles/The-Hot-Room.aspx" rel="noreferrer">http://thedailywtf.com/Articles/The-Hot-Room.aspx</a></p> <p>You see how at the bottom there're links to the next and previous articles ("Unprepared For Divide_By_Zero" and "A Completely Different Game")? How do I do that, but selecting the next and previous non-private articles? This works for selecting the next article:</p> <pre><code>SELECT * FROM articles WHERE id &gt; ? AND private IS NULL </code></pre> <p>But I cannot find a way to select the previous article.</p> <p>What is the proper/efficient way to do this, preferably in one query?</p>
[ { "answer_id": 169270, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": false, "text": "-- next\nSELECT * FROM articles WHERE id > ? AND private IS NULL ORDER BY id ASC LIMIT 1\n\n-- previous\nSELECT * FROM art...
2008/10/03
[ "https://Stackoverflow.com/questions/169233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23107/" ]
169,240
<p>I have two databases with the same structure. The tables have an integer as a primary key as used in Rails.</p> <p>If I have a patients table, I will have one patient using primary key 123 in one database and another patient using the same primary key in the other database.</p> <p>What would you suggest for merging the data from both databases?</p>
[ { "answer_id": 169606, "author": "user6325", "author_id": 6325, "author_profile": "https://Stackoverflow.com/users/6325", "pm_score": 3, "selected": false, "text": "def self.up\n ActiveRecord::Base.establish_connection :development\n patients = Patient.find(:all)\n ActiveRecord::Base....
2008/10/03
[ "https://Stackoverflow.com/questions/169240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14755/" ]
169,276
<p>After maintaining lots of code littered with #region (in both C# and VB.NET), it seems to me that this construct is just a bunch of "make work" for the programmer. It's work to PUT the dang things into the code, and then they make searching and reading code very annoying.</p> <p>What are the benefits? Why do coders go to the extra trouble to put this in their code.</p> <p>Make me a believer!</p>
[ { "answer_id": 169471, "author": "johnc", "author_id": 5302, "author_profile": "https://Stackoverflow.com/users/5302", "pm_score": 3, "selected": false, "text": "#region Properties\n\n#region Update Section\n\n#region Accessors\n" }, { "answer_id": 287371, "author": "Jeff", ...
2008/10/03
[ "https://Stackoverflow.com/questions/169276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814/" ]
169,277
<p>Is there a Generics Friendly way of using Collection.EMPTY_LIST in my Java Program.</p> <p>I know I could just declare one myself, but I'm just curious to know if there's a way in the JDK to do this.</p> <p>Something like <code>users = Collections&lt;User&gt;.EMPTY_LIST;</code></p>
[ { "answer_id": 169286, "author": "Ryan Delucchi", "author_id": 9931, "author_profile": "https://Stackoverflow.com/users/9931", "pm_score": 6, "selected": true, "text": "List<User> users = Collections.emptyList();\n" }, { "answer_id": 169290, "author": "Steve Kuo", "author...
2008/10/03
[ "https://Stackoverflow.com/questions/169277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
169,278
<p>How do I get modrewrite to ENTIRELY ignore the /vip/ directory so that all requests pass directly to the folder?</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^vip/.$ - [PT] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] &lt;/IfModule&gt; </code></pre> <p>See also <a href="https://stackoverflow.com/questions/163302/how-do-i-ignore-a-directory-in-modrewrite">How do I ignore a directory in mod_rewrite?</a> -- reposting because I wasn't sufficiently clear about the problem first time around. </p>
[ { "answer_id": 169347, "author": "ceejayoz", "author_id": 1902010, "author_profile": "https://Stackoverflow.com/users/1902010", "pm_score": 1, "selected": false, "text": "RewriteRule ^vip/.$ - [PT]\n" }, { "answer_id": 11918202, "author": "aron.duby", "author_id": 518064,...
2008/10/03
[ "https://Stackoverflow.com/questions/169278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24557/" ]
169,287
<p>Does anyone have a good resource on dlls and how they are used / generated in Visual Studio? A few questions I'm rather hazy on specifically are:</p> <ul> <li>How refresh files work</li> <li>How dll version numbers are generated</li> <li>The difference between adding a reference by project vs browsing for the specific dll</li> </ul> <p>Any other tips are welcome as well.</p>
[ { "answer_id": 169314, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 3, "selected": false, "text": "[assembly: AssemblyFileVersion(\"1.0.0.0\")]\n" }, { "answer_id": 169668, "author": "Kev", "author_id": 4...
2008/10/03
[ "https://Stackoverflow.com/questions/169287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
169,293
<p>I'm looking for a make utility for building large java programs. I'm aware of ANT already, but want to see what else is available.</p> <p>Ideally, it should be able to handle the .java->.class package directory weirdness that fouls up GNU Make.</p> <p>Win32, but cross platform is a plus.</p> <p><strong>EDIT:</strong> I see some cons to using ANT, which is why I wanted to see other options, though I'll probably end up using it anyway, just because it works.</p> <ul> <li>requires nontrivial XML makefiles, "HelloWorld" is already 25 lines, and any more reasonable program gets large quickly. <ul> <li>The ant tutorials show comparisons of ant build.xml files that are roughly identical to big .bat files that just run all the java commands, only longer. <a href="http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html" rel="noreferrer">http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html</a>, I've already got one of those.</li> <li>Xml means that every single dependency, variable, target, rule and project has extra cruft on it, it just makes lines hard to read. <a href="http://www.codinghorror.com/blog/archives/001114.html" rel="noreferrer">The Angle Bracket Tax</a></li> </ul></li> <li>solves all the wrong problems for me. <ul> <li>ant makes writing jar and javac command lines easier, generating manifests easier, specifying .java source files easier, specifying jvm/java properties easier, writing custom build tools easier.</li> <li>ant does not make java class dependencies easier, and does not seem to have a more powerful variable system, both things usually solved by make utilities.</li> </ul></li> </ul> <p>I'd use gnu make, but it can't figure out where the .class file for a .java file with a package declaration is going to end up.</p>
[ { "answer_id": 170060, "author": "oxbow_lakes", "author_id": 16853, "author_profile": "https://Stackoverflow.com/users/16853", "pm_score": 1, "selected": false, "text": "war" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/169293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4777/" ]
169,303
<p>I want to be able to run unstrusted ruby code. I want to be able to pass variables to said untrusted code that it may use. I also want said code to return a result to me. Here is a conceptual example of what I am thinking</p> <pre><code>input = "sweet" output = nil Thread.start { $SAFE = 4 #... untrusted code goes here, it uses the input variable(s) #to calculate some result that it places in the output variable } #parse the output variable as a string. </code></pre> <p>Just to clarify, I am basically using the untrusted code as a function. I want to provide its some inputs, and then allow it to write to the output. That is all I really want, I don't care how it is done, I just want the ability to use untrusted Ruby code as a sort of function. The solution does not have to look anything like the code I wrote above, I am just using it to illustrate what I want.</p> <p>Now, I can currently think of 3 ways to do this:</p> <ol> <li>Use the $SAFE level construct above.</li> <li>whytheluckystiff has a Sandbox plugin for ruby</li> <li>I could run each function in its own virtual machine, using some sort of os virtualization software like vmware or Xen or something.</li> </ol> <p>I am wondering if anyone has any recommendations for running untrusted ruby code in a functional way? What option would you recomend? How would you go about it? Thanks.</p>
[ { "answer_id": 26594052, "author": "fearless_fool", "author_id": 558639, "author_profile": "https://Stackoverflow.com/users/558639", "pm_score": 2, "selected": false, "text": "$SAFE" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/169303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21317/" ]
169,330
<p>Is there a way to get stored procedures from a SQL Server 2005 Express database using C#? I would like to export all of this data in the same manner that you can script it our using SQL Server Management Studio, without having to install the GUI.</p> <p>I've seen some references to do thing via the PowerShell but in the end a C# console app is what I really want.</p> <p><strong><em>To clarify....</em></strong></p> <p>I'd like to script out the stored procedures. The list via the <code>Select * from sys.procedures</code> is helpful, but in the end I need to script out each of these.</p>
[ { "answer_id": 169339, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 2, "selected": false, "text": "select * from sys.procedures\n" }, { "answer_id": 169340, "author": "Brian Kim", "author_id": 5704, ...
2008/10/03
[ "https://Stackoverflow.com/questions/169330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5678/" ]
169,332
<p>I want to use a timer in my simple <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="nofollow noreferrer">.NET</a> application written in C#. The only one I can find is the Windows.Forms.Timer class. I don't want to reference this namespace just for my console application. </p> <p>Is there a C# timer (or timer like) class for use in console applications?</p>
[ { "answer_id": 169337, "author": "Eric Schoonover", "author_id": 3957, "author_profile": "https://Stackoverflow.com/users/3957", "pm_score": 4, "selected": false, "text": "Timer" }, { "answer_id": 3381560, "author": "Sucharit", "author_id": 407871, "author_profile": "...
2008/10/03
[ "https://Stackoverflow.com/questions/169332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
169,342
<p>I have a solution that contains two projects. One project is an ASP.NET Web Application Project, and one is a class library. The web application has a project reference to the class library. Neither of these is strongly-named.</p> <p>In the class library, which I'll call &quot;Framework,&quot; I have an endpoint behavior (an IEndpointBehavior implementation) and a configuration element (a class derived from BehaviorExtensionsElement). The configuration element is so I can attach the endpoint behavior to a service via configuration.</p> <p>In the web application, I have an AJAX-enabled WCF service. In web.config, I have the AJAX service configured to use my custom behavior. The system.serviceModel section of the configuration is pretty standard and looks like this:</p> <pre><code>&lt;system.serviceModel&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name=&quot;MyEndpointBehavior&quot;&gt; &lt;enableWebScript /&gt; &lt;customEndpointBehavior /&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled=&quot;true&quot; /&gt; &lt;services&gt; &lt;service name=&quot;WebSite.AjaxService&quot;&gt; &lt;endpoint address=&quot;&quot; behaviorConfiguration=&quot;MyEndpointBehavior&quot; binding=&quot;webHttpBinding&quot; contract=&quot;WebSite.AjaxService&quot; /&gt; &lt;/service&gt; &lt;/services&gt; &lt;extensions&gt; &lt;behaviorExtensions&gt; &lt;add name=&quot;customEndpointBehavior&quot; type=&quot;Framework.MyBehaviorExtensionsElement, Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&quot;/&gt; &lt;/behaviorExtensions&gt; &lt;/extensions&gt; &lt;/system.serviceModel&gt; </code></pre> <p>At runtime, this works perfectly. The AJAX enabled WCF service correctly uses my custom configured endpoint behavior.</p> <p>The problem is when I try to add a new AJAX WCF service. If I do Add -&gt; New Item... and select &quot;AJAX-enabled WCF Service,&quot; I can watch it add the .svc file and codebehind, but when it gets to updating the web.config file, I get this error:</p> <blockquote> <p>The configuration file is not a valid configuration file for WCF Service Library.</p> <p>The type 'Framework.MyBehaviorExtensionsElement, Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'customEndpointBehavior' could not be loaded.</p> </blockquote> <p>Obviously the configuration is entirely valid since it works perfectly at runtime. If I remove the element from my behavior configuration temporarily and then add the AJAX-enabled WCF Service, everything goes without a hitch.</p> <p>Unfortunately, in a larger project where we will have multiple services with various configurations, removing all of the custom behaviors temporarily is going to be error prone. While I realize I could go without using the wizard and do everything manually, not everyone can, and it'd be nice to be able to just use the product as it was meant to be used - wizards and all.</p> <p><strong>Why isn't my custom WCF behavior extension element type being found?</strong></p> <p>Updates/clarifications:</p> <ul> <li>It does work at runtime, just not design time.</li> <li>The Framework assembly is in the web project's bin folder when I attempt to add the service.</li> <li>While I could add services manually (&quot;without configuration&quot;), I need the out-of-the-box item template to work - that's the whole goal of the question.</li> <li>This issue is being seen in Visual Studio 2008. <strong>In VS 2010 this appears to be resolved.</strong></li> </ul> <p><a href="https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=386511" rel="noreferrer">I filed this issue on Microsoft Connect</a> and it turns out you either have to put your custom configuration element in the GAC or put it in the IDE folder. They won't be fixing it, at least for now. I've posted the workaround they provided as the &quot;answer&quot; to this question.</p>
[ { "answer_id": 3332155, "author": "cdmdotnet", "author_id": 178840, "author_profile": "https://Stackoverflow.com/users/178840", "pm_score": 3, "selected": false, "text": "<system.serviceModel>\n <extensions>\n <behaviorExtensions>\n <add name=\"clientCredential\" typ...
2008/10/03
[ "https://Stackoverflow.com/questions/169342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8116/" ]
169,355
<p>Would anyone know why MSVC++ 2008 always returns error 5 on GetLastError() when I try to call OpenProcess with PROCESS_ALL_ACCESS as my desired access? PROCESS_VM_READ works just fine. I'm an administrator on this computer and it is working fine in Dev C++.</p> <p>Do I need to set an option somewhere?</p>
[ { "answer_id": 169394, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 2, "selected": false, "text": "DELETE" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/169355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
169,362
<p>I would like to compress a folder and all its sub-folders/files, and email the zip file as an attachment. What would be the best way to achieve this with Python? </p>
[ { "answer_id": 169406, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 5, "selected": true, "text": "homework" } ]
2008/10/03
[ "https://Stackoverflow.com/questions/169362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
169,377
<p>As a hobby I'm interesting in programming an Ethernet-connected LED sign to scroll messages across a screen. But I'm having trouble making a UDP sender in <a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET" rel="nofollow noreferrer">VB.NET</a> (I am using 2008 currently).</p> <p>Now the sign is nice enough to have <a href="http://support.favotech.com/protocol.specs.2.4.jetfile.pdf" rel="nofollow noreferrer">a specifications sheet on programming for it</a>.</p> <p>But an example of a line to send to it (page 3):</p> <pre><code>&lt;0x01&gt;Z30&lt;0x02&gt;AA&lt;0x06&gt;&lt;0x1B&gt;0b&lt;0x1C&gt;1&lt;0x1A&gt;1This message will show up on the screen&lt;0x04&gt; </code></pre> <p>With codes such as &lt;0x01> representing the hex character.</p> <p>Now, to send this to the sign I need to use <a href="http://en.wikipedia.org/wiki/User_Datagram_Protocol" rel="nofollow noreferrer">UDP</a>. However, the examples I have all encode the message as <a href="http://en.wikipedia.org/wiki/ASCII" rel="nofollow noreferrer">ASCII</a> before sending, like this one (from <em><a href="http://www.java2s.com/Code/VB/Network-Remote/UDPClientsendspacketstoandreceivespacketsfromaserver.htm" rel="nofollow noreferrer">UDP: Client sends packets to, and receives packets from, a server</a></em>):</p> <pre><code>Imports System.Threading Imports System.Net.Sockets Imports System.IO Imports System.Net Public Class MainClass Shared Dim client As UdpClient Shared Dim receivePoint As IPEndPoint Public Shared Sub Main() receivePoint = New IPEndPoint(New IPAddress(0), 0) client = New UdpClient(8888) Dim thread As Thread = New Thread(New ThreadStart(AddressOf WaitForPackets)) thread.Start() Dim packet As String = "client" Console.WriteLine("Sending packet containing: ") ' ' Note the following line below, would appear to be my problem. ' Dim data As Byte() = System.Text.Encoding.ASCII.GetBytes(packet) client.Send(data, data.Length, "localhost", 5000) Console.WriteLine("Packet sent") End Sub Shared Public Sub WaitForPackets() While True Dim data As Byte() = client.Receive(receivePoint) Console.WriteLine("Packet received:" &amp; _ vbCrLf &amp; "Length: " &amp; data.Length &amp; vbCrLf &amp; _ System.Text.Encoding.ASCII.GetString(data)) End While End Sub ' WaitForPackets End Class </code></pre> <p>To output a hexcode in VB.NET, I think the syntax may possibly be &amp;H1A - to send what the specifications would define as &lt;0x1A>.</p> <p>Could I modify that code, to correctly send a correctly formated packet to this sign?</p> <p>The answers from Grant (after sending a packet with hex in it), Hamish Smith (using a function to get hex values), and Hafthor (hardcoded chr() message into example) when attempted all did not work. So I'll research to see what else could go wrong. In theory, if this string is sent successfully, I should have a message containing "OK" back, which will help to know when it works.</p> <p>I have tried and am now able to monitor the packets going through. A working packet example is this (in raw hex): <a href="http://www.brettjamesonline.com/misc/forums/other/working.raw" rel="nofollow noreferrer">http://www.brettjamesonline.com/misc/forums/other/working.raw</a> vs my version: <a href="http://www.brettjamesonline.com/misc/forums/other/failed.raw" rel="nofollow noreferrer">http://www.brettjamesonline.com/misc/forums/other/failed.raw</a>. The difference is my hex codes are still not encoded correctly, seen in this side-by-side image: <a href="http://www.brettjamesonline.com/misc/forums/other/snapshotcoding.png" rel="nofollow noreferrer">http://www.brettjamesonline.com/misc/forums/other/snapshotcoding.png</a>.</p> <p>I have used this code to generate the packet and send it:</p> <pre><code>container = &amp;H1 &amp; "Z" &amp; &amp;H30 &amp; &amp;H2 &amp; "temp.nrg" &amp; &amp;H1C &amp; "1Something" &amp; &amp;H4 ' This did not appear to work neither 'container = Chr(&amp;H1) &amp; "Z" &amp; Chr(&amp;H30) &amp; Chr(&amp;H2) &amp; Chr(&amp;H1C) &amp; "1Something" &amp; Chr(&amp;H4) '&lt;0x01&gt;Z00&lt;0x02&gt;FILENAME&lt;0x1C&gt;1Test to display&lt;0x04&gt; &lt;- the "official" spec to send Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(container) </code></pre> <p>(Full snippet: <a href="http://pastebin.com/f44417743" rel="nofollow noreferrer">http://pastebin.com/f44417743</a>.)</p>
[ { "answer_id": 169422, "author": "Grant", "author_id": 30, "author_profile": "https://Stackoverflow.com/users/30", "pm_score": 0, "selected": false, "text": "Public Function HexFromIP(ByVal sIP As String)\n Dim aIP As String()\n Dim sHexCode As String = \"\"\n aIP = sIP.Split(\"...
2008/10/04
[ "https://Stackoverflow.com/questions/169377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25031/" ]
169,378
<p>ReSharper likes to point out multiple functions per ASP.NET page that could be made static. Does it help me if I do make them static? Should I make them static and move them to a utility class?</p>
[ { "answer_id": 169384, "author": "Eric Schoonover", "author_id": 3957, "author_profile": "https://Stackoverflow.com/users/3957", "pm_score": 3, "selected": false, "text": "this" }, { "answer_id": 169399, "author": "Jeff Yates", "author_id": 23234, "author_profile": "h...
2008/10/04
[ "https://Stackoverflow.com/questions/169378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459/" ]
169,404
<p>In a <a href="https://stackoverflow.com/questions/168408/c-alternatives-to-void-pointers-that-isnt-templates">related question</a> I asked about creating a generic container. Using polymorphic templates seems like the right way to go.</p> <p>However, I can't for the life of me figure out how a destructor should be written. I want the owner of the memory allocated to be the containers even if the example constructor takes in an array of <code>T</code> (along with its dimensions), allocated at some other point.</p> <p>I would like to be able to do something like</p> <pre><code>MyContainer&lt;float&gt; blah(); ... delete blah; </code></pre> <p>and</p> <pre><code>MyContainer&lt;ComplexObjectType*&gt; complexBlah(); ... delete complexBlah;` </code></pre> <p>Can I do something like this? Can I do it without smart pointers?</p> <p>Again, thanks for your input.</p>
[ { "answer_id": 169439, "author": "Scott Langham", "author_id": 11898, "author_profile": "https://Stackoverflow.com/users/11898", "pm_score": 3, "selected": true, "text": "MyContainer<shared_ptr<SomeComplexType> >" }, { "answer_id": 169986, "author": "yrp", "author_id": 72...
2008/10/04
[ "https://Stackoverflow.com/questions/169404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14621/" ]
169,419
<p>I like having my warning level set at W4 but all new projects start at W3. Is there some way to change the default value for warning levels for new projects?</p>
[ { "answer_id": 169434, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 2, "selected": false, "text": "%PROGRAM_FILES%\\Microsoft Visual Studio 9.0\\Common7\\IDE\\ProjectTemplates\\\n" }, { "answer_id": 169489, ...
2008/10/04
[ "https://Stackoverflow.com/questions/169419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3176/" ]
169,420
<p>I've been looking for a generic way to deal with bidirectional associations and a way to handle the inverse updates in manual written Java code.</p> <p>For those who don't know what I'm talking about, here is an example. Below it are my current results of (unsatisfying) solutions.</p> <pre><code>public class A { public B getB(); public void setB(B b); } public class B { public List&lt;A&gt; getAs(); } </code></pre> <p>Now, when updating any end of the association, in order to maintain consistency, the other end must be updated as well. Either manually each time </p> <pre><code>a.setB(b); b.getA().add(a); </code></pre> <p>or by putting matching code in the setter / getter and use a custom List implementation.</p> <p>I've found an outdated, unmaintained project whose dependencies are no longer available (<a href="https://e-nspire-gemini.dev.java.net/" rel="nofollow noreferrer">https://e-nspire-gemini.dev.java.net/</a>). It deals with the problem by using annotations that are used to inject the necessary code automatically.</p> <p>Does anyone know of another framework that deals with this in a generic, unobtrusive way ala gemini?</p> <p>ciao, Elmar</p>
[ { "answer_id": 169758, "author": "Kevin Day", "author_id": 10973, "author_profile": "https://Stackoverflow.com/users/10973", "pm_score": 0, "selected": false, "text": "AssociationBuilder.createAssociation(A a, Connector< A> ca, B b, Connector< B> cb, Synchronizer< A,B> sync)\n" }, {...
2008/10/04
[ "https://Stackoverflow.com/questions/169420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19935/" ]
169,428
<p>this code always returns 0 in PHP 5.2.5 for microseconds:</p> <pre><code>&lt;?php $dt = new DateTime(); echo $dt-&gt;format("Y-m-d\TH:i:s.u") . "\n"; ?&gt; </code></pre> <p>Output:</p> <pre><code>[root@www1 ~]$ php date_test.php 2008-10-03T20:31:26.000000 [root@www1 ~]$ php date_test.php 2008-10-03T20:31:27.000000 [root@www1 ~]$ php date_test.php 2008-10-03T20:31:27.000000 [root@www1 ~]$ php date_test.php 2008-10-03T20:31:28.000000 </code></pre> <p>Any ideas?</p>
[ { "answer_id": 169458, "author": "eydelber", "author_id": 25039, "author_profile": "https://Stackoverflow.com/users/25039", "pm_score": 6, "selected": true, "text": "function getTimestamp()\n{\n return date(\"Y-m-d\\TH:i:s\") . substr((string)microtime(), 1, 8);\n}\n" }, { ...
2008/10/04
[ "https://Stackoverflow.com/questions/169428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25039/" ]
169,435
<p>How can I view the intermediate translation done to JSP and JSPX pages by WTP? I'm getting weird syntax errors in my Problems tab of Eclipse in a project that has plenty of .jspx pages. They don't affect anything in the running application (Tomcat 6.0) and they appeared only over the last 2 weeks, after an update.</p> <p>The reason why I'd like to view the output is that I'm using the Stripes framework at <a href="http://stripesframework.org" rel="nofollow noreferrer">http://stripesframework.org</a> and the errors disappear for a particular .jspx file after I remove the &lt;stripes:errors /&gt; line of that file. At the same time, the syntax errors only appeared after I did recent fresh install of Eclipse at work, but then an update of Eclipse at home shortly therafter. I'd like to see the output to determine whose problem this should be (WTP, Stripes, or maybe just me :).</p> <p>Remember that this issue is somewhat cosmetic, as it doesn't affect anything functionally. It simply spams my Problems tab in Eclipse and shows the little red X icons in the project explorer.</p>
[ { "answer_id": 200594, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<stripes:errors/>" } ]
2008/10/04
[ "https://Stackoverflow.com/questions/169435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/269754/" ]
169,450
<p><em>Information-Expert</em>, <em>Tell-Don't-Ask</em>, and <em>SRP</em> are often mentioned together as best practices. But I think they are at odds. Here is what I'm talking about.</p> <p>Code that favors SRP but violates Tell-Don't-Ask &amp; Info-Expert:</p> <pre><code>Customer bob = ...; // TransferObjectFactory has to use Customer's accessors to do its work, // violates Tell Don't Ask CustomerDTO dto = TransferObjectFactory.createFrom(bob); </code></pre> <p>Code that favors Tell-Don't-Ask &amp; Info-Expert but violates SRP:</p> <pre><code>Customer bob = ...; // Now Customer is doing more than just representing the domain concept of Customer, // violates SRP CustomerDTO dto = bob.toDTO(); </code></pre> <p>Please fill me in on how these practices can co-exist peacefully.</p> <p>Definitions of the terms,</p> <ul> <li><p>Information Expert: objects that have the data needed for an operation should host the operation.</p></li> <li><p>Tell Don't Ask: don't ask objects for data in order to do work; tell the objects to do the work.</p></li> <li><p>Single Responsibility Principle: each object should have a narrowly defined responsibility.</p></li> </ul>
[ { "answer_id": 13421639, "author": "Michael Parker", "author_id": 1554346, "author_profile": "https://Stackoverflow.com/users/1554346", "pm_score": 1, "selected": false, "text": " List<Bill> bills = Customer.GetOutstandingBills();\n PaymentReminder.RemindCustomer(customer, bills);\n" ...
2008/10/04
[ "https://Stackoverflow.com/questions/169450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10759/" ]
169,453
<p>We're running a web app on Tomcat 6 and Apache mod_proxy 2.2.3. Seeing a lot of 502 errors like this:</p> <blockquote> <p>Bad Gateway! The proxy server received an invalid response from an upstream server.</p> <p>The proxy server could not handle the request GET /the/page.do.</p> <p>Reason: Error reading from remote server</p> <p>If you think this is a server error, please contact the webmaster.</p> <p>Error 502 </p> </blockquote> <p>Tomcat has plenty of threads, so it's not thread-constrained. We're pushing 2400 users via JMeter against the app. All the boxes are sitting inside our firewall on a fast unloaded network, so there shouldn't be any network problems. </p> <p>Anyone have any suggestions for things to look at or try? We're heading to tcpdump next.</p> <p>UPDATE 10/21/08: Still haven't figured this out. Seeing only a very small number of these under load. The answers below haven't provided any magical answers...yet. :)</p>
[ { "answer_id": 1287662, "author": "Janning", "author_id": 351758, "author_profile": "https://Stackoverflow.com/users/351758", "pm_score": 4, "selected": false, "text": "SetEnv proxy-nokeepalive 1\nSetEnv proxy-initial-not-pooled 1\n" }, { "answer_id": 1837936, "author": "sibn...
2008/10/04
[ "https://Stackoverflow.com/questions/169453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7671/" ]
169,470
<p>I have a function in which I get en external resource from the web using cocoa's Url object. And it works fine on the simulator, but occasionally fails on the device itself (it's a google query so the resource obviously does exist). Which leads me to believe that there is some internal timeout barrier on the hardware, but haven't read that such a barrier exists or not.</p> <p>Anyone else encountered similar issues? Or knows if the timeout is documented or can be changed?</p>
[ { "answer_id": 173275, "author": "lajos", "author_id": 3740, "author_profile": "https://Stackoverflow.com/users/3740", "pm_score": 1, "selected": false, "text": "+ (id)requestWithURL:(NSURL *)theURL cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval)timeoutI...
2008/10/04
[ "https://Stackoverflow.com/questions/169470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
169,477
<p>I'm trying to implement a server control that frobs a couple of files inside the web directory of an ASP.NET site. I'm using VS Web Dev Express 2008 as my IDE. When I call <code>HttpContext.Current.Request.ApplicationPath</code> to get a path to the web root so I can find those files, it returns C:. What the heck?</p> <p>Absolute paths work just fine, but I'd like to be able to feed the server control a relative directory and just let it do it's thing. What have I done wrong?</p> <pre><code>public String Target { get { return _target; } set { if (value.StartsWith("~")) { // WTF? Gives me C:\? Why? _target = HttpContext.Current.Request.ApplicationPath + value.Substring(1); } else { _target = value; } } } private String _target; protected override void Render(HtmlTextWriter writer) { HtmlControl wrapper = new HtmlGenericControl("div"); int fileCount = 0; try { DirectoryInfo dir = new DirectoryInfo(_target); foreach (FileInfo f in dir.GetFiles()) { fileCount++; a = new HtmlAnchor(); a.Attributes.Add("href", f.FullName); a.InnerHtml = f.Name; wrapper.Controls.Add(a); } } catch (IOException e) { throw e; } Controls.Add(wrapper); base.Render(writer); } </code></pre>
[ { "answer_id": 169490, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": 2, "selected": false, "text": "HTTPContext.Current.Request.ServerVariables(\"APPL_PHYSICAL_PATH\")\n" }, { "answer_id": 169510, "author": "Mark ...
2008/10/04
[ "https://Stackoverflow.com/questions/169477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16398/" ]
169,506
<p>I have a form with many input fields.</p> <p>When I catch the submit form event with jQuery, is it possible to get all the input fields of that form in an associative array?</p>
[ { "answer_id": 169553, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 3, "selected": false, "text": "var items = new Array();\n\n$('#form_id:input').each(function (el) {\n items[el.name] = el;\n});\n" }, { "answer_id...
2008/10/04
[ "https://Stackoverflow.com/questions/169506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7883/" ]
169,511
<p>How do I iterate over a range of numbers in Bash when the range is given by a variable?</p> <p>I know I can do this (called "sequence expression" in the Bash <a href="http://www.gnu.org/software/bash/manual/bashref.html#Brace-Expansion" rel="noreferrer">documentation</a>):</p> <pre><code> for i in {1..5}; do echo $i; done </code></pre> <p>Which gives:</p> <blockquote> <p>1 <br/> 2 <br/> 3 <br/> 4 <br/> 5</p> </blockquote> <p>Yet, how can I replace either of the range endpoints with a variable? This doesn't work:</p> <pre><code>END=5 for i in {1..$END}; do echo $i; done </code></pre> <p>Which prints:</p> <blockquote> <p>{1..5}</p> </blockquote>
[ { "answer_id": 169515, "author": "Peter Hoffmann", "author_id": 720, "author_profile": "https://Stackoverflow.com/users/720", "pm_score": 5, "selected": false, "text": "for i in $(seq $END); do echo $i; done\n" }, { "answer_id": 169517, "author": "Jiaaro", "author_id": 29...
2008/10/04
[ "https://Stackoverflow.com/questions/169511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24923/" ]
169,512
<p>I recently began using <a href="http://www.eclipse.org/birt/phoenix/deploy/" rel="noreferrer">BIRT</a> and have developed a report to use with my <a href="http://developer.mozilla.org/en/XULRunner" rel="noreferrer">xulrunner</a> application. What I haven't yet figured out is how I should deploy the viewer. It seems like BIRT mostly targets Java applications, so there are instructions for deploying on J2EE, JBoss, and other technologies -- with which I am not familiar (but I'm not developing in Java anyway).</p> <p>Reviewing <a href="http://www.onjava.com/pub/a/onjava/2006/07/26/deploying-birt.html" rel="noreferrer">this article</a> on deploying BIRT and reviewing the <a href="http://www.eclipse.org/birt/phoenix/deploy/" rel="noreferrer">deployment details</a> on BIRT's web site, I'm not sure where to go. I wasn't expecting to have to add some large Java dependency for the xulrunner application --is there no way I can drop an executable in with my xulrunner app, call it from my app, and pass it a report document? (Or something else that would be simpler than learning and using J2EE, JBoss, tomcat?)</p>
[ { "answer_id": 27257220, "author": "McCoy", "author_id": 2816092, "author_profile": "https://Stackoverflow.com/users/2816092", "pm_score": 2, "selected": false, "text": "genReport.bat -f PDF -o PATH/GENERATED_REPORTS/REPORT.pdf -F \"PATH/TO/REPORT.rptdesign\"" } ]
2008/10/04
[ "https://Stackoverflow.com/questions/169512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/525/" ]
169,520
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/795746/warning-mysql-fetch-array-supplied-argument-is-not-a-valid-mysql-result">Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result</a> </p> </blockquote> <p>When I run my php page, I get this error and do not know what's wrong, can anyone help? If anyone needs more infomation, I'll post the whole code.</p> <pre>Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in H:\Program Files\EasyPHP 2.0b1\www\test\info.php on line 16</pre> <pre><code>&lt;?PHP $user_name = "root"; $password = ""; $database = "addressbook"; $server = "127.0.0.1"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "SELECT * FROM tb_address_book"; $result = mysql_query($SQL); while ($db_field = mysql_fetch_assoc($result)) { print $db_field['ID'] . "&lt;BR&gt;"; print $db_field['First_Name'] . "&lt;BR&gt;"; print $db_field['Surname'] . "&lt;BR&gt;"; print $db_field['Address'] . "&lt;BR&gt;"; } mysql_close($db_handle); } else { print "Database NOT Found "; mysql_close($db_handle); } ?&gt; </code></pre>
[ { "answer_id": 169527, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<?PHP\n\n $user_name = \"root\";\n $password = \"\";\n $database = \"addressbook\";\n $server = \"127.0.0.1\";\n\n...
2008/10/04
[ "https://Stackoverflow.com/questions/169520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
169,529
<p>So I have a ListView with an upper limit of about 1000 items. I need to be able to filter these items using a textbox's TextChanged event. I have some code that works well for a smaller number of items (~400), but when I need to re-display a full list of all 1000 items, it takes about 4 seconds.</p> <p>I am not creating new ListViewItems every time. Instead, I keep a list of the full item collection and then add from that. It seems that the .Add method is taking a long time regardless. Here is a little sample:</p> <pre><code>this.BeginUpdate(); foreach (ListViewItem item in m_cachedItems) { MyListView.Add(item); } this.EndUpdate; </code></pre> <p>I have tried only adding the missing items (i.e., the difference between the items currently being displayed and the total list of items), but this doesn't work either. There can be a situation in which there is only one item currently displayed, the user clears the textbox, and I need to display the entire list.</p> <p>I am not very experienced in eeking performance out of .NET controls with a large sample like this, so I don't really know a better way to do it. Is there any way around using the .Add() method, or if not, just e better general solution?</p>
[ { "answer_id": 169611, "author": "sieben", "author_id": 1147, "author_profile": "https://Stackoverflow.com/users/1147", "pm_score": 2, "selected": false, "text": "MyListView.AddRange(items)\n" } ]
2008/10/04
[ "https://Stackoverflow.com/questions/169529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1053/" ]
169,555
<p>Greetings,</p> <p>I need to include a property in my class which is a collection of System.IO.FileInfo objects. I am not really sure how to do this and how I would add and removed objects from an instance of the the class (I would assume like any other collection). </p> <p>Please let me know if I need to add more information.</p> <p>Thank you</p> <p>Update: Am I approaching this the wrong way? I have read comments that adding to a collection which is a property is bad practice. If this is true what is good practice? I have a bunch of objects I need to store in a collection. The collection will be added to and removed from before a final action will be taken on it. Is this a correct approach or am I missing something?</p>
[ { "answer_id": 169568, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 1, "selected": false, "text": "File" }, { "answer_id": 169572, "author": "Kibbee", "author_id": 1862, "author_profile": "https://St...
2008/10/04
[ "https://Stackoverflow.com/questions/169555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5836/" ]
169,562
<p>Ok, my actual problem was this: I was implementing an <code>IList&lt;T&gt;</code>. When I got to <code>CopyTo(Array array, int index)</code>, this was my solution:</p> <pre><code>void ICollection.CopyTo(Array array, int index) { // Bounds checking, etc here. if (!(array.GetValue(0) is T)) throw new ArgumentException("Cannot cast to this type of Array."); // Handle copying here. } </code></pre> <p>This worked in my original code, and still works. But it has a small flaw, which wasn't exposed till I started building tests for it, specifically this one:</p> <pre><code>public void CopyToObjectArray() { ICollection coll = (ICollection)_list; string[] testArray = new string[6]; coll.CopyTo(testArray, 2); } </code></pre> <p>Now, this test should pass. It throws the <code>ArgumentException</code> about not being able to cast. Why? <code>array[0] == null</code>. The <code>is</code> keyword always returns false when checking a variable that is set to <code>null</code>. Now, this is handy for all sorts of reasons, including avoiding null dereferences, etc. What I finally came up with for my type checking was this:</p> <pre><code>try { T test = (T)array.GetValue(0); } catch (InvalidCastException ex) { throw new ArgumentException("Cannot cast to this type of Array.", ex); } </code></pre> <p>This isn't exactly elegant, but it works... Is there a better way though?</p>
[ { "answer_id": 169579, "author": "justin.m.chase", "author_id": 12958, "author_profile": "https://Stackoverflow.com/users/12958", "pm_score": 2, "selected": false, "text": "if(!typeof(T).IsAssignableFrom(array.GetElementType()))\n" }, { "answer_id": 169595, "author": "Mark Ci...
2008/10/04
[ "https://Stackoverflow.com/questions/169562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
169,573
<p>I am searching for an open source Java library to generate thumbnails for a given URL. I need to bundle this capability, rather than call out to external services, such as <a href="http://aws.amazon.com/ast/" rel="nofollow noreferrer">Amazon</a> or <a href="http://www.websnapr.com/" rel="nofollow noreferrer">websnapr</a>.</p> <p><a href="http://www.webrenderer.com/" rel="nofollow noreferrer">http://www.webrenderer.com/</a> was mentioned in this post: <a href="https://stackoverflow.com/questions/119116/server-generated-web-screenshots#119264">Server generated web screenshots</a>, but it is a commercial solution.</p> <p>I'm hoping for a Java based solution, but may need to look into executing an external process such as <a href="http://khtml2png.sourceforge.net/index.php?page=faq" rel="nofollow noreferrer">khtml2png</a>, or integrating something like <a href="http://user.it.uu.se/~jan/html2ps.html" rel="nofollow noreferrer">html2ps</a>.</p> <p>Any suggestions?</p>
[ { "answer_id": 170392, "author": "McDowell", "author_id": 304, "author_profile": "https://Stackoverflow.com/users/304", "pm_score": 4, "selected": true, "text": "import java.awt.Component;\nimport java.awt.Graphics2D;\nimport java.awt.image.BufferedImage;\nimport java.io.File;\nimport ja...
2008/10/04
[ "https://Stackoverflow.com/questions/169573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14419/" ]
169,574
<p>Like most *nix people, I tend to play with my tools and get them configured just the way that I like them. This was all well and good until recently. As I do more and more work, I tend to log onto more and more machines, and have more and more stuff that's configured great on my home machine, but not necessarily on my work machine, or my web server, or any of my work servers...</p> <p>How do you keep these config files updated? Do you just manually copy them over? Do you have them stored somewhere public?</p>
[ { "answer_id": 169638, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 1, "selected": false, "text": "sh" }, { "answer_id": 169663, "author": "Pierre Spring", "author_id": 1532, "author_profile": "https:...
2008/10/04
[ "https://Stackoverflow.com/questions/169574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24817/" ]
169,590
<p>I need to fire an event when the mouse is above a PictureBox with the mouse button already clicked and held down.</p> <p>Problems: </p> <p>The MouseDown and MouseEnter event handlers do not work together very well.</p> <p>For instance once a mouse button is clicked and held down, C# will fire the MouseDown event handler, but when the cursor moves over the PictureBox the MouseEnter event does not fire, until the mouse button is realeased.</p>
[ { "answer_id": 169604, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 4, "selected": false, "text": "System.Windows.Control.MousePosition" }, { "answer_id": 169666, "author": "Phil Wright", "author_id": 6...
2008/10/04
[ "https://Stackoverflow.com/questions/169590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/609/" ]
169,596
<p><strong>EDIT:</strong> <em>I'm still waiting for more answers. Thanks!</em></p> <p>In SQL 2000 days, I used to use temp table method where you create a temp table with new identity column and primary key then select where identity column between A and B.</p> <p>When <strong>SQL 2005</strong> came along I found out about <code>Row_Number()</code> and I've been using it ever since...</p> <p>But now, I found a serious performance issue with <code>Row_Number()</code>. It performs very well when you are working with not-so-gigantic result sets and sorting over an identity column. However, <strong>it performs very poorly</strong> when you are working with <strong>large result sets</strong> like over 10,000 records and <strong>sorting it over non-identity column</strong>. <code>Row_Number()</code> performs poorly even if you sort by an identity column if the result set is over 250,000 records. For me, it came to a point where it throws an error, "<strong>command timeout!</strong>"</p> <p><strong>What do you use to do paginate a large result set on SQL 2005?</strong> Is temp table method still better in this case? I'm not sure if this method <a href="https://web.archive.org/web/20211020131201/https://www.4guysfromrolla.com/webtech/042606-1.shtml" rel="noreferrer">using temp table with SET ROWCOUNT</a> will perform better... But some say there is an issue of giving wrong row number if you have multi-column primary key.</p> <p>In my case, I need to be able to sort the result set by a date type column... for my production web app.</p> <p>Let me know what you use for <strong>high-performing pagination in SQL 2005</strong>. And I'd also like to know a smart way of creating indexes. <strong>I'm suspecting choosing right primary keys and/or indexes (clustered/non-clustered) will play a big role here.</strong></p> <p>Thanks in advance.</p> <p>P.S. <strong>Does anyone know what stackoverflow uses?</strong></p> <p><strong>EDIT:</strong> Mine looks something like...</p> <pre><code>SELECT postID, postTitle, postDate FROM (SELECT postID, postTitle, postDate, ROW_NUMBER() OVER(ORDER BY postDate DESC, postID DESC) as RowNum FROM MyTable ) as DerivedMyTable WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1 </code></pre> <p>postID: Int, Identity (auto-increment), Primary key</p> <p>postDate: DateTime</p> <p><strong>EDIT:</strong> Is everyone using Row_Number()?</p>
[ { "answer_id": 169655, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 3, "selected": false, "text": "SELECT column_list\nFROM\n (SELECT column_list\n ROW_NUMBER() OVER(ORDER BY OrderByColumnName) as RowNum\n ...
2008/10/04
[ "https://Stackoverflow.com/questions/169596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5704/" ]
169,610
<p>I'm writing a function that gets the path environment variable of a system, splits up each path, then concats on some other extra characters onto the end of each path.</p> <p>Everything works fine until I use the <code>strcat()</code> function (see code below).</p> <pre><code>char* prependPath( char* exeName ) { char* path = getenv("PATH"); char* pathDeepCopy = (char *)malloc(strlen(path) + 1); char* token[80]; int j, i=0; // used to iterate through array strcpy(pathDeepCopy, path); //parse and split token[0] = strtok(pathDeepCopy, ":"); //get pointer to first token found and store in 0 //place in array while(token[i]!= NULL) { //ensure a pointer was found i++; token[i] = strtok(NULL, ":"); //continue to tokenize the string } for(j = 0; j &lt;= i-1; j++) { strcat(token[j], "/"); //strcat(token[j], exeName); printf("%s\n", token[j]); //print out all of the tokens } } </code></pre> <p>My shell output is like this (I'm concatenating "/which" onto everything):</p> <pre><code>... /usr/local/applic/Maple/bin/which which/which /usr/local/applic/opnet/8.1.A.wdmguru/sys/unix/bin/which which/which Bus error (core dumped) </code></pre> <p>I'm wondering why <code>strcat</code> is displaying a new line and then repeating <code>which/which</code>. I'm also wondering about the <code>Bus error (core dumped)</code> at the end.</p> <p>Has anyone seen this before when using <code>strcat()</code>? And if so, anyone know how to fix it?</p> <p>Thanks</p>
[ { "answer_id": 169615, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "strtok" }, { "answer_id": 169629, "author": "Martin York", "author_id": 14065, "author_profile": "https://...
2008/10/04
[ "https://Stackoverflow.com/questions/169610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
169,624
<p>I was looking into sorting tables by a column designated given some input, and from what I've found, there is no easy way to do this. The best I've found is a switch statement: </p> <pre><code>SELECT Column1, Column2, Column3, Column4 FROM Table ORDER BY CASE WHEN @OrderBY = 'Column1' THEN Column1 WHEN @OrderBY = 'Column2' THEN Column2 WHEN @OrderBY = 'Column3' THEN Column3 WHEN @OrderBY = 'Column4' THEN Column4 </code></pre> <p>Is it possible to do this without having a <code>CASE</code> statement like that? If the table gets bigger and more columns need to be sorted by, this could become messy.</p> <p>The only way I've been able to do this is by just concatenating a big SQL string, which sort of defeats the advantages of Stored Procedures, and makes the SQL hard to write and maintain.</p>
[ { "answer_id": 169632, "author": "Ron Savage", "author_id": 12476, "author_profile": "https://Stackoverflow.com/users/12476", "pm_score": 1, "selected": false, "text": "Select\n *\nFrom\n myTableFUnction()\nOrder by\n 1, 2, 3, 6 <-- defined by application code in the SQL for the ...
2008/10/04
[ "https://Stackoverflow.com/questions/169624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
169,625
<p>I would like users to submit a URL that is valid but also is an image, ending with .jpg, .png, or .gif.</p>
[ { "answer_id": 169631, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 6, "selected": false, "text": "#fragments" }, { "answer_id": 169634, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https...
2008/10/04
[ "https://Stackoverflow.com/questions/169625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
169,637
<p>When I retrieve a record using LINQ that has a DateTime field only the ToString() is available. </p> <p>Where are all the other DateTime methods? </p> <p>I have to Convert.ToDateTime the DateTime? that the Field returns?</p> <p>What is the difference between (DateTime) and (DateTime?)</p>
[ { "answer_id": 169644, "author": "Ryan", "author_id": 17917, "author_profile": "https://Stackoverflow.com/users/17917", "pm_score": 0, "selected": false, "text": "new DateTime()" }, { "answer_id": 169651, "author": "Mark Cidade", "author_id": 1659, "author_profile": "...
2008/10/04
[ "https://Stackoverflow.com/questions/169637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6161/" ]
169,662
<p>Is it possible, in Java, to enforce that a class have a specific set of subclasses and no others? For example:</p> <pre><code>public abstract class A {} public final class B extends A {} public final class C extends A {} public final class D extends A {} </code></pre> <p>Can I somehow enforce that no other subclasses of A can ever be created?</p>
[ { "answer_id": 169671, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": false, "text": "A" }, { "answer_id": 169675, "author": "asterite", "author_id": 20459, "author_profile": "https://St...
2008/10/04
[ "https://Stackoverflow.com/questions/169662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3434/" ]
169,695
<p>What is the best way to persist/save printer settings in .Net? There used to be a bug in .Net 1.1 in the serialization of the <code>PrinterSetting</code> object and there were some <a href="http://www.codeproject.com/KB/cs/printersettings.aspx" rel="nofollow noreferrer">workarounds</a> but I'm wondering if there isn't a better or easier way of doing this in the more recent versions of the framework.</p> <p>The main use case is to allow a user to define, using the standard printer setting user interfaces, all print details (including printer-specific options) for a given printer and have these saved so they get restored the next time the user prints to that printer.</p>
[ { "answer_id": 170030, "author": "Dmitry Shechtman", "author_id": 3583, "author_profile": "https://Stackoverflow.com/users/3583", "pm_score": 1, "selected": false, "text": "PrinterSettings" }, { "answer_id": 33784768, "author": "Marco Guignard", "author_id": 2087090, ...
2008/10/04
[ "https://Stackoverflow.com/questions/169695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3811/" ]
169,713
<p>What made it hard to find? How did you track it down?</p> <p>Not close enough to close but see also<br> <a href="https://stackoverflow.com/questions/175854/what-is-the-funniest-bug-youve-ever-experienced">https://stackoverflow.com/questions/175854/what-is-the-funniest-bug-youve-ever-experienced</a></p>
[ { "answer_id": 169725, "author": "Brian", "author_id": 18192, "author_profile": "https://Stackoverflow.com/users/18192", "pm_score": 1, "selected": false, "text": "XMLEncoder" }, { "answer_id": 171872, "author": "Tal", "author_id": 11287, "author_profile": "https://St...
2008/10/04
[ "https://Stackoverflow.com/questions/169713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10960/" ]
169,721
<p>I keep hearing that Flex is open source and I figured that a great way to learn about the inner workings would be to look at it. I can easily find the Flex SDK (<a href="http://opensource.adobe.com/wiki/display/flexsdk/Get+Source+Code" rel="noreferrer">http://opensource.adobe.com/wiki/display/flexsdk/Get+Source+Code</a>), but I'm wanting to look at the class definitions for the MXML core library (like NumericStepper). Have I misunderstood, or is this kind of thing available somewhere?</p> <p>Note, I'm looking for the source of some core MXML components so I can see how they work internally, not for the compiler's source. Does what I've linked above have what I'm looking for and I just can't find it in the director structure?</p>
[ { "answer_id": 169724, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 1, "selected": false, "text": "http://opensource.adobe.com/wiki/display/flexsdk/Downloads\n" } ]
2008/10/04
[ "https://Stackoverflow.com/questions/169721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9619/" ]
169,731
<p>In Javascript, I have an object:</p> <pre><code>obj = { one: "foo", two: "bar" }; </code></pre> <p>Now, I want do do this</p> <pre><code>var a = 'two'; if(confirm('Do you want One')) { a = 'one'; } alert(obj.a); </code></pre> <p>But of course it doesn't work. What would be the correct way of referencing this object dynamically?</p>
[ { "answer_id": 169737, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 3, "selected": false, "text": "obj[a]\n" }, { "answer_id": 169740, "author": "Javier", "author_id": 11649, "author_profile": "https...
2008/10/04
[ "https://Stackoverflow.com/questions/169731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/144/" ]
169,759
<p>What's the best .NET communication component or protocol for very low bandwidth and intermittently connected communication (i.e.: &lt; 10 kilobits/sec)?</p>
[ { "answer_id": 169763, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 1, "selected": false, "text": "System.Net.Sockets." } ]
2008/10/04
[ "https://Stackoverflow.com/questions/169759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25010/" ]
169,784
<p>I am totally new to <code>SQL</code>. I have a simple select query similar to this:</p> <pre><code>SELECT COUNT(col1) FROM table1 </code></pre> <p>There are some 120 records in the table and shown on the <code>GUI</code>. For some reason, this query always returns a number which is less than the actual count.</p> <p>Can somebody please help me?</p>
[ { "answer_id": 169785, "author": "Blorgbeard", "author_id": 369, "author_profile": "https://Stackoverflow.com/users/369", "pm_score": 4, "selected": false, "text": "select count(*) from table1\n" }, { "answer_id": 169786, "author": "Gulzar Nazim", "author_id": 4337, "...
2008/10/04
[ "https://Stackoverflow.com/questions/169784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25065/" ]
169,799
<p>I'm trying to get into java again (it's been a few years). I never really did any GUI coding in java. I've been using Netbeans to get started with this.</p> <p>When using winforms in C# at work I use a usercontrols to build parts of my UI and add them to forms dynamically. </p> <p>I've been trying to use <code>JPanels</code> like usercontrols in C#. I created a <code>JPanel</code> form called <code>BlurbEditor</code>. This has a few simple controls on it. I am trying to add it to another panel at run time on a button event. </p> <p>Here is the code that I thought would work:</p> <pre><code>mainPanel.add(new BlurbEditor()); mainPanel.revalidate(); //I've also tried all possible combinations of these too //mainPanel.repaint(); //mainPanel.validate(); </code></pre> <p>This unfortunately is not working. What am I doing wrong?</p>
[ { "answer_id": 169805, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": -1, "selected": false, "text": "mainPanel.invalidate()" }, { "answer_id": 169857, "author": "BFreeman", "author_id": 21811, "aut...
2008/10/04
[ "https://Stackoverflow.com/questions/169799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21811/" ]
169,815
<p>In the same spirit of other platforms, it seemed logical to follow up with this question: What are common non-obvious mistakes in Java? Things that seem like they ought to work, but don't.</p> <p>I won't give guidelines as to how to structure answers, or what's "too easy" to be considered a gotcha, since that's what the voting is for.</p> <p>See also:</p> <ul> <li><a href="https://stackoverflow.com/questions/166653/perl-common-gotchas">Perl - Common gotchas</a></li> <li><a href="https://stackoverflow.com/questions/66117/aspnet-common-gotchas">.NET - Common gotchas</a></li> </ul>
[ { "answer_id": 169824, "author": "Alan", "author_id": 17205, "author_profile": "https://Stackoverflow.com/users/17205", "pm_score": 1, "selected": false, "text": "Long" }, { "answer_id": 169853, "author": "David", "author_id": 24731, "author_profile": "https://Stackov...
2008/10/04
[ "https://Stackoverflow.com/questions/169815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17205/" ]
169,817
<p>I'm thinking the answer is no, but I'd love it it anybody had any insight into how to crawl a tree structure to any depth in SQL (MySQL), but with a single query</p> <p>More specifically, given a tree structured table (id, data, data, parent_id), and one row in the table, is it possible to get <em>all</em> descendants (child/grandchild/etc), or for that matter all ancestors (parent/grandparent/etc) without knowing how far down or up it will go, using a single query?</p> <p>Or is using some kind of recursion require, where I keep querying deeper until there are no new results?</p> <p>Specifically, I'm using Ruby and Rails, but I'm guessing that's not very relevant.</p>
[ { "answer_id": 169834, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": -1, "selected": false, "text": "getChildren(parent){\n children = query(SELECT * FROM table WHERE parent_id = parent.id)\n return children\n}\n\nprintT...
2008/10/04
[ "https://Stackoverflow.com/questions/169817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14873/" ]
169,818
<h2>What should happen when I call <code>$user-&gt;get_email_address()</code>?</h2> <h3>Option 1: Pull the email address from the database on demand</h3> <pre><code>public function get_email_address() { if (!$this-&gt;email_address) { $this-&gt;read_from_database('email_address'); } return $this-&gt;email_address; } </code></pre> <h3>Option 2: Pull the email address (and the other User attributes) from the database on object creation</h3> <pre><code>public function __construct(..., $id = 0) { if ($id) { $this-&gt;load_all_data_from_db($id); } } public function get_email_address() { return $this-&gt;email_address; } </code></pre> <p>My basic question is whether it's best to minimize the number of database queries, or whether it's best to minimize the amount of data that gets transferred from the database.</p> <p>Another possibility is that it's best to load the attributes that you'll need the most / contain the least data at object creation and everything else on demand.</p> <p>A follow-up question: What do ORM abstraction frameworks like Activerecord do?</p>
[ { "answer_id": 169923, "author": "Dylan Beattie", "author_id": 5017, "author_profile": "https://Stackoverflow.com/users/5017", "pm_score": 4, "selected": true, "text": "public function get_email_address() {\n if (!$this->email_address) {\n $this->load_all_data_from_db($this->id...
2008/10/04
[ "https://Stackoverflow.com/questions/169818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
169,828
<p>Interested if anyone has used VSTS Database Edition extensively and, if so, which features did you find the most useful over the standard Visual Studio database projects?</p> <p>What are the most compelling features as opposed to alternative schema management options or tools like RedGate's SqlCompare etc?</p> <p><strong>Edit</strong>: Microsoft just released the <b>RTM version of Database Edition (GDR)</b> which adds support for SQL Server 2008 - link is <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&amp;displaylang=en" rel="nofollow noreferrer">here</a>. I've previously blogged (briefly) about it <a href="http://internationalized.spaces.live.com/blog/cns!43F3A7682D1564E4!1177.entry" rel="nofollow noreferrer">here.</a></p> <p>Has anyone had a chance to do any real work with the GDR? It looks like there are some real enhancements including refactoring support. I'd be really interested to hear if people are using it with SQL Server 2008...</p> <p>Download From: [<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&amp;displaylang=en]" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&amp;displaylang=en]</a></p>
[ { "answer_id": 1847699, "author": "Andy", "author_id": 442820, "author_profile": "https://Stackoverflow.com/users/442820", "pm_score": 2, "selected": false, "text": "TaskName=\"DataGeneratorTask\"\nAssemblyName=\"Microsoft.Data.Schema.Tasks, Version=9.1.0.0, Culture=neutral, PublicKeyTok...
2008/10/04
[ "https://Stackoverflow.com/questions/169828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18471/" ]
169,829
<p>INotifyPropertyChanged is fairly self explanatory and I think I'm clear on when to raise that one (i.e. when I've finished updating the values).<br> If I implement INotifyPropertyChanging I'm tending to raise the event as soon as I enter the setter or other method that changes the objects state and then continue with any guards and validations that may occur. </p> <p>So I'm treating the event as a notification that the property may change but hasn't yet been changed, and might not actually finish changing successfully. </p> <p>If consumers of the object are using this property (like let's say LINQ to SQL using the event for change tracking) should I be holding off and only raising the event once I have validated that the the values I've been given are good and the state of the object is valid for the change? </p> <p>What is the contract for this event and what side effects would there be in subscribers?</p>
[ { "answer_id": 169849, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 5, "selected": true, "text": "PropertyChanging" } ]
2008/10/04
[ "https://Stackoverflow.com/questions/169829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15572/" ]
169,833
<p>I've opened a new window with window.open() and I want to use the reference from the window.open() call to then write content to the new window. I've tried copying HTML from the old window to the new window by using myWindow.document.body.innerHTML = oldWindowDiv.innerHTML; but that's doesn't work. Any ideas?</p>
[ { "answer_id": 169840, "author": "Giao", "author_id": 14099, "author_profile": "https://Stackoverflow.com/users/14099", "pm_score": -1, "selected": false, "text": "myWindow.document.writeln(documentString)\n" }, { "answer_id": 169843, "author": "Vijesh VP", "author_id": 2...
2008/10/04
[ "https://Stackoverflow.com/questions/169833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2484/" ]
169,866
<p>How to export pictures in Microsoft Word to TIFF file using Visual Studio Tools for Office? I can obtain a reference to the pictures as InlineShape object collection, the hard part now is how to save them as TIFF images.</p>
[ { "answer_id": 169893, "author": "Graviton", "author_id": 3834, "author_profile": "https://Stackoverflow.com/users/3834", "pm_score": 3, "selected": true, "text": " private void SaveToImage(Word.InlineShape picShape, string filePath)\n {\n picShape.Select();\n the...
2008/10/04
[ "https://Stackoverflow.com/questions/169866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
169,877
<p>Being new to test based development, this question has been bugging me. How much is too much? What should be tested, how should it be tested, and why should it be tested? The examples given are in C# with NUnit, but I assume the question itself is language agnostic.</p> <p>Here are two current examples of my own, tests on a generic list object (being tested with strings, the initialisation function adds three items <code>{"Foo", "Bar", "Baz"}</code>):</p> <pre><code>[Test] public void CountChanging() { Assert.That(_list.Count, Is.EqualTo(3)); _list.Add("Qux"); Assert.That(_list.Count, Is.EqualTo(4)); _list[7] = "Quuuux"; Assert.That(_list.Count, Is.EqualTo(8)); _list.Remove("Quuuux"); Assert.That(_list.Count, Is.EqualTo(7)); } [Test] public void ContainsItem() { Assert.That(_list.Contains("Qux"), Is.EqualTo(false)); _list.Add("Qux"); Assert.That(_list.Contains("Qux"), Is.EqualTo(true)); _list.Remove("Qux"); Assert.That(_list.Contains("Qux"), Is.EqualTo(false)); } </code></pre> <p>The code is fairly self-commenting, so I won't go into what's happening, but is this sort of thing taking it too far? <code>Add()</code> and <code>Remove()</code> are tested seperately of course, so what level should I go to with these sorts of tests? Should I even have these sorts of tests?</p>
[ { "answer_id": 169886, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 1, "selected": false, "text": "_list" } ]
2008/10/04
[ "https://Stackoverflow.com/questions/169877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
169,889
<p>There's another post on SO relating to .NET -- not us. Pure PHP. Trying to find the best way/process to deploy stable version of our PHP app. I've seen an article on <a href="http://www.simplisticcomplexity.com/2006/8/16/automated-php-deployment-with-capistrano/" rel="nofollow noreferrer">Capistrano</a>, but am curious what else is out there. Aside from the obvious reasons, I'm also looking to add some scripting so that the <a href="https://stackoverflow.com/questions/111436/how-can-i-get-the-svn-revision-number-in-php">SVN rev number gets added in there as well</a>.</p> <p>Much thanks.</p>
[ { "answer_id": 169935, "author": "Michael Johnson", "author_id": 17688, "author_profile": "https://Stackoverflow.com/users/17688", "pm_score": 3, "selected": true, "text": "svn export" } ]
2008/10/04
[ "https://Stackoverflow.com/questions/169889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24708/" ]
169,894
<p>The <a href="http://flot.googlecode.com/svn/trunk/API.txt" rel="nofollow noreferrer">Flot API documentation</a> describes the library's extensive hooks for customizing the axes of a graph. You can set the number of ticks, their color, etc. separately for each axis. However, I can not figure out how to prevent Flot from drawing the vertical grid lines without also removing the x-axis labels. I've tried changing the tickColor, ticks, and tickSize options with no success.</p> <p>I want to create beautiful, Tufte-compatible graphs such as these:</p> <p><a href="http://www.robgoodlatte.com/wp-content/uploads/2007/05/tufte_mint.gif" rel="nofollow noreferrer"><a href="http://www.robgoodlatte.com/wp-content/uploads/2007/05/tufte_mint.gif" rel="nofollow noreferrer">http://www.robgoodlatte.com/wp-content/uploads/2007/05/tufte_mint.gif</a></a> <a href="http://www.argmax.com/mt_blog/archive/RealGDP_graph.jpg" rel="nofollow noreferrer"><a href="http://www.argmax.com/mt_blog/archive/RealGDP_graph.jpg" rel="nofollow noreferrer">http://www.argmax.com/mt_blog/archive/RealGDP_graph.jpg</a></a></p> <p>I find the vertical ticks on my graphs to be chart junk. I am working with a time series that I am displaying as vertical bars so the vertical ticks often cut through the bars in a way that is visually noisy.</p>
[ { "answer_id": 4569708, "author": "Laurimann", "author_id": 328958, "author_profile": "https://Stackoverflow.com/users/328958", "pm_score": 3, "selected": false, "text": "var options = {\n grid: {show: true,\n color: \"rgb(48, 48, 48)\",\n tickColor: ...
2008/10/04
[ "https://Stackoverflow.com/questions/169894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10419/" ]
169,897
<p>I tried to package a Twisted program with py2exe, but once I run the exe file I built, I got a "No module named resource" error. </p> <p>And I found the py2exe said:</p> <blockquote> <p>The following modules appear to be missing ['FCNTL', 'OpenSSL', 'email.Generator', 'email.Iterators', 'email.Utils', 'pkg_resources', 'pywintypes', 'resource', 'win32api', 'win32con', 'win32event', 'win32file', 'win32pipe', 'win32process', 'win32security']</p> </blockquote> <p>So how do I solve this problem?</p> <p>Thanks.</p>
[ { "answer_id": 169913, "author": "teratorn", "author_id": 14739, "author_profile": "https://Stackoverflow.com/users/14739", "pm_score": 5, "selected": true, "text": "python setup.py py2exe -p win32com -i twisted.web.resource\n" }, { "answer_id": 31598939, "author": "K246", ...
2008/10/04
[ "https://Stackoverflow.com/questions/169897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25077/" ]
169,902
<p>Given two image buffers (assume it's an array of ints of size width * height, with each element a color value), how can I map an area defined by a quadrilateral from one image buffer into the other (always square) image buffer? I'm led to understand this is called "projective transformation".</p> <p>I'm also looking for a general (not language- or library-specific) way of doing this, such that it could be reasonably applied in any language without relying on "magic function X that does all the work for me".</p> <p>An example: I've written a short program in Java using the Processing library (processing.org) that captures video from a camera. During an initial "calibrating" step, the captured video is output directly into a window. The user then clicks on four points to define an area of the video that will be transformed, then mapped into the square window during subsequent operation of the program. If the user were to click on the four points defining the corners of a door visible at an angle in the camera's output, then this transformation would cause the subsequent video to map the transformed image of the door to the entire area of the window, albeit somewhat distorted.</p>
[ { "answer_id": 170108, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://Stackoverflow.com/users/7028", "pm_score": 0, "selected": false, "text": "t" }, { "answer_id": 170124, "author": "b3.", "author_id": 14946, "author_profile": "https://Stackoverfl...
2008/10/04
[ "https://Stackoverflow.com/questions/169902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/173449/" ]
169,904
<p>I'm using HttpListener to allow a user to set up a proxy on a user-defined port. When I start the HttpListener, I get an exception if the application isn't running under administrator privileges in Vista.</p> <p>From what I've read, <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93940" rel="noreferrer">this is expected behavior</a> - administrator privileges are required to start listening on a port. But I'm sure there are ways around this, as I run plenty of programs (like Skype) which listen on a port without requiring elevation to administrator.</p> <p>Is there a way to do this with HttpListener? If not, can I make other API calls in .NET code to set up the port?</p>
[ { "answer_id": 195256, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 6, "selected": false, "text": "netsh http show urlacl\n" }, { "answer_id": 6663823, "author": "rob", "author_id": 840650, "auth...
2008/10/04
[ "https://Stackoverflow.com/questions/169904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5/" ]
169,905
<p>I want to write a script which cleans the 'run' dialogue automatically every log off. Where is the history stored?</p>
[ { "answer_id": 169911, "author": "Vincent McNabb", "author_id": 16299, "author_profile": "https://Stackoverflow.com/users/16299", "pm_score": 2, "selected": false, "text": "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU\n" } ]
2008/10/04
[ "https://Stackoverflow.com/questions/169905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4960/" ]
169,907
<p>I need to encode a 100KB+ string as base64 in VBA. Are there any built-in functions or COM objects available which will do this as a pure VBA approach is either complex or doesn't scale well at these volumes (see links from <a href="http://www.vbforums.com/showthread.php?t=379072" rel="noreferrer">dbb</a> and <a href="http://www.motobit.com/tips/detpg_Base64Encode/" rel="noreferrer">marxidad</a>)?</p>
[ { "answer_id": 169945, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 7, "selected": true, "text": "Function EncodeBase64(text As String) As String\n Dim arrData() As Byte\n arrData = StrConv(text, vbFromUnicode) \...
2008/10/04
[ "https://Stackoverflow.com/questions/169907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4023/" ]
169,925
<p>I want to convert a string into a double and after doing some math on it, convert it back to a string.</p> <p>How do I do this in Objective-C?</p> <p>Is there a way to round a double to the nearest integer too?</p>
[ { "answer_id": 169932, "author": "olliej", "author_id": 784, "author_profile": "https://Stackoverflow.com/users/784", "pm_score": 9, "selected": true, "text": "double myDouble = [myString doubleValue];\n" }, { "answer_id": 169948, "author": "Paul Dixon", "author_id": 6521...
2008/10/04
[ "https://Stackoverflow.com/questions/169925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23695/" ]
169,973
<p>When is it better to use a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1" rel="noreferrer">List</a> vs a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.linkedlist-1" rel="noreferrer">LinkedList</a>?</p>
[ { "answer_id": 169983, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 8, "selected": false, "text": "List<T>" }, { "answer_id": 7777687, "author": "Drew Noakes", "author_id": 24874, "author_profile"...
2008/10/04
[ "https://Stackoverflow.com/questions/169973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5274/" ]
170,004
<p>Let's say:</p> <pre><code>&lt;div&gt; pre text &lt;div class="remove-just-this"&gt; &lt;p&gt;child foo&lt;/p&gt; &lt;p&gt;child bar&lt;/p&gt; nested text &lt;/div&gt; post text &lt;/div&gt; </code></pre> <p>to this:</p> <pre><code>&lt;div&gt; pre text &lt;p&gt;child foo&lt;/p&gt; &lt;p&gt;child bar&lt;/p&gt; nested text post text &lt;/div&gt; </code></pre> <p>I've been figuring out using Mootools, jQuery and even (raw) JavaScript, but couldn't get the idea how to do this.</p>
[ { "answer_id": 170056, "author": "jk.", "author_id": 21284, "author_profile": "https://Stackoverflow.com/users/21284", "pm_score": 8, "selected": true, "text": "var cnt = $(\".remove-just-this\").contents();\n$(\".remove-just-this\").replaceWith(cnt);\n" }, { "answer_id": 170142,...
2008/10/04
[ "https://Stackoverflow.com/questions/170004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20838/" ]
170,019
<p>I have an API that is dependent on certain state information between requests. As an easy first version of the code, I am simply using PHP session's to store the state information instead of something more advanced (APC, memcache, DB). Throughout my initial testing in a web browser, everything worked perfectly. However, it seems that when clients try to connect through non-browser methods such as Curl or wget, the state information is not being preserved. </p> <p>Will a PHP session only be created if a browser is requesting the page? I am explicitly starting the session with session_start() as well as naming it before hand with session_name(). </p> <p><strong>An added note</strong>. I learned that one of the major problems I was having was that I was naming the session instead of setting the session id via session_id($id); My intention in using session_name() was to retrieve the same session that was previously created, and the correct way to do this is by setting the session_id not the session_name. </p> <p>It seems that session information will be persisted on the server as noted below (THANK YOU). But to keep this you must pass the session id, or, as in my case, any other id that would uniquely identify the user. Use this id as the session_id and your sessions will function as expected. </p>
[ { "answer_id": 170031, "author": "keparo", "author_id": 19468, "author_profile": "https://Stackoverflow.com/users/19468", "pm_score": 5, "selected": true, "text": "mysite.com?PHPSESSID=10alksdjfq9e\n" }, { "answer_id": 170764, "author": "Alan Storm", "author_id": 4668, ...
2008/10/04
[ "https://Stackoverflow.com/questions/170019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8880/" ]
170,021
<p>We are currently running a SQL Job that archives data daily at every 10PM. However, the end users complains that from 10PM to 12, the page shows a time out error.</p> <p>Here's the pseudocode of the job</p> <pre><code>while @jobArchive = 1 and @countProcecessedItem &lt; @maxItem exec ArchiveItems @countProcecessedItem out if error occured set @jobArchive = 0 delay '00:10' </code></pre> <p>The ArchiveItems stored procedure grabs the top 100 item that was created 30 days ago, process and archive them in another database and delete the item in the original table, including other tables that are related with it. finally sets the @countProcecessedItem with the number of item processed. The ArchiveItems also creates and deletes temporary tables it used to hold some records.</p> <p><strong>Note:</strong> if the information I've provide is incomplete, reply and I'll gladly add more information if possible.</p>
[ { "answer_id": 170031, "author": "keparo", "author_id": 19468, "author_profile": "https://Stackoverflow.com/users/19468", "pm_score": 5, "selected": true, "text": "mysite.com?PHPSESSID=10alksdjfq9e\n" }, { "answer_id": 170764, "author": "Alan Storm", "author_id": 4668, ...
2008/10/04
[ "https://Stackoverflow.com/questions/170021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24755/" ]
170,028
<p>This seems very noisy to me. Five lines of overhead is just too much.</p> <pre><code>m_Lock.EnterReadLock() Try Return m_List.Count Finally m_Lock.ExitReadLock() End Try </code></pre> <p>So how would you simply this?</p>
[ { "answer_id": 170032, "author": "Jonathan Allen", "author_id": 5274, "author_profile": "https://Stackoverflow.com/users/5274", "pm_score": 0, "selected": false, "text": "Using m_Lock.ReadSection\n Return m_List.Count\nEnd Using\n" }, { "answer_id": 170040, "author": "Marc...
2008/10/04
[ "https://Stackoverflow.com/questions/170028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5274/" ]
170,036
<p>Does windows have any decent sampling (eg. non-instrumenting) profilers available? Preferably something akin to Shark on MacOS, although i am willing to accept that i am going to have to pay for such a profiler on windows.</p> <p>I've tried the profiler in VS Team Suite and was not overly impressed, and was wondering if there were any other good ones.</p> <p>[Edit: Erk, i forgot to say this is for C/C++, rather than .NET -- sorry for any confusion]</p>
[ { "answer_id": 171709, "author": "bk1e", "author_id": 8090, "author_profile": "https://Stackoverflow.com/users/8090", "pm_score": 2, "selected": false, "text": "dbghelp.dll" } ]
2008/10/04
[ "https://Stackoverflow.com/questions/170036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/784/" ]
170,051
<p>I'm trying to make things simpler. Here is my code:</p> <pre><code> If Threading.Monitor.TryEnter(syncRoot) Then Try 'do something Finally Threading.Monitor.Exit(syncRoot) End Try Else 'do something else End If </code></pre> <p>This is even worse than the ReaderWriterLock in terms of noise. I can use C# or VB, so answers applying to either will be welcome.</p>
[ { "answer_id": 170055, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "using(var token = GetLock(syncLock, timeout)) {\n if(token != null) { ... }\n}\n" }, { "answer_id": 170094, ...
2008/10/04
[ "https://Stackoverflow.com/questions/170051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5274/" ]