qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
241,425
<p>I'm also interested in other Symbian SDKs that allow to set their emulator's IMEI.</p>
[ { "answer_id": 280431, "author": "David Jacobson", "author_id": 28484, "author_profile": "https://Stackoverflow.com/users/28484", "pm_score": 1, "selected": false, "text": "#ifdef __WINS__" }, { "answer_id": 915150, "author": "JOM", "author_id": 113079, "author_profil...
2008/10/27
[ "https://Stackoverflow.com/questions/241425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15647/" ]
241,453
<p>I'm experimenting with JavaFX making a small game. </p> <p>I want to add sound. How?</p> <p>I tried <code>MediaPlayer</code> with <code>media</code> defined with relative <code>source</code> attribute like:</p> <pre><code>attribute media = Media{ source: "{__FILE__}/sound/hormpipe.mp3" } attribute player = MediaPlayer{ autoPlay:true media:media } </code></pre> <p>It doesn't play. I get </p> <blockquote> <p><code>FX Media Object caught Exception com.sun.media.jmc.MediaUnavailableException: Media unavailable: file: ... Sound.class/sound/hormpipe.mp3</code></p> </blockquote>
[ { "answer_id": 368256, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "var player = javafx.scene.media.MediaPlayer {\n repeatCount: javafx.scene.media.MediaPlayer.REPEAT_FOREVER\n media: Medi...
2008/10/27
[ "https://Stackoverflow.com/questions/241453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1514822/" ]
241,454
<p>What is the best way to manage a database connection in a Java servlet?</p> <p>Currently, I simply open a connection in the <code>init()</code> function, and then close it in <code>destroy()</code>. </p> <p>However, I am concerned that "permanently" holding onto a database connection could be a bad thing. </p> <p>Is this the correct way to handle this? If not, what are some better options?</p> <p>edit: to give a bit more clarification: I have tried simply opening/closing a new connection for each request, but with testing I've seen performance issues due to creating too many connections.</p> <p>Is there any value in sharing a connection over multiple requests? The requests for this application are almost all "read-only" and come fairly rapidly (although the data requested is fairly small).</p>
[ { "answer_id": 241464, "author": "John Topley", "author_id": 1450, "author_profile": "https://Stackoverflow.com/users/1450", "pm_score": 1, "selected": false, "text": "doGet/doPost" }, { "answer_id": 241569, "author": "anjanb", "author_id": 11142, "author_profile": "h...
2008/10/27
[ "https://Stackoverflow.com/questions/241454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12983/" ]
241,467
<p>As title. I didn't find one via google, at any rate.</p> <p>Update: thanks for the links from the two answers; this is very useful, but not what I was after - I am curious to see whether it is possible to query an IRepository backed by memcached (or some other distributed cache), backed by a RDBMS. I've really no idea how that might work in practise; I don't know very much about the internals of either distributed caches or LINQ providers.</p> <p>I'm maybe envisaging something like the cache LINQ provider generating cache-keys based on the query automatically (where query could be Expression> or some kind of Specification pattern implementation), and basically can be plumped down inbetween my app and my DB. Does that sound useful?</p>
[ { "answer_id": 352064, "author": "Funky81", "author_id": 37509, "author_profile": "https://Stackoverflow.com/users/37509", "pm_score": 1, "selected": false, "text": " public static IEnumerable<User> GetAllUsers() \n { \n // Retrieve from cache if it exists, otherwise run the ...
2008/10/27
[ "https://Stackoverflow.com/questions/241467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20971/" ]
241,470
<p>I am designing a simple internal framework for handling time series data. Given that LINQ is my current toy hammer, I want to hit everything with it.</p> <p>I want to implement methods in class TimeSeries (Select(), Where() and so on) so that I can use LINQ syntax to handle time series data</p> <p>Some things are straight forward, e.g. (from x in A select x+10), giving a new time series.</p> <p>What is the best syntax design for combining two or more time series? (from a in A from b in B select a+b) is not great, since it expresses a nested loop. Maybe some join? This should correspond to join on the implicit time variable. (What I have in mind corresponds to the lisp 'zip' function)</p> <hr> <p><strong>EDIT:</strong> <em>Some clarification is necessary.</em></p> <p>A time series is a kind of function depending on time, e.g. stock quotes. A combination of time series could be the difference between two stock prices, as a function of time.</p> <pre><code>Stock1.MyJoin(Stock2, (a,b)=&gt;a-b) </code></pre> <p>is possible, but can this be expressed neatly using some LINQ syntax? I am expecting to implement LINQ methods in <code>class MyTimeSeries</code> myself.</p>
[ { "answer_id": 241478, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "Union" }, { "answer_id": 241563, "author": "Greg Beech", "author_id": 13552, "author_profile": "http...
2008/10/27
[ "https://Stackoverflow.com/questions/241470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31890/" ]
241,507
<p>I think the title pretty much says it all... I'm looking to implement an interface similar to the standard OS X sidebar used in all the above mentioned programs, and I'm wondering if anybody has any thoughts as to the easiest way to do it, namely about what view to use for the left hand selection pane. Really I don't think I even need the hierarchical component as seen in the apple apps, I just need a good looking flat list of choices which determine what's shown in the right hand pane.</p> <p>The obvious start is a vertical split layout view, but beyond that I'm not entirely sure where to go. A collection view with only one column or something like that?</p>
[ { "answer_id": 241853, "author": "Ken", "author_id": 17320, "author_profile": "https://Stackoverflow.com/users/17320", "pm_score": 4, "selected": false, "text": "Highlight: Source List" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/241507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
241,512
<p>My HTML is as follows:</p> <pre><code>&lt;ul id="nav"&gt; &lt;li&gt;&lt;a href="./"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/About"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/Contact"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>And my css:</p> <pre><code>#nav { display: inline; } </code></pre> <p>However the whitespace between the li's shows up. I can remove the whitespace by collapsing them like so:</p> <pre><code>&lt;ul id="nav"&gt; &lt;li&gt;&lt;a href="./"&gt;Home&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="/About"&gt;About&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="/Contact"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>But this is being maintained largely by hand and I was wondering if there was a cleaner way of doing it.</p>
[ { "answer_id": 241523, "author": "thismat", "author_id": 14045, "author_profile": "https://Stackoverflow.com/users/14045", "pm_score": 6, "selected": true, "text": "<ul id=\"navigation\">\n <li><a href=\"#\" title=\"\">Home</a></li>\n <li><a href=\"#\" title=\"\">Home</a></li>\n <li><...
2008/10/27
[ "https://Stackoverflow.com/questions/241512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
241,513
<p>I've been trying to follow the information from:</p> <p><a href="http://www.datasprings.com/Resources/ArticlesInformation/Sharepoint2007CustomWebParts/tabid/775/Default.aspx" rel="nofollow noreferrer">Long URL clipped to stop breaking the page</a></p> <p>and</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms415817.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms415817.aspx</a></p> <p>Which more or less have the same instructions. I've been copying the .dll file from the build over to the BIN directory of the Sharepoint site.</p> <p>When I click the Web Part Gallery and hit new, both articles say that the web part should show up in the list.</p> <p>I have tried every possible way that I can think, but my web part will not show up in that list. Is there a step that I missed somewhere? Are there permissions that I should be thinking about? How exactly does Sharepoint recognize that there is a new web part. Is it simply from having the assembly placed in the BIN directory, or is it from adding the control in the safe list of web.config?</p> <p>I've added it to the safe controls list. I've tried every different combination that I could think of, but nothing has worked.</p> <p>Do I need to rename the .DLL assembly to something else?</p> <p>For the life of me I cannot figure this out.</p>
[ { "answer_id": 241527, "author": "AdamBT", "author_id": 22426, "author_profile": "https://Stackoverflow.com/users/22426", "pm_score": 2, "selected": false, "text": "... Namespace=\"*\" TypeName=\"*\" ..." }, { "answer_id": 241918, "author": "AdamBT", "author_id": 22426, ...
2008/10/27
[ "https://Stackoverflow.com/questions/241513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10420/" ]
241,526
<p>I've been tasked with build an accessible RSS feed for my company's job listings. I already have an RSS feed from our recruiting partner; so I'm transforming their RSS XML to our own proxy RSS feed to add additional data as well limit the number of items in the feed so we list on the latest jobs.</p> <p>The RSS validates via feedvalidator.org (with warnings); but the problem is this. Unfortunately, no matter how many times I tell them not to; my company's HR team directly copies and pastes their Word documents into our Recruiting partners CMS when inserting new job listings, leaving WordML in my feed. I believe this WordML is causing issues with Feedburner's BrowserFriendly feature; which we want to show up to make it easier for people to subscribe. Therefore, I need to remove the WordML markup in the feed.</p> <p>Anybody have experience doing this? Can anyone point me to a good solution to this problem?</p> <p>Preferably; I'd like to be pointed to a solution in .Net (VB or C# is fine) and/or XSL.</p> <p>Any advice on this is greatly appreciated.</p> <p>Thanks.</p>
[ { "answer_id": 241562, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "char[] charToRemove = { (char)8217, (char)8216, (char)8220, (char)8221, (char)8211 };\nchar[] charToAdd = { (char)39, (char)39...
2008/10/27
[ "https://Stackoverflow.com/questions/241526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10922/" ]
241,533
<p>I want to write a program that would print every combination of a set of variables to a text file, creating a word list. Each answer should be written on a separate line and write all of the results for 1 digit, 2 digits, and 3 digits to a single text file.</p> <p>Is there a simple way I can write a python program that can accomplish this? Here is an example of the output I am expecting when printing all the binary number combinations possible for 1, 2, and 3 digits:</p> <pre><code>Output: 0 1 00 01 10 11 000 001 010 011 100 101 110 111 </code></pre>
[ { "answer_id": 241542, "author": "wprl", "author_id": 17847, "author_profile": "https://Stackoverflow.com/users/17847", "pm_score": 2, "selected": false, "text": "for(int i=0; i < 2^digits; i++)\n{\n WriteLine(ToBinaryString(i));\n}\n" }, { "answer_id": 241557, "author": ...
2008/10/27
[ "https://Stackoverflow.com/questions/241533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
241,539
<p>I am extending a class defined in a library which I cannot change:</p> <pre><code>public class Parent { public void init(Map properties) { ... } } </code></pre> <p>If I am defining a class 'Child' that extends Parent and I am using Java 6 with generics, what is the best way to override the init method without getting unchecked warnings?</p> <pre><code>public class Child extends Parent { // warning: Map is a raw type. References to generic type Map&lt;K,V&gt; should be parameterized public void init(Map properties) { } } </code></pre> <p>If I add generic parameters, I get:</p> <pre><code> // error: The method init(Map&lt;Object,Object&gt;) of type Child has the same erasure as init(Map) of type Parent but does not override it public void init(Map&lt;Object,Object&gt;) { ... } // same error public void init(Map&lt;? extends Object,? extends Object&gt;) { ... } // same error public void init(Map&lt;?,?&gt;) { ... } </code></pre> <p>This error occurs regardless of whether I use a specific type, a bounded wildcard, or an unbounded wildcard. Is there a correct or idiomatic way to override a non-generic method without warnings, and without using @SuppressWarnings("unchecked")?</p>
[ { "answer_id": 241933, "author": "Dov Wasserman", "author_id": 26010, "author_profile": "https://Stackoverflow.com/users/26010", "pm_score": 5, "selected": true, "text": "@SuppressWarnings(\"unchecked\")" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/241539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16399/" ]
241,540
<p>I'm a little unsure how the open source licensing stuff works. If I were to choose a particular open source license, what do you actually have to do to make it applicable to your software? I would imagine it would be a little more involved than just 'stating' that you're releasing your software under LGPL. And how does this 'contract' bind legally to your software?</p>
[ { "answer_id": 241556, "author": "Kirk Strauser", "author_id": 32538, "author_profile": "https://Stackoverflow.com/users/32538", "pm_score": 2, "selected": false, "text": "<one line to give the program's name and a brief idea of what it does.>\nCopyright (C) <year> <name of author>\n\nT...
2008/10/27
[ "https://Stackoverflow.com/questions/241540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30563/" ]
241,541
<p>We decided to use the minimumRequiredVersion in our clickOnce application manifest, and now when we try to rollback to a previous version when the user launches the application it fails to start. It says the application manifest has a earlier version than the required version and the user can not use the application. We did not have this problem withou the minimumRequiredVersion, but we would like to use that. </p>
[ { "answer_id": 11282320, "author": "Hasani Blackwell", "author_id": 79668, "author_profile": "https://Stackoverflow.com/users/79668", "pm_score": 0, "selected": false, "text": "\nusing System;\nusing System.Deployment.Application;\nusing System.Reflection;\n\nnamespace ClickOnceAppRollba...
2008/10/27
[ "https://Stackoverflow.com/questions/241541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5102/" ]
241,550
<p>What are some good jQuery Resources along with some gotchas when using it with ASP.Net?</p>
[ { "answer_id": 241588, "author": "Adam Lassek", "author_id": 1249, "author_profile": "https://Stackoverflow.com/users/1249", "pm_score": 3, "selected": false, "text": "$('[id$=myid]')" }, { "answer_id": 241658, "author": "tsimon", "author_id": 1685, "author_profile": ...
2008/10/27
[ "https://Stackoverflow.com/questions/241550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26931/" ]
241,570
<p>Is there anyway to automatically run <code>javascript:window.print()</code> when the page finishes loading? </p>
[ { "answer_id": 241572, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 8, "selected": true, "text": "<body onload=\"window.print()\">" }, { "answer_id": 10467046, "author": "drftorres", "author_id": 1327395, ...
2008/10/27
[ "https://Stackoverflow.com/questions/241570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
241,579
<p>If I import a library to use a method, would it be worth it? Does importing take up a lot of memory?</p>
[ { "answer_id": 241583, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 3, "selected": false, "text": "my %number_for = (\n jan => 1,\n feb => 2,\n#etc...\n);\n#...\ndo_something_with($number_for{$month})\n" }, ...
2008/10/27
[ "https://Stackoverflow.com/questions/241579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31301/" ]
241,581
<p>I have no trouble building 1.35.0, as well as 1.36.0 on the timesys arm-gcc toolchain, both statically (link-static) as well as dynamically (.so, default option).</p> <p>However, when I try to link a simple sample filesystem app:</p> <pre><code>#include &lt;boost/filesystem.hpp> #include &lt;iostream> namespace fs = boost::filesystem; int main(int argc, char *argv[]) { const char* fileName = argv[1]; std::cout &lt;&lt; "file: " &lt;&lt; fileName &lt;&lt; " => " &lt;&lt; fs::exists(fileName) &lt;&lt; std::endl; return 0; } </code></pre> <p>I get the following linker error:</p> <pre><code> developer@eldp01:~/boost/test$ /opt/timesys/at91sam9263_ek/toolchain/bin/armv5l-timesys-linux-gnueabi-gcc exists.cpp -o exists.exe -I ../boost_1_35_0/ -lboost_filesystem -lboost_system -lstdc++ -L . /tmp/ccex3NGb.o: In function `boost::detail::atomic_decrement(int*)': exists.cpp:(.text._ZN5boost6detail16atomic_decrementEPi[boost::detail::atomic_decrement(int*)]+0x1c): undefined reference to `__sync_fetch_and_add_4' /tmp/ccex3NGb.o: In function `boost::detail::atomic_increment(int*)': exists.cpp:(.text._ZN5boost6detail16atomic_incrementEPi[boost::detail::atomic_increment(int*)]+0x1c): undefined reference to `__sync_fetch_and_add_4' collect2: ld returned 1 exit status </code></pre> <p>Does anyone know how I can get Boost to build for the gcc-arm toolchain?</p>
[ { "answer_id": 241583, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 3, "selected": false, "text": "my %number_for = (\n jan => 1,\n feb => 2,\n#etc...\n);\n#...\ndo_something_with($number_for{$month})\n" }, ...
2008/10/27
[ "https://Stackoverflow.com/questions/241581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4829/" ]
241,622
<p>I am not as familiar with Oracle as I would like to be. I have some 250k records, and I want to display them 100 per page. Currently I have one stored procedure which retrieves all quarter of a million records to a dataset using a data adapter, and dataset, and the dataadapter.Fill(dataset) method on the results from the stored proc. If I have "Page Number" and "Number of records per page" as integer values I can pass as parameters, what would be the best way to get back just that particular section. Say, if I pass 10 as a page number, and 120 as number of pages, from the select statement it would give me the 1880th through 1200th, or something like that, my math in my head might be off. </p> <p>I'm doing this in .NET with C#, thought that's not important, if I can get it right on the sql side, then I should be cool. </p> <p>Update: I was able to use Brian's suggestion, and it is working great. I'd like to work on some optimization, but the pages are coming up in 4 to 5 seconds rather than a minute, and my paging control was able to integrate in very well with my new stored procs. </p>
[ { "answer_id": 241643, "author": "Brian Schmitt", "author_id": 30492, "author_profile": "https://Stackoverflow.com/users/30492", "pm_score": 8, "selected": true, "text": "SELECT * FROM\n(\n SELECT a.*, rownum r__\n FROM\n (\n SELECT * FROM ORDERS WHERE CustomerID LIKE 'A%...
2008/10/27
[ "https://Stackoverflow.com/questions/241622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18893/" ]
241,631
<p>I'm writing a web application that <em>dynamically</em> creates URL's based off of some input, to be consumed by a client at another time. For discussion sake these URL's can contain certain characters, like a <strong>forward slash (i.e. '/')</strong>, which should not be interpreted as part of the actual URL, but just as an argument. For example:</p> <pre>http://mycompany.com/PartOfUrl1/PartOfUrl2/ArgumentTo/Url/GoesHere</pre> <p>As you can see, the <strong>ArgumentTo/Url/GoesHere</strong> does indeed have forward slashes but these should be <em>ignored or escaped</em>.</p> <p>This may be a bad example but the question in hand is more general and applies to other <em>special characters</em>.</p> <h3>So, if there are pieces of a URL that are just <em>argument</em>s and should not be used to resolve the actual web request, what's a good way of handling this?</h3> <h1>Update:</h1> <p>Given some of the answers I realized that I failed to point out a few pieces that hopefully will help clarify.</p> <p>I would like to keep this fairly language agnostic as it would be great if the client could just make a request. For example, if the client knew that it wanted to pass <strong>ArgumentTo/Url/GoesHere</strong>, it would be great if that could be <em>encoded</em> into a <em>unique</em> string in which the server could turn around and <em>decode</em> it to use.</p> <p>Can we assume that similar functions like HttpUtility.HtmlEncode/HtmlDecode in the .NET Framework are available on other systems/platforms? The URL does not have to be <em>pretty</em> by any means so having <em>real words</em> in the path does not really matter.</p> <h3>Would something like a base64 encoding of the argument work?</h3> <p>It seems that base64 encoding/decoding is fairly readily available on any platform/language.</p>
[ { "answer_id": 241639, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 3, "selected": false, "text": "urlencode" }, { "answer_id": 241648, "author": "dgw", "author_id": 5991, "author_profile": "https://Stackov...
2008/10/27
[ "https://Stackoverflow.com/questions/241631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4916/" ]
241,634
<p>In Cygwin a space in a path has to be escaped with a backslash Not true in Windows, put the whole path in a quote</p> <p>Is there a way to convert to this automatically in Ruby?</p> <p>Otherwise, how in Ruby do I detect if I am running with Windows or Cygwin?</p>
[ { "answer_id": 1582028, "author": "knoopx", "author_id": 62368, "author_profile": "https://Stackoverflow.com/users/62368", "pm_score": 2, "selected": true, "text": "sys.escape(\"foo bar\")\n# gives on Windows: '\"foo bar\"'\n# other systems: 'foo\\ bar'\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/241634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2167252/" ]
241,645
<p>I have the Profile, CCK, and Views2 modules installed on a Drupal 6 site. I added a string field to the user profile. I can filter easily on preset values, thru the Views GUI builder, really nicely. However, I'd like the filter criteria to be dynamically set based on other environment variables (namely the <code>$_SERVER['SERVER_NAME']</code>).</p> <p>Is there a basic 'How-to-write-a-custom-drupal-views-filter' somewhere out there? I've been looking thru the documentation, but it's not obvious to my simple mind on how to do it.</p>
[ { "answer_id": 835510, "author": "AbhiG", "author_id": 59182, "author_profile": "https://Stackoverflow.com/users/59182", "pm_score": 2, "selected": false, "text": "<?php custom_views_embed_view($view_name, $display_id) {\n$view = views_get_view($view_name);\n$view->set_display($display_i...
2008/10/27
[ "https://Stackoverflow.com/questions/241645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6824/" ]
241,663
<pre><code>$fp_src=fopen('file','r'); $filter = stream_filter_prepend($fp_src, 'convert.iconv.ISO-8859-1/UTF-8'); while(fread($fp_src,4096)){ ++$count; if($count%1000==0) print ftell($fp_src)."\n"; } </code></pre> <p>When I run this the script ends up consuming ~ 200 MB of RAM after going through just 35MB of the file. </p> <p>Running it without the stream_filter zips right through with a constant memory footprint of ~10 MB.</p> <p>What gives?</p>
[ { "answer_id": 241701, "author": "Peter Bailey", "author_id": 8815, "author_profile": "https://Stackoverflow.com/users/8815", "pm_score": 0, "selected": false, "text": "stream_filter_prepend()" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/241663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
241,673
<pre><code>if(!eregi("^([0-9a-z_\[\]\*\- ])+$", $subuser)) $form-&gt;setError($field, "* Username not alphanumeric"); </code></pre> <p>Can anybody tell me why it is not allowing characters such as <code>-</code> and <code>*</code>?</p> <pre><code>if(!eregi("^([0-9a-z])+$", $subuser)) $form-&gt;setError($field, "* Username not alphanumeric"); </code></pre> <p>That is the original piece of code. A friend changed it to the top piece and it will allow a-z and 0-9 but it wont allow the other characters I need it to. Can anyone help me?</p> <p>Thanks in advance.</p>
[ { "answer_id": 241680, "author": "Henning", "author_id": 29549, "author_profile": "https://Stackoverflow.com/users/29549", "pm_score": 3, "selected": false, "text": "else if (!preg_match(\"/^([0-9a-z_\\[\\]* -])+$/i\", $subuser)) {\n$form->setError($field, \"* Username not alphanumeric\"...
2008/10/27
[ "https://Stackoverflow.com/questions/241673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29912/" ]
241,691
<p>Rather than scraping a Ruby version of this algorithm off the net I wanted to create my own based on its description <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" rel="noreferrer">here</a>. However I cannot figure out two things</p> <pre><code>def primeSieve(n) primes = Array.new for i in 0..n-2 primes[i] = i+2 end index = 0 while Math.sqrt(primes.last).ceil &gt; primes[index] (primes[index] ** 2).step(primes.length - 1, primes[index]) {|x| x % primes[index] == 0 ? primes.delete(x) : ""} index += 1 end primes end </code></pre> <ol> <li>Why it doesn't iterate to the end of the array?</li> <li>According to the description in the link above the loop should be broken out of when the squareroot of the last element in the array is greater than the current prime - mine does this one before. </li> </ol> <p>I'm fairly sure it has something to do with the delete operation modifying the length of the array. For example my function currently yields 2,3,5,7,9,10 when I enter n=10 which is obviously not correct. Any suggestions on how I can go about alterating this to make it work like it's supposed to?</p>
[ { "answer_id": 241752, "author": "Andru Luvisi", "author_id": 5922, "author_profile": "https://Stackoverflow.com/users/5922", "pm_score": 4, "selected": true, "text": "while primes[index]**2 <= primes.last\n prime = primes[index]\n primes = primes.select { |x| x == prime || x%p...
2008/10/27
[ "https://Stackoverflow.com/questions/241691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2294/" ]
241,694
<p>I have a loop running that will process 1000's of records, currently once the loop is running it can't be stopped and the user must wait until it is finished. How can I stop the loop when someone clicks a 'Cancel' button? How do I break into that other routine?</p> <p>Thanks</p>
[ { "answer_id": 241707, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 4, "selected": false, "text": "backgroundworker1.WorkerSupportsCancellation = true;\n" }, { "answer_id": 241791, "author": "Community", "au...
2008/10/27
[ "https://Stackoverflow.com/questions/241694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
241,715
<p>I am writing PHP code where I want to pass the session id myself using POST. I don't want a cookie to store the session, as it should get lost when the user gets out of the POST cycle.</p> <p>PHP automatically sets the cookie where available. I learned it is possible to change this behaviour by setting <code>session.use_cookies</code> to 0 in <code>php.ini</code>. Unfortunately, I don't have access to that file and I also wouldn't want to break the behaviour of other scripts running on the same server.</p> <p>Is there a way to disable or void the session cookie inside the PHP script?</p> <p><strong>EDIT:</strong> As the proposed solutions don't work for me, I used $_SESSION = array() at positions in the code where I found the session should be invalidated.</p>
[ { "answer_id": 241719, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 5, "selected": false, "text": "ini_set('session.use_cookies', '0');\n" }, { "answer_id": 241726, "author": "lock", "author_id": 24744, ...
2008/10/27
[ "https://Stackoverflow.com/questions/241715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21974/" ]
241,725
<p>I'm trying to call a web service in an Excel Macro:</p> <pre><code>Set objHTTP = New MSXML.XMLHTTPRequest objHTTP.Open "post", "https://www.server.com/EIDEServer/EIDEService.asmx" objHTTP.setRequestHeader "Content-Type", "text/xml" objHTTP.setRequestHeader "SOAPAction", "PutSchedule" objHTTP.send strXML </code></pre> <p>And I get back the following response:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;soap:Body&gt; &lt;soap:Fault&gt; &lt;faultcode&gt;soap:Client&lt;/faultcode&gt; &lt;faultstring&gt;Server did not recognize the value of HTTP Header SOAPAction: PutSchedule.&lt;/faultstring&gt; &lt;detail /&gt; &lt;/soap:Fault&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>Anybody out there done something like this before?</p>
[ { "answer_id": 241956, "author": "Ray Lu", "author_id": 11413, "author_profile": "https://Stackoverflow.com/users/11413", "pm_score": 3, "selected": true, "text": "\"http://tempri.org/PutSchedule\"\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/241725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1766771/" ]
241,727
<p>If I had the following select, and did not know the value to use to select an item in advance like in this <a href="https://stackoverflow.com/questions/196684/jquery-get-select-option-text">question</a> or the index of the item I wanted selected, how could I select one of the options with jQuery if I did know the text value like Option C?</p> <pre><code>&lt;select id='list'&gt; &lt;option value='45'&gt;Option A&lt;/option&gt; &lt;option value='23'&gt;Option B&lt;/option&gt; &lt;option value='17'&gt;Option C&lt;/option&gt; &lt;/select&gt; </code></pre>
[ { "answer_id": 241743, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 5, "selected": true, "text": "var option;\n$('#list option').each(function() {\n if($(this).text() == 'Option C') {\n option = this;\n ...
2008/10/27
[ "https://Stackoverflow.com/questions/241727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25335/" ]
241,746
<p>In a database prototype, I have a set of fields (like name, description, status) that are required in multiple, functionally different tables.</p> <p>These fields always have the same end user functionality for labeling, display, search, filtering etc. They are not part of a foreign key constraint. How should this be modeled?</p> <p>I can think of the following variants:</p> <ul> <li><p>Each table gets all these attributes. In this case, how would you name them? The same, in each table, or with a table name prefix (like usrName, prodName)</p></li> <li><p>Move them into a table Attributes, add a foreign key to the "core" tables, referencing Attributes.PK</p></li> <li><p>As above, but instead of a foreign key, use the Attributes.PK as PK in the respective core table as well.</p></li> </ul>
[ { "answer_id": 241832, "author": "Terry G Lorber", "author_id": 809, "author_profile": "https://Stackoverflow.com/users/809", "pm_score": 2, "selected": false, "text": "order_status_types\n- id\n- name\n- description\n\nshipping_accounts\n- id\n- name\n- description\n\norders\n- order_st...
2008/10/27
[ "https://Stackoverflow.com/questions/241746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31317/" ]
241,758
<p>In VB6 you can do this:</p> <pre><code>Dim a As Variant a = Array(1, 2, 3)</code></pre> <p>Can you do a similar thing in VB.NET with specific types, like so?:</p> <pre><code>Dim a() As Integer a = <strong>Array</strong>(1, 2, 3)</code></pre>
[ { "answer_id": 241762, "author": "Jonathan Allen", "author_id": 5274, "author_profile": "https://Stackoverflow.com/users/5274", "pm_score": 5, "selected": true, "text": "Dim a() As Integer = New Integer() {1, 2, 3}\n" } ]
2008/10/27
[ "https://Stackoverflow.com/questions/241758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1670/" ]
241,783
<p>I'm interfacing with a payment gateway and not having any luck with Net::SSLeay and its post_https subroutine. The payment gateway has issued me a client certificate that must be used for authentication. The Net::SSLeay perldoc has the following example:</p> <pre><code>($page, $response, %reply_headers) = post_https('www.bacus.pt', 443, '/foo.cgi', # 3b make_headers('Authorization' =&gt; 'Basic ' . MIME::Base64::encode("$user:$pass",'')), make_form(OK =&gt; '1', name =&gt; 'Sampo'), $mime_type6, $path_to_crt7, $path_to_key8); </code></pre> <p>My own version is below and returns the error <strong>Too many arguments for Net::SSLeay::post_https</strong>:</p> <pre><code>#!/usr/bin/perl use strict; use warnings; use Net::SSLeay qw(post_https); my %post = ( #snip ); my ($page, $response, %reply_headers) = post_https( 'www.example.com', 443, '/submit', '', make_form(%post), 'text/xml', '/path/to/cert', '/path/to/key', ); </code></pre> <p>Why is this error occurring?</p>
[ { "answer_id": 241800, "author": "Andru Luvisi", "author_id": 5922, "author_profile": "https://Stackoverflow.com/users/5922", "pm_score": 1, "selected": false, "text": "sub post_https ($$$;***) { do_httpx2(POST => 1, @_) }\n" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/241783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6406/" ]
241,789
<p>I'm trying to parse an international datetime string similar to:</p> <pre><code>24-okt-08 21:09:06 CEST </code></pre> <p>So far I've got something like:</p> <pre><code>CultureInfo culture = CultureInfo.CreateSpecificCulture("nl-BE"); DateTime dt = DateTime.ParseExact("24-okt-08 21:09:06 CEST", "dd-MMM-yy HH:mm:ss ...", culture); </code></pre> <p>The problem is what should I use for the '...' in the format string? Looking at the <a href="http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx" rel="noreferrer">Custom Date and Time Format String</a> MSDN page doesn't seem to list a format string for parsing timezones in PST/CEST/GMT/UTC form.</p>
[ { "answer_id": 241885, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 6, "selected": true, "text": "DateTime dt1 = DateTime.ParseExact(\"24-okt-08 21:09:06 CEST\".Replace(\"CEST\", \"+2\"), \"dd-MMM-yy HH:mm:ss z\", culture);\n...
2008/10/28
[ "https://Stackoverflow.com/questions/241789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/163/" ]
241,790
<p>There have been a couple of questions that sort of dealt with this but not covering my exact question so here we go.</p> <p>For site settings, if these are stored in a database do you:</p> <ol> <li>retrieve them from the db every time someone makes a request</li> <li>store them in a session variable on login</li> <li>???????</li> </ol> <p>For user specific settings do I do the same as site settings??</p> <p>Any guidance/best practice would be greatly appreciated.</p> <p>Cheers</p>
[ { "answer_id": 241946, "author": "Jeff Fritz", "author_id": 29156, "author_profile": "https://Stackoverflow.com/users/29156", "pm_score": 2, "selected": true, "text": " #region Data Access\n\nprivate string GetSettingsFromDb(string settingName)\n{\n return \"\";\n}\nprivate Diction...
2008/10/28
[ "https://Stackoverflow.com/questions/241790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29376/" ]
241,819
<p>What's the difference between the two and when should I use each:</p> <pre><code>&lt;person&gt; &lt;firstname&gt;Joe&lt;/firstname&gt; &lt;lastname&gt;Plumber&lt;/lastname&gt; &lt;/person&gt; </code></pre> <p>versus</p> <pre><code>&lt;person firstname="Joe" lastname="Plumber" /&gt; </code></pre> <p>Thanks</p>
[ { "answer_id": 241834, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "<address>" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/241819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24059/" ]
241,822
<p>I'm preparing a class on Visual Basic 2005 targeting Visual Basic 6 programmers migrating to the .NET platform.</p> <p>My primary concern is to teach my students the best practices for developing in .NET, and I am wondering about whether to consider the use of the VB runtime functions VB.NET legitimate or not.</p> <p>I have read that many of the VB functions in VB.NET actually invoke methods on the .NET Framework, so it appears they exist primarily to ease the transition from earlier versions of Visual Basic to VB.NET. However, <a href="http://blogs.msdn.com/vbteam/" rel="nofollow noreferrer">the VB.NET team</a> seems to recommend to use them whenvever possible since they claim they put some optimizations in there on top of the .NET framework APIs.</p> <p>What's your take on this? </p>
[ { "answer_id": 241922, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 4, "selected": true, "text": "Trim(), Replace(), Len(), UCase()" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/241822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26396/" ]
241,839
<p>I need to choose a database management system (DBMS) that uses the least amount of main memory since we are severely constrained. Since a DBMS will use more and more memory to hold the index in main memory, how exactly do I tell which DBMS has the smallest memory footprint? </p> <p>Right now I just have a memory monitor program open while I perform a series of queries we'll call X. Then I run the same set of queries X on a different DBMS and see how much memory is used in its lifetime and compare with the other memory footprints. </p> <p>Is this a not-dumb way of going about it? Is there a better way?</p> <p>Thanks, Jbu</p>
[ { "answer_id": 241986, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 1, "selected": false, "text": "Collection" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/241839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
241,857
<p>I'm trying to use XPath to parse an XML document. One of my NSXMLElement's looks like the following, hypothetically speaking:</p> <pre><code>&lt;foo bar="yummy"&gt; </code></pre> <p>I'm trying to get the value for the attribute bar, however any interpretation of code I use, gives me back bar="woo", which means I need to do further string processing in order to obtain access to woo and woo alone.</p> <p>Essentially I'm doing something like</p> <pre><code>NSArray *nodes = [xmlDoc nodesForXPath:@"foo/@bar" error:&amp;error]; xmlElement = [nodes objectAtIndex:0]; </code></pre> <p>Is there anyway to write the code above to just give me yummy, versus bar="yummy" so I can relieve myself of parsing the string?</p> <p>Thanks.</p> <hr> <p>Assuming TouchXML is being used, is there still anyway to obtain similar results? As in grabbing just the value for the attribute, without the attribute="value"? That results in then further having to parse the string to get the value out.</p>
[ { "answer_id": 241888, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 2, "selected": false, "text": "-attributeForName:" }, { "answer_id": 242218, "author": "Brian Gianforcaro", "author_id": 3415, "au...
2008/10/28
[ "https://Stackoverflow.com/questions/241857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
241,860
<p>Say I want to get the HTML of</p> <pre>http://www.google.com</pre> <p>as a String using some built-in classes of the Cocoa Touch framework.</p> <p>What is the least amount of code I need to write?</p> <p>I've gotten this far, but can't figure out how to progress. There must be an easier way.</p> <pre><code>CFHTTPMessageRef req; NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; req = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), (CFURLRef)url, kCFHTTPVersion1_1); </code></pre>
[ { "answer_id": 241875, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 4, "selected": true, "text": "+stringWithContentsOfURL:" }, { "answer_id": 242257, "author": "Brian Gianforcaro", "author_id": 3415, ...
2008/10/28
[ "https://Stackoverflow.com/questions/241860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338/" ]
241,873
<p>i need to redirect all of the stdout of a program except the first line into a file. </p> <p>Is there a common unix program that removes lines from stdin and spits the rest out to stdout?</p>
[ { "answer_id": 241884, "author": "Andru Luvisi", "author_id": 5922, "author_profile": "https://Stackoverflow.com/users/5922", "pm_score": 6, "selected": true, "text": "sed 1d\n" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/241873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17076/" ]
241,882
<p>I'm trying to do an image capture on a high end Nokia phone (N95). The phone's internal camera is very good (4 megapixels) but in j2me I only seem to be able to get a maximum of 1360x1020 image out. I drew largely from this example <a href="http://developers.sun.com/mobility/midp/articles/picture/" rel="nofollow noreferrer">http://developers.sun.com/mobility/midp/articles/picture/</a></p> <p>What I did was start with 640x480 and increase the width and height by 80 and 60, respectively until it failed. The line of code is:</p> <p>jpg = mVideoControl.getSnapshot("encoding=jpeg&amp;quality=100&amp;width=" + width + "&amp;height=" + height);</p> <p>So the two issues are: 1. The phone throws an exception when getting an image larger than 1360x1020. 2. The higher resolution images appear to be just smoothed versions of the smaller ones. E.g. When I take a 640x480 image and increase it in photoshop I can't tell the difference between this and one that's supposedly 1360x1020.</p> <p>Is this a limitation of j2me on the phone? If so does anyone know of a way to get a higher resolution from within a j2me application and/or how to access the native camera from within another application?</p>
[ { "answer_id": 242582, "author": "izb", "author_id": 974, "author_profile": "https://Stackoverflow.com/users/974", "pm_score": 1, "selected": false, "text": "jpg = mVideoControl.getSnapshot(\"encoding=jpeg&quality=100&width=2048&height=1536\");\n" }, { "answer_id": 347403, "a...
2008/10/28
[ "https://Stackoverflow.com/questions/241882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8207/" ]
241,892
<p>I'm investigating SUDS as a SOAP client for python. I want to inspect the methods available from a specified service, and the types required by a specified method.</p> <p>The aim is to generate a user interface, allowing users to select a method, then fill in values in a dynamically generated form.</p> <p>I can get some information on a particular method, but am unsure how to parse it:</p> <pre><code>client = Client(url) method = client.sd.service.methods['MyMethod'] </code></pre> <p>I am unable to <strong>programmaticaly</strong> figure out what object type I need to create to be able to call the service</p> <pre><code>obj = client.factory.create('?') res = client.service.MyMethod(obj, soapheaders=authen) </code></pre> <p>Does anyone have some sample code?</p>
[ { "answer_id": 1842812, "author": "artdanil", "author_id": 214178, "author_profile": "https://Stackoverflow.com/users/214178", "pm_score": 4, "selected": false, "text": "suds" }, { "answer_id": 1858144, "author": "sj26", "author_id": 158252, "author_profile": "https:/...
2008/10/28
[ "https://Stackoverflow.com/questions/241892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18138/" ]
241,897
<p>How do I alternate HTML table row colors using JSP?</p> <p>My CSS looks something like:</p> <pre><code>tr.odd {background-color: #EEDDEE} tr.even {background-color: #EEEEDD} </code></pre> <p>I want to use <code>&lt;c:forEach&gt;</code> to iterate over a collection. </p> <pre><code>&lt;c:forEach items="${element}" var="myCollection"&gt; &lt;tr&gt; &lt;td&gt;&lt;c:out value="${element.field}"/&gt;&lt;/td&gt; ... &lt;/tr&gt; &lt;/c:forEach&gt; </code></pre> <p>I need an int count variable or boolean odd/even variable to track the row. Then my <code>&lt;tr&gt;</code> tag would look something like:</p> <pre><code>&lt;tr class="odd or even depending on the row"&gt; </code></pre>
[ { "answer_id": 241917, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 1, "selected": false, "text": "counter = 0\nforeach (elements)\n counter = counter + 1\n output: <tr class=\"row{counter % 2}\">...</tr>\n" }, { ...
2008/10/28
[ "https://Stackoverflow.com/questions/241897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
241,925
<p>I have a number of generated .sql files that I want to run in succession. I'd like to run them from a SQL statement in a query (i.e. Query Analyzer/Server Management Studio).<br> Is it possible to do something like this and if so what is the syntax for doing this?</p> <p>I'm hoping for something like:</p> <pre><code>exec 'c:\temp\file01.sql' exec 'c:\temp\file02.sql' </code></pre> <p>I am using SQL Server 2005 and running queries in management studio.</p>
[ { "answer_id": 241940, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 7, "selected": true, "text": "EXEC xp_cmdshell 'sqlcmd -S ' + @DBServerName + ' -d ' + @DBName + ' -i ' + @FilePathName\n" }, { "answer_id":...
2008/10/28
[ "https://Stackoverflow.com/questions/241925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25719/" ]
241,936
<p>The deceptively simple foundation of dynamic code generation within a C/C++ framework has already been covered in <a href="https://stackoverflow.com/questions/45408/">another question</a>. Are there any gentle introductions into topic with code examples? </p> <p>My eyes are starting to bleed staring at highly intricate open source JIT compilers when my needs are much more modest.</p> <p>Are there good texts on the subject that don't assume a doctorate in computer science? I'm looking for well worn patterns, things to watch out for, performance considerations, etc. Electronic or tree-based resources can be equally valuable. You can assume a working knowledge of (not just x86) assembly language.</p>
[ { "answer_id": 241997, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 3, "selected": true, "text": "typedef void (*code_ptr)();\nunsigned long instruction_pointer = entry_point;\nstd::map<unsigned long, code_ptr> code_ma...
2008/10/28
[ "https://Stackoverflow.com/questions/241936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1892/" ]
241,953
<p>I'm using an <em>Edit in Place</em> jquery plugin which needs to post the data to a script that will do the actual database update.</p> <p>The URL to this update script is easily viewable in the html source as well as with Firebug, so I need to add some sort of authentication check before the update is processed. This is of course so the user can't just pass in any old userid / field / value they want and mess with other people's records.</p> <p>I was initially passing their username and password in as well, but this isn't ideal as it's in a GET request so it's all in the URL. The site itself is SSL at least, but still not a best practice by any stretch.</p> <p>What's the best way to authenticate this type of update?</p> <p>FWIW, the update script is in PHP, and the Edit in Place plugin is: <a href="http://www.appelsiini.net/projects/jeditable" rel="nofollow noreferrer">jeditable</a>.</p> <p><strong>Edit:</strong> To clarify: The actual data payload is POSTed to the script, but the edit in place plugin has no explicit method for authentication, so I was passing the authentication as part of the URL to the update script, which was then taking those variables via GET and using them to check.</p> <p><strong>Edit 2:</strong> Yes, I can access the session info from the update script, so I've decided to just pull the previously saved User ID and using that in the db update statement. That would appear to be the most secure method.</p>
[ { "answer_id": 242008, "author": "Már Örlygsson", "author_id": 16271, "author_profile": "https://Stackoverflow.com/users/16271", "pm_score": 2, "selected": false, "text": "submitdata" }, { "answer_id": 378336, "author": "akaihola", "author_id": 15770, "author_profile"...
2008/10/28
[ "https://Stackoverflow.com/questions/241953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
241,955
<p>I find myself writing code that looks like this a lot:</p> <pre><code>set&lt;int&gt; affected_items; while (string code = GetKeyCodeFromSomewhere()) { if (code == "some constant" || code == "some other constant") { affected_items.insert(some_constant_id); } else if (code == "yet another constant" || code == "the constant I didn't mention yet") { affected_items.insert(some_other_constant_id); } // else if etc... } for (set&lt;int&gt;::iterator it = affected_items.begin(); it != affected_items.end(); it++) { switch(*it) { case some_constant_id: RunSomeFunction(with, these, params); break; case some_other_constant_id: RunSomeOtherFunction(with, these, other, params); break; // etc... } } </code></pre> <p>The reason I end up writing this code is that I need to only run the functions in the second loop once even if I've received multiple key codes that might cause them to run.</p> <p>This just doesn't seem like the best way to do it. Is there a neater way?</p>
[ { "answer_id": 241972, "author": "Don Neufeld", "author_id": 13097, "author_profile": "https://Stackoverflow.com/users/13097", "pm_score": 2, "selected": true, "text": "// Ahead of time you build a static map from your strings to bit values.\nstd::map< std::string, int > codesToValues;\n...
2008/10/28
[ "https://Stackoverflow.com/questions/241955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20889/" ]
241,960
<p>How do I drop a Groovlet into a Grails app? Say, for example, in web-app/groovlet.groovy</p> <pre> import java.util.Date if (session == null) { session = request.getSession(true); } if (session.counter == null) { session.counter = 1 } println """ &lt;html> &lt;head> &lt;title>Groovy Servlet&lt;/title> &lt;/head> &lt;body> Hello, ${request.remoteHost}: Counter: ${session.counter}! Date: ${new Date()} &lt;br> """ </pre>
[ { "answer_id": 242030, "author": "kolrie", "author_id": 14540, "author_profile": "https://Stackoverflow.com/users/14540", "pm_score": 0, "selected": false, "text": "class DateController {\n def index = {\n if (session == null) {\n session = request.getSession(true);\n ...
2008/10/28
[ "https://Stackoverflow.com/questions/241960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
241,964
<p>How to set internationalization to a <code>DateTimepicker</code> or <code>Calendar WinForm</code> control in .Net when the desire culture is different to the one installed in the PC?</p>
[ { "answer_id": 242010, "author": "Hapkido", "author_id": 27646, "author_profile": "https://Stackoverflow.com/users/27646", "pm_score": 0, "selected": false, "text": "dtp.Format = DateTimePickerFormat.Custom;\ndtp.CustomFormat = \"yyyy-MM-dd\"; // or the format you prefer\n" }, { ...
2008/10/28
[ "https://Stackoverflow.com/questions/241964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14440/" ]
241,967
<p>I am playing with the new stuff of C#3.0 and I have this code (mostly taken from <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx" rel="noreferrer">MSDN</a>) but I can only get true,false,true... and not the real value :</p> <pre><code> int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; var oddNumbers = numbers.Select(n =&gt; n % 2 == 1); Console.WriteLine("Numbers &lt; 5:"); foreach (var x in oddNumbers) { Console.WriteLine(x); } </code></pre> <p>How can I fix that to show the list of integer?</p>
[ { "answer_id": 241975, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 6, "selected": true, "text": " int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };\n\n var oddNumbers = numbers.Where(n => n % 2 == 1);\n\n ...
2008/10/28
[ "https://Stackoverflow.com/questions/241967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
241,971
<p>i have a web service hosted on another server with the Anonymous Access CheckBox in IIS is already checked. when my local web application is trying to access the web service, i still get the "The request failed with HTTP status 401: Access Denied." error. my web application is calling the web service like the following:</p> <p>MyObject.WebService ws = new MyObject.WebService (); ws.Retrieve(someParams);</p> <p>what am i missing here?</p>
[ { "answer_id": 242088, "author": "Vlad N", "author_id": 28472, "author_profile": "https://Stackoverflow.com/users/28472", "pm_score": 0, "selected": false, "text": "MyObject.WebService ws = new MyObject.WebService(); \nws.PreAuthenticate = true;\nresponse = ws.Retrieve(someParams);\n" ...
2008/10/28
[ "https://Stackoverflow.com/questions/241971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31936/" ]
241,989
<p>When I restart my apache2 and reload a page, the log file shows</p> <pre><code>boogie.tontut.fi - - [28/Oct/2008:03:27:49 +0200] "GET /test HTTP/1.1" 404 457 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3" </code></pre> <p>...as supposed to, as it's <code>03:27:49</code> now. However, when I click the refresh button again, the new log entry is:</p> <pre><code>boogie.tontut.fi - - [27/Oct/2008:21:27:52 -0400] "GET /test HTTP/1.1" 404 457 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3" </code></pre> <p>Offset has changed from <code>+0200 to -0400</code> and I have no clue where this comes from.</p> <p>How can I start troubleshooting this problem?</p>
[ { "answer_id": 242011, "author": "Kevin Hakanson", "author_id": 22514, "author_profile": "https://Stackoverflow.com/users/22514", "pm_score": 0, "selected": false, "text": "httpd.conf" }, { "answer_id": 242138, "author": "Martin Redmond", "author_id": 30541, "author_p...
2008/10/28
[ "https://Stackoverflow.com/questions/241989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30141/" ]
241,991
<p>We have a weird intermittent problem with saving from Word 2007 to our SharePoint 2007 (MOSS) document libraries that gives a dialog box that never goes away - it is titled "Content Types" and the message "Getting list of available content types..." with a green progress-type bar that keeps scrolling. It happens a lot on our training server (self-contained virtual machine with separate SQL Server) but more worryingly is happening on our live production server (which is in a medium server farm arrangement - web application server, another server for search/indexing and a SQL Server). All servers in the farms are 64 bit.</p> <p>It is strangely random - the user has to kill Word 2007, then they recover their document and try to save to the same document library and it saves without a problem. </p> <p>It happens more on the training server than the live server. The live web application server rarely goes over 20% CPU (usually around 5%) and memory peaks at 2Gb of the available 4Gb (usually at 1.5Gb) so I don't think its a resources issue. </p> <p>The document libraries are customised and deployed using Features in a Solution. The only content type in them is the standard Documents content type. </p> <p><strong>Update</strong> We opened this with Microsoft as a support issue and it is a known issue that is targeted to be addressed in a Cumulative Update hotfix package for SharePoint in February 2009.</p> <p><em>Edit</em> Copied the above response to an answer so this question could be flagged as answered.</p>
[ { "answer_id": 242011, "author": "Kevin Hakanson", "author_id": 22514, "author_profile": "https://Stackoverflow.com/users/22514", "pm_score": 0, "selected": false, "text": "httpd.conf" }, { "answer_id": 242138, "author": "Martin Redmond", "author_id": 30541, "author_p...
2008/10/28
[ "https://Stackoverflow.com/questions/241991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20977/" ]
241,994
<p>This is something that I have always wondered about, but never bothered to profile.</p> <p>Is it more efficient to assign a value to a temp variable, than to keep using that value. An Example may be clearer:</p> <pre><code>string s = reader.GetItem[0].ToString(); someClass.SomeField = s; someOtherClass.someField = s; </code></pre> <p>OR</p> <pre><code>someClass.SomeField = reader.GetItem[0].ToString(); someOtherClass.someField = reader.GetItem[0].ToString(); </code></pre> <p>My initial thought would the top example would be more efficient as it doesn't have to access the Item collection or call ToString.</p> <p>Would be interested to hear other peoples ideas, or definitive answer either way.</p>
[ { "answer_id": 242007, "author": "Johann Gerell", "author_id": 6345, "author_profile": "https://Stackoverflow.com/users/6345", "pm_score": 0, "selected": false, "text": "ToString" }, { "answer_id": 242416, "author": "Marc Gravell", "author_id": 23354, "author_profile"...
2008/10/28
[ "https://Stackoverflow.com/questions/241994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075/" ]
241,995
<p>I would like to be able to drop to the python REPL from the debugger -- if this is not possible is there an easier way to evaluate python expressions in the context of the current breakpoint other than manually adding them all as watch expressions?</p>
[ { "answer_id": 242774, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 3, "selected": true, "text": "import code\ncode.interact(local=locals())\n" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/241995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2168/" ]
242,012
<p>After looking on MSDN, it's still unclear to me how I should form a proper predicate to use the Find() method in List using a member variable of T (where T is a class)</p> <p>For example:</p> <pre><code>public class Car { public string Make; public string Model; public int Year; } { // somewhere in my code List&lt;Car&gt; carList = new List&lt;Car&gt;(); // ... code to add Cars ... Car myCar = new Car(); // Find the first of each car made between 1980 and 2000 for (int x = 1980; x &lt; 2000; x++) { myCar = carList.Find(byYear(x)); Console.Writeline(myCar.Make + myCar.Model); } } </code></pre> <p>What should my "byYear" predicate look like? </p> <p>(The MSDN example only talks about a List of dinosaurs and only searches for an unchanging value "saurus" -- It doesn't show how to pass a value into the predicate...)</p> <p>EDIT: I'm using VS2005/.NET2.0, so I don't think Lambda notation is available to me...</p> <p>EDIT2: Removed "1999" in the example because I may want to "Find" programatically based on different values. Example changed to range of cars from 1980 to 2000 using for-do loop.</p>
[ { "answer_id": 242020, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 2, "selected": false, "text": "Func<int, Predicate<Car>> byYear = i => (c => c.Year == i);\n" }, { "answer_id": 242024, "author": "Dan Finu...
2008/10/28
[ "https://Stackoverflow.com/questions/242012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21244/" ]
242,032
<p>Is there a way to get the directory of a project in Eclipse? We are writing a plugin that will allow the user to select files, and then run some processes on those files. I would ideally like to be able to get all the files with a certain extension, but that is not necessary.</p>
[ { "answer_id": 242075, "author": "AdamC", "author_id": 16476, "author_profile": "https://Stackoverflow.com/users/16476", "pm_score": 4, "selected": true, "text": "ResourcesPlugin.getWorkspace().getRoot().getProjects()\n" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17712/" ]
242,065
<p>I have been enjoying learning the basics of python, but before I started reading things I tried to install various python versions and modules clumsily. Now that I have some ideas of what I want to do and how to do it I'm finding that various aspects are broken. For instance, 2.6 IDLE won't launch, and when I try to import modules they usually don't work.</p> <p>My question is, how would you recommend I clean this up and start fresh? I have read information about modifying the 2.6 install, but I still can't get it to work.</p> <p>IDLE 2.4 works, and when I launch python from the terminal I am running python 2.4.4.</p>
[ { "answer_id": 248884, "author": "orestis", "author_id": 32617, "author_profile": "https://Stackoverflow.com/users/32617", "pm_score": 1, "selected": false, "text": "which python" }, { "answer_id": 286372, "author": "dbr", "author_id": 745, "author_profile": "https://...
2008/10/28
[ "https://Stackoverflow.com/questions/242065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20824/" ]
242,066
<p>I am currently validating a client's HTML Source and I am getting a lot of validation errors for images and input files which do not have the Omittag. I would do it manually but this client literally has thousands of files, with a lot of instances where the is not .</p> <p>This client has validated some img tags (for whatever reason).</p> <p>Just wondering if there is a unix command I could run to check to see if the does not have a Omittag to add it.</p> <p>I have done simple search and replaces with the following command:</p> <pre><code>find . \! -path '*.svn*' -type f -exec sed -i -n '1h;1!H;${;g;s/&lt;b&gt;/&lt;strong&gt;/g;p}' {} \; </code></pre> <p>But never something this large. Any help would be appreciated.</p>
[ { "answer_id": 242374, "author": "Anirvan", "author_id": 31100, "author_profile": "https://Stackoverflow.com/users/31100", "pm_score": 2, "selected": false, "text": ".orig" }, { "answer_id": 242377, "author": "joelhardi", "author_id": 11438, "author_profile": "https:/...
2008/10/28
[ "https://Stackoverflow.com/questions/242066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
242,073
<p>This is similar to <a href="https://stackoverflow.com/questions/18932/sql-how-can-i-remove-duplicate-rows">this question</a>, but it seems like some of the answers there aren't quite compatible with MySQL (or I'm not doing it right), and I'm having a heck of a time figuring out the changes I need. Apparently my SQL is rustier than I thought it was. I'm also looking to change a column value rather than delete, but I think at least <b>that</b> part is simple...</p> <p>I have a table like:</p> <pre>rowid SERIAL fingerprint TEXT duplicate BOOLEAN contents TEXT created_date DATETIME</pre> <p>I want to set duplicate=true for all but the first (by created_date) of each group by fingerprint. It's easy to mark <em>all</em> of the rows with duplicate fingerprints as dupes. The part I'm getting stuck on is keeping the first.</p> <p>One of the apps that populates the table does bulk loads of data, with multiple workers loading data from different sources, and the workers' data isn't necessarily partitioned by date, so it's a pain to try to mark these all as they come in (the first one inserted isn't necessarily the first one by date). Also, I already have a bunch of data in there I'll need to clean up either way. So I'd rather just have a relatively efficient query I can run after a bulk load to clean up than try to build it into that app.</p> <p>Thanks!</p>
[ { "answer_id": 242336, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 0, "selected": false, "text": "SET @rowid := 0;\n\nUPDATE mytable\nSET duplicate = (rowid = @rowid), \n rowid = (@rowid:=rowid)\nORDER BY rowid, c...
2008/10/28
[ "https://Stackoverflow.com/questions/242073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
242,079
<p>In Java, we can always use an array to store object reference. Then we have an ArrayList or HashTable which is automatically expandable to store objects. But does anyone know a native way to have an auto-expandable array of object references?</p> <p>Edit: What I mean is I want to know if the Java API has some class with the ability to store references to objects (but not storing the actual object like XXXList or HashTable do) AND the ability of auto-expansion.</p>
[ { "answer_id": 242093, "author": "Kevin Day", "author_id": 10973, "author_profile": "https://Stackoverflow.com/users/10973", "pm_score": 4, "selected": true, "text": "String myStrings[10];\n" }, { "answer_id": 242844, "author": "mtruesdell", "author_id": 6479, "author...
2008/10/28
[ "https://Stackoverflow.com/questions/242079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8203/" ]
242,097
<p>What's a more elegant way of having the code below where i want to return a derived class based on the type of another class.</p> <pre><code> if (option_ is Rectangle) { modelInputs = new Foo(); } else if (option_ is Circle) { modelInputs = new Bar(); } else if (option_ is Triangle) { modelInputs = new Bar2(); } </code></pre>
[ { "answer_id": 242109, "author": "mmiika", "author_id": 6846, "author_profile": "https://Stackoverflow.com/users/6846", "pm_score": 4, "selected": true, "text": "interface IHasModelInput\n{\n IModelInput GetModelInput();\n}\n" }, { "answer_id": 242198, "author": "Andrew St...
2008/10/28
[ "https://Stackoverflow.com/questions/242097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
242,118
<p>Assuming a Perl script that allows users to specify several text filter expressions in a config file, is there a safe way to let them enter regular expressions as well, without the possibility of unintended side effects or code execution? Without actually parsing the regexes and checking them for problematic constructs, that is. There won't be any substitution, only matching.</p> <p>As an aside, is there a way to test if the specified regex is valid before actually using it? I'd like to issue warnings if something like <code>/foo (bar/</code> was entered.</p> <p>Thanks, Z.</p> <p><hr> EDIT:<br> Thanks for the very interesting answers. I've since found out that the following dangerous constructs will only be evaluated in regexes if the <code>use re 'eval'</code> pragma is used:</p> <pre><code>(?{code}) (??{code}) ${code} @{code} </code></pre> <p>The default is <code>no re 'eval'</code>; so unless I'm missing something, it should be safe to read regular expressions from a file, with the only check being the eval/catch posted by Axeman. At least I haven't been able to hide anything evil in them in my tests.</p> <p>Thanks again. Z.</p>
[ { "answer_id": 242122, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "(?{ code })\n" }, { "answer_id": 242132, "author": "Axeman", "author_id": 11289, "author_profile": "h...
2008/10/28
[ "https://Stackoverflow.com/questions/242118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31682/" ]
242,143
<p>I am using WCF to upload data to a server.</p> <p>If the communication fails, is there any way to resume the upload?</p>
[ { "answer_id": 242122, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "(?{ code })\n" }, { "answer_id": 242132, "author": "Axeman", "author_id": 11289, "author_profile": "h...
2008/10/28
[ "https://Stackoverflow.com/questions/242143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
242,147
<p>I have just discovered the nifty unhandled exception handler for cocoa-touch.</p> <p>Now that I can gracefully notify the user about any unhandled exceptions that might crash my application, I'd like to shut down my application after notifying the user that a crash has occured.</p> <p>Does anyone know how to shut down an application programmatically?</p>
[ { "answer_id": 242388, "author": "Rich", "author_id": 22003, "author_profile": "https://Stackoverflow.com/users/22003", "pm_score": 2, "selected": false, "text": "exit(0);\n" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8918/" ]
242,160
<p>How is profiling different from logging?</p> <p>Is it just that profiling is used for performance measurements to see how long each function takes? Or am I off?</p> <p>Typically, how are profiling libraries used?</p> <p>What types of stats are obtained by profiling?</p>
[ { "answer_id": 242166, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 6, "selected": true, "text": "if" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
242,172
<blockquote> <p><strong>Edit:</strong> The code here still has some bugs in it, and it could do better in the performance department, but instead of trying to fix this, for the record I took the problem over to the Intel discussion groups and got lots of great feedback, and if all goes well a polished version of Atomic float will be included in a near future release of Intel's Threading Building Blocks</p> </blockquote> <p>Ok here's a tough one, I want an Atomic float, not for super-fast graphics performance, but to use routinely as data-members of classes. And I don't want to pay the price of using locks on these classes, because it provides no additional benefits for my needs. </p> <p>Now with intel's tbb and other atomic libraries I've seen, integer types are supported, but not floating points. So I went on and implemented one, and it works... but I'm not sure if it REALLY works, or I'm just very lucky that it works.</p> <p>Anyone here knows if this is not some form of threading heresy?</p> <pre><code>typedef unsigned int uint_32; struct AtomicFloat { private: tbb::atomic&lt;uint_32&gt; atomic_value_; public: template&lt;memory_semantics M&gt; float fetch_and_store( float value ) { const uint_32 value_ = atomic_value_.tbb::atomic&lt;uint_32&gt;::fetch_and_store&lt;M&gt;((uint_32&amp;)value); return reinterpret_cast&lt;const float&amp;&gt;(value_); } float fetch_and_store( float value ) { const uint_32 value_ = atomic_value_.tbb::atomic&lt;uint_32&gt;::fetch_and_store((uint_32&amp;)value); return reinterpret_cast&lt;const float&amp;&gt;(value_); } template&lt;memory_semantics M&gt; float compare_and_swap( float value, float comparand ) { const uint_32 value_ = atomic_value_.tbb::atomic&lt;uint_32&gt;::compare_and_swap&lt;M&gt;((uint_32&amp;)value,(uint_32&amp;)compare); return reinterpret_cast&lt;const float&amp;&gt;(value_); } float compare_and_swap(float value, float compare) { const uint_32 value_ = atomic_value_.tbb::atomic&lt;uint_32&gt;::compare_and_swap((uint_32&amp;)value,(uint_32&amp;)compare); return reinterpret_cast&lt;const float&amp;&gt;(value_); } operator float() const volatile // volatile qualifier here for backwards compatibility { const uint_32 value_ = atomic_value_; return reinterpret_cast&lt;const float&amp;&gt;(value_); } float operator=(float value) { const uint_32 value_ = atomic_value_.tbb::atomic&lt;uint_32&gt;::operator =((uint_32&amp;)value); return reinterpret_cast&lt;const float&amp;&gt;(value_); } float operator+=(float value) { volatile float old_value_, new_value_; do { old_value_ = reinterpret_cast&lt;float&amp;&gt;(atomic_value_); new_value_ = old_value_ + value; } while(compare_and_swap(new_value_,old_value_) != old_value_); return (new_value_); } float operator*=(float value) { volatile float old_value_, new_value_; do { old_value_ = reinterpret_cast&lt;float&amp;&gt;(atomic_value_); new_value_ = old_value_ * value; } while(compare_and_swap(new_value_,old_value_) != old_value_); return (new_value_); } float operator/=(float value) { volatile float old_value_, new_value_; do { old_value_ = reinterpret_cast&lt;float&amp;&gt;(atomic_value_); new_value_ = old_value_ / value; } while(compare_and_swap(new_value_,old_value_) != old_value_); return (new_value_); } float operator-=(float value) { return this-&gt;operator+=(-value); } float operator++() { return this-&gt;operator+=(1); } float operator--() { return this-&gt;operator+=(-1); } float fetch_and_add( float addend ) { return this-&gt;operator+=(-addend); } float fetch_and_increment() { return this-&gt;operator+=(1); } float fetch_and_decrement() { return this-&gt;operator+=(-1); } }; </code></pre> <p>Thanks!</p> <p><strong>Edit:</strong> changed size_t to uint32_t as Greg Rogers suggested, that way its more portable</p> <p><strong>Edit:</strong> added listing for the entire thing, with some fixes.</p> <p><strong>More Edits:</strong> Performance wise using a locked float for 5.000.000 += operations with 100 threads on my machine takes 3.6s, while my atomic float even with its silly do-while takes 0.2s to do the same work. So the >30x performance boost means its worth it, (and this is the catch) if its correct.</p> <p><strong>Even More Edits:</strong> As Awgn pointed out my <code>fetch_and_xxxx</code> parts were all wrong. Fixed that and removed parts of the API I'm not sure about (templated memory models). And implemented other operations in terms of operator += to avoid code repetition</p> <p><strong>Added:</strong> Added operator *= and operator /=, since floats wouldn't be floats without them. Thanks to Peterchen's comment that this was noticed</p> <p><strong>Edit:</strong> Latest version of the code follows (I'll leave the old version for reference though)</p> <pre><code> #include &lt;tbb/atomic.h&gt; typedef unsigned int uint_32; typedef __TBB_LONG_LONG uint_64; template&lt;typename FLOATING_POINT,typename MEMORY_BLOCK&gt; struct atomic_float_ { /* CRC Card ----------------------------------------------------- | Class: atmomic float template class | | Responsability: handle integral atomic memory as it were a float, | but partially bypassing FPU, SSE/MMX, so it is | slower than a true float, but faster and smaller | than a locked float. | *Warning* If your float usage is thwarted by | the A-B-A problem this class isn't for you | *Warning* Atomic specification says we return, | values not l-values. So (i = j) = k doesn't work. | | Collaborators: intel's tbb::atomic handles memory atomicity ----------------------------------------------------------------*/ typedef typename atomic_float_&lt;FLOATING_POINT,MEMORY_BLOCK&gt; self_t; tbb::atomic&lt;MEMORY_BLOCK&gt; atomic_value_; template&lt;memory_semantics M&gt; FLOATING_POINT fetch_and_store( FLOATING_POINT value ) { const MEMORY_BLOCK value_ = atomic_value_.tbb::atomic&lt;MEMORY_BLOCK&gt;::fetch_and_store&lt;M&gt;((MEMORY_BLOCK&amp;)value); //atomic specification requires returning old value, not new one return reinterpret_cast&lt;const FLOATING_POINT&amp;&gt;(value_); } FLOATING_POINT fetch_and_store( FLOATING_POINT value ) { const MEMORY_BLOCK value_ = atomic_value_.tbb::atomic&lt;MEMORY_BLOCK&gt;::fetch_and_store((MEMORY_BLOCK&amp;)value); //atomic specification requires returning old value, not new one return reinterpret_cast&lt;const FLOATING_POINT&amp;&gt;(value_); } template&lt;memory_semantics M&gt; FLOATING_POINT compare_and_swap( FLOATING_POINT value, FLOATING_POINT comparand ) { const MEMORY_BLOCK value_ = atomic_value_.tbb::atomic&lt;MEMORY_BLOCK&gt;::compare_and_swap&lt;M&gt;((MEMORY_BLOCK&amp;)value,(MEMORY_BLOCK&amp;)compare); //atomic specification requires returning old value, not new one return reinterpret_cast&lt;const FLOATING_POINT&amp;&gt;(value_); } FLOATING_POINT compare_and_swap(FLOATING_POINT value, FLOATING_POINT compare) { const MEMORY_BLOCK value_ = atomic_value_.tbb::atomic&lt;MEMORY_BLOCK&gt;::compare_and_swap((MEMORY_BLOCK&amp;)value,(MEMORY_BLOCK&amp;)compare); //atomic specification requires returning old value, not new one return reinterpret_cast&lt;const FLOATING_POINT&amp;&gt;(value_); } operator FLOATING_POINT() const volatile // volatile qualifier here for backwards compatibility { const MEMORY_BLOCK value_ = atomic_value_; return reinterpret_cast&lt;const FLOATING_POINT&amp;&gt;(value_); } //Note: atomic specification says we return the a copy of the base value not an l-value FLOATING_POINT operator=(FLOATING_POINT rhs) { const MEMORY_BLOCK value_ = atomic_value_.tbb::atomic&lt;MEMORY_BLOCK&gt;::operator =((MEMORY_BLOCK&amp;)rhs); return reinterpret_cast&lt;const FLOATING_POINT&amp;&gt;(value_); } //Note: atomic specification says we return an l-value when operating among atomics self_t&amp; operator=(self_t&amp; rhs) { const MEMORY_BLOCK value_ = atomic_value_.tbb::atomic&lt;MEMORY_BLOCK&gt;::operator =((MEMORY_BLOCK&amp;)rhs); return *this; } FLOATING_POINT&amp; _internal_reference() const { return reinterpret_cast&lt;FLOATING_POINT&amp;&gt;(atomic_value_.tbb::atomic&lt;MEMORY_BLOCK&gt;::_internal_reference()); } FLOATING_POINT operator+=(FLOATING_POINT value) { FLOATING_POINT old_value_, new_value_; do { old_value_ = reinterpret_cast&lt;FLOATING_POINT&amp;&gt;(atomic_value_); new_value_ = old_value_ + value; //floating point binary representation is not an issue because //we are using our self's compare and swap, thus comparing floats and floats } while(self_t::compare_and_swap(new_value_,old_value_) != old_value_); return (new_value_); //return resulting value } FLOATING_POINT operator*=(FLOATING_POINT value) { FLOATING_POINT old_value_, new_value_; do { old_value_ = reinterpret_cast&lt;FLOATING_POINT&amp;&gt;(atomic_value_); new_value_ = old_value_ * value; //floating point binary representation is not an issue becaus //we are using our self's compare and swap, thus comparing floats and floats } while(self_t::compare_and_swap(new_value_,old_value_) != old_value_); return (new_value_); //return resulting value } FLOATING_POINT operator/=(FLOATING_POINT value) { FLOATING_POINT old_value_, new_value_; do { old_value_ = reinterpret_cast&lt;FLOATING_POINT&amp;&gt;(atomic_value_); new_value_ = old_value_ / value; //floating point binary representation is not an issue because //we are using our self's compare and swap, thus comparing floats and floats } while(self_t::compare_and_swap(new_value_,old_value_) != old_value_); return (new_value_); //return resulting value } FLOATING_POINT operator-=(FLOATING_POINT value) { return this-&gt;operator+=(-value); //return resulting value } //Prefix operator FLOATING_POINT operator++() { return this-&gt;operator+=(1); //return resulting value } //Prefix operator FLOATING_POINT operator--() { return this-&gt;operator+=(-1); //return resulting value } //Postfix operator FLOATING_POINT operator++(int) { const FLOATING_POINT temp = this; this-&gt;operator+=(1); return temp//return resulting value } //Postfix operator FLOATING_POINT operator--(int) { const FLOATING_POINT temp = this; this-&gt;operator+=(1); return temp//return resulting value } FLOATING_POINT fetch_and_add( FLOATING_POINT addend ) { const FLOATING_POINT old_value_ = atomic_value_; this-&gt;operator+=(addend); //atomic specification requires returning old value, not new one as in operator x= return old_value_; } FLOATING_POINT fetch_and_increment() { const FLOATING_POINT old_value_ = atomic_value_; this-&gt;operator+=(+1); //atomic specification requires returning old value, not new one as in operator x= return old_value_; } FLOATING_POINT fetch_and_decrement() { const FLOATING_POINT old_value_ = atomic_value_; this-&gt;operator+=(-1); //atomic specification requires returning old value, not new one as in operator x= return old_value_; } }; typedef atomic_float_&lt;float,uint_32&gt; AtomicFloat; typedef atomic_float_&lt;double,uint_64&gt; AtomicDouble; </code></pre>
[ { "answer_id": 242178, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "sizeof(size_t) == sizeof(float)" }, { "answer_id": 242210, "author": "Greg Rogers", "author_id": 5963, ...
2008/10/28
[ "https://Stackoverflow.com/questions/242172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
242,177
<p>I understand object oriented programming, and have been writing OO programs for a long time. People seem to talk about aspect-oriented programming, but I've never really learned what it is or how to use it. What is the basic paradigm?</p> <p>This question is related, but doesn't quite ask it:</p> <p><a href="https://stackoverflow.com/questions/232884/aspect-oriented-programming-vs-object-oriented-programming">Aspect-Oriented Programming vs. Object Oriented Programming</a></p>
[ { "answer_id": 242194, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 9, "selected": true, "text": "function mainProgram()\n{ \n var x = foo();\n doSomethingWith(x);\n return x;\n}\n\naspect logging\n{ \n before...
2008/10/28
[ "https://Stackoverflow.com/questions/242177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31952/" ]
242,181
<p>I have a form with several checkboxes which values are pulled from a database. I managed to display them in the form, assign an appropriate value to each, but cannot insert their values into other database.</p> <p>Here's the code:</p> <pre><code>&lt;form id=&quot;form1&quot; name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot;&gt; &lt;?php $info_id = $_GET['info_id']; $kv_dodatoci = mysql_query(&quot;SELECT * FROM `dodatoci`&quot;) or die('ERROR DISPLAYING: ' . mysql_error()); while ($kol = mysql_fetch_array($kv_dodatoci)){ $id_dodatoci = $kol['id_dodatoci']; $mk = $kol['mk']; echo '&lt;input type=&quot;checkbox&quot; name=&quot;id_dodatoci[]&quot; id=&quot;id_dodatoci&quot; value=&quot;' . $id_dodatoci . '&quot; /&gt;'; echo '&lt;label for=&quot;' . $id_dodatoci.'&quot;&gt;' . $mk . '&lt;/label&gt;&lt;br /&gt;'; } ?&gt; &lt;input type=&quot;hidden&quot; value=&quot;&lt;?=$info_id?&gt;&quot; name=&quot;info_id&quot; /&gt; &lt;input name=&quot;insert_info&quot; type=&quot;submit&quot; value=&quot;Insert Additional info&quot; /&gt; &lt;/form&gt; &lt;?php if (isset($_POST['insert_info']) &amp;&amp; is_array($id_dodatoci)) { echo $id_dodatoci . '&lt;br /&gt;'; echo $mk . '&lt;br /&gt;'; // --- Guess here's the problem ----- // foreach ($_POST['id_dodatoci'] as $dodatok) { $dodatok_kv = mysql_query(&quot;INSERT INTO `dodatoci_hotel` (id_dodatoci, info_id) VALUES ('$dodatok', '$info_id')&quot;) or die('ERROR INSERTING: '.mysql_error()); } } </code></pre> <p>My problem is to loop through all checkboxes, and for each checked, populate a separate record in a database. Actually I don't know how to recognize the which box is checked, and put the appropriate value in db.</p>
[ { "answer_id": 242215, "author": "Eli", "author_id": 27580, "author_profile": "https://Stackoverflow.com/users/27580", "pm_score": 2, "selected": false, "text": "<input type='checkbox' name='ShowCloseWindowLink' value='1'/> Show the 'Close Window' link at the bottom of the form.\n" }, ...
2008/10/28
[ "https://Stackoverflow.com/questions/242181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
242,182
<p>I have a page with a "Print" link that takes the user to a printer-friendly page. The client wants a print dialog box to appear automatically when the user arrives at the print-friendly page. How can I do this with javascript?</p>
[ { "answer_id": 242190, "author": "Mark", "author_id": 26310, "author_profile": "https://Stackoverflow.com/users/26310", "pm_score": 9, "selected": true, "text": "window.print(); \n" }, { "answer_id": 242192, "author": "mmiika", "author_id": 6846, "author_profile": "h...
2008/10/28
[ "https://Stackoverflow.com/questions/242182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
242,255
<p>If I have class names such as "left", "right", "clear" and xhtml like</p> <pre><code>&lt;a href="index.php" class="right continueLink"&gt;Continue&lt;/a&gt; </code></pre> <p>With CSS like</p> <pre><code>.right { float: right; } </code></pre> <p>I know it's not a semantic name, but it does make things much easier sometimes.</p> <p>Anyway, what are your thoughts?</p>
[ { "answer_id": 242277, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 5, "selected": true, "text": ".right" }, { "answer_id": 242325, "author": "eyelidlessness", "author_id": 17964, "author_profile": "ht...
2008/10/28
[ "https://Stackoverflow.com/questions/242255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
242,264
<p>I am digging into LINQ--trying to understand basic models (it seems pretty cool to me). The code below is the code to perform before committing an update. </p> <pre><code> Linq01.Account acc = context.Accounts.Single( pc =&gt; pc.AccountID == AccountID ); acc.Name = textboxAccountNameRead.Text.Trim(); context.SubmitChanges(); </code></pre> <p>So far, so good. But what do you do if the Single() method failed--if the account ID wasn't found? </p> <p>Thank you!</p>
[ { "answer_id": 242266, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 4, "selected": true, "text": "SingleOrDefault" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2536/" ]
242,276
<p>I have an embedded flash that is transparent so it looks like part of the background. I achieved that by setting wmode to transparent.</p> <p>My problem is that the area underneath the flash becomes inaccessible, even though the flash is transparent. Therefore I cannot click on any links or buttons that are under the flash object.</p> <p>How do I make the flash unobtrusive?</p> <p>Clarifications: <br> - the flash is transparent but it has an animation that shows in the background.<br> - wmode set to transparent lets you click the contents underneath in IE but not Firefox.</p>
[ { "answer_id": 242308, "author": "joelhardi", "author_id": 11438, "author_profile": "https://Stackoverflow.com/users/11438", "pm_score": 4, "selected": true, "text": "object" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/131/" ]
242,282
<p>Are there any html helpers for page navigation. eg. if i have 1000 records to display, i want to display the Previous 1 2 3 4 ... etc Next link stuff under the filtered collection.</p> <p>Anyone know of anything out there?</p>
[ { "answer_id": 249367, "author": "µBio", "author_id": 9796, "author_profile": "https://Stackoverflow.com/users/9796", "pm_score": 0, "selected": false, "text": "public string Render()\n{\n var buffer = new StringBuilder( 1000 );\n buffer.AppendLine( @\"<ul class=\"\"datatable_pager...
2008/10/28
[ "https://Stackoverflow.com/questions/242282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
242,284
<p>While surfing, I came to know that somebody has done Tower of Hanoi using vim. WOW!!!</p> <p>Can you people share what all cool things you have been doing in vim.</p> <p>Edit: Not sure about the Tower of Hanoi solution using vim being all that useful. But I think this question should be re-opened to allow people to comment on any useful things that they've done using vim. For me? See my answer below. (-:</p>
[ { "answer_id": 245329, "author": "Diomidis Spinellis", "author_id": 20520, "author_profile": "https://Stackoverflow.com/users/20520", "pm_score": 3, "selected": false, "text": "system \"$vimrt\\\\gvim.exe\", qq{ \n -c \"edit /tmp/tmpcode.$ext \" \n -c \"source $vimrt/syntax/2html.vim\...
2008/10/28
[ "https://Stackoverflow.com/questions/242284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29405/" ]
242,286
<p>Mine would have to be the float and margin bugs...</p> <p>If you float an element, and then specify a margin for it, it will double the margin.</p> <p>The solution to this is to add <code>display: inline</code> to the element. This will stop the double margin, and all other browsers will ignore it because only block level objects can be floated.</p>
[ { "answer_id": 358172, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": 2, "selected": false, "text": "<td><img src=\"myimage.jpg\"></td>\n" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
242,295
<blockquote> <p><strong>EDIT</strong>: This question duplicates <a href="https://stackoverflow.com/questions/110175/how-to-access-the-current-subversion-build-number#111173">How to access the current Subversion build number?</a> (Thanks for the heads up, Charles!)</p> </blockquote> <p>Hi there,</p> <p>This question is similar to <a href="https://stackoverflow.com/questions/16248/getting-the-subversion-repository-number-into-code">Getting the subversion repository number into code</a></p> <p>The differences being:</p> <ol> <li><p>I would like to add the revision number to Python</p></li> <li><p>I want the revision of the repository (not the checked out file)</p></li> </ol> <p>I.e. I would like to extract the Revision number from the return from 'svn info', likeso:</p> <p>$ svn info</p> <pre><code>Path: . URL: svn://localhost/B/trunk Repository Root: svn://localhost/B Revision: 375 Node Kind: directory Schedule: normal Last Changed Author: bmh Last Changed Rev: 375 Last Changed Date: 2008-10-27 12:09:00 -0400 (Mon, 27 Oct 2008) </code></pre> <p>I want a variable with 375 (the Revision). It's easy enough with put $Rev$ into a variable to keep track of changes on a file. However, I would like to keep track of the repository's version, and I understand (and it seems based on my tests) that $Rev$ only updates when the file changes.</p> <p>My initial thoughts turn to using the svn/libsvn module built in to Python, though I can't find any documentation on or examples of how to use them.</p> <p>Alternatively, I've thought calling 'svn info' and regex'ing the code out, though that seems rather brutal. :)</p> <p>Help would be most appreciated.</p> <p>Thanks &amp; Cheers.</p>
[ { "answer_id": 242327, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 1, "selected": false, "text": "svnRev=$(echo \"$(svn info)\" | grep \"^Revision\" | awk -F\": \" '{print $2};')\necho $svnRev\n" }, { "answer_id": ...
2008/10/28
[ "https://Stackoverflow.com/questions/242295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19212/" ]
242,304
<p>I'm running Windows Server 2008 64-bit "workstation" and would like to get <a href="http://msdn.microsoft.com/en-us/library/ms164699%28v=vs.80%29.aspx" rel="nofollow noreferrer">corflags.exe</a>. Which SDK do I need to download? </p> <p>I know about <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=1AEF6FCE-6E06-4B66-AFE4-9AAD3C835D3D&amp;displaylang=en#Overview" rel="nofollow noreferrer">.NET Framework 2.0 Software Development Kit (SDK) (x64)</a> and <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&amp;displaylang=en" rel="nofollow noreferrer">Windows SDK for Windows Server 2008 and .NET Framework 3.5</a> but I was hoping to find something smaller as these are quite large downloads.</p> <p>Also the note about 2.0 SDK seems to suggest to download the 3.5 one, should I follow that?</p>
[ { "answer_id": 2456723, "author": "antiplex", "author_id": 294930, "author_profile": "https://Stackoverflow.com/users/294930", "pm_score": 3, "selected": false, "text": "coreflags.exe" }, { "answer_id": 45020509, "author": "langlauf.io", "author_id": 4480139, "author_...
2008/10/28
[ "https://Stackoverflow.com/questions/242304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6846/" ]
242,314
<p>Using gnuplot 4.2, is it possible to obtain the value of a specific column/row and use that value somehow?</p> <p>For example, let's say my datafile contains the following</p> <pre><code>#1 2 7 13 5 11 23 17 53 12 </code></pre> <p>For a simple plot where column 1 is the x axis and column 2 is the y axis I would:-</p> <pre><code>plot 'datafile' using 1:2 </code></pre> <p>What I'm trying to do is to normalize the all data in column 2 by the first element in that column (13). Is there a way to do this in gnuplot itself (i.e., without resorting to a scripting language or something to preprocess the data first)?</p> <p>Cheers</p>
[ { "answer_id": 28361017, "author": "Jonatan Lindén", "author_id": 167319, "author_profile": "https://Stackoverflow.com/users/167319", "pm_score": 3, "selected": false, "text": "base" }, { "answer_id": 71218187, "author": "Vikram Govindarajan", "author_id": 10584300, "...
2008/10/28
[ "https://Stackoverflow.com/questions/242314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11688/" ]
242,320
<p>Is there a way to bind a Generic List to a multicolumn listbox, yes listbox...I know but this is what I am stuck with and can't add a grid or listview.</p> <p>Thanks</p>
[ { "answer_id": 242408, "author": "Alexander Prokofyev", "author_id": 11256, "author_profile": "https://Stackoverflow.com/users/11256", "pm_score": 3, "selected": true, "text": "List<int> list = new List<int> { 1, 2, 4, 8, 16 };\nlistBox1.DataSource = list;\n" }, { "answer_id": 13...
2008/10/28
[ "https://Stackoverflow.com/questions/242320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
242,341
<p>I'm writing a utility to export evernote notes into Outlook on a schedule. The Outlook API's need plain text, and Evernote outputs a XHTML doc version of the plain text note. What I need is to strip out all the Tags and unescape the source XHTML doc embedded in the Evernote export file.</p> <p>Basically I need to turn;</p> <pre><code>&lt;note&gt; &lt;title&gt;Test Sync Note 1&lt;/title&gt; &lt;content&gt; &lt;![CDATA[ &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml.dtd"&gt; &lt;en-note bgcolor="#FFFFFF"&gt; &lt;div&gt;Test Sync Note 1&lt;/div&gt; &lt;div&gt;This i has some text in it&lt;/div&gt; &lt;div&gt;&amp;nbsp;&lt;/div&gt; &lt;div&gt;&amp;nbsp;&lt;/div&gt; &lt;div&gt;and a second line&lt;/div&gt; &lt;/en-note&gt; ]]&gt; &lt;/content&gt; &lt;created&gt;20081028T045727Z&lt;/created&gt; &lt;updated&gt;20081028T051346Z&lt;/updated&gt; &lt;tag&gt;Test&lt;/tag&gt; &lt;/note&gt; </code></pre> <p>Into </p> <pre> Test Sync Note 1 This i has some text in it and a second line </pre> <p>I can easily parse out the CDATA section and get just the 4 lines of text, but I need a reliable way to strip the div's, unescape and deal with any extra HTML that might have snuck in there.</p> <p>I'm assuming that there's some MS API combo that will do the job, but I don't know it.</p>
[ { "answer_id": 242379, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 0, "selected": false, "text": " string xml = @\"<note>\n <title>Test Sync Note 1</title> \n <content>\n <![CDATA[...
2008/10/28
[ "https://Stackoverflow.com/questions/242341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
242,344
<p>I want this page to return 200 whilst still sending the redirect...</p> <pre><code>&lt;script&gt; sub page_load 'Get the parameters dim content As String content = request.querystring("text") response.redirect ("http://100.200.100.10/test1/Default.aspx?CommandParm=" + content) end sub &lt;/script&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;form runat="server"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 242358, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 0, "selected": false, "text": "Response.Redirect()" }, { "answer_id": 242370, "author": "Ray Lu", "author_id": 11413, "author_profile...
2008/10/28
[ "https://Stackoverflow.com/questions/242344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
242,363
<p>I want create a drop shadow around the canvas component in flex. Technically speaking it will not be a shadow, as I want it to wrap around the component giving the component a floating look. I may be able to do it with glow, but can anyone drop an line or two who has already done it?</p> <p>Thanks in advance.</p>
[ { "answer_id": 242373, "author": "Mozammel", "author_id": 20165, "author_profile": "https://Stackoverflow.com/users/20165", "pm_score": 3, "selected": true, "text": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<mx:Canvas xmlns:mx=\"http://www.adobe.com/2006/mxml\" \n width=\"780\"...
2008/10/28
[ "https://Stackoverflow.com/questions/242363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20165/" ]
242,367
<p>I am developing iPhone application and In that application I've one <code>TableViewController</code>, and that <code>TableViewController</code> made up of Custom table cell.<br> into those cell I am loading image from URL, but the <code>scrolling</code> is not that smooth, (because each cell load images every time when scrolling happen).</p> <p>So I decided to store those images into application document folder, but I don't know how to use document folder in iPhone when application is in running state.</p> <p>Any suggestion?</p> <p>And on other forums I found that SQLITE has blob datatype to store binary data,</p> <p>Which method is efficient, document folder or sqlite to store image?</p>
[ { "answer_id": 242528, "author": "leonho", "author_id": 30883, "author_profile": "https://Stackoverflow.com/users/30883", "pm_score": 0, "selected": false, "text": "NSFileManager" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/451867/" ]
242,383
<p>I want to autowire a bean partially - that is, I want some args to be autowired but other to be explicitly set. For example:</p> <p>public MyClient(Service svc, boolean b)</p> <p>In the case of this constructor, I would like to specify in my xml the value for b, but have svc autowired. Is that possible?</p> <p>Thanks, Lowell</p>
[ { "answer_id": 242443, "author": "NR.", "author_id": 11701, "author_profile": "https://Stackoverflow.com/users/11701", "pm_score": 2, "selected": false, "text": "public MyClient() {}\n\n@Autowired\npublic setService (Service svc) {...}\n\npublic setBoolean (boolean b) {...}\n" }, { ...
2008/10/28
[ "https://Stackoverflow.com/questions/242383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22063/" ]
242,393
<p>I have the following classes</p> <pre><code>public interface InterfaceBase { } public class ImplementA:InterfaceBase { } public class ImplementB:InterfaceBase { } public void TestImplementType&lt;T&gt;(T obj) where T: InterfaceBase { } </code></pre> <p>How to infer what the T is whether ImplementA or ImplementB? I tried to use </p> <pre><code>typeof(T) is ImplementA </code></pre> <p>but this expression is always evaluated to false. </p> <p>Edit: And how am I going to cast obj to ImplementA or ImplementB?</p>
[ { "answer_id": 242395, "author": "Toby", "author_id": 291137, "author_profile": "https://Stackoverflow.com/users/291137", "pm_score": 3, "selected": true, "text": "obj is ImplementA" }, { "answer_id": 242396, "author": "Andrew Stapleton", "author_id": 28506, "author_p...
2008/10/28
[ "https://Stackoverflow.com/questions/242393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
242,404
<p>Four 2D points in an array. I need to sort them in clockwise order. I think it can be done with just one swap operation but I have not been able to put this down formally.</p> <p><strike>Edit: The four points are a convex polygon in my case.</strike></p> <p>Edit: The four points are the vertices of a convex polygon. They need not be in order.</p>
[ { "answer_id": 242469, "author": "Agnel Kurian", "author_id": 45603, "author_profile": "https://Stackoverflow.com/users/45603", "pm_score": 0, "selected": false, "text": "// Take signed area of ABC.\n// If negative,\n// Swap B and C.\n// Otherwise,\n// Take signed area of ACD.\n/...
2008/10/28
[ "https://Stackoverflow.com/questions/242404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45603/" ]
242,406
<p>So I have action_mailer_optional_tls (<a href="http://svn.douglasfshearer.com/rails/plugins/action_mailer_optional_tls" rel="nofollow noreferrer">http://svn.douglasfshearer.com/rails/plugins/action_mailer_optional_tls</a>) and this in my enviroment.rb</p> <pre><code>ActionMailer::Base.server_settings = { :tls =&gt; true, :address =&gt; "smtp.gmail.com", :port =&gt; "587", :domain =&gt; "www.somedomain.com", :authentication =&gt; :plain, :user_name =&gt; "someusername", :password =&gt; "somepassword" } </code></pre> <p>But now what If I want to send emails from different email accounts? How do I override the user_name and password fields on the fly?</p> <p>What Im looking for is a solution which allows dynamic switching between accounts. Example the following scenario: 10 "Admins" can send out notices to our customers. Each has their own gmail account, when they fill out a form on the site rails connects using their account and sends the mail.</p> <p>Thanks in advance!</p> <p>Ali</p>
[ { "answer_id": 244343, "author": "Daniel Beardsley", "author_id": 13216, "author_profile": "https://Stackoverflow.com/users/13216", "pm_score": 1, "selected": false, "text": "before_filter :load_email_settings\n\ndef load_email_settings\n ActionMailer::Base.server_settings.merge!(:user_...
2008/10/28
[ "https://Stackoverflow.com/questions/242406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31975/" ]
242,417
<p>I have two lists that are of the same length, is it possible to loop through these two lists at once?</p> <p>I am looking for the correct syntax to do the below</p> <pre><code>foreach itemA, itemB in ListA, ListB { Console.WriteLine(itemA.ToString()+","+itemB.ToString()); } </code></pre> <p>do you think this is possible in C#? And if it is, what is the lambda expression equivalent of this?</p>
[ { "answer_id": 242420, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": false, "text": "IEnumerable<T>" }, { "answer_id": 242422, "author": "jcelgin", "author_id": 26582, "author_profil...
2008/10/28
[ "https://Stackoverflow.com/questions/242417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
242,421
<p>I am trying to execute this SQL query prior to restoring a .BAK file in SQL Express. Initially, I had the file on the Desktop of my user account. I am logged in as Administrator.</p> <p>When I try to access the .BAK file on the desktop like this</p> <pre><code>RESTORE FILELISTONLY FROM DISK= 'C:\Documents and Settings\Administrator\Desktop\file.bak' </code></pre> <p>I get an error.</p> <pre>Msg 3201, Level 16, State 2, Line 1 Cannot open backup device 'C:\Documents and Settings\Administrator\Desktop\file.bak'. Operating system error 5(Access is denied.). Msg 3013, Level 16, State 1, Line 1 RESTORE FILELIST is terminating abnormally.</pre> <p>However, when I move the .BAK file to <code>C:\temp</code>, and execute this </p> <pre><code>RESTORE FILELISTONLY FROM DISK= 'C:\temp\file.bak' </code></pre> <p>It works just fine.</p> <p>I cant figure out what is going on. Is there a way to access files on Desktop using Windows Authentication with SQL Express?</p>
[ { "answer_id": 53519678, "author": "Marcello Miorelli", "author_id": 1501497, "author_profile": "https://Stackoverflow.com/users/1501497", "pm_score": 0, "selected": false, "text": "select * from\nsys.dm_server_services\n\nSELECT DSS.servicename,\n DSS.startup_type_desc,\n ...
2008/10/28
[ "https://Stackoverflow.com/questions/242421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31979/" ]
242,424
<p>I know how to move a layer based on touch. But I would also like to be able to rotate the image. </p> <p>Is there any sample code that shows how to do this? Or can anyone give me some advice?</p> <p>Thanks!</p>
[ { "answer_id": 242858, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 5, "selected": true, "text": "float angle = M_PI; //rotate 180°, or 1 π radians\nlayer.transform = CATransform3DMakeRotation(angle, 0, 0.0, 1.0);\n...
2008/10/28
[ "https://Stackoverflow.com/questions/242424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23695/" ]
242,438
<p>I've a performance related question regarding use of StringBuilder. In a very long loop I'm manipulating a <code>StringBuilder</code> and passing it to another method like this:</p> <pre><code>for (loop condition) { StringBuilder sb = new StringBuilder(); sb.append("some string"); . . . sb.append(anotherString); . . . passToMethod(sb.toString()); } </code></pre> <p>Is instantiating <code>StringBuilder</code> at every loop cycle is a good solution? And is calling a delete instead better, like the following?</p> <pre><code>StringBuilder sb = new StringBuilder(); for (loop condition) { sb.delete(0, sb.length); sb.append("some string"); . . . sb.append(anotherString); . . . passToMethod(sb.toString()); } </code></pre>
[ { "answer_id": 242449, "author": "Peter", "author_id": 26483, "author_profile": "https://Stackoverflow.com/users/26483", "pm_score": 5, "selected": false, "text": "for (loop condition) {\n StringBuilder sb = new StringBuilder(4096);\n}\n" }, { "answer_id": 242455, "author": ...
2008/10/28
[ "https://Stackoverflow.com/questions/242438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27789/" ]
242,444
<p>I have a little pet web app project I'd like to show someone who doesn't have an application server themselves (and who has no clue about application servers).</p> <p>What is the easiest and quickest way for them to get my WAR file running with zero configuration, preferably something I could send along with or bundle with the WAR file? Is there a slimmed down version of Jetty, for example? Something else?</p>
[ { "answer_id": 242476, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 3, "selected": true, "text": "* servlet-api-2.5-6.x.jar\n* jetty-util-6.x.jar\n* jetty-6.x.jar\n\n\n/usr/local/jetty-6.1.4/lib> ls -la servlet-api-...
2008/10/28
[ "https://Stackoverflow.com/questions/242444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
242,453
<p>I am trying to compare two decimal values in Java script. I have two objects as one assogned value "3" and the other as "3.00". When i say if (obj1 == obj2) it does not pass the condition as it is does the string comparision. </p> <p>I would instead want it to do a decimal comparision where 3 = 3.00. Please let me know how to do this.</p>
[ { "answer_id": 242461, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 0, "selected": false, "text": "if(parseFloat(obj1) == parseFloat(obj2)) { // ...\n" }, { "answer_id": 242464, "author": "Vincent Ramdh...
2008/10/28
[ "https://Stackoverflow.com/questions/242453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20951/" ]
242,468
<p>In my ASP.NET application I have a web.config file. In the web.config file I have a connection string...</p> <pre><code>&lt;connectionStrings&gt; &lt;add name="HRDb" connectionString="xxxxx" providerName="System.Data.SqlClient" /&gt; &lt;/connectionStrings&gt; </code></pre> <p>Yet, when I retrieve this value using <code>ConfigurationManager.ConnectionStringsp["HRDb"]</code>, I get the my old connection string, not the new one.</p> <p>Where else (apart from web.config) does the <code>ConfigurationManager</code> read connection string values from?</p> <p>I'm running the application from VS.NET (not deployed to IIS).</p>
[ { "answer_id": 242490, "author": "Rune Grimstad", "author_id": 30366, "author_profile": "https://Stackoverflow.com/users/30366", "pm_score": 1, "selected": false, "text": "<clear />" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22702/" ]
242,485
<p>This is a question I have wondered about for quite some time, yet I have never found a suitable solution. If I run a script and I come across, let's say an IndexError, python prints the line, location and quick description of the error and exits. Is it possible to automatically start pdb when an error is encountered? I am not against having an extra import statement at the top of the file, nor a few extra lines of code.</p>
[ { "answer_id": 242506, "author": "monkut", "author_id": 24718, "author_profile": "https://Stackoverflow.com/users/24718", "pm_score": 5, "selected": false, "text": "testlist = [1,2,3,4,5, 0]\n\nprev_i = None\nfor i in testlist:\n if not prev_i:\n prev_i = i\n else:\n ...
2008/10/28
[ "https://Stackoverflow.com/questions/242485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24530/" ]
242,504
<p>How can I generate a report in access with the data from a recordset (instead of a query or table). I have updates to the recordset that also must be shown in the report.</p>
[ { "answer_id": 243544, "author": "BIBD", "author_id": 685, "author_profile": "https://Stackoverflow.com/users/685", "pm_score": 3, "selected": true, "text": "Private Sub Report_Open(Cancel As Integer)\n Me.RecordSource = gMyRecordSet.Name\nEnd Sub\n" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
242,517
<p>I have a certain application which feeds information into an object, after comparing the new information to the old information. It goes something like</p> <pre><code>set { oldval=_value; _value=value; if (some comparison logic) raiseEvent(); } </code></pre> <p>This all happens on a background thread, in an infinite loop, which intermittently sleeps for 100ms. The really odd part is that it works the first time, the comparison logic turns up true, and the event is raised. After that, the information keeps flowing, it keep entering the object, I know this because I set MessageBoxes to display the old and new values all the time, but its as if it somehow bypasses the set clause! I set a messagebox in the beginning of the clause, an it just doesn't pop up! This is really wierd, since I am sure that the value keeps updating.</p> <p>Any Thoughts?</p> <hr> <p>Yeah, I know, but unfortunately theres not much more I can show... Let me try to explain the overall structure again: I have a separate background thread running an infinite loop. This loop continuously pulls data from a Data object, which is updated by a whole other set of threads. All of this is of course under synchronization with Monitor.Enter and Exit. The data pulled from the Data object is then inputted into the Comparer object.</p> <pre><code>while(true) { Thread.Sleep(100); Monitor.Enter(Data); Comparer.Value = Data.Value; Monitor.Exit(Data); } </code></pre> <p>The Comparer.Value is the property I mentioned in the first post. Its really quite weird since I set up a MessageBox in the end of the loop:</p> <pre><code>MessageBox.Show(Comparer.Value + " - " + Data.Value); </code></pre> <p>and the values DO actually update, it just somehow seems to bypass the set clause, which is impossible... This is truly weird.</p> <p>And Rob, the loop doesn't do any of the checking, it just simulates a stream of information into Comparer.Value; It's set clause contains the comparison logic.</p> <p>bh213, I'm pretty that it is, but I can't tell because the comparison stops before any meaningful checking is done.</p> <hr> <p>Alright, I've solved the problem, apparently my question was wrong, the problem was in a whole other place. Thanks for all the help, the question may be closed.</p>
[ { "answer_id": 242521, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "void SomeHandler(object sender, EventArgs args)\n{\n this.Invoke((MethodInvoker)delegate {\n this.Text = \"S...
2008/10/28
[ "https://Stackoverflow.com/questions/242517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30884/" ]
242,529
<p>I just saw the anouncement for the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=922B4655-93D0-4476-BDA4-94CF5F8D4814&amp;displaylang=en" rel="nofollow noreferrer">Visual Studio CTP</a> today, and am currently waiting for all those files to download...</p> <p>Have you already tried the CTP, or maybe a previous version? What are your thoughts? There is another question <a href="https://stackoverflow.com/questions/206943/what-features-would-you-most-like-to-see-in-visual-studio-2010">What features would you most like to see in Visual Studio 2010</a>, now here it is, what do you think?</p>
[ { "answer_id": 463967, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "dynamic" } ]
2008/10/28
[ "https://Stackoverflow.com/questions/242529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
242,534
<pre><code>private const int THE_ANSWER = 42; </code></pre> <p>or</p> <pre><code>private const int theAnswer = 42; </code></pre> <p>Personally I think with modern IDEs we should go with camelCase as ALL_CAPS looks strange. What do you think?</p>
[ { "answer_id": 242539, "author": "dove", "author_id": 30913, "author_profile": "https://Stackoverflow.com/users/30913", "pm_score": 4, "selected": false, "text": "private const int Answer = 42;\n" }, { "answer_id": 242545, "author": "bh213", "author_id": 28912, "autho...
2008/10/28
[ "https://Stackoverflow.com/questions/242534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6846/" ]
242,538
<p>Basically I need to run the script with paths related to the shell script file location, how can I change the current directory to the same directory as where the script file resides?</p>
[ { "answer_id": 242550, "author": "TheMarko", "author_id": 31099, "author_profile": "https://Stackoverflow.com/users/31099", "pm_score": 10, "selected": true, "text": "#!/usr/bin/env bash\n\nBASEDIR=$(dirname \"$0\")\necho \"$BASEDIR\"\n" }, { "answer_id": 242557, "author": "M...
2008/10/28
[ "https://Stackoverflow.com/questions/242538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16371/" ]