Compare objects recursively in Javascript
October 9th, 2009
This is a need I've run into more than once, yet there doesn't seem to be an elegant off-the-shelf solution that can handle a wide range of use cases, including simple (flat) objects, linear (one-dimensional) arrays, arrays of objects, and complex objects (objects within objects).
So here's a [relatively] straightforward recursive object comparison function that features optional loose type comparison (strict by default) for those times when you're working with data from different sources, (e.g., which give you quoted numbers ("3" == 3) or empty strings ("" == null == undefined == 0 == "0")), but your task at hand doesn't distinguish among these semantic differences.
Read the rest of this entry »
Gmail POP/IMAP access with Outlook: keeps asking for password
October 7th, 2009
Quick solution: RTFM (yes, it was right there on Google's help page) - clear the captcha by going to:
http://www.google.com/accounts/DisplayUnlockCaptcha
or if you use Google Apps:
https://www.google.com/a/yourdomain.com/UnlockCaptcha
Google Chrome slow under Sandboxie?
September 29th, 2009
I was having trouble getting Chrome to play nicely with Sandboxie - it loads and runs, but it was slow to show the "New Tab" page (with thumbnails of your most visited sites), the History page, and, well, most websites in general - so it appeared as though Chrome was trying to copy some needed files into the sandbox every time it loaded a page... Note that I have my sandbox set to automatically delete when the last sandboxed program ends to ensure I'm cleaning up after myself.
I couldn't find any specifics elsewhere, but after a little tweaking I solved the problem:
Read the rest of this entry »
The new Location bar in Firefox 3.x will, by default, take any non-URL input and:
- If it's a single word (no spaces): first attempt to prepend "www.", and/or append ".com", then lookup in OpenDNS to see if this makes a valid server name - if so, you are automatically redirected to this found server
- If there is a space: it is assumed this is a search phrase, so the the input is passed (by default) to Google's Browse By Name service. This works similarly to a standard Google web search, however if the search phrase is associated with an "authoritative" server (as deemed by Google), you are automatically redirected to this server (similar to an I'm Feeling Lucky search).
To disable these behaviors, resulting in similar functionality to Google Chrome's address bar, just make a couple changes in Firefox's hidden about:config settings (that is, type "about:config" in the address bar and hit Enter):
- Change the value of "browser.fixup.alternate.enabled" to false
- Change the value of "keyword.URL" to
http://www.google.com/search?q=
Note that there is nothing after the equal sign.
This appears to work up through Firefox 3.5b4.
I've had one particular network printer (installed on a local TCP/IP port) that has been incredibly slow since we've had it installed: it seems to be some bottleneck with the process of communicating with the printer in general, since even opening the printer properties window (or switching tabs within that window) can take 5-10 seconds, and sending over a print job generally hangs the sending application for a similar amount of time. However, pings are fine (<1ms), and two other network printers configured similarly work just fine, and I've exhausted most other possibilities (cabling, network hardware, port settings) for solving the issue.
However, it appears to be an odd bug in Windows, the workaround for which may not work in all cases, but seems to fix this issue. I had the printer installed on a local TCP/IP port (it has a built-in print server with a static IP), but by following this advice, I assigned the NetBIOS name for the printer to an unused LPT port at a command prompt:
net use LPT2 \\printserver\printername
And then, in the printer's Properties window, under the Ports tab, I changed the port from the TCP/IP port I had originally used to LPT2.
Voila - instant fix.
View Rendered Source in Internet Explorer
April 20th, 2009
IE 6 and 7 can be a nightmare for debugging Javascript, especially after working with the quality tools available for other browsers such as Firebug for Firefox. However, one small step in the right direction would be the ability to View Source for the currently rendered page, after Javascript has been executed (since typically the View Source command displays the source code as it was sent by the server, prior to any script execution).
Read the rest of this entry »
Create an empty (zero-length) text file in Windows
January 19th, 2009
Run the following from a command prompt or batch file:
@echo|find /I /V "echo" > file.txt
Most other, more straightforward techniques will result in a file size greater than zero bytes (usually containing spaces, linefeeds, or other less-than-obvious text).
Dead Space (PC) tweaks
November 14th, 2008
Since I've found this game is frustrating many users (myself included) with its tendency to force your mouse to work like a console game controller, among other things, I did some digging to overcome some of the issues I was having.
- Very sluggish mouse input: Disable v-sync in the game options. You might still be able to force v-sync in your video driver configuration (see here for Nvidia driver) to eliminate tearing.
- Mouse input too slow / "swimmy": You can only increase the mouse sensitivity so far in the game options, but if that's still not sensitive enough for you, try editing the setting manually in the config file. Open the file called
config.txtin this folder under Windows XP:C:\Documents and Settings\<YOUR USER NAME>\Local Settings\Application Data\Electronic Arts\Dead Space
or this folder under Vista:
C:\Users\<YOUR USER NAME>\Local Settings\Application Data\Electronic Arts\Dead Space
Look for a setting for
Control.MouseSensitivity- this only goes up to 1.0 from the in-game options menu, but you can theoretically set it quite a bit higher. I currently have it set to 2.0, which is a pretty decent improvement. Note: setting this too high will make the mouse much too sensitive in the in-game menus, so turn it up slowly and experiment. - Brightness too high even at lowest setting: this one can also be tweaked in the config file above. The setting is called
Window.Gamma- the in-game brightness adjustment only sets this as low as 0.0, but apparently it can go negative. Currently I have it set to -0.5, and it looks much more creepy and atmospheric.
Hopefully EA will patch the claustrophobic, controller-esque feeling of the mouse at some point in the future, but otherwise these settings make a huge improvement over the out-of-the-box experience.
Stable quicksort in Javascript
October 28th, 2008
Firefox < v3.0 doesn't have a stable Array.sort() function - that is, it doesn't maintain indexes for elements of equal value. This is undefined in the ECMA spec, and has been fixed in Firefox as of version 3 (and curiously enough has been stable in IE all along). As a result, I set out to find a stable, efficient Array.sort() replacement/supplement.
Read the rest of this entry »
MySQL inner join to perform update from same table
September 9th, 2008
Typically, using SELECT in a subquery to perform an UPDATE on the same table, such as:
UPDATE table1 AS target
SET field1 = (
SELECT field2
FROM table1 AS source
WHERE source.id = target.id
)
is illegal in MySQL. To achieve the desired effect, you can perform an INNER JOIN in the UPDATE:
UPDATE table1 AS target INNER JOIN table1 AS source USING(id) SET target.field1 = source.field2