qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
40,873
<p>I have a table which is full of arbitrarily formatted phone numbers, like this</p> <pre><code>027 123 5644 021 393-5593 (07) 123 456 042123456 </code></pre> <p>I need to search for a phone number in a similarly arbitrary format ( e.g. <code>07123456</code> should find the entry <code>(07) 123 456</code></p> <p>The way I'd do this in a normal programming language is to strip all the non-digit characters out of the 'needle', then go through each number in the haystack, strip all non-digit characters out of it, then compare against the needle, eg (in ruby)</p> <pre><code>digits_only = lambda{ |n| n.gsub /[^\d]/, '' } needle = digits_only[input_phone_number] haystack.map(&amp;digits_only).include?(needle) </code></pre> <p>The catch is, I need to do this in MySQL. It has a host of string functions, none of which really seem to do what I want.</p> <p>Currently I can think of 2 'solutions'</p> <ul> <li>Hack together a franken-query of <code>CONCAT</code> and <code>SUBSTR</code></li> <li>Insert a <code>%</code> between every character of the needle ( so it's like this: <code>%0%7%1%2%3%4%5%6%</code> )</li> </ul> <p>However, neither of these seem like particularly elegant solutions.<br /> Hopefully someone can help or I might be forced to use the %%%%%% solution</p> <h3>Update: This is operating over a relatively fixed set of data, with maybe a few hundred rows. I just didn't want to do something ridiculously bad that future programmers would cry over.</h3> <p>If the dataset grows I'll take the 'phoneStripped' approach. Thanks for all the feedback!</p> <hr /> <blockquote> <p>could you use a &quot;replace&quot; function to strip out any instances of &quot;(&quot;, &quot;-&quot; and &quot; &quot;,</p> </blockquote> <p>I'm not concerned about the result being numeric. The main characters I need to consider are <code>+</code>, <code>-</code>, <code>(</code>, <code>)</code> and <code>space</code> So would that solution look like this?</p> <pre><code>SELECT * FROM people WHERE REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(phonenumber, '('),')'),'-'),' '),'+') LIKE '123456' </code></pre> <p>Wouldn't that be terribly slow?</p>
[ { "answer_id": 40904, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 0, "selected": false, "text": "\"(027) 123 456\"" }, { "answer_id": 40938, "author": "Orion Edwards", "author_id": 234, "author_prof...
2008/09/02
[ "https://Stackoverflow.com/questions/40873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
40,884
<p>How can I go about storing a vb.net user defined object in a sql database. I am not trying to replicate the properties with columns. I mean something along the lines of converting or encoding my object to a byte array and then storing that in a field in the db. Like when you store an instance of an object in session, but I need the info to persist past the current session. </p> <hr> <p>@Orion Edwards</p> <blockquote> <p>It's not a matter of stances. It's because one day, you will change your code. Then you will try de-serialize the old object, and YOUR PROGRAM WILL CRASH.</p> </blockquote> <p>My Program will not "CRASH", it will throw an exception. Lucky for me .net has a whole set of classes dedicated for such an occasion. At which time I will refresh my stale data and put it back in the db. That is the point of this one field (or stance, as the case may be).</p>
[ { "answer_id": 41126, "author": "Jas", "author_id": 777, "author_profile": "https://Stackoverflow.com/users/777", "pm_score": 0, "selected": false, "text": " #'res is my object to serialize\n Dim xml_serializer As System.Xml.Serialization.XmlSerializer\n Dim string_writer As New...
2008/09/02
[ "https://Stackoverflow.com/questions/40884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/777/" ]
40,912
<p>I'm looking for a way to check within <code>pageLoad()</code> if this method is raised during load event because of a postback/async postback or because of being loaded and access the first time.</p> <p>This is similar to <code>Page.IsPostback</code> property within code behind page.</p> <p>TIA, Ricky</p>
[ { "answer_id": 40981, "author": "Ricky Supit", "author_id": 4191, "author_profile": "https://Stackoverflow.com/users/4191", "pm_score": 2, "selected": false, "text": " function pageLoad(sender, arg) {\n if (!arg.get_isPartialLoad()) {\n //code to be executed only on the f...
2008/09/02
[ "https://Stackoverflow.com/questions/40912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4191/" ]
40,913
<p>I am having problems manually looping through xml data that is received via an HTTPService call, the xml looks something like this: </p> <pre><code>&lt;DataTable&gt; &lt;Row&gt; &lt;text&gt;foo&lt;/text&gt; &lt;/Row&gt; &lt;Row&gt; &lt;text&gt;bar&lt;/text&gt; &lt;/Row&gt; &lt;/DataTable&gt; </code></pre> <p>When the webservice result event is fired I do something like this:</p> <pre><code>for(var i:int=0;i&amp;lt;event.result.DataTable.Row.length;i++) { if(event.result.DataTable.Row[i].text == "foo") mx.controls.Alert.show('foo found!'); } </code></pre> <p>This code works then there is more than 1 "Row" nodes returned. However, it seems that if there is only one "Row" node then the <em>event.DataTable.Row</em> object is not an error and the code subsequently breaks. </p> <p>What is the proper way to loop through the <em>HTTPService</em> result object? Do I need to convert it to some type of <em>XMLList</em> collection or an <em>ArrayCollection</em>? I have tried setting the resultFormat to <em>e4x</em> and that has yet to fix the problem...</p> <p>Thanks.</p>
[ { "answer_id": 40930, "author": "dlamblin", "author_id": 459, "author_profile": "https://Stackoverflow.com/users/459", "pm_score": 2, "selected": false, "text": "if (exists(event.result.DataTable) && exists(event.result.DataTable.Row)){\n if (exists(event.result.DataTable.Row.length)) {...
2008/09/02
[ "https://Stackoverflow.com/questions/40913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
40,923
<p>I have a framework written in Perl that sets a bunch of environment variables to support interprocess (typically it is sub process) communication. We keep a sets of key/value pairs in XML-ish files. We tried to make the key names camel-case <code>somethingLikeThis</code>. This all works well.</p> <p>Recently we have had occasion to pass control (chain) processes from Windows to UNIX. When we spit out the <code>%ENV</code> hash to a file from Windows the <code>somethingLikeThis</code> key becomes <code>SOMETHINGLIKETHIS</code>. When the Unix process picks up the file and reloads the environment and looks up the value of <code>$ENV{somethingLikeThis}</code> it does not exist since UNIX is case sensitive (from the Windows side the same code works fine). </p> <p>We have since gone back and changed all the keys to UPPERCASE and solved the problem, but that was tedious and caused pain to the users. Is there a way to make Perl on Windows preserve the character case of the keys of the environment hash?</p>
[ { "answer_id": 73849, "author": "piCookie", "author_id": 8763, "author_profile": "https://Stackoverflow.com/users/8763", "pm_score": 2, "selected": false, "text": "my %env = map {/(.*?)=(.*)/;} `set`;\nprint join(' ', sort keys %env);\n" } ]
2008/09/02
[ "https://Stackoverflow.com/questions/40923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
40,943
<p>What code do you need to add in PHP to automatically have the browser download a file to the local machine when a link is visited?</p> <p>I am specifically thinking of functionality similar to that of download sites that prompt the user to save a file to disk once you click on the name of the software?</p>
[ { "answer_id": 40945, "author": "grom", "author_id": 486, "author_profile": "https://Stackoverflow.com/users/486", "pm_score": 5, "selected": false, "text": "header('Content-type: application/pdf');\nheader('Content-Disposition: attachment; filename=\"' . basename($filename) . '\"');\nhe...
2008/09/03
[ "https://Stackoverflow.com/questions/40943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277/" ]
40,957
<p>I'm early in development on a web application built in VS2008. I have both a desktop PC (where most of the work gets done) and a laptop (for occasional portability) on which I use AnkhSVN to keep the project code synced. What's the best way to keep my development database (SQL Server Express) synced up as well?</p> <p>I have a VS database project in SVN containing create scripts which I re-generate when the schema changes. The original idea was to recreate the DB whenever something changed, but it's quickly becoming a pain. Also, I'd lose all the sample rows I entered to make sure data is being displayed properly.</p> <p>I'm considering putting the .MDF and .LDF files under source control, but I doubt SQL Server Express will handle it gracefully if I do an SVN Update and the files get yanked out from under it, replaced with newer copies. Sticking a couple big binary files into source control doesn't seem like an elegant solution either, even if it is just a throwaway development database. Any suggestions?</p>
[ { "answer_id": 40963, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 2, "selected": false, "text": "use master\ngo\n\nif exists (select * from master.dbo.sysdatabases where name = 'your_db')\nbegin\n alter database your_db set...
2008/09/03
[ "https://Stackoverflow.com/questions/40957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4160/" ]
40,962
<p>I have a need to close a parent form from within child form from a Windows application. What would be the best way to do this?</p>
[ { "answer_id": 41579, "author": "Ed Schwehm", "author_id": 1206, "author_profile": "https://Stackoverflow.com/users/1206", "pm_score": 0, "selected": false, "text": "private Form pForm;\npublic ChildForm(ref Form parentForm)\n{\n pForm = parentForm;\n}\n\nprivate closeParent()\n{\n ...
2008/09/03
[ "https://Stackoverflow.com/questions/40962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2062/" ]
40,966
<p>I have a javascript function that manipulates the DOM when it is called (adds CSS classes, etc). This is invoked when the user changes some values in a form. When the document is first loading, I want to invoke this function to prepare the initial state (which is simpler in this case than setting up the DOM from the server side to the correct initial state).</p> <p>Is it better to use window.onload to do this functionality or have a script block after the DOM elements I need to modify? For either case, why is it better?</p> <p>For example:</p> <pre><code>function updateDOM(id) { // updates the id element based on form state } </code></pre> <p>should I invoke it via:</p> <pre><code>window.onload = function() { updateDOM("myElement"); }; </code></pre> <p>or:</p> <pre><code>&lt;div id="myElement"&gt;...&lt;/div&gt; &lt;script language="javascript"&gt; updateDOM("myElement"); &lt;/script&gt; </code></pre> <p>The former seems to be the standard way to do it, but the latter seems to be just as good, perhaps better since it will update the element as soon as the script is hit, and as long as it is placed after the element, I don't see a problem with it.</p> <p>Any thoughts? Is one version really better than the other?</p>
[ { "answer_id": 40972, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 4, "selected": true, "text": "onload" }, { "answer_id": 41008, "author": "John Millikin", "author_id": 3560, "author_profile": "ht...
2008/09/03
[ "https://Stackoverflow.com/questions/40966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122/" ]
40,999
<p>Here's a quick question I've been banging my head against today.</p> <p>I'm trying to convert a .Net dataset into an XML stream, transform it with an xsl file in memory, then output the result to a new XML file. </p> <p>Here's the current solution:</p> <pre><code> string transformXML = @"pathToXslDocument"; XmlDocument originalXml = new XmlDocument(); XmlDocument transformedXml = new XmlDocument(); XslCompiledTransform transformer = new XslCompiledTransform(); DataSet ds = new DataSet(); string filepath; originalXml.LoadXml(ds.GetXml()); //data loaded prior StringBuilder sb = new StringBuilder(); XmlWriter writer = XmlWriter.Create(sb); transformer.Load(transformXML); transformer.Transform(originalXml, writer); //no need to select the node transformedXml.LoadXml(sb.ToString()); transformedXml.Save(filepath); writer.Close(); </code></pre> <p>Here's the original code:</p> <pre><code>BufferedStream stream = new BufferedStream(new MemoryStream()); DataSet ds = new DataSet(); da.Fill(ds); ds.WriteXml(stream); StreamReader sr = new StreamReader(stream, true); stream.Position = 0; //I'm not certain if this is necessary, but for the StreamReader to read the text the position must be reset. XmlReader reader = XmlReader.Create(sr, null); //Problem is created here, the XmlReader is created with none of the data from the StreamReader XslCompiledTransform transformer = new XslCompiledTransform(); transformer.Load(@"&lt;path to xsl file&gt;"); transformer.Transform(reader, null, writer); //Exception is thrown here, though the problem originates from the XmlReader.Create(sr, null) </code></pre> <p>For some reason in the transformer.Transform method, the reader has no root node, in fact the reader isn't reading anything from the StreamReader.</p> <p>My questions is what is wrong with this code? Secondarily, is there a better way to convert/transform/store a dataset into XML?</p> <p>Edit: Both answers were helpful and technically aku's was closer. However I am leaning towards a solution that more closely resembles Longhorn's after trying both solutions.</p>
[ { "answer_id": 41012, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 4, "selected": true, "text": " BufferedStream stream = new BufferedStream(new MemoryStream());\n stream.Write(Encoding.ASCII.GetBytes(\"<xml>foo</xml>\"),...
2008/09/03
[ "https://Stackoverflow.com/questions/40999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2916/" ]
41,010
<p><strong>A Little Background Information</strong>:<br> I've been looking at a few PHP framework recently, and it came down to two. The Zend Framework or CodeIgniter. </p> <p>I prefer CodeIgniter, because of its simple design. It's very bare bone, and it is just kept simple. The thing I don't like though is the weak template system. The template system is important for me, because I will be working with another designer. Being able to give him a good template system is a big plus.</p> <p>Zend was the second choice, because of the better template system that is built in. Zend is a different beast though compared to CodeIgniter. It emphasis "loose coupling between modules", but is a bigger framework. I don't like to feel like I have many things running under the hood that I never use. That is unnecessary overhead in my opinion, so I thought about putting a template system into CodeIgniter: Smarty.</p> <p><strong>Question(s)</strong>: How easy/hard is the process to integrate Smarty into CodeIgniter? From my initial scan of the CodeIgniter documentation, I can see that the layout of the framework is easy enough to understand, and I anticipate no problems. I want to know if anyone has used it before, and therefore are aware of any "gotchas" you my have experienced that is going to make this harder than it should be or impossible to pull off. I also want to know if this is a good thing to do at all. Is the template system in CodeIgniter enough for normal use? Are there any other template modules that are good for CodeIgniter aside from Smarty? I better off with Zend Framework? Is any wheel being invented here?</p>
[ { "answer_id": 30263642, "author": "Luca Mori Polpettini", "author_id": 2270716, "author_profile": "https://Stackoverflow.com/users/2270716", "pm_score": 0, "selected": false, "text": "<?php\nif ( ! defined('BASEPATH')) exit('No direct script access allowed');\n\nrequire_once(APPPATH.'th...
2008/09/03
[ "https://Stackoverflow.com/questions/41010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2976/" ]
41,018
<p>Grails makes it very easy to configure datasources for different environments (development, test, production) in its DataSources.groovy file, but there seems to be no facility for configuring multiple datasources in one environment. What to I do if I need to access several databases from the same Grails application?</p>
[ { "answer_id": 12075345, "author": "anataliocs", "author_id": 555177, "author_profile": "https://Stackoverflow.com/users/555177", "pm_score": 2, "selected": false, "text": "dataSource {\n pooled = true\n driverClassName = \"org.h2.Driver\"\n username = \"sa\"\n password = \"\...
2008/09/03
[ "https://Stackoverflow.com/questions/41018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2453/" ]
41,027
<p>I am looking for a little bit of JQuery or JS that allows me to produce a horizontally scrolling "news ticker" list.</p> <p>The produced HTML needs to be standards compliant as well.</p> <p>I have tried <a href="http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html" rel="noreferrer">liScroll</a> but this has a habit of breaking (some content ends up on a second line at the start of the scroll), especially with longer lists.</p> <p>I have also tried <a href="http://www.mioplanet.com/rsc/newsticker_javascript.htm" rel="noreferrer">this News Ticker</a> but when a DOCTYPE is included the scrolling will jolt rather than cycle smoothly at the end of each cycle.</p> <p>Any suggestions are appreciated.</p> <p><strong>Edit</strong></p> <p>So thanks to Matt Hinze's suggestion I realised I could do what I wanted to do with JQuery animate (I require continuous scrolling not discrete scrolling like the example). However, I quickly ran into similar problems to those I was having with liScroll and after all that realised a CSS issue (as always) was responsible.</p> <p>Solution: liScroll - change the default 'var stripWidth = 0' to something like 100, to give a little space and avoid new line wrapping.</p>
[ { "answer_id": 40595802, "author": "tj001", "author_id": 7052915, "author_profile": "https://Stackoverflow.com/users/7052915", "pm_score": 0, "selected": false, "text": "<li>&nbsp;</li>" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
41,039
<p>Is there a way to search the latest version of every file in TFS for a specific string or regex? This is probably the only thing I miss from Visual Source Safe... </p> <p>Currently I perform a Get Latest on the entire codebase and use Windows Search, but this gets quite painful with over 1GB of code in 75,000 files. </p> <p><strong>EDIT</strong>: Tried the powertools mentioned, but the "Wildcard Search" option appears to only search filenames and not contents.</p> <p><strong>UPDATE</strong>: We have implemented a customised search option in an existing MOSS (Search Server) installation. </p>
[ { "answer_id": 78966, "author": "granth", "author_id": 11210, "author_profile": "https://Stackoverflow.com/users/11210", "pm_score": 7, "selected": true, "text": "foo" }, { "answer_id": 23023410, "author": "Vijayanand Settin", "author_id": 2125810, "author_profile": "...
2008/09/03
[ "https://Stackoverflow.com/questions/41039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/952/" ]
41,045
<p>As a general rule, I prefer using value rather than pointer semantics in C++ (ie using <code>vector&lt;Class&gt;</code> instead of <code>vector&lt;Class*&gt;</code>). Usually the slight loss in performance is more than made up for by not having to remember to delete dynamically allocated objects.</p> <p>Unfortunately, value collections don't work when you want to store a variety of object types that all derive from a common base. See the example below.</p> <pre><code>#include &lt;iostream&gt; using namespace std; class Parent { public: Parent() : parent_mem(1) {} virtual void write() { cout &lt;&lt; "Parent: " &lt;&lt; parent_mem &lt;&lt; endl; } int parent_mem; }; class Child : public Parent { public: Child() : child_mem(2) { parent_mem = 2; } void write() { cout &lt;&lt; "Child: " &lt;&lt; parent_mem &lt;&lt; ", " &lt;&lt; child_mem &lt;&lt; endl; } int child_mem; }; int main(int, char**) { // I can have a polymorphic container with pointer semantics vector&lt;Parent*&gt; pointerVec; pointerVec.push_back(new Parent()); pointerVec.push_back(new Child()); pointerVec[0]-&gt;write(); pointerVec[1]-&gt;write(); // Output: // // Parent: 1 // Child: 2, 2 // But I can't do it with value semantics vector&lt;Parent&gt; valueVec; valueVec.push_back(Parent()); valueVec.push_back(Child()); // gets turned into a Parent object :( valueVec[0].write(); valueVec[1].write(); // Output: // // Parent: 1 // Parent: 2 } </code></pre> <p>My question is: Can I have have my cake (value semantics) and eat it too (polymorphic containers)? Or do I have to use pointers?</p>
[ { "answer_id": 41059, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 6, "selected": true, "text": "vector<shared_ptr<Parent>> vec;\nvec.push_back(shared_ptr<Parent>(new Child()));\n" }, { "answer_id": 41103, ...
2008/09/03
[ "https://Stackoverflow.com/questions/41045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2994/" ]
41,089
<p>I have a vb6 form with an ocx control on it. The ocx control has a button on it that I want to press from code. How do I do this?</p> <p>I have:</p> <pre><code>Dim b As CommandButton Set b = ocx.GetButton("btnPrint") SendMessage ocx.hwnd, WM_COMMAND, GetWindowLong(b.hwnd, GWL_ID), b.hwnd </code></pre> <p>but it doesn't seem to work.</p>
[ { "answer_id": 41521, "author": "DAC", "author_id": 1111, "author_profile": "https://Stackoverflow.com/users/1111", "pm_score": 3, "selected": true, "text": "Dim b As CommandButton\nSet b = ocx.GetButton(\"btnPrint\")\nb = True\n" }, { "answer_id": 41543, "author": "Mark Ingr...
2008/09/03
[ "https://Stackoverflow.com/questions/41089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4495/" ]
41,097
<p>The question sort of says it all.</p> <p>Whether it's for code testing purposes, or you're modeling a real-world process, or you're trying to impress a loved one, what are some algorithms that folks use to generate interesting time series data? Are there any good resources out there with a consolidated list? No constraints on values (except plus or minus infinity) or dimensions, but I'm looking for examples that people have found useful or exciting in practice. </p> <p>Bonus points for parsimonious and readable code samples. </p>
[ { "answer_id": 41521, "author": "DAC", "author_id": 1111, "author_profile": "https://Stackoverflow.com/users/1111", "pm_score": 3, "selected": true, "text": "Dim b As CommandButton\nSet b = ocx.GetButton(\"btnPrint\")\nb = True\n" }, { "answer_id": 41543, "author": "Mark Ingr...
2008/09/03
[ "https://Stackoverflow.com/questions/41097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4069/" ]
41,107
<p>I've been looking for a <em>simple</em> Java algorithm to generate a pseudo-random alpha-numeric string. In my situation it would be used as a unique session/key identifier that would "likely" be unique over <code>500K+</code> generation (my needs don't really require anything much more sophisticated). </p> <p>Ideally, I would be able to specify a length depending on my uniqueness needs. For example, a generated string of length 12 might look something like <code>"AEYGF7K0DM1X"</code>. </p>
[ { "answer_id": 41156, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 12, "selected": true, "text": "public class RandomString {\n\n /**\n * Generate a random string.\n */\n public String nextString() {\n ...
2008/09/03
[ "https://Stackoverflow.com/questions/41107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3803/" ]
41,134
<p>Here is the deal. </p> <p>$ gem --version</p> <blockquote> <p>1.1.0</p> </blockquote> <p>$ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config</p> <blockquote> <p>Bulk updating Gem source index for: <a href="http://gems.rubyforge.org/" rel="nofollow noreferrer">http://gems.rubyforge.org/</a> ERROR: could not find mysql locally or in a repository</p> </blockquote> <p>$ sudo gem update</p> <blockquote> <p>Updating installed gems Bulk updating Gem source index for: <a href="http://gems.rubyforge.org/" rel="nofollow noreferrer">http://gems.rubyforge.org/</a> </p> <p>Updating RedCloth ERROR: While executing gem ... (Gem::GemNotFoundException) could not find RedCloth locally or in a repository</p> </blockquote> <p>I've tried <a href="http://www.gregbenedict.com/2008/02/21/mysql-ruby-gem-install-issues-solved/" rel="nofollow noreferrer">this</a>, <a href="http://dev.mysql.com/downloads/ruby.html" rel="nofollow noreferrer">this</a>, <a href="http://installingcats.com/2007/12/13/mysql-ruby-gem-install-problem-on-mac-os-x-leopard/" rel="nofollow noreferrer">this</a>, <a href="http://www.docuverse.com/blog/donpark/2007/06/14/os-x-mysql-ruby-gem-install-problem" rel="nofollow noreferrer">this</a>, and a ton of others. </p> <p>None of them have worked for me. Is anyone else having this problem? If so what did you do to fix it that is not mentioned above? </p>
[ { "answer_id": 41160, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 2, "selected": false, "text": "gem update --system\n" }, { "answer_id": 223708, "author": "James A. Rosen", "author_id": 1190, "auth...
2008/09/03
[ "https://Stackoverflow.com/questions/41134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1797/" ]
41,155
<p>In the process of developing my first WCF service and when I try to use it I get "Method not Allowed" with no other explanation. </p> <p>I've got my interface set up with the ServiceContract and OperationContract:</p> <pre><code> [OperationContract] void FileUpload(UploadedFile file); </code></pre> <p>Along with the actual method:</p> <pre><code> public void FileUpload(UploadedFile file) {}; </code></pre> <p>To access the Service I enter <a href="http://localhost/project/myService.svc/FileUpload" rel="noreferrer">http://localhost/project/myService.svc/FileUpload</a> but I get the "Method not Allowed" error</p> <p>Am I missing something?</p>
[ { "answer_id": 41205, "author": "Jeremy McGee", "author_id": 3546, "author_profile": "https://Stackoverflow.com/users/3546", "pm_score": 2, "selected": false, "text": "byte" }, { "answer_id": 41301, "author": "Ubiguchi", "author_id": 2562, "author_profile": "https://S...
2008/09/03
[ "https://Stackoverflow.com/questions/41155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/831/" ]
41,159
<p>Given the following:</p> <pre><code>List&lt;List&lt;Option&gt;&gt; optionLists; </code></pre> <p>what would be a quick way to determine the subset of Option objects that appear in all N lists? Equality is determined through some string property such as option1.Value == option2.Value.</p> <p>So we should end up with <code>List&lt;Option&gt;</code> where each item appears only once.</p>
[ { "answer_id": 41175, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": true, "text": "var x = from list in optionLists\n from option in list\n where optionLists.All(l => l.Any(o => o.Value == op...
2008/09/03
[ "https://Stackoverflow.com/questions/41159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3615/" ]
41,179
<p>I have a number of users with multi-megabyte files that need to be processed before they can be uploaded. I am trying to find a way to do this without having to install any executable software on their machines. </p> <p>If every machine shipped with, say, Python it would be easy. I could have a Python script do everything. The only scripting language I can think of that's on every machine is JavaScript. However I know there are security restrictions that prevent reading and writing local files from web browsers. </p> <p>Is there any way to use this extremely pervasive scripting language for general purpose computing tasks?</p> <hr> <p>EDIT: To clarify the requirements, this needs to be a cross platform, cross browser solution. I believe that HTA is an Internet Explorer only technology (or that the Firefox equivalent is broken).</p>
[ { "answer_id": 51186981, "author": "Isaac", "author_id": 9816472, "author_profile": "https://Stackoverflow.com/users/9816472", "pm_score": 0, "selected": false, "text": "fs" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4262/" ]
41,198
<p>How can I get an image to stretch the height of a <code>DIV</code> class?</p> <p>Currently it looks like this:</p> <p><img src="https://i.stack.imgur.com/DcrXC.png" width="650" /></p> <p>However, I would like the <code>DIV</code> to be stretched so the <code>image</code> fits properly, but I do not want to resize the `image.</p> <p>Here is the CSS for the <code>DIV</code> (the grey box):</p> <pre class="lang-css prettyprint-override"><code>.product1 { width: 100%; padding: 5px; margin: 0px 0px 15px -5px; background: #ADA19A; color: #000000; min-height: 100px; } </code></pre> <p>The CSS being applied on the image:</p> <pre class="lang-css prettyprint-override"><code>.product{ display: inline; float: left; } </code></pre> <p>So, how can I fix this?</p>
[ { "answer_id": 41201, "author": "DevelopingChris", "author_id": 1220, "author_profile": "https://Stackoverflow.com/users/1220", "pm_score": 1, "selected": false, "text": "display:inline \nfloat:left \n" }, { "answer_id": 41203, "author": "John Millikin", "author_id": 35...
2008/09/03
[ "https://Stackoverflow.com/questions/41198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2592/" ]
41,204
<p>Is there a fast and clean way of returning a JSON hash back from any node in a Ruby on Rails' acts_as_nested_set without using recursion?</p> <p>Here's the recursive solution for reference:</p> <pre><code>class Node &lt; ActiveRecord::Base has_many :products def json_hash if children.size &gt; 0 children.collect { |node| { node.name =&gt; node.json_hash }.to_json else { node.name =&gt; node.products.find(:all).collect(&amp;:name) }.to_json end end end </code></pre>
[ { "answer_id": 41275, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 2, "selected": false, "text": "{ node.name => node.products.find(:all).collect(&:name) }.to_json\n" }, { "answer_id": 3587874, "author": "stand...
2008/09/03
[ "https://Stackoverflow.com/questions/41204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3499/" ]
41,207
<p>For debugging and testing I'm searching for a JavaScript shell with auto completion and if possible object introspection (like ipython). The online <a href="http://www.squarefree.com/shell/" rel="nofollow noreferrer">JavaScript Shell</a> is really nice, but I'm looking for something local, without the need for an browser.</p> <p>So far I have tested the standalone JavaScript interpreter rhino, spidermonkey and google V8. But neither of them has completion. At least Rhino with jline and spidermonkey have some kind of command history via key up/down, but nothing more.</p> <p>Any suggestions?</p> <p>This question was asked again <a href="https://stackoverflow.com/questions/260787/javascript-shell">here</a>. It might contain an answer that you are looking for.</p>
[ { "answer_id": 1812416, "author": "Cheeso", "author_id": 48082, "author_profile": "https://Stackoverflow.com/users/48082", "pm_score": 3, "selected": false, "text": "// shell.js\n// ------------------------------------------------------------------\n//\n// implements an interactive javas...
2008/09/03
[ "https://Stackoverflow.com/questions/41207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/720/" ]
41,218
<p>I am running MAMP locally on my laptop, and I like to test as much as I can locally. Unfortunately, since I work on e-commerce stuff (PHP), I normally force ssl in most of the checkout forms and it just fails on my laptop. Is there any easy configuration that I might be missing to allow "https" to run under MAMP? Please note, I know that I <strong>could</strong> configure Apache by hand, re-compile PHP, etc. but I'm just wondering if there's an easier way for a lazy programmer.</p> <p>Thanks</p>
[ { "answer_id": 41272, "author": "David Crow", "author_id": 2783, "author_profile": "https://Stackoverflow.com/users/2783", "pm_score": 2, "selected": false, "text": "/Applications/MAMP/bin/apache2/bin$ ./apachectl stop\n/Applications/MAMP/bin/apache2/bin$ sudo ./apachectl startssl\n" }...
2008/09/03
[ "https://Stackoverflow.com/questions/41218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4247/" ]
41,233
<p>I'm attracted to the neatness that a single file database provides. What driver/connector library is out there to connect and use SQLite with Java.</p> <p>I've discovered a wrapper library, <a href="http://www.ch-werner.de/javasqlite/" rel="noreferrer">http://www.ch-werner.de/javasqlite</a>, but are there other more prominent projects available?</p>
[ { "answer_id": 593137, "author": "Bernie Perez", "author_id": 1992, "author_profile": "https://Stackoverflow.com/users/1992", "pm_score": 8, "selected": false, "text": "java -cp .:sqlitejdbc-v056.jar Test" }, { "answer_id": 8797310, "author": "snail", "author_id": 1139901...
2008/09/03
[ "https://Stackoverflow.com/questions/41233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1915/" ]
41,239
<p>I am pretty sure that the settings that I am using are correct, so all possible things can be wrong which I should check out so that I can make authentication with our Active Directory work.</p>
[ { "answer_id": 41247, "author": "grom", "author_id": 486, "author_profile": "https://Stackoverflow.com/users/486", "pm_score": 1, "selected": false, "text": "<?php\n$ds = ldap_connect('host.ad.lan', 389);\nldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);\nldap_set_option($ds, LDAP_OPT...
2008/09/03
[ "https://Stackoverflow.com/questions/41239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380/" ]
41,244
<p>I found an example in the <a href="http://msdn2.microsoft.com/en-us/bb330936.aspx" rel="noreferrer">VS2008 Examples</a> for Dynamic LINQ that allows you to use a SQL-like string (e.g. <code>OrderBy(&quot;Name, Age DESC&quot;))</code> for ordering. Unfortunately, the method included only works on <code>IQueryable&lt;T&gt;</code>. Is there any way to get this functionality on <code>IEnumerable&lt;T&gt;</code>?</p>
[ { "answer_id": 41262, "author": "Kjetil Watnedal", "author_id": 4116, "author_profile": "https://Stackoverflow.com/users/4116", "pm_score": 6, "selected": false, "text": "IEnumerable<T> myEnumerables\nvar query=from enumerable in myenumerables\n where some criteria\n or...
2008/09/03
[ "https://Stackoverflow.com/questions/41244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1786/" ]
41,290
<p>I have a file which is an XML representation of some data that is taken from a Web service and cached locally within a Web Application. The idea being is that this data is <em>very</em> static, but just <em>might</em> change. So I have set it up to cache to a file, and stuck a monitor against it to check if it has been deleted. Once deleted, the file will be refreshed from its source and rebuilt.</p> <p>I am now running in to problems though, because obviously in a multi-threaded environment it falls over as it is trying to access the data when it is still reading/writing the file.</p> <p>This is confusing me, because I added a object to lock against, and this is always locked during read/write. It was my understanding that attempted access from other threads would be told to "wait" until the lock was released?</p> <p>Just to let you know, I am real new to multi-threaded development, so I am totally willing to accept this is a screw up on my part :)</p> <ul> <li><strong>Am I missing something?</strong></li> <li><strong>What is the best file access strategy in a multi-threaded environment?</strong> <hr></li> </ul> <h3>Edit</h3> <p>Sorry - I should have said this is using <strong>ASP.NET 2.0</strong> :)</p>
[ { "answer_id": 41559, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 4, "selected": true, "text": " /// <summary>\n /// Blocks until the file is not locked any more.\n /// </summary>\n /// <param name=\"fullP...
2008/09/03
[ "https://Stackoverflow.com/questions/41290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
41,300
<p>How do you run Emacs in Windows?</p> <p>What is the best flavor of Emacs to use in Windows, and where can I download it? And where is the .emacs file located?</p>
[ { "answer_id": 3679058, "author": "cristobalito", "author_id": 376700, "author_profile": "https://Stackoverflow.com/users/376700", "pm_score": 5, "selected": false, "text": "C-h v user-init-file\n" }, { "answer_id": 14307654, "author": "mkasberg", "author_id": 1263211, ...
2008/09/03
[ "https://Stackoverflow.com/questions/41300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/473/" ]
41,304
<p>I know in ASP.NET I can get an item from a DropDownList by using</p> <pre><code>DropDownList1.Items.FindByText </code></pre> <p>Is there a similar method I can use in WPF for a ComboBox?</p> <p>Here's the scenario.</p> <p>I have a table called RestrictionFormat that contains a column called RestrictionType, the type is a foreign key to a table that stores these values.</p> <p>In my editor application I'm writing, when the user selects the RestrictionFormat from a ComboBox (this works fine), I'm pulling up the details for editing. I'm using a second ComboBox to make sure the user only selects one RestrictionType when editing. I already have the second combobox bound property from the RestrictionType table, but I need to change the selected index on it to match the value specified in the record.</p> <hr> <p>Here's the scenario.</p> <p>I have a table called RestrictionFormat that contains a column called RestrictionType, the type is a foreign key to a table that stores these values.</p> <p>In my editor application I'm writing, when the user selects the RestrictionFormat from a ComboBox (this works fine), I'm pulling up the details for editing. I'm using a second ComboBox to make sure the user only selects one RestrictionType when editing. I already have the second combobox bound property from the RestrictionType table, but I need to change the selected index on it to match the value specified in the record.</p> <p>Does this make sense?</p>
[ { "answer_id": 41305, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 2, "selected": false, "text": " <ComboBox Name=\"combo\">\n <ComboBoxItem Name=\"item1\" >1</ComboBoxItem>\n <ComboBoxItem Name=\"item2\">2</Co...
2008/09/03
[ "https://Stackoverflow.com/questions/41304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71/" ]
41,319
<p>What's the "best" (taking both speed and readability into account) way to determine if a list is empty? Even if the list is of type <code>IEnumerable&lt;T&gt;</code> and doesn't have a Count property.</p> <p>Right now I'm tossing up between this:</p> <pre><code>if (myList.Count() == 0) { ... } </code></pre> <p>and this:</p> <pre><code>if (!myList.Any()) { ... } </code></pre> <p>My guess is that the second option is faster, since it'll come back with a result as soon as it sees the first item, whereas the second option (for an IEnumerable) will need to visit every item to return the count.</p> <p>That being said, does the second option look as readable to you? Which would you prefer? Or can you think of a better way to test for an empty list?</p> <p><strong>Edit</strong> @lassevk's response seems to be the most logical, coupled with a bit of runtime checking to use a cached count if possible, like this:</p> <pre><code>public static bool IsEmpty&lt;T&gt;(this IEnumerable&lt;T&gt; list) { if (list is ICollection&lt;T&gt;) return ((ICollection&lt;T&gt;)list).Count == 0; return !list.Any(); } </code></pre>
[ { "answer_id": 41324, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 8, "selected": true, "text": "public static Boolean IsEmpty<T>(this IEnumerable<T> source)\n{\n if (source == null)\n return true; // or th...
2008/09/03
[ "https://Stackoverflow.com/questions/41319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/615/" ]
41,330
<p>How do I detect if the system has a default recording device installed? I bet this can be done through some calls to the Win32 API, anyone has any experience with this?</p> <p>I'm talking about doing this through code, not by opening the control panel and taking a look under sound options.</p>
[ { "answer_id": 41385, "author": "Jeff Hillman", "author_id": 3950, "author_profile": "https://Stackoverflow.com/users/3950", "pm_score": 2, "selected": true, "text": "#include <tchar.h>\n#include <windows.h>\n#include \"mmsystem.h\"\n\nint _tmain( int argc, wchar_t *argv[] )\n{\n UINT...
2008/09/03
[ "https://Stackoverflow.com/questions/41330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1509946/" ]
41,355
<p>Has anybody got any kind of experience with dynamic programming using WCF. By dynamic programming I mean runtime consumption of WSDL's. I have found one blog entry/tool: <a href="http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx</a></p> <p>Has anybody here found good tools for this?</p>
[ { "answer_id": 169485, "author": "Cuyler", "author_id": 25041, "author_profile": "https://Stackoverflow.com/users/25041", "pm_score": 3, "selected": true, "text": "Execute()" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4189/" ]
41,397
<p>Right, I know I am totally going to look an idiot with this one, but my brain is just <em>not</em> kicking in to gear this morning.</p> <p>I want to have a method where I can say &quot;if it goes bad, come back with this type of Exception&quot;, right?</p> <p>For example, something like (<strong>and this doesn't work</strong>):</p> <pre><code> static ExType TestException&lt;ExType&gt;(string message) where ExType:Exception { Exception ex1 = new Exception(); ExType ex = new Exception(message); return ex; } </code></pre> <p>Now whats confusing me is that we <em>KNOW</em> that the generic type is going to be of an Exception type due to the <em>where</em> clause. However, the code fails because we cannot implicitly cast <em>Exception</em> to <em>ExType</em>. We cannot explicitly convert it either, such as:</p> <pre><code> static ExType TestException&lt;ExType&gt;(string message) where ExType:Exception { Exception ex1 = new Exception(); ExType ex = (ExType)(new Exception(message)); return ex; } </code></pre> <p>As that fails too.. So <strong>is this kind of thing possible?</strong> I have a strong feeling its going to be real simple, but I am having a tough day with the old noggin, so cut me some slack :P</p> <hr /> <h2>Update</h2> <p>Thanks for the responses guys, looks like it wasn't me being a <em>complete</em> idiot! ;)</p> <p>OK, so <a href="https://stackoverflow.com/questions/41397/asking-a-generic-method-to-throw-specific-exception-type-on-fail#41398">Vegard</a> and <a href="https://stackoverflow.com/questions/41397/asking-a-generic-method-to-throw-specific-exception-type-on-fail#41404">Sam</a> got me on to the point where I could instantiate the correct type, but then obviously got stuck because the <em>message</em> param is read-only following instantiation.</p> <p><a href="https://stackoverflow.com/questions/41397/asking-a-generic-method-to-throw-specific-exception-type-on-fail#41408">Matt</a> hit the nail right on the head with his response, I have tested this and all works fine. Here is the example code:</p> <pre><code> static ExType TestException&lt;ExType&gt;(string message) where ExType:Exception, new () { ExType ex = (ExType)Activator.CreateInstance(typeof(ExType), message); return ex; } </code></pre> <p>Sweet! :)</p> <p>Thanks guys!</p>
[ { "answer_id": 41402, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 0, "selected": false, "text": "static T TestException<Exception>(string message)\n{}\n" }, { "answer_id": 41404, "author": "samjudson", "au...
2008/09/03
[ "https://Stackoverflow.com/questions/41397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
41,400
<p>I am looking to do this in C/C++. I came across <a href="http://www.swig.org/Doc1.3/Varargs.html" rel="nofollow noreferrer"><strong>Variable Length Arguments</strong></a>, but this suggests a solution with Python and C using <a href="http://sourceware.org/libffi/" rel="nofollow noreferrer">libffi</a>.</p> <p>Now, if I want to wrap the <code>printf</code> function with <code>myprintf</code>.</p> <p>I do it like below:</p> <pre><code>void myprintf(char* fmt, ...) { va_list args; va_start(args, fmt); printf(fmt, args); va_end(args); } int _tmain(int argc, _TCHAR* argv[]) { int a = 9; int b = 10; char v = 'C'; myprintf(&quot;This is a number: %d and \nthis is a character: %c and \n another number: %d\n&quot;, a, v, b); return 0; } </code></pre> <p>But the results are not as expected!</p> <pre class="lang-none prettyprint-override"><code>This is a number: 1244780 and this is a character: h and another number: 29953463 </code></pre> <p>What did I miss?</p>
[ { "answer_id": 41414, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 1, "selected": false, "text": "void f(varargs va) {\n BOOST_FOREACH(varargs::iterator i, va)\n cout << *i << \" \";\n}\n\nf(args = 1, 2, 3,...
2008/09/03
[ "https://Stackoverflow.com/questions/41400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/123/" ]
41,406
<p>I'm trying to write a page that calls PHP that's stored in a MySQL database. The page that is stored in the MySQL database contains PHP (and HTML) code which I want to run on page load.</p> <p>How could I go about doing this?</p>
[ { "answer_id": 41440, "author": "Michał Niedźwiedzki", "author_id": 2169, "author_profile": "https://Stackoverflow.com/users/2169", "pm_score": 3, "selected": false, "text": "eval()" }, { "answer_id": 1472666, "author": "Community", "author_id": -1, "author_profile": ...
2008/09/03
[ "https://Stackoverflow.com/questions/41406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3654/" ]
41,407
<p>I'm currently working on a parser for our internal log files (generated by log4php, log4net and log4j). So far I have a nice regular expression to parse the logs, except for one annoying bit: Some log messages span multiple lines, which I can't get to match properly. The regex I have now is this:</p> <pre><code>(?&lt;date&gt;\d{2}/\d{2}/\d{2})\s(?&lt;time&gt;\d{2}):\d{2}:\d{2}),\d{3})\s(?&lt;message&gt;.+) </code></pre> <p>The log format (which I use for testing the parser) is this:</p> <pre><code>07/23/08 14:17:31,321 log message spanning multiple lines 07/23/08 14:17:31,321 log message on one line </code></pre> <p>When I run the parser right now, I get only the line the log starts on. If I change it to span multiple lines, I get only one result (the whole log file).</p> <hr> <p>@samjudson:</p> <p><em>You need to pass the RegexOptions.Singleline flag in to the regular expression, so that "." matches all characters, not just all characters except new lines (which is the default).</em></p> <p>I tried that, but then it matches the whole file. I also tried to set the message-group to .+? (non-greedy), but then it matches a single character (which isn't what I'm looking for either).</p> <p>The problem is that the pattern for the message matches on the date-group as well, so when it doesn't break on a new-line it just goes on and on and on.</p> <hr> <p>I use this regex for the message group now. It works, unless there's a pattern IN the log message which is the same as the start of the log message.</p> <pre><code>(?&lt;message&gt;(.(?!\d{2}/\d{2}/\d{2}\s\d{2}:\d{2}:\d{2},\d{3}\s\[\d{4}\]))+) </code></pre>
[ { "answer_id": 41412, "author": "samjudson", "author_id": 1908, "author_profile": "https://Stackoverflow.com/users/1908", "pm_score": 0, "selected": false, "text": "RegexOptions" }, { "answer_id": 41428, "author": "Jeff Hillman", "author_id": 3950, "author_profile": "...
2008/09/03
[ "https://Stackoverflow.com/questions/41407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/909/" ]
41,424
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/307291/how-does-the-google-did-you-mean-algorithm-work">How does the Google “Did you mean?” Algorithm work?</a> </p> </blockquote> <p>Suppose you have a search system already in your website. How can you implement the "Did you mean:<code>&lt;spell_checked_word&gt;</code>" like Google does in some <a href="http://www.google.com/search?hl=en&amp;q=spellling&amp;btnG=Search" rel="noreferrer">search queries</a>?</p>
[ { "answer_id": 302727, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": " string = \"my haert wil go on\"\n\n string.gsub(/[\\w\\']+/) do |word|\n if !speller.check(word)\n # word is wrong\...
2008/09/03
[ "https://Stackoverflow.com/questions/41424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644/" ]
41,449
<p>The exact error is as follows</p> <blockquote> <p>Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. An attempt was made to load a program with an incorrect format.</p> </blockquote> <p>I've recently started working on this project again after a two month move to another project. It worked perfectly before, and I've double checked all the references.</p>
[ { "answer_id": 2926982, "author": "bboyle1234", "author_id": 213256, "author_profile": "https://Stackoverflow.com/users/213256", "pm_score": 9, "selected": false, "text": "ChilkatDotNet2" }, { "answer_id": 4023955, "author": "Community", "author_id": -1, "author_profi...
2008/09/03
[ "https://Stackoverflow.com/questions/41449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2012/" ]
41,453
<p>I'd like to be able to introspect a C++ class for its name, contents (i.e. members and their types) etc. I'm talking native C++ here, not managed C++, which has reflection. I realise C++ supplies some limited information using RTTI. Which additional libraries (or other techniques) could supply this information?</p>
[ { "answer_id": 41865, "author": "KeithB", "author_id": 2298, "author_profile": "https://Stackoverflow.com/users/2298", "pm_score": 4, "selected": false, "text": "namespace {\n static bool b2 = Filter::Filterable<const MyObj>::Register(\"MyObject\");\n} \n\nbool MyObj::BuildMap()\n{\n F...
2008/09/03
[ "https://Stackoverflow.com/questions/41453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3233/" ]
41,469
<p>I am planning on creating a small website for my personal book collection. To automate the process a little bit, I would like to create the following functionality:</p> <p>The website will ask me for the ISBN number of the book and will then automatically fetch the title and add it to my database.</p> <p>Although I am mainly interested in doing this in php, I also have some Java implementation ideas for this. I believe it could also help if the answer was as much language-agnostic as possible.</p>
[ { "answer_id": 41473, "author": "Giovanni Galbo", "author_id": 4050, "author_profile": "https://Stackoverflow.com/users/4050", "pm_score": 3, "selected": false, "text": "- Cataloguing home book collections\n- Building and verifying bookstores' inventories\n- Empowering forums and online ...
2008/09/03
[ "https://Stackoverflow.com/questions/41469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644/" ]
41,479
<p>After discussion with colleagues regarding the use of the 'var' keyword in C# 3 I wondered what people's opinions were on the appropriate uses of type inference via var?</p> <p>For example I rather lazily used var in questionable circumstances, e.g.:-</p> <pre><code>foreach(var item in someList) { // ... } // Type of 'item' not clear. var something = someObject.SomeProperty; // Type of 'something' not clear. var something = someMethod(); // Type of 'something' not clear. </code></pre> <p>More legitimate uses of var are as follows:-</p> <pre><code>var l = new List&lt;string&gt;(); // Obvious what l will be. var s = new SomeClass(); // Obvious what s will be. </code></pre> <p>Interestingly LINQ seems to be a bit of a grey area, e.g.:-</p> <pre><code>var results = from r in dataContext.SomeTable select r; // Not *entirely clear* what results will be here. </code></pre> <p>It's clear what results will be in that it will be a type which implements IEnumerable, however it isn't entirely obvious in the same way a var declaring a new object is.</p> <p>It's even worse when it comes to LINQ to objects, e.g.:-</p> <pre><code>var results = from item in someList where item != 3 select item; </code></pre> <p>This is no better than the equivilent foreach(var item in someList) { // ... } equivilent.</p> <p>There is a real concern about type safety here - for example if we were to place the results of that query into an overloaded method that accepted IEnumerable&lt;int&gt; and IEnumerable&lt;double&gt; the caller might inadvertently pass in the wrong type.</p> <p><code>var</code> <em>does</em> maintain strong typing but the question is really whether it's dangerous for the type to not be immediately apparent on definition, something which is magnified when overloads mean compiler errors might not be issued when you unintentionally pass the wrong type to a method.</p>
[ { "answer_id": 41486, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 6, "selected": false, "text": "foreach (var c in list) { ... }\n" }, { "answer_id": 41487, "author": "Jon Limjap", "author_id": 372, ...
2008/09/03
[ "https://Stackoverflow.com/questions/41479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3394/" ]
41,492
<p>Is it possible to determine which property of an ActiveX control is the default property? For example, what is the default property of the VB6 control CommandButton and how would I found out any other controls default!</p> <p><strong>/EDIT:</strong> Without having source to the object itself</p>
[ { "answer_id": 41612, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 1, "selected": false, "text": "Attribute Value.VB_UserMemId = 0\n" }, { "answer_id": 54239, "author": "John T", "author_id": 5553, ...
2008/09/03
[ "https://Stackoverflow.com/questions/41492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1111/" ]
41,498
<p>We recently lost a database and I want to recover the data from de Production.log.</p> <p>Every request is logged like this:</p> <p>Processing ChamadosController#create (for XXX.XXX.XXX.40 at 2008-07-30 11:07:30) [POST] Session ID: 74c865cefa0fdd96b4e4422497b828f9 Parameters: {"commit"=>"Gravar", "action"=>"create", "funcionario"=>"6" ... (all other parameters go here).</p> <p>But some stuff to post on de database were in the session. In the request I have the Session ID, and I also have all the session files from the server.</p> <p>Is there anyway I can, from this Session ID, open de session file and get it's contents?</p>
[ { "answer_id": 7872075, "author": "parasew", "author_id": 298982, "author_profile": "https://Stackoverflow.com/users/298982", "pm_score": 2, "selected": false, "text": "file = File.open(\"location_of_your_production.log\", \"rb\")\ncontents = file.read\ncontents.scan(/(Started POST \\\"(...
2008/09/03
[ "https://Stackoverflow.com/questions/41498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4384/" ]
41,499
<p>In Java, static and transient fields are not serialized. However, I found out that initialization of static fields causes the generated serialVersionUID to be changed. For example, <code>static int MYINT = 3;</code> causes the serialVersionUID to change. In this example, it makes sense because different versions of the class would get different initial values. Why does any initialization change the serialVersionUID? For example, <code>static String MYSTRING = System.getProperty("foo");</code> also causes the serialVersionUID to change.</p> <p>To be specific, my question is why does initialization with a method cause the serialVersionUID to change. The problem I hit is that I added a new static field that was initialized with a system property value (getProperty). That change caused a serialization exception on a remote call.</p>
[ { "answer_id": 41515, "author": "Alfred B. Thordarson", "author_id": 3379, "author_profile": "https://Stackoverflow.com/users/3379", "pm_score": 0, "selected": false, "text": "serialVersionUID" }, { "answer_id": 41527, "author": "David G", "author_id": 3150, "author_p...
2008/09/03
[ "https://Stackoverflow.com/questions/41499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3150/" ]
41,513
<p>I am going to be using Subversion for source control on a new J2EE web application. What directory structure will you recommend for organizing code, tests and documentation?</p>
[ { "answer_id": 41524, "author": "Mendelt", "author_id": 3320, "author_profile": "https://Stackoverflow.com/users/3320", "pm_score": 4, "selected": false, "text": "/project\n /trunk\n /src\n /doc\n /...\n /branches\n /feature1\n /src\n ...
2008/09/03
[ "https://Stackoverflow.com/questions/41513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
41,525
<p>If not, what are the significant differences?</p> <hr> <p><strong>Edit:</strong> Daren Thomas asks:</p> <blockquote> <p>which ones?</p> <p>I use gvim on Windows and MacVim on the mac. Seem similar enough to be the same to me...</p> </blockquote> <p>By which ones, I'm guessing that you mean a specific implementation of vi and emacs for Windows. I'm not sure as I thought there were only one or two. I'm looking for the ones that are closest to the Unix counterparts.</p>
[ { "answer_id": 41529, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https://Stackoverflow.com/users/2260", "pm_score": 0, "selected": false, "text": "gvim" }, { "answer_id": 41545, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https...
2008/09/03
[ "https://Stackoverflow.com/questions/41525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
41,547
<p>I am working on a small intranet site for a small company, where user should be able to post. I have imagined a very simple authentication mechanism where people just enter their email address, and gets sent a unique login url, that sets a cookie that will always identify them for future requests.</p> <p>In my template setup, I have base.html, and the other pages extend this. I want to show logged in or register button in the base.html, but how can I ensure that the necessary variables are always a part of the context? It seems that each view just sets up the context as they like, and there is no global context population. Is there a way of doing this without including the user in each context creation?</p> <p>Or will I have to make my own custom shortcuts to setup the context properly?</p>
[ { "answer_id": 41555, "author": "David Webb", "author_id": 3171, "author_profile": "https://Stackoverflow.com/users/3171", "pm_score": 2, "selected": false, "text": "request.user" }, { "answer_id": 269249, "author": "zalun", "author_id": 23457, "author_profile": "http...
2008/09/03
[ "https://Stackoverflow.com/questions/41547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
41,561
<p>I'm trying to understand how namespaces work in XML. When I have an element like foo:bar, the attributes will often not have namespaces on them. But sometimes they will. Are the attribute in the namespace of the element, even when the default namespace has been declared? Looking over the xsd for xhtml it seems the attributes are part of the schema and should be in the namespace for xhtml, but they are never presented that way...</p>
[ { "answer_id": 43226, "author": "jelovirt", "author_id": 2679, "author_profile": "https://Stackoverflow.com/users/2679", "pm_score": 4, "selected": false, "text": "<bar xmlns:foo=\"http://www.foo.com/\"\n foo:baz=\"baz\"\n qux=\"qux\"/>\n<bar xmlns=\"http://www.foo.com/\" xmlns:foo...
2008/09/03
[ "https://Stackoverflow.com/questions/41561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4315/" ]
41,568
<p>this kind of follows on from another <a href="https://stackoverflow.com/questions/41290/file-access-strategy-in-a-multi-threaded-environment-web-app">question</a> of mine.</p> <p>Basically, once I have the code to access the file (will review the answers there in a minute) what would be the best way to <strong>test</strong> it?</p> <p>I am thinking of creating a method which just spawns lots of <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="noreferrer">BackgroundWorker</a>'s or something and tells them all load/save the file, and test with varying file/object sizes. Then, get a response back from the threads to see if it failed/succeeded/made the world implode etc.</p> <p>Can you guys offer any suggestions on the best way to approach this? As I said before, this is all kinda new to me :)</p> <h3>Edit</h3> <p>Following <a href="https://stackoverflow.com/questions/41568/whats-the-best-way-to-test-a-method-from-multiple-threads#41572">ajmastrean's</a> post:</p> <p>I am using a console app to test with Debug.Asserts :)</p> <hr /> <h2>Update</h2> <p>I originally rolled with using <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="noreferrer">BackgroundWorker</a> to deal with the threading (since I am used to that from Windows dev) I soon realised that when I was performing tests where multiple ops (threads) needed to complete before continuing, I realised it was going to be a bit of a hack to get it to do this.</p> <p>I then followed up on <a href="https://stackoverflow.com/questions/41568/whats-the-best-way-to-unit-test-from-multiple-threads#41589">ajmastrean</a>'s post and realised I should really be using the <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread(VS.80).aspx" rel="noreferrer">Thread</a> class for working with concurrent operations. I will now refactor using this method (albeit a different approach).</p>
[ { "answer_id": 41589, "author": "Anthony Mastrean", "author_id": 3619, "author_profile": "https://Stackoverflow.com/users/3619", "pm_score": 5, "selected": true, "text": "ThreadPool" }, { "answer_id": 41619, "author": "aku", "author_id": 1196, "author_profile": "https...
2008/09/03
[ "https://Stackoverflow.com/questions/41568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
41,590
<p>I come from a Java background, where packages are used, not namespaces. I'm used to putting classes that work together to form a complete object into packages, and then reusing them later from that package. But now I'm working in C++.</p> <p>How do you use namespaces in C++? Do you create a single namespace for the entire application, or do you create namespaces for the major components? If so, how do you create objects from classes in other namespaces?</p>
[ { "answer_id": 41598, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 8, "selected": true, "text": "namespace MyNamespace\n{\n class MyClass\n {\n };\n}\n" }, { "answer_id": 41620, "author": "Adam Hollidge", ...
2008/09/03
[ "https://Stackoverflow.com/questions/41590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1585/" ]
41,594
<p>I have a table in an access table which contains Product entries, one of the columns has a jpg image stored as an OLE Object. I am trying to import this table to MySQL but nothing seems to work. I have tried the MySQL migration tool but that has a known issue with Access and OLE Objects. (The issue being it doesnt work and leaves the fields blank) I also tried the suggestion on <a href="http://www.plus2net.com/sql_tutorial/access_to_mysql.php" rel="nofollow noreferrer">this site</a> and while the data is imported it seems as though the image is getting corrupted in the transfer. When i try to preview the image i just get a binary view, if i save it on disk as a jpg image and try to open it i get an error stating the image is corrupt.</p> <p>The images in Access are fine and can be previewed. Access is storing the data as an OLE Object and when i import it to MySql it is saved in a MediumBlob field.</p> <p>Has anyone had this issue before and how did they resolve it ?</p>
[ { "answer_id": 41985, "author": "SecretDeveloper", "author_id": 2720, "author_profile": "https://Stackoverflow.com/users/2720", "pm_score": 3, "selected": true, "text": " Private Function GetImageFromRow(ByRef row As DataRowView, ByVal columnName As String) As Bitmap\n Dim oImage A...
2008/09/03
[ "https://Stackoverflow.com/questions/41594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2720/" ]
41,630
<p>I would like to execute an OS command from my ruby script but I want to add an argument from a ruby variable.</p> <p>I know that's possible by using keyword <em>system</em> like that :</p> <pre><code>#!/usr/bin/env ruby directory = '/home/paulgreg/' system 'ls ' + directory </code></pre> <p>but is that possible by using the "backquotes or backticks syntax" ? (I mean by using that syntax : <code>ls</code>)</p>
[ { "answer_id": 41635, "author": "Jordi Bunster", "author_id": 4272, "author_profile": "https://Stackoverflow.com/users/4272", "pm_score": 4, "selected": true, "text": "ls" }, { "answer_id": 41892, "author": "Nick Brosnahan", "author_id": 528, "author_profile": "https:...
2008/09/03
[ "https://Stackoverflow.com/questions/41630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3122/" ]
41,638
<p>The current system that I am working on makes use of Castle Activerecord to provide ORM (Object Relational Mapping) between the Domain objects and the database. This is all well and good and at most times actually works well!</p> <p>The problem comes about with Castle Activerecords support for asynchronous execution, well, more specifically the SessionScope that manages the session that objects belong to. Long story short, bad stuff happens!</p> <p>We are therefore looking for a way to easily convert (think automagically) from the Domain objects (who know that a DB exists and care) to the DTO object (who know nothing about the DB and care not for sessions, mapping attributes or all thing ORM).</p> <p>Does anyone have suggestions on doing this. For the start I am looking for a basic One to One mapping of object. Domain object <strong>Person</strong> will be mapped to say <strong>PersonDTO</strong>. I do not want to do this manually since it is a waste.</p> <p>Obviously reflection comes to mind, but I am hoping with some of the better IT knowledge floating around this site that <em>"cooler"</em> will be suggested.</p> <p>Oh, I am working in C#, the ORM objects as said before a mapped with Castle ActiveRecord.</p> <hr> <h2>Example code:</h2> <p>By @ajmastrean's request I have <a href="http://www.fryhard.com/downloads/stackoverflow/ActiveRecordAsync.zip" rel="noreferrer">linked</a> to an example that I have (badly) mocked together. The example has a <strong>capture form</strong>, capture form <strong>controller</strong>, <strong>domain</strong> objects, activerecord <strong>repository</strong> and an <strong>async</strong> helper. It is slightly big (3MB) because I included the ActiveRecored dll's needed to get it running. You will need to create a database called <em>ActiveRecordAsync</em> on your local machine or just change the .config file.</p> <p>Basic details of example:</p> <p><strong>The Capture Form</strong></p> <p>The capture form has a reference to the contoller</p> <pre><code>private CompanyCaptureController MyController { get; set; } </code></pre> <p>On initialise of the form it calls MyController.Load() private void InitForm () { MyController = new CompanyCaptureController(this); MyController.Load(); } This will return back to a method called LoadComplete()</p> <pre><code>public void LoadCompleted (Company loadCompany) { _context.Post(delegate { CurrentItem = loadCompany; bindingSource.DataSource = CurrentItem; bindingSource.ResetCurrentItem(); //TOTO: This line will thow the exception since the session scope used to fetch loadCompany is now gone. grdEmployees.DataSource = loadCompany.Employees; }, null); } } </code></pre> <p>this is where the <em>"bad stuff"</em> occurs, since we are using the child list of Company that is set as Lazy load.</p> <p><strong>The Controller</strong></p> <p>The controller has a Load method that was called from the form, it then calls the Asyc helper to asynchronously call the LoadCompany method and then return to the Capture form's LoadComplete method.</p> <pre><code>public void Load () { new AsyncListLoad&lt;Company&gt;().BeginLoad(LoadCompany, Form.LoadCompleted); } </code></pre> <p>The LoadCompany() method simply makes use of the Repository to find a know company.</p> <pre><code>public Company LoadCompany() { return ActiveRecordRepository&lt;Company&gt;.Find(Setup.company.Identifier); } </code></pre> <p>The rest of the example is rather generic, it has two domain classes which inherit from a base class, a setup file to instert some data and the repository to provide the <strong>ActiveRecordMediator</strong> abilities.</p>
[ { "answer_id": 169708, "author": "ZeroBugBounce", "author_id": 11314, "author_profile": "https://Stackoverflow.com/users/11314", "pm_score": 3, "selected": false, "text": "public static T ChangeType<S, T>(this S source) where T : class, new()\n" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231/" ]
41,640
<p>I am in need of a way to mute a specific application in Vista.</p> <p>Example: Mute just Firefox, but not all of the other application. Much similar to muting a specific program from within the volume mixer in vista. </p> <p>If there is a program that will do this, i would appreciate that. Otherwise if there is a way to do this, I will write a small app(Preferrably something .net).</p> <p>EDIT: I want to automate this procedure, possibly key-map it.</p>
[ { "answer_id": 29990633, "author": "Devin", "author_id": 4854726, "author_profile": "https://Stackoverflow.com/users/4854726", "pm_score": 0, "selected": false, "text": "#NoEnv ;// Recommended for new scripts\n#Persistent ;// Recommended for new scripts\nSendMode Input ;// Recommended f...
2008/09/03
[ "https://Stackoverflow.com/questions/41640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4394/" ]
41,647
<p>When using the php include function the include is succesfully executed, but it is also outputting a char before the output of the include is outputted, the char is of hex value 3F and I have no idea where it is coming from, although it seems to happen with every include. </p> <p>At first I thbought it was file encoding, but this doesn't seem to be a problem. I have created a test case to demonstrate it: (<strong>link no longer working</strong>) <a href="http://driveefficiently.com/testinclude.php" rel="noreferrer">http://driveefficiently.com/testinclude.php</a> this file consists of only: </p> <pre><code>&lt;? include("include.inc"); ?&gt; </code></pre> <p>and include.inc consists of only: </p> <pre><code>&lt;? echo ("hello, world"); ?&gt; </code></pre> <p>and yet, the output is: <em>"?hello, world"</em> where the ? is a char with a random value. It is this value that I do not know the origins of and it is sometimes screwing up my sites a bit. </p> <p>Any ideas of where this could be coming from? At first I thought it might be something to do with file encoding, but I don't think its a problem.</p>
[ { "answer_id": 41655, "author": "Thomas Owens", "author_id": 572, "author_profile": "https://Stackoverflow.com/users/572", "pm_score": 0, "selected": false, "text": "hello, world" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1111/" ]
41,652
<p>We have got a custom <code>MembershipProvider</code> in <code>ASP.NET</code>. Now there are 2 possible scenario the user can be validated:</p> <ol> <li><p>User login via <code>login.aspx</code> page by entering his username/password. I have used <strong>Login control</strong> and linked it with the <code>MyMembershipProvider</code>. This is working perfectly fine.</p></li> <li><p>An authentication token is passed via some URL in query string form a different web sites. For this I have one overload in <code>MembershipProvider.Validate(string authenticationToken)</code>, which is actually validating the user. In this case we cannot use the <strong>Login control</strong>. Now how can I use the same <code>MembershipProvider</code> to validate the user without actually using the <strong>Login control</strong>? I tried to call <code>Validate</code> manually, but this is not signing the user in.</p></li> </ol> <p>Here is the code snippet I am using </p> <pre><code>if (!string.IsNullOrEmpty(Request.QueryString["authenticationToken"])) { string ticket = Request.QueryString["authenticationToken"]; MyMembershipProvider provider = Membership.Provider as MyMembershipProvider; if (provider != null) { if (provider.ValidateUser(ticket)) // Login Success else // Login Fail } } </code></pre>
[ { "answer_id": 42151, "author": "JasonS", "author_id": 1865, "author_profile": "https://Stackoverflow.com/users/1865", "pm_score": 2, "selected": false, "text": "FormsAuthenticationTicket" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191/" ]
41,659
<p>Is there any way in the Servlet API to access properties specified in web.xml (such as initialization parameters) from within a Bean or Factory class that is not associated at all with the web container?</p> <p>For example, I'm writing a Factory class, and I'd like to include some logic within the Factory to check a hierarchy of files and configuration locations to see which if any are available to determine which implementation class to instantiate - for example, </p> <ol> <li>a properties file in the classpath,</li> <li>a web.xml parameter, </li> <li>a system property, or </li> <li>some default logic if nothing else is available. </li> </ol> <p>I'd like to be able to do this without injecting any reference to <code>ServletConfig</code> or anything similiar to my Factory - the code should be able to run ok outside of a Servlet Container.</p> <p>This might sound a little bit uncommon, but I'd like for this component I'm working on to be able to be packaged with one of our webapps, and also be versatile enough to be packaged with some of our command-line tools without requiring a new properties file just for my component - so I was hoping to piggyback on top of other configuration files such as web.xml.</p> <p>If I recall correctly, .NET has something like <code>Request.GetCurrentRequest()</code> to get a reference to the currently executing <code>Request</code> - but since this is a Java app I'm looking for something simliar that could be used to gain access to <code>ServletConfig</code>.</p>
[ { "answer_id": 41814, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 4, "selected": true, "text": "public class FactoryInitialisingServletContextListener implements ServletContextListener {\n\n public void contextDestroyed...
2008/09/03
[ "https://Stackoverflow.com/questions/41659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
41,665
<p>Is there any way to convert a bmp image to jpg/png without losing the quality in C#? Using Image class we can convert bmp to jpg but the quality of output image is very poor. Can we gain the quality level as good as an image converted to jpg using photoshop with highest quality?</p>
[ { "answer_id": 41672, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": 0, "selected": false, "text": "Bitmap.InterpolationMode = InterpolationMode.HighQualityBicubic;\n" }, { "answer_id": 41684, "author": "aku", ...
2008/09/03
[ "https://Stackoverflow.com/questions/41665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191/" ]
41,674
<p>In Visual Studio you can create a template XML document from an existing schema. The new <a href="http://msdn.microsoft.com/en-us/library/cc716766.aspx" rel="noreferrer">XML Schema Explorer</a> in VS2008 SP1 takes this a stage further and can create a sample XML document complete with data. Is there a class library in .NET to do this automatically without having to use Visual Studio? I found the <a href="http://msdn.microsoft.com/en-us/library/aa302296.aspx" rel="noreferrer">XmlSampleGenerator</a> article on MSDN but it was written in 2004 so maybe there is something already included in .NET to do this now?</p>
[ { "answer_id": 245461, "author": "Andrew Theken", "author_id": 32238, "author_profile": "https://Stackoverflow.com/users/32238", "pm_score": 3, "selected": false, "text": "DataSet ds = new DataSet();\nds.ReadXmlSchema(\"c:/xsdfile.xsd\");\n\nforeach(DataTable t in ds.Tables)\n{\nvar row ...
2008/09/03
[ "https://Stackoverflow.com/questions/41674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3873/" ]
41,686
<p>I've got some Java code using a servlet and Apache Commons FileUpload to upload a file to a set directory. It's working fine for character data (e.g. text files) but image files are coming out garbled. I can open them but the image doesn't look like it should. Here's my code:</p> <p>Servlet</p> <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { String customerPath = "\\leetest\\"; // Check that we have a file upload request boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(); // Parse the request FileItemIterator iter = upload.getItemIterator(request); while (iter.hasNext()) { FileItemStream item = iter.next(); String name = item.getFieldName(); if (item.isFormField()) { // Form field. Ignore for now } else { BufferedInputStream stream = new BufferedInputStream(item .openStream()); if (stream == null) { LOGGER .error("Something went wrong with fetching the stream for field " + name); } byte[] bytes = StreamUtils.getBytes(stream); FileManager.createFile(customerPath, item.getName(), bytes); stream.close(); } } } } catch (Exception e) { throw new UploadException("An error occured during upload: " + e.getMessage()); } } </code></pre> <p>StreamUtils.getBytes(stream) looks like:</p> <pre><code>public static byte[] getBytes(InputStream src, int buffsize) throws IOException { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); byte[] buff = new byte[buffsize]; while (true) { int nBytesRead = src.read(buff); if (nBytesRead &lt; 0) { break; } byteStream.write(buff); } byte[] result = byteStream.toByteArray(); byteStream.close(); return result; } </code></pre> <p>And finally FileManager.createFile looks like:</p> <pre><code>public static void createFile(String customerPath, String filename, byte[] fileData) throws IOException { customerPath = getFullPath(customerPath + filename); File newFile = new File(customerPath); if (!newFile.getParentFile().exists()) { newFile.getParentFile().mkdirs(); } FileOutputStream outputStream = new FileOutputStream(newFile); outputStream.write(fileData); outputStream.close(); } </code></pre> <p>Can anyone spot what I'm doing wrong?</p> <p>Cheers, Lee</p>
[ { "answer_id": 41748, "author": "Ben", "author_id": 1417, "author_profile": "https://Stackoverflow.com/users/1417", "pm_score": 0, "selected": false, "text": "getBytes()" }, { "answer_id": 42202, "author": "Stu Thompson", "author_id": 2961, "author_profile": "https://...
2008/09/03
[ "https://Stackoverflow.com/questions/41686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1900/" ]
41,699
<p>So creating a Windows service using Visual Studio is fairly trivial. My question goes a bit deeper as to what actually makes an executable installable as a service &amp; how to write a service as a straight C application. I couldn't find a lot of references on this, but I'm presuming there has to be some interface I can implement so my .exe can be installed as a service.</p>
[ { "answer_id": 43161, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 2, "selected": false, "text": "SERVICE_TABLE_ENTRY ServiceStartTable[] =\n{\n { \"ServiceName\", ServiceMain },\n { 0, 0 }\n};\n\nif (!StartServiceCtr...
2008/09/03
[ "https://Stackoverflow.com/questions/41699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/634/" ]
41,701
<p>I have a method in my Python code that returns a tuple - a row from a SQL query. Let's say it has three fields: (jobId, label, username)</p> <p>For ease of passing it around between functions, I've been passing the entire tuple as a variable called 'job'. Eventually, however, I want to get at the bits, so I've been using code like this: (jobId, label, username) = job</p> <p>I've realised, however, that this is a maintenance nightmare, because now I can never add new fields to the result set without breaking all of my existing code. How should I have written this?</p> <p>Here are my two best guesses: (jobId, label, username) = (job[0], job[1], job[2]) ...but that doesn't scale nicely when you have 15...20 fields</p> <p>or to convert the results from the SQL query to a dictionary straight away and pass that around (I don't have control over the fact that it starts life as a tuple, that's fixed for me)</p>
[ { "answer_id": 41707, "author": "Chris Upchurch", "author_id": 2600, "author_profile": "https://Stackoverflow.com/users/2600", "pm_score": 5, "selected": true, "text": "job={}\njob['jobid'], job['label'], job['username']=<querycode>\n" }, { "answer_id": 41709, "author": "dF."...
2008/09/03
[ "https://Stackoverflow.com/questions/41701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4397/" ]
41,715
<p>Right now I'm working with an ASP.NET website that automatically generates images and stores them in a temporary folder. When working on my local system these go going into a temporary folder that gets picked up by Visual Source Safe which then wants to check them in. As such, I am wondering if there is a way to just exclude that particular folder from source control?</p> <p>I've done a bit of reading and found that there are ways to do this for <a href="http://forums.msdn.microsoft.com/en-US/vssourcecontrol/thread/6cc4aab0-e7bc-44e8-baa3-045c9cd82e9a/" rel="nofollow noreferrer">individual files</a>, but I haven't found anything yet about an entire folder.</p>
[ { "answer_id": 778985, "author": "Min", "author_id": 14461, "author_profile": "https://Stackoverflow.com/users/14461", "pm_score": 0, "selected": false, "text": "C:\\tempfiles" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1185/" ]
41,717
<p>Like many others on this site I am considering a move to ASP.NET MVC for future projects. Currently my sites are running the traditional ASP.NET 2.0 Web Forms, and it works OK for us, so my other option is just to stick with what I know and make the move to ASP.NET 3.5 with the integrated AJAX stuff.</p> <p>I'm wondering about how user controls work in ASP.NET MVC. We have tons of <code>.ASCX</code> controls, and a few composite controls. When I work with web designers it is very easy to get them to use ASCX controls effectively, even without any programming knowledge, so that's a definite plus. But then of course the downsides are the page life cycle, which can be maddening, and the fact that ASCX controls are hard to share between different projects. Composite controls are share-able, but basically a black box to a designer.</p> <p>What's the model in ASP.NET MVC? Is there a way to create controls that solves the problems we've dealt with using ASCX and composite controls? Allowing easy access for web designers without having to worry about code being broken is an important consideration.</p>
[ { "answer_id": 41722, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 4, "selected": true, "text": "<% Html.RenderPartial(\"~/Views/Shared/MyControl.ascx\", {data model object}) %>\n" }, { "answer_id": 5192101, "a...
2008/09/03
[ "https://Stackoverflow.com/questions/41717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1219/" ]
41,724
<p>I'm hearing more and more about domain specific languages being thrown about and how they change the way you treat business logic, and I've seen <a href="http://ayende.com/blog/tags/domain-specific-languages" rel="noreferrer">Ayende's blog posts</a> and things, but I've never really gotten exactly why I would take my business logic away from the methods and situations I'm using in my provider.</p> <p>If you've got some background using these things, any chance you could put it in real laymans terms:</p> <ul> <li>What exactly building DSLs means?</li> <li>What languages are you using?</li> <li>Where using a DSL makes sense?</li> <li>What is the benefit of using DSLs?</li> </ul>
[ { "answer_id": 41742, "author": "Staale", "author_id": 3355, "author_profile": "https://Stackoverflow.com/users/3355", "pm_score": 1, "selected": false, "text": "NewsDAO.writtenBy(\"someUser\").before(\"someDate\").updateStatus(\"Deleted\")\n" }, { "answer_id": 41743, "author...
2008/09/03
[ "https://Stackoverflow.com/questions/41724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3717/" ]
41,733
<p>Say I have an array of records which I want to sort based on one of the fields in the record. What's the best way to achieve this?</p> <pre><code>TExample = record SortOrder : integer; SomethingElse : string; end; var SomeVar : array of TExample; </code></pre>
[ { "answer_id": 41951, "author": "Barry Kelly", "author_id": 3712, "author_profile": "https://Stackoverflow.com/users/3712", "pm_score": 6, "selected": true, "text": "TList" }, { "answer_id": 49702, "author": "ddowns", "author_id": 5201, "author_profile": "https://Stac...
2008/09/03
[ "https://Stackoverflow.com/questions/41733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008/" ]
41,763
<p>What is the best way to calculate Age using Flex?</p>
[ { "answer_id": 41845, "author": "Richard Braxton", "author_id": 4393, "author_profile": "https://Stackoverflow.com/users/4393", "pm_score": 4, "selected": false, "text": "private function getYearsOld(dob:Date):uint { \n var now:Date = new Date(); \n var yearsOld:uint = Number(now...
2008/09/03
[ "https://Stackoverflow.com/questions/41763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4393/" ]
41,766
<p>I just saw a really cool WPF twitter client that I think is developed by the Herding Code podcast guys <a href="http://www.herdingcode.com/" rel="noreferrer">HerdingCode</a> called <a href="http://code.google.com/p/wittytwitter/" rel="noreferrer">Witty</a>. (or at least, I see a lot of those guys using this client). This project is currently posted up on Google Code.</p> <p>Many of the projects on Google Code use Subversion as the version control system (including Witty). Having never used Subversion, I'm not sure what to do to download the code. </p> <p>On the source page for this project (<a href="http://code.google.com/p/wittytwitter/source/checkout" rel="noreferrer">google code witty source</a>) it gives the following instruction:</p> <p><strong>Non-members may check out a read-only working copy anonymously over HTTP.</strong> <br> <strong><em>svn checkout <a href="http://wittytwitter.googlecode.com/svn/trunk/" rel="noreferrer">http://wittytwitter.googlecode.com/svn/trunk/</a> wittytwitter-read-only</em></strong> </p> <p>I'm confused as to where I am supposed to enter the above command so that I can download the code.</p> <p>I have installed SVN and Tortoise (which I know almost nothing about). </p> <p>Thanks for any help or simply pointing me in the right direction.</p> <p>...Ed (@emcpadden)</p>
[ { "answer_id": 41771, "author": "jodonnell", "author_id": 4223, "author_profile": "https://Stackoverflow.com/users/4223", "pm_score": 4, "selected": false, "text": "svn checkout http://wittytwitter.googlecode.com/svn/trunk\n" }, { "answer_id": 41774, "author": "Tim Howland", ...
2008/09/03
[ "https://Stackoverflow.com/questions/41766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2858/" ]
41,781
<p>I've worked with T-SQL for years but I've just moved to an organisation that is going to require writing some Oracle stuff, probably just simple CRUD operations at least until I find my feet. I'm not going to be migrating databases from one to the other simply interacting with existing Oracle databases from an Application Development perspective. Is there are tool or utility available to easily translate T-SQL into Oracle SQL, a keyword mapper is the sort of thing I'm looking for.</p> <p>P.S. I'm too lazy to RTFM, besides it's not going to be a big part of my role so I just want something to get me up to speed a little faster.</p>
[ { "answer_id": 54420302, "author": "Lukas Eder", "author_id": 521799, "author_profile": "https://Stackoverflow.com/users/521799", "pm_score": 0, "selected": false, "text": "$ java -cp jooq-3.11.9.jar org.jooq.ParserCLI -t ORACLE -s \"SELECT substring('abcde', 2, 3)\"\nselect substr('abcd...
2008/09/03
[ "https://Stackoverflow.com/questions/41781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4403/" ]
41,792
<p>I am re-factoring some code and am wondering about the use of a <code>lock</code> in the instance constructor.</p> <pre><code>public class MyClass { private static Int32 counter = 0; private Int32 myCount; public MyClass() { lock(this) { counter++; myCount = counter; } } } </code></pre> <p>Please confirm</p> <ol> <li>Instance constructors are thread-safe.</li> <li>The lock statement prevents access to that code block, not to the static 'counter' member.</li> </ol> <p>If the intent of the original programmer were to have each instance know its 'count', how would I synchronize access to the 'counter' member to ensure that another thread isn't new'ing a <code>MyClass</code> and changing the count before this one sets its count?</p> <p><em>FYI - This class is not a singleton. Instances must simply be aware of their number.</em></p>
[ { "answer_id": 41801, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 2, "selected": false, "text": "private static int counter = 0;\nprivate static object counterLock = new Object();\n\nlock(counterLock) {\n counter++;\n ...
2008/09/03
[ "https://Stackoverflow.com/questions/41792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3619/" ]
41,796
<p>I'm looking for a quality WinForms component that supports syntax highlighting, code folding and the like. The key criteria are:</p> <ol> <li>Stability </li> <li>Value (price)</li> <li>Ability to easily customize syntax to highlight</li> <li>Light weight</li> </ol>
[ { "answer_id": 16391867, "author": "Jeremy Thompson", "author_id": 495455, "author_profile": "https://Stackoverflow.com/users/495455", "pm_score": 2, "selected": false, "text": "public Form1()\n{\nInitializeComponent();\nICSharpCode.AvalonEdit.TextEditor te = new ICSharpCode.AvalonEdit.T...
2008/09/03
[ "https://Stackoverflow.com/questions/41796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4398/" ]
41,824
<p>I'm using Microsoft AjaxControlToolkit for modal popup window.</p> <p>And on a modal popup window, when a postback occurred, the window was closing. How do I prevent from the closing action of the modal popup?</p>
[ { "answer_id": 41910, "author": "Ricky Supit", "author_id": 4191, "author_profile": "https://Stackoverflow.com/users/4191", "pm_score": 3, "selected": false, "text": "Show()" }, { "answer_id": 42188, "author": "Jon Erickson", "author_id": 1950, "author_profile": "http...
2008/09/03
[ "https://Stackoverflow.com/questions/41824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4215/" ]
41,836
<p>I have tried both of :</p> <pre><code>ini_set('include_path', '.:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes'); </code></pre> <p>and also :</p> <pre><code>php_value include_path ".:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes" </code></pre> <p>in the .htaccess file.</p> <p>Both methods actually <strong>do work</strong> but only intermittently. That is, they will work fine for about 37 pages requests and then fail about 42 pages requests resulting in an require() call to cause a fatal error effectively crashing the site.</p> <p>I'm not even sure where to begin trying to find out what is going on!</p> <hr> <p>@<a href="https://stackoverflow.com/questions/41836/setting-include-path-in-php-intermittently-fails-why#41877">cnote</a></p> <blockquote> <p>Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.</p> </blockquote> <p>The in script version was originally </p> <pre><code>ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . 'lib' . PATH_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'classes'); </code></pre> <p>and thus the .:.: was coming from the existing path:</p> <pre><code>ini_get('include_path') </code></pre> <p>I tried removing it anyway and the problem persists.</p>
[ { "answer_id": 42336, "author": "Ian", "author_id": 4396, "author_profile": "https://Stackoverflow.com/users/4396", "pm_score": 2, "selected": false, "text": "PATH_SEPARATOR" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319/" ]
41,842
<p>When should I include PDB files for a production release? Should I use the <code>Optimize code</code> flag and how would that affect the information I get from an exception?</p> <p>If there is a noticeable performance benefit I would want to use the optimizations but if not I'd rather have accurate debugging info. What is typically done for a production app?</p>
[ { "answer_id": 96261, "author": "HTTP 410", "author_id": 13118, "author_profile": "https://Stackoverflow.com/users/13118", "pm_score": 4, "selected": false, "text": "[.NET Framework Debugging Control]\nGenerateTrackingInfo=0\nAllowOptimize=1\n" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3615/" ]
41,869
<p>If I run the following query in SQL Server 2000 Query Analyzer:</p> <pre><code>BULK INSERT OurTable FROM 'c:\OurTable.txt' WITH (CODEPAGE = 'RAW', DATAFILETYPE = 'char', FIELDTERMINATOR = '\t', ROWS_PER_BATCH = 10000, TABLOCK) </code></pre> <p>On a text file that conforms to OurTable's schema for 40 lines, but then changes format for the last 20 lines (lets say the last 20 lines have fewer fields), I receive an error. However, the first 40 lines are committed to the table. Is there something about the way I'm calling Bulk Insert that makes it not be transactional, or do I need to do something explicit to force it to rollback on failure?</p>
[ { "answer_id": 152695, "author": "Josef", "author_id": 5581, "author_profile": "https://Stackoverflow.com/users/5581", "pm_score": 6, "selected": true, "text": "BULK INSERT" }, { "answer_id": 9520696, "author": "Guillermo Garcia", "author_id": 247684, "author_profile"...
2008/09/03
[ "https://Stackoverflow.com/questions/41869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2831/" ]
41,881
<p>I am using the <code>ODBC</code> connector to access a MySQL db from Visual Studio 2008 and I'm facing performance problems when dealing with crystal reports and to solve this I need a native connector to visual studio. If someone has had a similar problem and knows a solution or tools (freeware preferable), I would be really grateful.</p>
[ { "answer_id": 2738330, "author": "Fabio", "author_id": 329018, "author_profile": "https://Stackoverflow.com/users/329018", "pm_score": 1, "selected": false, "text": "Mysql.Data.dll" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
41,894
<p>Is there a way to find the name of the program that is running in Java? The class of the main method would be good enough.</p>
[ { "answer_id": 41904, "author": "jodonnell", "author_id": 4223, "author_profile": "https://Stackoverflow.com/users/4223", "pm_score": 7, "selected": true, "text": " StackTraceElement[] stack = Thread.currentThread ().getStackTrace ();\n StackTraceElement main = stack[stack.length -...
2008/09/03
[ "https://Stackoverflow.com/questions/41894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/823/" ]
41,925
<p>What is a good data structure for storing phone numbers in database fields? I'm looking for something that is flexible enough to handle international numbers, and also something that allows the various parts of the number to be queried efficiently.</p> <p><strong>Edit:</strong> Just to clarify the use case here: I currently store numbers in a single varchar field, and I leave them just as the customer entered them. Then, when the number is needed by code, I normalize it. The problem is that if I want to query a few million rows to find matching phone numbers, it involves a function, like</p> <pre><code>where dbo.f_normalizenum(num1) = dbo.f_normalizenum(num2) </code></pre> <p>which is terribly inefficient. Also queries that are looking for things like the area code become extremely tricky when it's just a single varchar field.</p> <p><strong>[Edit]</strong></p> <p>People have made lots of good suggestions here, thanks! As an update, here is what I'm doing now: I still store numbers exactly as they were entered, in a varchar field, but instead of normalizing things at query time, I have a trigger that does all that work as records are inserted or updated. So I have ints or bigints for any parts that I need to query, and those fields are indexed to make queries run faster.</p>
[ { "answer_id": 41982, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 7, "selected": true, "text": "vanity" }, { "answer_id": 42028, "author": "jcoby", "author_id": 2884, "author_profile": "https://Stack...
2008/09/03
[ "https://Stackoverflow.com/questions/41925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1219/" ]
41,928
<p>I have just received and bypassed a problem with LightWindow and IE7 where, on page load, it throws a JavaScript error on line 444 of <code>lightwindow.js</code>, claiming that the <code>object does not support this property or method</code>. Despite finding various postings on various forums, no Google result I could find had a solution, so I am posting this here in the hopes that it will help someone / myself later.</p> <p>Many suggested a specific order of the script files but I was already using this order (prototype, scriptaculous, lightwindow).</p> <p>These are the steps I took that seemed to finally work, I write them here only as a record as I do not know nor have time to test which ones specifically "fixed" the issue:</p> <ol> <li>Moved the call to lightwindow.js to the bottom of the page.</li> <li>Changed line 444 to: <code>if (this._getGalleryInfo(link.rel)) {</code></li> <li>Changed line 1157 to: <code>if (this._getGalleryInfo(this.element.rel)) {</code></li> <li>Finally, I enclosed (and this is dirty, my apologies) lines 1417 to 1474 with a <code>try/catch</code> block, swallowing the exception.</li> </ol> <p><strong>EDIT:</strong> </p> <p>I realised that this broke Firefox. Adding the following as line 445 now makes it work - <code>try { gallery = this._getGalleryInfo(link.rel); } catch (e) { }</code></p> <p>It's not a very nice fix, but my page (which contains a lightwindow link with no "rel" tag, several lightwindow links which do have "rel" tags, and one "inline" link) works just fine in IE7 now. Please comment if you have anything to add about this issue or problems with / improvements to my given solution.</p>
[ { "answer_id": 47224, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 1, "selected": false, "text": "if( this && this._getGalleryInfo )\n{\n //use the function\n\n}\n" }, { "answer_id": 595214, "author": "Com...
2008/09/03
[ "https://Stackoverflow.com/questions/41928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
41,934
<p>When I do a file search on eclipse it includes the <code>.svn</code> directories by default. I tried excluding them from the build path but they still appear on file search results.</p>
[ { "answer_id": 41959, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 3, "selected": false, "text": ".svn" }, { "answer_id": 354675, "author": "Community", "author_id": -1, "author_profile": "https://Stac...
2008/09/03
[ "https://Stackoverflow.com/questions/41934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/823/" ]
41,937
<p>I need to convert latitude/longitude coordinates into Easting/Northing coordinates in the Alberta 10 TM Projection.</p> <p>The 10 TM projection is similar to UTM, but it is a custom projection for the province of Alberta, Canada. I think (with some effort) I could code it myself but would rather not reinvent the wheel if it's been done already.</p>
[ { "answer_id": 1143731, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "MapWindow" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1958/" ]
41,948
<p>I'm creating an application which lets you define events with a time frame. I want to automatically fill in the end date when the user selects or changes the start date. I can't quite figure out, however, how to get the difference between the two times, and then how to create a new end Date using that difference.</p>
[ { "answer_id": 41960, "author": "Vincent Robert", "author_id": 268, "author_profile": "https://Stackoverflow.com/users/268", "pm_score": 7, "selected": true, "text": "getTime()" }, { "answer_id": 41966, "author": "Aaron", "author_id": 2628, "author_profile": "https://...
2008/09/03
[ "https://Stackoverflow.com/questions/41948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2688/" ]
41,969
<p>I want to open a folder window, in the appropriate file manager, from within a cross-platform (windows/mac/linux) Python application.</p> <p>On OSX, I can open a window in the finder with</p> <pre><code>os.system('open "%s"' % foldername) </code></pre> <p>and on Windows with</p> <pre><code>os.startfile(foldername) </code></pre> <p>What about unix/linux? Is there a standard way to do this or do I have to special case gnome/kde/etc and manually run the appropriate application (nautilus/konqueror/etc)?</p> <p>This looks like something that could be specified by the <a href="http://freedesktop.org" rel="noreferrer">freedesktop.org</a> folks (a python module, similar to <code>webbrowser</code>, would also be nice!).</p>
[ { "answer_id": 42046, "author": "pixelbeat", "author_id": 4421, "author_profile": "https://Stackoverflow.com/users/4421", "pm_score": 5, "selected": true, "text": "os.system('xdg-open \"%s\"' % foldername)\n" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/41969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3002/" ]
42,017
<p>I am looking for simple straightforward solution for accessing EXIF information of jpeg images in .Net. Does anybody has experience with this?</p>
[ { "answer_id": 2707506, "author": "Rowland Shaw", "author_id": 50447, "author_profile": "https://Stackoverflow.com/users/50447", "pm_score": 3, "selected": false, "text": "BitmapSource" }, { "answer_id": 31329551, "author": "Drew Noakes", "author_id": 24874, "author_p...
2008/09/03
[ "https://Stackoverflow.com/questions/42017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2361/" ]
42,034
<p>I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type would be useful in practice. Can I have some examples, perhaps in Python, where an immutable set of numbers would be needed? How is this different from a list?</p>
[ { "answer_id": 42052, "author": "sphereinabox", "author_id": 2775, "author_profile": "https://Stackoverflow.com/users/2775", "pm_score": 4, "selected": false, "text": "a = {}\na[(1,2,\"bob\")] = \"hello!\"\na[(\"Hello\",\"en-US\")] = \"Hi There!\"\n" }, { "answer_id": 39638334, ...
2008/09/03
[ "https://Stackoverflow.com/questions/42034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/577/" ]
42,068
<p>I've generated some JSON and I'm trying to pull it into an object in JavaScript. I keep getting errors. Here's what I have:</p> <pre><code>var data = '{"count" : 1, "stack" : "sometext\n\n"}'; var dataObj = eval('('+data+')'); </code></pre> <p>This gives me an error: </p> <pre><code>unterminated string literal </code></pre> <p>With <code>JSON.parse(data)</code>, I see similar error messages: "<code>Unexpected token ↵</code>" in Chrome, and "<code>unterminated string literal</code>" in Firefox and IE.</p> <p>When I take out the <code>\n</code> after <code>sometext</code> the error goes away in both cases. I can't seem to figure out why the <code>\n</code> makes <code>eval</code> and <code>JSON.parse</code> fail. </p>
[ { "answer_id": 42073, "author": "BlaM", "author_id": 999, "author_profile": "https://Stackoverflow.com/users/999", "pm_score": 10, "selected": true, "text": "var data = '{\"count\" : 1, \"stack\" : \"sometext\\\\n\\\\n\"}';\n" }, { "answer_id": 1111538, "author": "Ron", "...
2008/09/03
[ "https://Stackoverflow.com/questions/42068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3636/" ]
42,070
<p>What's going on here?</p> <p>printf.sh:</p> <pre><code>#! /bin/sh NAME="George W. Bush" printf "Hello, %s\n" $NAME </code></pre> <p>Command line session:</p> <pre><code>$ ./printf.sh Hello, George Hello, W. Hello, Bush </code></pre> <p>UPDATE: <code>printf "Hello, %s\n" "$NAME"</code> works. For why I'm not using <code>echo</code>, consider</p> <p>echo.sh:</p> <pre><code>#! /bin/sh FILE="C:\tmp" echo "Filename: $FILE" </code></pre> <p>Command-line:</p> <pre><code>$ ./echo.sh Filename: C: mp </code></pre> <p>The <a href="http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html" rel="noreferrer">POSIX spec for <code>echo</code></a> says, "New applications are encouraged to use <code>printf</code> instead of <code>echo</code>" (for this and other reasons). </p>
[ { "answer_id": 42089, "author": "Tanj", "author_id": 4275, "author_profile": "https://Stackoverflow.com/users/4275", "pm_score": 1, "selected": false, "text": "NAME=\"George W. Bush\"\necho \"Hello, \"$NAME\n" }, { "answer_id": 42092, "author": "ColinYounger", "author_id"...
2008/09/03
[ "https://Stackoverflow.com/questions/42070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
42,076
<p><strong>What mechanisms do you know that prevent your site from being abused by anonymous spammers.</strong></p> <p>For example, let's say that I have a site where people can vote something. But I <em>don't</em> want someone to spam something all the way to the top. So I found (a) creating an account and only allowed to vote once and (b) CAPTCHA to decrease spam. What other methods do you know and how good do they work?</p>
[ { "answer_id": 895737, "author": "DisgruntledGoat", "author_id": 37947, "author_profile": "https://Stackoverflow.com/users/37947", "pm_score": 2, "selected": false, "text": "style=\"display:none\"" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/42076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644/" ]
42,102
<p>I have a Singleton/Factory object that I'd like to write a JUnit test for. The Factory method decides which implementing class to instantiate based upon a classname in a properties file on the classpath. If no properties file is found, or the properties file does not contain the classname key, then the class will instantiate a default implementing class.</p> <p>Since the factory keeps a static instance of the Singleton to use once it has been instantiated, to be able to test the "failover" logic in the Factory method I would need to run each test method in a different classloader. </p> <p>Is there any way with JUnit (or with another unit testing package) to do this?</p> <p>edit: here is some of the Factory code that is in use:</p> <pre><code>private static MyClass myClassImpl = instantiateMyClass(); private static MyClass instantiateMyClass() { MyClass newMyClass = null; String className = null; try { Properties props = getProperties(); className = props.getProperty(PROPERTY_CLASSNAME_KEY); if (className == null) { log.warn("instantiateMyClass: Property [" + PROPERTY_CLASSNAME_KEY + "] not found in properties, using default MyClass class [" + DEFAULT_CLASSNAME + "]"); className = DEFAULT_CLASSNAME; } Class MyClassClass = Class.forName(className); Object MyClassObj = MyClassClass.newInstance(); if (MyClassObj instanceof MyClass) { newMyClass = (MyClass) MyClassObj; } } catch (...) { ... } return newMyClass; } private static Properties getProperties() throws IOException { Properties props = new Properties(); InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(PROPERTIES_FILENAME); if (stream != null) { props.load(stream); } else { log.error("getProperties: could not load properties file [" + PROPERTIES_FILENAME + "] from classpath, file not found"); } return props; } </code></pre>
[ { "answer_id": 42130, "author": "Cem Catikkas", "author_id": 3087, "author_profile": "https://Stackoverflow.com/users/3087", "pm_score": 2, "selected": false, "text": "myClassImpl" }, { "answer_id": 9192126, "author": "AutomatedMike", "author_id": 352035, "author_prof...
2008/09/03
[ "https://Stackoverflow.com/questions/42102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
42,115
<p>I am running into an issue I had before; can't find my reference on how to solve it.</p> <p>Here is the issue. We encrypt the connection strings section in the app.config for our client application using code below:</p> <pre><code> config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) If config.ConnectionStrings.SectionInformation.IsProtected = False Then config.ConnectionStrings.SectionInformation.ProtectSection(Nothing) ' We must save the changes to the configuration file.' config.Save(ConfigurationSaveMode.Modified, True) End If </code></pre> <p>The issue is we had a salesperson leave. The old laptop is going to a new salesperson and under the new user's login, when it tries to to do this we get an error. The error is:</p> <pre><code>Unhandled Exception: System.Configuration.ConfigurationErrorsException: An error occurred executing the configuration section handler for connectionStrings. ---&gt; System.Configuration.ConfigurationErrorsException: Failed to encrypt the section 'connectionStrings' using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: Object already exists. ---&gt; System.Security.Cryptography.CryptographicException: Object already exists </code></pre>
[ { "answer_id": 373205, "author": "MikeScott8", "author_id": 1889, "author_profile": "https://Stackoverflow.com/users/1889", "pm_score": 2, "selected": true, "text": "aspnet_regiis -pa \"NetFrameworkConfigurationKey\" \"{domain}\\{user}\"\n" }, { "answer_id": 2702297, "author"...
2008/09/03
[ "https://Stackoverflow.com/questions/42115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1889/" ]
42,125
<p>I have a library I created,</p> <h3>File <em>mylib.c:</em></h3> <pre><code>#include &lt;mylib.h&gt; int testlib() { printf(&quot;Hello, World!\n&quot;); return (0); } </code></pre> <h3>File <em>mylib.h:</em></h3> <pre><code>#include &lt;stdio.h&gt; extern int testlib(); </code></pre> <p>In my program, I've attempted to call this library function:</p> <h3>File <em>myprogram.c</em>:</h3> <pre><code>#include &lt;mylib.h&gt; int main (int argc, char *argv[]) { testlib(); return (0); } </code></pre> <p>When I attempt to compile this program I get the following error:</p> <pre>In file included from myprogram.c:1 mylib.h:2 warning: function declaration isn't a prototype</pre> <p>I'm using: <code>gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)</code></p> <p>What is the proper way to declare a function prototype?</p>
[ { "answer_id": 42133, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 5, "selected": false, "text": "extern int testlib(void);\n" }, { "answer_id": 47693, "author": "Pramod", "author_id": 1386292, "a...
2008/09/03
[ "https://Stackoverflow.com/questions/42125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3807/" ]
42,126
<p>I am getting C++ Compiler error C2371 when I include a header file that itself includes odbcss.h. My project is set to MBCS.</p> <blockquote> <p>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\odbcss.h(430) : error C2371: 'WCHAR' : redefinition; different basic types 1><br> C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winnt.h(289) : see declaration of 'WCHAR'</p> </blockquote> <p>I don't see any defines in odbcss.h that I could set to avoid this. Has anyone else seen this? </p>
[ { "answer_id": 42207, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 0, "selected": false, "text": "#define WIN16" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/42126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114/" ]
42,146
<p>This is an adapted version of a question from someone in my office. She's trying to determine how to tell what ports MSDE is running on for an application we have in the field.</p> <p>Answers to that narrower question would be greatly appreciated. I'm also interested in a broader answer that could be applied to any networked applications.</p>
[ { "answer_id": 42152, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 4, "selected": false, "text": "netstat -b\n" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/42146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3475/" ]
42,150
<p>.NET Framework: 2.0 Preferred Language: C#</p> <p>I am new to TDD (Test Driven Development).</p> <p>First of all, is it even possible to unit test Windows Service?</p> <p>Windows service class is derived from ServiceBase, which has overridable methods, </p> <ol> <li>OnStart </li> <li>OnStop</li> </ol> <p>How can I trigger those methods to be called as if unit test is an actual service that calls those methods in proper order?</p> <p>At this point, am I even doing a Unit testing? or an Integration test?</p> <p>I have looked at WCF service question but it didn't make any sense to me since I have never dealt with WCF service.</p>
[ { "answer_id": 42155, "author": "David Basarab", "author_id": 2469, "author_profile": "https://Stackoverflow.com/users/2469", "pm_score": 3, "selected": false, "text": "public static void StartService(string serviceName, int timeoutMilliseconds)\n{\n ServiceController service = new Serv...
2008/09/03
[ "https://Stackoverflow.com/questions/42150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4035/" ]
42,153
<p>I searched for this subject on Google and got some website about an experts exchange...so I figured I should just ask here instead.</p> <p>How do you embed a <code>JApplet</code> in HTML on a webpage?</p>
[ { "answer_id": 42163, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 4, "selected": true, "text": "<applet code=\"TumbleItem.class\" \n codebase=\"examples/\"\n archive=\"tumbleClasses.jar, tumbleImages.jar\"\n...
2008/09/03
[ "https://Stackoverflow.com/questions/42153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
42,169
<p>I converted my company's calendar to XSL and changed all the tables to divs. It worked pretty well, but I had a lot of 8 day week bugs to work out initially owing to precarious cross-browser spacing issues. But I was reading another post regarding when to use tables v. divs and the consensus seemed to be that you should only use divs for true divisions between parts of the webpage, and only use tables for tabular data. </p> <p>I'm not sure I could even have used tables with XSL but I wanted to follow up that discussion of Divs and Tables with a discussion of the ideal way to make a web calendars and maybe a union of the two. </p>
[ { "answer_id": 42183, "author": "automatic", "author_id": 3854, "author_profile": "https://Stackoverflow.com/users/3854", "pm_score": 1, "selected": false, "text": "<table>" } ]
2008/09/03
[ "https://Stackoverflow.com/questions/42169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1765/" ]
42,182
<p>I'm trying to write a blog post which includes a code segment inside a <code>&lt;pre&gt;</code> tag. The code segment includes a generic type and uses <code>&lt;&gt;</code> to define that type. This is what the segment looks like:</p> <pre><code>&lt;pre&gt; PrimeCalc calc = new PrimeCalc(); Func&lt;int, int&gt; del = calc.GetNextPrime; &lt;/pre&gt; </code></pre> <p>The resulting HTML removes the <code>&lt;&gt;</code> and ends up like this:</p> <pre><code>PrimeCalc calc = new PrimeCalc(); Func del = calc.GetNextPrime; </code></pre> <p>How do I escape the <code>&lt;&gt;</code> so they show up in the HTML?</p>
[ { "answer_id": 42191, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 3, "selected": false, "text": "&lt; and &gt;\n" }, { "answer_id": 42192, "author": "ckpwong", "author_id": 2551, "author_profile": "http...
2008/09/03
[ "https://Stackoverflow.com/questions/42182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373/" ]