my photo in Flickr

I just remembered that I have an account in Flickr and updated some photos:) The url is http://www.flickr.com/photos/zation/

Posted in Uncategorized | 1 Comment

Running sudo command via ssh

Ususally “sudo” requires a login session by default, and if we just use ssh, it returns “Sorry, you must have a tty to run sudo”. If it is easy for us to log in to the remote machine, we can just edit /etc/sudoers to comment out the “requiretty” stuff. Otherwise just use “ssh -t”, which allocates a sudo tty on the remote machine. I prefer the later one.

Posted in Uncategorized | 1 Comment

sync ubuntu’s system time

This is usually ignored, but when using Amazon APIs, if the time on your system somehow doesn’t agree with that in Amazon, you often get the “client.InvalidSecurity: request expired” error. The way to sync the time is “ntpdate ntp.ubuntu.com”.

Posted in linux | Leave a comment

Extract all the metadata nodes in llvm

Sometimes it is very useful to get all the metadata nodes in llvm, for the purpose of, say, find the type name of some fields of a data structure. LLVM does not provide the this complete information via any well-formed APIs, so let’s find some way out.

First about a few introductions of metadata:

Continue reading

Posted in compiler, Work | 1 Comment

Real Mega Seafood Noodle Soup

I find out that if I really want to enjoy something, I cannot depend on the cafe on the campus.

So here is the mega seafood noodle soup I cook for myself. This is what it means by “MEGA”!!

20120501-152024.jpg

Posted in cook | 2 Comments

Mounting a disk image in Linux

Previously I posted how to download amazon ec2 ami to local drive. And to use it, I posted there that we can copy it (actually “dd”) to a virtual disk in vmware in order to make use of it. That takes a lot of time (15 hours for a 10 GB disk image). Fortunately, if we don’t need to boot it, and only want to retrieve the content in the disk image, we don’t need to do that. The simplest way is to directly mount it in Linux.

To mount a disk image, we use

mount -o loop,ro,offset=XX image.img /path/to/the/mount/directory

(I didn’t use -t here because the ami is in ext4 and can be recognized directly on my ubuntu)

To determine the offset, we can use “parted” tool. So we type:

$parted image.img

GNU Parted 2.3
Using /home/zation/amazonec2/vm1/image
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) unit
Unit? [compact]? B
(parted) print
Model: (file)
Disk /home/zation/amazonec2/vm1/image: 10737418240B
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number Start     End                    Size                     File system        Flags
1               0B     10737418239B   10737418240B   ext4

(parted) quit

We see that there is only one partition, starting from 0B. So we put the offset=0

If there are multiple partitions, we can mount each partition separately by inputting the start value to the offset.

Posted in linux, virtual machine, Work | Leave a comment

Creating a language front end for llvm, and better error handling in flex and bison

Just two links. They are fantastic!

Creating a language front end for llvm:

http://gnuu.org/2009/09/18/writing-your-own-toy-compiler

Better error handling in flex and bison:

http://www.ibm.com/developerworks/opensource/library/l-flexbison/index.html

Posted in compiler, Work | Leave a comment