Word of the Day: Fremdschämen

February 28th, 2010

Fremdschämen is a German word which means vicarious embarrassment on behalf of others.

For examples, refer to almost anything that Ricky Gervais has made.

Photo Journal: Dempster Highway to the Arctic

February 26th, 2010

Dempster Highway to the Arctic, Vancouver to Inuvik is an interesting photo journal by David Cambon.

MicroSD Card Sleuthing

February 17th, 2010

I just read a fascinating story about investigating a bad batch of Kingston MicroSD cards. Some of the things I learned:

  • Toshiba and Sandisk co-own the same fabrication facility.
  • Samsung does not sell their own cards retail, only through resellers who re-brand them.
  • Kingston does not appear to manufacture their own memory chips, but repackage Sandisk/Toshiba chips.
  • A complete SD card’s cost is nearly identical to the raw Flash chip itself, meaning that the controller and package is provided essentially for free. This is presumably because the cost of testing a free-standing Flash chip is dramatically higher than testing a complete SD card.
  • Chinese fake SD cards are impressively made and packaged.
  • How to spot a knock-off SD card (appearance irregularities and card ID data).
  • Z-A-Recovery is useful for recovering strange data from that re-sold, fake SD card you bought at a Chinese market stall.

I’m certainly wouldn’t say that Kingston SD cards are bad, but I will point out that I don’t see any reason to move away from my quite affordable Sandisk, Lexar, and A-DATA cards.

IME Functions Fail From Separate Process

February 13th, 2010

I wanted to change the behavior of the Microsoft IME bar using AutoHotkeys, a utility which can be used to create macros, remap keys, or do any of a variety of other related tasks.

This led me to ime_func.ahk, which appears to be an AutoHotkeys script which uses DllCall to access Imm32.dll, the Input Method Manager library. I believe that this script was intended to manipulate the state of the IME language bar.

As near as I can tell, this AutoHotkeys script targets an older implementation of the IMM library. Some of the methods used are now only listed for Windows Mobile platforms.

I began experimenting with ImmGetContext and ImmGetConversionStatus. ImmGetContext always returned a hIMC value of NULL.

On the Developing IME-Aware Multiple-thread Applications MSDN page, the following is stated (bold highlight added):

The IMM includes thread identification checking that determines if a calling thread is the creator of a specified input method context handle (HIMC type) or window handle (HWND type). If the thread is not the creator of the handle, the called IMM function fails and a subsequent call to GetLastError returns ERROR_INVALID_ACCESS.

Additionally:

  • A thread should not access the input context created by another thread.

  • A thread should not associate an input context with a window created by another thread, and vice versa.

So, it appears that cross-process IME manipulation is forbidden.

Publishing GPG Public Key in DNS Records

February 9th, 2010

Dan Mahoney wrote an excellent guide on publishing PGP keys in DNS TXT records.

This guide to GoDaddy DNS record configuration made it relatively easy to modify my TXT record.

GnuPG Not Working Under Cygwin

February 9th, 2010

I was having trouble using the GnuPG plugin for vim under Cygwin. The GnuPG plugin allows seamlessly integrated decryption, editing, and re-encryption of GPG-encrypted content within vim. However, on my Windows 7 box, it just showed gibberish. Attempting to edit my encrypted password file resulted in a rather vague error message:

$ vim Documents/passwords.gpg

"Documents/passwords.gpg" [Incomplete last line][converted] 7 lines,
2547 characters
Press ENTER or type command to continue

Pressing enter simply resulted in gibberish, likely the raw data of the encrypted file.

The solution was to turn on vim’s filetype plugin processing:

:filetype plugin on

To make this setting persistent, add it to your ~/.vimrc file.

Converting MP3 to AAC

February 5th, 2010

Here is a script I wrote to convert MP3 files to AAC for my Softbank 821SC phone. The script uses FFmpeg, which I downloaded from here.

@echo off

REM ---------------------------------------------------------------------------
REM  Set the following variable to the ffmpeg.exe path on your system.
REM ---------------------------------------------------------------------------
set FFMPEG_PATH="c:\tools\FFmpeg\ffmpeg.exe"

REM make sure the user provided an argument.
if NOT "%~1" == "" goto ARGS_OK

REM bad arguments, print error and exit.
echo.
echo    Usage examples:
echo       mp3toaac.bat file_to_convert.mp3
echo       mp3toaac.bat *.mp3
echo       mp3toaac.bat some_directory\*.mp3
exit /b 1

:ARGS_OK

REM use for/in so that we can accept individual files or wildcards.
for %%i in ("%~1") do %FFMPEG_PATH% -i "%%~i" "%%~ni.aac"

echo.
echo Done.

exit /b 0

Interesting elements of this batch file:

  • Use of for/in in order to accept both filenames and wildcards.
  • Use of %~X to strip parentheses from a filename variable.
  • Use of %~nX to strip the extension from a filename variable (i.e. retrieve the basename).

Are Transcend And A-DATA The Same Company?

January 31st, 2010

I have an A-DATA 8GB MicroSDHC card from NewEgg.com. On the back appears:

9A0275
MMAGR08GUDCA-DB
S FLH3E6X3 941

If you search for MMAGR08GUDCA-DB, you’ll find posts listing this same product identification number for Transcend cards.

Corporate profiles list different CEOs (Peter Shu for Transcend, Simon Chen for A-DATA). The product details, however, seem to indicate that they’re the same company, or at least share suppliers.

This is relevant only because A-DATA cards sell for slightly less than Transcend cards ($17.49 vs. $20.99). Additionally, if you don’t need the SD adapter, you can get the bare A-DATA MicroSDHC 8GB card for a few cents less ($16.99).

Horrible Stack Overflow at Coding Horror

December 11th, 2009

At sometime around 10:40am on December 11th, 2009, both Coding Horror and the Stack Overflow Blog disappeared when their host, CrystalTech, lost the VM on which they run. Coding Horror was immediately replaced with this:

Coding Horror experienced 100% data loss at our hosting provider, CrystalTech.

I have some backups and I’ll try to get it up and running ASAP!

CodingHorror_BrokenSite

According to his Tweets, however, Atwood soon discovered that all backups were on the very virtual machine which was lost.

CodingHorror_Tweet_BackupVM

This is all rather ironic, since Jeff himself blogged about how important backups are. The record of this is currently only available via Google Cache. Within the blog post, he did mention the potential of Google Cache as a backup system, so perhaps this is just his admission that second-rate backups are good enough for him:

while Google may be a great service, it’s only a so-so backup mechanism.

CodingHorror_BackupStrategy

This, of course, has the Internet falling over in alternating fits of schadenfreude and irony.

Rock Climbing Gyms in Japan

October 13th, 2009

I’ve begun to gather information on rock climbing gyms in Japan and put them into Google Maps. This map is centered on Tokyo, but I’ll add gyms anywhere in Japan as I come across them.

My goal is to provide, for each gym:

  • Exact location, including standardized Japanese address, as well as a Western-readable address.
  • Hours of operation.
  • Prices.
  • Whether the gym provides roped climbing, bouldering, or both.
  • Images of the exterior and interior climbing walls.


View Indoor Climbing Gyms/Walls in Japan in a larger map

The map currently includes the following gyms:

Central Fitness Club Nishidai
3-7-10 Hasune Itabashi-ku, Tōkyō

Fukagawa Sport Center
1-2-18 Etchūjima Kōtō-ku, Tōkyō

Nippin Main Branch
3-11-1 Soto-kanda Chiyoda-ku, Tōkyō

Rondo Fitness Club
1-28, Sakae-chō Higashi-murayama-shi

T-Wall Kinshi-chō Branch
2-10-12 Mouri Kōtō-ku, Tōkyō

T-Wall Edogawabashi Tokyo
2-5-23 Suidō Bunkyō-ku, Tōkyō

Tama Sport Hall
5 Azuma-chō Akishima-shi, Tōkyō

Climbing Gym Runout
Tokyo Building, 2-10-19 Nishi-koigakubo Kokubunji-shi, Tōkyō

B-Pump 2 Kanagawa, Yokohama
1-8-2 Hiranuma Nishi Yokohama Kanagawa

B-Pump Tokyo
1-24-10 Kamiogi Sugunami-Ku Tōkyō

Pump 2 Kawasaki
Tama Ward, Kawasaki City, Kanagawa Prefecture

Pump Ōsaka
Nishiyodogawa Ward, Ōsaka City, Ōsaka Prefecture

7a
NS Building B1, 3-17-11 Sanda-machi Hachioji-shi, Tōkyō

J-Wall in Kanagawa
Kanagawa

Central Fitness Club Mizunokuchi
2-10-22 Mizonokuchi, Takatsu, Kawasaki, Kanagawa

SSH Tunneling Windows RDC

July 5th, 2009

This article explains how to securely port-forward Windows Remote Desktop (Terminal Services) over SSH, using standard SSH command line syntax. If you prefer to use GUI SSH tools, such as PuTTY, there are other guides for that.

Terminology Notes

My terminology assumes that you are connecting to a machine on your home network, which is protected by a firewall. However, the diagrams and commands are valid regardless of whether the remote network is at home or not.

Additionally, I use RDCHOST to represent the local name or IP of your RDC server within the home network, and my_home_ip to represent your home IP address as visible from the Internet.

Prerequisites

  • Depending on network configuration, port-forwarding may have to be configured on the firewall.
  • An SSH client (e.g. Cygwin’s OpenSSH for Windows) must be installed on the local machine.
  • An SSH server (e.g. Cygwin’s OpenSSHD for Windows) must be present on some machine within the home network.
  • SSH keys must be generated and deployed appropriately.

SSH Command Syntax

ssh -C -N -L localPort:destinationHost:3389 proxyHost

  • localPort is the port on localhost through which you wish to connect.
  • destinationHost is the Remote Desktop host, as it appears on the home network.
  • proxyHost is the host running SSHD, through which you will tunnel.

Configuration 1: Discrete Servers

This configuration has the firewall port-forward SSH to a server on the home network, which proxies the connection to the RDC server:

                       +-----------[ Home Network ]---------------+
                       |                                          |
localhost <----> Home Firewall <---> SSH Server <---> RDC Server  |
                       |                                          |
                       +------------------------------------------+

Command line:

ssh -C -N -L 6009:RDCHOST:3389 my_home_ip

Configuration 2: Combined RDC & SSH Servers

In this configuration, the RDC server also has an SSH server, and the firewall port-forwards directly to it:

                       +------[ Home Network ]-----+
                       |                           |
localhost <----> Home Firewall <-----> RDC & SSH   |
                       |                Server     |
                       +---------------------------+

Command line:

ssh -C -N -L 6009:localhost:3389 my_home_ip

Configuration 3: Firewall as SSH Server

In this configuration, the firewall acts as the SSH server, proxying the connection directly to the RDC server on the home network:

                       +----[ Home Network ]----+
                       |                        |
localhost <----> Home Firewall <---> RDC Server |
                  & SSH Server                  |
                       |                        |
                       +------------------------+

Command line:

ssh -C -N -L 6009:RDCHOST:3389 my_home_ip

Additional Suggestions

Rather than specifying the IP address of your home firewall, I suggest using DynDNS to get a dynamic DNS entry.

Rikaichan: Perfect Tool for Japanese Learners

July 5th, 2009

The Rikaichan Project is a Firefox plugin which pops up translations information for Japanese characters.

Rikaichan-Example

Usage:

  1. Install the Rikaichan plugin.
  2. Restart your browser.
  3. Navigate to a page with Japanese characters.
  4. Right-click on the page and select Rikaichan (see image below).
  5. Hover the mouse over characters to see a pop-up translation.

Rikaichan-Enable

Run External Application as Another User in C#

June 4th, 2009

An arbitrary external application can be executed from C# using System.Diagnostics.Process. If you want to run as another user, setting the System.Diagnostics.Process.StartInfo.Password field can be a bit confusing. Here is one way using System.Security.SecureString.AppendChar to avoid having to resort to unsafe code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSRunAs
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Diagnostics.Process p = new System.Diagnostics.Process();

            // Domain and User Name:
            p.StartInfo.Domain = "optional_domain";
            p.StartInfo.UserName = "user_to_run_as";

            // Command to execute and arguments:
            p.StartInfo.FileName = "c:\\path\\to\\executable.exe";
            p.StartInfo.Arguments = "your argument string";

            // Build the SecureString password...
            System.String rawPassword = "your_password";
            System.Security.SecureString encPassword = new System.Security.SecureString();
            foreach (System.Char c in rawPassword)
            {
                encPassword.AppendChar(c);
            }

            p.StartInfo.Password = encPassword;

            // The UseShellExecute flag must be turned off in order to supply a password:
            p.StartInfo.UseShellExecute = false;

            p.Start();
        }
    }
}

Install Trillian 3.1 on Windows 7

May 8th, 2009

Trillian’s installer complains that it cannot create “buddy.dll”.

An ugly workaround is to right-click on the installer executable and select “Run As Administrator”.

Windows 7 Install Freezing at “Starting Windows” Animation

May 4th, 2009

Windows 7 was very troublesome to install on my system. My system specifications:

  • Motherboard: Biostar TF8200 A2+ (nVidia chipset)
  • Processor: AMD 4080e Athlon 64 x2 (45W version)
  • Memory: 4GB
  • Optical: Sony/NEC SATA DVD-RW
  • Hard Disk: Seagate SATA 320GB, 7200RPM

Installation would hang at the “Starting Windows” logo. By pressing F8 when the installer first loaded, and selecting “Safe Mode With Command Prompt”, I was able to see that it was hanging after loading DISK.SYS.

I experimented with SATA and AHCPI modes. I replaced the old PATA/IDE DVD-ROM drive with a new SATA one. I tried removing one of my 2GB memory sticks. I tried both the x64 and x86 versions. None of these changes made any difference whatsoever

In the end, the only thing that worked was to turn off all motherboard accessories. I believe I only needed to turn off the USB 2.0 controller, but to be safe I turned off all USB, audio, parallel port, floppy drive, etc.

Now that Windows 7 is fully installed, I’m still unable to use the USB 2.0 functionality.

As an aside, I reinstalled the OS two more times because I kept getting a black screen with the “Windows Release Candidate Build 7100″ in the lower, right corner. After several frustrating hours, I realized that the problem was simply that I had both the VGA and DVI connectors plugged into my monitor! The installation had been continuing just fine, but on the other monitor input!