instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I am working to integrate unit testing into the development process on the team I work on and there are some sceptics. What are some good ways to convince the sceptical developers on the team of the value of Unit Testing? In my specific case we would be adding Unit Tests as we add functionality or fixed bugs. Unfort...
<p>Every day in our office there is an exchange which goes something like this:</p> <blockquote> <p>"Man, I just love unit tests, I've just been able to make a bunch of changes to the way something works, and then was able to confirm I hadn't broken anything by running the test over it again..."</p> </blockquote> <...
<p>Unit testing works for QA guys or your managers, not for you; so it's definitely not worth it.</p> <p>You should focus on writing correct code (whatever it means), not test cases. Let other guys worry about those.</p>
9,286
<p>I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine?</p> <p>Also, this will be an i...
<p>Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either. :)</p> <p>Start with the Ruby One Click installer so you have a sane in...
<p>You can install SQLite and a Rails server like Mongrel on a Windows machine. I used Aptana to run a development environment, but I'm sure that there are better alternatives that don't require the IDE to be open to run. But this proves it is possible.</p>
5,600
<p>I would like to know difference between static variables and global variables in terms of <strong>access speed</strong> and <strong>space consumption</strong>. (If you want to know my platform: gcc compiler on Windows. (I am using Cygwin with Triton IDE for ARM7 embedded programming on windows. Triton comes with gcc...
<p>There is no difference for the space, they take the same amount.</p> <p>But there is a speed difference: static is faster.</p> <p>Of course the memory access to the variable is for global and static the same. But the compiler can optimize when you have static. When it compiles a module it knows that no function ca...
<p>There is <strong>no difference</strong> in the env you describe when it comes to <strong>space</strong>. The static or global var consume just the same amount of memory.</p> <p>For <strong>speed</strong> considerations (<em>but not good practice</em>) you could <strong>prefer global vars</strong>, if you need acces...
41,814
<p>I am trying to resolve this for months and have tried almost everything, I guess.</p> <p>I am using Marlin firmware on a custom extruder with a custom fabricated heating block in which heater and thermistor (Marlin Temp_Sensor 11) are set up perpendicular to each other. Whenever I try to heat it up to 200 degree Ce...
<p>There are many unknowns at this point, you need to work methodically through each stage. You probably also need some test equipment, at least a basic multimeter. Ideally a temperature probe too.</p> <p>First, check that your power supply can drive the hot-end directly. You already know how long it takes to reach 12...
<p>Now that we can see the real problem, your heater cartridge doesn't have good thermal contact to the block, and the block does not have good contact to the nozzle.</p> <p>Where is your heatbreak? You need to perform a basic analysis of the heat flow in your design. Anything that is expected to conduct needs to be c...
1,027
<p>I'm calling a web service that returns an array of objects in JSON. I want to take those objects and populate a div with HTML. Let's say each object contains a url and a name.</p> <p>If I wanted to generate the following HTML for each object:</p> <pre><code>&lt;div&gt;&lt;img src="the url" /&gt;the name&lt;/div&...
<p>Options #1 and #2 are going to be your most immediate straight forward options, however, for both options, you're going to feel the performance and maintenance impact by either building strings or creating DOM objects.</p> <p>Templating isn't all that immature, and you're seeing it popup in most of the major Javasc...
<blockquote> <p>Is there a best practice for this? I can see a few ways of doing it:</p> <ol> <li>Concatenate strings </li> <li>Create elements </li> <li>Use a templating plugin </li> <li>Generate the html on the server, then serve up via JSON.</li> </ol> </blockquote> <p><strong>1)</strong> This i...
27,165
<p>Probably not much more to elaborate on here - I'm using a NumericStepper control and I want the user to use the buttons only to change the value in the NS, not by typing into the control - I couldn't find a property to disable the text - does it exist? </p> <p>If it doesn't, how would I subclass this thing to disab...
<p>Ok - I think I got it - there is no property you can set but you can subclass the control and set:</p> <pre><code>mx_internal::inputField.enabled = false; </code></pre> <p>Although that sets up next question about what the hell mx_internal is...</p>
<p>mx_internal is a namespace. There's a good explanation of how it all works here:</p> <p><a href="http://nondocs.blogspot.com/2007/04/mxcoremxinternal.html" rel="nofollow noreferrer">http://nondocs.blogspot.com/2007/04/mxcoremxinternal.html</a></p>
48,175
<h2>Background</h2> <p>I have an application written in native C++ over the course of several years that is around 60 KLOC. There are many many functions and classes that are dead (probably 10-15% like the similar Unix based question below asked). We recently began doing unit testing on all new code and applying it to...
<p>Ask the linker to remove unreferenced objects (/OPT:REF). If you use function-level linking, and verbose linker output, the linker output will list every function it can prove is unused. This list may be far from complete, but you already have the tools needed.</p>
<p>Use a code coverage tool against your unit test suite.</p>
39,573
<p>I'm following the sample code in <em>CFNetwork Programming Guide</em>, specifically the section on <strong>Preventing Blocking When Working with Streams</strong>. my code is nearly identical to theirs (below) but, when I connect to my server, I get posix error 14 (bad address -- is that bad IP address (except it's ...
<p>Olie, where does</p> <pre><code>buffer </code></pre> <p>that you supply to</p> <pre><code>CFReadStreamRead() </code></pre> <p>come from? EFAULT is a bad buffer address... are you sure you've actually initialized this buffer to point to something valid? It's obviously a global or sometime... which itself is a pre...
<p>I'm not familiar with Cocoa or Objective-C, but I can tell you that POSIX error code 14 is called <a href="http://www.wlug.org.nz/EFAULT" rel="nofollow noreferrer">EFAULT</a>, and it means you made a system call with an invalid pointer value. This is almost certainly some user-supplied buffer pointer to a read or w...
42,096
<p>I need that my Apache require authentication only to external access but free in my local network. I have mod_user in my Apache.</p>
<p>The <strong><em>easiest</em></strong> way to deal with this is to use two virtual host. Use one for the external users and one of the internal users... i.e. "www.myhost.com" for external and "www-int.myhome.com" for internal users. Restrict www-int to internal IP's only with no auth requirements.</p> <p>Alternative...
<p>Not much into apache authentication, i just use tomcat from time to time to test some jsp.</p> <p>Have you tried reading this? <a href="http://httpd.apache.org/docs/1.3/howto/auth.html#basicconfig" rel="nofollow noreferrer">http://httpd.apache.org/docs/1.3/howto/auth.html#basicconfig</a></p>
25,739
<p>I know how to find a method in java using a fixed string,</p> <pre><code>someClass.getMethod("foobar", argTypes); </code></pre> <p>but is there a way to use a regular expression rather than a fixed string to find a method on a given class? </p> <p>An example of the usage might be if I wanted to find a method that...
<p>You should apply your regexp on <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getDeclaredMethods()" rel="nofollow noreferrer">getDeclaredMethods</a>() reflection method (or GetMethods() if you want only the public ones).</p> <p>[Warning: both methods will throw a SecurityException if there i...
<p>No, you can't do that, but you can get a list of the method a class has and apply the regexp to them.</p> <pre><code>Method[] getMethods( String regexp, Class clazz, Object ... argTypes ){ List&lt;Method&gt; toReturn = new ArrayList&lt;Method&gt;(); for( Method m : clazz.getDeclaredMethods() ){ if...
28,123
<p>Is VBA going to go away any time soon, like VB6 has? Should I not develop new Office applications with VBA? Or should I be developing all new Office Apps with VSTO?</p> <p>Update: Recently read this <a href="http://visualbasic.about.com/b/2009/09/26/visual-basic-and-office-an-update.htm" rel="nofollow noreferrer...
<p>Office VSTO offers a great deal of additional functionality over Office VBA, and while I don't believe Microsoft has signaled that it's going to terminate VBA (in fact, <a href="http://blogs.msdn.com/access/archive/2008/01/17/vba-in-office-14.aspx" rel="noreferrer">they've said explicitly</a> that it will be around ...
<p>Here is a <a href="http://blogs.msdn.com/excel/archive/2008/01/16/clarification-on-vba-support.aspx" rel="nofollow noreferrer">comment from Microsoft</a> regarding future VBA support. In a nutshell, it is not going away on Windows versions of Office (but is discontinued for Mac versions).</p>
14,039
<p>I have a .Net program that I want to install on a terminal server. In the past I've created installer projects and generated an MSI. However, terminal servers require all users be bumped off before running an MSI and I want to avoid that. Is there a way to do an install without a MSI?</p> <p>Sometimes for some u...
<p>yes, in general, unless you need to install a component into the Global Assembly Cache, (GAC), all you need to do is copy the files to a folder on the computer you want to run it on.. To run it, all you need to do is double click the .exe file. </p> <p>The only caveat is that the machine has to have the correct ....
<p>If you just want to do updates of an app (and not install new shortcuts or whatnot) then I would just make a WinRAR self extracting file. You can embed in it the destination directory and specify a quiet install even.</p>
36,566
<p>I wrote a wrapper for a COM object that only excepted strings as input, so in good OOP practice I wrapped the string up in a function so that it was easier to build and call.</p> <p>I was just wondering if anyone could think of a better way to do the following code. </p> <pre><code> Public Function OpenTable(By...
<p>In this case it seems many of the parameters are just 'configuration values' (which end up being strings), you could modify it to accept a single class for all the configuration that you prepare before the call and that will return you the string accordingly.</p> <p>Something like</p> <pre><code>class COMConfigura...
<p>Since i dont know your programming language, im gonna keep this to pseudo code, but my general answer is to use ann array as single parameter:</p> <pre><code>function OpenTable( options As array) { if (options is not array or options is empty) { Throw exception } return_string = ""; if ( key...
21,923
<p>In converting from short to a byte array I found the following solution on the web but could not quite understand the logic involved.</p> <pre><code>//buffer is an array of bytes, bytes[] buffer[position] = (byte)(sample &amp; 0xff); buffer[position+1] = (byte)((sample &gt;&gt; 8) &amp; 0xff); </code></pre> <p>Can...
<p>This code probably comes from C code (or was written by a C programmer who don't parse Java as well as erickson does). This is because in Java a cast from a type with more information to a type with less information will discard the higher order bits and thus the &amp; 0xff is unnecessary in both cases.</p> <p>A sh...
<p>It makes sure there's no overflow; specifically, the first line there is taking the LSByte of "sample" and masking OUT your upper 8 bits, giving you only values in the range of 0-255; the second line there is taking the MSByte of "sample" (by performing the right-shift) and doing the same thing. It shouldn't be nec...
34,383
<p>I need to make a piece of C# code interact through COM with all kinds of implementations.</p> <p>To make it easeier for users of that integration, I included the interacted interfaces in IDL (as part of a relevant existing DLL, but without coclass or implementation), then got that into my C# code by running Tlbimp ...
<p>Again - thanks for the suggestions.</p> <p>I was able to finally resolve the issue on my own. I tried the above suggestions and didn't made any progress. Then I changed the namespace of the interop in the 'testing' code - it varied from the one in the main code because of different argument use when using Tlbimp. T...
<p>I think you need this on the interface</p> <pre><code>[InterfaceType(ComInterfaceType.InterfaceIsDual)] </code></pre>
35,701
<p>I have a very large code base that contains extensive unit tests (using CppUnit). <b>I need to work out what percentage of the code is exercised by these tests</b>, and (ideally) generate some sort of report that tells me on a per-library or per-file basis, how much of the code was exercised.</p> <p>Here's the kick...
<h3>Which tool should I use?</h3> <p>This <a href="http://web.archive.org/web/20090527141110/http://www.kimbly.com/blog/000331.html" rel="noreferrer">article describes</a> another developers frustrations searching for C++ code coverage tools. The author's final solution was <a href="http://www.bullseye.com/" rel="nore...
<p>I guess I should have specified the compiler - we're using gcc for Linux, and MSVC 6 (yeah I know, it's old, but it works (mostly) for us) for WIn32.</p> <p>For that reasons, gcov won't work for our Win32 builds, and Bullseye won't work for our Linux builds.</p> <p>Then again maybe I only need coverage in one OS.....
5,300
<p>What usability evaluation methods do you use? </p> <ul> <li>GOMS? </li> <li>Cognitive Walkthrough?</li> <li>Think aloud protocol?</li> </ul> <p>Others? (apart from 'ask your mum' tips that are well covered elsewhere on SO)</p>
<ol> <li><p>Dogfooding. Using our own application we quickly find out which parts are clunky or inconvenient to use.</p></li> <li><p>Log and analyse support calls, and track what parts of the application users have trouble using or finding.</p></li> <li><p>Usability tests. We write down a task, as near to an actual use...
<p>build the UI out of pieces of paper. create several task scenarios - probably don't expect to cover the entire UI in one sitting. find good test subjects based on target audience (this may be the hardest part). provide said subjects with printed agenda .. provide a human-being to act as 'help system' but otherwise ...
44,838
<p>I'm looking for something like <a href="http://ondras.zarovi.cz/sql/demo/?keyword=default" rel="nofollow noreferrer">WWW SQL Designer</a> for UML Modeling.</p>
<p>This one is not in Ajax, it's in flash, at least it is online: <a href="http://www.gskinner.com/gmodeler/launch.html" rel="nofollow noreferrer">http://www.gskinner.com/gmodeler/launch.html</a></p>
<p>Not totally UML but it's super user-friendly and automatically generates an AJAX application prototype based on your model. it saves us a lot of time. <a href="http://www.xifactory.com" rel="nofollow noreferrer">http://www.xifactory.com</a> </p>
35,691
<p>I am using the following code fragment in a php script to safely update a shared resource. </p> <pre><code>$lock_id = sem_get( ftok( 'tmp/this.lock', 'r')); sem_acquire($lock_id) //do something sem_release($lock_id) </code></pre> <p>When I stress test this code with large number of requests I get an error:</p> <p...
<p>I wouldn't ignore the ENOSPC (you're getting something other than EINTR, as the code shows). You may end up in a busy loop waiting for a resource that you have earlier exhausted. If you're out of some space somewhere, you want to make sure that you deal with that issue. ENOSPC generally means you are out of...som...
<p>After posting this question I noticed that I misread the code as <code>errno</code> <strong><code>==</code></strong> <code>EINTR</code> and jumped into conclusion. So as bog has pointed out, the error is <code>ENOSPC</code> and not <code>EINTR</code>. After some digging I located the reason for <code>ENOSPC</code>. ...
34,298
<p>I've got a website that I've just uploaded onto the interwebs, and it's displaying differently using Firefox 3.0.1 on Ubuntu and WinXP.</p> <p>Two things I've noticed on Ubuntu:</p> <ol> <li>The favicon is missing </li> <li>The background color isn't displaying (it's set in the stylesheet)</li> </ol> <p>What have...
<p>I would first suggesting getting you html and css code validated. If there are any errors in your markup, these can cause errors in the rendering.</p> <ul> <li><a href="http://jigsaw.w3.org/css-validator/" rel="noreferrer">CSS Validator</a></li> <li><a href="http://validator.w3.org/" rel="noreferrer">HTML Validator...
<p>i believe this is a font issue and a browser / OS issue.</p> <p>we know that different firefox versions are dependent on the OS - there are some firefox extensions available for Linux, some firefox extensions for windows are available. it's the font I guess.</p> <p>Try to download mtts core fonts (microsoft true ...
2,801
<p>This is going to sound like a silly question, but I'm still learning C, so please bear with me. :)</p> <p>I'm working on chapter 6 of K&amp;R (structs), and thus far through the book have seen great success. I decided to work with structs pretty heavily, and therefore did a lot of work early in the chapter with the...
<p><strong>I think what you want to do is this:</strong></p> <pre><code>void canonRect(struct rect *r) { struct rect temp; temp.lowerLeft.x = min(r-&gt;lowerLeft.x, r-&gt;upperRight.x); temp.lowerLeft.y = min(r-&gt;lowerLeft.y, r-&gt;upperRight.y); temp.upperRight.x = max(r-&gt;lowerLeft.x, r-&gt;upper...
<blockquote> <p>2.Why might I get an illegal indirection compile-time error if I try to pass in a pointer to canonRect? (IE, if I had canonRect(*r); in main().)</p> </blockquote> <p>Because, it is not the purpose of <strong>pointer</strong>.</p>
31,962
<p>Is there a command like <code>cat</code> in linux which can return a specified quantity of characters from a file?</p> <p>e.g., I have a text file like:</p> <pre><code>Hello world this is the second line this is the third line </code></pre> <p>And I want something that would return the first 5 characters, which w...
<p><code>head</code> works too:</p> <pre><code>head -c 100 file # returns the first 100 bytes in the file </code></pre> <p>..will extract the first 100 bytes and return them. </p> <p>What's nice about using <code>head</code> for this is that the syntax for <code>tail</code> matches:</p> <pre><code>tail -c 100 file...
<p>Here's a simple script that wraps up using the <code>dd</code> approach mentioned here:</p> <h1>extract_chars.sh</h1> <pre><code>#!/usr/bin/env bash function show_help() { IT=&quot; extracts characters X to Y from stdin or FILE usage: X Y {FILE} e.g. 2 10 /tmp/it =&gt; extract chars 2-10 from /tmp/it EOF ...
26,944
<p>I am trying to get system date in a C program on a MSVC++ 6.0 compiler. I am using a system call:</p> <p><strong>system("date /T")</strong> (output is e.g. 13-Oct-08 which is date on my system in the format i have set) </p> <p>but this prints the date to the i/o console. </p> <p>How do i make take this date as ...
<pre><code>#include &lt;windows.h&gt; #include &lt;iostream&gt; int main() { SYSTEMTIME systmDateTime = {}; ::GetLocalTime(&amp;systmDateTime); wchar_t wszDate[64] = {}; int const result = ::GetDateFormatW( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &amp;systmDateTime, 0, wszDate, _countof(wszDate)); if...
<p>There are a couple of ways to do this using API functions, two that jump to mind are <a href="http://msdn.microsoft.com/en-us/library/aa272978(VS.60).aspx" rel="nofollow noreferrer">strftime</a> and <a href="http://msdn.microsoft.com/en-us/library/ms776293.aspx" rel="nofollow noreferrer">GetDateFormat</a>.</p> <p>I...
23,987
<p>I'm trying to transform each element of a numpy array into an array itself (say, to interpret a greyscale image as a color image). In other words:</p> <pre><code>&gt;&gt;&gt; my_ar = numpy.array((0,5,10)) [0, 5, 10] &gt;&gt;&gt; transformed = my_fun(my_ar) # In reality, my_fun() would do something more useful arra...
<p>Does numpy.dstack do what you want? The first two indexes are the same as the original array, and the new third index is "depth".</p> <pre><code>&gt;&gt;&gt; import numpy as N &gt;&gt;&gt; a = N.array([[1,2,3],[4,5,6],[7,8,9]]) &gt;&gt;&gt; a array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) &gt;&gt;&gt; b = N...
<p>I propose:</p> <pre><code> numpy.resize(my_ar, (3,3)).transpose() </code></pre> <p>You can of course adapt the shape <code>(my_ar.shape[0],)*2</code> or whatever</p>
40,001
<p>I'm installing SVN with Apache 2.2 on windows 2003 everything seems good but when I try to login no username/password works.</p> <p>Here is some info<br /> I load this module in httpd.conf</p> <p><code>LoadModule auth_basic_module modules/mod_auth_basic.so</code><br /> and in <code>svnserv.conf</code> I have</p> <pr...
<p>I think the problem might be that you need to generate the password file using <a href="http://httpd.apache.org/docs/1.3/programs/htpasswd.html" rel="nofollow noreferrer">htpasswd</a>. Storing unencrypted passwords isn't a good thing!</p>
<p>Ok, this isnt't technically an answer to the question you've asked, but you should try installing <a href="http://www.visualsvn.com/server/" rel="nofollow noreferrer">Visual SVN Server</a>, which takes care of all of these headaches for you. Setting up an SVN server is much easier with this tool on Windows than it ...
39,812
<p>I'm sure there's a simple explanation for this, but I haven't had much luck at finding the answer yet, so I figured I'd put the word out to my colleagues, as I'm sure some of you've run into this one before.</p> <p>In my (simple) dev environment, I'm working with a handful of WCF Web Services, imported into my FB3 ...
<p>I think C++ will go out of fashion in the next 10 years just the same way as assembly did. I'm a professional game programmer for more the 15 years. In early 90's lot of people said that C is not efficient enough for games. In the late 90's same people said that C is OK but C++ is just way too slow for performance c...
<p><a href="http://www.lua.org/" rel="nofollow noreferrer">Lua</a> should be of interest to you, as you can embed it in C# and access your objects from LuaScript. </p>
46,426
<p>I've developed a windows application that uses shared memory---that is---memory mapped files for interprocess communication. I have a windows service that does some processing and periodically writes data to the memory mapped file. I have a separate windows application that reads from the memory mapped file and di...
<p>So I found the solution to my problem:</p> <p>On Windows XP, all named kernel objects such as mutex, semaphore and memory mapped objects are stored in the same namespace. So when different processes in different user sessions reference a particular object using it's name, they obtain a handle to that object. Howeve...
<p>Have you tried moving the file to a different location. Try putting it in the 'Shared Documents' folder, this seems to be the most freely accessible folder in Vista.</p>
21,243
<p>If i try to paste source code in word 2007 the spacing between the lines seems to get messed up as all new lines are spaced way apart compared to a programming text editor.</p> <p>Can somebody tell me how to paste source code in word 2007 preserving the formatting and the spacing between lines?</p>
<p>The problem is that each line is a paragraph, and often in Word, paragraphs have a certain amount of Space Before. If you choose a style that has 0 space before, and 0 space after, it should look fine.</p>
<p>If you're using VIM you can use <code>2html.vim</code> which comes bundled with VIM:</p> <pre><code>source $VIM/syntax/2html.vim </code></pre> <p>This will open a new buffer with the file in HTML that you can save or copy and paste any way you wish.</p>
35,392
<p>We're currently running with php 5.2.5. We have now encountered a bug that creates a seg fault. Our first idea at the solution is upgrading to version 5.2.6 but are skeptical of problems that it will create. We are running Apache and host a dozen or so sites.</p> <ul> <li>Will any existing code break?</li> <li>Are ...
<p>It's impossible for any of us to say definitely yes or no about your existing code breaking without performing an analysis on it first.</p> <p>This is exactly what test environments are for. If you have a test environment set up, you can perform the upgrade, then do regression testing to see if anything breaks. Wit...
<p>Thanks for everyone's input. Getting a test server is definitely on the road map. This should be a good argument for finally getting one setup. We're a small enough company where we could easily get away with only having one, but there are so many advantages to having a test server.</p> <p>Unfortunately it will be ...
18,125
<p>I own a delta 3D printer. The problem is that, at the beginning of a print the extruder outputs dirty filament. I want a clean filament flow at the start of my prints!</p> <p>How can I make the hotend exit the print surface (glass plate) by 10mm, extrude the bad filament and go back to printing again? Can this be d...
<p>You can achieve this using the <code>G1</code> command. I don't know your exact printer, but you should be able to use something like this (add to the start G-code in your slicer):</p> <pre><code>G1 X0 Y62 Z0.2 F9000 ; Move slightly past edge of bed G92 E0 ; Zero extruder position G0 E1 F100 ; Extrude 1mm of fila...
<p>A lot of slicers will have a Wipe option. Here are some examples:</p> <ul> <li><p>See <a href="https://jinschoi.github.io/simplify3d-docs/" rel="nofollow noreferrer">Unofficial Simplify3D Documentation</a>. Go to the section talking about <em>Wipe Nozzle</em>, under the heading <strong>Extruder Tab</strong></p> <b...
357
<p>My if statement is always evaluating to false and not entering the <code>&lt;span&gt;</code> block. Because of which, I'm not able to get the value of "index" in the if condition, I've tried every thing appending index with # and %. Can anybody suggest the solution?</p> <pre><code>&lt;c:forEach var="index" begin="1...
<p>got it actully it is some conflict in the tags</p> <p>it should be like</p> <pre><code>&lt;c:forEach var="index" begin="1" end="&lt;%=a%&gt;" step="1" varStatus="status"&gt; &lt;c:choose&gt; &lt;c:when test="${page_id==index}"&gt; ...
<p>The test value isn't evaluatable, it's just a string to the page. </p> <p>Edit, you have you use strut's syntax. </p> <p>Add "%{}", like so:</p> <pre><code>&lt;s:if test="%{index == 1}"&gt; </code></pre>
43,751
<p>I'm using th WebBrowser control in the .net 2.0 framework. Is it possible to change the printing behavior so it always prints to the default printer, without showing any dialog to the user? This is for a kiosk so there will always be a printer directly connected to the Kiosk, and printing should be seemless to the ...
<p>Get the default PrinterName using the method shown here <a href="http://msdn.microsoft.com/en-" rel="nofollow noreferrer">http://msdn.microsoft.com/en-</a><a href="http://us/library/system.drawing.printing.printersettings.isdefaultprinter.aspx">us/library/system.drawing.printing.printersettings.isdefaultprinter.aspx...
<p>Simply use the WebBroser.Print() method.<br /> I've used it before and it directly prints to the default printer.</p>
26,980
<p>What are the most common browser compatibility issues across the major desktop browsers?</p> <p>No dups please. Up-vote problems you've run into. I'm hoping for the list to self-sort. "IE sux" is not a pitfall, but a call for down-vote.</p> <p>[Edit] Yes, I know it's a poll - I'm not posting answers in this to gat...
<p>Transparent PNGs in Internet Explorer 6, especially because the common, JavaScript-less workaround of using the AlphaImageLoader can have the side effect of <a href="http://blogs.cozi.com/tech/2008/03/transparent-png.html" rel="nofollow noreferrer">locking up IE6</a>.</p>
<p>When performing an XMLHttpRequest and executing a function 'onreadystatechange' the XMLHttpRequest.responseText property contains the data loaded at that point in Firefox, but not in IE (and maybe Safari). </p> <p>This prevents the capture of partial data in those browsers for use in displaying an execution progres...
18,623
<p>I am trying to print with clay.</p> <p>These are my Slic3r speed settings,</p> <p><a href="https://i.stack.imgur.com/FE115.png" rel="nofollow noreferrer" title="Slic3r speed settings"><img src="https://i.stack.imgur.com/FE115.png" alt="Slic3r speed settings" title="Slic3r speed settings"></a></p> <p>Other informa...
<p>No, you did not set all the settings to the same speed, there are 2 different print speeds defined:</p> <ul> <li>Infill Solid: <strong>60</strong> mm/s</li> <li>First Layer Speed: <strong>30%</strong></li> </ul> <p>This means, that some walls will be printed 10 mm/s faster than the others, and that <em>first layer...
<p>Make sure that on the Print Settings tab, under Advanced, you have set the Extrusion widths for your custom nozzle settings.</p>
1,117
<p>With the following code:</p> <pre><code>Dim x As System.Xml.Linq.XElement = _ &lt;div&gt; &lt;%= message.ToString() %&gt; &lt;/div&gt; Dim m = x.ToString() </code></pre> <p>...if message is HTML, then the &lt; and > characters get converted to <code>&amp;lt;</code> and <code>&amp;rt;</code>. </p> <p>How can I fo...
<p>What is the type of your <code>message</code> variable? If <code>message</code> is an <code>XElement</code>, then just leave off the <code>.ToString</code> call like this:</p> <pre><code>Dim x As System.Xml.Linq.XElement = _ &lt;div&gt; &lt;%= message %&gt; &lt;/div&gt; Dim m = x.ToString() </code>...
<p>You need to open the HTML snippit as an XML document and append the document node to the Div node you are creating.</p> <p>If you want to add XML (or HTML) to an existing XML document then you have to add it as XML and not as text (cause that gets encoded).</p>
36,254
<p>I have two raw sound streams that I need to add together. For the purposes of this question, we can assume they are the same bitrate and bit depth (say 16 bit sample, 44.1khz sample rate).</p> <p>Obviously if I just add them together I will overflow and underflow my 16 bit space. If I add them together and divide...
<p>You should add them together, but clip the result to the allowable range to prevent over/underflow.</p> <p>In the event of the clipping occuring, you <strong>will</strong> introduce distortion into the audio, but that's unavoidable. You can use your clipping code to "detect" this condition and report it to the user...
<p>I'd say just add them together. If you're overflowing your 16 bit PCM space, then the sounds you're using are already incredibly loud to begin with and you should attenuate them. If that would cause them to be too soft by themselves, look for another way of increasing the overall volume output, such as an OS setti...
49,210
<p>I have IIS6 configured such that browsing to <a href="http://localhost:8082/Reports" rel="nofollow noreferrer">http://localhost:8082/Reports</a> gets me the reporting services default home page, which is all as expected. However, when I try to publish a report via Microsoft Business Intelligence Visual Studio 2005 I...
<p>Have you tried to publish you report to:</p> <p><a href="http://localhost:8082/ReportsServer" rel="nofollow noreferrer">http://localhost:8082/ReportsServer</a></p> <p>"/ReportsServer" is the webservice for Reporting Services. "/Reports" is the front end.</p>
<p>Step 1 : Just log in to the corresponding server</p> <p>step 2 : Do the settings in internet explorer[IE] browser, Tools => Internet Options => Select connections tab => Click on LAN settings => Just check the check box use a proxy server</p> <p>Step 3 : Issue will get fixed</p>
14,476
<p>I want my errors to float above, left-justified, the input field that doesn't validate. How can I do this?</p> <p>If I can't, how can I turn the errors off? I still want the fields to validate (and highlight on error), but not for the actual error messages to display. I couldn't seem to find anything in the jQue...
<p>You want the errorPlacement option, and perhaps errorContainer and errorElement for further customization.</p> <p>See <a href="http://docs.jquery.com/Plugins/Validation/validate#toptions" rel="noreferrer">http://docs.jquery.com/Plugins/Validation/validate#toptions</a></p>
<p>Use the errorPlacement property for your jQuery validation call, as J Cooper suggested:</p> <pre><code>$(...).validate({ errorPlacement: function(error, element) { error.insertBefore(element); } }); </code></pre> <p>And CSS to style the error (in your stylesheet, or to the individual elements):</p>...
39,882
<p>There are many SCM systems out there. Some open, some closed, some free, some quite expensive. Which one <em>(please choose only one)</em> would you use for a 3000+ developer organization with several sites (some behind a very slow link)? Explain why you chose the one you chose. (Give some reasons, not just "because...
<ul> <li>For such a huge installation, there are at least the following major requirements: <strong>Data safety</strong>, maturity, robustness, <strong>Scalability</strong>, <strong>price</strong> (a per seat licence vs. open source always makes a huge difference regardless of the price per seat), ease of administratio...
<p>If they're all working on the same product, probably Perforce.</p> <p>If there are lots of smaller projects (2 to 50), I'd run several Subversion (SVN) boxes.</p>
9,119
<p>I have a FlashForge CreatorX (MakerBot clone) that's been working fine for about 15 months. Int he past month, I started noticing "thin" layers in some of my ABS prints. I finally tracked the issue down to the extruder gear grinding the filament (after a while, enough filament had ground off that the gear teeth were...
<p>Usually there is no need to clean the hotend, as filament sticks well to itself rather than to the inside of the hotend. If there are remains - the simplest way to clean it up is to extrude 5-10 cm of new filament, which will gather all remainings clean the hotend.</p> <p>The above concerns changing filament in the...
<p>Or you can use atomic nozle clianning!It woks fine for me :) <a href="https://www.youtube.com/watch?v=04T8zdgyh3E" rel="nofollow">https://www.youtube.com/watch?v=04T8zdgyh3E</a></p>
293
<p>I'm trying to format numbers. Examples:</p> <pre><code>1 =&gt; 1 12 =&gt; 12 123 =&gt; 123 1234 =&gt; 1,234 12345 =&gt; 12,345 </code></pre> <p>It strikes as a fairly common thing to do but I can't figure out which filter I'm supposed to use.</p> <p>Edit: If you've a generic Python way to do this, I'm h...
<p>Django's contributed <a href="http://docs.djangoproject.com/en/dev/ref/contrib/humanize/#ref-contrib-humanize" rel="noreferrer">humanize</a> application does this:</p> <pre><code>{% load humanize %} {{ my_num|intcomma }} </code></pre> <p>Be sure to add <code>'django.contrib.humanize'</code> to your <code>INSTALLED...
<p>Be aware that changing locale is process-wide and not thread safe (iow., can have side effects or can affect other code executed within the same process).</p> <p>My proposition: check out the <a href="http://babel.edgewall.org/" rel="nofollow noreferrer">Babel</a> package. Some means of integrating with Django temp...
45,081
<p>I know we can use tools like JProfiler etc. Is there any tutorial on how to configure it to display the memory usage just by remote monitoring?</p> <p>Any idea?</p>
<p>you have VisualGC, it's not very advanced but you can see the memory usage of your application (garbage,old, perm etc...)</p> <p><a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstatd.html" rel="noreferrer">http://java.sun.com/performance/jvmstat/visualgc.html</a></p> <p>to resume : you launch a daemo...
<p>I've heard good things of VisualVM and here is an article on how to it up remotely:</p> <p><a href="http://www.codefactorycr.com/java-visualvm-to-profile-a-remote-server.html" rel="nofollow">Java VisualVM to profile a remote server</a></p> <p><strong>EDIT</strong>: I wrote a blog post on how to setup remote profil...
23,608
<p>I obtained the following wire 22 Gauge Stranded Hookup Wire from Radio Shack:</p> <pre><code>Type/Style: AWM/1007 Wire Gauge: 22 AWG Insulation Thickness: AVE. 0.42 mm Rated Voltage: 300V Temperature Rating: 80°C / 176°F </code></pre> <blockquote> <p>Use Limitation: Internal wiring of appliances; or where ex...
<p>22awg wiring is good for a max of 7A in this usage case. Your power supply can provide 30A. So it is definitely not large enough wire gauge for good wiring practice -- in the event of a short, you want the PSU's over-current protection to kick in before the wiring overheats. That would mean 14ga between the PSU and ...
<p>That should be fine for powering RAMPS, steppers and extruders but it is on the thin side. To err on the side of caution you should use somewhat ticker wires. However, you should definitely use thicker wires for the heated bed connection.</p>
234
<p>I need a way to easily export and then import data in a MySQL table from a remote server to my home server. I don't have direct access to the server, and no utilities such as phpMyAdmin are installed. I do, however, have the ability to put PHP scripts on the server.</p> <p>How do I get at the data?</p> <p><em>I as...
<p>You could use SQL for this:</p> <pre><code>$file = 'backups/mytable.sql'; $result = mysql_query("SELECT * INTO OUTFILE '$file' FROM `##table##`"); </code></pre> <p>Then just point a browser or FTP client at the directory/file (backups/mytable.sql). This is also a nice way to do incremental backups, given the filen...
<p>I use mysqldump via the command line :</p> <pre><code>exec("mysqldump sourceDatabase -uUsername -p'password' &gt; outputFilename.sql"); </code></pre> <p>Then you just download the resulting file and your done.</p>
10,764
<p>I want to attach an xslt stylesheet to an XML document that I build with XMLBuilder. This is done with a Processing Instruction that looks like</p> <pre><code>&lt;?xml-stylesheet type='text/xsl' href='/stylesheets/style.xslt' ?&gt; </code></pre> <p>Normally, I'd use the <code>instruct!</code> method, but <code>:x...
<p>I'm not sure this will solve your problem since I don't know the instruct! method of that object, but :'xml-stylesheet' is a valid ruby symbol.</p>
<p>If using the <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/AtomFeedHelper.html#method-i-atom_feed" rel="nofollow"><code>atom_feed</code></a> helper, you can pass this in the <code>instruct</code> option:</p> <pre><code>atom_feed(instruct: { 'xml-stylesheet' =&gt; {type: 'text/xsl', href: 'style...
17,173
<p>I was wondering if there is a smart way to find out</p> <p>There is a 1/4 chance something happens.</p> <p>I know we can do this with rand() % 4 and checking if it is equal to 0, but is there a way without using rand()? In c++, thanks.</p>
<p>If you mean you want to avoid the inherent crappiness of many <code>rand()</code> implementations, you should probably look into <a href="http://www.boost.org/doc/libs/1_37_0/libs/random/index.html" rel="nofollow noreferrer">the Boost Random library</a>, which has several high-quality pRNGs (pseudo-random number gen...
<p>Umm... write your own <code>rand()</code>? You will need <b>some</b> kind of random function!</p>
42,336
<p>Is there any way to get own phone number by standard APIs from iPhone SDK?</p>
<p>At the risk of getting negative marks, I want to suggest that the highest ranking solution (currently the first response) violates the latest SDK Agreement as of Nov 5, 2009. Our application was just rejected for using it. Here's the response from Apple:</p> <blockquote>"For security reasons, iPhone OS restricts an...
<p>AppStore will reject it, as it's reaching outside of application container.</p> <blockquote> <p>Apps should be self-contained in their bundles, and may not read or write data outside the designated container area</p> </blockquote> <p>Section 2.5.2 : <a href="https://developer.apple.com/app-store/review/guidelin...
23,486
<p>When writing database queries in something like TSQL or PLSQL, we often have a choice of iterating over rows with a cursor to accomplish the task, or crafting a single SQL statement that does the same job all at once.</p> <p>Also, we have the choice of simply pulling a large set of data back into our application an...
<p>The main reason that I'm aware of is that set-based operations can be optimised by the engine by running them across multiple threads. For example, think of a quicksort - you can separate the list you're sorting into multiple "chunks" and sort each separately in their own thread. SQL engines can do similar things wi...
<p>The idea behind preferring to do the work in queries is that the database engine can optimize by reformulating it. That's also why you'd want to run EXPLAIN on your query, to see what the db is <em>actually</em> doing. (e.g. taking advantage of indices, table sizes and sometimes even knowledge about the distribution...
4,390
<p>I'm sick of waiting hours for Flash to publish. .NET / VisualStudio projects are WAAAAY faster - is that only compiling the classes that have changed?</p> <p>Update: Does the Flash IDE re-encode all your sounds and images every time you publish? Can't it cache them somewhere?</p>
<p>In Flash CS4, disabling Warnings Mode speeds up code compilation by about 30% (still quite slow). Strict Mode also, but I'm not sure to what extent.</p> <p>As for library assets, the optimal speed is achieved by setting JPEGs to "Use imported JPEG data" and PNGs/GIFs as "Loosless PNG/GIF". As for sounds, I'm not 10...
<p>It all depends on your project. I know of some animators that use Flash for publishing broadcast content and that usually takes a long time to publish. There's no getting around it for them. Otherwise, if it takes hours to publish an SWF that will be viewed on the web, then you're probably not going about things the...
40,538
<p>When we are developing new sites or testing changes in new ones that involve css after the new code is committed and someone goes to check the changes they always see a cached version of the old css. This is causing a lot of problems in testing because people never are sure if they have the latest css on screen (I k...
<p>If you're serving your CSS from static files (or anything that the query string doesn't matter for), try varying that to ensure that the browser makes a fresh request, as it will think that it's pulling a completley different resource, so have for example:</p> <p>"styles.css?token=1234" in the CSS reference in your...
<p>Its not a great solution, but I've gotten around this before at the page level by adding a querystring to the end of the call to the CSS file:</p> <pre><code> &lt;link href="/css/global.css?id=3939" type="text/css" rel="stylesheet" /&gt; </code></pre> <p>Then I'd randomize the id value so that it always loads a di...
14,322
<p>In .net (C#), If you have two types discovered through reflection is it possible to determine if one can be cast to the other? (implicit and/or explicit).</p> <p>What I'm trying to do is create a library that allows users to specify that a property on one type is mapped to a property on another type. Everything is ...
<pre><code>public static bool HasConversionOperator( Type from, Type to ) { Func&lt;Expression, UnaryExpression&gt; bodyFunction = body =&gt; Expression.Convert( body, to ); ParameterExpression inp = Expression.Parameter( from, "inp" ); try { // If...
<p>So, probably you mean duck typing or structural typing? There are several implementations that will dynamically generate the required proxies.</p> <p>For example: </p> <p><a href="http://www.deftflux.net/blog/page/Duck-Typing-Project.aspx" rel="nofollow noreferrer">http://www.deftflux.net/blog/page/Duck-Typing-Pro...
37,313
<p>I am looking for a method to compare and sort UTF-8 strings in C++ in a case-insensitive manner to use it in a <a href="http://www.sqlite.org/c3ref/create_collation.html" rel="noreferrer">custom collation function in SQLite</a>.</p> <ol> <li>The method should <em>ideally</em> be locale-independent. However I won't ...
<p>What you really want is logically impossible. There is no locale-independent, case-insensitive way of sorting strings. The simple counter-example is "i" &lt;> "I" ? The naive answer is no, but in Turkish these strings are unequal. "i" is uppercased to "İ" (U+130 Latin Capital I with dot above)</p> <p>UTF-8 strings ...
<p>I don't think there's a standard C/C++ library function you can use. You'll have to roll your own or use a 3rd-party library. The full Unicode specification for locale-specific collation can be found here: <a href="http://www.unicode.org/reports/tr10/" rel="nofollow noreferrer"><a href="http://www.unicode.org/repo...
21,842
<p>Aside from executing XP_CmdShell, which I have disabled in my SQL 2005 installation, what could a malicious user who gains DBO rights to my database do:</p> <ul> <li>To my database,</li> <li>To my server?</li> </ul> <p>I'm assessing the worst-case security risk of someone obtaining DBO to justify running a "least-...
<p>he can run any XP_ sproc so it can mess up the registry and mess up your whole server for one thing. drop/change tables, etc... </p>
<p>To put it bluntly, if he owns your database, he <em>pwns</em> your database. That is to say, you can kiss your data good-bye.</p>
37,835
<p>What's your preferred way of wrapping lines of code, especially when it comes to long argument lists?</p> <p>There has been several questions relating to wrapping lines (such as <a href="https://stackoverflow.com/questions/268284/when-writing-code-do-you-wrap-text-or-not">When writing code do you wrap text or not?<...
<p>The option 3 suggested</p> <pre><code>int SomeReturnValue = SomeMethodWithLotsOfArguments( Argument1, Argument2, Argument3, Argument4 ); </code></pre> <p>is a better way as it gives a good feel. If the lengths of arguments are more or less same, then we can put them together so that they line up as...
<p>In functions with long parameter list, I wrap after each one or two parameters for readability (always keeping the same number of parameters on each line):</p> <pre><code>int SomeReturnValue = SomeMethodWithLotsOfArguments(Argument1, Argument2, ...
35,935
<p>I currently have heavily multi-threaded server application, and I'm shopping around for a good multi-threaded memory allocator.</p> <p>So far I'm torn between:</p> <ul> <li>Sun's umem</li> <li>Google's tcmalloc</li> <li>Intel's threading building blocks allocator</li> <li>Emery Berger's hoard</li> </ul> <p>From w...
<p>I've used tcmalloc and read about Hoard. Both have similar implementations and both achieve roughly linear performance scaling with respect to the number of threads/CPUs (according to the graphs on their respective sites).</p> <p>So: if performance is really that incredibly crucial, then do performance/load testing...
<p>Maybe this is the wrong way to approach what you are asking, but maybe a different tactic could be employed altogether. If you are looking for a really fast memory allocator maybe you should ask why you need to be spending all that time allocating memory when you could perhaps just get away with stack allocation of ...
17,731
<p>I want to make a JavaScript application that's not open source, and thus I wish to learn how to can obfuscate my JS code? Is this possible?</p>
<p><strong>Obfuscation:</strong></p> <p><strike> Try <a href="http://yuilibrary.com/" rel="noreferrer"><strong>YUI Compressor</strong></a>. It's a very popular tool, built, enhanced and maintained by the Yahoo UI team.</p> <p>You may also use:</p> <ul> <li><a href="http://closure-compiler.appspot.com/home" rel="norefe...
<p>I'm under the impression that some enterprises (e.g.: JackBe) put encrypted JavaScript code inside *.gif files, rather than JS files, as an additional measure of obfuscation.</p>
23,620
<p>I need to generate a new WSDL file in the document/literal style based on an old RPC/encoded one. I've viewed the other WSDL questions here - and read <a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/" rel="noreferrer">http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/</a...
<p>This technical article may help you:<br> <a href="https://msdn.microsoft.com/en-us/library/ms996466.aspx#rpc_literal_topic3" rel="nofollow noreferrer"><strong>Converting RPC/literal to Document/literal</strong></a></p>
<p>Use <a href="https://github.com/Taron133/CWSDLGeneratorDocument" rel="nofollow">CWSDLGeneratorDocument.php</a> for generate WSDL file in DOCUMENT/LITERAl style and use standart library JAX-WS in java 1.7.</p> <p>It's simply.</p>
37,001
<p>My zune just updated to 3.0 (didn't even realize they were releasing something new!) and the update came with two games, but the Zune marketplace does not have games. </p> <p>Where do I go to get started, and what are the capabilities of the Zune in terms of games/apps?</p>
<p>Well, first, you must download the Microsoft XNA 3.0 CTP. Read the documentation, which will explain the capabilities. But, from memory:</p> <ul> <li>No hardware accelerated 3d (obviously, you can create a software 3d engine and then render the result to a 2d sprite, but... Don't expect much in terms of performance...
<p>I was hoping someone here would have better resources, but as this seems to be a new area of development, <a href="http://blog.paranoidferret.com/index.php/2008/09/19/zune-game-development-getting-started/" rel="nofollow noreferrer">here's one resource</a> that appears to give all the steps for a newbie to get start...
17,257
<p>I'm talking about testing a package that you're building, especially one that spawns a daemon and/or fiddles with init.d.</p> <p>Do you log into some sort of chroot? Do you create a virtualized distribution and tear it down? How do you test your runtime dependencies and test suite without fouling up your dev machin...
<p>A virtualised machine, which you reset to a "clean" state after testing, would be the easiest. VMWare and Parallels "Snapshot" features is perfect for this..</p> <p>You would install Debian or Ubuntu, then take a Snapshot (How-to for <a href="http://www.vmware.com/support/ws5/doc/ws_preserve_sshot_taking.html" rel=...
<p>chroots are commonly used for package testing.</p>
42,687
<p>In C and C++ you can tell the compiler that a number is a 'long' by putting an 'l' at the end of the number. e.g long x = 0l;</p> <p>How can I tell the C# compiler that a number is a byte?</p>
<p>According to the <a href="http://msdn.microsoft.com/en-us/library/aa664674(VS.71).aspx" rel="noreferrer">C# language specification</a> there is no way to specify a byte literal. You'll have to cast down to byte in order to get a byte. Your best bet is probably to specify in hex and cast down, like this:</p> <pre>...
<p>MSDN uses <a href="http://msdn.microsoft.com/en-us/library/5bdb6693(VS.71).aspx" rel="nofollow noreferrer">implicit conversion</a>. I don't see a <a href="http://msdn.microsoft.com/en-us/library/aa664674(VS.71).aspx" rel="nofollow noreferrer">byte type suffix</a>, but you might use an explicit cast. I'd just use a 2...
18,496
<p>A bit of background first:</p> <ul> <li><p>I am using "base" code from a remote SVN repository, not under my control. The code is not tagged (yet), so I always need to keep up with the trunk. </p></li> <li><p>For a number of reasons (the most important being that our local extensions to the code are of a "niche" na...
<p>I did this using git svn, with my development done in a git repository. The remote development is done in subversion. I made a git svn clone of the subversion repository, which I push to a real git repository. A cronjob runs "git svn rebase &amp;&amp; git push" every now and again to create a git mirror of the subve...
<p>You can have your local repository where you commit your changes, as you already have done. Further you would do a periodic merge from the base repository in order to merge the changes done in the base trunk into your local repository.</p> <p>The only difficult thing is that you need to keep track of the revisions ...
41,496
<p>my company started recently to use Git for source version control, and due to the incompetence of the coders - that's me and my boss :-P - we have a really nice spaghetti of files being overwritten here and there.<br> Is there a way to mark certain files as 'untouchable' so if when updating a branch from another eit...
<p>You can do exactly what you're asking for with hooks, but I don't know if that solves your real problem.</p> <p>If it's as simple as your in-progress files getting munged, that's easy: Never pull/merge/rebase with uncommitted changes. Always commit before bringing in any other code.</p>
<p>Sounds like what you want is to stop git from tracking the 'untouchable' files. This is done by using the <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rm.html" rel="nofollow noreferrer" title="git rm command">git rm command</a>.</p> <pre><code>git rm &lt;file&gt; </code></pre> <p>If that is what yo...
41,624
<p>I'm a software developer who has a background in usability engineering. When I studied usability engineering in grad school, one of the professors had a mantra: "You are not the user". The idea was that we need to base UI design on actual user research rather than our own ideas as to how the UI should work.</p> <p>...
<p>I think one of the biggest examples is that expert users tend to <strong>play with an application</strong>. </p> <p>They say, "Okay, I have this tool, what can I do with it?"</p> <p>Your average user sees the ecosystem of an operating system, filesystem, or application as a big scary place where they are likely t...
<p>pretty much anything at the O/S level in Linux is a good example, from the choice of names ("grep" obviously means "search" to the user!) to the choice of syntax ("rm *" is good for you!)</p> <p>[i'm not hatin' on linux, it's just chock full of unix-legacy un-usability examples]</p>
47,224
<p>I need to parse a large amount of text that uses HTML font tags for formatting,</p> <p>For example:</p> <pre><code>&lt;font face="fontname" ...&gt;Some text&lt;/font&gt; </code></pre> <p>Specifically, I need to determine which characters would be rendered using each font used in the text. I need to be able to han...
<p>I have not used it, but I have seen the <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow noreferrer">HTML Agility Pack</a> frequently mentioned for this type of thing.</p>
<p>Not sure if this is applicable to your situation as I don't know what the intended use is, but what about the use of XSLT tempaltes?</p>
28,263
<p>I see the phrase "programming idiom" thrown around as if it is commonly understood. Yet, in search results and stackoverflow I see everything...</p> <p>From micro:</p> <ul> <li>Incrementing a variable</li> <li>Representing an infinite loop</li> <li>Swapping variable values</li> </ul> <p>To medium:</p> <ul> <li><...
<p>A programming idiom is the usual way to code a task in a specific language. For example a loop is often written like this in C:</p> <pre><code>for (i=0; i&lt;10; i++) </code></pre> <p>PHP will understand a similar construct:</p> <pre><code>for ($i = 1; $i &lt;= 10; $i++) </code></pre> <p>But it is discouraged in...
<p>It comes from <a href="https://en.wiktionary.org/wiki/idiomatic" rel="nofollow noreferrer">idiomatic</a> the meaning of the word <a href="https://en.wiktionary.org/wiki/idiom" rel="nofollow noreferrer">idiom</a> in programming can be summed up as phrase that carries meaning and implications that is more than the sum...
38,839
<p>I'm in the process of moving an application from PHP to Java and there is heavy use of regular expressions in the code. I've run across something in PHP that doesn't seem to have a java equivalent:</p> <pre><code>preg_replace_callback() </code></pre> <p>For every match in the regex, it calls a function that is pa...
<p><strong>IMPORTANT</strong>: As pointed out by <a href="https://stackoverflow.com/questions/375420/java-equivalent-to-phps-preg-replace-callback/375479?noredirect=1#comment2566951_375479">Kip</a> in the comments, this class has an infinite loop bug if the matching regex matches on the replacement string. I'll leave i...
<p>Here is the final result of what I did with your suggestion. I thought it would be nice to have out here in case someone has the same problem. The resulting calling code looks like:</p> <pre><code>content = ReplaceCallback.find(content, regex, new ReplaceCallback.Callback() { public String matches(MatchResult...
49,130
<p>We have some input data that sometimes appears with &amp;nbsp characters on the end.</p> <p>The data comes in from the source system as varchar() and our attempts to cast as decimal fail b/c of these characters.</p> <p>Ltrim and Rtrim don't remove the characters, so we're forced to do something like:</p> <pre><co...
<p><a href="http://www.lazydba.com/sql/1__4390.html" rel="noreferrer">This page</a> has a sample of how you can remove non-alphanumeric chars:</p> <pre><code>-- Put something like this into a user function: DECLARE @cString VARCHAR(32) DECLARE @nPos INTEGER SELECT @cString = '90$%45623 *6%}~:@' SELECT @nPos = ...
<p>For large datasets I have had better luck with this function that checks the ASCII value. I have added options to keep only alpha, numeric or alphanumeric based on the parameters.</p> <pre><code>--CleanType 1 - Remove all non alpanumeric -- 2 - Remove only alpha -- 3 - Remove only numeric CREATE F...
7,555
<p>I have a snippet looking something like the below.</p> <pre><code>string bodyTypeAssemblyQualifiedName = "XXX.XX.XI.CustomerPayment.Schemas.r1.CustomerPayments_v01, XXX.XX.XI.CustomerPaym" + "ent.Schemas.r1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ac564f277cd4488" + "e"; </c...
<p>This works:</p> <blockquote> <p>(?&lt;=string\sbodyTypeAssemblyQualifiedName\s=\s)(?s:[^;]*)(?=;)</p> </blockquote> <p>Which is the equivalent of:</p> <ol> <li>After the string "string bodyTypeAssemblyQualifiedName = "</li> <li>Turn on single line (treat \r\n as any other character) ( this is what (?s: ) does)<...
<p>You can try</p> <pre><code>bodyTypeAssemblyQualifiedName\s=\s(?&lt;location&gt;[.\n]*?); </code></pre> <p>Or you set the <code>RegexOptions.Singleline</code> for your pattern.</p> <blockquote> <p><strong>RegexOptions.Singleline</strong> - Specifies single-line mode. Changes the meaning of the dot (.) so it matc...
35,546
<p>Which algorithm does the JavaScript <code>Array#sort()</code> function use? I understand that it can take all manner of arguments and functions to perform different kinds of sorts, I'm simply interested in which algorithm the vanilla sort uses.</p>
<p>I've just had a look at the WebKit (Chrome, Safari …) <a href="http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp?rev=138530#L647" rel="noreferrer">source</a>. Depending on the type of array, different sort methods are used:</p> <p><a href="http://trac.webkit.org/browser/trunk/Sou...
<p>I think that would depend on what browser implementation you are refering to.</p> <p>Every browser type has it's own javascript engine implementation, so it depends. You could check the sourcecode repos for Mozilla and Webkit/Khtml for different implementations.</p> <p>IE is closed source however, so you may have ...
29,047
<p>Is it possible to produce an alert similar to JavaScript's alert("message") in python, with an application running as a daemon.</p> <p>This will be run in Windows, Most likely XP but 2000 and Vista are also very real possibilities.</p> <p>Update:<br /> This is intended to run in the background and alert the user w...
<p>what about this:</p> <pre><code>import win32api win32api.MessageBox(0, 'hello', 'title') </code></pre> <p>Additionally:</p> <pre><code>win32api.MessageBox(0, 'hello', 'title', 0x00001000) </code></pre> <p>will make the box appear on top of other windows, for urgent messages. See <a href="http://msdn.microsoft....
<p>Start an app as a background process that either has a TCP port bound to localhost, or communicates through a file -- your daemon has the file open, and then you <code>echo "foo" &gt; c:\your\file</code>. After, say, 1 second of no activity, you display the message and truncate the file.</p>
21,359
<p>On Windows XP when a process crashes, we get a dialog box with a link:</p> <p>"To view technical information about the error report, click here."</p> <p>The "click here" link brings up a whole lot of information in a window, but no obvious way to save it to a file. Is there a way? It would be very nice to be able ...
<p>If you want to implement a while loop, you will need to use recursion in the preprocessor. The easiest way to do recursion is to use a deferred expression. A deferred expression is an expression that requires more scans to fully expand:</p> <pre><code>#define EMPTY() #define DEFER(id) id EMPTY() #define OBSTRUCT(id...
<p>I found this scheme useful when the compiler got cranky and wouldn't unroll certain loops for me</p> <blockquote> <p>#define REPEAT20(x) { x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;}</p> <p>REPEAT20( val = pleaseconverge(val) );</p> </blockquote> <p>But IMHO, if you need something much more complicated than t...
41,286
<p>I am currently using the following code to create a web request:</p> <pre><code>Dim myRequest As WebRequest = WebRequest.Create("http://foo.com/bar") Dim myResponse As WebResponse = myRequest.GetResponse() </code></pre> <p>The problem is that this "locks" up the program until the request is completed (and program ...
<p>You'll use BeginGetResponse to add a AsyncCallback, which basically points to some other method in your code that will be called when the WebRequest returns. There is a good <a href="http://www.sitepoint.com/forums/showpost.php?p=3753215" rel="nofollow noreferrer">sample here</a>.</p> <p><a href="http://www.sitepoi...
<p>myRequest.BeginGetResponse()</p> <p>You'll also need to call EndGetReponse() when the request is finished (determined via WaitHandle, callback, or polling).</p>
15,607
<p>What is the Java analogue of .NET's XML serialization?</p>
<p><strong>2008 Answer</strong> The "Official" Java API for this is now JAXB - Java API for XML Binding. See <a href="http://docs.oracle.com/javase/tutorial/jaxb/TOC.html" rel="noreferrer">Tutorial by Oracle</a>. The reference implementation lives at <a href="http://jaxb.java.net/" rel="noreferrer">http://jaxb.java.net...
<pre><code>public static String genXmlTag(String tagName, String innerXml, String properties ) { return String.format("&lt;%s %s&gt;%s&lt;/%s&gt;", tagName, properties, innerXml, tagName); } public static String genXmlTag(String tagName, String innerXml ) { return genXmlTag(tagName, innerXml, ""); } public st...
5,636
<p>Is there a library function that performs binary search on a list/tuple and return the position of the item if found and 'False' (-1, None, etc.) if not?</p> <p>I found the functions bisect_left/right in the <a href="http://docs.python.org/library/bisect.html" rel="noreferrer">bisect module</a>, but they still retu...
<p><code>bisect_left</code> finds the first position <code>p</code> at which an element could be inserted in a given sorted range while maintaining the sorted order. That will be the position of <code>x</code> if <code>x</code> exists in the range. If <code>p</code> is the past-the-end position, <code>x</code> wasn't ...
<pre><code>''' Only used if set your position as global ''' position #set global def bst(array,taget): # just pass the array and target global position low = 0 high = len(array) while low &lt;= high: mid = (lo+hi)//2 if a[mid] == target: position = mid ...
26,100
<p>I have a repository of files which are unrelated to each other but are common to multiple projects. Each project might only need a subset of these files. For example:</p> <pre><code>/myRepo: /jquery.js /jquery.form.js /jquery.ui.js </code></pre> <p>Project A requires <code>jquery.js</code> and <code>jq...
<p>Don't complicate yourself. Either pull out all files (what is the disadvatage of this ? a few more 100s of Ks of space ?), or divide the files into several directories, and only check out the needed directories (using the 'externals' property) in relevant projects.</p>
<p>If I understood your question correctly, you want to share code across projects? If so, look at the svn:externals property.</p> <p><a href="http://svnbook.red-bean.com/en/1.4/svn.advanced.externals.html" rel="nofollow noreferrer">Externals explained in Subversion Red Book</a></p> <p><a href="http://www.systemwidge...
15,252
<p>When using tooltips to show a detailed description of a TreeNode, the tooltip is drawn on top of the node, as if it was completing the node's text. Also, if the text is long, the tooltip is positioned in a way that the <strong>text exceeds the screen</strong>. </p> <p>But what I need is the tooltip to show right be...
<p>I didn't find the answer I was looking for, but I somehow made it work the way I wanted.</p> <p>Before, I was trying to set up the tooltip as follows:</p> <pre><code> private void treeView1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { TreeNode node = treeView1.GetNodeAt(e.X, e.Y...
<p>You need to define a ToolTip and write an MouseOverEventHandler for the TreeView. In the MouseOverEventHandler calculate the node above which mouse is positioned, then show the description ToolTip. Also make sure you are not setting the tooltip description more than once, otherwise the behavior is quite ugly.</p> <...
19,669
<p>Maybe I just don't know .NET well enough yet, but I have yet to see a satisfactory way to implement this simple VB6 code easily in .NET (assume this code is on a form with N CommandButtons in array Command1() and N TextBoxes in array Text1()):</p> <pre><code>Private Sub Command1_Click(Index As Integer) Text1(In...
<p>Make a generic list of textboxes:</p> <pre><code>var textBoxes = new List&lt;TextBox&gt;(); // Create 10 textboxes in the collection for (int i = 0; i &lt; 10; i++) { var textBox = new TextBox(); textBox.Text = "Textbox " + i; textBoxes.Add(textBox); } // Loop through and set new values on textboxes i...
<p>Make an array of controls.</p> <pre><code>TextBox[] textboxes = new TextBox[] { textBox1, textBox2, textBox3 }; </code></pre>
6,063
<p>I use Codesmith to create our code generation templates and have had success in learning how to use the tool by looking at example templates and the built in documentation. However I was wondering if there are any other resources (books, articles, tutorials, etc.) for getting a better grasp of Codesmith?</p>
<p>Have you checked the <a href="http://community.codesmithtools.com/content/Tutorials.aspx" rel="nofollow noreferrer">codesmith community site</a></p>
<p>Depending on the templates you are using, we might have a separate website with tons of useful information like <a href="http://nettiers.com/" rel="nofollow noreferrer">nettiers.com</a> and <a href="http://plinqo.com/" rel="nofollow noreferrer">plinqo.com</a>. Also check out the <a href="http://community.codesmithto...
14,050
<p>I'm building a website that requires very basic markup capabilities. I can't use any 3rd party plugins, so I just need a simple way to convert markup to HTML. I might have a total of 3 tags that I'll allow.</p> <p>What is the best way to convert <code>==Heading==</code> to <code>&lt;h2&gt;Heading&lt;/h2&gt;</code>, ...
<p>It's not really a simple problem, because if you're going to display things back to the user, you'll need to also sanitise the input to ensure you don't create any <a href="http://en.wikipedia.org/wiki/Cross-site_scripting" rel="nofollow noreferrer">cross site scripting</a> vulnerabilities.</p> <p>That said, you co...
<p>This really depends on the Wiki syntax you're using as there are several different ones. Obviously the wiki software has this functionality somewhere; if you can't find a software package that does this for you, you could start looking for the relevant code in your wiki software.</p>
6,802
<p>I have designed database tables (normalised, on an MS SQL server) and created a standalone windows front end for an application that will be used by a handful of users to add and edit information. We will add a web interface to allow searching accross our production area at a later date.</p> <p>I am concerned that ...
<p>If you expect infrequent collisions, <a href="http://msdn.microsoft.com/en-us/library/aa0416cz.aspx" rel="noreferrer">Optimistic Concurrency</a> is probably your best bet.</p> <p>Scott Mitchell wrote a comprehensive tutorial on implementing that pattern:<br> <a href="http://www.asp.net/Learn/data-access/tutorial-21...
<p>The database will do this for you. Look at "select ... for update", which is designed just for this kind of thing. It will give you a write lock on the selected rows, which you can then commit or roll back.</p>
2,326
<p>What are the most common problems that can be solved with both these data structures?</p> <p>It would be good for me to have also recommendations on books that:</p> <ul> <li>Implement the structures</li> <li>Implement and explain the reasoning of the algorithms that use them</li> </ul>
<p>The first thing I think about when I read this question is: <em>what types of things use graphs/trees?</em> and then I think backwards to how I could use them.</p> <p>For example, take two common uses of a tree:</p> <ul> <li>The DOM</li> <li>File systems</li> </ul> <p>The DOM, and XML for that matter, resemble tr...
<p>There's a course for such things at my university: <a href="http://www.cs.washington.edu/education/courses/326/" rel="nofollow noreferrer">CSE 326</a>. I didn't think the book was too useful, but the projects are fun and teach you a fair bit about implementing some of the simpler structures. </p> <p>As for examples...
2,512
<p>I'm working on a canvas app embedded in a page. I have it so you can zoom into the drawing with the mousewheel but unfortunately this scrolls the page as it is part of an article.</p> <p>Is it possible to prevent mousewheel scrolling on the window when I'm mousewheeling on a dom element?!</p>
<p>Attach an event handler for mousewheel (Not Gecko) / DOMMouseScroll (Not IE) and prevent its default action (that is to scroll content):</p> <pre> if (element.addEventListener) element.addEventListener("DOMMouseScroll", function(event) { event.preventDefault(); }, false); else element.attachEven...
<p>I know this is old, but this may still be helpful to googlers.</p> <p>I've written a jQuery plugin to handle this: <strong><a href="https://github.com/ultrapasty/jquery-disablescroll" rel="nofollow">$.disablescroll</a></strong>.</p> <p>Not only does it handle mousewheels, but also touchmove and keypress events whi...
44,642
<p>I'm trying to create a logger for a GWT application as an exercise to evaluate GWT. What I specifically want to do is have it so that I can post messages to a client side label at any point from the server side. So, if some interesting stuff has happened on the server the client can be updated.</p> <p>My First ques...
<p>Well, there are a couple of Options. You need to get the data from the server... So you either need to poll the server, or use server push.</p> <p>Polling is pretty easy. Just use the <a href="http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/index.html?overview-summary.html" rel="noreferrer">Timer</a> cla...
<p>Polling is probably the best way to do what you're looking for. The big gotcha with GWT is that everything has to be serializable. I'm not sure if anything that can push to the browser can be easily serialized.</p>
22,703
<p>I am a college student at a school that teaches mainly in Java. One of the strong points of Java, which I quite enjoy, is the large collection of libraries. What makes these libraries especially useful is the extensive documentation and organization presented via JavaDoc. Are there any library collections for Common...
<p>No, there is no comprehensive, consistently documented library collection. The inexistence of such a thing is Common Lisp's biggest problem right now. If you're interested in helping the Lisp community, this may well be the thing to attack first.</p> <p>Also, while there are <a href="http://www.cliki.net/Document...
<p>If you are used to Java, you may give <a href="http://clojure.org" rel="nofollow noreferrer">Clojure</a> a chance and keep using the Java libraries you know.</p>
23,403
<p>What are the best practices for dealing with </p> <ol> <li>Things that should be hashed. i.e. passwords</li> </ol> <p>and </p> <ol start="2"> <li>Things that cannot be hashed, but are extremely confidential and would cause tremendous pain if compromised. i.e. credit cards, SSN, missle launch codes.</li> </ol> <p...
<p>There are built in crypto libraries you can use in .Net. There are many good symmetric and asymmetric encryption algorithms (AES, RSA, etc) Many of these algorithms let you select how strong a key you want (1024bit, 2048bit, etc).</p> <p>Storing your keys is a much dicier situation. I suggest not in a plain text...
<p>Regarding hashing, there are built in libraries for performing hash operations (much like the crypto libraries) that make it fairly straightforward to hash a value for storage.</p> <p>In addition to looking into these libraries, you should also consider adding "salt" to the hashes, which essentially means adding so...
38,912
<p>I'm getting increasingly frustrated with the limitations and verbosity required to actually commit some business logic to stored procedures, using languages such as Transact-SQL or PL/SQL. I would love to convert some current databases to Oracle and take advantage of its support for Java stored procedures, but that...
<p>There are some architectural obstacles to having more clever query languages in a database manager. The principal one is the query optimiser. One of the design constraints on SQL is that it can only use constructs that are accessible to the query optimiser. This means that the language and its capabilities are qu...
<p>DB2 for Z/OS is the database that support most languages as I know. It support COBOL,C/C++,JAVA as the store procedure, It of course also support SQL procedure.</p>
44,127
<p>I would like to flash a success message on my page.</p> <p>I am using the jQuery <code>fadeOut</code> method to fade and then remove the element. I can increase the duration to make it last longer, however this looks strange.</p> <p>What I would like to happen is have the element be displayed for five seconds, the...
<p>The new <code>delay()</code> function in jQuery 1.4 should do the trick.</p> <pre><code>$('#foo').fadeIn(200).delay(5000).fadeOut(200).remove(); </code></pre>
<p>Update for 1.6.2</p> <p>Nathan Long's answer will cause the element to pop off without obeying delay or <code>fadeOut</code>.</p> <p>This works:</p> <pre><code>$('#foo').delay(2000).fadeOut(2000); </code></pre>
6,370
<p>How do I determine using TSQL what roles are granted execute permissions on a specific stored procedure? Is there a system stored procedure or a system view I can use?</p>
<p>In 7.0 or 2000, you can modify and use the following code:</p> <pre><code>SELECT convert(varchar(100), 'GRANT ' + CASE WHEN actadd &amp; 32 = 32 THEN 'EXECUTE' ELSE CASE WHEN actadd &amp; 1 = 1 THEN 'SELECT' + CASE WHEN actadd &amp; (8|2|16) &gt; 0 ...
<p>You can try something like this. Note, I believe 3 is EXECUTE.</p> <pre><code>SELECT grantee_principal.name AS [Grantee], CASE grantee_principal.type WHEN 'R' THEN 3 WHEN 'A' THEN 4 ELSE 2 END - CASE 'database' WHEN 'database' THEN 0 ELSE 2 END AS [GranteeType] FROM sys.all_objects AS sp INNER JOIN sys.database_p...
9,283
<p>I've heard that trampolining is an ineffective way of implementing TCO. How does DrScheme (PLAI Scheme, technically) do it? Does it do it the 'right' way (that is, produce assembly code which directly branches to the tail call, instead of going through the stack and trampolining)? </p>
<p>The implementors of PLT Scheme are quite active in their <a href="http://groups.google.com/group/plt-scheme" rel="nofollow noreferrer">Google group</a>, where you can get a quick answer from the people who write the code. </p> <p>I'm not sure they read SO, though, so your best bet would probably be asking there.</p...
<p>Trampolines are used in implementations that translate Scheme code into a target language X (C, Java, etc.) that doesn't support Proper Tail Calls. PLT Scheme employs JIT-compilation - and therefore trampolines are not needed. For the exact implementation strategy used, ask the question on the PLT mailing list.</p>...
44,816
<p>I want to select the last 5 records from a table in SQL Server without arranging the table in ascending or descending order.</p>
<p>This is just about the most bizarre query I've ever written, but I'm pretty sure it gets the "last 5" rows from a table without ordering:</p> <pre><code>select * from issues where issueid not in ( select top ( (select count(*) from issues) - 5 ) issueid from issues ) </code></pre> <p>Note that...
<p>Get the count of that table </p> <pre><code>select count(*) from TABLE select top count * from TABLE where 'primary key row' NOT IN (select top (count-5) 'primary key row' from TABLE) </code></pre>
40,081
<p>How do I convert the RGB values of a pixel to a single monochrome value?</p>
<p>I found one possible solution in the <a href="http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html" rel="noreferrer">Color FAQ</a>. The <em>luminance component</em> Y (from the <em>CIE XYZ system</em>) captures what is most perceived by humans as color in one channel. So, use those coefficients:</p> <pre><co...
<p>The logic behind converting any RGB based picture to monochrome can is not a trivial linear transformation. In my opinion such a problem is better addressed by "Color Segmentation" techniques. You could achieve "Color segmentation" by k-means clustering.</p> <p>See reference example from MathWorks site.</p> <p><a...
3,509
<p>For an open source project I am looking for a good, simple implementation of a Dictionary that is backed by a file. Meaning, if an application crashes or restarts the dictionary will keep its state. I would like it to update the underlying file every time the dictionary is touched. (Add a value or remove a value). A...
<ul> <li><p><a href="http://bplusdotnet.sourceforge.net/" rel="noreferrer"><strong>bplustreedotnet</strong></a></p> <p>The bplusdotnet package is a library of cross compatible data structure implementations in C#, java, and Python which are useful for applications which need to store and retrieve persistent informatio...
<p>I am not much of a programmer, but wouldn't creating a really simple XML format to store your data do the trick?</p> <pre><code>&lt;dico&gt; &lt;dicEntry index="x"&gt; &lt;key&gt;MyKey&lt;/key&gt; &lt;val type="string"&gt;My val&lt;/val&gt; &lt;/dicEntry&gt; ... &lt;/dico&gt; </code></pre> <p>F...
12,547
<p>I have a site that I am currently working on in ASP.NET 2.0 using the usual WebForm stuff and ASP.NET AJAX 1.0. Is it possible to bind an event to a dynamically created control after the Page.Load event?</p> <p>I have a table &lt;td&gt; element that I am dynamically creating similarly to this code:</p> <pre><code>'...
<p>You need to postback the whole page after your data changes in the 'btnClick Event elsewhere on the page'. It sounds like you have an UpdatePanel and it sounds like this is catching the postback of your btnClick event handler. Put the btnClick outside the UpdatePanel or change its triggers so that your btnClick fo...
<p>You have to add the controls before Page.Load in order to maintain ViewState between postbacks, so use the OnInit event handler for that. </p> <p>But once they're added, you should be able to bind event handlers (such as OnClick) at any point during or after the Page.Load... for example in your grid's ItemDataBou...
41,630
<p>I've seen several question on here about <a href="https://stackoverflow.com/questions/tagged/exception?sort=votes">exceptions</a>, and some of them hint at <a href="https://stackoverflow.com/search?s=interrupt+exception">interrupts as exceptions</a>, but none make the connection clear.</p> <ul> <li><p>What is an in...
<p>An interupt is a CPU signal generated by hardware, or specific CPU instructions. These cause interupt handlers to be executed. Things such as I/O signals from I/O hardware generate interupts.</p> <p>An exception can be thought of as a software-version of an interupt, that only affects its process.</p> <p>I'm not s...
<p>When you are talking about interrupts and exceptions you are generally talking close to hardware level code and interrupts and exceptions are often implemented in part by hardware and part in software.</p> <p>An interrupt is an event in hardware (or manually fired in assembly) that is associated with a vector of ha...
15,241
<p>When using feature descriptors [like SIFT, SURF] - is Approximate Nearest Neighbour the fastest method to do matching between images?</p>
<p>I'd say that Euclidean distnace based nearest neighbor would be the easiest to implement, but not necessarily the fastest.</p> <p>I'd agree that approximate nearest neighbor or 'best bin first' would be the quickest at identifying which image in your background set most closely resembles the probe image.</p> <p>If...
<p>You can also see <a href="http://people.cs.ubc.ca/~mariusm/index.php/FLANN/FLANN" rel="nofollow">FLANN - Fast Library for Approximate Nearest Neighbors</a></p>
14,562
<p>How can we get the network interface name (i.e. the one that appears in the "Network connections" dialog) given the device description (i.e. the string that appears in the "Device Properties -> Connect using:" textbox)?</p> <p>We must do it in pure C/C++ language, or through some of the standard command line tools ...
<p>I was able to do this via the registry. Using GetAdaptersInfo(), which gives an IP_ADAPTER_INFO output, take the AdapterName string. This should be a GUID for the adapter. For (ipv4 at least), under HKLM\SYSTEM\CurrentControlSet\Control\Network{4D36E972-E325-11CE-BFC1-08002BE10318}\{<em>INSERT GUID HERE</em>}\Conne...
<p>I'll have to double check, but I think this might be in the registry somewhere... I'll get back to this.</p> <p>hklm/system/currentcontrolset/control/network</p> <p>might help. </p> <p>I did not find exactly what i thought I would though, sorry</p> <p>EDIT This might help too:</p> <p><a href="http://www.java2s...
49,928
<p>The company I work for has consultants that work off site. Because of policy we are not allowed to set up email forwarding so these users can receive their email. Obviously this is a problem as these users may miss important email. Can anyone recommend a way that we could inform these users they have email waitin...
<p>If they have cell phones on their person you could send them an SMS. I'm not sure how you would hook up to that but you would want to have some kind of SMPP service from whichever provider you can find. With SMPP you can actually re-encode the email and send it that way. For users with Blackberries it wouldn't be to...
<p>I'm sure these consultants have their own email accounts (be it through their consulting firm or personal). So just email them the necessary messages to those accounts.</p>
35,080
<p>While it would be very convenient to use inline functions at some situations,</p> <p>Are there any drawbacks with inline functions?</p> <p><strong>Conclusion</strong>:</p> <p>Apparently, There is nothing wrong with using inline functions.</p> <p>But it is worth noting the following points!</p> <ul> <li><p>Overu...
<p>It worth pointing out that the inline keyword is actually just a hint to the compiler. The compiler may ignore the inline and simply generate code for the function someplace.</p> <p>The main drawback to inline functions is that it can <strong>increase the size of your executable</strong> (depending on the number of...
<ol> <li><p>As other people said that inline function can create a problem if the the code is large.As each instruction is stored in a specific memory location ,so overloading of inline function make a code to take more time to get exicuted.</p></li> <li><p>there are few other situations where inline may not work</p> ...
8,588
<p>An answer to a <a href="https://stackoverflow.com/questions/200394/one-table-or-many">question of mine on DB design</a> suggested something called single table inheritance. I've done a bit of searching on that, but I can't seem to find that much clear information on it.</p> <p>Basically what I seem to understand fr...
<p>Is it a good idea ? It depends. It breaks Normalization in that a table does not have a single purpose. What happens when you extend the base class for the nth time ? You will have to add columns to the table. Most modern DBs don't have a problem with that as you can modify the table but what about refactoring and...
<p>Definitive <a href="http://martinfowler.com/eaaCatalog/singleTableInheritance.html" rel="nofollow noreferrer">reference</a>. It allows a single table to store multiple objects that have a common base class.</p> <p>Ruby on Rails uses a library called <a href="http://wiki.rubyonrails.org/rails/pages/ActiveRecord" re...
24,503
<p>I have 3 lists, I will make them simple here. </p> <p>list of letters<br> A<br> B<br> C </p> <p>list of numbers<br> 1<br> 2<br> 3 </p> <p>Mixed<br> A,1<br> A,2<br> B,2<br> B,3<br> C,1<br> C,3</p> <p>I need to know what is missing:<br> A,3<br> B,1<br> C,2</p> <p>The...
<p>There's no need to create extra tables. The following query would work just as well:</p> <pre><code>SELECT c.chr, n.num FROM chars c, nums n WHERE NOT EXISTS (SELECT 1 FROM mix m WHERE m.chr = c.chr AND m.num = n.num) </code></pre>
<p>75.000 is not much. Load list of letters and list of numbers into two separate TStringLists. Create dynamic array (indices would be indexes into those two string lists) with the appropriate dimensions. Fill it up. Load the data and mark each line in the array. Output all elements that were not marked.</p> <p>In pse...
33,635