Saturday, December 12, 2009

Reset mysql root password

$> sudo bash
$> /etc/init.d/mysql stop
$> mysqld_safe --skip-grant-tables

// Another shell
$> mysql -u root mysql
mysql>update user Password='new password' where user='root';
mysql>flush privileges;
mysql>exit;

Done

Friday, December 4, 2009

Setup nxproxy

Two machine, local and remote.

local> xauth list :0
local/unix:0 MIT-MAGIC-COOKIE-1 db5f3e3cb4132fe9d653ce40f290e248
local> nxproxy -S accept=127.0.0.1:8

local> ssh -R4008:localhost:4008 remote
remote> xauth add :8 . db5f3e3cb4132fe9d653ce40f290e248
remote> nxproxy -C link=isdn connect=127.0.0.1 127.0.0.1:8


Open a new terminal on local machine:

local> ssh remote
remote> export DISPLAY=:8
remote> xterm&

Thursday, December 3, 2009

When Google DNS is not good for you

Today Google announced its public DNS service, 8.8.8.8 and 8.8.4.4. It is probably good for most of users, but there are some pitfalls. Here is why:
Content deliver networks (CDNs), such as Akamai, have many datacenters around the country. One domain name can be served by servers in different locations. For example, requests to static.ak.fbcdn.net can be served by 96.17.148.114 in west coast, or by a different IP address in the east coast. When my IPS DNS server looks up static.ak.fbcdn.net, the lookup request goes doen to Akamai's own DNS server. Akamai's DNS server uses the geo info of ISP's DNS server address and decide where the original request was from. The assumption is that a user is usually close to its DNS server.

Currently Google's DNS server seems living in the east coast. The assumption used by Akamai is broken. It'd assume I am in east coast because Google's DNS servers are in east coast. Although I get a faster DNS lookup, my actual request to Akamai is a slow one because it acrosses the country.

The way to fix it is Google needs to deploy DNS servers in California (still using 8.8.8.8 address). Many DNS providers have this setups. The technology used here is called Anycast.

Sunday, November 22, 2009

Setup a remote git repository

Create an empty repository on the server:

ssh server
cd /git && mkdir myproj.git
cd myproj.git && git --bare init


Initialize a local repository and push it to the server:

git init
git add .
git commit -m "first time import of ..."
git remote add origin ssh://server/git/myproj.git
git push origin master


Other useful commands:

git remote show origin

adb and Karmic

I still kept an Android Sapphire phone. It is fun to use it play with modified version of Android OS.

Recently, I upgraded my workstation from Ubuntu 9.04 to 9.10 and suddenly adb couldn't find Sapphire phones. A few things changes since 9.10:

1. /etc/udev/rules.d/51-android.rules use ATTR instead of SYSFS

SUBSYSTEM=="usb", ATTR{idVendor}="0bb4", MODE="0666"


2. /lib/udev/rules.d/50-udev-default.rules needs a small change:

# libusb device nodes
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0666"

By default, MODE="0664" and you need to change it to "0664".

Happy hacking!

Thursday, October 15, 2009

Setup ssh-agent on multiple machines

I often log into several servers at the same time. It is convenient to use ssh-agent. To setup it automatically, I added following scripts in my .bashrc file:


HOSTNAME=`hostname`
AGENT_ENV_SH=$HOME/.agent_env-$HOSTNAME.sh
AGENT_IS_RUNNING=`ps x | grep ssh-agent | grep -v grep`
if [ -z "$AGENT_IS_RUNNING" ]; then
ssh-agent -s > $AGENT_ENV_SH
fi

if [ -f $AGENT_ENV_SH ]; then
# It is important to redirect output to /dev/null, otherwise, it will confuse scp
source $AGENT_ENV_SH >& /dev/null
fi


After the first login, type 'ssh-add', then never ask you the ssh phrase again.