instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm seeing strange errors when my C++ code has min() or max() calls. I'm using Visual C++ compilers.</p>
<p>Check if your code is including the <strong>windows.h</strong> header file and either your code or other third-party headers have their own <strong>min()</strong>/<strong>max()</strong> definitions. If yes, then prepend your <strong>windows.h</strong> inclusion with a definition of <strong>NOMINMAX</strong> like thi...
<p>Honestly, when it comes to min/max, I find it best to just define my own:</p> <pre><code>#define min(a,b) ((a) &lt; (b) ? (a) : (b)) #define max(a,b) ((a) &gt;= (b) ? (a) : (b)) </code></pre>
3,499
<p>I assumed there were only bug fixes/(no new types) in .NET 2.0 SP1 until I came across <a href="http://davesbox.com/archive/2008/08/25/new-for-visual-studio-2008-sp1-and-fxcop-1-36-multi-targeting-rule.aspx" rel="nofollow noreferrer">few</a> posts which were mentioning <a href="http://msdn.microsoft.com/en-us/librar...
<p>Here's what you're looking for:</p> <p><img src="https://i.stack.imgur.com/abAMI.gif" alt="alt text"></p> <p>Full Article: <a href="http://www.hanselman.com/blog/CatchingRedBitsDifferencesInNET20AndNET20SP1.aspx" rel="nofollow noreferrer">http://www.hanselman.com/blog/CatchingRedBitsDifferencesInNET20AndNET20SP1.a...
<p>DateTimeOffset was added to 2.0 SP1 - I'm not aware of any other new types.</p> <p>Given the coincidental timing, it's perhaps worth reminding people that 2.0 SP1 shipped with 3.5 RTM (i.e November 2007) and 2.0 SP2 shipped with 3.5 SP1.</p>
6,256
<p>Cura does not seem let the full print area to be used. My printer is a <a href="https://www.lulzbot.com/store/printers/lulzbot-mini" rel="noreferrer">Lulzbot Mini</a>. The design illustrated below can be found <a href="https://www.tinkercad.com/things/hBE6Aj2EJMo-skyrail-marble-coster-banked-curve-beta" rel="norefer...
<p>Cura is likely factoring in your skirt. Change the skirt lines to 0 and you might be able to print (<code>Expert</code> -&gt; <code>Switch to full settings</code>, then click the options button next to &quot;platform adhesion type.&quot;). Cura also seems to have an in-built build size offset of about 2 mm. I can't ...
<p>If you set skirt setting to 'none', it will get you up to full bed area -1 mm at the edges, so, for example, 198x198 instead of 200x200.</p> <p>You need to go to 'Travel' and set 'Travel avoid distance' to zero to get the full 200x200, or whatever, bed area.</p>
203
<p>The other day I decided to write an implementation of <a href="http://en.wikipedia.org/wiki/Radix_sort" rel="nofollow noreferrer">radix sort</a> in Java. Radix sort is supposed to be O(k*N) but mine ended up being O(k^2*N) because of the process of breaking down each digit to one number. I broke down each digit by m...
<p>As a hint, try using a radix other than 10, since computers handle binary arithmetic better than decimal. </p> <ul> <li>x >>> n is equivalent to x / 2<sup>n</sup></li> <li>x &amp; (2<sup>n</sup> - 1) is equivalent to x % 2<sup>n</sup></li> </ul> <p>By the way, Java's >> performs sign extension, which is probably n...
<p><a href="http://en.literateprograms.org/Radix_sort_(Java)" rel="nofollow noreferrer">Radix_sort_(Java)</a></p> <p>The line of code that does this;</p> <pre><code>int key = (a[p] &amp; mask) &gt;&gt; rshift; </code></pre> <p>is the bit manipulation part.</p> <p><code>&amp;</code> is the operator to do a bitwise A...
42,960
<p>With the rise of multicore CPUs on the desktop, multithreading skills will become a valuable asset for programmers. Can you recommend some good resources (books, tutorials, websites, etc.) for a programmer who is looking to learn about threaded programming?</p>
<p>Take a look at Herb Sutter's "<a href="http://www.gotw.ca/publications/concurrency-ddj.htm" rel="noreferrer">The Free Lunch Is Over</a>" and then his series of articles on <a href="http://herbsutter.wordpress.com/2008/07/31/effective-concurrency-the-many-faces-of-deadlock/" rel="noreferrer">Effective Concurrency</a>...
<p>If you work with C#, the book "C# 2008 and 2005 threaded programming", by Gaston C. Hillar - Packt Publishing - <a href="http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book" rel="nofollow noreferrer">http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-pr...
2,457
<p>Suppose I have the following code:</p> <pre><code>while(TRUE) { pthread_t *thread = (pthread_t *) malloc(sizeof(pthread_t)); pthread_create(thread, NULL, someFunction, someArgument); pthread_detach(*thread); sleep(10); } </code></pre> <p>Will the detached thread free the memory allocated by malloc, or is t...
<p>No. <strong>pthread_create()</strong> has no way of knowing that the <strong>thread</strong> pointer passed to it was dynamically allocated. pthreads doesn't use this value internally; it simply returns the new thread id to the caller. You don't need to dynamically allocate that value; you can pass the address of a ...
<p>You need to free the memory yourself. It would be preferable to simply allocate the pthread_t variable on the stack as opposed to the heap.</p>
16,407
<p>I understand that these methods are for pickling/unpickling and have no relation to the reduce built-in function, but what's the difference between the 2 and why do we need both?</p>
<p><a href="https://docs.python.org/3/library/pickle.html#object.__reduce__" rel="nofollow noreferrer">The docs</a> say that</p> <blockquote> <p>If provided, at pickling time <code>__reduce__()</code> will be called with no arguments, and it must return either a string or a tuple.</p> </blockquote> <p>On the other hand...
<p><code>__reduce_ex__</code> is what <code>__reduce__</code> should have been but never became. <code>__reduce_ex__</code> works like <code>__reduce__</code> but the pickle protocol is passed.</p>
18,109
<p>Just starting to explore the 'wonders' of regex. Being someone who learns from trial and error, I'm really struggling because my trials are throwing up a disproportionate amount of errors... My experiments are in PHP using ereg().</p> <p>Anyway. I work with first and last names separately but for now using the s...
<ul> <li>Hyphenated Names (Worthington-Smythe)</li> </ul> <p>Add a - into the second character class. The easiest way to do that is to add it at the start so that it can't possibly be interpreted as a range modifier (as in <code>a-z</code>).</p> <pre>^[A-Z][-a-zA-Z]+$</pre> <ul> <li>Names with Apostophies (D'Angelo)...
<p>Give up. Every rule you can think of has exceptions in some culture or other. Even if that "culture" is geeks who like legally change their names to "37eet".</p>
34,678
<p>I have the following <code>textarea</code> in a <code>table</code>:</p> <pre><code>&lt;table width="300"&gt;&lt;tr&gt;&lt;td&gt; &lt;textarea style="width:100%"&gt; longstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstring &lt;/textarea&gt; ...
<p>Apply the width to the <code>td</code>, not the <code>table</code>.</p> <p>EDIT: @Emmett - the width could just as easily be applied via CSS.</p> <pre class="lang-css prettyprint-override"><code>td { width: 300px; } </code></pre> <p>produces the desired result. Or, if you're using jQuery, you could add the wi...
<p>did you try...</p> <p><code>overflow: hidden;</code></p> <p>??</p> <p>I'm not sure if it should be in the table of the textarea... experiment a bit</p>
5,406
<p>You often see, on sites like <a href="http://en.wikipedia.org/wiki/The_Daily_WTF" rel="nofollow noreferrer">The Daily WTF</a>, examples of overengineered code that should have just been a call to a built-in method within the .NET framework.</p> <p>What namespaces/classes should be considered essential knowledge for...
<pre><code>System; System.Collections; System.Collections.Generic; </code></pre>
<p>System.Data, particularly Datatable, </p>
23,549
<p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE_(Python)" rel="noreferrer">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. Bu...
<p>There's a file called <code>idle.py</code> in your Python installation directory in <code>Lib\idlelib\idle.py</code>.</p> <p>If you run that file with Python, then IDLE should start.</p> <blockquote> <p>c:\Python25\pythonw.exe c:\Python25\Lib\idlelib\idle.py</p> </blockquote>
<p>I got a shortcut for Idle (Python GUI). </p> <ul> <li>Click on Window icon at the bottom left or use Window Key (only Python 2), you will see Idle (Python GUI) icon</li> <li>Right click on the icon then more</li> <li>Open File Location</li> <li>A new window will appears, and you will see the shortcut of Idle (Pytho...
14,395
<p>I have VS2008 with .NET 3.5 SP1 (vs has SP1 too of course). I have loaded the latest silverlight tools.. and it went through and un-installed any beta stuff..</p> <p>No errors installing, and everything else in SP1 seems ok. In fact silverlight itself (i.e. when you select the silverlight project). </p> <p>Just...
<p>The visual studio 2008 silverlight desing surface is a read only view. You will need expression blend to do that.</p>
<p>You can drag controls from the toolbox into XAML view, but the designer view is display only in Visual Studio 2008.</p> <p>If you want a designer you need to try Expression Blend. You can download a 60 day trial of Blend here - <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=5FF08106-B9F4-43CD-AB...
34,094
<p>I am looking for suggestions on how to find the sizes (in bits) and range of floating point numbers in an architecture independent manner. The code could be built on various platforms (AIX, Linux, HPUX, VMS, maybe Windoze) using different flags - so results should vary. The sign, I've only seen as one bit, but how...
<p>Since you're looking at building for a number of systems, I think you may be looking at using GCC for compilation.</p> <p>Some good info on floating point - this is what almost all modern architectures use: <a href="http://en.wikipedia.org/wiki/IEEE_754" rel="noreferrer">http://en.wikipedia.org/wiki/IEEE_754</a></p...
<p>The number of bits used to store each field in a floating point number doesn't change.</p> <pre><code> Sign Exponent Fraction Bias Single Precision 1 [31] 8 [30-23] 23 [22-00] 127 Double Precision 1 [63] 11 [62-52] 52 [51-00] 1023 </code></pre> ...
32,055
<p>I have an Apache 2 installation on Debian with mod_ssl installed. The server private key is protected by a passphase that needs to be entered on start-up. The error and access logs are subject to logrotate on a weekly basis. I find that Apache crashes with a passphrase-related error shortly after logrotate runs.<...
<p>One option is to use Apache's provided log rotation tool. Its configured a bit differently than the system logrotate, but as it works with pipes, can move files around without an Apache restart.</p>
<p>One option is to use Apache's provided log rotation tool. Its configured a bit differently than the system logrotate, but as it works with pipes, can move files around without an Apache restart.</p>
10,334
<p>Is SSL secure enough for using sensitive data (like password) in query string? Is there any extra options to implement?</p>
<p>SSL provides <strong>secure, transport-level security</strong>. Nobody between client and server should be able to read the information.</p> <p><strong>But</strong> you should <strong>change your mind about writing sensitive data in the querystring</strong>. It will show up in the browser's history and is visible i...
<p>you should never send anything critically sensitive using query strings!</p>
23,157
<p>I am having troubles migrating from OC4J 10.1.2.3 to 10.1.3.1.4. The problem is for applications that have multiple EJBs (all are 2.1, no EJB 3.0). Jdeveloper will take the default ejb-jar.xml (the one required for Jdeveloper to run it on its stand-alone OC4J instance) and package it into each EJB JAR module NO MAT...
<p>You should check the Oracle documentation to see which is your case. The Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide is a good start According to the Oracle® Containers for J2EE Services Guide, chapter 2: Using JNDI when you use the form "ejb/EJBName" you perform "local" lookup. If you want t...
<p>You should check the Oracle documentation to see which is your case. The Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide is a good start According to the Oracle® Containers for J2EE Services Guide, chapter 2: Using JNDI when you use the form "ejb/EJBName" you perform "local" lookup. If you want t...
17,132
<p>I would like to do the equivalent off <a href="http://www.bigdumbdev.com/2007/08/build-better-skimmer-part-2.html" rel="nofollow noreferrer">this</a> (ruby code) in python for a Django project I am working on. I want to make a <a href="http://designvigilante.com/files/photoSkim/filmStrip.jpg" rel="nofollow noreferre...
<p>Do you mnean something like this? <a href="http://code.activestate.com/recipes/412982/" rel="nofollow noreferrer">Use PIL to make a "contact sheet" of images</a>?</p> <p>Perhaps there are others here that are closer to what you want: <a href="http://code.activestate.com/recipes/tags/graphics/" rel="nofollow norefe...
<p>Do you mnean something like this? <a href="http://code.activestate.com/recipes/412982/" rel="nofollow noreferrer">Use PIL to make a "contact sheet" of images</a>?</p> <p>Perhaps there are others here that are closer to what you want: <a href="http://code.activestate.com/recipes/tags/graphics/" rel="nofollow norefe...
43,419
<p>In a previous job we had a classic ASP application that no one wanted to migrate to ASP.NET. The things that it did, it did very well. </p> <p>However there was some new functionality that needed to be added that just seemed best suited to ASP.NET. The decision was made to allow the system to become a weird hybr...
<p>Can you not persist session data to a serverside data store? ie XML file, database etc. You could then pass just a hash (calculated based on some criteria that securely identifies the session) to a .NET page which can the pick the data up from the data store using this identifier and populate your session data. It s...
<p>Well, ultimately the best idea would probably to have converted the ASP app to .NET. I think that probably goes without saying though. If security is a big concern there are steps you can take as far as encryption and maintaining the integrity of the session information, to make it more secure, such as some symmet...
16,121
<p>Is it at the state where it is actually useful and can do more than rename classes?</p>
<p>CDT (C/C++ Development Tools - eclipse project) 5.0 has a bunch of new refactorings</p> <pre><code>* Declare Method * Extract Baseclass * Extract Constant * Extract Method * Extract Subclass * Hide Method * Implement Method * Move Field / Method * Replace Number * Separate Class * Generate Getters and Setters </cod...
<p>Yeah and most of them don't work actually if the code is too complicated. Things like move a method, rename, etc have problems sometimes.</p>
15,899
<p>I have a web user control that contains several other (web user) controls and subscribes to events the children raise.</p> <p>I saw someone somewhere in a similar situation providing Dispose() on the containing control and unregistering the events it had subscribed to. </p> <p>Isn't it all going to be blown away ...
<p>Since the contained controls (event publishers) will no longer be referenced by anything when the containing control itself is no longer referenced, they should be garbage collected. When that happens the containing control can also be garbage collected. Since these objects are all in the same generation, I don't ...
<p>I don't think this is a necessary step.</p>
27,658
<p>SQL Server 2000 Standard, Windows 2003<br> My coworker removed 'BUILTIN\Administrators' group from SQL Server which results in 'SQL Server Agent' not working. All my TSQLs to synchronize databases stopped working. <br> <br> I have Administrator rights on the server and my database user is in sysadmin role. <br> <br>...
<p>You don't want to re-add 'BUILTIN\Administrators' as it is a SQL Server 2000 security flaw. All domain administrators will have full sysadmin rights to your SQL Server to drop databases etc.</p> <p>Find the account that is running SQL Agent (Right click SQL Server agent in enterprise manager and select properties)....
<p>Using Enterprise Manager, can't you just go into Logins and add "Administrators" as a Windows Login to the server? Then add the login to the sysadmin role?</p> <p>If you can't use "Administrators", try "MACHINENAME\Administrators" (obviously substituting MACHINENAME for the actual name).</p> <p>Sorry I don't have...
16,717
<p>I am running two different sites on two different servers with two different domains. One site is running Joomla, the other Moodle. I have configured the Moodle server to base its authentication on the users table on the Joomla site, so we have an authoritative source of user information.</p> <p>What I'd like to do...
<p>You can do the following for a Secure single-sign-one solution :</p> <ul> <li>Generate a random (with PRNG) token based for Joomla user (store this )</li> <li>Send this token internally (via a web service etc., -keep it over HTTPS-, or local data source) to Moodle </li> <li>While sending this token also you should ...
<p>If you're using Joomla! 1.5, don't forget user plugins. Take a look at plugins/user/example.php. You can capture the password during the onLoginUser event which may help you bridge the systems.</p>
45,820
<p>I'm aware that Python 3 fixes a lot of UTF issues, I am not however able to use Python 3, I am using 2.5.1</p> <p>I'm trying to regex a document but the document has UTF hyphens in it – rather than -. Python can't match these and if I put them in the regex it throws a wobbly.</p> <p>How can I force Python to use a...
<p>You have to escape the character in question (–) and put a u in front of the string literal to make it a unicode string. </p> <p>So, for example, this:</p> <pre><code>re.compile("–") </code></pre> <p>becomes this:</p> <pre><code>re.compile(u"\u2013") </code></pre>
<p>Don't use UTF-8 in a regular expression. UTF-8 is a multibyte encoding where some unicode code points are encoded by 2 or more bytes. You may match parts of your string that you didn't plan to match. Instead use unicode strings as suggested.</p>
48,637
<p>Is it possible to overload the null-coalescing operator for a class in C#? </p> <p>Say for example I want to return a default value if an instance is null and return the instance if it's not. The code would look like something like this:</p> <pre><code> return instance ?? new MyClass("Default"); </code></pre>...
<p>Good question! It's not listed one way or another in the <a href="http://msdn.microsoft.com/en-us/library/8edha89s.aspx" rel="noreferrer">list of overloadable and non-overloadable operators</a> and nothing's mentioned on <a href="http://msdn.microsoft.com/en-us/library/ms173224.aspx" rel="noreferrer">the operator's...
<p>If anyone is here looking for a solution, the closest example would be to do this</p> <pre><code>return instance.MyValue != null ? instance : new MyClass("Default"); </code></pre>
45,422
<p>If I want to create the registry key</p> <blockquote> <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MyApp</p> </blockquote> <p>with the string value</p> <blockquote> <p>EventMessageFile : C:\Path\To\File.dll</p> </blockquote> <p>how do I define this in my <a href="http://en.wik...
<p>You seem to want to create an event log source. If that is the case, you should take a look at the <a href="http://wix.sourceforge.net/manual-wix3/util_xsd_eventsource.htm" rel="nofollow noreferrer">&lt;EventSource&gt;</a> element in the util extension.</p>
<p>Use the following under DirectoryRef --> Directory... </p> &lt;Component Id="RegisterAddReferencesTab32" Guid="D9D01248-8F19-45FC-B807-093CD6765A60"&gt;</p>&nbsp; &lt;RegistryValue Action="write" Id="RegInstallDir32" Key="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MyApp" Root="HKLM" T...
15,385
<p>I have a (HIC) version of the Prusa i3. I have recently installed the E3D v6 hotend and titan extruder. After fixing some other issues, I noticed that there is no filament being extruded. In addition, the gear looked like it was going in the wrong direction. How can I fix this?</p>
<p>You can either flip the connector for the motor around (i.e. plug it in backwards) or (if you are using Marlin firmware) look for the following line in configuration.h: (using the Arduino editor open the Marlin file For your 3D Printer, one of the tabs is labelled "configuration.h" click on that tab to bring it to...
<p>Reverse the plug for the motor on the board. Or do firmware. Doesn't matter. *** assuming you have ramps and a standard stepper.. </p>
320
<p>In .NET, after this code, what mechanism stops the <code>Thread</code> object from being garbage collected?</p> <pre><code>new Thread(Foo).Start(); GC.Collect(); </code></pre> <p>Yes, it's safe to assume <strong>something</strong> has a reference to the thread, I was just wandering what exactly. For some reason Re...
<p>The runtime keeps a reference to the thread as long as it is running. The GC wont collect it as long as anyone still keeps that reference.</p>
<p>Assign the new Thread to a local field?</p> <pre><code>class YourClass { Thread thread; void Start() { thread = new Thread(Foo); thread.Start(); GC.Collect(); } } </code></pre> <p>Garbage Collection collects everyting that is not references, so in your code there is no field/variable referenci...
10,748
<p>I have an existing htaccess that works fine:</p> <pre><code>RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule (.*) /default.php DirectoryIndex index.php /default.php </code></pre> <p>I wish to modify this so that all urls that start with /test/ go to /test/default....
<p>Put the rule for /test/ in before the rule for everything else, but give it an <code>[L]</code> flag to stop the rewrite rule processing there if it matches.</p>
<p>Try this</p> <pre><code>RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule (/test/)?(.*) $1/default.php DirectoryIndex index.php /default.php </code></pre>
42,957
<p>Starting recently, some of my new web pages (XHTML 1.1) are setup to do a regex of the request header <code>Accept</code> and send the right HTTP response headers if the user agent accepts XML (Firefox and Safari do).</p> <p>IE (or any other browser that doesn't accept it) will just get the plain <code>text/html</c...
<p>I use content negotiation to switch between <code>application/xhtml+xml</code> and <code>text/html</code> just like you describe, without noticing any problems with search bots. Strictly though, you should take into account the q values in the accept header that indicates the preference of the user agent to each con...
<p>Since IE doesn't support xhtml as application/xhtml+xml, the only way to get cross browser support is to use content negotiation. According to <a href="http://www.webdevout.net/articles/beware-of-xhtml#content_negotiation" rel="nofollow noreferrer">Web Devout</a>, content negotiation is hard due to the misuse of wil...
45,748
<p>Here's the code. Not much to it.</p> <pre><code>&lt;?php include(&quot;Spreadsheet/Excel/Writer.php&quot;); $xls = new Spreadsheet_Excel_Writer(); $sheet = $xls-&gt;addWorksheet('At a Glance'); $colNames = array('Foo', 'Bar'); $sheet-&gt;writeRow(0, 0, $colNames, $colHeadingFormat); for($i=1; $i&lt;=10; $i++) ...
<p>The code in the question has a bug which causes the error.</p> <p>This line writes a bunch of column names to row 0</p> <pre><code>$sheet-&gt;writeRow(0, 0, $colNames, $colHeadingFormat); </code></pre> <p>Then we have the loop which is supposed to write out the value rows.</p> <pre><code>for($i=1; $i&lt;=10; $i+...
<p>I got this error when writing to column 0 (A0) with PHPExcel. Excel is 1-indexed (A1), that's why it said "data may have been lost".</p> <pre><code>$this-&gt;m_excel-&gt;getActiveSheet()-&gt;SetCellValue($chr[$col].$row, $data)); </code></pre> <p><code>$row</code> was initialized to 0</p>
30,255
<p>What would be a clever way to make a 'please wait' control for a Flex application for long running operations like calling a webservice.</p> <p>I am not asking about the graphical portion of it - just the 'controller' part. How should I trigger it and hide it. I am planning to make just a simple canvas with text in...
<p>One way I have done it in the past is to have a global integer and increment / decrement the value based on the web services running. When the counter was 0, I would hide the loading text, when it was greater than 0, I would display the loading text. Here is a simplified version of it:</p> <pre> <code> &lt;mx:Appli...
<p>If you are using a framework like Cairngorm or similar that implements MVC, the straightforward approach is to update a "global" variable (via a Singleton object) thats bound to UI Component's (ie. titleWindow under main mxml or whatever) visible attribute. the variable will be updated to true during execute() and f...
38,538
<p>I have always been for documenting code, but when it comes to AJAX + PHP, it's not always easy: the code is really spread out! Logic, data, presentation - you name it - are split and mixed between server-side and client-side code. Sometimes there's also database-side code (stored procedures, views, etc) doing part o...
<p>I think it's best to take a hierarchical approach. </p> <p>For api-level documentation like on the function and class level, write inline documentation in the code and generate html documentation out of them using the many documentation tools out there (<a href="http://jsdoc.sourceforge.net/" rel="nofollow noreferr...
<p>For projects with a lot of javascript, I use a build system (makefiles) with a <a href="http://www.crockford.com/javascript/jsmin.html" rel="nofollow noreferrer" title="JSMin">javascript minimizer</a>. As the jsmin author notes, stripping comments "encourages a more expressive programming style because it eliminates...
20,681
<p>I really love WeakReference's. But I wish there was a way to tell the CLR how much (say, on a scale of 1 to 5) how weak you consider the reference to be. That would be brilliant.</p> <p>Java has SoftReference, WeakReference and I believe also a third type called a "phantom reference". That's 3 levels right there wh...
<p>I believe the fundamental reason that NET does not have soft references is because it can rely on an operating system with virtual memory. A Java process must specify its maximum OS memory (e.g. with <code>-Xmx128M</code>), and it <em>never</em> takes more OS memory than that. Whereas a NET process keeps taking OS...
<p>Looking for the 'trackResurrection' option passed to the constructor perhaps?</p> <p>The GC class also offers some assistance.</p>
42,037
<p>Does anyone have any experience with the triangulated GPS used by the non-3G iPhone? How does it compare with 3G positioning? Does the iPhone 3G use triangulation in the event that there is no GPS signal available? Is there anyway to determine the accuracy of the non 3G coordinates? Thanks. </p>
<p>I have done a lot of mobile software with a bunch of different devices including 3G iphones and 3G blackberry's and here is what I have found.</p> <p>The blackberry and iPhone GPS is really good when you have clear line of sight and at least 9 satellites present. In some dense residential or urban areas you might ...
<p>I have done a lot of mobile software with a bunch of different devices including 3G iphones and 3G blackberry's and here is what I have found.</p> <p>The blackberry and iPhone GPS is really good when you have clear line of sight and at least 9 satellites present. In some dense residential or urban areas you might ...
40,310
<p>I'm a new user of Matlab, can you please help:<br> I have the following code in an .M file:</p> <pre><code>function f = divrat(w, C) S=sqrt(diag(diag(C))); s=diag(S); f=sqrt(w'*C*w)/(w'*s); </code></pre> <p>I have stored this file (divrat.M) in the normal Matlab path, and therefore I'm assuming that Matlab will re...
<p>You get this error when the function isn't on the MATLAB path or in pwd.</p> <p>First, make sure that you are able to find the function using:</p> <pre><code>&gt;&gt; which divrat c:\work\divrat\divrat.m </code></pre> <p>If it returns:</p> <pre><code>&gt;&gt; which divrat 'divrat' not found. </code></pre> <p>It...
<p>I am pretty sure that the reason why this problem happened is because of the license of the toolbox (package) in which this function belongs in. Write <code>which divrat</code> and see what will be the result. If it returns path of the function and the comment <code>Has no license available</code>, then the problem ...
24,024
<p>I tried looking for the .emacs file for my Windows installation for Emacs, but I could not find it. Does it have the same filename under Windows as in Unix?</p> <p>Do I have to create it myself? If so, under what specific directory does it go?</p>
<p>Copy and pasted from the Emacs FAQ, <a href="http://www.gnu.org/software/emacs/windows/" rel="noreferrer">http://www.gnu.org/software/emacs/windows/</a>:</p> <h3><a href="http://www.gnu.org/software/emacs/manual/html_node/efaq-w32/Location-of-init-file.html#Location-of-init-file" rel="noreferrer">Where do I put my ...
<p>There is a list of directories based on your Windows version and extra information: <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Windows-HOME.html" rel="nofollow">http://www.gnu.org/software/emacs/manual/html_node/emacs/Windows-HOME.html</a></p>
22,984
<p>Consider the following code:</p> <pre><code>abstract class SomeClassX&lt;T&gt; { // blah } class SomeClassY: SomeClassX&lt;int&gt; { // blah } class SomeClassZ: SomeClassX&lt;long&gt; { // blah } </code></pre> <p>I want a collection of SomeClassX&lt;T&gt;'s, however, this isn't possible since SomeClassX&lt...
<p>Divide the number by 2.5, round up to the nearest integer, then multiply the result by 2.5.</p> <p>You're close.</p> <pre><code>Function RoundToIncrement(ByVal orignialNumber As Decimal, ByVal increment As Decimal) As Decimal Return Math.Ceiling( orignialNumber / increment ) * increment End Function </code></p...
<pre><code> /* This will round up (Math.Ceiling) or down (Math.Floor) based on the midpoint of the increment. The other examples use Math.Ceiling and therefore always round up. Assume the increment is 2.5 in this example and the number is 6.13 */ ...
28,134
<p>I have a list of bean objects passed into my JSP page, and one of them is a comment field. This field may contain newlines, and I want to replace them with semicolons using JSTL, so that the field can be displayed in a text input. I have found one solution, but it's not very elegant. I'll post below as a possibility...
<p>Here is a solution I found. It doesn't seem very elegant, though:</p> <pre><code>&lt;%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %&gt; &lt;% pageContext.setAttribute("newLineChar", "\n"); %&gt; ${fn:replace(item.comments, newLineChar, "; ")} </code></pre>
<p>You could write your own JSP function to do the replacement.</p> <p>This means you'd end up with something like:</p> <pre><code>&lt;%@ taglib prefix="ns" uri="..." %&gt; ... ${ns:replace(data)} </code></pre> <p>Where <code>ns</code> is a namespace prefix you define and <code>replace</code> is your JSP function.</...
8,250
<p>I have an ASP.NET Datagrid with several text boxes and drop down boxes inside it. I want to read all the values in the grid using a JavaScript function. How do i go about it?</p>
<p>Easily done with jQuery. I don't recall what kind of markup the Datagrid creates but basically something like this will work in Jquery</p> <pre><code> $('#client_id_of_datagrid input, #client_id_of_datagrid select') .each(function() {val = this.value; /* Do Stuff */}) </code></pre>
<p>Easily done with jQuery. I don't recall what kind of markup the Datagrid creates but basically something like this will work in Jquery</p> <pre><code> $('#client_id_of_datagrid input, #client_id_of_datagrid select') .each(function() {val = this.value; /* Do Stuff */}) </code></pre>
16,685
<p>I'm starting a new database application and I wonder if it would be better to start the design at the objects (with UML) and build the database schema accordingly, or start at the design of the database (with ER) and create the objects accordingly.</p> <p>What are the pros and cons of either approach?</p> <p>(I do...
<p>Depends on whether your application is designed to meet user needs, or to meet the needs of developers.</p> <p>Start with the user stories, and get the OOP Classes straight. And your users will love you.</p> <p>Otherwise you end up with an application that turns users into data entry clerks. (You'll have lots of c...
<p>That depends. Are you doing object-oriented programming or SQL-oriented programming?</p>
34,533
<p>How to implement a great search within a mysqldb - within a table if i search with '...LIke %bla%....' not all entrys would be found - if bla within a word for example. a search with soundex would be great to - but if i read the manual i must create an soundex-index to search for soundex-values? </p> <p>So the ques...
<p>You could say:</p> <pre><code>// Local Variables: // eval: (rename-buffer "my-buffer-name-here") // end: </code></pre> <p>It is a trick though. </p> <p>You could otherwise program a <code>find-file-hook</code> hook in your <code>.emacs</code> which rename the buffer to a specific local variable contents. Somethin...
<p>Thanks Pierre. Your pdp-buffer-name elisp example worked very well.</p> <p>I made one enhancement because I noticed emacs was treating the local variable as "unsafe" i.e., always prompting to ask if the value should be applied. Since I want this to work with many different values without cluttering up my .emacs w...
46,005
<p>What is the difference between early and late binding?</p>
<p>The short answer is that early (or static) binding refers to compile time binding and late (or dynamic) binding refers to runtime binding (for example when you use reflection).</p>
<pre><code>public class child() { public void method1() { System.out.println("child1"); } public void method2() { System.out.println("child2"); } } public class teenager extends child() { public void method3() { System.out.println("teenager3"); } } public class adul...
3,176
<p>I must be overlooking something simple. I'm setting a variable from a query result in a MySQL stored procedure like this:</p> <pre><code>SELECT @myName := username FROM User WHERE ID=1; </code></pre> <p>So, @myName is storing the username of userid 1, which is 'Paul'. Great.</p> <p>But later in the stored procedu...
<p>That's very surprising, I agree. I'm not sure how to explain it, but for what it's worth, try this instead:</p> <pre><code>SELECT username INTO myName FROM User WHERE ID=1; </code></pre> <p>See <a href="http://dev.mysql.com/doc/refman/5.0/en/select-into-statement.html" rel="nofollow noreferrer">http://dev.mysql.c...
<p>Variable <code>@name</code> still has the value Paul. If you want to update your variable you should assign the new value :</p> <pre><code>drop procedure if exists doit; delimiter !! create procedure doit() begin declare name varchar(10); select @name:=username from user where id=1; select @name; -- shows 'Pa...
35,184
<p>I have coded a MS Access 2000 report that displays a calendar with one month per page and projects added to particular days. The only data in the underlying record source is a list of months. The structure is created via the On Page event, which also reads in other data.</p> <p>When this report is opened, I've noti...
<p>I would recommend restructuring your code so that you build your data in one query, multiple queries, or in VBA, and then open the report with the new datasource. I might still have Access 2000 at home to check, but at work I can test both 2003 and 2007, and in both versions, the OnPage event fired before each page ...
<p>Have you considered the Format event for the various sections, especially the Detail section? Format or Print are a more usual events for manipulating reports.</p>
27,258
<p>Is it possible to reference system environment variables (as opposed to Java system properties) in a log4j xml configuration file?</p> <p>I'd like to be able to do something like:</p> <pre><code>&lt;level value="${env.LOG_LEVEL}" /&gt; </code></pre> <p>and have it get that from the system environment variables, s...
<p>I tried to do that recently and couldn't get it to work. What I ended up doing is sending a variable at startup. So say you have an environment variable called $LOG_LEVEL:</p> <pre><code>&lt;level value="${log_level}" /&gt; </code></pre> <p>and at startup...</p> <pre><code>java -Dlog_level=$LOG_LEVEL your_app </c...
<p>Create a system variable. I prefer to use setenv.bat for such variables.</p> <pre><code>@echo off rem app specific log dir set "APP_LOG_ROOTDIR=../app/app-log" exit /b 0 </code></pre> <p>Add reference in log4j.xml file</p> <pre><code>&lt;appender name="fileAppender" class="org.apache.log4j.RollingFileAppender"&gt...
24,563
<p>Wondering if there is any Text to Speech software available as a plug in for IE or Firefox.</p>
<p><a href="http://webanywhere.cs.washington.edu/" rel="noreferrer">WebAnywhere</a> is a university project aimed at creating a site that allows you to use text to speech from any browser at any location, without installing anything or using any plugins.</p> <p>You can <a href="http://webanywhere.cs.washington.edu/wa....
<p>For Firefox, there is LowBrowse, which has text to speech for the paragraph that the cursor is in. </p>
17,381
<p>Is it a measure of anything that a developer or even manager can look at and get meaning from? I know at one time, it was all about the 7, 8, 9, and 10 PageRank. But is it still a valid measure of anything? If so, what can you learn from a PageRank?</p> <p>Note that I'm assuming that you have other measurements tha...
<p>PageRank is specific to <strong>Google</strong> and is a trademarked proprietary algorithm. </p> <p>There are many variables in the formulas used by Google, but PageRank is primarily affected by the number of links pointing to the page, the number of internal links pointing to the page within the site and the numbe...
<p>The page rank algorithm is the probability distribution used to represent the likelihood that a person randomly clicking on links will arrive at any particular page. It is a relatively good approximation of importance of a webpage.</p>
39,775
<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 implem...
<p>Actually what Google does is very much non-trivial and also at first counter-intuitive. They don't do anything like check against a dictionary, but rather they make use of statistics to identify "similar" queries that returned more results than your query, the exact algorithm is of course not known.</p> <p>There ar...
<p>Soundex is good for phonetic matches, but works best with peoples' names (it was originally developed for census data)</p> <p>Also check out Full-Text-Indexing, the syntax is different from Google logic, but it's very quick and can deal with similar language elements.</p>
6,272
<p>Let's suppose I have an applet running within a page in a browser. What happens when the browser is closed by the user?</p> <p>Is the applet notified so that it can perform some kind of close action on its side (closing connections opened to a server, cleaning static variables, ...)?</p> <p>Also, I assume the same...
<p>Yes, the <strong>destroy() method</strong> should be called before the <strong>browser unloads the object</strong>.</p> <p><strong>destroy()</strong> is the last of four "<strong>life-cycle methods</strong>" of the Java applet (the others are <strong>init()</strong>, <strong>start()</strong>, and <strong>stop()</st...
<p>Most Of the times destroy will be called , but it dont get enough time to do required tasks in case of closing the window.</p> <p>It gets enough time when refreshing , navigating with Backword &lt;- and Forward -></p>
31,041
<p>I'm about to deploy a mediumsized site powered by Django. I have a dedicated Ubuntu Server. </p> <p>I'm really confused over which serversoftware to use. So i thought to myself: why not ask stackoverflow.</p> <p>What i'm looking for is:</p> <ul> <li>Easy to set up</li> <li>Fast and easy on resources</li> <li>Can ...
<p>Since I was looking for some more in-depth answers, I decided to research the issue myself in depth. Please let me know if I've misunderstood anything.</p> <p>Some general recommendation are to use a separate webserver for handling media. By separate, I mean a webserver which is not running Django. This server can ...
<p>If you're using lighthttpd, you can also use FastCGI for serving Django. I'm not sure how the speed compares to mod_wsgi, but if memory serves correctly, you get a couple of the benefits that you would get with mod_wsgi that you wouldn't get with mod_python. The main one being that you can give each application it...
4,562
<p>I am developing a small web app project (ColdFusion) and I am trying to keep my project split into multiple files during development, but deploy just one file on completion.</p> <p>I have references to external files, for instance:</p> <pre><code>&lt;script type="text/javascript" src="jquery-1.2.6.pack.js"&gt;&lt;...
<p>Does this do what you want?</p> <pre><code>&lt;property name="filename" value="jquery-1.2.6.pack.js" /&gt; &lt;loadfile property="contents" srcfile="${filename}" /&gt; &lt;replace dir="."&gt; &lt;include name="index.cfm"/&gt; &lt;replacetoken&gt;&lt;![CDATA[&lt;script type="text/javascript...
<p>Does this do what you want?</p> <pre><code>&lt;property name="filename" value="jquery-1.2.6.pack.js" /&gt; &lt;loadfile property="contents" srcfile="${filename}" /&gt; &lt;replace dir="."&gt; &lt;include name="index.cfm"/&gt; &lt;replacetoken&gt;&lt;![CDATA[&lt;script type="text/javascript...
20,289
<p>I am trying to create a "quick links" dropdown for a site I'm designing and it has to be compatible for all browsers IE6 and up. It needs to remain 120px wide because its position will be static. Using the <code>&lt;select&gt;</code> tag and setting a width, this works; however, when the box is opened, IE cuts off t...
<p>check out <a href="http://lwis.net/free-css-drop-down-menu/" rel="nofollow noreferrer">http://lwis.net/free-css-drop-down-menu/</a></p>
<p>If the A List Apart <a href="http://www.alistapart.com/articles/dropdowns/" rel="nofollow noreferrer">suckerfish</a> is of interest, you should take a look at the updated <a href="http://www.htmldog.com/articles/suckerfish/dropdowns/" rel="nofollow noreferrer">son of suckerfish</a> for inspiration. 12 lines of javas...
47,417
<p>We have a client application that has reference to a webservice. We had set the timeout property on the webclientprotocol object to 50 (ms) and wanted to observe what goes on. We tied up a long running webmethod that returns a huge DataSet to the client. When the default value was there, the DataSet was returned pro...
<p>The documentation is unfortunately unclear. When you say you "didn't observe anything" what exactly do you mean? Did the code hang forever? Was an exception thrown? Presumaby a valid DataSet wasn't returned.</p> <p>I would <em>expect</em> a <a href="http://msdn.microsoft.com/en-us/library/system.timeoutexception.as...
<p>I just ran into this. In a .NET 2.0 Web service, it throws a pretty unspecific <code>WebException</code>, with only the <code>Message</code> property to distinguish it:</p> <blockquote> <p>The request was aborted: The connection was closed unexpectedly.</p> </blockquote> <p>I haven't tried it in the WCF-based s...
47,252
<p>Alright it can be a lame question, but everybody uses these things differently. What's some of the best time savers out there for this IDE. <BR><BR>Tom</p>
<p>Don't forget <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>L</kbd>, which displays a list of all the keyboard shortcut combinations (just in case you forget any of those listed here).</p>
<p>CTRL + b: to build the project under c++</p> <p>CTRL + SHIFT + f: to format your code (c++)</p>
7,855
<p>I need to format an integer representation of bytes into something friendly, and I'm hoping that there's a utility function in Ruby or in Rails that will do that formatting for me (to perpetuate my laziness, of course.)</p> <p>I'm looking for something that would look like:</p> <pre><code>format_bytes(1024) -&...
<p><a href="http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html" rel="noreferrer">Number to human size</a> is what you're looking for.</p> <pre><code>require 'action_view' include ActionView::Helpers::NumberHelper number_to_human_size(123) # =&gt; 123 Bytes ...
<p>Accepted answer still work, but requires actionpack instead of actionview in newer rails.</p> <pre><code>require 'actionpack' </code></pre>
45,548
<p>I have a lot of castle xml configs where properties like connectionstring are also held under .Net configuration sections.</p> <p>I'd like to be able to read out the properties using the container but can't see a mechanism to do it.</p> <p>ie </p> <pre><code>&lt;castle&gt; &lt;configuration&gt; &lt;properti...
<p>You could do this a few different ways - for a strongly typed solution the obvious approach would be to implement a custom configuration class, then wire up the properties of the class with the properties in the windsor config (read-only properties with a bunch of constructor arguments would probably be best, so oth...
<p>Aren't you thinking about this the wrong way round?</p> <p>Surely the object that is using the connection string should have a ConnectionString property in the constructor and the dependency pushed in there with something in the components section of config like:</p> <pre><code>&lt;component type="SessionManager"&...
25,067
<p>I have the following snippet in one of my html pages :</p> <pre><code>&lt;div class="inputboximage"&gt; &lt;div class="value2"&gt; &lt;input name='address1' value='Somewhere' type="text" size="26" maxlength="40" /&gt; &lt;br /&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>My problem is that I ne...
<p>I think using</p> <pre><code>$(this).parents('div.inputBoxImage').css(...) </code></pre> <p>instead of <code>$(this.parentNode)</code> should work.</p> <p>See the jQuery <a href="http://docs.jquery.com/Traversing/parents#expr" rel="noreferrer">traversing documentation</a></p> <p>Edit: updated following Prody's a...
<p>Now since in HTML only IDs are unique, you can reference the div directly without doing any traversal:</p> <pre><code>&lt;div class="inputboximage" id="inputboximage"&gt; &lt;div class="value2"&gt; &lt;input name='address1' value='5 The Laurels' type="text" size="26" maxlength="40" /&gt; &lt;br /&g...
32,246
<p>Does any know of a good calendar (not datepicker, but a BIG browsable calendar) plugin for one of the major javascript frameworks. I'd prefer jQuery.</p>
<p>just published a new open source project (jQuery plugin). sounds exactly like what you want:</p> <p><a href="http://arshaw.com/fullcalendar/" rel="noreferrer">FullCalendar</a></p> <p>Hope it works well for you!</p>
<p>I have successfully used <a href="http://www.stefanoverna.com/log/create-astonishing-ical-like-calendars-with-jquery" rel="nofollow noreferrer">http://www.stefanoverna.com/log/create-astonishing-ical-like-calendars-with-jquery</a></p>
10,412
<p>I'm looking for an application that would lock my computer and display a screensaver with an away message that I set when I lock it. The idea is that when I go off somewhere during work, my co-workers would know where I'm off to instead of puzzling over my empty desk. </p> <p>Does such an application exist?</p> <p...
<p>I know it's not really the answer you're after, but have you considered just using Post-It&trade; Notes?</p>
<p>Most version of Windows have either the Marquee or 3D Text screensaver and give you the option of "On resume, display logon screen." You could just set the text of the screensaver to indicate where you are and why you are not at your desk, and when you return you have to put your password in to resume work. Is tha...
26,323
<p>If I click on a package and do control-shift-F10 it only looks for and runs JUnit tests in that package - but I really want it to recurse down into subpackages and run them. </p> <p>UPDATE: looks like its something else wrong. When I run it on a package that has tests, it still complains there are none (yet if I op...
<ol> <li>Run->Edit Configurations...</li> <li>Create a new junit test configuration</li> <li>Name it "All tests"</li> <li>Include entire package</li> <li>Apply/Run.</li> </ol> <p><img src="https://i.stack.imgur.com/6T5Sg.png" alt="enter image description here"></p> <p>From @andersoyvind's comment.</p>
<p>For <strong>Python</strong> users:</p> <ol> <li>Include <code>__init__.py</code> in each subfolder</li> <li>Create a <code>dummy_test.py</code> in the root of your tests directory, eg.:</li> </ol> <pre class="lang-py prettyprint-override"><code>class DummyTest(TestCase): pass </code></pre> <p>(<a href="https://...
41,749
<p>i have several common elements (components), that will generate some html. it seems my options are creating a taglib, or just putting that logic into a jsp page and including the jsp.</p> <p>whats the difference? positives vs negatives?</p>
<p>Taglibs allow you to define (typed) parameters which you can document. Also taglibs can be aware of their location in the object tree so act differently in a different context; or call a specific template over and over again to create iterators or statement constructs.</p> <p>Are you aware that taglibs don't necess...
<p>taglibs make it easier to define and handle parameters, but there's a significant overhead to developing them. Includes are simpler, but less powerful. Much depends on your style. </p> <p>In my experience, people generally just use includes because they don't want to take the time to learn to create tablibs. Leadin...
18,045
<p>I'm writing a python script that executes a csh script in Solaris 10. The csh script prompts the user for the root password (which I know) but I'm not sure how to make the python script answer the prompt with the password. Is this possible? Here is what I'm using to execute the csh script:</p> <pre><code>import com...
<p>Have a look at the <a href="http://www.noah.org/wiki/Pexpect" rel="noreferrer">pexpect</a> module. It is designed to deal with interactive programs, which seems to be your case.</p> <p>Oh, and remember that hard-encoding root's password in a shell or python script is potentially a security hole :D</p>
<p>Should be able to pass it as a parameter. something like:</p> <pre><code>commands.getoutput('server stop -p password') </code></pre>
28,575
<p>I'm making a simple remove link with an onClick event that brings up a confirm dialog. I want to confirm that the user wants to delete an entry. However, it seems that when Cancel is clicked in the dialog, the default action (i.e. the href link) is still taking place, so the entry still gets deleted. Not sure what I...
<p>There's a typo in your code (the tag <strong>a</strong> is closed too early). You can either use:</p> <pre><code>&lt;a href="whatever" onclick="return confirm('are you sure?')"&gt;&lt;img ...&gt;&lt;/a&gt; </code></pre> <p>note the <strong>return (confirm)</strong>: the value returned by scripts in intrinsic evens...
<p>I've had issue with IE7 and returning false before.</p> <p>Check my answer here to another problem: <a href="https://stackoverflow.com/questions/257085/javascript-not-running-on-ie#257097">Javascript not running on IE</a></p>
43,517
<p>I've been developing a GUI library for Windows (as a personal side project, no aspirations of usefulness). For my main window class, I've set up a hierarchy of option classes (using the <a href="http://www.parashift.com/c++-faq-lite/named-parameter-idiom.html" rel="nofollow noreferrer">Named Parameter Idiom</a>), be...
<p>Maybe not what you want to hear, but I for one think it's ok to have lots of ugly type-casts and template parameters in library-code that's (more or less) hidden from the client <em>as long as</em> it is safe <em>and</em> makes the life of the client a lot easier. The beauty in library code is not in the code itself...
<p>Templates are hot.</p> <p>But POP (Plain old Polymorphism) isn't dead.</p> <p>Why not return a (smart)pointer to the subclass?</p>
25,901
<p>Say I have accepted() a connection to my server (that runs on a Solaris) and the client has closed the connection. What is the state of the socket (in netstat categories) of the socket on the server side before I close() it on the server side? Is it BOUND?</p>
<p>It will be CLOSE_WAIT, see the tcp state diagram, e.g. on <a href="http://en.wikipedia.org/wiki/File:Tcp_state_diagram_new.svg" rel="noreferrer">http://en.wikipedia.org/wiki/File:Tcp_state_diagram_new.svg</a></p>
<p>I guess, TIME_WAIT.</p> <p>You may check it with "netstat" on Linux, don't know how do it on Solaris.</p>
48,024
<p>In JPA the Entities are nice annotated Plain Old Java Objects. But I have not found a good way to interact with them and the database.</p> <p>In my current app, my basic design is always to have a sequence based id as primary key so I usually have to look up entities by other properties than PK.</p> <p>And for eac...
<p>Try Seam. The <a href="http://docs.jboss.com/seam/2.1.0.BETA1/reference/en-US/html_single/#d0e7527" rel="nofollow noreferrer">Query Objects</a> do most of the work for you, and they're easily extendable. Or, you could always implement a similar pattern.</p> <p>In general, Seam does a lot of useful stuff to bridge t...
<p>I prefer using Spring's JpaDaoSupport, which helps to deal with JPA. A good example is here <a href="http://github.com/rafalrusin/jpaqb/blob/master/src/test/java/jpaqb/CarDao.java" rel="nofollow noreferrer">http://github.com/rafalrusin/jpaqb/blob/master/src/test/java/jpaqb/CarDao.java</a>.</p> <p>A good separation ...
21,443
<p>Say I'm building an ASP.Net class that inherits from <code>IHttpHandler</code>, should I wire this up to a URL ending in <code>.ashx</code>, or should I use the <code>.axd</code> extension? </p> <p>Does it matter as long as there's no naming conflict?</p>
<p>Ahh.. ScottGu says it doesn't matter, but .ashx is slightly better because there's less chance of a conflict with things like trace.axd and others. That's why the flag went up in my head that .ashx might be better.</p> <p><a href="http://forums.asp.net/t/964074.aspx" rel="nofollow noreferrer">http://forums.asp.net/...
<p>Out in "the wild", .ashx are definitely the most popular extension.</p>
7,690
<p>Does anyone have any good starting points for me when looking at making web pages/sites/applications specifically for viewing on the iPhone?</p> <p>I've looked at templates like the one <a href="http://blog.wired.com/monkeybites/2007/07/meet-joe-hewitt.html" rel="noreferrer">Joe Hewitt</a> has made, and also seen s...
<p>I found <a href="http://code.google.com/p/iphone-universal/" rel="nofollow noreferrer">iphone-universal</a> on Google Code the other day. Haven't had a chance to try it out but it looks promising.</p>
<p>This <em>looks</em> good, but unfortunately it's being licensed under GPLv3, so I'm actually a bit afraid to start looking at that code. The framework I either need to find, or develop if needs be, must be able to be used as part of a commercial program, without having to license the entire program different. Commer...
3,025
<p>Does anybody know how to call the <code>import data</code> built-in dialog excel from a macro (vba)?</p> <p>I've tried <code>Application.Dialogs.Item(...).Show</code> but I can´t find the right dialog. Please help.</p> <p>Thanks in advance.</p>
<p>The closest I can find using the dialog system is:</p> <pre><code>Application.Dialogs(xlDialogImportTextFile).Show </code></pre> <p>You can get a reference to the command bar button (at least for me in both 2k3 and 2k7) via:</p> <pre><code>Set button = Application.CommandBars.FindControl(ID:=6262) </code></pre> ...
<p>If you choose the Object Browser and search for say, xlDialogImportTextFile, you will get a list of possible dialogs.</p> <p>EDIT: Perhaps something on these lines would suit:</p> <pre><code>'Allow user to select text file sf = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If sf &lt;&gt; False Th...
30,433
<p>I'm at a client doing some quick fixes to their access application. It was a while I had a go with access, but I'm recovering quickly. However, I've discovered an interesting problem:</p> <p>For some reports, I get a "Record is deleted" error. I've checked the reports, and it seems like there's a problem with one t...
<p>Have you tried the built in Access compact/repair tool? This should flush deleted records from the database.</p> <p>The exact location varies according to the version of Access you're running, but on Access 2003 it's under Tools > Database Utilities > Compact and repair database. Some earlier versions of Access had...
<p>you can also try this <a href="http://support.microsoft.com/kb/295334" rel="nofollow noreferrer">Command line utility</a></p> <p>//andy</p>
31,065
<p>Is there an easy way to capitalize the first letter of a string and lower the rest of it? Is there a built in method or do I need to make my own?</p>
<p><code>TextInfo.ToTitleCase()</code> capitalizes the first character in each token of a string.<br /> If there is no need to maintain Acronym Uppercasing, then you should include <code>ToLower()</code>.</p> <pre><code>string s = "JOHN DOE"; s = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s.ToLower()); // Produce...
<p>Like edg indicated, you'll need a more complex algorithm to handle special names (this is probably why many places force everything to upper case).</p> <p>Something like this untested c# should handle the simple case you requested:</p> <pre><code>public string SentenceCase(string input) { return input(0, 1).To...
9,843
<p>How do I check whether a file exists or not, without using the <a href="https://docs.python.org/3.6/reference/compound_stmts.html#try" rel="noreferrer"><code>try</code></a> statement?</p>
<p>If the reason you're checking is so you can do something like <code>if file_exists: open_it()</code>, it's safer to use a <code>try</code> around the attempt to open it. Checking and then opening risks the file being deleted or moved or something between when you check and when you try to open it.</p> <p>If you're ...
<p>This is how I found a list of files (in these images) in one folder and searched it in a folder (with subfolders):</p> <pre><code># This script concatenates JavaScript files into a unified JavaScript file to reduce server round-trips import os import string import math import ntpath import sys #import pyodbc impo...
10,844
<p>I have the code pasted below, which servers as the core of a small ajax application. This was working fine previously, with makewindows actually displaying a popup containing the rsult of artcile_desc. I seem to have an error before that function however, as now only the actual php code is outputted. This is not a p...
<p>Firstly, any time you encode anything to a particular notation, you should convert the 'special characters' before doing so, just in case it breaks the notation.</p> <pre><code>child1.document.write("&lt;?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?&gt;"); </code></pre> <p>Should re...
<p>Mmm, if the JavaScript displays PHP code, that means the server no longer knows that something.php must run the PHP interpreter. You should double check the settings. And verify PHP isn't corrupted or something.</p> <p>Beside, the Firebug error you show is strange, it shows garbage. Perhaps you have set the server ...
48,493
<p>I have an API call in my application where I am checking the time taken for a single call. I have put this in a FOR loop and using 10000 calls to get the average times of all calls. Now the issue which came up was that the actual application using the API, is multi-threaded. If I wish to make my application also do ...
<p>Probably the best C++ library to use for threading is the thread library in Boost, but like all C++ threading, you will be forced to manually do your synchronization. You will need to use mutex and lock types to make it work properly. Your question isn't very clear, so I can't really help you any more (though I thin...
<p>In what platform? Just about every one supports threads, and I imagine they all have documentation on how to create a thread. Under Windows you'd call the CreateThread API.</p>
38,981
<p>I'd appreciate some feedback on a particular approach I'm thinking of using. The scenario is below.</p> <p>I have an object (lets call it MObject) that has a number of properties, say, x and y coordinates, height and width. The properties are named according to the KVC guidelines (MObject.x; MObject.height, etc). M...
<p>Don't override <code>-[NSObject valueForKey:]</code> and <code>-[NSObject setValue:forKey:]</code> if you can at all help it.</p> <p>Your best bet would be to convert the keys you get from the XML file on the fly. Use a separate method to do the conversion and you can also maintain a cache of names to property key...
<p>Override <code>-valueForKey:</code> and <code>-setValue:forKey:</code>.</p> <p>You should probably only accept keys (element/attribute names) you recognize, and call up to <code>super</code> for other keys.</p>
43,565
<p>I have some website which requires a logon and shows sensitive information.</p> <p>The person goes to the page, is prompted to log in, then gets to see the information.</p> <p>The person logs out of the site, and is redirected back to the login page.</p> <p>The person then can hit "back" and go right back to the ...
<p>The short answer is that it cannot be done securely.</p> <p>There are, however, a lot of tricks that can be implemented to make it difficult for users to hit back and get sensitive data displayed.</p> <pre><code>Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(Now.AddSeconds(-1))...
<p>You are looking for a no-cache directive:</p> <pre><code>&lt;META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"&gt; </code></pre> <p>If you've got a master page design going, this may be a little bit of a juggle, but I believe you can put this directive on a single page, without affecting the rest of your site (assuming ...
8,957
<p>I recently downloaded PLT Scheme and DrScheme. When I open DrScheme, I am told to choose a language. However, I'm not familiar with any of my options, and the help guides don't really break it down to help me easily choose which choice.</p> <p>So, first - is DrScheme and PLT Scheme really the tools I need to learn ...
<p>Just go for "Pretty Big". That will be all you need until you know what the rest are for. I find that R5RS is good, but it does lack the extensions that PLT has added to DrScheme.</p> <p><em>edit:</em> I just checked and I guess that both "Pretty Big" and "R5RS" are considered "legacy" in DrScheme 4 and the "Module...
<p>Standard (R5RS) is the actual thing so that would be your best bet<br> i learnt it from <a href="http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/" rel="nofollow noreferrer">http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/</a><br> used MIT Scheme while doing that<br> but ...
34,696
<p>Here is pseudo-code of how I setup an array representing the MandelBrot set, yet it becomes horribly stretched when leaving an aspect ratio of 1:1.</p> <pre><code>xStep = (maxX - minX) / width; yStep = (maxY - minY) / height; for(i = 0; i &lt; width; i++) for(j = 0; j &lt; height; j++) { constantReal = minRe...
<blockquote> <p>Here is pseudo-code of how I setup an array representing the MandelBrot set, yet it becomes horribly stretched when leaving an aspect ratio of 1:1.</p> </blockquote> <pre><code>xStep = (maxX - minX) / width; yStep = (maxY - minY) / height; </code></pre> <p>Aha! It's because you must keep the same ...
<p>It probably has to do with how you are displaying the <code>image</code> array. You use the width variable i as the first index, but usually the first index should be the slowest changing, that is, the height.</p> <p>Try changing the last line to <code>image[j][i] =</code> ...</p>
41,348
<p>I'm trying to use SubSonic for a new project with an existing database but when I try to build the project after generating the SubSonic files I'm getting these same two exceptions on different classes:</p> <ul> <li>Partial declarations of 'MyData.UserCollection' must not specify different base classes</li> <li>Typ...
<p>Search for UserCollection in your project. SubSonic generated a partial class for this in the User.cs generated file. You either have a UserCollection of your own in which case you should probably rename it or put it in another namespace. Either that, or you tried to add functionality to the UserCollection and you d...
<p>Rob,</p> <p>Thanks for the help. You got me going on the right track. Apparently, the generator doesn't like tables with the word "Collection" in the name. I see now that the error was with:</p> <pre><code>public partial class UserCollectionCollection : ActiveList&lt;UserCollection, UserCollectionCollection&gt;...
33,000
<p>How do I detect if my program runs in an Active Directory environment?</p> <p>I'm using C# and .Net 2.0</p>
<p>Try getting Environment.UserDomainName and comparing it to Environment.MachineName. If the two are the same then it's likely that the user does not have a domain. If they are not the same then the user is logged into a domain which must have a directory server.</p>
<p>From <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.path.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.path.aspx</a></p> <blockquote> <p>To bind to the current domain using LDAP, use the path "LDAP://RootDS...
16,993
<p>I've already got a NAnt build script that builds/runs tests/zips web project together, etc. but I'm working on a basic desktop application. How would I go about building the setup project using NAnt so I can include it with the build report on TeamCity.</p> <p>Edit: The setup is the basic Setup Project supplied wi...
<p>It's been a few years, but the last time I had to do this, I used a tool called Wix, which had utilities named Candle and Light. I used these tools in my NAnt script to create an MSI Installer.</p>
<p>Instead of trying to build using MSBUILD (assumption), build the solution or project using DEVENV.EXE. The command line is something along the lines of:</p> <p>DEVENV MySolutionFile.sln /build DEBUG /project SetupProject.vdproj</p> <p>You can change the DEBUG to RELEASE or any other build configuration you've set ...
10,786
<p>As first layer is so important, I am looking for an easy way to generate the gcode to print just the first layer. I see that with Slic3r you can cut from a Z But for test purposes I prefer just selecting a number of layers to be generated so I can easily generate different "first layer(s) tests" with different firs...
<p>I understand your question like this:</p> <blockquote> <p>I know I could cut the mesh and just slice the bottom of my model, but since I am interested in a given <strong>number of layers</strong> and the heigh of a layer may change according to settings (e.g.: 0.2mm, 0.1mm, 0.05mm...), I want to find a way to gen...
<p>You could just insert an M30 at the end of layer 1, and the job will end there.</p>
789
<p>Is there a way to add a resource to a ResourceDictionary from code without giving it a resource key?</p> <p>For instance, I have this resource in XAML:</p> <pre><code>&lt;TreeView.Resources&gt; &lt;HierarchicalDataTemplate DataType="{x:Type xbap:FieldPropertyInfo}" ItemsSource="{Binding Path=Value.Valu...
<p>Use the type that you want the template to apply to as the key:</p> <pre><code>HierarchicalDataTemplate fieldPropertyTemplate = new HierarchicalDataTemplate("FieldProperyInfo"); fieldPropertyTemplate.SetBinding( HierarchialDataTemplate.ItemSourceProperty, new Binding("Value.Values"); this.Resources.Add...
<p>Use the type that you want the template to apply to as the key:</p> <pre><code>this.Resources.Add(FieldPropertyInfo.GetType(), fieldPropertyTemplate); </code></pre> <p>As with your template above you provide a type. You have to either have to provide a name or a type.</p>
17,032
<p>I have a string, lets say "123|ABC|test|12345|FF" and I want to xor the ascii value of each character and print the result in hex.</p> <p>What is the simplest way?</p>
<p>I posted a related question to this once that you might want to take a look at: <a href="https://stackoverflow.com/questions/133988/problem-with-synchronizing-on-string-objects">Problem with synchronizing on String objects?</a></p> <p>What I learned was: using intern'ed Strings for synchronization is a <strong>bad<...
<p>key.intern() guarantee uniqueness because key.intern() returns a string from String constants pool.</p> <p><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#intern()" rel="nofollow noreferrer">http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#intern()</a> intern</p> <p>public St...
45,409
<p>I have OS X 10.5 set up with the precompiled versions of PHP 5 and Apache 2. I'm trying to set up the Zend Debugger, but with no luck. Here's what I did:</p> <ul> <li>I downloaded <code>ZendDebugger-5.2.14-darwin8.6-uni.tar</code></li> <li>I created the directory <code>/Developer/Extras/PHP</code> and set the per...
<p>If I remember correctly, this problem is do to the fact that the Zend Debugger is compiled for 32-bit Apache while the Apache that comes with Max OS 10.5 is compiled as 64-bit application. Until Zend comes out with a 64-bit version, you have two options: </p> <p>1) <a href="http://www.entropy.ch/phpbb2/viewtopic.p...
<p>Me too, HOURS!! Thanks so much!! Also if for some reason you need to restart apache/httpd after running this (e.g. you need to make a change in your php.ini) but when you run "sudo arch -i386 /usr/sbin/httpd" you're getting this error:</p> <p>(48)Address already in use: make_sock: could not bind to address [::]:80<...
29,797
<p>As you may know, Silverlight does not have the TileBrush found in WPF. Is there a workaround to do tiling?</p>
<p>According to contributor at <a href="http://silverlight.net/forums/t/84987.aspx" rel="nofollow noreferrer">Silverlight forum</a> </p> <blockquote> <p>TileBrush in Silverlight (2 and 3) is only a placeholder class ready for future expansion and for WPF compatibility</p> </blockquote> <p>A PixelShader workaround i...
<p>Well, it would appear that Silverlight does support the TileBrush, as referenced on MSDN: <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.tilebrush(VS.95).aspx" rel="nofollow noreferrer">System.Windows.Media.TileBrush</a>. It first appears in Silverlight 2.0 Beta 2.</p>
11,109
<p>How to get unique Google Gadget ID from a gadget added to a iGoogle website, with Javascript?</p>
<p>If you are trying to access the ID of a gadget from JavaScript within the gadget itself, you can use <code>__MODULE_ID__</code>. This is replaced automatically by the iGoogle server with the actual module ID, and is used in a number of the standard libraries as a common constructor parameter (see the <a href="http:...
<p>I'm not 100% sure what you mean, but it seems that the URL for Google Gadgets is something like this: <a href="http://hosting.gmodules.com/ig/gadgets/file/unique_id/name.xml" rel="nofollow noreferrer">http://hosting.gmodules.com/ig/gadgets/file/unique_id/name.xml</a>..., and after Google is done with their JavaScrip...
49,775
<p>I’ve got this proximity sensor which is a 5 V, it doesn’t say it can be used over 5 V. Can I use a buck converter or is it possible to wire it up direct to a 5 V source on the Ender 3 V2?</p> <p>What I don’t understand is where to wire it direct to 5 V on the printer or if I use a buck converter then where does the ...
<p>PLA is a forgiving filament, you can even print such filament without a heated bed. Although there are differences in quality between brands, PLA shouldn't need a raft to be printed. Hatchbox filament is not considered as a low quality type of filament; it is economical and has been around since 2013. A raft is a st...
<p>Please try one (or more) of the following:</p> <ol> <li><p>Change the temperature of your heated bed (50 - 60 °C)</p> </li> <li><p>Check your nozzle height (0.15 - 0.25 mm is what I use)</p> </li> <li><p>Make sure your bed is level (Maybe use a leaving stick (or whatever those bubble things are called))</p> </li> <l...
1,935
<p>I am writing an iframe based facebook app. Now I want to use the same html page to render the normal website as well as the canvas page within facebook. I want to know if I can determine whether the page has been loaded inside the iframe or directly in the browser?</p>
<p>Browsers can block access to <code>window.top</code> due to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript" rel="noreferrer">same origin policy</a>. IE bugs also take place. Here's the working code:</p> <pre><code>function inIframe () { try { return wi...
<p>It's an ancient piece of code that I've used a few times:</p> <pre><code>if (parent.location.href == self.location.href) { window.location.href = 'https://www.facebook.com/pagename?v=app_1357902468'; } </code></pre>
42,245
<p>I'd like to be able to access the contents of my Storage Card which is in my Windows Mobile device. Normally, I'd just remove the card and shove it in a card reader, but its encrypted (and thus, locked to my WM device).</p> <p>Is there an API or some sort of framework allowing read/write access to the Storage Card ...
<p>I think it runs one for each Port -- you can try turning setting them to have the same port - click on the project and look at the properties pane (you have to turn off the the automatic port generation and then set the port#)</p>
<p>Suggestion - don't use the internal WebDev, use IIS instead. Also reduces the clutter in the systray. ;)</p>
42,606
<p>I've been tasked with updating a series of applications which are performance critical VB.NET apps that essentially just monitor and return networking statistics. I've only got three requirements: <em>convert it to C#, make it fast, and make it stable</em></p> <p>One caveat is that we <em>"may"</em> migrate from a ...
<p>First off, I would put some time into trying out a few <a href="http://www.google.com/search?q=VB.NET+to+C%23+converter&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a" rel="nofollow noreferrer">VB.NET to C# converters</a>. You're basically porting syntax, and there's no r...
<p><strong>I might be misunderstanding the issue</strong>, but if it is a network monitoring system, why isn't it written as a "dedicated" Windows service? </p> <p>VB.NET shouldn't be much slower than C#. I'm not 100% certain if there is any big differences in the generated IL-code, but the only advantage (and justifi...
3,119
<p>I am trying to snoop on a log file that an application is writing to.</p> <p>I have successfully hooked createfile with the detours library from MSR, but createfile never seems to be called with file I am interested in snooping on. I have also tried hooking openfile with the same results.</p> <p>I am not an experie...
<p>You can use Sysinternal's <a href="http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx" rel="nofollow noreferrer">FileMon</a>. It is an excellent monitor that can tell you exactly which file-related system calls are being made and what are the parameters.</p> <p>I think that this approach is much easier ...
<p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="nofollow noreferrer">Process Monitor</a> from sysinternals could help too.</p>
3,475
<p>I'm writing a programmer's text editor (yes another one) in Perl called <a href="http://kephra.sourceforge.net/" rel="nofollow noreferrer">Kephra</a>, which is also a CPAN module of course and bundled with <a href="http://cpanratings.perl.org/dist/Module-Install" rel="nofollow noreferrer">Module::Install</a>. Recent...
<p>The cud as already been chewed a bit on this before in <a href="https://stackoverflow.com/questions/73889/which-framework-should-i-use-to-write-modules">"Which framework should I use to write modules?"</a></p> <p>After spitting out the cud I decided to go with <a href="http://search.cpan.org/dist/Module-Build/" rel...
<p>Well, <code>Module::Build</code> is a pretty good module, it's supposed to be a drop in replacement for <code>ExtUtils::MakeMaker</code>, that is, replace the Makefile.PL by a Build.PL, which generate a Build instead of a Makefile. It was also meant as "simple things should stay simple, hard things should be possibl...
48,217
<p>I have a large application (~50 modules) using a structure similar to the following:</p> <ul> <li>Application <ul> <li>Communication modules <ul> <li>Color communication module</li> <li>SSN communication module</li> <li>etc. communication module</li> </ul></li> <li>Router module</li> <li>Service modules <ul> <...
<p>We have a largish application (160+ OSGi bundles where each bundle is a Maven module) and the lesson we learned, and continue to learn, is that flat is better. The problem with encoding semantics in your hierarchy is that you lose flexibility. A module that is 100% say "communication" today may be partly "service" t...
<p>I think you're better off flattening your directory structure. Perhaps you want to come up with a naming convention for the directories such that they sort nicely when viewing all of the projects, but ultimately I don't think all of that extra hierarchy is necessary.</p> <p>Assuming you're using Eclipse as your ID...
4,034
<p>Is there any free IDE for Pl/SQL development</p>
<p>I use <a href="http://www.oracle.com/technology/products/database/sql_developer/index.html" rel="noreferrer">SQL Developer</a> every day to develop packages. Whilst it's not perfect, it's got some useful features:</p> <ul> <li>Syntax highlighting;</li> <li>Autocompletion;</li> <li>Debugging (although not of live re...
<p><a href="http://www.sqltools.net/" rel="nofollow noreferrer">SQL Tools</a> is a free PL/SQL IDE that is lightweight and fast, and it's free. Although one feature it's missing is a debugger support.</p>
39,166
<p>If I have a double (234.004223), etc., I would like to round this to x significant digits in C#.</p> <p>So far I can only find ways to round to x decimal places, but this simply removes the precision if there are any 0s in the number.</p> <p>For example, 0.086 to one decimal place becomes 0.1, but I would like it ...
<p>The framework doesn't have a built-in function to round (or truncate, as in your example) to a number of significant digits. One way you can do this, though, is to scale your number so that your first significant digit is right after the decimal point, round (or truncate), then scale back. The following code shoul...
<p>I just did:</p> <pre><code>int integer1 = Math.Round(double you want to round, significant figures you want to round to) </code></pre>
48,951
<p>my primary language is spanish, but I use all my software in english, including windows; however I'd like to use speech recognition in spanish.</p> <p>Do you know if there's a way to use vista's speech recognition in other language than the primary os language?</p>
<p>Citation from Vista <a href="http://blogs.msdn.com/speech/archive/2007/09/01/windows-speech-recognition-language-support-in-windows-vista.aspx" rel="nofollow noreferrer">speech recognition blog</a>:</p> <blockquote> <p>In Windows Vista, Windows Speech Recognition works in the current language of the OS. That...
<p>You can install the language pack, but not apply it on your user. Then you might be able to change the language of the speech recognition, although I haven't tried it since I don't have Vista Ultimate.</p>
5,713
<p>I have a group of strings in Javascript and I need to write a function that detects if another specific string belongs to this group or not.</p> <p>What is the fastest way to achieve this? Is it alright to put the group of values into an array, and then write a function that searches through the array?</p> <p>I th...
<p>Use a hash table, and do this:</p> <pre><code>// Initialise the set mySet = {}; // Add to the set mySet["some string value"] = true; ... // Test if a value is in the set: if (testValue in mySet) { alert(testValue + " is in the set"); } else { alert(testValue + " is not in the set"); } </code></pre>
<p>Using a hash table might be a quicker option. </p> <p>Whatever option you go for its definitely worth testing out its performance against the alternatives you consider.</p>
39,689
<p>There's something I want to customize in the System.Web.Script.Services.ScriptHandlerFactory and other .NET stuff inside an internal class. Unfortunately, it's an internal class. What options do I have when trying to customize a method in this class?</p>
<p>You might find <a href="http://blogs.msdn.com/ericlippert/archive/2008/09/26/preventing-third-party-derivation-part-one.aspx" rel="noreferrer">this recent article</a> enlightening. Basically, it says that you can't override anything marked <code>internal</code>, and the source is about as authoritative as it gets. ...
<p>It depends on the assembly. This could possibly violate some licensing (although its similar to some sort of static linking), and maybe even make deployment a nightmare, but you could consider:</p> <ul> <li>Decompile and copy the code over to your own project; modify as needed</li> <li>Recompile/patch the assembly ...
23,877
<p>I have a table, users, in an Oracle 9.2.0.6 database. Two of the fields are varchar - last_name and first_name.</p> <p>When rows are inserted into this table, the first name and last name fields are supposed to be in all upper case, but somehow some values in these two fields are mixed case.</p> <p>I want to run ...
<p>How about this:</p> <pre><code>select id, first, last from mytable where first != upper(first) or last != upper(last); </code></pre>
<p>for SQL server where the DB collation setting is Case insensitive use the following:</p> <pre><code>SELECT * FROM tbl_user WHERE LEFT(username,1) COLLATE Latin1_General_CS_AI &lt;&gt; UPPER(LEFT(username,1)) </code></pre>
41,018