Pages

Thursday, August 28, 2014

Encode and Decoder QR Code in Command Line

You can encode and decode QR code in command line by using ZXing.

Download jar file of zxing
http://repo1.maven.org/maven2/com/google/zxing/core/3.1.0/core-3.1.0.jar
http://repo1.maven.org/maven2/com/google/zxing/javase/3.1.0/javase-3.1.0.jar

Decoder QR code with an image file (img.png)
java -cp "core-3.1.0.jar:javase-3.1.0.jar" com.google.zxing.client.j2se.CommandLineRunner img.png

Encode QR code
java -cp "core-3.1.0.jar;javase-3.1.0.jar" com.google.zxing.client.j2se.CommandLineEncoder --image_format=GIF --output=output.gif "YHChien: Text for encode here"

Wednesday, August 13, 2014

Mount An Image with Multiple Partitions

If an image is from a hard disk, it may contains multiple partitions for mount. You access an image  with multiple partitions by following commands:

List partitions for a disk image
kpartx -l disk_image

Add and show mapper for a disk image
kpartx -av disk_image

Mount a loop device (e.g. the second partition)

mount /dev/mapper/loop0p2 /mnt

Delete mapper for a disk image
kpart -d disk_image