qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
221,267
<p>What is the simplest way of copying symbolic links on the Mac?</p> <p>A python or perl solution would be preferred, but any solution would be a help.</p> <p>I am copying frameworks for an installation package, and need the links to be maintained</p>
[ { "answer_id": 221305, "author": "Florian Bösch", "author_id": 19435, "author_profile": "https://Stackoverflow.com/users/19435", "pm_score": 2, "selected": false, "text": "import os, stat\nif stat.S_ISLNK(os.lstat('foo').st_mode):\n src = os.readlink('source')\n os.symlink(src, 'de...
2008/10/21
[ "https://Stackoverflow.com/questions/221267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/259/" ]
221,273
<p>I've been given a prototype/mockup of a grid written in html and javascript (via ExtJS) that I now need to implement within an ASP.net web application. Does anyone have any pointers as to how to pass data to the grid (to a GroupingStore, specifically). </p> <p>I'd rather not have a proliferation of web services or helper pages returning XML/JSON so if there's a way to use Client callbacks or Page Methods (Can't you tell I'm not particularly familiar with either - buzzword bingo!) or somesuch, that would be preferred.</p> <p>Please, no recommendations that I use jQuery, the built-in ASP.net grid, or any other UI framework. The use of the ExtJS grid has been mandated by the powers that be, so that's the grid I'm using, for better or worse :)</p>
[ { "answer_id": 221360, "author": "tobinharris", "author_id": 1136215, "author_profile": "https://Stackoverflow.com/users/1136215", "pm_score": 2, "selected": true, "text": "http://mysite.com/query.aspx?sql=select * from orders where status = 'open'\n" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7872/" ]
221,277
<p>I'm trying to do XHTML DOM parsing with JTidy, and it seems to be rather counterintuitive task. In particular, there's a method to parse HTML:</p> <pre><code>Node Tidy.parse(Reader, Writer) </code></pre> <p>And to get the &lt;body /&gt; of that Node, I assume, I should use</p> <pre><code>Node Node.findBody(TagTable) </code></pre> <p>Where should I get an instance of that TagTable? (Constructor is protected, and I haven't found a factory to produce it.)</p> <p>I use JTidy 8.0-SNAPSHOT.</p>
[ { "answer_id": 221327, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 2, "selected": false, "text": "parseDOM" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1764/" ]
221,283
<p>I like to keep my shell sessions named with useful titles as I work, this helps me keep track of what I'm using each of the many tabs for.</p> <p>Currently to rename a session I double click its name on the tabbed part of the console - is there any command that I can use to do this from within the shell? It would save me a bit of time.</p> <p>thanks in advance</p> <p>edit :- I am using KDE's Konsole shell.</p>
[ { "answer_id": 221293, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 2, "selected": false, "text": "echo -n \"\\033]0;New Window Title\\007\"\n" }, { "answer_id": 222216, "author": "ephemient", "author_id": ...
2008/10/21
[ "https://Stackoverflow.com/questions/221283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22061/" ]
221,287
<p>I've noticed that when you create a web service object (inheriting from SoapHttpClientProtocol) and you use the Async method, it makes the callback on the Windows GUI thread.</p> <ol> <li>Does anyone know how this works?</li> <li>How can I achieve the same thing.</li> </ol> <p>I figure this will save me having to check for InvokeRequired in my GUI forms if I am sure the callback is always occurring on the gui thread.</p>
[ { "answer_id": 221506, "author": "Richard Nienaber", "author_id": 9539, "author_profile": "https://Stackoverflow.com/users/9539", "pm_score": 2, "selected": false, "text": " public partial class AsyncTest : Form\n {\n static void Main()\n {\n Application.Ru...
2008/10/21
[ "https://Stackoverflow.com/questions/221287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9539/" ]
221,292
<p>I have a problem with Crystal Reports 8. When exporting a report from my application, Crystal Reports <strong>sometimes</strong> freezes. The progress windows just stays, saying X of X records exported.</p> <ol> <li>Smaller reports with less data are more likley to freeze.</li> <li>Faster workstations (P4, Core2) tend to freeze much more often, sometimes every second try. On older workstations (&lt; P2) no freezing happens at all, or at least once every one or two days.</li> <li>The export format (rtf, pdf, html, rpt) does not influence the freezing behavior.</li> <li>The same report can be successfully exported multiple times with excactly the same data, but eventually it will freeze.</li> <li>No freezing happens on Windows Vista (!)</li> </ol> <p>Is there a way to stop this or at least a way to predict a freeze?</p>
[ { "answer_id": 1321068, "author": "Daniel Rikowski", "author_id": 23368, "author_profile": "https://Stackoverflow.com/users/23368", "pm_score": 3, "selected": true, "text": "WaitForSingleObject(?, INFINITE)" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23368/" ]
221,294
<p>I want a single number that represents the current date and time, like a <a href="https://en.wikipedia.org/wiki/Unix_time" rel="noreferrer">Unix timestamp</a>.</p>
[ { "answer_id": 221297, "author": "daveb", "author_id": 11858, "author_profile": "https://Stackoverflow.com/users/11858", "pm_score": 13, "selected": true, "text": "Date.now" }, { "answer_id": 221357, "author": "Staale", "author_id": 3355, "author_profile": "https://St...
2008/10/21
[ "https://Stackoverflow.com/questions/221294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6068/" ]
221,307
<p>I've been scanning through all the popular js libraries, but I can't find one that has a width function for a DOM element that actually accounts for quirks mode in Internet Explorer. The issue is that padding and borders don't get counted in the the width when quirks mode is engaged. As far as I can tell this happens when the doctype is left out or the doctype is set to html 3.2.</p> <p>Obviously I could just set the doctype to something standards compliant, but this script can be embedded anywhere so I don't have control over the doctype.</p> <p>To break the problem down into smaller parts:</p> <p>1) How do you detect quirks mode? 2) What's the best way to extract the border and padding from an element to compensate?</p> <p>Example with prototype:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="mydiv" style="width: 250px; pading-left: 1px; border: 2px black solid"&gt;hello&lt;/div&gt; &lt;script&gt; alert($('mydiv').getWidth()) &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>result:</p> <p>253 (ff) 250 (ie)</p> <p>Thanks in advance!</p>
[ { "answer_id": 221405, "author": "Aleris", "author_id": 20417, "author_profile": "https://Stackoverflow.com/users/20417", "pm_score": 1, "selected": false, "text": "<div id=\"mydiv\" style=\"width: 100px; border-left: 100px black solid;\">&nbsp;</div>\n" }, { "answer_id": 221703,...
2008/10/21
[ "https://Stackoverflow.com/questions/221307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29899/" ]
221,311
<p>I have a sea of weighted nodes with edges linking clusters of nodes together. This graph follows the typical small world layout.</p> <p>I wish to find a path finding algorithm, which isn't costly on processor power, to find a path along the best possible path where the nodes are the most favorably weighted, the fastest route is not the most important factor. This algorithm, also takes into consideration load bearing, and traffic rerouting.</p> <p>(sidenote: could neural networks be used here?)</p> <p>Thanks</p> <hr> <p>I'm looking at <a href="http://www.scholarpedia.org/article/Ant_colony_optimization" rel="noreferrer"><strong>ACO</strong></a>. Is there anything better than ACO for this kind of problem?</p> <hr> <p>Right the <a href="http://en.wikipedia.org/wiki/A%2A" rel="noreferrer"><strong>A*</strong></a> algorithm finds the least cost or fastest route, without load balancing.</p> <p>Lets say that the fastest or shortest route is not the most important route, what is more important is following a path where the weighted nodes have a certain value. no1.</p> <p>no2. If using A* the traffic on that route gets overloaded then suddenly that path is redundant. So as cool as A* is, it doesnt have certain features that ACO ie inherent load balancing.</p> <p>-- unless im mistaken and misunderstood A*</p> <p>Then what beats ACO?</p> <hr> <p>It really looks like a show down between ACO and A* , there has been so much positive talk about A* , I will certainly look deeper into it.</p> <p>Firstly in response to David; I can run ACO simulation in the back ground and come up with the best path, so yes there is an initial startup cost but the startup luckily isnt essential. So i can afford to run a simulation multiple times. The one real trouble is finding connected source and destination nodes. Whereas it seems A* will be able to do this quite easily. Now what happens when this network get dreadfully large like in millions of nodes. Will A* be able to scale easily?</p> <p>I will research A* further. But I leave you with a last question!</p> <p>Will A* be able to scale as well as Antnet (ACO)?</p>
[ { "answer_id": 221454, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": 3, "selected": false, "text": "A---1---B---1---C\n| |\n\\-------1-------/\n" }, { "answer_id": 50149961, "author": "Alexandr Zhyten...
2008/10/21
[ "https://Stackoverflow.com/questions/221311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
221,317
<p>I've created a custom search page with some defined options in my search scope.</p> <p>I have a metadata mapped <code>jobtitle</code>, and added the search option to my custom search.</p> <pre><code>&lt;Property name="JobTitle" ManagedName="title" ProfileURI="urn:schemas-microsoft-com:sharepoint:portal:profile:Title"/&gt; </code></pre> <p>I want to change my managed name to <code>jobtitle</code>, because title doesn't hit the dutch word for jobtitle. I changed the managed name to <code>jobtitle</code>, after applying the changes it wouldn't change the label.</p> <p>Anyone have an idea?</p>
[ { "answer_id": 227583, "author": "RedDeckWins", "author_id": 1646, "author_profile": "https://Stackoverflow.com/users/1646", "pm_score": 1, "selected": false, "text": "xsl/xml" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28139/" ]
221,320
<p>For a file containing the given class, SomeCoolClass, what would be the proper or standard filename?</p> <pre> 1. somecoolclass.rb 2. some_cool_class.rb 3. some-cool-class.rb 4. SomeCoolClass.rb </pre> <p>or some other variation?</p> <p>I noticed in the Ruby stdlib, versions 1, 2 and 3 are used.</p>
[ { "answer_id": 221391, "author": "Daniel Beardsley", "author_id": 13216, "author_profile": "https://Stackoverflow.com/users/13216", "pm_score": 7, "selected": true, "text": "lowercase_and_underscore.rb" }, { "answer_id": 222178, "author": "Pistos", "author_id": 28558, ...
2008/10/21
[ "https://Stackoverflow.com/questions/221320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
221,345
<p>I am currently writing a system that stores meta data for around 140,000 ish images stored within a legacy image library that are being moved to cloud storage. I am using the following to get the jpg data...</p> <pre><code>System.Drawing.Image image = System.Drawing.Image.FromFile("filePath"); </code></pre> <p>Im quite new to image manipulation but this is fine for getting simple values like width, height, aspect ratio etc but what I cannot work out is how to retrieve the physical file size of the jpg expressed in bytes. Any help would be much appreciated.</p> <p>Thanks</p> <p>Final solution including an MD5 hash of the image for later comparison</p> <pre><code>System.Drawing.Image image = System.Drawing.Image.FromFile(filePath); if (image != null) { int width = image.Width; int height = image.Height; decimal aspectRatio = width &gt; height ? decimal.divide(width, height) : decimal.divide(height, width); int fileSize = (int)new System.IO.FileInfo(filePath).Length; using (System.IO.MemoryStream stream = new System.IO.MemoryStream(fileSize)) { image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); Byte[] imageBytes = stream.GetBuffer(); System.Security.Cryptography.MD5CryptoServiceProvider provider = new System.Security.Cryptography.MD5CryptoServiceProvider(); Byte[] hash = provider.ComputeHash(imageBytes); System.Text.StringBuilder hashBuilder = new System.Text.StringBuilder(); for (int i = 0; i &lt; hash.Length; i++) { hashBuilder.Append(hash[i].ToString("X2")); } string md5 = hashBuilder.ToString(); } image.Dispose(); } </code></pre>
[ { "answer_id": 221348, "author": "Ilya Ryzhenkov", "author_id": 18575, "author_profile": "https://Stackoverflow.com/users/18575", "pm_score": 7, "selected": true, "text": " var fileLength = new FileInfo(filePath).Length; \n" }, { "answer_id": 221353, "author": "MysticSlayer",...
2008/10/21
[ "https://Stackoverflow.com/questions/221345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12918/" ]
221,346
<p>What is the arrow operator (<code>-&gt;</code>) a synonym for?</p>
[ { "answer_id": 221351, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 8, "selected": true, "text": "a->b\n\n(*a).b\n" }, { "answer_id": 221354, "author": "Konrad Rudolph", "author_id": 1968, "author_pro...
2008/10/21
[ "https://Stackoverflow.com/questions/221346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4975/" ]
221,365
<p>If I have a folder structure set up like this:</p> <pre><code>~/Projects emacs package1 package1-helpers package2 package2-helpers package2-more-helpers package3 package3-helpers </code></pre> <p>How do I add these folders:</p> <ul> <li>~/Projects/emacs</li> <li>~/Projects/emacs/package1</li> <li>~/Projects/emacs/package2</li> <li>~/Projects/emacs/package3</li> </ul> <p>...to the <code>load-path</code> from my .emacs file?</p> <p>I basically need a short automated version of this code:</p> <pre><code>(add-to-list 'load-path "~/Projects/emacs") (add-to-list 'load-path "~/Projects/emacs/package1") (add-to-list 'load-path "~/Projects/emacs/package2") (add-to-list 'load-path "~/Projects/emacs/package3") </code></pre>
[ { "answer_id": 221449, "author": "Jouni K. Seppänen", "author_id": 26575, "author_profile": "https://Stackoverflow.com/users/26575", "pm_score": 5, "selected": true, "text": "(let ((base \"~/Projects/emacs\"))\n (add-to-list 'load-path base)\n (dolist (f (directory-files base))\n (l...
2008/10/21
[ "https://Stackoverflow.com/questions/221365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/712/" ]
221,370
<p>Is there an easy way with LINQ to flatten an XML file?</p> <p>I can see a number of ways with XSLT but wondered what the best option with LINQ would be?</p> <p>I cant put the xml structure up exactly as stackoverflow seems to filter chevron chars. But its something like this </p> <p>nodeA </p> <p>--nodeA1 </p> <p>--nodeA2 </p> <p>NodeB </p> <p>I want to end up with </p> <p>nodeA </p> <p>nodeA1</p> <p>nodeA2 </p> <p>NodeB</p>
[ { "answer_id": 221377, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": true, "text": "string xml = @\"<xml><nodeA><nodeA1/><nodeA2/></nodeA><NodeB/></xml>\";\n\nXmlDocument doc = new XmlDocument();\ndoc.L...
2008/10/21
[ "https://Stackoverflow.com/questions/221370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23066/" ]
221,373
<p>Sometimes, when we're doing small changes to our web apps, e.g. bug fixes, we don't build a whole new WAR-file each time, but merely replace just the affected class files in the exploded web app directory under <code>WEB-INF/classes</code> and restart the app.</p> <p>Is that okay?</p>
[ { "answer_id": 221811, "author": "miceuz", "author_id": 24443, "author_profile": "https://Stackoverflow.com/users/24443", "pm_score": 2, "selected": false, "text": "svn update\nmvn clean compile war:exploded tomcat:inplace -P deployment\n" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18722/" ]
221,376
<p>I need to include a copyright statement at the top of every Python source file I produce:</p> <pre><code># Copyright: © 2008 etc. </code></pre> <p>However, when I then run such a file I get this message:</p> <p>SyntaxError: Non-ASCII character '\xa9' in file MyFile.py on line 3, but no encoding declared; see <a href="http://www.python.org/peps/pep-0263.html" rel="noreferrer">http://www.python.org/peps/pep-0263.html</a> for details.</p> <p>Apparently Python isn't happy about the copyright symbol because it assumes the source file is all in ASCII. Either I need to make my first line be:</p> <pre><code># -*- coding: iso-8859-1 -*- </code></pre> <p>to tell Python I'm using Latin encoding, or I can change the copyright statement to: </p> <pre><code># Copyright: \xa9 2008 etc. </code></pre> <p>which just possibly doesn't have the same legal standing.</p> <p>Is there a more elegant solution?</p>
[ { "answer_id": 221380, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 6, "selected": true, "text": "(c)" }, { "answer_id": 19210542, "author": "sergio", "author_id": 2852044, "author_profile": "https://St...
2008/10/21
[ "https://Stackoverflow.com/questions/221376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11677/" ]
221,378
<p>I appreciate that there are now many mechanisms in dotnet to deal with XML in a myriad of ways... </p> <p>Suppose I have a string containing the XML....</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;root&gt; &lt;Element1&gt; &lt;Element1_1&gt; SomeData &lt;/Element1_1&gt; &lt;/Element1&gt; &lt;Element2&gt; Some More Data &lt;/Element2&gt; &lt;/root&gt; </code></pre> <p><strong>What is the simplest (most readable) way of removing Element1_1?</strong></p> <p>Update... I can use any .Net API available in .Net 3.5 :D </p>
[ { "answer_id": 221383, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "XElement element = doc.XPathSelectElement(\"/root/Element1/Element1_1\");\nelement.Remove();\n" }, { "answer_id":...
2008/10/21
[ "https://Stackoverflow.com/questions/221378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
221,379
<p>Is it okay to run Hibernate applications configured with <code>hbm2ddl.auto=update</code> to update the database schema in a production environment?</p>
[ { "answer_id": 336101, "author": "cliff.meyers", "author_id": 41754, "author_profile": "https://Stackoverflow.com/users/41754", "pm_score": 5, "selected": false, "text": "String with @Column(length=50) ==> varchar(50)\nchanged to\nString with @Column(length=100) ==> still varchar(50), n...
2008/10/21
[ "https://Stackoverflow.com/questions/221379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18722/" ]
221,385
<p>Has anyone gotten the jquery plugin <a href="http://www.appelsiini.net/projects/jeditable" rel="nofollow noreferrer">jeditable</a> to run properly in a Rails applications. If so, could you share some hints on how to set it up? I'm having some trouble with creating the "submit-url".</p> <hr> <p>IIRC, you cannot simply call ruby code from within javascript (please let me be wrong:-). Do you mean RJS??? Isn't that limited to Prototype? I'm using jQuery.</p> <hr> <p><strong>UPDATE:</strong><br> uh.....asked this a while back and in the meantime switched to a different solution. But IIRC my main issue was the following:</p> <p>I'm using the RESTful resources. So let's say I have to model a blog and thus have the resource "posts". If I want to edit a post (e.g. the post with the ID 8), my update is sent via HTTP to the URL <a href="http://my.url.com/posts/8" rel="nofollow noreferrer">http://my.url.com/posts/8</a> with the HTTP verb POST. This URL however is constructed in my Rails code. So how would I get my submit-url into my jQuery code? Since this is RESTful code, my update URL will change with every post.</p>
[ { "answer_id": 259187, "author": "jonnii", "author_id": 4590, "author_profile": "https://Stackoverflow.com/users/4590", "pm_score": 0, "selected": false, "text": "<%= url_for(@post) %>\n" }, { "answer_id": 259755, "author": "Sebastian", "author_id": 29909, "author_pro...
2008/10/21
[ "https://Stackoverflow.com/questions/221385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29909/" ]
221,386
<p>I would like to trim long sequences of the same value from a binary file in python. A simple way of doing it is simply reading in the file and using re.sub to replace the unwanted sequence. This will of course not work on large binary files. Can it be done in something like numpy?</p>
[ { "answer_id": 221696, "author": "Alex Coventry", "author_id": 1941213, "author_profile": "https://Stackoverflow.com/users/1941213", "pm_score": 0, "selected": false, "text": "subprocess" }, { "answer_id": 221851, "author": "dbr", "author_id": 745, "author_profile": "...
2008/10/21
[ "https://Stackoverflow.com/questions/221386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29908/" ]
221,387
<p>I need a way to check for Wi-Fi routers/access points on my DS homebrew. I'm using PAlib.</p>
[ { "answer_id": 825415, "author": "PypeBros", "author_id": 15304, "author_profile": "https://Stackoverflow.com/users/15304", "pm_score": 2, "selected": false, "text": "Wifi_ScanMode()" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1599/" ]
221,396
<p>Is it possible to call a function from PHP using <code>onsubmit</code> from JavaScript? If so could someone give me an example of how it would be done?</p> <pre><code>function addOrder(){ $con = mysql_connect("localhost", "146687", "password"); if(!$con){ die('Could not connect: ' . mysql_error()) } $sql = "INSERT INTO orders ((user, 1st row, 2nd row, 3rd row, 4th row) VALUES ($session-&gt;username,1st variable, 2nd variable, 3rd variable, 4th variable))"; mysql_query($sql,$con) if(mysql_query($sql,$con)){ echo "Your order has been added"; }else{ echo "There was an error adding your order to the databse: " . mysql_error(); } } </code></pre> <p>That's the function I am wanting to call. Its an ordering system, you type in how much of each item you want, hit submit and it <em>should</em> add the order to the table.</p>
[ { "answer_id": 221658, "author": "e-satis", "author_id": 9951, "author_profile": "https://Stackoverflow.com/users/9951", "pm_score": 5, "selected": true, "text": "$.ajax({\n type: \"POST\", // the request type. You most likely going to use POST\n url: \"your_php_script.php\", // the ...
2008/10/21
[ "https://Stackoverflow.com/questions/221396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29912/" ]
221,399
<p>I am using <strong>mysql (5.0.32-Debian_7etch6-log)</strong> and i've got a nightly running bulk load <strong>php (5.2.6)</strong> script <strong>(using Zend_DB (1.5.1)</strong> via PDO) which does the following:</p> <ol> <li>truncating a set of 4 'import' tables</li> <li>bulk inserting data into these 4 'import' tables (re-using ids that have previously been in the tables as well, but i truncated the whole table, so that shouldn't be an issue, right?)</li> <li>if everything goes well, rename the 'live' tables to 'temp', the 'import' tables to 'live' and then the 'temp' (old 'live') tables to 'import'</li> </ol> <p>This worked great for weeks. Now I am occassionally getting this, somewhere in the middle of the whole bulk loading process:</p> <p><code>SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '911' for key 1</code></p> <p>Mind you that, this is not the first id that has been in the table before the truncation already. When I just start the script manually again, it works like a charm.</p> <p>Any ideas? leftover indexes, something to do with the renaming maybe?</p> <p>In addition, when I check the table for an entry with the id 911 afterwards, it is not even in there.</p>
[ { "answer_id": 222904, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "DELETE FROM" }, { "answer_id": 224223, "author": "Community", "author_id": -1, "author_profile": "https://...
2008/10/21
[ "https://Stackoverflow.com/questions/221399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
221,410
<p>I need to be able to logoff any user from his windows session from a program. </p> <p>I know I could log in as an admin and force a remote logoff. Is there any other way to force a logoff without logging in? </p> <p>The tool will run as admin so that's not a problem, being able to remote logoff without logging in is.</p> <p>Tool is in .NET, but any other way is welcome (JScript, command line tool to run from PInvoke, etc.)</p>
[ { "answer_id": 222192, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 1, "selected": false, "text": "' Logoff.vbs, Version 1.00\n' Logoff current user on any WMI enabled computer on the network\n'\n' Adapted from post...
2008/10/21
[ "https://Stackoverflow.com/questions/221410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5190/" ]
221,411
<p>I'm creating window using pure Win32 API (RegisterClass and CreateWindow functions). How can I specify a font for the window instead of system defined one?</p>
[ { "answer_id": 221419, "author": "vividos", "author_id": 23740, "author_profile": "https://Stackoverflow.com/users/23740", "pm_score": 3, "selected": false, "text": "CreateFont" }, { "answer_id": 224457, "author": "Bob Jones", "author_id": 2067, "author_profile": "htt...
2008/10/21
[ "https://Stackoverflow.com/questions/221411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
221,432
<p>I'm opening a new browser window from my site for some of the members. However, some may later close it, or it might have initially failed to open.</p> <p>Is there a snippet of fairly plain Javascript that can be run on each page to confirm if another browser window is open, and if not, to provide a link to re-open it?</p> <p><strong>[clarification:]</strong> The code to check is a window is open would be run on other pages - not just in the same window and URL that opened it. Imagine a user logging in, the window (tries to) open, and then they surf around in the same tab/window (or others) for some time before they close the 2nd window (or it never opened) - I want to be able to notice the window has been closed some time after the initial attempt at opening/after it's closed, so I'm not sure that checking the javascript's return from window.open() (with popup_window_handle.closed) is easily used, or indeed possible.</p>
[ { "answer_id": 221439, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 1, "selected": false, "text": "var myWin = window.open(...);\n\nif (myWin.closed)\n{\n myWin = window.open(...);\n}\n" }, { "answer_id": 221461, ...
2008/10/21
[ "https://Stackoverflow.com/questions/221432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6216/" ]
221,434
<p>I'm trying to serve dynamically generated xml pages from a web server, and provide a custom, static, xslt from the same web server, that will offload the processing into the client web browser.</p> <p>Until recently, I had this working fine in Firefox 2, 3, IE5, 6 and Chrome. Recently, though, something has changed, and Firefox 3 now displays just the text elements in the source.</p> <p>The page source starts like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!-- Firefox 2.0 and Internet Explorer 7 use simplistic feed sniffing to override desired presentation behavior for this feed, and thus we are obliged to insert this comment, a bit of a waste of bandwidth, unfortunately. This should ensure that the following stylesheet processing instruction is honored by these new browser versions. For some more background you might want to visit the following bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=338621 --&gt; &lt;?xml-stylesheet type="text/xsl" href="/WebObjects/SantaPreview.woa/Contents/WebServerResources/Root.xsl"?&gt; &lt;wrapper xmlns="http://www.bbc.co.uk/ContentInterface/Content" xmlns:cont="http://www.bbc.co.uk/ContentInterface/Content" sceneId="T2a_INDEX" serviceName="DSat_T2"&gt; .... </code></pre> <p>Firebug shows that the Root.xsl file is being loaded, and the response headers for it include the line</p> <pre><code>Content-Type text/xml </code></pre> <p><em>I've also tried it with application/xml as the content type, but it makes no difference :-(</em></p> <p>The Web Developer Extension shows the correct generated source too, and if you save this and load the page in Firefox, it displays correctly.</p> <p>The version of Firefox displaying the problem is 3.0.3</p> <p>Any ideas what I might be doing wrong?</p>
[ { "answer_id": 3925500, "author": "Prof. Falken", "author_id": 193892, "author_profile": "https://Stackoverflow.com/users/193892", "pm_score": 2, "selected": false, "text": "_" }, { "answer_id": 16191491, "author": "Thomas Leonard", "author_id": 50926, "author_profile...
2008/10/21
[ "https://Stackoverflow.com/questions/221434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7938/" ]
221,442
<p>With JSR 311 and its implementations we have a powerful standard for exposing Java objects via REST. However on the client side there seems to be something missing that is comparable to Apache Axis for SOAP - something that hides the web service and marshals the data transparently back to Java objects.</p> <p>How do you create Java RESTful clients? Using HTTPConnection and manual parsing of the result? Or specialized clients for e.g. Jersey or Apache CXR?</p>
[ { "answer_id": 221763, "author": "James Strachan", "author_id": 2068211, "author_profile": "https://Stackoverflow.com/users/2068211", "pm_score": 6, "selected": false, "text": " clientConfig = new DefaultClientConfig();\n client = Client.create(clientConfig);\n\n resource = clie...
2008/10/21
[ "https://Stackoverflow.com/questions/221442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7524/" ]
221,444
<p>How can I put up a "File Open" dialog from some VBA running in Excel? </p> <p>I'm using Excel 2003. </p>
[ { "answer_id": 221456, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 2, "selected": false, "text": "Sub PromptForFile()\nDim d As New MSComDlg.CommonDialog\n\nd.Filter = \"xls\"\nd.Filename = \"*.xls\"\nd.ShowOpen\n\nExcel...
2008/10/21
[ "https://Stackoverflow.com/questions/221444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7211/" ]
221,452
<pre><code>Control.TabIndex </code></pre> <p>Only allows me to overide the Tab order of controls in a given container. </p> <p>Is there a way to specify this across all the controls in, for example a UserControl, regardless of the contains used to arrange the controls.</p> <p>Cheers,</p> <p>Jan</p>
[ { "answer_id": 234133, "author": "James Osborn", "author_id": 6686, "author_profile": "https://Stackoverflow.com/users/6686", "pm_score": 1, "selected": false, "text": "KeyboardNavigation.TabNavigation" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/460845/" ]
221,455
<p>My stomach churns when I see this kind of output.</p> <p><a href="http://www.freeimagehosting.net/uploads/e1097a5a10.jpg" rel="nofollow noreferrer">http://www.freeimagehosting.net/uploads/e1097a5a10.jpg</a></p> <p>and this was my command as suggested by <a href="https://stackoverflow.com/questions/75500/best-way-to-convert-pdf-files-to-tiff-files#221341">Best way to convert pdf files to tiff files</a></p> <pre><code>gswin32c.exe -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=a.tif a.pdf -c quit </code></pre> <p>What am I doing wrong?</p> <p>(commercial products will not be considered)</p>
[ { "answer_id": 221588, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 1, "selected": false, "text": "nconvert -page 1 -out tiff -dpi 200 -c 2 -o c.tif FMD.pdf\n" }, { "answer_id": 224517, "author": "Setori", ...
2008/10/21
[ "https://Stackoverflow.com/questions/221455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
221,467
<p>I'm trying to complete a practice question from a book on generics but the question doesn't make sense to me. Here it goes.</p> <p>Create two classes with identical functionality. Use generics for the first class, and cast the second class to Object types. Create a for loop that uses class and the Object based class to determine which performs better.</p> <p>I'm not sure what it means by casting to Object types. Here is my code so far</p> <pre><code> //Generic class Person&lt;T&gt; { T var1; public Person(T yer) { var1 = yer; } public T Value { get { return var1; } } } //Normal class class Human { int var1; public Human(int yer) { var1 = yer; } public int Value { get { return var1; } } } </code></pre> <p>My main program running the loops</p> <pre><code>for (int i = 0; i &lt; 1000000; i++) { Person&lt;int&gt; me = new Person&lt;int&gt;(1); int hey = me.Value; } for (int i = 0; i &lt; 1000000; i++) { Human per = new Human(1); object her = (object)per.Value; } </code></pre> <p>I don't know if Im doing this right. Help please :-)</p>
[ { "answer_id": 221470, "author": "endian", "author_id": 25462, "author_profile": "https://Stackoverflow.com/users/25462", "pm_score": 4, "selected": true, "text": "List<Human> myList = new List<Human>();\nHuman h = new Human();\nmyList.Add(h);\n" }, { "answer_id": 221480, "au...
2008/10/21
[ "https://Stackoverflow.com/questions/221467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
221,474
<p>When you create a link to an executable file intended for download (like say update.exe), on a web page, IE7 gives the user the option to "Run" or "Save". I don't want users to be running the update file they should be downloading.</p> <p>Is it possible to disable the "Save" option on the dialog the IE displays, or even force the download automatically.</p>
[ { "answer_id": 221493, "author": "Mark S. Rasmussen", "author_id": 12469, "author_profile": "https://Stackoverflow.com/users/12469", "pm_score": 3, "selected": true, "text": "HttpContext.Current.Response.Buffer = false;\nHttpContext.Current.Response.ClearContent();\nHttpContext.Current.R...
2008/10/21
[ "https://Stackoverflow.com/questions/221474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5019/" ]
221,475
<p>In LinqToSql, it is lovely easy to load a row, change a column, and submit the changes to the database:</p> <pre><code>using (MyDataContext wdc = new MyDataContext()) { Article article = wdc.Article.First(p =&gt; p.ID == id); article.ItemsInStock = itemsinstock; wdc.SubmitChanges(); } </code></pre> <p>The only drawback: Article is huge. <strong>To load the entire article, just to update one column is way overkill</strong> and slows down my app significantly.</p> <p>Is there a way to update a single column using LINQ, without having to load the entire row?</p> <p>Right now I revert to using ExecuteCommand where speed is of essence, but this is ugly and error prone:</p> <pre><code>wdc.ExecuteCommand("UPDATE Article SET ItemsInStock = @1 WHERE ID = @2", itemsinstock,id); </code></pre>
[ { "answer_id": 221547, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 3, "selected": false, "text": "UPDATE ... SET ... WHERE ID = @2\n" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
221,476
<p>After update, old Eclipse plugins remain in "plugins" folder (there are also leftovers in "features" folder).</p> <p>Is there a way to remove those automatically?</p>
[ { "answer_id": 221985, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "\\[eclipse\\]/dropins/eclemma1.3.1/eclipse/(plugins|features)\n" }, { "answer_id": 10878310, "author": "LiuYan 刘研",...
2008/10/21
[ "https://Stackoverflow.com/questions/221476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5817/" ]
221,502
<p>I'm comparing the results produced when i use the 'Make .exe' compared to when i run the exact same process using the exact same variables though the IDE vb 6 debugger.</p> <p>I've tried an array of different compiler options but to no avail.</p> <p>So my question is why would i get a difference between the debugger and the 'Make .exe'? have you ever come arross something similar and if so did you find a fix?</p> <p><em>the program takes a large file of counts of cars in a timeperiod and averages them into 15 minute timeperiods for the day over a month for each route. It elminates certain records depending on if there outside the standard deviation and other statistical algorithms To eliminate values. its a bit to much code to post unfortunately...</em></p>
[ { "answer_id": 221622, "author": "dummy", "author_id": 6297, "author_profile": "https://Stackoverflow.com/users/6297", "pm_score": 2, "selected": false, "text": "Debug.Assert" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5186/" ]
221,503
<p>I wish we have "Usable" pattern in C#, when code block of using construct would be passed to a function as delegate:</p> <pre><code>class Usable : IUsable { public void Use(Action action) // implements IUsable { // acquire resources action(); // release resources } } </code></pre> <p>and in user code:</p> <pre><code>using (new Usable()) { // this code block is converted to delegate and passed to Use method above } </code></pre> <p>Pros:</p> <ul> <li>Controlled execution, exceptions </li> <li>The fact of using "Usable" is visible in call stack</li> </ul> <p>Cons:</p> <ul> <li>Cost of delegate</li> </ul> <p>Do you think it is feasible and useful, and if it doesn't have any problems from the language point of view? Are there any pitfalls you can see?</p> <p>EDIT: David Schmitt <a href="https://stackoverflow.com/questions/221503/iusable-controlling-resources-in-a-better-way-than-idisposable#221522">proposed</a> the following </p> <pre><code>using(new Usable(delegate() { // actions here }) {} </code></pre> <p>It can work in the sample scenario like that, but usually you have resource already allocated and want it to look like this:</p> <pre><code>using (Repository.GlobalResource) { // actions here } </code></pre> <p>Where GlobalResource (yes, I know global resources are bad) implements IUsable. You can rewrite is as short as</p> <pre><code>Repository.GlobalResource.Use(() =&gt; { // actions here }); </code></pre> <p>But it looks a little bit weird (and more weird if you implement interface explicitly), and this is so often case in various flavours, that I thought it deserve to be new syntactic sugar in a language. </p>
[ { "answer_id": 221522, "author": "David Schmitt", "author_id": 4918, "author_profile": "https://Stackoverflow.com/users/4918", "pm_score": 1, "selected": false, "text": "using(new Usable(delegate() {\n // actions here\n}) {}\n" }, { "answer_id": 221923, "author": "Hallgrim...
2008/10/21
[ "https://Stackoverflow.com/questions/221503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18575/" ]
221,514
<p>Suppose, objects of type <i>A</i> are stored in DB. Here's the way I load specific one from DB using hibernate:</p> <pre><code>org.hibernate.Session session = ...; long id = 1; A obj = session.load(A.class, id); </code></pre> <p>If object with id=1 doesn't exist I will get <i>ObjectNotFoundException</i>. But is there a way to check if such object exists without having to catch the exception? What I would like to have is smth like:</p> <pre><code>org.hibernate.Session session = ...; long id = 1; boolean exists = session.exists(A.class, id); if(exists){ // do smth..... } </code></pre> <p>Couldn't find it hibernate docs...</p>
[ { "answer_id": 221526, "author": "Juanma", "author_id": 3730, "author_profile": "https://Stackoverflow.com/users/3730", "pm_score": 6, "selected": true, "text": "session.get" }, { "answer_id": 6796237, "author": "ArBR", "author_id": 476200, "author_profile": "https://...
2008/10/21
[ "https://Stackoverflow.com/questions/221514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
221,519
<p>The following Code does not compile</p> <pre><code>Dim BasicGroups As String() = New String() {"Node1", "Node2"} Dim NodesToRemove = From Element In SchemaDoc.Root.&lt;Group&gt; _ Where Element.@Name not in BasicGroups For Each XNode In NodesToRemove XNode.Remove() Next </code></pre> <p>It is supposed to Remove any Immediate child of the rootnode which has an attribute called name whose value is <strong>Not</strong> listed in the BasicGroups StringArray.</p> <p><strong>What is the correct syntax for this task?</strong></p>
[ { "answer_id": 221605, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 3, "selected": true, "text": "where (not (list.Contains(foo))\n" }, { "answer_id": 221613, "author": "mdb", "author_id": 8562, "author...
2008/10/21
[ "https://Stackoverflow.com/questions/221519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
221,520
<p>I don't understand, why does the following regular expression:</p> <pre><code>^*$ </code></pre> <p>Match the string "127.0.0.1"? Using <code>Regex.IsMatch("127.0.0.1", "^*$");</code></p> <p>Using Expresso, it does not match, which is also what I would expect. Using the expression <code>^.*$</code> does match the string, which I would also expect.</p> <p>Technically, <code>^*$</code> should match the beginning of a string/line any number of times, followed by the ending of the string/line. It seems * is implicitly treated as a <code>.*</code></p> <p>What am I missing?</p> <p>EDIT: Run the following to see an example of the problem.</p> <pre><code>using System; using System.Text.RegularExpressions; namespace RegexFubar { class Program { static void Main(string[] args) { Console.WriteLine(Regex.IsMatch("127.0.0.1", "^*$")); Console.Read(); } } } </code></pre> <p>I do not wish to have ^*$ match my string, I am wondering why it <strong>does</strong> match it. I would think that the expression should result in an exception being thrown, or at least a non-match.</p> <p>EDIT2: To clear up any confusion. I did not write this regex with the intention of having it match "127.0.0.1". A user of our application entered the expression and wondered why it matched the string when it should not. After looking at it, I could not come up with an explanation for why it matched - especially not since Expresso and .NET seems to handle it differently.</p> <p>I guess the question is answered by it being due to the .NET implementation avoiding throwing an exception, even thought it's technically an incorrect expression. But is this really what we want?</p>
[ { "answer_id": 221537, "author": "Richard Nienaber", "author_id": 9539, "author_profile": "https://Stackoverflow.com/users/9539", "pm_score": -1, "selected": false, "text": "^+$\n" }, { "answer_id": 221545, "author": "Mecki", "author_id": 15809, "author_profile": "htt...
2008/10/21
[ "https://Stackoverflow.com/questions/221520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12469/" ]
221,523
<p>I would like to hide the UISearchBar most of the time and only call it to appear when user wants it. </p> <p>I've put a UISearchBar in Interface Builder and hide it behind a view, when user click a button, it calls the following code, which I hoped it would bring the search bar to the front and slide the keyboard to view. But it doesn't....</p> <pre><code>- (IBAction)search:(id)sender { [mySearchBar performSelector:@selector(searchBarTextDidBeginEditing:)]; } </code></pre> <p>Anyone have any idea how to activate UISearchBar by code?</p> <p>Thanks. </p> <p>Thanks for your replies. I just post the complete code in case someone's interested</p> <pre><code>- (IBAction)search:(id)sender { mySearchBar.hidden = NO; [mySearchBar becomeFirstResponder]; } #pragma mark UISearchBarDelegate delegate methods // called when keyboard search button pressed - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { mySearchBar.hidden = YES; [mySearchBar resignFirstResponder]; // Do something with the mySearchBar.text } // called when cancel button pressed - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar { mySearchBar.hidden = YES; [mySearchBar resignFirstResponder]; } </code></pre>
[ { "answer_id": 221581, "author": "Stephen Darlington", "author_id": 2998, "author_profile": "https://Stackoverflow.com/users/2998", "pm_score": 2, "selected": false, "text": "mySearchBar.hidden = NO;\n" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9774/" ]
221,525
<p>Please don't say EHCache or OSCache, etc. Assume for purposes of this question that I want to implement my own using just the SDK (learning by doing). Given that the cache will be used in a multithreaded environment, which datastructures would you use? I've already implemented one using <a href="http://docs.oracle.com/javase/7/docs/api/java/util/LinkedHashMap.html" rel="noreferrer">LinkedHashMap</a> and <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedMap(java.util.Map)" rel="noreferrer">Collections#synchronizedMap</a>, but I'm curious if any of the new concurrent collections would be better candidates.</p> <p>UPDATE: I was just reading through <a href="http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html" rel="noreferrer">Yegge's latest</a> when I found this nugget:</p> <blockquote> <p>If you need constant-time access and want to maintain the insertion order, you can't do better than a LinkedHashMap, a truly wonderful data structure. The only way it could possibly be more wonderful is if there were a concurrent version. But alas.</p> </blockquote> <p>I was thinking almost exactly the same thing before I went with the <code>LinkedHashMap</code> + <code>Collections#synchronizedMap</code> implementation I mentioned above. Nice to know I hadn't just overlooked something.</p> <p>Based on the answers so far, it sounds like my best bet for a highly concurrent LRU would be to extend <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentHashMap.html" rel="noreferrer">ConcurrentHashMap</a> using some of the same logic that <code>LinkedHashMap</code> uses.</p>
[ { "answer_id": 221546, "author": "Steve McLeod", "author_id": 2959, "author_profile": "https://Stackoverflow.com/users/2959", "pm_score": 3, "selected": false, "text": "class CacheElement {\n private final Object obj;\n private int numberOfUsers = 0;\n\n CacheElement(Object obj)...
2008/10/21
[ "https://Stackoverflow.com/questions/221525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4203/" ]
221,534
<p>What are the <strong>differences</strong> in considerations in respect to designing or developing an <strong>Intranet and an Internet application</strong> ?</p>
[ { "answer_id": 221632, "author": "Jon Schneider", "author_id": 12484, "author_profile": "https://Stackoverflow.com/users/12484", "pm_score": 3, "selected": false, "text": "\\\\corporateserver\\devteam\\ArchitectureDiagram.vsd" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11614/" ]
221,539
<p>I've seen this in a few <a href="https://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript#221357">places</a></p> <pre><code>function fn() { return +new Date; } </code></pre> <p>And I can see that it is returning a timestamp rather than a date object, but I can't find any documentation on what the plus sign is doing.</p> <p>Can anyone explain?</p>
[ { "answer_id": 221560, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 6, "selected": false, "text": ">>> +new Date()\n1224589625406\n>>> +\"3\"\n3\n>>> +true\n1\n>>> 3 == \"3\"\ntrue\n" }, { "answer_id": 221565...
2008/10/21
[ "https://Stackoverflow.com/questions/221539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20074/" ]
221,568
<p>Is there a way in SWT to get a monospaced font simply, that works across various operating systems?</p> <p>For example. this works on Linux, but not Windows:</p> <pre> <code> Font mono = new Font(parent.getDisplay(), "Mono", 10, SWT.NONE); </code> </pre> <p>or do I need to have a method that tries loading varying fonts (Consolas, Terminal, Monaco, Mono) until one isn't null? Alternatively I could specify it in a properties file on startup.</p> <p>I tried getting the system font from Display, but that wasn't monospaced.</p>
[ { "answer_id": 222885, "author": "fhe", "author_id": 4445, "author_profile": "https://Stackoverflow.com/users/4445", "pm_score": 5, "selected": true, "text": "Font mono = new Font(parent.getDisplay(), \"Monospaced\", 10, SWT.NONE);" }, { "answer_id": 226404, "author": "McDowe...
2008/10/21
[ "https://Stackoverflow.com/questions/221568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17832/" ]
221,570
<p>I'd like them to be easy to bundle, with few dependencies and easy to use.</p>
[ { "answer_id": 33449865, "author": "stack questions", "author_id": 5395968, "author_profile": "https://Stackoverflow.com/users/5395968", "pm_score": 1, "selected": false, "text": " RSyntaxTextArea textArea = new RSyntaxTextArea();\n textArea.setSyntaxEditingStyle(SyntaxCons...
2008/10/21
[ "https://Stackoverflow.com/questions/221570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28968/" ]
221,578
<p>I'm trying to make a script that sleeps my wireless card in linux. For that I'm using the <code>deepsleep</code> command of <code>iwpriv</code>:</p> <pre><code>iwpriv wlan0 deepsleep 1 </code></pre> <p>The problem is that this command only works if the wireless card is disconnected and disassociated. When it's connected there is no problem because if I disconnect, it disassociates automatically. But if it's disconnected, sometimes it associates (but not connects) automatically to unencrypted networks, so I cannot run the <code>iwpriv</code> command. The only fix I have found is to change the mode first to Ad-Hoc and then to Managed before sleep the card:</p> <pre><code>iwconfig wlan0 mode ad-hoc iwconfig wlan0 mode managed iwpriv wlan0 deepsleep 1 </code></pre> <p>But I think it's a bit tricky.</p> <p>Does exist a more direct way to disassociate a wireless card in linux?</p>
[ { "answer_id": 327211, "author": "ctuffli", "author_id": 26683, "author_profile": "https://Stackoverflow.com/users/26683", "pm_score": 1, "selected": false, "text": "iwconfig wlan0 ap 00:00:00:00:00:00\nsleep 1\niwpriv wlan0 deepsleep 1\n" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28855/" ]
221,582
<p>This question comes up occasionally, but I haven't seen a satisfactory answer.</p> <p>A typical pattern is (row is a <strong>DataRow</strong>):</p> <pre><code> if (row["value"] != DBNull.Value) { someObject.Member = row["value"]; } </code></pre> <p>My first question is which is more efficient (I've flipped the condition):</p> <pre><code> row["value"] == DBNull.Value; // Or row["value"] is DBNull; // Or row["value"].GetType() == typeof(DBNull) // Or... any suggestions? </code></pre> <p><a href="https://stackoverflow.com/questions/184681/is-vs-typeof">This</a> indicates that .GetType() should be faster, but maybe the compiler knows a few tricks I don't?</p> <p>Second question, is it worth caching the value of row["value"] or does the compiler optimize the indexer away anyway?</p> <p>For example:</p> <pre><code> object valueHolder; if (DBNull.Value == (valueHolder = row["value"])) {} </code></pre> <p>Notes:</p> <ol> <li>row["value"] exists.</li> <li>I don't know the column index of the column (hence the column name lookup).</li> <li>I'm asking specifically about checking for DBNull and then assignment (not about premature optimization, etc.).</li> </ol> <p>I benchmarked a few scenarios (time in seconds, 10,000,000 trials):</p> <pre><code>row["value"] == DBNull.Value: 00:00:01.5478995 row["value"] is DBNull: 00:00:01.6306578 row["value"].GetType() == typeof(DBNull): 00:00:02.0138757 </code></pre> <p>Object.ReferenceEquals has the same performance as "=="</p> <p>The most interesting result? If you mismatch the name of the column by case (for example, "Value" instead of "value", it takes roughly ten times longer (for a string):</p> <pre><code>row["Value"] == DBNull.Value: 00:00:12.2792374 </code></pre> <p>The moral of the story seems to be that if you can't look up a column by its index, then ensure that the column name you feed to the indexer matches the DataColumn's name exactly.</p> <p>Caching the value also appears to be nearly <strong>twice</strong> as fast:</p> <pre><code>No Caching: 00:00:03.0996622 With Caching: 00:00:01.5659920 </code></pre> <p>So the most efficient method <em>seems</em> to be:</p> <pre><code> object temp; string variable; if (DBNull.Value != (temp = row["value"])) { variable = temp.ToString(); } </code></pre>
[ { "answer_id": 221590, "author": "Jon Grant", "author_id": 18774, "author_profile": "https://Stackoverflow.com/users/18774", "pm_score": 5, "selected": false, "text": "Convert.IsDBNull()\n" }, { "answer_id": 221599, "author": "Marc Gravell", "author_id": 23354, "autho...
2008/10/21
[ "https://Stackoverflow.com/questions/221582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9825/" ]
221,584
<p>I have some products that belongs to the some category.</p> <p>Each category can have different properties.</p> <p>For example, </p> <ul> <li>category <em>cars</em> has properties <em>color</em>, power, ... </li> <li>category <em>pets</em> have properties <em>weight</em>, <em>age</em>, ...</li> </ul> <p>Number of categories is about 10-15. Number of properties in each category is 3-15. Number of products is very big.</p> <p>Main requirement for this app is very good search. We will select category, and enter criteria for each property in this category.</p> <p>Have to design database for this scenario. (SQL Server 2005)</p>
[ { "answer_id": 221614, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 1, "selected": false, "text": "tProduct \n productID\n <other product details>\n\ntCategory\n categoryID\n <other category details>\n\ntProperty\n...
2008/10/21
[ "https://Stackoverflow.com/questions/221584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
221,592
<p>Does anyone know whether the iPhone supports or will soon support the <a href="http://dev.w3.org/geo/api/spec-source.html" rel="noreferrer">W3C Geolocation specification</a>?</p> <p>I'm looking to build an app for mobile users, but rather than spend the time developing apps for every different platform (iPhone, Android, etc...), I'd much prefer to create a web app that makes use of the W3C Standard.</p>
[ { "answer_id": 1134136, "author": "SavoryBytes", "author_id": 131944, "author_profile": "https://Stackoverflow.com/users/131944", "pm_score": 7, "selected": true, "text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http:/...
2008/10/21
[ "https://Stackoverflow.com/questions/221592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12037/" ]
221,593
<p>I am building an ObjectQuery like this:</p> <pre><code> string query = "select value obj from Entities.Class as obj " + "where obj.Property = @Value"; ObjectQuery&lt;Class&gt; oQuery = new ObjectQuery&lt;Class&gt;(query, EntityContext.Instance); oQuery.Parameters.Add(new ObjectParameter("Value", someVariable)); </code></pre> <p>I can now assign this object as a DataSource for a control, or iterate with a foreach loop or even force a materialization to a List, however, I can I count the number of objects that will be returned, without forcing a materialization?</p> <p>Do I need to create a companion query that will execute a count() or is there a function that will do that for me somewhere?</p> <p>Thank you.</p>
[ { "answer_id": 221630, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "ObjectQuery<T>" }, { "answer_id": 221633, "author": "Jon Grant", "author_id": 18774, "author_profi...
2008/10/21
[ "https://Stackoverflow.com/questions/221593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3610/" ]
221,595
<p>I have a button inside an update panel that I would like to update the whole page. I have set <code>ChildrenAsTriggers="false"</code> and <code>UpdateMode="Conditional"</code>.</p> <p>I have some sample code here that demonstrates my problem.</p> <pre><code>&lt;asp:UpdatePanel ID="myFirstPanel" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;asp:Button runat="server" ID="myFirstButton" Text="My First Button" onclick="myFirstButton_Click" /&gt; &lt;asp:Button runat="server" ID="mySecondButton" Text="My Second Button" onclick="mySecondButton_Click" /&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;asp:UpdatePanel ID="mySecondPanel" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:Label runat="server" ID="myFirstLabel" Text="My First Label"&gt;&lt;/asp:Label&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="myFirstButton" EventName="Click" /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; &lt;asp:Label runat="server" ID="mySecondLabel" Text="My Second Label"&gt;&lt;/asp:Label&gt; </code></pre> <p>And the code behind:</p> <pre><code>protected void myFirstButton_Click(object sender, EventArgs e) { myFirstLabel.Text = "Inside Panel " + DateTime.Now.ToString("mm:ss"); } protected void mySecondButton_Click(object sender, EventArgs e) { mySecondLabel.Text = "Outside Panel " + DateTime.Now.ToString("mm:ss"); } </code></pre> <p>I want to update the label that is not inside an update panel when the second button is clicked. The second button needs to be in an update panel. I don't want to put the lable into an update panel.</p>
[ { "answer_id": 221718, "author": "tpower", "author_id": 18107, "author_profile": "https://Stackoverflow.com/users/18107", "pm_score": 1, "selected": false, "text": "<Triggers>\n <asp:PostBackTrigger ControlID=\"mySecondButton\" />\n</Triggers>\n" }, { "answer_id": 12943127, ...
2008/10/21
[ "https://Stackoverflow.com/questions/221595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107/" ]
221,611
<p>For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated. How would you design this?</p> <ul> <li><p>What data types would you use in the database (assuming MySQL, possibly in a different timezone that the JVM)? Will the data types be timezone-aware?</p></li> <li><p>What data types would you use in Java (<code>Date</code>, <code>Calendar</code>, <code>long</code>, ...)?</p></li> <li><p>Whom would you make responsible for setting the timestamps&mdash;the database, the ORM framework (Hibernate), or the application programmer?</p></li> <li><p>What annotations would you use for the mapping (e.g. <code>@Temporal</code>)?</p></li> </ul> <p>I'm not only looking for a working solution, but for a safe and well-designed solution.</p>
[ { "answer_id": 221782, "author": "davetron5000", "author_id": 3029, "author_profile": "https://Stackoverflow.com/users/3029", "pm_score": 2, "selected": false, "text": "java.util.Calender" }, { "answer_id": 221827, "author": "Guðmundur Bjarni", "author_id": 27349, "au...
2008/10/21
[ "https://Stackoverflow.com/questions/221611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23109/" ]
221,674
<p>Are there ways except CAPTCHAs for web apps like <a href="http://pastie.org" rel="nofollow noreferrer">pastie.org</a> or <a href="http://p.ramaze.net" rel="nofollow noreferrer">p.ramaze.net</a>? CAPTCHAs take too long for a small paste for my taste.</p>
[ { "answer_id": 221721, "author": "Gene", "author_id": 22673, "author_profile": "https://Stackoverflow.com/users/22673", "pm_score": 1, "selected": false, "text": "* Current software is unable to solve accurately.\n* Most humans can solve.\n* Does not rely on the type of CAPTCHA being new...
2008/10/21
[ "https://Stackoverflow.com/questions/221674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28968/" ]
221,687
<p>I want to make a generic class that accepts only serializable classes, can it be done with the where constraint?</p> <p>The concept I'm looking for is this:</p> <pre><code>public class MyClass&lt;T&gt; where T : //[is serializable/has the serializable attribute] </code></pre>
[ { "answer_id": 221695, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "where T : class" }, { "answer_id": 221727, "author": "Patrik Svensson", "author_id": 936, "author_pro...
2008/10/21
[ "https://Stackoverflow.com/questions/221687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1782/" ]
221,691
<p>This might be a old question: Why does <code>IEnumerable&lt;T&gt;</code> inherit from <code>IEnumerable</code>?</p> <p>This is how .NET do, but it brings a little trouble. Every time I write a class implements <code>IEumerable&lt;T&gt;</code>, I have to write two <code>GetEnumerator()</code> functions, one for <code>IEnumerable&lt;T&gt;</code> and the other for <code>IEnumerable</code>.</p> <p>And, <code>IList&lt;T&gt;</code> doesn't inherit from IList. </p> <p>I don't know why <code>IEnumerable&lt;T&gt;</code> is designed in other way.</p>
[ { "answer_id": 221722, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": false, "text": "IEnumerable" }, { "answer_id": 221724, "author": "Mark Brackett", "author_id": 2199, "author_profile...
2008/10/21
[ "https://Stackoverflow.com/questions/221691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
221,693
<p>I have a function that automatically exports a table into a CSV file, then I try to attach that same file into a function that will email it. I have sent attachments using html mime mail before, but I was wondering if that created CSV file needs to be stored on the server first before attaching it to the email?</p>
[ { "answer_id": 221720, "author": "vfilby", "author_id": 24279, "author_profile": "https://Stackoverflow.com/users/24279", "pm_score": 0, "selected": false, "text": "uuencode" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26130/" ]
221,730
<p>I want to create a .bat file so I can just click on it so it can run:</p> <pre><code>svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://localhost:8000/ServiceModelSamples/service </code></pre> <p>Can someone help me with the structure of the .bat file?</p>
[ { "answer_id": 221815, "author": "myplacedk", "author_id": 28683, "author_profile": "https://Stackoverflow.com/users/28683", "pm_score": 3, "selected": false, "text": "@echo off\nsvcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://localhost:8000/ServiceModelSamples/...
2008/10/21
[ "https://Stackoverflow.com/questions/221730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
221,732
<p>I've been searching a lot but couldn't find a solution. How do you deal with a DateTime that should be able to contain an uninitialized value (equivalent to null)? I have a class which might have a DateTime property value set or not. I was thinking of initializing the property holder to DateTime.MinValue, which then could easily be checked. I guess this is a quite common question, how do you do that?</p>
[ { "answer_id": 221740, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 10, "selected": true, "text": "DateTime.MinValue" }, { "answer_id": 221741, "author": "David Mohundro", "author_id": 4570, "autho...
2008/10/21
[ "https://Stackoverflow.com/questions/221732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16440/" ]
221,745
<p>I realize I'm probably just dumb and missing something big and important, but I can't figure out how to specify a timeout in twisted using reactor.listenUDP. My goal is to be able to specify a timeout, and after said amount of time, if DatagramProtocol.datagramReceived has not been executed, have it execute a callback or something that I can use to call reactor.stop(). Any help or advice is appreciated. Thanks</p>
[ { "answer_id": 221832, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 4, "selected": true, "text": "from twisted.internet import task\nfrom twisted.internet import reactor\n\ndatagramRecieved = False\ntimeout = 1.0 # On...
2008/10/21
[ "https://Stackoverflow.com/questions/221745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20572/" ]
221,774
<p>I have a MySQL database of keywords that are presently mixed-case. However, I want to convert them all to lowercase. Is there an easy command to do this, either using MySQL or MySQL and PHP?</p>
[ { "answer_id": 221780, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": false, "text": "SELECT LOWER(foo) AS foo FROM bar" }, { "answer_id": 221787, "author": "Paul Dixon", "author_id": 6521, "...
2008/10/21
[ "https://Stackoverflow.com/questions/221774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
221,781
<p>We are migrating a web applicatin from vs05 to vs08. This application is using Telerik web controls. After I converted the project, and run, I get the exception: "A control is already associated with the element". I traced it down to a use control that has Telerik RadCombo box on it. However, I don't see anything out of place. Researching it, hasn't gotten me any results. I would appreciate any pointers.</p> <p>Thanks!</p>
[ { "answer_id": 6444157, "author": "Greg Woods", "author_id": 810857, "author_profile": "https://Stackoverflow.com/users/810857", "pm_score": 1, "selected": false, "text": "child.control.dispose();\nchild.control = undefined;\n" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29726/" ]
221,783
<p>Consider the following code:</p> <pre><code>client.Send(data, data.Length, endpoint); byte[] response = client.Receive(ref endpoint); </code></pre> <p>While, according to WireShark (network sniffer), the remote host does reply with data, the application here just waits for data forever... it does not receive the answer from the remote host for some reason.</p> <p>Any ideas?</p>
[ { "answer_id": 4849573, "author": "Mostafa", "author_id": 596652, "author_profile": "https://Stackoverflow.com/users/596652", "pm_score": 1, "selected": false, "text": "client.Client.ReceiveTimeout = 5000; \n" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
221,800
<p>I want to learn MSBuild, was wondering if someone could get me started with a simple build script to filter out my vs.net 2008 project of all files with the .cs extension.</p> <ol> <li>how do I run the build?</li> <li>where do you usually store the build also?</li> </ol>
[ { "answer_id": 221854, "author": "kenny", "author_id": 3225, "author_profile": "https://Stackoverflow.com/users/3225", "pm_score": 0, "selected": false, "text": "C:\\projects\\_Play\\SimpleIpService>type \\\\sysrdswbld1\\public\\bin\\mrb-vs2008.cmd\n@echo off\n\ncall \"c:\\Program Files\...
2008/10/21
[ "https://Stackoverflow.com/questions/221800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
221,804
<p>I need to find the min and max value in an array. The <code>.max</code> function works but <code>.min</code> keeps showing zero.</p> <pre><code>Public Class Program_2_Grade Dim max As Integer Dim min As Integer Dim average As Integer Dim average1 As Integer Dim grade As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = Nothing Or TextBox1.Text &gt; 100 Then MsgBox("Doesn't Meet Grade Requirements", MsgBoxStyle.Exclamation, "Error") TextBox1.Clear() TextBox1.Focus() counter = 0 Else grade_enter(counter) = TextBox1.Text TextBox1.Clear() TextBox1.Focus() counter = counter + 1 If counter = grade_amount Then max = grade_enter.Max() min = grade_enter.Min() For i As Integer = 0 To counter average = average + grade_enter(i) / counter average1 = average1 + grade_enter(i) - grade_enter.Min / counter Next Select Case average Case 30 To 49 grade = "C" Case 50 To 69 grade = "B" Case 70 To 100 grade = "A" Case Else grade = "Fail" End Select If (Program_2.CheckBox1.Checked = True) Then Program_2.TextBox4.Text = _ ("Name:" &amp; " " &amp; (Program_2.TextBox1.Text) &amp; vbNewLine &amp; _ "Class: " &amp; (Program_2.TextBox2.Text) &amp; vbNewLine &amp; _ "Number Of Grades:" &amp; " " &amp; (Program_2.TextBox3.Text) &amp; vbNewLine &amp; _ "Max:" &amp; " " &amp; max &amp; vbNewLine &amp; _ "Min:" &amp; " " &amp; min &amp; vbNewLine &amp; _ "Average:" &amp; " " &amp; average1 &amp; vbNewLine) &amp; _ "Grade:" &amp; " " &amp; grade &amp; vbNewLine &amp; _ "Dropped Lowest Grade" Else Program_2.TextBox4.Text = _ ("Name:" &amp; " " &amp; (Program_2.TextBox1.Text) &amp; vbNewLine &amp; _ "Class: " &amp; (Program_2.TextBox2.Text) &amp; vbNewLine &amp; _ "Number Of Grades:" &amp; " " &amp; (Program_2.TextBox3.Text) &amp; vbNewLine &amp; _ "Max:" &amp; " " &amp; max &amp; vbNewLine &amp; _ "Min:" &amp; " " &amp; min &amp; vbNewLine &amp; _ "Average:" &amp; " " &amp; average &amp; vbNewLine) &amp; _ "Grade:" &amp; " " &amp; grade &amp; vbNewLine End If Me.Close() average = 0 average1 = 0 counter = 0 End If End If End Sub </code></pre> <p>My arrays are set at global scope.</p>
[ { "answer_id": 221834, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "max = grade_enter.Take(counter).Max()\nmin = grade_enter.Take(counter).Min()\n" }, { "answer_id": 221836, "a...
2008/10/21
[ "https://Stackoverflow.com/questions/221804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
221,806
<p>I have two questions :</p> <ol> <li><p>While doing source level debugging (using any debugger) does any debugger save state of some iteration/for-loop/any code executed and allow the user to go back to that previously executed code/data state at a later point of time during debugging? The need for this is some variable/pointer is corrupted somewhere earlier in time during execution but is accessed after some time / later in the execution of code and thats when it crashes/hangs the code, so i would like to go back and see which function/at what time the variable was corrupted/wrong value computed and written to it ? Is it possible in any debugger (gcc, MSVC6.0 ...) </p></li> <li><p>Does any debugger/IDE have provision that when a memory address/variable is marked for "analysis", it should display which function in which file, and which code changed that memory(write), every time it is changed/written?</p></li> </ol> <p>-AD </p>
[ { "answer_id": 221849, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 1, "selected": false, "text": "for (i = 0; i < list.size(); i++) {\n foo = list[i];\n}\n" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2759376/" ]
221,822
<p>I'm familiar with Sybase / SQL server, where I can create a temp. table like this: </p> <pre><code>SELECT * INTO #temp FROM tab1 , tab2 WHERE tab1.key = tab2.fkey SELECT * FROM #temp WHERE field1 = 'value' </code></pre> <p>#temp only exists for the duration of this session, and can only be seen by me. </p> <p>I would like to do a similar thing in Oracle, but I'm reading about "global temporary tables", which don't sound like the same thing. </p> <p>How can I do the same thing in Oracle as I'm doing in Sybase? </p> <p>Thanks :)</p>
[ { "answer_id": 221880, "author": "carson", "author_id": 25343, "author_profile": "https://Stackoverflow.com/users/25343", "pm_score": 1, "selected": false, "text": "CREATE GLOBAL TEMPORARY TABLE my_temp_table ON COMMIT DELETE ROWS select * from other table;\n" }, { "answer_id": 2...
2008/10/21
[ "https://Stackoverflow.com/questions/221822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7211/" ]
221,824
<p>Basically I'm converting local dates stored in the database into UTC. But I've read somewhere that daylight saving rules have changed in 2007. So does the Date.ToUniversalTime() function still work correctly. Basically the dates before 2007(when the new rules came into effect) would be converted correctly but the dates after that would be not. Am I right here? Or would .Net take care of the conversion internally i.e. depending upon the different daylight saving rules?</p> <p>EDIT: Dates are stored in DB as local times. I am converting it into UTC. So a date such as '9 March 2005' should be converted using day light rules of 2005 instead of today's rules. The rules changed in the US in 2007. So the date is coming out wrong by one hour.</p>
[ { "answer_id": 221850, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "ToUniversalTime()" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
221,830
<p>I have two BufferedImages I loaded in from pngs. The first contains an image, the second an alpha mask for the image.</p> <p>I want to create a combined image from the two, by applying the alpha mask. My google-fu fails me.</p> <p>I know how to load/save the images, I just need the bit where I go from two BufferedImages to one BufferedImage with the right alpha channel.</p>
[ { "answer_id": 221869, "author": "Zarkonnen", "author_id": 15255, "author_profile": "https://Stackoverflow.com/users/15255", "pm_score": 0, "selected": false, "text": "for (int y = 0; y < image.getHeight(); y++) {\n for (int x = 0; x < image.getWidth(); x++) {\n Color c = new C...
2008/10/21
[ "https://Stackoverflow.com/questions/221830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15255/" ]
221,892
<p>Is there a way to write an enumeration that can be extended. I have several methods that I would like to always have available for my enumerations. For example I use an enumeration for my database fields. I include the actual field name in the database. </p> <pre><code>public enum ORDERFIELDS { OrderID("Order_ID"); private String FieldName; private ORDERFIELDS(String fname) { this.FieldName = fname; } public String getFieldName() { return FieldName; } } </code></pre>
[ { "answer_id": 221902, "author": "Guido", "author_id": 12388, "author_profile": "https://Stackoverflow.com/users/12388", "pm_score": 4, "selected": false, "text": "java.lang.Enum" }, { "answer_id": 221916, "author": "Dónal", "author_id": 2648, "author_profile": "https...
2008/10/21
[ "https://Stackoverflow.com/questions/221892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17712/" ]
221,894
<p>We are currently using the <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;118623" rel="noreferrer">NetBios method</a>, and it works ok under XP. Preliminary tests under Vista show that it also works, but there are caveats - NetBIOS has to be present, for instance, and from what I've been reading, the order of the adapters is bound to change. Our alternative method - with <a href="http://msdn.microsoft.com/en-us/library/aa378021(VS.85).aspx" rel="noreferrer">SNMPExtensionQuery</a> - seems to be broken under Vista.</p> <p>The question is: do you know of a reliable way to get a list of the local MAC addresses on a Vista machine? Backwards compatibility with XP is a plus (I'd rather have one single method than lots of ugly #ifdef's). Thanks!</p>
[ { "answer_id": 221992, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 4, "selected": false, "text": "void getdMacAddresses(std::vector<std::string> &vMacAddresses;)\n{\n vMacAddresses.clear();\n IP_ADAPTER_INFO A...
2008/10/21
[ "https://Stackoverflow.com/questions/221894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7134/" ]
221,901
<p>Do the clients need something else than a proper jdk and javafx compliant browser to visit javafx applets?</p>
[ { "answer_id": 221992, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 4, "selected": false, "text": "void getdMacAddresses(std::vector<std::string> &vMacAddresses;)\n{\n vMacAddresses.clear();\n IP_ADAPTER_INFO A...
2008/10/21
[ "https://Stackoverflow.com/questions/221901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/148909/" ]
221,909
<p>I'm writing a stored procedure that needs to have a lot of conditioning in it. With the general knowledge from C#.NET coding that exceptions can hurt performance, I've always avoided using them in PL/SQL as well. My conditioning in this stored proc mostly revolves around whether or not a record exists, which I could do one of two ways:</p> <pre><code>SELECT COUNT(*) INTO var WHERE condition; IF var &gt; 0 THEN SELECT NEEDED_FIELD INTO otherVar WHERE condition; .... </code></pre> <p><b>-or-</b></p> <pre><code>SELECT NEEDED_FIELD INTO var WHERE condition; EXCEPTION WHEN NO_DATA_FOUND .... </code></pre> <p>The second case seems a bit more elegant to me, because then I can use NEEDED_FIELD, which I would have had to select in the first statement after the condition in the first case. Less code. But if the stored procedure will run faster using the COUNT(*), then I don't mind typing a little more to make up processing speed.</p> <p>Any hints? Am I missing another possibility?</p> <p><b>EDIT</b> I should have mentioned that this is all already nested in a FOR LOOP. Not sure if this makes a difference with using a cursor, since I don't think I can DECLARE the cursor as a select in the FOR LOOP.</p>
[ { "answer_id": 221960, "author": "Steve Bosman", "author_id": 4389, "author_profile": "https://Stackoverflow.com/users/4389", "pm_score": 1, "selected": false, "text": "DECLARE\n CURSOR foo_cur IS \n SELECT NEEDED_FIELD WHERE condition ;\nBEGIN\n OPEN foo_cur;\n FETCH foo_cur INTO ...
2008/10/21
[ "https://Stackoverflow.com/questions/221909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27457/" ]
221,913
<p>I am getting a warning when trying to include the .net 3.5 sp1 prerequisite for my setup project. The warning states Prerequisite could not found for bootstrapping.</p> <p>Any suggestions?</p> <p>Thanks</p>
[ { "answer_id": 5556080, "author": "Michael Eakins", "author_id": 437301, "author_profile": "https://Stackoverflow.com/users/437301", "pm_score": 1, "selected": false, "text": "<PackageFile Name=\"TOOLS\\clwireg.exe\"/>\n<PackageFile Name=\"TOOLS\\clwireg_x64.exe\"/>\n<PackageFile Name=\"...
2008/10/21
[ "https://Stackoverflow.com/questions/221913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29961/" ]
221,919
<p>Is there a difference between the two examples below for beginning a Perl script? If so, when would I use one over the other?</p> <p>example 1:</p> <pre><code>#!/usr/bin/perl use warnings; </code></pre> <p>example 2:</p> <pre><code>#!/usr/bin/perl -w </code></pre>
[ { "answer_id": 222071, "author": "friedo", "author_id": 20745, "author_profile": "https://Stackoverflow.com/users/20745", "pm_score": 4, "selected": false, "text": "-w" }, { "answer_id": 227553, "author": "Community", "author_id": -1, "author_profile": "https://Stacko...
2008/10/21
[ "https://Stackoverflow.com/questions/221919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6406/" ]
221,921
<p>I'm looking for the string <code>foo=</code> in text files in a directory tree. It's on a common Linux machine, I have bash shell:</p> <pre><code>grep -ircl &quot;foo=&quot; * </code></pre> <p>In the directories are also many binary files which match <code>&quot;foo=&quot;</code>. As these results are not relevant and slow down the search, I want grep to skip searching these files (mostly JPEG and PNG images). How would I do that?</p> <p>I know there are the <code>--exclude=PATTERN</code> and <code>--include=PATTERN</code> options, but what is the pattern format? The man page of grep says:</p> <pre><code>--include=PATTERN Recurse in directories only searching file matching PATTERN. --exclude=PATTERN Recurse in directories skip file matching PATTERN. </code></pre> <p>Searching on <em>grep include</em>, <em>grep include exclude</em>, <em>grep exclude</em> and variants did not find anything relevant</p> <p>If there's a better way of grepping only in certain files, I'm all for it; moving the offending files is not an option. I can't search only certain directories (the directory structure is a big mess, with everything everywhere). Also, I can't install anything, so I have to do with common tools (like <em>grep</em> or the suggested <em>find</em>).</p>
[ { "answer_id": 221929, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 11, "selected": true, "text": "grep pattern -r --include=\\*.cpp --include=\\*.h rootdir\n" }, { "answer_id": 221936, "author": "Aaron ...
2008/10/21
[ "https://Stackoverflow.com/questions/221921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19746/" ]
221,925
<p>What is the prefered method for creating a byte array from an input stream? </p> <p>Here is my current solution with .NET 3.5. </p> <pre><code>Stream s; byte[] b; using (BinaryReader br = new BinaryReader(s)) { b = br.ReadBytes((int)s.Length); } </code></pre> <p>Is it still a better idea to read and write chunks of the stream?</p>
[ { "answer_id": 221941, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 11, "selected": true, "text": "s.Length" }, { "answer_id": 2630539, "author": "Fernando Neira", "author_id": 315601, "author_profil...
2008/10/21
[ "https://Stackoverflow.com/questions/221925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45/" ]
221,930
<p>I have a master page that contains an ASP.NET server side Menu control (System.Web.UI.WebControls.Menu)</p> <p>I <em>am</em> using the CSSFriendly adapters from here</p> <p><a href="http://www.asp.net/CSSAdapters/Menu.aspx" rel="noreferrer">http://www.asp.net/CSSAdapters/Menu.aspx</a></p> <p>and they do make the rendered HTML much cleaner however I am still getting inline styles output into the HEAD element in the HTML like this</p> <pre><code>&lt;style type="text/css"&gt; .ctl00_SiteHeader1_TabBar1_Menu1_0 { background-color:white;visibility:hidden;display:none;position:absolute;left:0px;top:0px; } .ctl00_SiteHeader1_TabBar1_Menu1_1 { text-decoration:none; } .ctl00_SiteHeader1_TabBar1_Menu1_2 { } .ctl00_LeftColumnContent_LeftHandNavigator1_Menu1_0 { text-decoration:none; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; </code></pre> <p>I thik these styles are being generated by ASP.NET, I don't think I need them as I am using the CSSAdapters so is there any way of stopping them from being generated?</p> <p>Derek</p>
[ { "answer_id": 9429489, "author": "Ignacio Calvo", "author_id": 429487, "author_profile": "https://Stackoverflow.com/users/429487", "pm_score": 2, "selected": false, "text": "IncludeStyleBlock" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28584/" ]
221,938
<p>I want to provide silverlight app to my customer while hosting the app at my own site for streamlined maintenance.</p> <ul> <li>my Silverlight .xap is hosted in, let say, domain <em>me-supplier.com</em></li> <li>i want to embed it in, let say, domain <em>my-customer.com</em></li> </ul> <p>It works perfectly for <em><a href="http://my-customer.com" rel="nofollow noreferrer">http://my-customer.com</a></em>, not for <strong><em>https</strong>://my-customer.com</em> </p> <ul> <li>i have added the (<em>me-supplier.com</em> hosted) cross domain silverlight policy file to allow <em>my-customer.com</em></li> <li>i have configured the mime types for .xap</li> <li>the silverlight app needs html dom access so the iframe approach is not viable i believe.</li> </ul> <p>this works for javascript code, so why not for silverlight ? any idea, workaround ?</p>
[ { "answer_id": 9429489, "author": "Ignacio Calvo", "author_id": 429487, "author_profile": "https://Stackoverflow.com/users/429487", "pm_score": 2, "selected": false, "text": "IncludeStyleBlock" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/221938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29952/" ]
221,950
<p>This <a href="http://themechanicalbride.blogspot.com/2008/04/using-operators-with-generics.html" rel="nofollow noreferrer">article</a> describes a way, in C#, to allow the addition of arbitrary value types which have a + operator defined for them. In essence it allows the following code:</p> <pre><code>public T Add(T val1, T val2) { return val1 + val2; } </code></pre> <p>This code does not compile as there is no guarantee that the T type has a definition for the '+' operator, but the effect is achieved with code like this:</p> <pre><code>public T Add(T val1, T val2) { //Num&lt;T&gt; defines a '+' operation which returns a value of type T return (new Num&lt;T&gt;(val1) + new Num&lt;T&gt;(val2)); } </code></pre> <p>Follow the link to see how the Num class achieves this. Anyways, on to the question. Is there any way to achieve the same effect in C or C++? For the curious, the problem I'm trying to solve is to allow a CUDA kernel to be more flexible/general by allowing it to operate on more types.</p> <p><strong>Update:</strong> For .NET, Marc Gravell has made a <a href="http://www.yoda.arachsys.com/csharp/miscutil/usage/genericoperators.html" rel="nofollow noreferrer">utility library</a> which solves the operator problem very elegantly.</p>
[ { "answer_id": 221961, "author": "Pieter", "author_id": 5822, "author_profile": "https://Stackoverflow.com/users/5822", "pm_score": 5, "selected": true, "text": "template < class T >\nT add(T const & val1, T const & val2)\n{\n return val1 + val2;\n}\n" }, { "answer_id": 221962...
2008/10/21
[ "https://Stackoverflow.com/questions/221950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4055/" ]
221,976
<p>I am creating an application in java which will be the part of an external application. My application contains a viewport which shows some polygons and stuff like that. The external application needs to get the image of the viewport in gif format. For that it calls a method in an interface (implemented by my application) and my application returns the image. The external application needs to store the image in database (or something related to it which I dont need to worry about).</p> <p>My question is:- What should be the data container type of the image when my application send it to the external application? I mean what should be the return type of the method? Currently my gif encoder class returns a byte array. Is there any other 'better' option?</p>
[ { "answer_id": 222010, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 3, "selected": true, "text": "OutputStream" }, { "answer_id": 417778, "author": "asalamon74", "author_id": 21348, "author_profile":...
2008/10/21
[ "https://Stackoverflow.com/questions/221976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22550/" ]
221,984
<p>I'm writing an Excel Addin using COM Interop from .net. I have a command that pops up a dialog, and from the dialog I do some work like collecting data from the used range of several sheets. The problem is that if a cell is in edit mode, some of the calls that I need to make will throw exceptions. I would like a way of determining before-hand that Excel is in edit mode, so that I can warn the user to finish editing the cell first.</p> <p>Any ideas?</p>
[ { "answer_id": 25057820, "author": "SZL", "author_id": 2278037, "author_profile": "https://Stackoverflow.com/users/2278037", "pm_score": 3, "selected": false, "text": " Function IsInEditMode(ByRef exapp As Excel.Application) As Boolean\n If exapp.Interactive = False Then\n ...
2008/10/21
[ "https://Stackoverflow.com/questions/221984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1727/" ]
222,017
<p>I'm looking for (simple) examples of problems for which JMS is a good solution, and also reasons why JMS is a good solution in these cases. In the past I've simply used the database as a means of passing messages from A to B when the message cannot necessarily be processed by B immediately.</p> <p>A hypothetical example of such a system is where all newly registered users should be sent a welcome e-mail within 24 hours of registration. For the sake of argument, assume the DB does not record the time when each user registered, but instead a reference (foreign key) to each new user is stored in the pending_email table. The e-mail sender job runs once every 24 hours, sends an e-mail to all the users in this table, then deletes all the pending_email records.</p> <p>This seems like the kind of problem for which JMS should be used, but it's not clear to me what benefit JMS would have over the approach I've described. One advantage of the DB approach is that the messages are persistent. I understand that JMS message queues can also be persisted, but in that case there seems to be little difference between JMS and the "database as message queue" approach I've described?</p> <p>What am I missing? - Don</p>
[ { "answer_id": 19044855, "author": "Aniket Thakur", "author_id": 2396539, "author_profile": "https://Stackoverflow.com/users/2396539", "pm_score": 2, "selected": false, "text": "what is JMS good for?" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/222017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
222,018
<p>How to format numbers in JavaScript?</p> <hr> <ul> <li><a href="https://stackoverflow.com/questions/51564/javascript-culture-sensitive-currency-formatting">JavaScript culture sensitive currency formatting</a></li> </ul>
[ { "answer_id": 222038, "author": "SaaS Developer", "author_id": 7215, "author_profile": "https://Stackoverflow.com/users/7215", "pm_score": 5, "selected": true, "text": "var num = 10;\nvar result = num.toFixed(2); // result will equal 10.00\n\nnum = 930.9805;\nresult = num.toFixed(3); //...
2008/10/21
[ "https://Stackoverflow.com/questions/222018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1100/" ]
222,019
<p>How do i take advantage of MySQL's ability to cache prepared statements? One reason to use prepared statements is that there is no need to send the prepared statement itself multiple times if the same prepared statement is to be used again. </p> <pre><code>Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/mydb" + "?cachePrepStmts=true", "user", "pass"); for (int i = 0; i &lt; 5; i++) { PreparedStatement ps = conn.prepareStatement("select * from MYTABLE where id=?"); ps.setInt(1, 1); ps.execute(); } conn.close() </code></pre> <p>When running the above Java example I see 5 pairs of Prepare and Execute commands in the mysqld log file. Moving the ps assignment outside of the loop results in a single Prepare and 5 Execute commands of course. The connection parameter "cachePrepStmts=true" doesn't seem to make any difference here.<br> When running a similar program using Spring and Hibernate the number of Prepare commands sent (1 or 5) depends on whether the cachePrepStmts connection parameter is enabled. How does Hibernate execute prepared statements to take advantage of the cachePrepStmts setting? Is it possible to mimic this using pure JDBC?<br> I was running this on MySQL Server 4.1.22 and mysql-connector-java-5.0.4.jar</p>
[ { "answer_id": 374372, "author": "kosoant", "author_id": 15114, "author_profile": "https://Stackoverflow.com/users/15114", "pm_score": 2, "selected": false, "text": "Connection conn = DatabaseUtil.getConnection();\nPreparedStatement stmtUpdate = conn.prepareStatement(\"UPDATE foo SET bar...
2008/10/21
[ "https://Stackoverflow.com/questions/222019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11411/" ]
222,028
<p>Lots of frameworks let me expose an ejb as a webservice. </p> <p>But then 2 months after publishing the initial service I need to change the ejb or any part of its interface. I still have clients that need to access the old interface, so I obviously need to have 2 webservices with different signatures.</p> <p>Anyone have any suggestions on how I can do this, preferably letting the framework do the grunt work of creating wrappers and copying logic (unless there's an even smarter way).</p> <p>I can choose webservice framework on basis of this, so suggestions are welcome.</p> <p>Edit: I know my change is going to break compatibility,and I am fully aware that I will need two services with different namespaces at the same time. But how can I do it in a simple manner ?</p>
[ { "answer_id": 265013, "author": "Kariem", "author_id": 12039, "author_profile": "https://Stackoverflow.com/users/12039", "pm_score": 4, "selected": true, "text": "@WebService\n@SOAPBinding(style = Style.RPC)\npublic interface ILegacyService extends IOtherLegacyService {\n // the inte...
2008/10/21
[ "https://Stackoverflow.com/questions/222028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23691/" ]
222,029
<p>the WPF Popup control is nice, but somewhat limited in my opinion. is there a way to "drag" a popup around when it is opened (like with the DragMove() method of windows)?</p> <p>can this be done without big problems or do i have to write a substitute for the popup class myself? thanks</p>
[ { "answer_id": 222219, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 4, "selected": false, "text": "<Popup x:Name=\"pop\" IsOpen=\"True\" Height=\"200\" Placement=\"AbsolutePoint\" Width=\"200\">\n <Rectangle Stretch=\"F...
2008/10/21
[ "https://Stackoverflow.com/questions/222029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20227/" ]
222,030
<p>How can I create 7-Zip archives from my C# console application? I need to be able to extract the archives using the regular, widely available <a href="http://www.7-zip.org/" rel="noreferrer">7-Zip</a> program.</p> <hr> <h2>Here are my results with the examples provided as answers to this question</h2> <ul> <li>"Shelling out" to 7z.exe - this is the simplest and most effective approach, and I can confirm that <strong>it works nicely</strong>. As <a href="https://stackoverflow.com/questions/222030/how-do-i-create-7-zip-archives-with-net#222047">workmad3 mentions</a>, I just need to guarantee that 7z.exe is installed on all target machines, which is something I can guarantee.</li> <li><a href="http://www.eggheadcafe.com/tutorials/aspnet/064b41e4-60bc-4d35-9136-368603bcc27a/7zip-lzma-inmemory-com.aspx" rel="noreferrer">7Zip in memory compression</a> - this refers to compressing cookies "in-memory" before sending to the client; this method seems somewhat promising. The wrapper methods (wrapping the <a href="http://www.7-zip.org/sdk.html" rel="noreferrer">LZMA SDK</a>) return type <code>byte[]</code>. When I write the <code>byte[]</code> array to a file, I can't extract it using 7-Zip (<code>File.7z is not supported archive</code>).</li> <li><a href="http://www.codeplex.com/7zsharp" rel="noreferrer">7zSharp</a> Wrapper (found on CodePlex) - this wraps the 7z exe/<a href="http://www.7-zip.org/sdk.html" rel="noreferrer">LZMA SDK</a>. I referenced the project from my app, and it successfully created some archive files, but I was unable to extract the files using the regular 7-Zip program (<code>File.7z is not supported archive</code>).</li> <li><a href="http://www.7-zip.org/sdk.html" rel="noreferrer">7Zip SDK aka LZMA SDK</a> - I guess I'm not smart enough to figure out how to use this (which is why I posted here)... Any working code examples that demonstrate creating a 7zip archive that is able to be extracted by the regular 7zip program?</li> <li><a href="http://www.codeproject.com/KB/DLL/cs_interface_7zip.aspx" rel="noreferrer">CodeProject C# (.NET) Interface for 7-Zip Archive DLLs</a> - only supports extracting from 7zip archives... I need to create them!</li> <li><a href="http://sharpdevelop.net/OpenSource/SharpZipLib/Default.aspx" rel="noreferrer">SharpZipLib</a> - According to their <a href="http://wiki.sharpdevelop.net/SharpZipLib_FAQ.ashx" rel="noreferrer">FAQ</a>, SharpZipLib doesn't support 7zip.</li> </ul>
[ { "answer_id": 367502, "author": "WOPR", "author_id": 46255, "author_profile": "https://Stackoverflow.com/users/46255", "pm_score": 3, "selected": false, "text": "using SevenZip.Compression.LZMA;\nprivate static void CompressFileLZMA(string inFile, string outFile)\n{\n SevenZip.Compres...
2008/10/21
[ "https://Stackoverflow.com/questions/222030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]
222,043
<p>I have a variable that contains a 4 byte, network-order IPv4 address (this was created using pack and the integer representation). I have another variable, also a 4 byte network-order, subnet. I'm trying to add them together and add one to get the first IP in the subnet.</p> <p>To get the ASCII representation, I can do <code>inet_ntoa($ip&amp;$netmask)</code> to get the base address, but it's an error to do <code>inet_ntoa((($ip&amp;$netmask)+1)</code>; I get a message like:</p> <pre><code> Argument "\n\r&amp;\0" isn't numeric in addition (+) at test.pm line 95. </code></pre> <p>So what's happening, the best as I can tell, is it's looking at the 4 bytes, and seeing that the 4 bytes don't represent a numeric string, and then refusing to add 1.</p> <p>Another way of putting it: What I want it to do is add 1 to the least significant byte, which I know is the 4th byte? That is, I want to take the string <code>\n\r&amp;\0</code> and end up with the string <code>\n\r&amp;\1</code>. What's the simplest way of doing that? </p> <p>Is there a way to do this without having to unpack and re-pack the variable?</p>
[ { "answer_id": 222096, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 5, "selected": true, "text": "$ip&$netmask" }, { "answer_id": 222169, "author": "Liudvikas Bukys", "author_id": 5845, "author_p...
2008/10/21
[ "https://Stackoverflow.com/questions/222043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7548/" ]
222,052
<p>I have a ControlTemplate that is made up of a ToolBarTray and a ToolBar. In my ToolBar, I have several buttons and then a label. I want to be able to update the label in my toolbar with something like "1 of 10" </p> <p>My first thought is to programatically find the label and set it, but I'm reading that this should be done with Triggers. I am having a hard time understanding how to accomplish this. Any ideas?</p> <pre><code> &lt;Style x:Key="DocViewerToolBarStyle" TargetType="{x:Type ContentControl}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ContentControl}"&gt; &lt;ToolBarTray... /&gt; &lt;ToolBar.../&gt; &lt;Button../&gt; &lt;Button..&gt; &lt;Label x:Name="myStatusLabel" .. /&gt; </code></pre>
[ { "answer_id": 222106, "author": "Bryan Anderson", "author_id": 21186, "author_profile": "https://Stackoverflow.com/users/21186", "pm_score": 1, "selected": false, "text": "<Label x:Name=\"myStatusLabel\" Content=\"{TemplateBinding Content}\"/>\n" }, { "answer_id": 222129, "...
2008/10/21
[ "https://Stackoverflow.com/questions/222052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
222,053
<p>this is my first question here so I hope I can articulate it well and hopefully it won't be too mind-numbingly easy.</p> <p>I have the following class <em>SubSim</em> which extends <em>Sim</em>, which is extending <em>MainSim</em>. In a completely separate class (and library as well) I need to check if an object being passed through is a type of <em>MainSim</em>. So the following is done to check;</p> <pre> Type t = GetType(sim); //in this case, sim = SubSim if (t != null) { return t.BaseType == typeof(MainSim); } </pre> <p>Obviously <em>t.BaseType</em> is going to return <em>Sim</em> since <em>Type.BaseType</em> gets the type from which the current Type directly inherits. </p> <p>Short of having to do <em>t.BaseType.BaseType</em> to get <em>MainSub</em>, is there any other way to get the proper type using .NET libraries? Or are there overrides that can be redefined to return the main class? </p> <p>Thank you in advance</p>
[ { "answer_id": 222059, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 3, "selected": false, "text": "if (sim is MainSim)\n" }, { "answer_id": 222062, "author": "Mark Cidade", "author_id": 1659, "aut...
2008/10/21
[ "https://Stackoverflow.com/questions/222053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13064/" ]
222,065
<p>When creating an index over a column that is going to be UNIQUE (but not the primary key of the table), SQL server let's me choose a few options:</p> <p>1) I can choose for it to be a Constraint or an Index.<br> I'm guessing this means that if I set it as constraint, it won't use it when querying, only when writing. However, the only efficient way I can think of for SQL Server to enforce that constraint is by actually building an index. What is the use for this option?</p> <p>2) Also, if I set it as "index", it let's me specify that it should ignore duplicate keys. This is the most puzzling for me...<br> I again guess it means the opposite of constraint. It probably means "use it when querying, but don't even check when writing".<br> But then why would I set it as UNIQUE?<br> I'm guessing there are some optimizations SQL Server can do, but i'd like to understand it better.</p> <p>Does anyone know what exactly SQL Server does with these options?<br> What's the use case for setting an index to be Unique, but ignore duplicate keys?</p> <p>NOTE: This is for SQL Server 2000</p> <hr /> <p><strong>EDIT:</strong> According to what you said, however... If I create a Constraint, will it be used to speed up queries that filter using the fields in the constraint?</p> <p>Thanks!</p>
[ { "answer_id": 222284, "author": "onedaywhen", "author_id": 15354, "author_profile": "https://Stackoverflow.com/users/15354", "pm_score": 4, "selected": true, "text": "UNIQUE" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/222065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
222,089
<p>With the following file reading code:</p> <pre><code>using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None)) { using (TextReader tr = new StreamReader(fileStream)) { string fileContents = tr.ReadToEnd(); } } </code></pre> <p>And the following file write code:</p> <pre><code>using (TextWriter tw = new StreamWriter(fileName)) { tw.Write(fileContents); tw.Close(); } </code></pre> <p>The following exception details are seen:</p> <blockquote> <p>The process cannot access the file 'c:\temp\myfile.txt' because it is being used by another process.</p> </blockquote> <p>What is the best way of avoiding this? Does the reader need to retry upon receipt of the exception or is there some better way?</p> <p>Note that the reader process is using a <em>FileSystemWatcher</em> to know when the file has changed.</p> <p>Also note that, in this instance, I'm <strong>not</strong> looking for alternatives ways of sharing strings between the 2 processes.</p>
[ { "answer_id": 222100, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 2, "selected": false, "text": "Mutex" }, { "answer_id": 222111, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https:/...
2008/10/21
[ "https://Stackoverflow.com/questions/222089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5993/" ]
222,108
<p>On my busiest production installation, on occasion I get a single thread that seems to get stuck in an infinite loop. I've not managed to figure out who is the culprit, after much research and debugging, but it seems like it should be possible. Here are the gory details:</p> <p><strong><em>Current debugging notes:</em></strong></p> <p>1) <strong>ps -eL 18975</strong> shows me the the Linux pid the problem child thread, 19269</p> <pre><code>$ps -eL | grep 18975 ... PID LWP TTY TIME CMD 18975 18994 ? 00:00:05 java 18975 19268 ? 00:00:00 java 18975 19269 ? 05:16:49 java 18975 19271 ? 00:01:22 java 18975 19273 ? 00:00:00 java ... </code></pre> <p>2) <strong>jstack -l 18975</strong> says there are no deadlocks, <strong>jstack -m 18975</strong> does not work </p> <p>3) <strong>jstack -l 18975</strong> does give me the stack trace for all my threads (~400). Example thread stack (<em>and not the problem</em>):</p> <pre>"http-342.877.573.944-8080-360" daemon prio=10 tid=0x0000002adaba9c00 nid=0x754c in Object.wait() [0x00000000595bc000..0x00000000595bccb0] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on (a org.apache.tomcat.util.net.JIoEndpoint$Worker) at java.lang.Object.wait(Object.java:485) at org.apache.tomcat.util.net.JIoEndpoint$Worker.await(JIoEndpoint.java:416) - locked (a org.apache.tomcat.util.net.JIoEndpoint$Worker) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:442) at java.lang.Thread.run(Thread.java:619) </pre> <p>4) The ps -eL output's thread ID does not match the output from jstack, or at least I cannot see it. (jstack documentation is a bit sparse.) </p> <p>5) There are no heavy IO, memory usage or other corresponding activity clues to work with.</p> <p><strong><em>Platform:</em></strong></p> <ul> <li>Java 6</li> <li>Tomcat 6</li> <li>RHEL 4 (64-bit)</li> </ul> <p>Does anybody know how I can make that connection from the linux ps output to my problem child java thread? So close, yet so far...</p>
[ { "answer_id": 1199127, "author": "ubiyubix", "author_id": 19701, "author_profile": "https://Stackoverflow.com/users/19701", "pm_score": 5, "selected": true, "text": "\"http-342.877.573.944-8080-360\" daemon prio=10 tid=0x0000002adaba9c00 nid=0x754c in Object.wait() [0x00000000595bc000.....
2008/10/21
[ "https://Stackoverflow.com/questions/222108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2961/" ]
222,117
<p><a href="https://stackoverflow.com/questions/106597/why-are-fixnums-in-emacs-only-29-bits">The fixnum question</a> brought my mind to an other question I've wondered for a long time.</p> <p>Many online material about garbage collection does not tell about how runtime type information can be implemented. Therefore I know lots about all sorts of garbage collectors, but not really about how I can implement them.</p> <p>The fixnum solution is actually quite nice, it's very clear which value is a pointer and which isn't. What other commonly used solutions for storing type information there is?</p> <p>Also, I wonder about fixnum -thing. Doesn't that mean that you are being limited to fixnums on every array index? Or is there some sort of workaround for getting full 64-bit integers?</p>
[ { "answer_id": 711687, "author": "Damien Pollet", "author_id": 63112, "author_profile": "https://Stackoverflow.com/users/63112", "pm_score": 0, "selected": false, "text": "SmallInteger" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/222117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21711/" ]
222,119
<p>I have encapsulated a backup database command in a Try/Catch and it appears that the error message is being lost somewhere. For example:</p> <pre><code>BACKUP DATABASE NonExistantDB TO DISK = 'C:\TEMP\NonExistantDB.bak' </code></pre> <p>..gives error:<br> <strong><em>Could not locate entry in sysdatabases for database 'NonExistantDB'. No entry found with that name. Make sure that the name is entered correctly. BACKUP DATABASE is terminating abnormally.</em></strong></p> <p>Whereas:</p> <pre><code>BEGIN TRY BACKUP DATABASE NonExistantDB TO DISK = 'C:\TEMP\NonExistantDB.bak' END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH </code></pre> <p>... only gives error: <strong><em>BACKUP DATABASE is terminating abnormally.</em></strong></p> <p>Is there a way to get the full error message or is this a limitation of try/catch?</p>
[ { "answer_id": 222277, "author": "Josef", "author_id": 5581, "author_profile": "https://Stackoverflow.com/users/5581", "pm_score": 3, "selected": true, "text": " BACKUP DATABASE NonExistantDB TO DISK = 'C:\\TEMP\\NonExistantDB.bak'\n" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/222119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11989/" ]
222,133
<p>I'm working on a web application that will return a variable set of modules depending on user input. Each module is a Python class with a constructor that accepts a single parameter and has an '.html' property that contains the output.</p> <p>Pulling the class dynamically from the global namespace works:</p> <pre><code>result = globals()[classname](param).html </code></pre> <p>And it's certainly more succinct than:</p> <pre><code>if classname == 'Foo': result = Foo(param).html elif classname == 'Bar': ... </code></pre> <p>What is considered the best way to write this, stylistically? Are there risks or reasons not to use the global namespace?</p>
[ { "answer_id": 222307, "author": "Dan Lenski", "author_id": 20789, "author_profile": "https://Stackoverflow.com/users/20789", "pm_score": 2, "selected": false, "text": "dispatch = {'Foo': Foo, 'Bar': Bar, 'Bizbaz': Bizbaz}\n" }, { "answer_id": 222334, "author": "Brian", "...
2008/10/21
[ "https://Stackoverflow.com/questions/222133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7341/" ]
222,139
<p>I'm building a new site for my company, and I'm at the stage where I've created the html mockup of the first page. I'm going to use this as a basis for the rest of the site. I'm thinking of organising my stylesheet better now I've got the design looking consistent cross-browser, but I'm wondering how far to go when I'm breaking it up.</p> <p>One idea is to have the following:</p> <ul> <li>reset.css</li> <li>typography.css</li> <li>layout.css</li> <li>colors.css</li> </ul> <p>but where do I draw the line? theoretically I could go on and break them down into classes, ids etc, but I think thats going overboard.</p> <p>Does this seem a reasonable method?</p>
[ { "answer_id": 222158, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 3, "selected": false, "text": "base.css" }, { "answer_id": 222867, "author": "Steve Paulo", "author_id": 9414, "author_profile": "https://...
2008/10/21
[ "https://Stackoverflow.com/questions/222139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26107/" ]
222,148
<p>The default value for the first item in a drop down list is the name of the database field. I need to change it to a more user friendly name. How do I change the value?</p>
[ { "answer_id": 222852, "author": "Joshua", "author_id": 6013, "author_profile": "https://Stackoverflow.com/users/6013", "pm_score": 4, "selected": true, "text": "<script>" } ]
2008/10/21
[ "https://Stackoverflow.com/questions/222148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6013/" ]