Tuesday, July 3, 2012

Automatically sync Windows time with Internet at boot

If you want Windows to sync with its Internet time servers at boot (e.g. your CMOS battery died and you're too lazy to replace it), put the following into a batch file and put it in the All Users Start Up folder:

fix-time.bat:
net start w32time 
w32tm /resync /force


Put it in the All Users startup folder:
1) Right click on Start Menu -> All Programs -> Start Up and choose Explore All Users
2) Copy fix-time.bat into that folder

Friday, March 23, 2012

Controlling MPD via hotkeys in OS X

You can use Spark to set global hotkeys in OS X. Then, to control mpd with mpc, create AppleScript hotkeys with the following commands, and bind them to the desired key combination:

  • do shell script "/opt/local/bin/mpc prev"

  • do shell script "/opt/local/bin/mpc toggle"

  • do shell script "/opt/local/bin/mpc next"

Saturday, January 21, 2012

Profiling node.js on linux

According to "Understanding V8" by Vyacheslav Egorov, you profile node applications like this:

% node --prof parser.js
806 ms
711.4267990074442 bytes/ms
% deps/v8/tools/mac-tick-processor

[GC]:
ticks total nonlib name
576 79.0%

However, I couldn't get the linux-tick-processor (in the same folder) to work:

% ~/Documents/node/deps/v8/tools/linux-tick-processor v8.log
d8 shell not found in .
To build, execute 'scons d8' from the V8 directory

I ran scons as instructed, but the command still wouldn't work. What I finally realized is that I need to run the command from the v8 folder:

% pwd
/home/iggames/Documents/node/deps/v8
% tools/linux-tick-processor ~/code/nodetest/v8.log


Lame, but it works.

Thursday, October 6, 2011

More robust verification

Fragile: relying on certain behavior between action and response, and using this to know when to validate the response

Better: make no assumptions about the behavior. Instead, continuously check for a valid response for a reasonable amount of time.

e.g.:

Fragile:
- perform action
- wait for loading ui (if the devs change or remove loading ui, this will break)
- validate response

Better:
- perform action
- check for valid response
- wait a second or two
- check again...for 5-10 seconds

The second is only invalidated if the response changes (less likely). The former is invalidated if the loading UI changes (apparently, any time the PM/devs get bored).

Wednesday, October 5, 2011

TimeStamp100nSec is DateTime FileTime

The TimeStamp100nSec value of CounterSamples is in the same format you get from DateTime.ToFileTime() (or maybe DateTime.ToFileTimeUtc() in some situations, not sure).

This was not made clear to me in any documentation I could find, but some example code half-way down this page spells it out.

To go from TimeStamp100nSec to a DateTime object, use DateTime.FromFileTime(timestamp100nsec).

Friday, September 30, 2011

Division of labor for automation

Devs should maintain robust task library of functions that perform and validate user interactions (e.g. "Select", "Resize"), so they can easily update these functions at the same time the behavior changes in the build.

Test should maintain the scenarios that use these basic actions. This way, they can stay above the nitty gritty of changes to buttons, DOM, etc, and focus on building a large library of interesting/eclectic scenarios and test files.

This is especially bad with actively changing features -- if test is responsible for the tasklibrary as well, then they get stuck churning code just to keep the most basic functionality tests up to date. This is made worse if dev hates the automation system test uses...

Saturday, August 27, 2011

My bash prompt

Here's my bash prompt (in ~/.bashrc):
PS1="\[\033[1;32m\]$(date +%H:%M)\[\033[0m\]:\[\033[1;34m\]\W\[\033[0m\]$ "

For an explanation of the control codes (the parts that look like gibberish), go here.

The result looks something like this:
16:29:Downloads$

In other words, it shows the time and the name of the directory I'm currently in (not the full path; if I need that, I can just run pwd)

Most prompts show the user and/or machine name, which is probably a good default, but I usually don't care about it so much. What I found far more useful in multi-machine situations with command prompts was to change the color of the timestamp (e.g. my laptop was green, my home server was yellow, various school machines were white), since I'm personally much more likely to notice differences in color than differences in name.

I also find the time to be useful in a variety of situations (e.g. how long did that command take to run? when was the last time I built?)

You can certainly do more elaborate prompts with all kind of information in them, but I like mine because it's very compact and leaves lots of space, even in 80-char windows