input
stringlengths
51
42.3k
output
stringlengths
18
55k
How can I view more than one version of IE on my computer? <p>Where I work we only have IE 7. I want to view IE 6 on my computer also. </p> <p>How can I view both on the same computer? </p> <p>I want more than just a screen shot. I want to view both versions of IE as I write code.</p>
<p>Microsoft makes available virtual machine images that can be used with the also free Virtual PC program for each version of IE to be used by testers. You can find these here:</p> <p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF&amp;displaylang=en" rel="nofoll...
Append newline to flat-file schema in BizTalk 2006 R2 <p>I have a flat-file schema that has a header and detail records. It looks something like this:</p> <pre><code>HDR**2401*XX0062484*22750***20081006000000*000******* LIN**001*788-0538-001*4891-788538010*20000*EA**0000*** </code></pre> <p>I need to append two blank...
<p>You should be able to accomplish what you want by using the Delimiter properties of the flat file schema.</p> <p>Based on your example file I created a schema with the following record structure:</p> <pre> &lt;Schema&gt; &nbsp;&nbsp;&lt;Root&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;HDRGroup&gt; &nbsp;&nbsp;&nbs...
WinForms: How to customize a tooltip when it is about to be shown? <p>i want to have a tooltip for each item in a treeview, and each item in a listview, and different for each subitem (i.e. column) in the listview.</p> <p>i can determine the text i want to show (using hit testing with the current mouse position, etc):...
<p>You need to guard your code in the <code>Popup</code> event handler so that if you are calling <code>SetToolTip</code> from within it, you don't call <code>SetToolTip</code> again.</p> <p>Something like:</p> <pre><code>private bool updatingTooltip; private void toolTip1_Popup(object sender, PopupEventArgs e) { ...
mdi app with multiple GUI threads <p>C# MDI application with separate GUI threads for each child in MDI is that possible ?</p> <p>For example if one of the child forms is blocked by some synchronous request it freezes the entire container ( MDI Parent ) and the other windows open also become in accessible.</p> <p>In...
<p>Rather than trying to force multiple threads into the GUI layer, make the GUI layer defer all its work to a background thread. That way if some background thread becomes unresponsive the whole GUI including the MDI child that is reflecting the unresponsive background thread is responsive.</p>
How does GB18030 differ from Unicode? <p>How does the Chinese GB18030 code set differ from Unicode?</p> <p>What special techniques are required for handling GB18030?</p> <p>Are there any (open source) libraries for handling GB18030?</p>
<p>As per the <a href="http://en.wikipedia.org/wiki/GB_18030">Wikipedia article on GB18030</a>, "GB18030 can be be considered a Unicode Transformation Format (i.e. an encoding of all Unicode code points) that maintains compatibility with a legacy character set." That is, all Unicode characters can be encoded in GB18030...
What are the major drawbacks to using OpenOffice DB vs. Microsoft Access? <p>I know that Open Office Database uses a java database backend. Does anyone have any insight on how this compares to the Jet Database Engine? </p> <p>Also is the query designer/reporting nearly as robust as MS Access?</p>
<p>It's odd for me to say this, because I'm not a fan of Access at all. However, I think Access is actually the nicer product here, for a number of reasons:</p> <ul> <li>It's been around a lot longer (maturity)</li> <li>The core db engine is included with windows. </li> <li>There's an easily distributable runtime if...
Checking for duplicates in a complex object using Linq or Lamda expression <p>I've just started learning linq and lamda expressions, and they seem to be a good fit for finding duplicates in a complex object collection, but I'm getting a little confused and hope someone can help put me back on the path to happy coding.<...
<ul> <li>Unpack the hierarchy</li> <li>Project each element to its uniqueID property</li> <li>Group these ID's up</li> <li>Filter the groups by groups that have more than 1 element</li> <li>Project each group to the group's key (back to uniqueID)</li> <li>Enumerate the query and store the result in a list.</li> </ul> ...
HTML encode user input when storing or when displaying <p>Simple question that keeps bugging me.</p> <p>Should I HTML encode user input right away and store the encoded contents in the database, or should I store the raw values and HTML encode when displaying?</p> <p>Storing encoded data greatly reduces the risk of a...
<p>i'd strongly suggest encoding information on the way out. storing raw data in the database is useful if you wish to change the way it's viewed at a certain point. the flow should be something similar to:</p> <pre><code>sanitize user input -&gt; protect against sql injection -&gt; db -&gt; encode for display </code>...
Saving/Organizing/Searching Outlook E-mail outside of Outlook <p>My company requires me to use Outlook for my E-mail. Outlook does virtually nothing the way I want to do it and it frustrates me greatly. (I'm not trying to start a flame war here, it must do exactly what thousands of CEO's want it to do, but I'm not a ...
<p><a href="http://www.dimastr.com/redemption/">Outlook Redemption</a> is the best thing currently to use that I have found. It will allow you to get into the messages and extract the attachments and the message bodies. i am using it now to do just that.</p> <p>Here is some code I use in a class. I included the con...
How to detect the current sharepoint pages from the client machine? <p>On the client machine I need to be able to somehow detect which sites the current user are looking at right now. I know the base URL of the sharepoint app, say sharepoint.thecompany.net but how the hack do I get the last requested url from the serve...
<p><a href="http://watin.sourceforge.net/" rel="nofollow">WatiN</a> will allow you to attach to IE instances and get the current url from them. It will also allow you to do the same with Firefox instances.</p> <p>It might be more efficient however to try to get requested urls at the network level using a wireshark ty...
Java generics - returning subtype of declared type from method <p>My class is implementing a super-class method which which returns <code>List&lt;JComponent&gt;</code>. The list being returned is read-only:</p> <pre><code>public abstract class SuperClass { public abstract List&lt;JComponent&gt; getComponents(); }...
<p>Declare <code>getComponents()</code> as:</p> <pre><code>public List&lt;? extends JComponent&gt; getComponents() </code></pre>
C# - Optimising binary serialization for multi-dimensional generic arrays <p>I have a class that I need to binary serialize. The class contains one field as below:</p> <pre><code>private T[,] m_data; </code></pre> <p>These multi-dimensional arrays can be fairly large (hundreds of thousands of elements) and of any pri...
<p>Here's what I came up with. The code below makes an int[1000][10000] and writes it out using the BinaryFormatter to 2 files - one zipped and one not. </p> <p>The zipped file is 1.19 MB (1,255,339 bytes) Unzipped is 38.2 MB (40,150,034 bytes)</p> <pre><code> int width = 1000; int height = 10000; ...
How do .NET sites hide .aspx extension of their files? <p>I'm pretty sure stackoverflow.com is created with ASP.NET, but no matter where I click I see no .aspx extension in the address bar. How it is done and is there a particular reason for this?</p>
<p>In the case of stackoverflow, they use ASP.NET MVC rather than ASP.NET web forms. With web forms, the url is pointing to a file on your disk, while MVC is pointing to a controller action. If you're using webforms, you'd want to use URL rewriting. Scott Guthrie has a <a href="http://weblogs.asp.net/scottgu/archive...
How can I relax PHP's open_basedir restriction? <p><a href="http://www.php.net/features.safe-mode">open_basedir</a> limits the files that can be opened by PHP within a directory-tree.</p> <p>I am storing several class libraries and configuration files outside of my web root directory. This way the web server does not...
<p>You can also do this easily on a per-directory basis using the Apache (assuming this is your web server) configuration file (e.g. httpd.conf)</p> <pre><code>&lt;Directory /var/www/vhosts/domain.tld/httpdocs&gt; php_admin_value open_basedir "/var/www/vhosts/domain.tld/httpdocs:/var/www/vhosts/domain.tld/zend" &lt;/D...
How much JavaScript do you let Rails generate? <p>Ruby on Rails has a lot of ways to generate JavaScript. Particularly when it comes to Ajax. Unfortunately, there are a few problems that I often see with the JavaScript that it generates. </p> <ul> <li><p>Rails typically uses inline event handling.</p> <pre><code>&lt;...
<p>If you prefer jQuery you can use the <a href="http://ennerchi.com/projects/jrails" rel="nofollow">jQuery on Rails Project</a>. A drop in to replace Prototype with jQuery.</p> <p>Some of what Rails does with Javascript generation is good and some is bad. In the bad instances, write it yourself and keep it unobtrus...
Inline Disabling of Firefox Spellcheck? <p>I researched this a while ago and can't remember how to do it. I want to be able to prevent Firefox from running it's spell-checking functionality on certain input fields from within the page. I know it's possible but can't remember how to set it up.</p>
<p>Talk about having a big "duh" moment! I found the answer after some trial &amp; error:</p> <pre><code>&lt;textarea spellcheck="false"&gt;&lt;/textarea&gt; </code></pre>
How do I perform query filtering in django templates <p>I need to perform a filtered query from within a django template, to get a set of objects equivalent to python code within a view:</p> <pre><code>queryset = Modelclass.objects.filter(somekey=foo) </code></pre> <p>In my template I would like to do</p> <pre><code...
<p>You can't do this, which is by design. The Django framework authors intended a strict separation of presentation code from data logic. Filtering models is data logic, and outputting HTML is presentation logic.</p> <p>So you have several options. The easiest is to do the filtering, then pass the result to <code>r...
How do I calculate the previous business day in ksh shell script? <p>What is the most elegant way to calculate the previous business day in shell ksh script ?</p> <p>What I got until now is :</p> <pre><code>#!/bin/ksh set -x DAY_DIFF=1 case `date '+%a'` in "Sun") DAY_DIFF=2 ;; "Mon") DAY_DIFF=3 ;; esac ...
<p>Here is a solution that doesn't use Perl. It works both with <code>ksh</code> and <code>sh</code>.</p> <pre><code>#!/bin/ksh diff=-1 [ `date +%u` == 1 ] &amp;&amp; diff=-3 seconds=$((`date +%s` + $diff * 24 * 3600)) format=+%Y-%m-%d if date --help 2&gt;/dev/null | grep -q -- -d ; then # GNU date (e.g., Linu...
local variables in constructors are not followed. Is this a bug in gdb ? <p>I am currently running gdb version 6.7.1 on Ubuntu Linux, and working in a C++ project.</p> <p>Surprisingly I was trying to debug a constructor and I have found that local variables declared within the scope of the constructor are not followed...
<p>It is a <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27574">bug</a> in GCC, not in GDB.</p> <p>It was recently <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27574#c21">fixed</a>.</p>
QuickBooks Item Query help needed <p>I'm sure this is going to be a long shot, but I need help with a query involving QuickBooks Items.</p> <p>I need to query for all QuickBooks Items that are linked to an Income account. Is there an easy way to do this, or do I need to make 2 queries (one for items ans one for accoun...
<p>You need to use at least two queries. You'll need to fetch a list of accounts, and then compare the items AccountRef FullName to the income accounts in the list. </p>
SQL: How do I SELECT only the rows with a unique value on certain column? <p>Thanks a million everyone for everyone's response. Unfortunately, none of the solutions appear to be working on my end, and my guess is that the example I've provided is messed up.</p> <p>So let me try again.</p> <p>My table looks like this...
<p><strong>Updated to use your newly provided data:</strong></p> <p>The solutions using the original data may be found at the end of this answer.</p> <p>Using your new data:</p> <pre><code>DECLARE @T TABLE( [contract] INT, project INT, activity INT ) INSERT INTO @T VALUES( 1000, 8000, 10 ) INSERT INTO @T VALU...
What is the difference between iPod touch and iPod touch 2nd generation? <p>When submitting an app to the app store what is the real difference between iPod Touch and iPod Touch 2nd generation? </p>
<p>The following:</p> <ul> <li>Slightly thinner</li> <li>Built-in support for Nike+</li> <li>Volume bar</li> <li>External speaker</li> <li>Faster processor (533MHz vs 400MHz)</li> <li>Supports new headphones with the microphone and volume control (allowing you to use VOIP apps)</li> </ul>
log4net with ASP.NET 3.5 problems <p>I'm having some trouble getting log4net to work from ASP.NET 3.5. This is the first time I've tried to use log4net, I feel like I'm missing a piece of the puzzle.</p> <p>My project references the log4net assembly, and as far as I can tell, it is being deployed successfully on my se...
<p>The root logger is mandatory I think. I suspect configuration is failing because the root doesn't exist.</p> <p>Another potential problem is that Configure isn't being pointed to the Web.config.</p> <p>Try Configure(Server.MapPath("~/web.config")) instead.</p>
xcopy ASP.NET deployment of a Subversion-managed project <p>I'm currently using Subversion to manage my ASP.NET website. I'm finding that whenever I go to upload my website to my server, I'm copying a large number of hidden .svn folders and whatever contents may lie within them.</p> <p>Does anyone have any suggestions...
<ol> <li>You should use export command of the subversion.</li> <li>You may tweak registry and add a "Delete SVN Folders" to the context menu for folders. Here is an example script from <a href="http://weblogs.asp.net/jgalloway/archive/2007/02/24/shell-command-remove-svn-folders.aspx" rel="nofollow">http://weblogs.asp.n...
Is it possible to see the CODE for sp_executesql? Is it TSQL? <p>Is it possible to see the CODE for sp_executesql? I would like to see the actual code. I could not find it in sql server management studio. </p>
<p>sp_executesql is an extended stored procedure. It's binary in a DLL.</p>
Checkout from TFS with MSBuild <p>What's the easiest way to checkout a file from our TFS with MSBUILD. </p> <p>From what I can see it's to shell out to TF.EXE and manually call the checkout command. Is there really no built in command?!</p>
<p>There really is no built in command. Even worse, the tf checkout command only accepts a single filespec. </p> <p>The recently released <a href="http://www.codeplex.com/MSBuildExtensionPack">MSBuildExtensionPack</a> has some msbuild commands for TFS, but no perf gain there. Under the hood, they shell out to tf.exe</...
How does "Edit and continue" work in Visual Studio? <p>I have always found this to be a very useful feature in Visual Studio. For those who don't know about it, it allows you to edit code while you are debugging a running process, re-compile the code <em>while the binary is still running</em> and continue using the ap...
<p>My understanding is that when the app is compiled with support for Edit and Continue enabled, the compiler leaves extra room around the functions in the binary image to allow for adding additional code. Then the debugger can compile a new version of the function, replace the existing version (using the padding space...
How to remove the background from a fingerprint image? <p>I have a fingerprint image taken from a sliding scanner. However the output does not have clean background. It looks like this:</p> <p><img src="http://img208.imageshack.us/img208/2622/dirtyie0.png" alt="dirty" /></p> <p>I want to remove the background so that...
<p>You can check the frequency spectrum for the area around the pixels. The less high frequency components you have, the more likely it is that the pixel is part of the background.</p> <p>The most sophisticated way to do that would be to run a FFT of a block of pixels and check the spectrum directly. Since finger prin...
Incoming poplib refactoring using windows python 2.3 <p>Hi Guys could you please help me refactor this so that it is sensibly pythonic.</p> <pre><code>import sys import poplib import string import StringIO, rfc822 import datetime import logging def _dump_pop_emails(self): self.logger.info("open pop account %s wit...
<p>I don't see anything significant wrong with that code -- is it behaving incorrectly, or are you just looking for general style guidelines?</p> <p>A few notes:</p> <ol> <li>Instead of <code>logger.info ("foo %s %s" % (bar, baz))</code>, use <code>"foo %s %s", bar, baz</code>. This avoids the overhead of string form...
Tips for writing fluent interfaces in C# 3 <p>I'm after some good tips for fluent interfaces in C#. I'm just learning about it myself but keen to hear what others think outside of the articles I am reading. In particular I'm after:</p> <ol> <li>when is fluent too much?</li> <li>are there any fluent patterns?</li> <li>...
<p>The single biggest challenge I have experienced as a consumer of fluent interfaces is that most of them aren't really fluent intefaces -- instead they are really instances of what I tend to refer to as 'legible interfaces'.</p> <p>A fluent interface implies that its primary goal is to make it easy to SPEAK it where...
How can I pass arguments to anonymous functions in JavaScript? <p>I'm trying to figure out how to pass arguments to an anonymous function in JavaScript.</p> <p>Check out this sample code and I think you will see what I mean:</p> <pre><code>&lt;input type="button" value="Click me" id="myButton" /&gt; &lt;script type=...
<p>Your specific case can simply be corrected to be working:</p> <pre><code>&lt;script type="text/javascript"&gt; var myButton = document.getElementById("myButton"); var myMessage = "it's working"; myButton.onclick = function() { alert(myMessage); }; &lt;/script&gt; </code></pre> <p>This example will work becau...
How do I set a SQL Server script's timeout from within the script? <p>I have a large script file (nearly 300MB, and feasibly bigger in the future) that I am trying to run. It has been suggested in the comments of Gulzar's answer to my <a href="http://stackoverflow.com/questions/222442/sql-server-running-large-script-f...
<p>Your solution - Add GO every 100 or 150 lines</p> <p><a href="http://www.red-gate.com/MessageBoard/viewtopic.php?t=8109">http://www.red-gate.com/MessageBoard/viewtopic.php?t=8109</a></p>
Should the timezone be a constant or a variable? <p>I have a few places in the code where I need to use the TimeZone. I can get the timezone name using <a href="http://search.cpan.org/dist/DateTime" rel="nofollow">DateTime::TimeZone</a>. Is it reasonable to put the timezone name in a constant? Or should it be in a vari...
<p>If the value can change, use a variable, of it is guaranteed to stay the same, use a constant. </p> <p>For a timezone, the chance it will change is not big, but it is also not 0. The user can change the timezone and it would be nice if the program behaves accordingly.</p>
How to stop IE asking which debugger to choose when **trying** to debug? <p>When debugging in Internet Explorer; I first get an alert box with extremely limited if not useless information (sorry IE) and choice to debug it; After selecting yes; I get another option <em>every time</em> to chose between 'New instance of M...
<p>Apparently the problem happens if you do not uninstall the old (crappy) Microsoft Script Debugger before you install the newer Microsoft Script Editor.</p> <p>You would think that all you need to do is to uninstall the old debugger - however, according to a blog posting (which I can't recall at the moment), if you ...
Code Coverage on Visual Studio Team System 2008 Developer Edition (on an NUnit application) <p>Is this possible? I am looking forward to a tutorial which explains the steps to achieve this.</p>
<p><a href="http://testdriven.net/" rel="nofollow">TestDriven.NET</a> has the ability to test (NUnit/MSTest/etc) with Team Coverage (which you already have since you have Team System : Dev).</p> <p>Walkthrough: <a href="http://weblogs.asp.net/nunitaddin/archive/2006/11/08/Driving-MSTest-and-Team-Coverage-using-TestDri...
ejabberd - LDAP authentication <p>I'm trying to configure an ejabberd installation, using LDAP authentication, but I just can't login, even with the admin user. This is part of my ejabberd.cfg file:</p> <pre><code>%... {auth_method, ldap}. {ldap_servers, ["server2000.tek2000.local"]}. {ldap_port,389}. {ldap_uidattr, "...
<p>I'd expect that your ldap_rootdn should actually look something like</p> <pre><code>cn=tempadm,dc=server2000,dc=tek2000,dc=com </code></pre> <p>rather than the format you've used there.</p>
Receive parameter from request body in WCF/ADO.NET Data Service <p>I'm tryint to post to a ADO.NET Data Service but the parameters seems to get lost along the way.</p> <p>I got something like:</p> <pre><code>[WebInvoke(Method="POST")] public int MyMethod(int foo, string bar) {...} </code></pre> <p>and I make an ajax...
<p>WCF and ASMX webservices tend to be a bit choosey about the request body, when you specify args the request is usually encoded as a form post i.e. foo=4&amp;bar=test instead you need to specify the javascript literal:-</p> <pre><code> new Ajax.Request(baseurl + 'MyMethod', { method: 'POST', postBo...
Are there any pitfalls / things you need to know when changing from MyISAM to InnoDB <p>One of my projects use the MyISAM engine in MySQL, but I'm considering changing it to InnoDB as I need transaction support here and there.</p> <ul> <li>What should I look at or consider before doing this? </li> <li>Can I just chang...
<p>Yes absolutely, there are many things, you should test your application extremely thoroughly:</p> <ul> <li>Transactions can deadlock and need to be repeated. This is the case (in some circumstances) even with an autocommitted transaction which only inserts one row.</li> <li>Disc usage will almost certainly increase...
Removing Duplicate Images <p>We have a collection of photo images sizing a few hundred gigs. A large number of the photos are visually duplicates, but with differing filesizes, resolution, compression etc. </p> <p>Is it possible to use any specific image processing methods to search out and remove these duplicate imag...
<p>I recently wanted to accomplish this task for a PHP image gallery. I wanted to be able to generate a "fuzzy" fingerprint for an uploaded image, and check a database for any images that had the same fingerprint, indicating they were similar, and then compare them more closely to determine how similar.</p> <p>I accom...
How to generate empty definitions given a header file <p>I have a 3rd-party library which for various reasons I don't wish to link against yet. I don't want to butcher my code though to remove all reference to its API, so I'd like to generate a dummy implementation of it.</p> <p>Is there any tool I can use which spit...
<p>This is a harder problem than you might like, as parsing C++ can quickly become a difficult task. Your best bet would be to pick an existing parser with a nice interface.</p> <p>A quick search found <a href="http://compilers.iecc.com/comparch/article/06-09-169" rel="nofollow">this thread</a> which has many recommen...
How to load a .NET assembly for reflection operations and subsequently unload it? <p>I'm writing a tool to report information about .NET applications deployed across environments and regions within my client's systems.</p> <p>I'd like to read the values of assembly attributes in these assemblies.</p> <p>This can be a...
<p>From the <a href="http://msdn.microsoft.com/en-us/library/0et80c7k.aspx">MSDN documentation of System.Reflection.Assembly.ReflectionOnlyLoad (String)</a> :</p> <blockquote> <p>The reflection-only context is no different from other contexts. Assemblies that are loaded into the context can be unloaded only by...
On XP, best way to synchronize files and folders <p>I'm using SyncToy 1.4 and it would be fine for what I need except that: </p> <ul> <li>It can't handle the assigned drive letter changing between systems (e.g. syncing a USB drive), </li> <li>it leaves its own (hidden) files in the folders being synched (is this a lim...
<p><a href="http://allwaysync.com/">http://allwaysync.com/</a> - and it's free</p>
Is there a tool that supports discrete mathematics? <p><a href="http://en.wikipedia.org/wiki/Discrete_mathematics" rel="nofollow">Discrete mathematics (also finite mathematics)</a> deals with topics such as logic, set theory, information theory, partially ordered sets, proofs, relations, and a number of other topics.</...
<p>The current version of <a href="http://www.wolfram.com/products/mathematica/index.html">Mathematica</a> is 7. License costs:</p> <ol> <li><a href="http://wolfram.com/products/mathematicahomeedition/qa.html">Home Edition</a>: $295.</li> <li>Standard: $2,495 Win/Mac/Linux PC ($3,120 for Solaris)</li> <li>Government: ...
ASP.NET Performance : web application without precompilation <p>Currently we're using Web Application project, so we have a gain with compilation. But as far as I know, the aspx pages a still compiled at the first page hit. So does precompilation give a perceptible performance gain ? (first hit exluded).</p> <p>What t...
<p>Pre-compilation saves the first hit the work of doing the JIT compilation, for a site with a large number of pages who knows how long it will be before every page is visited and gets compilled.</p> <p>After the first hit there's no difference between the page having compiled JIT or pre-compilled.</p> <p>We use pre...
Embed image in code, without using resource section or external images <p>I'm looking for a way to embed an image in a library (Windows-only). I don't want to go the 'traditional' way of putting it in the resources (because of special circumstances that make it not so convenient to mess around with the resource handle....
<p>Google for a bin2c utility (something like <a href="http://stud3.tuwien.ac.at/~e0025274/bin2c/bin2c.c">http://stud3.tuwien.ac.at/~e0025274/bin2c/bin2c.c</a>). It takes a file's binary representation and spits out a C source file that includes an array of bytes initialized to that data.</p> <p>Just link the file in...
How to close a .Net Form from its PreFilterMessage()? <p>I'm filtering the messages that come to a form with PreFilterMessage like this:</p> <p><code>print("code sample");</code></p> <pre><code> public bool PreFilterMessage(ref Message m) { if (m.Msg == WM_KEYDOWN &amp;&amp; (int)m.WParam == VK_ESCAPE) { ...
<p>I don't know if this fits with what you are doing. I usually set Form.CancelButton to the close or cancel button on my form, and it will automatically call the button OnClick when the user hits Esc on the keyboard.</p>
Is there a PHP function to remove any/all key/value pairs that have a certain value from an array? <p>I think questions like this are the reason why I don't like working with PHP. The manual is good, if you can find what you are looking for. After reading through the <a href="http://us3.php.net/array" rel="nofollow">Ar...
<p><a href="http://de.php.net/array_diff" rel="nofollow"><code>array_diff</code></a> is what you want.</p> <pre><code>$array1 = array("a" =&gt; "green", "red", "blue", "red"); $array2 = array("b" =&gt; "green", "yellow", "red"); $result = array_diff($array1, $array2); </code></pre> <p>Result: <code>"blue"</code>.</p>...
Is it good to include title="" within your links? <p>I am developing a website and for the main navigation, I was thinking it would be a good idea to include the title attribute.</p> <pre><code>&lt;a href="/results/" title="Results"&gt;Results&lt;/a&gt; </code></pre> <p>Is this a good thing to do? Also, is it good fo...
<p>It is a great thing to do. For accessibility, for SEO, for standards, for good netiquette.<br /> You may want to make them slightly more descriptive though: title="Results of your Search" or "Results of Test #2"</p>
Controlling the execution of a Jython script from Java <p>I'm trying to control the execution of a Jython script from within Java and executed through a call to PythonInterpreter.exec(). The script contains calls to classes defined in Java. I'll call these classes "commands" for the discussion here. The commands can al...
<p>my 0.10 Eur : (ist not easy)</p> <p>Build a Factory as descripted in</p> <p><a href="http://wiki.python.org/jython/JythonMonthly/Articles/September2006/1" rel="nofollow">http://wiki.python.org/jython/JythonMonthly/Articles/September2006/1</a></p> <p>and a Java-Interface that represents a script-class (IJScript) (...
Should I include dependencies for my releases? <p>Should I include dependencies when I do releases for my common projects such as CommonUtils or should I simply specify which dependencies should be referenced when they are to be used?</p>
<p>You users do not want the work if figuring out your dependencies.</p> <ul> <li>What packages do I need?</li> <li>What if it's not available? (dead server, provider out of business)</li> <li>What version of each one do I need?</li> <li>What if it's not available? (new version)</li> <li>How do I download each one?</l...
How to deal with multiple versions of dependencies? <p>Hi I have a problem with a dependency hierarchy I am unsure how to solve:</p> <p> <a href="http://img525.imageshack.us/my.php?image=56330713it2.jpg" rel="nofollow">http://img525.imageshack.us/my.php?image=56330713it2.jpg</a></p> <p>The problem is with how I shoul...
<p>If you are using the classes that BaseProject returns directly within MyProject, you need to stick with the same version (1.0). But if BaseProject only uses those classes internally and does not share with MyProject, you can safely use the new version (2.0).</p> <p>Best practice: strongly name your assemblies so th...
Syntax highlighting when pasting into emails <p>Im in the situation that I often send small codesnippets and xml-snippets to coworkers and partners via my outlook. Has anyone got a good idea or tool that I can use to have my pastes syntaxhighlighted before I paste them into an email.</p> <p>I was thinking of an inter...
<p>Late but I can give an answer that works. You need 2 things</p> <ol> <li>putty</li> <li>access to some Unix server (With vim)</li> </ol> <p>In putty options, Under window &rarr; selection , turn the check box on for </p> <p><code>Paste in to clipboard in RTF as well as plain text</code>.</p> <p>Log on to the se...
How do I "single-instance" an ASP.Net AJAX web portal? <p>I’ve been asked if we can optionally “single-instance” our web portal. See <a href="http://www.hanselman.com/blog/TheWeeklySourceCode31SingleInstanceWinFormsAndMicrosoftVisualBasicdll.aspx" rel="nofollow">this post on Hanselman's blog</a> for the same ide...
<p>There is no way on the server side to control which browser instance your page opens up on the client. You can't force all requests to open in the same browser window.</p> <p>Also, an Application scope variable is shared by <em>all users</em> of your application. At least make this a Session-scope variable - otherw...
Why use LabVIEW? <p>I am learning to use LabVIEW as part of my honours project, and was wondering what benefits the graphical programming language has over a textual one?</p>
<p>To me, the benefit of LabVIEW is not in graphical vs. textual.</p> <p>It's dataflow vs. imperative.</p> <p><a href="http://en.wikipedia.org/wiki/Dataflow_programming">Dataflow programming</a> lends itself to concurrency, because your execution is modeled as black boxes which execute when their inputs are valid, wh...
How do I specify values in a properties file so they can be retrieved using ResourceBundle#getStringArray? <p>I am trying to use <code>ResourceBundle#getStringArray</code> to retrieve a <code>String[]</code> from a properties file. The description of this method in the documentation reads:</p> <blockquote> <p>Gets a...
<p>A <code>Properties</code> object can hold <strong><code>Object</code>s</strong>, not just <code>String</code>s. That tends to be forgotten because they're overwhelmingly used to load .properties files, and so often will only contain <code>String</code>s. <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Res...
What is your favorite User Interface? (web application) <p>I think it would be interesting to get a programmers viewpoint on UI design.</p> <p>What is your favorite User Interface that you have come across in a web application?</p> <p>If possible, say a little bit about why you like it.</p>
<p><a href="http://www.google.com" rel="nofollow">http://www.google.com</a> is my favorite. Can be considered a "lack of UI" ;)</p>
Eclipse class version bug <p>In eclipse 3.4 I'm trying to do some performance tests on a large product, one of the included libraries is the vecmath.jar (javax.vecmath package) from the Java3D project. Everything was working fine and then when trying to run it yesterday I get this exception/error not long after starti...
<p>Could there be another javax.vecmath.Point2f on your classpath?</p>
Is there a way to make Crystal Reports include a constant in a join condition, without using a SQL command object? <p>What I want to do is an outer join to a table, where I exclude records from the joined table based on matching a constant, however keep records from the main table. For example:</p> <pre><code>SELECT a...
<p>Crystal reports can't generate that commonly used SQL statement based on its links and report selection criteria. You have to use a "command" or build a view.</p> <p>In short, Crystal sucks. </p>
What TFS tool would you recommend? <p>I am mostly use to using Subversion for my source control. However, my current position has me using TFS. The UI of the TFS explorer and its integration with Visual Studio has me a little disoriented. I miss having tools like SmartSVN where I could see at a glance what I've modifie...
<p>Checkout/modification information is available in the solution explorer. Checked out items have a check mark next to their name/icon. Checked in items have a lock. Items checked out to others have a person icon. You can also do a right click and view pending changes. I've found that this shows me all pending ch...
What do PHP stream contexts do in relation to file operations? <p>In the PHP manual, the file operations reference an optional context (e.g. for <a href="http://us3.php.net/copy" rel="nofollow">copy</a>). How do these contexts affect basic file operations?</p>
<p>As it turns out, stream contexts can contain both <a href="http://us2.php.net/manual/en/context.php" rel="nofollow">options</a> and <a href="http://us2.php.net/manual/en/function.stream-context-set-params.php" rel="nofollow">parameters</a>. At the current time, parameters are simply callback functions so that you c...
Looking for an OSX application that can do image processing using a webcam <p>I'm looking for an OSX (or Linux?) application that can recieve data from a webcam/video-input and let you do some image processing on the pixels in something similar to c or python or perl, not that bothered about the processing language.</p...
<p>If you're willing to do a little coding, you want to take a look at QTKit, the QuickTime framework for Cocoa. QTKit will let you easity set up an input source from the webcam (intro <a href="http://developer.apple.com/quicktime/qtkit.html" rel="nofollow">here</a>). You can also apply Core Image filters to the stream...
C# Attribute to trigger an event on invoking a method <p>Is there a way in C# or .NET in general to create an attribute on a method which triggers an event when a method is invoked? Ideally, I would be able to run custom actions before and after the invocation of the method.</p> <p>I mean something like this:</p> <pr...
<p>The only way I know how to do this is with <a href="https://www.postsharp.net/" rel="nofollow">PostSharp</a>. It post-processes your IL and can do things like what you asked for.</p>
Semi-Tricky SQL Query <p>I am trying to write a query for SQL Server 2005 but I can't figure out how to do it. I have a table with the following fields:</p> <p><strong>MessageID int<br/> CategoryID int<br/> Priority tinyint<br/> MessageText NVARCHAR(MAX)<br/></strong></p> <p>I need a query that will return * for eac...
<p>Verified:</p> <pre><code>SELECT highest_priority_messages.* FROM ( SELECT m.MessageID , m.CategoryID , m.Priority , m.MessageText , Rank() OVER (PARTITION BY m.CategoryID ORDER BY m.Priority DESC) AS p_rank FROM [Message] m GROUP BY m.CategoryID , m.Pri...
Django Forms - How to Use Prefix Parameter <p>Say I have a form like:</p> <pre><code>class GeneralForm(forms.Form): field1 = forms.IntegerField(required=False) field2 = forms. IntegerField(required=False) </code></pre> <p>And I want to show it twice on a page within one form tag each time with a different pre...
<p>You process each form as you normally would, ensuring that you create instances which have the same prefixes as those used to generate the form initially.</p> <p>Here's a slightly awkward example using the form you've given, as I don't know what the exact use case is:</p> <pre><code>def some_view(request): if ...
What is the best tool for build automation for a one-man software shop? <p>I am building Windows apps for a few clients. I read Joel on Software and took the Joel Test and realized I don't quite measure up. One place I am lacking is automated builds. What should I use to have automated builds? I have Windows apps t...
<p><a href="http://www.cruisecontrolnet.org/" rel="nofollow">CruiseControl.Net</a> and <a href="http://nant.sourceforge.net/" rel="nofollow">NAnt</a> are the standard tools (and open source too), so there will be a lot of community support available. <a href="https://github.com/Microsoft/msbuild" rel="nofollow">MSBuild...
Migrating Java UNO code from OpenOffice 2.4 to 3.0 <p>I had a nifty small tool written to convert spreadsheets to plain text. Since it was my private hacker tool, it relied on OpenOffice 2.x to read the files.</p> <p>But when I installed <strong>OpenOffice 3</strong> and tried to get it get it to run, I failed miserab...
<p>I found what I was missing.</p> <p>I had to include the following jars</p> <pre><code>URE/java/juh.jar URE/java/jurt.jar URE/java/ridl.jar Basis/program/classes/unoil.jar </code></pre> <p>The last one I was missing before - <em>note the German OOo version</em>.</p> <p>And, something I didn't have to do before,...
Why does Convert.ToDouble(string) round? <p>For example, Convert.ToDouble("0.1234567890123456789") = 0.123456789012346</p> <p>What is the maximum number of significant figures? Couldn't find it in the docs.</p>
<p>Of course there's a maximum precision. It's the maximum that you can express with the bits used to store the double. For that string you might try Decimal instead.</p>
Silverlight 2 UI pattern <p>I have to build small (for now) admin app in Silverlight2, and would like to use some pattern for binding UI with my BL/DAL.<br /> I found view-model-viewmodel and mvp/mvc patterns, where first one (V/M/VM) is specially suited for WPF apps, because it uses rich capabilities of WPF data-bindi...
<p>Nikhil Kothari has a great set of examples (with code) on M-V-VM in Silverlight as well as a framework built with some very nice extra features. You should definitely check them out. <a href="http://nikhilk.net/Silverlight-ViewModel-Pattern.aspx" rel="nofollow" title="M-V-VM in Silverlight">M-V-VM in Silverlight</a>...
Error when compiling with Windows DDK <p>Forgive me for being a complete newbie with Windows DDK.</p> <p>I have create a simple file named <code>test.cpp</code>:</p> <pre><code>#include &lt;windows.h&gt; #define BAD_ADDRESS 0xBAADF00D int __cdecl main(int argc, char* args[]) { char* p =(char*)BAD_ADDRESS; *...
<p>You have compiled a 'native application' rather than a win32 one. The TARGET_TYPE definition controls this.</p> <p>See '<a href="http://technet.microsoft.com/en-us/sysinternals/bb897447.aspx" rel="nofollow">Inside Native Applications</a>' for a discussion of using the DDK to generate a native application.</p>
How do you compile flex in Visual Studio 2005/2008? <p>I can't figure this one out. I can download a win32 binary of flex 2.5.4a from gnuwin32, but I'd like to build the latest version (2.5.35) using Visual Studio 2005. I suppose I could build in in cygwin, but where is the fun in that?</p> <p><a href="http://flex.s...
<p>Note that Flex is seriously out-of-date on Windows when it comes to generating C++ scanners. Recent Flex versions which are able to generate ISO C++ scanners do not support Win32 (MinGW or VS), so you're probably better of trying to generate a C scanner and call it from C++.</p>
How to sanity check a date in java <p>I find it curious that the most obvious way to create Date objects in Java has been deprecated and appears to have been "substituted" with not so obvious to use lenient calendar. So...</p> <p>How do you check that a date given as a combination of day, month and year is a valid dat...
<p>Key is <strong>df.setLenient(false);</strong>. This is more than enough for simple cases. If you are looking for a more robust (I doubt) and/or alternate libraries like joda-time then look here (not the accepted answer but the answer from the user named "tardate"): <a href="http://stackoverflow.com/questions/226910/...
What's the best open source game to learn from? <blockquote> <p>This question has been preserved for historical reasons, but it is not considered on-topic, so don't use it as an excuse to post something similar.</p> <p>More info at <a href="http://stackoverflow.com/faq">http://stackoverflow.com/faq</a>.</p>...
<p><a href="ftp://ftp.idsoftware.com/idstuff/source/">Quake</a> (1,2 and 3) and <a href="http://www.3drealms.com/downloads.html#duke3d">DukeNukem 3D</a> source code is available under the GPL.</p>
Google Maps API - GMarker.openInfoWindowHtml() stopped working <p>I have a Google Map that suddenly stopped working for no apparent reason (I hadn't touched the code for months, but the wrapper code from our CMS may have changed without Corporate telling me).</p> <p><a href="http://www.democratandchronicle.com/section...
<p>I've had random problems with Google Maps API at times and more than once it has been fixed by going back one API version. i.e. if your google maps API javascript inclusion string is like this <code>http://maps.google.com/maps?file=api&amp;v=2.xd&amp;key=XXXXX</code> change the <strong>2.x</strong> to something a f...
Is it acceptable to "borrow" dependency properties from unrelated classes? <p>I'm writing a class that renders some content in WPF, and I want to give the user control over how the content is rendered. The rendering is mostly stroking lines, so I decided to look to the System.Windows.Forms.Shapes.Line class to get an ...
<p>It is very safe and useful to borrow DPs... Read the <a href="http://www.drwpf.com/blog/Home/tabid/36/EntryID/20/Default.aspx" rel="nofollow">following</a> post by Dr WPF about the subject!</p> <p>Here is a few of the "tips" he provide:</p> <ul> <li>You should always know what the owner class does with any propert...
Hibernate returns invalid results with composite key <p>I'm getting the strangest results. I have a class with a composite key. If i do the following query:</p> <blockquote> <p>from LOVEJB l order by l.canonicalId desc</p> </blockquote> <p>my results are not ordered by the '<strong>canonicalId</strong>' column I ...
<p>I found out. My composite key had columns that were not part of the table's primary key. Thanks all.</p>
C# Speech Recognition - Is this what the user said? <p>I have need to write an application which uses a speech recognition engine -- either the built in vista one, or a third party one -- that can display a word or phrase, and recognise when the user reads it (or an approximation of it). I also need to be able to swit...
<p>A similar question was asked on Joel on Software a while back. You can use the <a href="http://msdn.microsoft.com/en-us/library/system.speech.recognition.aspx">System.Speech.Recognition</a> namespace to do this...with some limitations. Add System.Speech (should be in the GAC) to your project. Here's some sample c...
How to find number of lines changed between CVS versions? <p>I've spent most of the day making what are basically some housekeeping changes to the codebase of one of our projects (replacing all <code>System.out.println()</code> calls with log4j).</p> <p>I'm kind of curious how many lines of code I've updated with this...
<p>The <a href="http://invisible-island.net/diffstat/">diffstat</a> utility is a nice tool for getting some simple metrics from the output of cvs, svn or other diffs.</p>
Visual Studio Solution Explorer Locks Up <p>I have an issue with Visual Studio 2005 w/ TFS where, from time to time, the Solution Explorer will stop responding to interaction. Instead it does the beep, like I'm trying to click on a parent window with a modal dialog visible, but there isn't one. The only thing I've fo...
<p>If VS Editor lockdown is accompanied by creation of <strong>Setup.exe</strong> process that never finishes (visible in the task manager), then this is an issue with Microsoft Office 2007 components.</p> <p>The solution that has worked for me - reinstalling Microsoft Office 2007. <a href="http://abdullin.com/journal...
Software protection by encryption <p>For our software we use hardware dongles to protect the software. No protection is perfect but this commercial solution is affordable and keeps honest people honest (as mentioned in another thread). The advantage is the 128 bit key that is stored 'unreadable' on the hardware dongle....
<p>There is no way to completely secure the key. If it can be read by your program, then it can be read by another program.</p>
Best practice for a collection of generic classes <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...
<p>I would either use the interface you suggested, or make SomeClassX inherit from another class. It really depends on what you need to do with the objects in your collection. Whatever functionality they are going to have in common should go in a base class, or interface if that seems more appropriate.</p>
Suggestions to improve VB.NET URL shortener? <p>Here is my function (<strong>updated</strong>):</p> <pre><code>Public Shared Function shortenUrl(ByVal URL As String) As String Return shortenUrl(URL, 32) End Function Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String If...
<p>Why not do this?</p> <pre><code>Public Shared Function shortenUrl(ByVal URL As String) As String Return shortenUrl(URL, 29) End Function Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String If URL.Length &gt; maxLength Then Return String.Format("{0}...{1}", UR...
Select Box onClick - Rails <p>I have a Rails application that in the erb code, I use a select box. What I would like to do is reload the page passing the sort parameter. My controller already handles it, but I don't know how to reload the page with the selected value from my select box. Here is my code:</p> <pre><code...
<p>Have you considered using an ajax call on your list box? If you have a method on your controller that returns just the sorted list, based on sort parameter, then you could do:</p> <pre><code>&lt;% @options = {:latest =&gt; 'lastest' , :alphabetical =&gt; 'alphabetical', :pricelow =&gt; 'price-low', :pricehigh =&gt;...
Simple Search: Passing Form Variable to URI Using CodeIgniter <p>I have a search form on each of my pages. If I use form helper, it defaults to <code>$_POST</code>. I'd like the search term to show up in the URI:</p> <pre><code>http://example.com/search/KEYWORD </code></pre> <p>I've been on Google for about an hour, ...
<p>There's a better fix if you're dealing with people without JS enabled.</p> <p><strong>View:</strong></p> <pre><code>&lt;?php echo form_open('ad/pre_search');?&gt; &lt;input type="text" name="keyword" /&gt; &lt;/form&gt; </code></pre> <p><strong>Controller</strong> </p> <pre><code>&lt;?php function pre_...
JSTL, Beans, and method calls <p>I'm working on a JSP where I need to call methods on object that come from a Bean. The previous version of the page does not use JSTL and it works properly. My new version has a set up like this:</p> <pre><code>&lt;jsp:useBean id="pageBean" scope="request" type="com.epicentric.page.web...
<p>When using the dot operator for property access in JSTL, <code>${pageDividers.size}</code> (no <strong>()</strong> needed) results in a call to a method named <code>getSize()</code>.<br /> Since java.util.List offers a method called <code>size()</code> (rather than <code>getSize()</code>) you won't be able to access...
How to Dynamically add menu items to master page in ASP.NET 3.5 MVC app <p>I want to dynamically add menuitems to my master page based on membership security login role. From what I've read RenderAction in the master page html could perhaps do this. Since I'm fumbling thru this I am not sure how it would look and how i...
<p>In the controller, I would create a MenuModel class or the like, that is the model for your menu. It would be a data only class. Create and populate it in the controller, taking into consideration the current user's access permissions. This will allow you to write unit tests that ensure your security code is correct...
Unique identifier for an iPhone app <p>For an iPhone app that submits images to a server I need somehow to tie all the images from a particular phone together. With every submit I'd like to send some unique phone id. Looked at <pre> [[UIDevice mainDevice] uniqueIdentifier]<br /> and [[NSUserDefaults standardDefau...
<p>What errors are you getting? <code>[[UIDevice currentDevice] uniqueIdentifier]</code> (<i>edited to fix API, thanks Martin!</i>) is the officially recommended way of doing this.</p>
Question about skipping IDs in an identity column in MSSQL <p>Say I have an MSSQL table with two columns: an int ID column that's the identity column and some other datetime or whatever column. Say the table has 10 records with IDs 1-10. Now I delete the record with ID = 5.</p> <p>Are there any scenarios where anot...
<p>No, unless you specifically enable identity inserts (typically done when copying tables with identity columns) and insert a row manually with the id of 5. SQLServer keeps track of the last identity inserted into each table with identity columns and increments the last inserted value to obtain the next value on inse...
Apart from initial cost, are there any other benefits of using MySQL over MSQL server with .net? <p>I've used both and I've found MySql to have several frustrating bugs, limited support for: IDE integration, profiling, integration services, reporting, and even lack of a decent manager. Total cost of ownership of MSSQL ...
<p>I've used MySQL in the past and I'm using MSSQL lately but I can't remember anything that MySQL has and MSSQL can't do. </p> <p>I think the most killer feature of MySQL it's the simplicity. For some projects you just don't need all the power you can have with a huge system like MSSQL. I have an UNIX heritage and fi...
Passing a list while retaining the original <p>So I'm teaching myself Python, and I'm having an issue with lists. I want to pass my function a list and pop items off it while retaining the original list. How do I make python "instance" the passed list rather that passing a pointer to the original one?</p> <p>Example:<...
<p>As other answers have suggested, you can provide your function with a copy of the list.</p> <p>As an alternative, your function could take a copy of the argument:</p> <pre><code>def burninate(b): c = [] b = list(b) for i in range(3): c.append(b.pop()) return c </code></pre> <p>Basically, y...
Why is it bad to use an iteration variable in a lambda expression <p>I was just writing some quick code and noticed this complier error </p> <blockquote> <p>Using the iteration variable in a lambda expression may have unexpected results.<br> Instead, create a local variable within the loop and assign it the value ...
<p>Consider this code:</p> <pre><code>List&lt;Action&gt; actions = new List&lt;Action&gt;(); for (int i=0; i &lt; 10; i++) { actions.Add(() =&gt; Console.WriteLine(i)); } foreach (Action action in actions) { action(); } </code></pre> <p>What would you expect this to print? The obvious answer is 0...9 - but ...
Programatic Accent Reduction in JavaScript (aka text normalization or unaccenting) <p>I need to compare 2 strings as equal such as these:</p> <blockquote> <p>Lubeck == Lübeck</p> </blockquote> <p>In JavaScript.</p> <p>Why? Well, I have an auto-completion field that's going out to a Java service using Lucene, wher...
<pre><code>/** * Creates a RegExp that matches the words in the search string. * Case and accent insensitive. */ function make_pattern(search_string) { // escape meta characters search_string = search_string.replace(/([|()[{.+*?^$\\])/g,"\\$1"); // split into words var words = search_string.split(/\...
Merge Facts from Different Sources? Or Load Separately? <p>We've got data with two different origins: some comes from a customer, some comes from different vendors. Currently, we physically "merge" this data into a massive table with almost a hundred columns, tens of thousands of rows and no formal separation of the ...
<p>I'd go for the single fact table. The highlight pro of this approach is that it leaves all the hard work at load time rather than at query time.</p>
Custom URI for HTTPListener? <p>Is there a way to add a custom prefix/URI that is not http or https? The HTTPListener.Prefixes.Add method only accepts http:// and https:// prefixes.</p> <p>I just don't want to recreate the functionality of this class if I don't have to. </p>
<p>What did you have in mind? Mainly, I doubt it; besides, it will still only handle http[s], so why confuse things with a different scheme name? You can listen on a different port by adding it to the prefix list (eg "http://127.0.0.1:90/"), though. If a client connects on that port using the correct protocol (http vs ...
Why is there not a register that contains the higher bytes of EAX? <p><code>%AX = (%AH + %AL)</code></p> <p>So why not <code>%EAX = (%SOME_RESTIER + %AX)</code> for some register <code>%SOME_REGISTER</code>? </p>
<p>Just for some clarification. In the early microprocessor days of the 1970's, CPUs had only a small number of registers and a very limited instruction set. Typically, the arithmetic unit could only operate on a single CPU register, often referred to as the "accumulator". The accumulator on the 8 bit 8080 &amp; Z80 pr...
RegEx teaser <p>Let's say we have 2 php variables:</p> <ul> <li><strong>$name</strong> = 'caption';</li> <li><strong>$url</strong> = '<a href="http://domain.com/photo.jpg" rel="nofollow">http://domain.com/photo.jpg</a>';</li> </ul> <p>The input string of <code>'{@url,&lt;img src="," alt="{@name}" /&gt;}'</code> shoul...
<p>I think you've come across one of those situations where you <em>shouldn't</em> use regex.</p> <p>much like this one.</p> <p><a href="http://stackoverflow.com/questions/154708/multi-line-group-and-search-with-regex">http://stackoverflow.com/questions/154708/multi-line-group-and-search-with-regex</a> <a href="http:...
Removing file locks <p>I need to recover form an error case where a file gets left in a locked state. How can I in c# tell this file to reset it's locks? I need to add to this the file is opened by a 3rd party dll and I don't actually have access to the file handle.</p>
<p>Locking a file is the responsibility of the Operating System (on behalf of the program that opens it). If a file is left in a locked state, its really up to the OS to unlock. This typically happens automatically when the process that opened the file exits.</p> <p>There is, however, a really cool utility that I ca...
Looking for alternatives or improvements to drop down lists/menus on websites <p>Drop-down lists, menus and combo boxes are all very common user interface elements. Users are accustomed to seeing these elements in native applications and sometimes web apps, but there are a few problems with them. </p> <ol> <li><p>You ...
<p>Hmm..one more thing which annoys me about the dropdown list is the inability to control their width as it expands with the text (or is their something which I am unaware of ?).</p> <p>For an alternate, I think about a little popup which initially displays a list of available options in form of Alphabetic index and ...
What is the best method for getting a database connection/object into a function in PHP? <p>A couple of the options are:</p> <pre><code>$connection = {my db connection/object}; function PassedIn($connection) { ... } function PassedByReference(&amp;$connection) { ... } function UsingGlobal() { global $connection...
<p>I use a Singleton ResourceManager class to handle stuff like DB connections and config settings through a whole app:</p> <pre><code>class ResourceManager { private static $DB; private static $Config; public static function get($resource, $options = false) { if (property_exists('ResourceManager', $resource)) {...
Garbage Collection in C++ -- why? <p>I keep hearing people complaining that C++ doesn't have garbage collection. I also hear that the C++ Standards Committee is looking at adding it to the language. I'm afraid I just don't see the point to it... using RAII with smart pointers eliminates the need for it, right?</p> <p>...
<h2>I keep hearing people complaining that C++ doesn't have garbage collection.</h2> <p>I am so sorry for them. Seriously.</p> <p>C++ has RAII, and I always complain to find no RAII (or a castrated RAII) in Garbage Collected languages.</p> <h2>What advantages could garbage collection offer an experienced C++ develop...
How to Load More than 1 CSV File at a Time Via Excel VBA? <p>how does one import CSV files via Excel VBA in a set, in groups or in multiple individual files, rather than one at a time?</p>
<p>I am a bit puzzled in that most versions of Excel will open .csv files with out any problems.</p> <pre><code>strPath = "C:\Docs\" strFile = Dir(strPath &amp; "*.csv") Do While strFile &lt;&gt; "" Workbooks.Open Filename:=strPath &amp; strFile ActiveWorkbook.SaveAs Filename:=strPath &amp; Mid(strFile, 1, In...