Some ramblings and write-ups about tech, music, travelling and other topics.

Git Proxy Switching

So here's a little instruction on how to set up git proxy switching to swtich between accessing your home git repos from work, where you have to go through SOCKS proxy for external access, and git repos on internal network. Setting the environment variable GIT_PROXY_COMMAND overrides whatever proxy configuration already exists - this is all we need to get git:// repositories to work. To get Git-over-SSH connections to work, which you probably want for push operations, you’ll also need to set up GIT_SSH.


First of all, save the .gitconfig you use at work as ~/home/.gitconfig-work. It might look something like this:
	name = Takeshi Kanemoto
	email = [email protected]
    ui = auto
    attributesfile = ~/.gitattributes


Next, we set up a .gitconfig used to access your home git repos, located on host The following example assumes that you are using gerrit to manage your git repositories, hence the port 29418.
	name = Takeshi Kanemoto
	email = [email protected]
    ui = auto
[url "ssh://[email protected]:29418/"]
    insteadOf = git://
    pushInsteadOf = git://
    attributesfile = ~/.gitattributes


This is a .gitconfig you would use at home, pulling your local git repositories using git:// for faster access.
	name = Takeshi Kanemoto
	email = [email protected]
    ui = auto

[url "ssh://[email protected]:29418/"]
    pushInsteadOf = git://
    attributesfile = ~/.gitattributes


# Filename: ~/bin/git-switch
# This script switches between work, home, and local
# It MUST be sourced.

echo "I: setting up for $1..."

[ -e ~/.gitconfig ] && rm -v ~/.gitconfig

case $1 in
        export GIT_SSH="${HOME}/bin/socks-ssh"
        export GIT_PROXY_COMMAND="${HOME}/bin/socks-gw"
        ln -v -s .gitconfig-home ~/.gitconfig
        unset GIT_SSH
        unset GIT_PROXY_COMMAND
        ln -v -s .gitconfig-local ~/.gitconfig
        unset GIT_SSH
        unset GIT_PROXY_COMMAND
        ln -v -s .gitconfig-work ~/.gitconfig

echo "I: GIT_SSH=$GIT_SSH"

echo "I: done!"


# Filename: ~/bin/socks-gw
# This script connects to a SOCKS proxy using connect.c
$HOME/bin/connect -H [email protected]
You will need to have a built binary from connect.c in ~/bin/connect


# Filename: ~/bin/socks-ssh
# This script opens an SSH connection through a SOCKS server
ssh -o ProxyCommand="${HOME}/bin/socks-gw %h %p" [email protected]


Now, all you need to do is:
. ~/bin/git-switch {work|home|local}
Or even better, you can add the following to ~/.bashrc:
alias gits='. ${HOME}/bin/git-switch'
and all you have to do is
gits {work|home|local}


'\r' in bash

Sometimes in Bash, you want to display some text in the console and sometimes you may also want to have the ability to overwrite the line that you have just displayed with a new string. For example, a bash script could display a text “Working..” on the console and then, instead of display “Finished!” to the next line, you want the line that first display “Working…” be cleared and replace with the “Finished!” string. Here is a little piece of code that could do this:

tput sc
echo -n “Working…”
for i in `seq 1 5000`;
echo $i > \dev\null
tput el1
tput rc
echo “Finished!”
Update There's actually a simpler way:
for i in `seq 1 5000`; do
    echo $i > /dev/null               # do some processing
    echo -n -e "working $i\x0d"

SSH dies on iPhone 4

What To Do

Delete these files:
Reinstall OpenSSH


Worm:iPhoneOS/Ikee.C is a worm that uses the default root password in SSH in order to spread among jail-broken iPhones. The worm also changes the affected machine's background image. Installation When run on an iPhone, this worm takes the following actions: 1. Attempts to set a file lock at /var/lock/bbot.lock in order to verify that only one copy of the worm runs at a time. 2. Attempts to copy the file /var/log/youcanbeclosertogod.jpg to /var/mobile/Library/LockBackground.jpg 3. Removes the /usr/sbin/sshd directory and stops the SSH daemon. 4. Attempts to spread using several hard-coded IP ranges. When the worm infects a remote host, it does so by copying /bin/poc-bbot, /bin/sshpass and /var/log/youcanbeclosertogod.jpg from the local system to the remote system. It also copies /var/log/youcanbeclosertogod.jpg to /var/mobil/Library/LockBackground.jpg on the remote system. The file /System/Library/LaunchDaemons/com.ikey.bbot.plist is also copied to the remote system and the following command is run: "launchctl load /System/Library/LaunchDaemons/com.ikey.bbot.plist" This command is used to load the worm remotely, and to add it to startup on reboot on the remote machine. The worm then remotely stops the SSH daemon and deletes the automatic start on reboot option for the SSH service.

Massive White Poop on Google Lawn

Jenna is said to 'Burst into tears' when she thinks of her lowest point as a frozen yogurt saleswoman in the Nevada desert, an occupation that we've failed to mention until now....DAAAAYYYAAAMMMNNN!

Getting a Free iPhone 4 Case from Apple

On July 23, 2010 Apple began allowing iPhone 4 owners to receive a free case or bumper in the hopes of fixing the notorious antenna reception problems caused by holding in a way that attenuates the antenna. Here is how you can get your free case or bumper from your iPhone, from your computer, or as a refund.


From Your iPhone

  1. [caption id="" align="alignright" width="203" caption="Search for "iPhone 4 Case Program" at the App Store"]Search for "iPhone 4 Case Program" at the App Store[/caption] Go to the App Store on your iPhone and search for "iPhone 4 case program". Select the app that appears on top of the list.

  2. [caption id="" align="alignright" width="203" caption="Click "Free" to begin downloading"]Click "Free" to begin downloading[/caption] Click the blue button marked "Free" to begin downloading the app.

  3. [caption id="" align="alignright" width="203" caption="Pick the case"]Pick the case[/caption] Press "Get Started" and then select the case or bumper you want. You can view details of the cases available by clicking each case.

  4. [caption id="" align="alignright" width="203" caption="Now wait 3-5 weeks."]Now wait 3-5 weeks.[/caption] Follow the prompts to confirm your address information. Wait at least 3-5 weeks for your free case to arrive by mail.

From Your Computer

  1. Navigate directly to the App Store via this link.
  2. Download the app as you would any other iPhone app.
  3. Sync with iTunes via the USB cable.
  4. Open the app on your iPhone and follow the "On Your iPhone" instructions above.

WordPress on iPhone

I often use this blog for my own reference, and often access it from my iPhone. Though the iPhone renders the blog wonderfully in full, having to zoom in and out to navigate around the blog is a bit of a pain in the backside. While browsing through the sea of wordpress plugins - a lot of good stuff, some of them weren't so helpful - I've stumble upon WPtouch, which seems to be the best plugin for making WordPress blogs render in "mobile" mode. It detects if the client is a mobile device (iPhone/iPod/Android), and automatically applies a very well-polished iPhone-themed style with various JQuery visual effects, all with one simple Install -> Activate.[gallery]