qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
285,775
<p>One of my columns is called <code>from</code>. I can't change the name because I didn't make it. Am I allowed to do something like <code>SELECT from FROM TableName</code> or is there a special syntax to avoid the SQL Server being confused?</p>
[ { "answer_id": 285777, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 10, "selected": true, "text": "from" }, { "answer_id": 285783, "author": "John Baughman", "author_id": 26923, "author_profile": "h...
2008/11/12
[ "https://Stackoverflow.com/questions/285775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25645/" ]
285,782
<p>I have been using git for several months in a project developed only by myself. I have a local repository and push it regularly to github for backup purposes.</p> <p>I want to add another developer to this project, however I will have the responsibility of integrating the whole project.</p> <p>What is the recommended workflow? </p> <p>Do we need a private and a public repository for each developer?</p> <p>If the github repository is the main one, does the other developer have to clone this repository or the repository in my computer?</p> <p>Should he have the right to push in my repository or should I pull from his repository?</p>
[ { "answer_id": 285803, "author": "Chris Vest", "author_id": 13251, "author_profile": "https://Stackoverflow.com/users/13251", "pm_score": 3, "selected": false, "text": "git format-patch" } ]
2008/11/12
[ "https://Stackoverflow.com/questions/285782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14755/" ]
285,790
<pre><code>while (xxx) { timeout.tv_sec=TIMEOUT; timeout.tv_usec=0; FD_ZERO(&amp;set); FD_SET(sd,&amp;set); switch (select(FD_SETSIZE,&amp;set,NULL,NULL,&amp;timeout)) xxxxx } </code></pre> <p>works fine, however</p> <pre><code>FD_ZERO(&amp;set); FD_SET(sd,&amp;set); while (xxx) { timeout.tv_sec=TIMEOUT; timeout.tv_usec=0; switch (select(FD_SETSIZE,&amp;set,NULL,NULL,&amp;timeout)) xxxxx } </code></pre> <p>doesn't. It works the first time around, but the next time it runs through the while loop it gets a timeout even if the sd socket receives data. It seems to me to be a waste of resources to have to empty and fill set every time.</p> <p>Anybody have a good explanation why this is, and even better, perhaps a suggestion how to avoid it?</p>
[ { "answer_id": 286231, "author": "DGentry", "author_id": 4761, "author_profile": "https://Stackoverflow.com/users/4761", "pm_score": 5, "selected": true, "text": "switch (select((sd + 1),&set,NULL,NULL,&timeout))\n" } ]
2008/11/12
[ "https://Stackoverflow.com/questions/285790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37169/" ]
285,793
<p>Eclipse issues warnings when a <code>serialVersionUID</code> is missing. </p> <blockquote> <p>The serializable class Foo does not declare a static final serialVersionUID field of type long</p> </blockquote> <p>What is <code>serialVersionUID</code> and why is it important? Please show an example where missing <code>serialVersionUID</code> will cause a problem.</p>
[ { "answer_id": 285809, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 12, "selected": true, "text": "java.io.Serializable" }, { "answer_id": 285827, "author": "Scott Bale", "author_id": 2495576, "autho...
2008/11/12
[ "https://Stackoverflow.com/questions/285793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33203/" ]
285,816
<p>I want to add items in a LaTeX-document. Say for example, that I want add hints to the document. I create a command, so I can call something similar to this:</p> <pre><code>\hint{foocareful}{Be careful with foo!}{foo is a very precious item and can easily be broken. Be careful, especially don't throw foo.} </code></pre> <p>This will be formatted in special way, to make it easy for the reader to recognize it as a hint. It gets a label, that can be referenced in the example with 'foocareful'.</p> <p>In the appendix I want to add a list of all hints with references to them. Something like:</p> <pre><code>\begin{enumerate} ... \item Be careful with foo! (\pageref{foocareful}) ... \end{enumerate} </code></pre> <p>But naturally I don't want to maintain this list by hand. How can I create automatically such a list?</p>
[ { "answer_id": 286165, "author": "Will Robertson", "author_id": 4161, "author_profile": "https://Stackoverflow.com/users/4161", "pm_score": 4, "selected": true, "text": "float" } ]
2008/11/12
[ "https://Stackoverflow.com/questions/285816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
285,818
<p>With Java Version 1.5.0_06 on both Windows and Ubuntu Linux :</p> <p>Whenever I add minutes to the date "2008/10/05 00:00:00" , it seems that an extra hour is wrongly added.</p> <p>ie: adding 360 minutes to 2008/10/05 00:00:00 at midnight should arrive at 2008/10/05 06:00:00</p> <p>But it is arriving at 2008/10/05 07:00:00</p> <p>The totally perplexing thing is that this <strong>ONLY</strong> happens when the day is 2008/10/05, all other days that I try perform the minutes addition correctly. </p> <p>Am I going crazy or is this a bug in Java ?</p> <pre><code> SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); try { String date = "2008/10/05 00:00:00"; int minutesToAdd = 360; // 6 hrs Calendar cal = Calendar.getInstance(); cal.setTime(sdf.parse(date)); cal.add(Calendar.MINUTE, minutesToAdd); System.out.println(cal.getTime()); } catch (ParseException e) {} </code></pre>
[ { "answer_id": 68963768, "author": "Ole V.V.", "author_id": 5772882, "author_profile": "https://Stackoverflow.com/users/5772882", "pm_score": 0, "selected": false, "text": "private static final DateTimeFormatter PARSER\n = DateTimeFormatter.ofPattern(\"yyyy/MM/dd HH:mm:ss\", Local...
2008/11/12
[ "https://Stackoverflow.com/questions/285818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27262/" ]
285,829
<p>I'd like to use the DataGridView control as a list with columns. Sort of like ListView in Details mode but I want to keep the DataGridView flexibility.</p> <p><strong>ListView</strong> (with <em>Details</em> view and <em>FullRowSelect</em> enabled) highlights the whole line and shows the focus mark around the whole line:<br> <img src="https://i361.photobucket.com/albums/oo51/Stark3000/ListView_row.png" alt="selected row in ListView control"></p> <p><strong>DataGridView</strong> (with <em>SelectionMode</em> = <em>FullRowSelect</em>) displays focus mark only around a single cell:<br> <img src="https://i361.photobucket.com/albums/oo51/Stark3000/DataGridView_row.png" alt="selected row in DataGridView"></p> <p>So, does anyone know of some (ideally) easy way to make the DataGridView row selection look like the ListView one?<br> I'm not looking for a changed behaviour of the control - I only want it to look the same.<br> Ideally, without messing up with the methods that do the actual painting.</p>
[ { "answer_id": 331438, "author": "Tomas Sedovic", "author_id": 2239, "author_profile": "https://Stackoverflow.com/users/2239", "pm_score": 7, "selected": true, "text": "dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;\ndgv.MultiSelect = false;\ndgv.RowPrePaint +=new DataGridV...
2008/11/12
[ "https://Stackoverflow.com/questions/285829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2239/" ]
285,837
<p>My company is in the process of rewriting our software from scratch, and I'm the one who is going to be doing most of the work in rewriting the Mac client (The core of our software is Windows based, and the Mac client communicates with it through a webservice).</p> <p>This isn't a real heavy app, mainly does some background work tracking stuff and a UI component for the user to enter information.</p> <p>I'm trying to decide how hard I should argue for dropping support for 10.4 and going with pure 10.5+/Obj-C 2.0 code.</p> <p>My main motivations for this are:</p> <ul> <li><p>It would be easier to code, I could use all the features of Obj-C 2.0 such as synthesized properties and fast enumeration.</p></li> <li><p>It would give me access to several classes, and methods in existing classes, that don't exist in 10.4 (Just in mocking up a UI I've come across NSPathControl and NSTreeNode, both of which I would otherwise be very happy to use.</p></li> <li><p>Preparing for the conversion to 64 bit coming in Snow Leopard. It seems like most of the techniques for <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/Cocoa64BitGuide/64BitChangesCocoa/chapter_3_section_2.html#//apple_ref/doc/uid/TP40004247-CH4-DontLinkElementID_1" rel="nofollow noreferrer">preparing for the move to 64 bit</a> (NSInteger, etc) are only available in 10.5+, and it would not be possible to use these if writing for 10.4.</p></li> </ul> <p>The downside would of course be that we'd no longer be supporting an operating system that was only a year out of date.</p> <p>My boss is himself supportive of this move, but of course has our customers to consider and doesn't want to cause any more issues for them than are justified. The director of support would like to support 10.4. I suspect the other execs will be marginally against it at first, just due to the not being able to support some customers thing. Everybody would be open to persuasion by a good argument from either side.</p> <p>I'm trying to talk to some of the support people and get an idea of how many of our customers are actually still using 10.4, but I don't have that data yet.</p> <p>Some kind of hybrid solution might be possible, such as rewriting parts of the old client to use the new webservice, or writing the client in 10.5 and backporting it to 10.4 if enough people made a fuss, but quite frankly those sound like they're likely to be even more trouble than giving up the 10.5 features and writing the code in 10.4 to begin with.</p> <p>So I guess my questions are as follows:</p> <ol> <li><p>Given the information above, do you think making a case for the adoption of 10.5+ only is the right thing to do? Do you have any suggestions as to how this might be presented positively to the rest of the company?</p></li> <li><p>I don't know as much about the coming 64 bit transition as I'd like. Does anybody have any good references on what will be different, and do you think that supporting only 10.5+ would make this transition easier for us?</p></li> </ol>
[ { "answer_id": 285878, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 1, "selected": false, "text": "NSTask" } ]
2008/11/12
[ "https://Stackoverflow.com/questions/285837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
285,860
<p>Using Java, how can I test that a URL is contactable, and returns a valid response?</p> <pre><code>http://stackoverflow.com/about </code></pre>
[ { "answer_id": 285862, "author": "brasskazoo", "author_id": 6340, "author_profile": "https://Stackoverflow.com/users/6340", "pm_score": 7, "selected": true, "text": "public void testURL() throws Exception {\n String strUrl = \"http://stackoverflow.com/about\";\n\n try {\n UR...
2008/11/12
[ "https://Stackoverflow.com/questions/285860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6340/" ]
285,866
<p>I want to create an Ant buildfile, that includes some files as a sort of plugin.</p> <p>So if I want to activate a feature in a project - say pmd-checking - I copy a pmd.xml in a directory and the build.xml get on the start the idea, that pmd.xml exists and imports it, so that new targets can be available to the build.</p> <p>But the 'import' task can only be used as a top-level task, so I have no idea how to relize this functionality. Is this possible with Ant and if so, how can I do it?</p> <p>EDIT: I would prefer a solution, that allows new targets to show up in the listing presented by <code>ant -p</code>.</p>
[ { "answer_id": 285951, "author": "Miguel Ping", "author_id": 22992, "author_profile": "https://Stackoverflow.com/users/22992", "pm_score": 2, "selected": false, "text": "<ant antfile=\"plugins/pmd.xml\" target=\"${pmd-target}\"/>\n" }, { "answer_id": 286008, "author": "sblund...
2008/11/12
[ "https://Stackoverflow.com/questions/285866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
285,869
<p>Does anyone know how to use the <a href="http://msdn.microsoft.com/en-us/library/ms645543(VS.85).aspx" rel="nofollow noreferrer">Raw Input</a> facility on Windows from a WX Python application?</p> <p>What I need to do is be able to differentiate the input from multiple keyboards. So if there is another way to achieving that, that would work too.</p>
[ { "answer_id": 307018, "author": "joeforker", "author_id": 36330, "author_profile": "https://Stackoverflow.com/users/36330", "pm_score": 3, "selected": true, "text": ">>> import ctypes\n>>> ctypes.windll.user32.RegisterRawInputDevices\n<_FuncPtr object at 0x01FCFDC8>\n" } ]
2008/11/12
[ "https://Stackoverflow.com/questions/285869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10286/" ]
285,886
<p>I'm not talking about a pointer to an instance, I want a pointer to a class itself.</p>
[ { "answer_id": 285894, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 5, "selected": true, "text": "type_info" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/285886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37181/" ]
285,889
<p>I want to create a file on the webserver dynamically in PHP.</p> <p>First I create a directory to store the file. THIS WORKS</p> <pre><code>// create the users directory and index page $dirToCreate = "..".$_SESSION['s_USER_URL']; mkdir($dirToCreate, 0777, TRUE); // create the directory for the user </code></pre> <p>Now I want to create a file called index.php and write out some content into it.</p> <p>I am trying:</p> <pre><code>$ourFileName = $_SESSION['s_USER_URL']."/"."index.php"; $ourFileHandle = fopen($ourFileName, 'x') or die("can't open file"); fclose($ourFileHandle); // append data to it $ourFileHandle = fopen($ourFileName, 'a') or die("can't write to file"); $stringData = "Hi"; fwrite($ourFileHandle, $stringData); </code></pre> <p>But it never gets past the <code>$ourFileHandle = fopen($ourFileName, 'x') or die("can't open file");</code> Saying the file does not exist, but that is the point. I want to create it.</p> <p>I did some echoing and the path (/people/jason) exists and I am trying to write to /people/jason/index.php</p> <p>Does anyone have any thoughts on what I am doing wrong? </p> <p>PHP 5 on a linux server I believe.</p> <p>-Jason</p>
[ { "answer_id": 285905, "author": "Tom Haigh", "author_id": 22224, "author_profile": "https://Stackoverflow.com/users/22224", "pm_score": 4, "selected": true, "text": "$dirToCreate = \"..\".$_SESSION['s_USER_URL']; \n" }, { "answer_id": 285906, "author": "Kris", "author_id...
2008/11/13
[ "https://Stackoverflow.com/questions/285889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
285,928
<pre><code> private void activateRecords(long[] stuff) { ... api.activateRecords(Arrays.asList(specIdsToActivate)); } </code></pre> <p>Shouldn't this call to Arrays.asList return a list of <code>Long</code>s? Instead it is returning a <code>List&lt;long[]&gt;</code></p> <pre><code>public static &lt;T&gt; List&lt;T&gt; asList(T... a) </code></pre> <p>The method signature is consistent with the results, the varargs throws the entire array into the list. It's the same as <code>new ArrayList(); list.add(myArray)</code> And yes, I know it's meant to be used like this: <code>Arrays.asList(T t1, T t2, T t3)</code></p> <p>I guess what I'm getting at, is instead of the varargs form, why can't I just have my old asList method (at least I think this is how it used to work) that would take the contents and put them individually into a list? Any other <strong>clean</strong> way of doing this?</p>
[ { "answer_id": 285969, "author": "Stephen", "author_id": 37193, "author_profile": "https://Stackoverflow.com/users/37193", "pm_score": 3, "selected": false, "text": "private List<Long> array(final long[] lngs) {\n List<Long> list = new ArrayList<Long>();\n for (long l : lngs) {\n ...
2008/11/13
[ "https://Stackoverflow.com/questions/285928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/402777/" ]
285,937
<p>Is it possible to insert a row, but only if one of the values already in the table does not exist?</p> <p>I'm creating a <em>Tell A Friend</em> with referral points for an ecommerce system, where I need to insert the friend's email into the database table, but only if it doesn't already exist in the table. This is because I don't want any more than 1 person getting the referral points once the new customer signs up and purchases something. Therefore I want only one email ever once in the table.</p> <p>I'm using PHP 4 and MySql 4.1.</p>
[ { "answer_id": 285953, "author": "José Leal", "author_id": 37190, "author_profile": "https://Stackoverflow.com/users/37190", "pm_score": 1, "selected": false, "text": "try {\n mysql_query($sql);\n}\ncatch(Exception $e) {\n\n}\n" }, { "answer_id": 285957, "author": "victoriah...
2008/11/13
[ "https://Stackoverflow.com/questions/285937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
285,938
<p>Given an HTML link like</p> <pre><code>&lt;a href="urltxt" class="someclass" close="true"&gt;texttxt&lt;/a&gt; </code></pre> <p>how can I isolate the url and the text? </p> <p><strong>Updates</strong></p> <p>I'm using Beautiful Soup, and am unable to figure out how to do that. </p> <p>I did </p> <pre><code>soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(url)) links = soup.findAll('a') for link in links: print "link content:", link.content," and attr:",link.attrs </code></pre> <p>i get </p> <pre><code>*link content: None and attr: [(u'href', u'_redirectGeneric.asp?genericURL=/root /support.asp')]* ... ... </code></pre> <p>Why am i missing the content? </p> <p>edit: elaborated on 'stuck' as advised :)</p>
[ { "answer_id": 285941, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 4, "selected": true, "text": "soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(url).read())\n" }, { "answer_id": 285959, "author": "Je...
2008/11/13
[ "https://Stackoverflow.com/questions/285938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19731/" ]
285,955
<p>Does anybody have a snippet of Java that can return the newest file in a directory (or knowledge of a library that simplifies this sort of thing)?</p>
[ { "answer_id": 285987, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 1, "selected": false, "text": "import java.io.File;\nimport java.util.Arrays;\nimport java.util.Comparator;\n\n\npublic class Newest {\n public stati...
2008/11/13
[ "https://Stackoverflow.com/questions/285955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
285,960
<p>The <code>equals()</code> method of the URL class in the Java class library makes a DNS request to get the IP for the hostname, to check the two IP's for equality. This happens even for URLs that are created from the same <code>String</code>. Is there a way to avoid this internet access?</p>
[ { "answer_id": 285967, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 1, "selected": false, "text": "equals" }, { "answer_id": 285975, "author": "Rick", "author_id": 14138, "author_profile": "https://Stack...
2008/11/13
[ "https://Stackoverflow.com/questions/285960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
285,990
<p>In .Net, I found this great library, <a href="http://www.codeplex.com/htmlagilitypack" rel="noreferrer">HtmlAgilityPack</a> that allows you to easily parse non-well-formed HTML using XPath. I've used this for a couple years in my .Net sites, but I've had to settle for more painful libraries for my Python, Ruby and other projects. Is anyone aware of similar libraries for other languages?</p>
[ { "answer_id": 289167, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 4, "selected": true, "text": ">>> from elementtidy.TidyHTMLTreeBuilder import TidyHTMLTreeBuilder as TB\n>>> tb = TB()\n>>> tb.feed(\"<p>Hello world\...
2008/11/13
[ "https://Stackoverflow.com/questions/285990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30529/" ]
286,004
<p>There seem to be a decent number of <code>mod_rewrite</code> threads floating around lately with a bit of confusion over how certain aspects of it work. As a result I've compiled a few notes on common functionality, and perhaps a few annoying nuances.</p> <p>What other features / common issues have you run across using <code>mod_rewrite</code>?</p>
[ { "answer_id": 286005, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 8, "selected": false, "text": "mod_rewrite" }, { "answer_id": 1298917, "author": "Michael Ekoka", "author_id": 56974, "author_profile": "h...
2008/11/13
[ "https://Stackoverflow.com/questions/286004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4853/" ]
286,007
<p>I need to configure Tomcat memory settings as part of a larger installation, so manually configuring tomcat with the configuration app after the fact is out of the question. I thought I could just throw the JVM memory settings into the JAVA_OPTS environment variable, but I'm testing that with jconsole to see if it works and it... doesn't.</p> <p>As per the comment below, CATALINA_OPTS doesn't work either. So far, the only way I can get it to work is via the Tomcat configuration GUI, and that's not an acceptable solution for my problem.</p>
[ { "answer_id": 286011, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 3, "selected": false, "text": "CATALINA_OPTS" }, { "answer_id": 286415, "author": "kgiannakakis", "author_id": 24054, "author_profile": ...
2008/11/13
[ "https://Stackoverflow.com/questions/286007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1282409/" ]
286,021
<p>We have YouTube videos on a site and want to detect if it is likely that they will not be able to view them due to (mostly likely) company policy or otherwise.</p> <p>We have two sites:</p> <p>1) Flex / Flash 2) HTML</p> <p>I think with Flex I can attempt to download <a href="http://youtube.com/crossdomain.xml" rel="noreferrer">http://youtube.com/crossdomain.xml</a> and if it is valid XML assume the site is available</p> <p>But with HTML I don't know how to do it. I can't even think of a 'nice hack'.</p>
[ { "answer_id": 286055, "author": "Tristan Havelick", "author_id": 30529, "author_profile": "https://Stackoverflow.com/users/30529", "pm_score": 3, "selected": false, "text": "<html>\n\n<head>\n <script src=\"http://www.youtube.com/js/account.js\"></script>\n <script>\n funct...
2008/11/13
[ "https://Stackoverflow.com/questions/286021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
286,031
<p>I am trying to share DTO's from my datalayer assembly between the client and WCF service. This works using svcutil, but doesn't work when using VS2008. VS2008 generates it's own DTO objects whereas svcutil uses the shared data type.</p> <p>The svcutil parameters I used are:</p> <pre><code>"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\SvcUtil" /serializer:DataContractSerializer /language:vb /out:ServiceClient.cs /namespace:*,CommonWCF /noconfig /reference:"D:\trunk\DataLayer\bin\Debug\DataLayer.dll" /collectionType:System.Collections.Generic.List`1 http://localhost:3371/Common.svc </code></pre> <p>I read that VS2008 just calls svcutil behind the scenes, so why doesn't it work? I really want to avoid adding a manual process to the build process.</p>
[ { "answer_id": 397970, "author": "oefe", "author_id": 49793, "author_profile": "https://Stackoverflow.com/users/49793", "pm_score": 2, "selected": false, "text": "ClientFactory<T>" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24681/" ]
286,039
<p>Is there a way to get the count of rows in all tables in a MySQL database without running a <code>SELECT count()</code> on each table?</p>
[ { "answer_id": 286047, "author": "gpojd", "author_id": 28071, "author_profile": "https://Stackoverflow.com/users/28071", "pm_score": 8, "selected": false, "text": "SELECT table_name, table_rows\nFROM INFORMATION_SCHEMA.TABLES\nWHERE TABLE_SCHEMA = '**YOUR SCHEMA**';\n" }, { "answ...
2008/11/13
[ "https://Stackoverflow.com/questions/286039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37204/" ]
286,058
<p>If I have a key set of 1000, what is a suitable size for my Hash table, and how is that determined?</p>
[ { "answer_id": 286063, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "Hashtable" }, { "answer_id": 286079, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "...
2008/11/13
[ "https://Stackoverflow.com/questions/286058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36545/" ]
286,060
<p>ASP.Net 3.5 running under IIS 7 doesn't seem to allow this out of the box.</p> <pre><code> if (!EventLog.SourceExists("MyAppLog")) EventLog.CreateEventSource("MyAppLog", "Application"); EventLog myLog = new EventLog(); myLog.Source = "MyAppLog"; myLog.WriteEntry("Message"); </code></pre>
[ { "answer_id": 7848414, "author": "Chris S", "author_id": 21574, "author_profile": "https://Stackoverflow.com/users/21574", "pm_score": 5, "selected": false, "text": "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\eventlog\\Application\\MY-AWESOME-APP" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25372/" ]
286,061
<p>I seem to be losing a lot of precision with floats.</p> <p>For example I need to solve a matrix:</p> <pre><code>4.0x -2.0y 1.0z =11.0 1.0x +5.0y -3.0z =-6.0 2.0x +2.0y +5.0z =7.0 </code></pre> <p>This is the code I use to import the matrix from a text file:</p> <pre><code>f = open('gauss.dat') lines = f.readlines() f.close() j=0 for line in lines: bits = string.split(line, ',') s=[] for i in range(len(bits)): if (i!= len(bits)-1): s.append(float(bits[i])) #print s[i] b.append(s) y.append(float(bits[len(bits)-1])) </code></pre> <p>I need to solve using gauss-seidel so I need to rearrange the equations for x, y, and z:</p> <pre><code>x=(11+2y-1z)/4 y=(-6-x+3z)/5 z=(7-2x-2y)/7 </code></pre> <p>Here is the code I use to rearrange the equations. <code>b</code> is a matrix of coefficients and <code>y</code> is the answer vector:</p> <pre><code>def equations(b,y): i=0 eqn=[] row=[] while(i&lt;len(b)): j=0 row=[] while(j&lt;len(b)): if(i==j): row.append(y[i]/b[i][i]) else: row.append(-b[i][j]/b[i][i]) j=j+1 eqn.append(row) i=i+1 return eqn </code></pre> <p>However the answers I get back aren't precise to the decimal place.</p> <p>For example, upon rearranging the second equation from above, I should get:</p> <pre><code>y=-1.2-.2x+.6z </code></pre> <p>What I get is:</p> <pre><code>y=-1.2-0.20000000000000001x+0.59999999999999998z </code></pre> <p>This might not seem like a big issue but when you raise the number to a very high power the error is quite large. Is there a way around this? I tried the <code>Decimal</code> class but it does not work well with powers (i.e, <code>Decimal(x)**2</code>).</p> <p>Any ideas?</p>
[ { "answer_id": 286064, "author": "Jeremy", "author_id": 1114, "author_profile": "https://Stackoverflow.com/users/1114", "pm_score": 5, "selected": true, "text": "EDIT:" }, { "answer_id": 286119, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stacko...
2008/11/13
[ "https://Stackoverflow.com/questions/286061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338360/" ]
286,062
<p>How would I go about creating a Google map that allows the user to zoom beyond the default zoom levels for the map? Would I have to create a new map type that has a greater maximum zoom? Are there any tutorials out there that show how to do this?</p>
[ { "answer_id": 286064, "author": "Jeremy", "author_id": 1114, "author_profile": "https://Stackoverflow.com/users/1114", "pm_score": 5, "selected": true, "text": "EDIT:" }, { "answer_id": 286119, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stacko...
2008/11/13
[ "https://Stackoverflow.com/questions/286062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
286,076
<p>My question is a lot like <a href="https://stackoverflow.com/questions/80721/">this one</a>. However I'm on MySQL and I'm looking for the "lowest tech" solution that I can find. </p> <p>The situation is that I have 2 databases that should have the same data in them but they are updated primarily when they are not able to contact each other. I suspect that there is some sort of clustering or master/slave thing that would be able to sync them just fine. However in my cases that is major overkill as this is just a scratch DB for my own use.</p> <p>What is a good way to do this?</p> <p>My current approach is to have a Federated table on one of them and, every so often, stuff the data over the wire to the other with an insert/select. It get a bit convoluted trying to deal with primary keys and what not. (<code>insert ignore</code> seems to not work correctly)</p> <p>p.s. I can easily build a query that selects the rows to transfer.</p>
[ { "answer_id": 288523, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 1, "selected": true, "text": "INSERT...SELECT...ON DUPLICATE UPDATE" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
286,081
<p>When I access a wrong call to a sql server data into my application in classical ASP I get this message in my entire site: Service Unavailable. It stopped. My site is in a remote host. Don´t know what to do. What can I tell to the "support team" of them to fix that?</p>
[ { "answer_id": 286292, "author": "Cyril Gupta", "author_id": 33052, "author_profile": "https://Stackoverflow.com/users/33052", "pm_score": 1, "selected": false, "text": "Run IIS\nRight click on the node 'Application Pools' in your left sidebar.\nClick on the tab 'Health'\nRemove the chec...
2008/11/13
[ "https://Stackoverflow.com/questions/286081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22869/" ]
286,085
<p>I've installed Subversion on Ubuntu following the guide <em><a href="http://alephzarro.com/blog/2007/01/07/installation-of-subversion-on-ubuntu-with-apache-ssl-and-basicauth" rel="nofollow noreferrer">Installation of Subversion on Ubuntu, with Apache, SSL, and BasicAuth.</a></em>.</p> <p>It works, and I was able commit and create different repositories, but somehow, from time to time (sometimes minutes), when trying to do a commit, I'm forced to reset or recreate my user and password with the following command.</p> <pre><code>htpasswd2 -c -m /etc/apache2/dav_svn.passwd $AUTH_USER </code></pre> <p>Because SVN does not recognize my user/password anymore. </p> <p>I'm using TortoiseSVN as SVN Client. I would like to know why this is happening. Maybe it's a configuration issue, or maybe TortoiseSVN is sending invalid credentials, causing a locked account. Since I'm far from being an SVN expert/administrator. Are there some pointers in order to attack the problem.</p>
[ { "answer_id": 286127, "author": "ala", "author_id": 37198, "author_profile": "https://Stackoverflow.com/users/37198", "pm_score": -1, "selected": false, "text": "<domain>\\<user>" }, { "answer_id": 293726, "author": "tommym", "author_id": 37607, "author_profile": "ht...
2008/11/13
[ "https://Stackoverflow.com/questions/286085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32424/" ]
286,090
<p>The question is actually about stack overflows in C. I have an assigment that I can not get done for the life of me, I've looked at everything in the gdb and I just cant figure it.</p> <p>The question is the following:</p> <pre><code>int i,n; void confused() { printf("who called me"); exit(0); } void shell_call(char *c) { printf(" ***Now calling \"%s\" shell command *** \n",c); system(c); exit(0); } void victim_func() { int a[4]; printf("[8]:%x\n", &amp;a[8]); printf("Enter n: "); scanf("%d",&amp;n); printf("Enter %d HEX Values \n",n); for(i=0;i&lt;n;i++) scanf("%x",&amp;a[i]); printf("Done reading junk numbers\n"); } int main() { printf("ls=736c --- ps = 7370 --- cal = 6c6163\n"); printf("location of confused %x \n", confused); printf("location of shell_call %x \n", shell_call); victim_func(); printf("Done, thank you\n"); } </code></pre> <p>Ok, so I managed to get the first question correctly, which is to arbitrarily call one of the two functions not explicitly called in the main path. By the way, this has to be done while running the program without any modifications. I did this by running the program, setting <code>N</code> to <code>7</code>, which gets me to the Function Pointer of the <code>victim_func</code> frame, I write <code>a[7]</code> with the memory address of confused or <code>shell_call</code>, and it works. (I have a 64 bit machine, thats why I have to get it to 7, since the EBI pointer is 2 ints wide, instead of 1)</p> <p>My question is the following, how could I control which argument gets passed to the <code>shell_code</code> funcion? ie. how do I write a <code>string</code> to <code>char* c</code>. The whole point is executing unix commands like <strong>ps</strong> etc, by running only the program.</p> <p>I figured writing the EBI pointer with the hex representation of <strong>ps</strong> and setting the arg list of <code>shell_call</code> to that, but that didn't work. I also tried inputing <code>argsv</code> arguments and setting the arg list of <code>shell_call</code> to the <code>arg_list</code> of main, but didn't work either. </p> <p>I think the second version should work, but I believe I'm not setting the arg list of the new stack frame correctly ( I did it by writing <code>a[8]</code> to <code>0</code>, since its the first part of the function pointer, and writing <code>a[9]=736c</code> and <code>a[10]=0000</code>, but its probably not right since those are the parameters of <code>victim_func</code>. So how do I access the parameters of <code>shell_call</code>? </p>
[ { "answer_id": 292514, "author": "Nicola Bonelli", "author_id": 19630, "author_profile": "https://Stackoverflow.com/users/19630", "pm_score": 1, "selected": false, "text": "main()" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
286,091
<p>I am not a fan of using SQL*PLUS as an interface to Oracle. I usually use <a href="http://sourceforge.net/projects/yasql/" rel="noreferrer">yasql</a>, but it hasn't been updated since 2005 and can do with some improvements. A quick <a href="http://www.google.com/search?q=sql*plus+replacement" rel="noreferrer">Google search</a> shows yasql and <a href="http://www.sqlpal.com/" rel="noreferrer">SQLPal</a>. I am using linux, so SQLPal is not an option. </p> <p>Are there any alternatives out there, or am I stuck with an interface that I do not like or one that is no longer maintained? </p>
[ { "answer_id": 7433988, "author": "Николай Мишин", "author_id": 937070, "author_profile": "https://Stackoverflow.com/users/937070", "pm_score": 1, "selected": false, "text": "alias sqr='sqlsh -d DBI:Oracle:MYSERVER.COM -u USER -p PASSWORD'\n" }, { "answer_id": 54116222, "auth...
2008/11/13
[ "https://Stackoverflow.com/questions/286091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28071/" ]
286,093
<p>I want to assert that a method is called exactly one time. I'm using RhinoMocks 3.5.</p> <p>Here's what I thought would work:</p> <pre class="lang-cs prettyprint-override"><code>[Test] public void just_once() { var key = "id_of_something"; var source = MockRepository.GenerateStub&lt;ISomeDataSource&gt;(); source.Expect(x =&gt; x.GetSomethingThatTakesALotOfResources(key)) .Return(new Something()) .Repeat.Once(); var client = new Client(soure); // the first call I expect the client to use the source client.GetMeMyThing(key); // the second call the result should be cached // and source is not used client.GetMeMyThing(key); } </code></pre> <p>I want this test to fail if the second invocation of <code>GetMeMyThing()</code> calls <code>source.GetSomethingThatTakesALotOfResources()</code>.</p>
[ { "answer_id": 286125, "author": "Christopher Bennage", "author_id": 6855, "author_profile": "https://Stackoverflow.com/users/6855", "pm_score": 2, "selected": false, "text": "[Test]\npublic void just_once()\n{\n var key = \"id_of_something\";\n\n var source = MockRepository.Genera...
2008/11/13
[ "https://Stackoverflow.com/questions/286093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6855/" ]
286,096
<pre><code>typedef struct { nat id; char *data; } element_struct; typedef element_struct * element; void push(element e, queue s) { nat lt = s-&gt;length; if (lt == max_length - 1) { printf("Error in push: Queue is full.\n"); return; } else { s-&gt;contents[lt] = e; s-&gt;length = lt + 1; } } int main () { push(something_of_type_element, s); } </code></pre> <p>How would i go about formatting "<code>something_of_type_element</code>"?</p> <p>Thanks</p> <p>Notes: nat is the same as int</p>
[ { "answer_id": 286108, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 2, "selected": false, "text": "element elem = malloc(sizeof(element_struct));\nif (elem == NULL) {\n /* Handle error. */\n}\n\nelem->id = somethi...
2008/11/13
[ "https://Stackoverflow.com/questions/286096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31549/" ]
286,103
<p>Our Windows Forms application by default saves data files in a user's 'My Documents' folder (on XP) or 'Documents' folder (on Vista). We look up this location by calling:</p> <pre><code>Environment.GetFolderPath( Environment.SpecialFolder.Personal ) </code></pre> <p>We know for sure this works great for users whose personal folder is on a local disk. What we're not sure about is domain users who have Folder Redirection in effect for their profile/personal data folders.</p> <p>My question is: <strong>Does the above call properly resolve regardless of whether Folder Redirection is active?</strong></p> <p>I don't have the environment to test this out, and I haven't been able to find any definite confirmation one way or the other.</p>
[ { "answer_id": 286131, "author": "Jon Norton", "author_id": 4797, "author_profile": "https://Stackoverflow.com/users/4797", "pm_score": 1, "selected": false, "text": "Environment.GetFolderPath" }, { "answer_id": 286147, "author": "JaredPar", "author_id": 23283, "autho...
2008/11/13
[ "https://Stackoverflow.com/questions/286103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17966/" ]
286,104
<p>Before anybody asks, I am not doing any kind of screenscraping.</p> <p>I'm trying to parse an html string to find a div with a certain id. I cannot for the life of me get this to work. The following expression worked in one instance, but not in another. I'm not sure if it has to do with extra elements in the html or not.</p> <pre><code>&lt;div\s*?id=(\""|&amp;quot;|&amp;#34;)content(\""|&amp;quot;|&amp;#34;).*?&gt;\s*?(?&gt;(?! &lt;div\s*?&gt; | &lt;/div&gt; ) | &lt;div\s*?&gt;(?&lt;DEPTH&gt;) | &lt;/div&gt;(?&lt;-DEPTH&gt;) | .?)*(?(DEPTH)(?!))&lt;/div&gt; </code></pre> <p>It is finding the first div with the right id correctly, but it then closes at the first closing div, and not the related div.</p> <pre><code>&lt;div id="firstdiv"&gt;begining content&lt;div id="content"&gt;some other stuff &lt;div id="otherdiv"&gt;other stuff here&lt;/div&gt; more stuff &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This should bring back</p> <pre><code>&lt;div id="content"&gt;some other stuff &lt;div id="otherdiv"&gt;other stuff here&lt;/div&gt; more stuff &lt;/div&gt; </code></pre> <p>, but for some reason, it is not. It is bring back:</p> <pre><code> &lt;div id="content"&gt;some other stuff &lt;div id="otherdiv"&gt;other stuff here&lt;/div&gt; </code></pre> <p>Does anybody have an easier expression to handle this?</p> <p>To clarify, this is in .NET, and I'm using the DEPTH keyword. You can find more details <a href="http://www.m-8.dk/resources/RegEx-Balancing-Group.aspx" rel="noreferrer">here</a>.</p>
[ { "answer_id": 287758, "author": "pro3carp3", "author_id": 7899, "author_profile": "https://Stackoverflow.com/users/7899", "pm_score": 4, "selected": true, "text": "(?<text>\n(<div\\s*?id=(\\\"|&quot;|&\\#34;)content(\\\"|&quot;|&\\#34;).*?>)\n\n (?>\n .*?</div>\n |\n .*?<d...
2008/11/13
[ "https://Stackoverflow.com/questions/286104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8534/" ]
286,105
<p>I have a C library with numerous math routines for dealing with vectors, matrices, quaternions and so on. It needs to remain in C because I often use it for embedded work and as a Lua extension. In addition, I have C++ class wrappers to allow for more convenient object management and operator overloading for math operations using the C API. The wrapper only consists of a header file and as much use on inlining is made as possible.</p> <p>Is there an appreciable penalty for wrapping the C code versus porting and inlining the implementation directly into the C++ class? This library is used in time critical applications. So, does the boost from eliminating indirection compensate for the maintenance headache of two ports?</p> <p>Example of C interface:</p> <pre><code>typedef float VECTOR3[3]; void v3_add(VECTOR3 *out, VECTOR3 lhs, VECTOR3 rhs); </code></pre> <p>Example of C++ wrapper:</p> <pre><code>class Vector3 { private: VECTOR3 v_; public: // copy constructors, etc... Vector3&amp; operator+=(const Vector3&amp; rhs) { v3_add(&amp;this-&gt;v_, this-&gt;v_, const_cast&lt;VECTOR3&gt; (rhs.v_)); return *this; } Vector3 operator+(const Vector3&amp; rhs) const { Vector3 tmp(*this); tmp += rhs; return tmp; } // more methods... }; </code></pre>
[ { "answer_id": 286143, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 2, "selected": false, "text": "-S" }, { "answer_id": 286617, "author": "peterchen", "author_id": 31317, "author_profile": "https://Sta...
2008/11/13
[ "https://Stackoverflow.com/questions/286105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1491/" ]
286,117
<p>I work on a team with about 10 developers. Some of the developers have very exacting formatting needs. I would like to find a pretty printer that I could configure to these specifications and then add to the build processes. In this way no matter how badly other people mess up the format when it is pulled down from source control it will look acceptable.</p>
[ { "answer_id": 286293, "author": "Ben McNiel", "author_id": 1455, "author_profile": "https://Stackoverflow.com/users/1455", "pm_score": 1, "selected": false, "text": "ServiceLocator.Logger.WriteDefault(string.format(\"{0}{1}\"\n ,foo\n ...
2008/11/13
[ "https://Stackoverflow.com/questions/286117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1455/" ]
286,123
<p>I have to read a txt file with lines formated like this:</p> <pre> 1: (G, 2), (F, 3) 2: (G, 2), (F, 3) 3: (F, 4), (G, 5) 4: (F, 4), (G, 5) 5: (F, 6), (c, w) 6: (p, f), (G, 7) 7: (G, 7), (G, 7) w: (c, w), (c, w) </pre> <p>Each line will feed a struct with its data (the 5 numbers or letters in it).<br> What's the best way to read the line and get the strings I want?<br> I'm currently using a long sequence of conditions using <code>fgetc</code> but that seems ugly and not very smart.<br> I can't use arrays because the lines may vary in size if the numbers have two digits.</p>
[ { "answer_id": 286138, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 2, "selected": false, "text": "fgets()" }, { "answer_id": 286151, "author": "FlySwat", "author_id": 1965, "author_profile": "ht...
2008/11/13
[ "https://Stackoverflow.com/questions/286123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9835/" ]
286,124
<p>How can I test <code>Controller.ViewData.ModelState</code>? I would prefer to do it without any mock framework. </p>
[ { "answer_id": 589350, "author": "Scott Hanselman", "author_id": 6380, "author_profile": "https://Stackoverflow.com/users/6380", "pm_score": 7, "selected": true, "text": "// Test for required \"FirstName\".\n controller.ViewData.ModelState.Clear();\n\n newCustomer = new Customer\n ...
2008/11/13
[ "https://Stackoverflow.com/questions/286124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32173/" ]
286,132
<p>I have developed a simple mechanism for my mvc website to pull in html via jquery which then populates a specified div. All is well and it looks cool.<br> My problem is that i'm now creating html markup inside of my controller (Which is very easy to do in VB.net btw) I'd rather not mix up the sepparation of concerns.</p> <p>Is it possible to use a custom 'MVC View User Control' to suit this need? Can I create an instance of a control, pass in the model data and render to html? It would then be a simple matter of rendering and passing back to the calling browser.</p>
[ { "answer_id": 286177, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 0, "selected": false, "text": "render :partial => 'yourfilename'" }, { "answer_id": 286381, "author": "Christian Dalager", "author_id":...
2008/11/13
[ "https://Stackoverflow.com/questions/286132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30576/" ]
286,141
<p>How do I remove all attributes which are <code>undefined</code> or <code>null</code> in a JavaScript object?</p> <p>(Question is similar to <a href="https://stackoverflow.com/questions/208105/how-to-remove-a-property-from-a-javascript-object">this one</a> for Arrays)</p>
[ { "answer_id": 286145, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 4, "selected": false, "text": "delete" }, { "answer_id": 286162, "author": "Owen", "author_id": 4853, "author_profile": "https://St...
2008/11/13
[ "https://Stackoverflow.com/questions/286141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33581/" ]
286,149
<p>I'm trying to disable a button when a user submits a payment form and the code to post the form is causing a double post in firefox. This problem does not occur when the code is removed, and does not occur in any browser other than firefox.</p> <p>Any idea how to prevent the double post here?</p> <pre><code>System.Text.StringBuilder sb = new StringBuilder(); sb.Append("if (typeof(Page_ClientValidate) == 'function') { "); sb.Append("if (Page_ClientValidate() == false) { return false; }} "); sb.Append("this.value = 'Please wait...';"); sb.Append("this.disabled = true;"); sb.Append(Page.GetPostBackEventReference(btnSubmit )); sb.Append(";"); btnSubmit.Attributes.Add("onclick", sb.ToString()); </code></pre> <p>it's the sb.Append(Page.GetPostBackEventReference(btnSubmit )) line that's causing the issue</p> <p>Thanks</p> <p>EDIT: Here's the c# of the button:</p> <pre><code>&lt;asp:Button ID="cmdSubmit" runat="server" Text="Submit" /&gt; </code></pre> <p>here's the html<br><br> This code posts twice (and disables the submit button and verifies input):</p> <pre><code>&lt;input type="submit" name="ctl00$MainContent$cmdSubmit" value="Submit" onclick="if (typeof(Page_ClientValidate) == 'function') { if (Page_ClientValidate() == false) { return false; }} this.value = 'Please wait...';this.disabled = true;document.getElementById('ctl00_MainContent_cmdBack').disabled = true;__doPostBack('ctl00$MainContent$cmdSubmit','');" id="ctl00_MainContent_cmdSubmit" /&gt; </code></pre> <p><br>This code posts twice (but doesn’t disable the submit button):</p> <pre><code>&lt;input type="submit" name="ctl00$MainContent$cmdSubmit" value="Submit" onclick="__doPostBack('ctl00$MainContent$cmdSubmit','');" id="ctl00_MainContent_cmdSubmit" /&gt; </code></pre> <p><br>This code posts once (but doesn’t verify the user input and doesn’t disable the submit button):</p> <pre><code>&lt;input type="submit" name="ctl00$MainContent$cmdSubmit" value="Submit" id="ctl00_MainContent_cmdSubmit" /&gt; </code></pre> <p><br>This code posts once (but doesn’t disable submit button):</p> <pre><code>&lt;input type="submit" name="ctl00$MainContent$cmdSubmit" value="Submit" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&amp;quot;ctl00$MainContent$cmdSubmit&amp;quot;, &amp;quot;&amp;quot;, true, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, false, false))" id="ctl00_MainContent_cmdSubmit" /&gt; </code></pre> <p>This code doesn’t post at all: <br><br></p> <pre><code>&lt;input type="submit" name="ctl00$MainContent$cmdSubmit" value="Submit" onclick="this.disabled = true;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&amp;quot;ctl00$MainContent$cmdSubmit&amp;quot;, &amp;quot;&amp;quot;, true, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, false, false))" id="ctl00_MainContent_cmdSubmit" /&gt; </code></pre> <p>Obviously it’s the disabling of the submit button that’s posing the problem. Do you have any ideas how we can disable the submit to avoid multiple clicking? </p>
[ { "answer_id": 286154, "author": "Jeromy Irvine", "author_id": 8223, "author_profile": "https://Stackoverflow.com/users/8223", "pm_score": 2, "selected": false, "text": "btnSubmit" }, { "answer_id": 1910457, "author": "ta4ka", "author_id": 232449, "author_profile": "h...
2008/11/13
[ "https://Stackoverflow.com/questions/286149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36798/" ]
286,150
<p>So I'm using python to do some parsing of web pages and I want to split the full web address into two parts. Say I have the address <a href="http://www.stackoverflow.com/questions/ask">http://www.stackoverflow.com/questions/ask</a>. I would need the protocol and domain (e.g. <a href="http://www.stackoverflow.com">http://www.stackoverflow.com</a>) and the path (e.g. /questions/ask). I figured this might be solved by some regex, however I'm not so handy with that. Any suggestions?</p>
[ { "answer_id": 286155, "author": "Cybis", "author_id": 32998, "author_profile": "https://Stackoverflow.com/users/32998", "pm_score": -1, "selected": false, "text": "import re\nurl = \"http://stackoverflow.com/questions/ask\"\nprotocol, domain = re.match(r\"(http://[^/]*)(.*)\", url).grou...
2008/11/13
[ "https://Stackoverflow.com/questions/286150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
286,161
<p>example:</p> <p>I want to see if <code>array[5]</code> holds a value or is empty.</p>
[ { "answer_id": 286163, "author": "Rob Kennedy", "author_id": 33732, "author_profile": "https://Stackoverflow.com/users/33732", "pm_score": 3, "selected": false, "text": "Object" }, { "answer_id": 286167, "author": "Bill the Lizard", "author_id": 1288, "author_profile"...
2008/11/13
[ "https://Stackoverflow.com/questions/286161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36545/" ]
286,184
<p>I have a c# winforms program and it opens up a serial port. The problem happens when the end user unplugs the usb cable and then the device disappears. After this the program will crash and want to report the error to microsoft. </p> <p>Is there a way to capture this event and shut down gracefully? </p>
[ { "answer_id": 1327400, "author": "MrHIDEn", "author_id": 160581, "author_profile": "https://Stackoverflow.com/users/160581", "pm_score": 2, "selected": false, "text": "Windows Registry Editor Version 5.00\nHKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM]\n\"Winachsf0\"=\"COM10\"\n\"...
2008/11/13
[ "https://Stackoverflow.com/questions/286184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32958/" ]
286,187
<p>I'm developing an object-oriented PHP website right now and am trying to determine the best way to abstract database functionality from the rest of the system. Right now, I've got a DB class that manages all the connections and queries that the system uses (it's pretty much an interface to MDB2). However, when using this system, I've realized that I've got a lot of SQL query strings showing up everywhere in my code. For instance, in my User class, I've got something like this:</p> <pre><code>function checkLogin($email,$password,$remember=false){ $password = $this-&gt;__encrypt($password); $query = "SELECT uid FROM Users WHERE email=? AND pw=?"; $result = $this-&gt;db-&gt;q($query,array($email,$password)); if(sizeof($result) == 1){ $row = $result-&gt;fetchRow(MDB2_FETCHMODE_ASSOC); $uid = $row['uid']; }else{ return false; } /* Rest of the login script */ } </code></pre> <p>What I would like to do is find out the best technique for reducing the amount of inline SQL. I understand that one way to do this would be to write functions within User for each of the queries that User makes use of (something like the following), but that could lead to quite a few functions.</p> <pre><code>function checkLogin($email,$password,$remember=false){ $password = $this-&gt;__encrypt($password); $uid = $this-&gt;do_verify_login_query($email,$password); /* Rest of the login script */ } function do_verify_login_query($email,$encpw){ $query = "SELECT uid FROM Users WHERE email=? AND pw=?"; $result = $this-&gt;$db-&gt;q($query,array($email,$encpw)); if(sizeof($result) == 1){ $row = $result-&gt;fetchRow(MDB2_FETCHMODE_ASSOC); return $row['uid']; }else{ return false; } } </code></pre> <p>So...my question. What is the best technique for managing the large amount of queries that a typical database application would use? Would the way I described be the proper way of handling this situation? Or what about registering a list of queries within the DB class and associating with each a unique ID (such as USER_CHECKLOGIN) that is passed into the DB's query function? This method could also help with security, as it would limit the queries that could be run to only those that are registered in this list, but it's one more thing to remember when writing all the class functions. Thoughts?</p>
[ { "answer_id": 287478, "author": "Dave Sherohman", "author_id": 18914, "author_profile": "https://Stackoverflow.com/users/18914", "pm_score": 2, "selected": false, "text": "$user->check_password($entered_password)" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33212/" ]
286,190
<p>My present contract engagement is at a large E-Commerce company. Their code base which has origins going back to .Net 1.0 has caught me by surprise to contain many issues that raise the level of smell beyond the last crap I took. </p> <p>That notwithstanding and trying to diffuse my level of distraction from it, I go along merrily trying to add in features to either fix other problems or extend more crap. Where I touch the DAL/BLL the time it will take to fix the aforementioned will be done. However I wanted to get a vote of confidence from the experts to get some assurance of not wasting the clients time or worse having my credibility voted down by touching "stuff that works". Of course unit testing would solve or at least soften this worry. Perhaps this should also be added to the wtf.com?</p> <pre><code>Public Function GetSizeInfoBySite(ByVal siteID As String) As IList Dim strSQL As String = "YES INLINE SQL!! :)" Dim ci As CrapInfo Dim alAnArrayList As ArrayList Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim cmd As New SqlCommand(strSQL, cn) cmd.Parameters.Add(New SqlParameter("@MySiteID", SqlDbType.NVarChar, 2)).Value = siteID cn.Open() Dim rs As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection) While rs.Read() ci = New CategoryInfo(rs("someID"), rs("someName")) If IsNothing(alAnArrayList) Then alAnArrayList = New ArrayList End If alAnArrayList.Add(ci) End While rs.Close() Return CType(alAnArrayList, IList) End Function </code></pre> <p>Does anyone see problems with this aside from the inline SQL which makes my gut churn? At the least wouldn't you ordinarily wrap the above in a try/catch/finally which most of us knows has been around since .Net v1.0? Even better would'nt it be wise to fix with Using statements? Does the SQLDataReader close really encapsulate the connection close automagically? </p>
[ { "answer_id": 286217, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": true, "text": "List<T>" }, { "answer_id": 286244, "author": "hwiechers", "author_id": 5883, "author_profile": "htt...
2008/11/13
[ "https://Stackoverflow.com/questions/286190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4814/" ]
286,191
<p>I have this query statement and want to only get records that has a certain column empty (<code>volunteers_2009.venue_id</code>)</p> <p>Table is <code>volunteers_2009</code>, column I am looking to see if it is empty: <code>venue_id</code></p> <p>Here is the current query:</p> <pre><code>SELECT volunteers_2009.id, volunteers_2009.comments, volunteers_2009.choice1, volunteers_2009.choice2, volunteers_2009.choice3, volunteers_2009.lname, volunteers_2009.fname, volunteers_2009.venue_id, venues.venue_name FROM volunteers_2009 AS volunteers_2009 LEFT OUTER JOIN venues ON (volunteers_2009.venue_id = venues.id) ORDER by $order $sort </code></pre> <p>I am trying to do this:</p> <pre><code>SELECT volunteers_2009.id, volunteers_2009.comments, volunteers_2009.choice1, volunteers_2009.choice2, volunteers_2009.choice3, volunteers_2009.lname, volunteers_2009.fname, volunteers_2009.venue_id, venues.venue_name FROM volunteers_2009 AS volunteers_2009 LEFT OUTER JOIN venues ON (volunteers_2009.venue_id = venues.id) ORDER by $order $sort WHERE volunteers_2009.venue_id == '' </code></pre> <p>How would I only list records that have an empty column (<code>venue_id</code>) within the table (<code>volunteers_2009</code>)?</p>
[ { "answer_id": 286201, "author": "Vincent Ramdhanie", "author_id": 27439, "author_profile": "https://Stackoverflow.com/users/27439", "pm_score": 2, "selected": false, "text": "venue_id" }, { "answer_id": 286215, "author": "Joel Coehoorn", "author_id": 3043, "author_pr...
2008/11/13
[ "https://Stackoverflow.com/questions/286191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26130/" ]
286,206
<p>I'm writing an app for Blackberry that was originally implemented in standard J2ME. The network connection was done using <code>Connector.open("socket://...:80/...")</code> instead of <code>http://</code></p> <p>Now, I've implemented the connection using both methods, and it seems like some times, the socket method is more responsive, and some times it doesn't work at all. Is there a significant difference between the two? Mostly what I'm trying to achieve is responsiveness from the connection to get a smooth progress bar.</p>
[ { "answer_id": 286933, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 4, "selected": true, "text": "http" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36007/" ]
286,207
<p>I am showing an addressbook view to the user and letting them click on a contact and select a phone number. If they select a phone number, I want to get the phone number as an integer and the contact's name as an NSString. </p> <p>I've tried doing it with the following code: </p> <pre><code> //printf("%s\n",[[(NSArray *)ABMultiValueCopyArrayOfAllValues(theProperty) objectAtIndex:identifier] UTF8String]); //CFArrayRef *arrayString = [[(NSArray *)ABMultiValueCopyArrayOfAllValues(theProperty) objectAtIndex:identifier] UTF8String]; NSArray *arrayString = [(NSArray *)ABMultiValueCopyArrayOfAllValues(theProperty) objectAtIndex:identifier]; printf("%s\n", arrayString); </code></pre> <p>This code is inside this method:</p> <pre><code>- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier </code></pre> <p>And I am checking if the user selected a phone number with this code:</p> <pre><code>if (propertyType == kABStringPropertyType) { [self wrongSelection]; } else if (propertyType == kABIntegerPropertyType) { [self wrongSelection]; } else if (propertyType == kABRealPropertyType) { [self wrongSelection]; } else if (propertyType == kABMultiStringPropertyType) { //This is the phone number... </code></pre> <p>I am able to get the phone number to display in the console with printf, however I can't figure out how to convert it into an integer and how to also get the contacts name even though the property selected is not a person's name. </p> <p>Also, what I'm doing seems very inefficient. Are there any better ways to do this?</p> <p>Edit: If I can't store them as an int, a string would be fine. I just can't figure out how to go from that array to an actual string. If I cast it or save it as a UTF8String I always get some error. </p>
[ { "answer_id": 286281, "author": "Jason Coco", "author_id": 34218, "author_profile": "https://Stackoverflow.com/users/34218", "pm_score": 4, "selected": false, "text": "switch( propertyType ) {\n case kABMultiStringPropertyType:\n // this is the phone number, do something\n break;...
2008/11/13
[ "https://Stackoverflow.com/questions/286207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23695/" ]
286,219
<p>I'm trying to run a freshly created ASP.NET Website using C#, however when I do so it launches FireFox and attempts to connect to <a href="http://localhost:1295/WebSite1/Default.aspx" rel="nofollow noreferrer">http://localhost:1295/WebSite1/Default.aspx</a> (for example), but after about 10-15 seconds it displays a "Connection Interrupted - The connection to the server was reset while the page was loading." Error.</p> <p>This issue is also present with older ASP.NET C# pages/Web Services I've built in the past, nothing is actually running off the ASP.NET Development server.</p> <p>I am using: Windows XP Pro SP2, Visual Studio 2008</p> <p>For reference I have SQL Server 2005 Developer Edition installed as well.</p> <p>I have tried:</p> <ul> <li>Browsing it with IE instead of Mozilla</li> <li>Trying 2.0 framework instead of 3.5</li> <li>Reinstalling Visual Studio 2008</li> </ul> <p>This problem seems so trivial the more I think about it, but I havn't been able to work it out just yet! Appreciate any help on the matter.</p>
[ { "answer_id": 5347747, "author": "JollySwagman", "author_id": 633298, "author_profile": "https://Stackoverflow.com/users/633298", "pm_score": 3, "selected": false, "text": "System.Web.HttpException (0x80004005): Maximum request length exceeded.\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30598/" ]
286,238
<p>is it possible to throw a custom error message to a ThrowActivity, in windows workflow foundation?</p> <p>eg. Imagine i want to throw this exception, in my WF :-</p> <pre><code>CutomException("This is my custom error message", myNumber, myObect); </code></pre> <p>cheers :)</p>
[ { "answer_id": 287159, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 3, "selected": true, "text": "Fault" }, { "answer_id": 364703, "author": "balaweblog", "author_id": 22162, "author_profile": "https://Sta...
2008/11/13
[ "https://Stackoverflow.com/questions/286238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
286,250
<p>If I am evaluating two variables and not two method calls does it matter weather I use "&amp;&amp;" or "&amp;"</p> <pre><code>//some logic that sets bool values boolean X = true; boolean Y = true; if (X &amp; Y){ // perform some operation } if (X &amp;&amp; Y){ // perform some operation } </code></pre> <p>Further a book I am using for C# 3.0 / .NET 3.5 only makes reference to the &amp;&amp; operator, is the &amp; operator going away?</p>
[ { "answer_id": 286258, "author": "vfilby", "author_id": 24279, "author_profile": "https://Stackoverflow.com/users/24279", "pm_score": 3, "selected": false, "text": "true && true == true\n" }, { "answer_id": 286259, "author": "jpoh", "author_id": 4368, "author_profile"...
2008/11/13
[ "https://Stackoverflow.com/questions/286250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35585/" ]
286,257
<p>I am currently refactoring an application that prints its status to the console window. At the moment I am doing something like this:</p> <pre><code> Console.Write("Print some status.....") //some code Console.WriteLine("Done!") </code></pre> <p>Now while this works fine, all the logic is hidden between console.writelines and I find makes it very hard to read.</p> <p>I don't know if there is a better way of doing this, but I just wanted to ask and see if anyone has come up with a better/more clean way of print application status to the console.</p> <p>Any ideas?</p>
[ { "answer_id": 288836, "author": "Jamie Penney", "author_id": 68230, "author_profile": "https://Stackoverflow.com/users/68230", "pm_score": 1, "selected": false, "text": "log4net.Config.BasicConfigurator.Configure(new log4net.Appender.ConsoleAppender());\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
286,270
<p>What is the best way to password protect quicktime streaming videos using php/.htaccess. They are being streamed using rtsp, but I can use other formats if necessary.</p> <p>I know how to do authentication with php, but I'm not sure how to setup authentication so that will protect the streaming files urls so that a user can't just copy the url and share it.</p> <p>Or am I overthinking this and I can just use a normal authentication scheme and place the files in a protected directory?</p>
[ { "answer_id": 286307, "author": "cmptrgeekken", "author_id": 33212, "author_profile": "https://Stackoverflow.com/users/33212", "pm_score": 0, "selected": false, "text": "RewriteEngine On\nRewriteCond %{HTTP_REFERER} !^$\nRewriteCond %{HTTP_COOKIE} obscurename=obscurevalue [NC]\nRewriteC...
2008/11/13
[ "https://Stackoverflow.com/questions/286270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
286,274
<p>Given two 3D vectors A and B, I need to derive a rotation matrix which rotates from A to B.</p> <p>This is what I came up with:</p> <ol> <li>Derive cosine from <strike>acos</strike>(A . B)</li> <li>Derive sine from <strike>asin</strike>(|A x B| / (|A| * |B|))</li> <li>Use A x B as axis of rotation</li> <li>Use matrix given near the bottom of <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/index.htm" rel="nofollow noreferrer">this page</a> (axis angle)</li> </ol> <p>This works fine except for rotations of 0&deg; (which I ignore) and 180&deg; (which I treat as a special case). Is there a more graceful way to do this using the Direct3D library? I am looking for a Direct3D specific answer.</p> <p>Edit: Removed acos and asin (see <a href="https://stackoverflow.com/questions/286274/direct3d-geometry-rotation-matrix-from-two-vectors#286300">Hugh Allen's post</a>)</p>
[ { "answer_id": 286299, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 2, "selected": false, "text": "D3DXMatrixRotationAxis()" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45603/" ]
286,275
<p>What's the best way (if any) to make an image appear "grayed out" with CSS (i.e., without loading a separate, grayed out version of the image)?</p> <p>My context is that I have rows in a table that all have buttons in the right most cell and some rows need to look lighter than others. So I can make the font lighter easily of course but I'd also like to make the images lighter without having to manage two versions of each image.</p>
[ { "answer_id": 286279, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 9, "selected": true, "text": "<div>" }, { "answer_id": 286305, "author": "Dave Jensen", "author_id": 35341, "author_profile": "https://Sta...
2008/11/13
[ "https://Stackoverflow.com/questions/286275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26842/" ]
286,282
<p>How can I make cookies in my Flash application using ActionScript 2.0?</p>
[ { "answer_id": 286349, "author": "chews", "author_id": 33966, "author_profile": "https://Stackoverflow.com/users/33966", "pm_score": 0, "selected": false, "text": "// Javascript Function\nfunction setCookie(c_name,value,expiredays)\n{\n var exdate=new Date();\n exdate.setDate(exdat...
2008/11/13
[ "https://Stackoverflow.com/questions/286282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
286,297
<p>I have a suspicion that I'm using the <code>finally</code> block incorrectly, and that I don't understand the fundamentals of its purpose...</p> <pre><code> function myFunc() { try { if (true) { throw "An error"; } } catch (e) { alert (e); return false; } finally { return true; } } </code></pre> <p>This function will run the <code>catch</code> block, alert "An error", but then return true. Why doesn't it return false?</p>
[ { "answer_id": 286306, "author": "Gilean", "author_id": 6305, "author_profile": "https://Stackoverflow.com/users/6305", "pm_score": 7, "selected": true, "text": "finally" }, { "answer_id": 28165868, "author": "Danny Mor", "author_id": 4497780, "author_profile": "https...
2008/11/13
[ "https://Stackoverflow.com/questions/286297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
286,316
<p>I authenticate users through Radius, and I have the option to assign Radius attributes through SQL statements, but I can't for the life of me find any documentation on this. Anyone know the proper syntax?</p>
[ { "answer_id": 292110, "author": "kylex", "author_id": 36545, "author_profile": "https://Stackoverflow.com/users/36545", "pm_score": 2, "selected": true, "text": "SELECT 'attribute', value FROM table WHERE username ='$u'" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36545/" ]
286,321
<p>I would like to make my application somewhat REST compliant. I am using Rails on the backend and <a href="https://developers.google.com/web-toolkit/" rel="noreferrer">GWT</a> on the frontend. I would like to do updates and deletes. I realize I can do something like mydomain.com/:id/delete (GET) and accomplish the same thing. However, as I stated previously, I would like to have a REST compliant backend. Thus, I want to do mydomain.com/:id (DELETE) and have it implicitly call my delete method.</p> <p>Now, it's my understanding that if a browser (my browser is GWT RequestBuilder) doesn't support DELETE/GET, Rails somehow accomplishes this task with a POST and some other url parameter. So, how can I accomplish this with a GWT RequestBuilder?</p>
[ { "answer_id": 286463, "author": "Christian Lescuyer", "author_id": 341, "author_profile": "https://Stackoverflow.com/users/341", "pm_score": 4, "selected": true, "text": "rails jp\ncd jp\n./script/generate scaffold RequestBuilder name:string\nrake db:migrate\n./script/server \n" }, ...
2008/11/13
[ "https://Stackoverflow.com/questions/286321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10333/" ]
286,332
<p>I have subclassed the UITableView control, and the style is grouped, but I do not need the cell separators. I tried setting my table view's separatorStyle to none, but it doesn't work. Can any one help me out?</p>
[ { "answer_id": 456945, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": false, "text": "tableView.separatorStyle = UITableViewCellSeparatorStyleNone;" }, { "answer_id": 1661079, "author": "Akshay Shah",...
2008/11/13
[ "https://Stackoverflow.com/questions/286332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
286,334
<p>I have a table of events, I need to find all tail events of type 1 and all head events of type 1. </p> <p>So, for the set of events in this order [1, 1], 3, 1 ,4, 5, [1,1,1] the brackets denote head and tail events of type 1. </p> <p>This is much better illustrated in SQL:</p> <pre><code>drop table #event go create table #event (group_id int, [date] datetime, [type] int) create index idx1 on #event (group_id, date) insert into #event values (1, '2000-01-01', 1) insert into #event values (1, '2000-01-02', 1) insert into #event values (1, '2000-01-03', 3) insert into #event values (1, '2000-01-04', 2) insert into #event values (1, '2000-01-05', 1) insert into #event values (2, '2000-01-01', 2) insert into #event values (2, '2000-01-02', 2) insert into #event values (2, '2000-01-03', 3) insert into #event values (2, '2000-01-04', 2) insert into #event values (2, '2000-01-05', 1) insert into #event values (3, '2000-01-01', 1) insert into #event values (3, '2000-01-02', 2) insert into #event values (3, '2000-01-03', 1) insert into #event values (3, '2000-01-04', 2) insert into #event values (3, '2000-01-05', 2) insert into #event values (4, '2000-01-01', 2) insert into #event values (4, '2000-01-02', 2) insert into #event values (4, '2000-01-03', 3) insert into #event values (4, '2000-01-04', 1) insert into #event values (4, '2000-01-05', 1) go select e1.* from #event e1 where ( not exists ( select top 1 1 from #event e2 where e1.group_id = e2.group_id and e2.date &lt; e1.date and e2.type &lt;&gt; 1 ) or not exists ( select top 1 1 from #event e2 where e1.group_id = e2.group_id and e2.date &gt; e1.date and e2.type &lt;&gt; 1 ) ) and e1.type = 1 </code></pre> <p>Expected results: </p> <pre><code>1 2000-01-01 00:00:00.000 1 1 2000-01-02 00:00:00.000 1 1 2000-01-05 00:00:00.000 1 2 2000-01-05 00:00:00.000 1 3 2000-01-01 00:00:00.000 1 4 2000-01-04 00:00:00.000 1 4 2000-01-05 00:00:00.000 1 </code></pre> <p>This all works just fine and returns my expected results, but it scans through the table 3 times. Is there any way to make this perform faster and reduce the number of table scans? </p>
[ { "answer_id": 286343, "author": "Robert Wagner", "author_id": 10784, "author_profile": "https://Stackoverflow.com/users/10784", "pm_score": 0, "selected": false, "text": ";WITH Ranked AS (\n SELECT \n *,\n Row_Number() OVER (ORDER BY date) as 'rnk'\n FROM #event\n)\n...
2008/11/13
[ "https://Stackoverflow.com/questions/286334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
286,354
<p>I am trying to wrap my head around this. I am making a business specific messaging application, it is going to connect between 5000 and 10,000 machines back to our datacenter via WCF (no vpns, all over the net). It is mainly for alerts and I need to be able to send message direclty to specific clients, and WCF allows me to do all of this with a Duplex contract, but with this many clients it got me thinking about maxing out the TCP port space of 65535 ports.</p> <p>I am going to assume that all inbound connections are going to come in over whatever port I choose, but outbounds back to the clients are going to take one port each. I am curious if the WCF port sharing service does anything to solve this issue or if its just 65535 ports to an IP address? For that matter, how does MSN Messenger and the like deal with this situation. Granted I may never reach it, but I am getting in the realm at least.</p> <p>Or does the WCF duplex contract on the service end keep the port open for the callback for the duration of the client, or does it release it?</p>
[ { "answer_id": 286398, "author": "stephbu", "author_id": 12702, "author_profile": "https://Stackoverflow.com/users/12702", "pm_score": 2, "selected": false, "text": "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\n\nTcpTimedWaitDelay = 30\nMaxUserPort = 65534 ...
2008/11/13
[ "https://Stackoverflow.com/questions/286354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29466/" ]
286,375
<p>Hi i am encountering problems trying to post a WebRequest under Https. </p> <p>i received the following errors</p> <h1>1.-The underlying connection was closed: Unable to connect to the remote server.</h1> <h1>2.-the operation TimeOut</h1> <h1>3-The underlying connection was closed: Could not establish secure channel for SSL/TLS.</h1> <p>i tried with about 3 or 4 different proxies of my company and the customer company and not even when i am directly with the ISP provider with no restrictions, i get the above errors when executing the following method</p> <pre><code>WebRequest.GetRequestStream() </code></pre> <p>this occurs behind a proxy or not, the request can only be succesfully post from one single PC which is behind a proxy. the proxy doesn't have a client certificate installed.</p> <p>this is under .net framework 1.1 and the request already contains network credentials.</p> <p>what could be?</p> <h1>Update</h1> <p>the inner exception the 3rd error is the following: The function completed successfully, but must be called again to complete the context</p> <p>according to iisper.h <a href="http://doc.ddart.net/msdn/header/include/issperr.h.html" rel="nofollow noreferrer">documentation</a> this error belongs to the </p> <pre><code>// // MessageId: SEC_I_CONTINUE_NEEDED // // MessageText: // // The function completed successfully, but must be called // again to complete the context // #define SEC_I_CONTINUE_NEEDED ((HRESULT)0x00090312L) </code></pre> <p>on <a href="http://msdn.microsoft.com/en-us/library/aa375924(VS.85).aspx" rel="nofollow noreferrer">MSDN</a> this refers to </p> <p>SEC_I_CONTINUE_NEEDED The client must send the output token to the server and wait for a return token. The returned token is then passed in another call to InitializeSecurityContext (Schannel). The output token can be empty.</p> <p>does this means the PC lacks a client certificate?</p>
[ { "answer_id": 286393, "author": "Sani Singh Huttunen", "author_id": 26742, "author_profile": "https://Stackoverflow.com/users/26742", "pm_score": 0, "selected": false, "text": "// .NET 2.0+\n...\nServicePointManager.ServerCertificateValidationCallback += MyValidationCallback\n...\npubli...
2008/11/13
[ "https://Stackoverflow.com/questions/286375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14440/" ]
286,392
<p>How to use batch file to check if an application still running or not? If the application still running, this process will loop again and again. Else, there will be error message.</p> <p>Thank you very much</p>
[ { "answer_id": 286453, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "@echo off\n\nCommandYouWillRun.exe\n\nrem waiting for the process to start\n:startcmd\nsleep 1\nc:\\path\\to\\pslist.exe Comma...
2008/11/13
[ "https://Stackoverflow.com/questions/286392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
286,399
<p>I want to build two-dimentional array of strings where length of one dimention is 2. Similar to this</p> <pre><code>string[,] array = new string[,] { {"a", "b"}, {"c", "d"}, {"e", "f"}, {"g", "h"} } </code></pre> <p>Doing</p> <pre><code>List&lt;string[]&gt; list = new List&lt;string[]&gt;(); list.Add(new string[2] {"a", "b"}); list.Add(new string[2] {"c", "d"}); list.Add(new string[2] {"e", "f"}); list.Add(new string[2] {"g", "h"}); list.ToArray(); </code></pre> <p>gives me </p> <pre><code>string[][] </code></pre> <p>but not </p> <pre><code>string[,] </code></pre> <p>array.</p> <p>Just curious, is there some trick to build dynamically</p> <pre><code>string[,] </code></pre> <p>array somehow?</p>
[ { "answer_id": 286420, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https://Stackoverflow.com/users/22506", "pm_score": 0, "selected": false, "text": "List<string[]>" }, { "answer_id": 286428, "author": "Robert Wagner", "author_id": 10784, "author...
2008/11/13
[ "https://Stackoverflow.com/questions/286399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11256/" ]
286,402
<p>I have a couple of array's:</p> <pre><code>const string a_strs[] = {"cr=1", "ag=2", "gnd=U", "prl=12", "av=123", "sz=345", "rc=6", "pc=12345"}; const string b_strs[] = {"cr=2", "sz=345", "ag=10", "gnd=M", "prl=11", "rc=6", "cp=34", "cv=54", "av=654", "ct=77", "pc=12345"}; </code></pre> <p>which i then need to parse out for '=' and then put the values in the struct. (the rc key maps to the fc key in the struct), which is in the form of:</p> <pre><code>struct predict_cache_key { pck() : av_id(0), sz_id(0), cr_id(0), cp_id(0), cv_id(0), ct_id(0), fc(0), gnd(0), ag(0), pc(0), prl_id(0) { } int av_id; int sz_id; int cr_id; int cp_id; int cv_id; int ct_id; int fc; char gnd; int ag; int pc; long prl_id; }; </code></pre> <p>The problem I am encountering is that the array's are not in sequence or in the same sequence as the struct fields. So, I need to check each and then come up with a scheme to put the same into the struct.</p> <p>Any help in using C or C++ to solve the above?</p>
[ { "answer_id": 286450, "author": "qrdl", "author_id": 28494, "author_profile": "https://Stackoverflow.com/users/28494", "pm_score": 3, "selected": false, "text": "key" }, { "answer_id": 286667, "author": "quinmars", "author_id": 18687, "author_profile": "https://Stack...
2008/11/13
[ "https://Stackoverflow.com/questions/286402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
286,419
<p>Is it possible to build a .dmg file (for distributing apps) from a non-Mac platform? And if yes, how?</p>
[ { "answer_id": 3776463, "author": "jstck", "author_id": 88979, "author_profile": "https://Stackoverflow.com/users/88979", "pm_score": 5, "selected": false, "text": "dd if=/dev/zero of=/tmp/foo.dmg bs=1M count=64\nmkfs.hfsplus -v ThisIsFoo /tmp/foo.dmg\n" }, { "answer_id": 7553878...
2008/11/13
[ "https://Stackoverflow.com/questions/286419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15173/" ]
286,426
<p>I have a page P1 loading from site S1 which contains an iframe. That iframe loads a page P2 from another site S2. At some point P2 would like to close the browser window, which contains P1 loaded from S1. Of course, since P2 is loaded from another site, it can't just do parent.close().</p> <p>I have full control over P1 and P2, so I can add JavaScript code to both P1 and P2 as needed. Suggestions on how to resolve this?</p>
[ { "answer_id": 286472, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<iframe name = \"frame1\" src = \"http://yoursite\">\n</iframe>\n\n<script type = \"text/javascript\">\n alert(window.frames...
2008/11/13
[ "https://Stackoverflow.com/questions/286426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5295/" ]
286,427
<p>Inspired by this <a href="https://stackoverflow.com/questions/283561/extracting-leaf-paths-from-n-ary-tree-in-f">question</a> and <a href="https://stackoverflow.com/questions/283561/extracting-leaf-paths-from-n-ary-tree-in-f#283638">answer</a>, how do I create a generic permutations algorithm in F#? Google doesn't give any useful answers to this.</p> <p>EDIT: I provide my best answer below, but I suspect that Tomas's is better (certainly shorter!)</p>
[ { "answer_id": 286544, "author": "Benjol", "author_id": 11410, "author_profile": "https://Stackoverflow.com/users/11410", "pm_score": 1, "selected": false, "text": "//mini-extension to List for removing 1 element from a list\nmodule List = \n let remove n lst = List.filter (fun x -> x...
2008/11/13
[ "https://Stackoverflow.com/questions/286427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
286,441
<pre><code>from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') setup( options = {'py2exe': {'bundle_files': 1}}, windows = [{'script': "single.py"}], zipfile = None, ) </code></pre> <p>in this setup file for py2exe where it says single.py is that where I place the name of my program?</p>
[ { "answer_id": 286495, "author": "Denes Tarjan", "author_id": 17617, "author_profile": "https://Stackoverflow.com/users/17617", "pm_score": 3, "selected": false, "text": "<UNPACKED_FILES_DIR>" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
286,459
<p>I'm using VB .NET 2005 and Exchange Server 2003 installed I have found some code which gives me the ability to connect in an Exchange Server and create an appointment. The thing is that I cannot find the CDO. Appointment. Where can I find it and make the below code to work ? I have tried all the examples with CDO and Outlook. I believe that the below code need to be produced in an Exchange environment and use CDOEX.DLL ? Appreciate any help or ideas you can give me. Thank you</p> <p>[Sample Code]</p> <pre><code>sURL = "http://ExchangeServername/Exchange/testuser/calendar" Dim oCn As ADODB.Connection = New ADODB.Connection() 'oCn.Provider = "exoledb.datasource"; 'I am using the below provider because I am in the client side oCn.Provider = "MSDAIPP.DSO" oCn.Open(sURL, "testuser", "q1w2e3r4t5", 0) If oCn.State = 1 Then MsgBox("Good Connection") Else MsgBox("Bad Connection") Return End If Dim iConfg As CDO.Configuration = New CDO.Configuration() Dim oFields As ADODB.Fields oFields = iConfg.Fields oFields.Item(CDO.CdoCalendar.cdoTimeZoneIDURN).Value = CDO.CdoTimeZoneId.cdoAthens 'oFields.Item(CDO.CdoConfiguration.cdoSendEmailAddress).Value = "test@test.com" oFields.Update() Dim oApp As CDO.Appointment = New CDO.Appointment() oApp.Configuration = iConfg oApp.StartTime = Convert.ToDateTime("10/11/2001 10:00:00 AM") oApp.EndTime = Convert.ToDateTime("10/11/2001 11:00:00 AM") oApp.Location = "My Location" oApp.Subject = "Test: Create Meeting in VB.NET" oApp.TextBody = "Hello..." '' Add recurring appointment '' Every Thursday starting today, and repeat 3 times. '' Save to the folder oApp.DataSource.SaveToContainer(sURL, , _ ADODB.ConnectModeEnum.adModeReadWrite, _ ADODB.RecordCreateOptionsEnum.adCreateNonCollection, _ ADODB.RecordOpenOptionsEnum.adOpenSource, _ "", "") oCn.Close() oApp = Nothing oCn = Nothing oFields = Nothing </code></pre>
[ { "answer_id": 293360, "author": "Patrick de Kleijn", "author_id": 33221, "author_profile": "https://Stackoverflow.com/users/33221", "pm_score": 0, "selected": false, "text": "cdoex.dll" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
286,468
<p>I've got a VB.NET module that reads from a resource file to display text in the correct language. Here's my problem - this code is shared between a web application and a non-web application, In the web application, I'm using System.Web.HttpContext to determine the user's preferred language, but now my Windows app won't even compile, because it says HttpContext isn't defined (I've already tried adding an imports for the full namespace - no dice).</p> <p>I would love to use some kind of try/catch block if I can't otherwise work around it, but that doesn't change that the windows app won't compile with a reference to HttpContext in it. Without moving this chunk of code into a new file and including it only in the web application (I don't own that app, so I'd rather not deal with those implications), is there another choice I have to deal with this?</p> <p>If it doesn't make sense, please let me know and I'll do my best to clarify.</p> <p><strong>SOLUTION:</strong> I just added a reference to System.Web, which allowed my application to compile. I also wrapped the HttpContext reference in an "If HttpContext.Current isnot Nothing Then...End If" block, which causes it to skip over the code if it's not running as a web application, which is exactly what I was looking for.</p>
[ { "answer_id": 286574, "author": "Davy Landman", "author_id": 11098, "author_profile": "https://Stackoverflow.com/users/11098", "pm_score": 1, "selected": false, "text": "public interface IPreferredLanguage\n{\n String PeferredLanguage { get; set; }\n}\n" }, { "answer_id": 40...
2008/11/13
[ "https://Stackoverflow.com/questions/286468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8114/" ]
286,475
<p>It looks like the run-time compiler doesn't support the same language as the command-line compiler so if you want to use lambda expressions, extensions methods or LINQ, well, you're stuck.</p> <p>There's more detail here:</p> <p><a href="http://metadatalabs.com/blog/" rel="nofollow noreferrer">http://metadatalabs.com/blog/</a></p> <p>Is this correct or is there a work-around? (Short of spawning the command-line compiler, of course.)</p>
[ { "answer_id": 286509, "author": "Jamie Penney", "author_id": 68230, "author_profile": "https://Stackoverflow.com/users/68230", "pm_score": 2, "selected": false, "text": "CodeDomProvider provider = new CSharpCodeProvider(new Dictionary<string, string> { { \"CompilerVersion\", \"v3.5\" } ...
2008/11/13
[ "https://Stackoverflow.com/questions/286475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37263/" ]
286,481
<p>I was always wondering why such a simple and basic operation like swapping the contents of two variables is not built-in for many languages.</p> <p>It is one of the most basic programming exercises in computer science classes; it is heavily used in many algorithms (e.g. sorting); every now and then one needs it and one must use a temporary variable or use a template/generic function.</p> <p>It is even a basic machine instruction on many processors, so that the standard scheme with a temporary variable will get optimized.</p> <p>Many less obvious operators have been created, like the assignment operators (e.g. +=, which was probably created for reflecting the cumulative machine instructions, e.g. add ax,bx), or the ?? operator in C#.</p> <p>So, what is the reason? Or does it actually exist, and I always missed it?</p>
[ { "answer_id": 286560, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "#include <algorithm>\n#include <cassert>\n\nint\nmain()\n{\n using std::swap;\n int a(3), b(5);\n swap(a, b);\n ...
2008/11/13
[ "https://Stackoverflow.com/questions/286481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26070/" ]
286,486
<p>In relation to <a href="https://stackoverflow.com/questions/283431/why-would-an-command-not-recognized-error-occur-only-when-a-window-is-populated">another question</a>, how do you account for paths that may change? For example, if a program is calling a file in the same directory as the program, you can simply use the path ".\foo.py" in *nix. However, apparently Windows likes to have the path hard-coded, e.g. "C:\Python_project\foo.py".</p> <p>What happens if the path changes? For example, the file may not be on the C: drive but on a thumb drive or external drive that can change the drive letter. The file may still be in the same directory as the program but it won't match the drive letter in the code.</p> <p>I want the program to be cross-platform, but I expect I may have to use <strong>os.name</strong> or something to determine which path code block to use.</p>
[ { "answer_id": 286499, "author": "TheObserver", "author_id": 20879, "author_profile": "https://Stackoverflow.com/users/20879", "pm_score": 0, "selected": false, "text": "def _isInProductionMode():\n \"\"\" returns True when running the exe, \n False when running from a script, ...
2008/11/13
[ "https://Stackoverflow.com/questions/286486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18676/" ]
286,493
<p>I use db2 v.9.1 on windows 2003 server so it can not use LPAD or RPAD functions scalar. because that functions support only z/OS right?</p> <p>Now, I use this way for pad zero when COLUMN1 type is VARCHAR</p> <pre><code> RIGHT('0000' || COLUMN1 ,4) AS RPAD LEFT('0000' || COLUMN1 ,4) AS LPAD </code></pre> <p>Have better way for replace LPAD or RPAD function?</p>
[ { "answer_id": 61216244, "author": "JOHN HOUZOURIS", "author_id": 13315027, "author_profile": "https://Stackoverflow.com/users/13315027", "pm_score": 0, "selected": false, "text": "REPEAT('0',4) || column_name\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24550/" ]
286,496
<p>I am developing an iOS application, and trying to zip the file I have created in the application, is there any built in function able to do this?</p>
[ { "answer_id": 8969690, "author": "nlg", "author_id": 973043, "author_profile": "https://Stackoverflow.com/users/973043", "pm_score": 2, "selected": false, "text": "-(IBAction)Zip{\nself.fileManager = [NSFileManager defaultManager];\nNSArray *paths = NSSearchPathForDirectoriesInDomains(N...
2008/11/13
[ "https://Stackoverflow.com/questions/286496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35405/" ]
286,508
<p>I've looked at the ReaderWriterLock in .NET 2.0 and the ReaderWriterLockSlim in .NET 3.5, and the slim version doesn't use kernel objects for the locking. For my context, which can potentially generate a large (but not huge) amount of objects, this sounds better.</p> <p>But the code I write needs to be used in both .NET 2.0 and 3.5 during a transition period, so the 3.5 version, while looking good for my purposes, can't be used.</p> <p>Does anyone have, or know of, a similar class that I can plug into .NET 2.0 and get some of the same benefits with?</p>
[ { "answer_id": 286520, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "ReaderWriterLockSlim" }, { "answer_id": 720653, "author": "Dmitri Nesteruk", "author_id": 9476, "auth...
2008/11/13
[ "https://Stackoverflow.com/questions/286508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
286,533
<p>I'm testing how the classes FileStream and StreamReader work togheter. Via a Console application. I'm trying to go in a file and read the lines and print them on the console.</p> <p>I've been able to do it with a while-loop, but I want to try it with a foreach loop.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace testing { public class Program { public static void Main(string[] args) { string file = @"C:\Temp\New Folder\New Text Document.txt"; using(FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read)) { using(StreamReader sr = new StreamReader(fs)) { foreach(string line in file) { Console.WriteLine(line); } } } } } } </code></pre> <p>The error I keep getting for this is: Cannot convert type 'char' to 'string'</p> <p>The while loop, which does work, looks like this:</p> <pre><code>while((line = sr.ReadLine()) != null) { Console.WriteLine(line); } </code></pre> <p>I'm probably overlooking something really basic, but I can't see it.</p>
[ { "answer_id": 286539, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 2, "selected": false, "text": "foreach(string line in file)\n{\n Console.WriteLine(line);\n}\n" }, { "answer_id": 286541, "author": "Mikael S...
2008/11/13
[ "https://Stackoverflow.com/questions/286533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11795/" ]
286,534
<p>I want to enumerate all available drive letters (which aren't already taken) in Windows using VC++.</p> <p>How can I do this?</p>
[ { "answer_id": 286550, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": false, "text": "GetLogicalDriveStrings" }, { "answer_id": 286555, "author": "JTeagle", "author_id": 162171, "author_prof...
2008/11/13
[ "https://Stackoverflow.com/questions/286534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7891/" ]
286,543
<p>I have a checkbox in GridViewColumn which i use for show/change database value. The click event for the checkbox is used for change value in the database. For handling the state of property "IsChecked" I'm using datatrigger and a setter, se xaml code below:</p> <pre><code>&lt;Style TargetType="CheckBox"&gt; &lt;Setter Property="IsEnabled" Value="True" /&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding Path=ID, Converter={StaticResource Converter}}" Value="true"&gt; &lt;Setter Property="IsChecked" Value="True"/&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; </code></pre> <p>The binding works great until I click the checkbox. After I clicked the checkbox for the first time the state of the property "IsChecked" don't updates if a manually in the Database change the value which i mapped to the property "IsChecked". If I map for example the same value to the property "Content" of the checkbox the trigger works fine even after I've clicked the checkbox. </p> <p>Does anyone no whats the problem is?</p>
[ { "answer_id": 286918, "author": "Pop Catalin", "author_id": 4685, "author_profile": "https://Stackoverflow.com/users/4685", "pm_score": 3, "selected": true, "text": "<Style TargetType=\"CheckBox\">\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37271/" ]
286,549
<p>Can PL/SQL procedure in Oracle know it's own name?</p> <p>Let me explain:</p> <pre><code>CREATE OR REPLACE procedure some_procedure is v_procedure_name varchar2(32); begin v_procedure_name := %%something%%; end; </code></pre> <p>After <code>%%something%%</code> executes, variable <code>v_procedure_name</code> should contain 'SOME_PROCEDURE'. It is also OK if it contains <code>object_id</code> of that procedure, so I can look up name in <code>all_objects</code>.</p>
[ { "answer_id": 286569, "author": "cagcowboy", "author_id": 19629, "author_profile": "https://Stackoverflow.com/users/19629", "pm_score": 6, "selected": true, "text": "v_procedure_name := $$PLSQL_UNIT;\n" }, { "answer_id": 18705074, "author": "T. L. Jones", "author_id": 27...
2008/11/13
[ "https://Stackoverflow.com/questions/286549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23220/" ]
286,564
<p>Does Ruby have any tools along the lines of <a href="http://pypi.python.org/pypi/pylint" rel="noreferrer">pylint</a> for analyzing source code for errors and simple coding standards?</p> <p>It would be nice if it could be integrated with <a href="http://cruisecontrolrb.thoughtworks.com/" rel="noreferrer">cruisecontrolrb</a> for continuous integration.</p> <p>Or does everyone write such good tests that they don't need source code checkers!</p>
[ { "answer_id": 310940, "author": "Atiaxi", "author_id": 2555346, "author_profile": "https://Stackoverflow.com/users/2555346", "pm_score": 2, "selected": false, "text": "ruby -w\n" }, { "answer_id": 892656, "author": "Community", "author_id": -1, "author_profile": "htt...
2008/11/13
[ "https://Stackoverflow.com/questions/286564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2761/" ]
286,565
<p>I'm using a QTableWidget to display several rows. Some of these rows should reflect an error and their text color is changed :</p> <p>Rows reflecting that there is no error are displayed with a default color (black text on white background on my computer).<br> Rows reflecting that there is an error are displayed with a red text color (which is red text on white background on my computer).</p> <p>This is all fine as long as there is no selection. As soon as a row is selected, no matter of the unselected text color, the text color becomes always white (on my computer) over a blue background.</p> <p>This is something I would like to change to get the following :<br> When a row is selected, if the row is reflecting there is no error, I would like it to be displayed with white text on blue background (default behavior).<br> If the row is reflecting an error and is selected, I would like it to be displayed with red text on blue background.</p> <p>So far I have only been able to change the selection color for the whole QTableWidget, which is not what I want !</p>
[ { "answer_id": 287660, "author": "Caleb Huitt - cjhuitt", "author_id": 9876, "author_profile": "https://Stackoverflow.com/users/9876", "pm_score": 0, "selected": false, "text": "QAbstractItemDelegate" }, { "answer_id": 298160, "author": "Jérôme", "author_id": 2796, "a...
2008/11/13
[ "https://Stackoverflow.com/questions/286565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2796/" ]
286,570
<p>I have several init.d scripts that I'm using to start some daemons. Most of these scripts I've found on the internet and they all use start-stop-daemon. My understanding is that "start-stop-daemon" is a command that is specific to Linux or BSD distros and is not available on Solaris.</p> <p>What is the best way to translate my init.d scripts from Linux to Solaris? Is there a command equivalent to start-stop-daemon that I can use, roughly?</p> <p>Since I'm not much of a Solaris user, I'm willing to admit upfront that I don't even know if my question is inherently invalid or not.</p>
[ { "answer_id": 286673, "author": "Anders Westrup", "author_id": 36845, "author_profile": "https://Stackoverflow.com/users/36845", "pm_score": 4, "selected": true, "text": "svcs" }, { "answer_id": 674955, "author": "Community", "author_id": -1, "author_profile": "https...
2008/11/13
[ "https://Stackoverflow.com/questions/286570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35341/" ]
286,571
<p>As the title really, I'm in one part of my code and I would like to invoke any methods that have been added to the Button.Click handler.</p> <p>How can I do this?</p>
[ { "answer_id": 286595, "author": "Lars Mæhlum", "author_id": 960, "author_profile": "https://Stackoverflow.com/users/960", "pm_score": 1, "selected": false, "text": " private EventHandler ButtonClick;\n\n protected override void CreateChildControls()\n {\n base.CreateChil...
2008/11/13
[ "https://Stackoverflow.com/questions/286571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26081/" ]
286,583
<p>I want to print styled html pages with their images from a script. Can anyone suggest an open-source solution?</p> <p>I'm using linux (Ubuntu 8.04) but would be also be interested in solutions for other operating systems.</p>
[ { "answer_id": 286698, "author": "Tader", "author_id": 30700, "author_profile": "https://Stackoverflow.com/users/30700", "pm_score": 4, "selected": true, "text": "sudo aptitude install html2ps" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20074/" ]
286,584
<p>I need a member of my class to be a Control, and for it to implement an interface we define.</p> <p>If I declare it like this...</p> <pre><code>public class MyClass { public Control MyMember; } </code></pre> <p>... then I don't get the interface methods, but if I declare it like this...</p> <pre><code>public class MyClass { public IMyInterface MyMember; } </code></pre> <p>...then I don't get the Control methods. Is there a way to specify that MyMember must be initialised to a type that inherits from both? I can't find one on MSDN. Something like...</p> <pre><code>public class MyClass { public Control : IMyInterface MyMember; } </code></pre> <p>... or ...</p> <pre><code>public class MyClass { public Control MyMember : IMyInterface; } </code></pre> <p>... except that neither of those work. Can I specify interfaces when I declare a member, and if so, how?</p>
[ { "answer_id": 286591, "author": "VVS", "author_id": 21038, "author_profile": "https://Stackoverflow.com/users/21038", "pm_score": -1, "selected": false, "text": "public interface IMyInterface : Control\n{\n ..\n}\n" }, { "answer_id": 286597, "author": "TcKs", "author_id...
2008/11/13
[ "https://Stackoverflow.com/questions/286584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
286,589
<p>I'm writing a ruby program that executes some external command-line utilities. How could I mock the filesystem from my rspec tests so that I could easily setup some file hierarchy and verify it after testing. It would also be best to be implemented in ram so that tests would run quickly. </p> <p>I realize that I may not find a portable solution as my external utilities are native programs interacting directly with operating system file services. Linux is my primary platform and solution for that would suffice.</p>
[ { "answer_id": 286796, "author": "Adam Byrtek", "author_id": 36656, "author_profile": "https://Stackoverflow.com/users/36656", "pm_score": 4, "selected": true, "text": "File.exist?" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30958/" ]
286,594
<p>I normally work on single threaded applications and have generally never really bothered with dealing with threads. My understanding of how things work - which certainly, may be wrong - is that as long as we're always dealing with single threaded code (i.e. no forks or anything like that) it will always be executed in the same thread.</p> <p>Is this assumption correct? I have a fuzzy idea that UI libraries/frameworks may spawn off threads of their own to handle GUI stuff (which accounts for the fact that the Windows task manager tells me that my 'single threaded' application is actually running on 10 threads) but I'm guessing that this shouldn't affect me?</p> <p>How does this apply to COM? For instance, if I were to create an instance of a COM component in my code; and that COM component writes some information to a thread-based location (using <code>System.Threading.Thread.GetData</code> for instance) will my application be able to get hold of that information?</p> <p>So in summary:</p> <ol> <li><p>In single threaded code, can I be sure that whatever I store in a thread-based location can be retrievable from anywhere else in the code?</p></li> <li><p>If that single threaded code were to create an instance of a COM component which stores some information in a thread-based location, can that be similarly retrievable from anywhere else?</p></li> </ol>
[ { "answer_id": 286664, "author": "Marco M.", "author_id": 28375, "author_profile": "https://Stackoverflow.com/users/28375", "pm_score": 3, "selected": true, "text": "void AssertSingleThread()\n{\n if (m_ThreadId < 0) m_ThreadId = Thread.CurrentThread.ManagedThreadId;\n Debug.Assert(m...
2008/11/13
[ "https://Stackoverflow.com/questions/286594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4368/" ]
286,603
<p>I have an application that uses <code>Ajax.Request</code> and its <code>onSuccess</code> event handler in lots of places.</p> <p>I need to call a function (that will check the response) before all these <code>onSuccess</code> events fire. I tried using <code>Ajax.Responders.register</code> with <code>onComplete</code> event but it fires after <code>Ajax.Request</code>'s <code>onSuccess</code> event. Any suggestions?</p>
[ { "answer_id": 286672, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "Ajax.Request" }, { "answer_id": 304636, "author": "Thomas Hansen", "author_id": 29746, "author_profile...
2008/11/13
[ "https://Stackoverflow.com/questions/286603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25768/" ]
286,605
<p>I am trying to create a Key Listener in java however when I try </p> <pre><code>KeyListener listener = new KeyListener(); </code></pre> <p>Netbeans is telling me that KeyListener is abstract;cannot be instantiated. I know that I am missing some other piece of this key listener, but since this is my first time using a key listener i am unsure of what else i need. Why is it telling me this?</p> <p>Thanks,</p> <p>Tomek</p>
[ { "answer_id": 286613, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "KeyListener" }, { "answer_id": 287500, "author": "Joey Gibson", "author_id": 6645, "author_profile": ...
2008/11/13
[ "https://Stackoverflow.com/questions/286605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29326/" ]
286,606
<p>In the application there is a dialog where only numeric string entries are valid. Therefore I would like to set the numeric keyboard layout.</p> <p>Does anyone know how to simulate key press on the keyboard or any other method to change the keyboard layout?</p> <p>Thanks!</p>
[ { "answer_id": 286785, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 0, "selected": false, "text": "InputModeEditor.SetInputMode(textBox1,InputMode.Numeric);\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22996/" ]
286,614
<p>I'm developing an application with a team in .Net (C++) and provide a COM interface to interact with python and other languages.</p> <p>What we've found is that pushing data through COM turns out to be pretty slow.</p> <p>I've considered several alternatives:</p> <ul> <li>dumping data to a file and sending the file path through com</li> <li>Shared Memory via <a href="http://docs.python.org/library/mmap.html?highlight=shared%20memory#module-mmap" rel="nofollow noreferrer">mmap</a>?</li> <li>Stream data through a socket directly?</li> </ul> <p>From your experience what's the best way to pass around data?</p>
[ { "answer_id": 286738, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 4, "selected": true, "text": "win32pipe" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/286614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24718/" ]
286,619
<p>I am using a .Net <code>HtmlTextWriter</code> to generate HTML.</p> <pre><code>try { htw.RenderBeginTag( HtmlTextWriterTag.Span ); htw.Write(myObject.GenerateHtml()); htw.RenderEndTag( ); } catch (Exception e) { GenerateHtmlErrorMessage(htw); } </code></pre> <p>In this example, if an error exception is fired during <code>myObject.GenerateHtml()</code>, I will generate a nice error html but it will be preceded by an opening <code>span</code> tag that is never closed.</p> <p>I could refactor it like so</p> <pre><code>try { string myHtml = myObject.GenerateHtml(); // now hope we don't get any more exceptions htw.RenderBeginTag( HtmlTextWriterTag.Span ); htw.Write(myHtml) htw.RenderEndTag( ); } catch (Exception e) { GenerateHtmlErrorMessage(htw); } </code></pre> <p>Now my span doesn't open 'till I've done the hard work, but this just looks awkward to me. Is there any way do rollback with a HtmlWriter? Even if I had to put in loads of using blocks.</p> <p>I'm currently working in .Net 2.0, but a discussion of solutions in 3.5 would be ok.</p>
[ { "answer_id": 286661, "author": "Mikael Söderström", "author_id": 36944, "author_profile": "https://Stackoverflow.com/users/36944", "pm_score": -1, "selected": false, "text": "if (myHTML != null)\n{\n htw.RenderBeginTag( HtmlTextWriterTag.Span );\n htw.Write(myHtml) \n htw.Ren...
2008/11/13
[ "https://Stackoverflow.com/questions/286619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107/" ]
286,624
<p>I am reading log files but not all lines want to be processed straight away. I am using a queue / buffer to store the lines while they wait to be processed.</p> <p>This queue is regularly scanned for particular lines - when they are found, they are removed from the queue (they can be anywhere in it). When there isn't a particular line to be found, lines are taken out of the start of the queue one by one to be processed.</p> <p>Therefore, the queue needs the following:</p> <ul> <li>Able to be resized (or give that impression)</li> <li>Have elements removed from anywhere</li> <li>Have elements added (will always be at the end of the queue)</li> <li>Be scanned quickly</li> <li>Depending on performance, have a pointer of where it got to on the last scan.</li> </ul> <p>I initially wrote the code when I had little experience of Java or the API, and just used an ArrayList because I knew it would work (not necessarily because it was the best option).</p> <p>Its performance is now becoming poor with more and more logs needing to be processed - so, what collection would you recommend to be used in this situation? There's always the possibility of writing my own too.</p> <p>Thanks</p>
[ { "answer_id": 286874, "author": "James Camfield", "author_id": 35033, "author_profile": "https://Stackoverflow.com/users/35033", "pm_score": 1, "selected": false, "text": "HashMap<String,LinkedList<String>>\n" }, { "answer_id": 287172, "author": "Bill Michell", "author_i...
2008/11/13
[ "https://Stackoverflow.com/questions/286624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35033/" ]