## Tuesday, December 10, 2013

A quick note to myself. Assuming OS X is installed in the 2nd partition of the 1st hard disk, modify your /etc/grub.d/40_custom file to have:

menuentry "OS X" {
insmod hfsplus
set root="(hd0,gpt2)"
}


Then remember to run update-grub2.

The file /usr/standalone/i386/boot0 can be found in your hackintosh. It is the boot code from Chameleon. If you do not find this file, grab it from Chameleon package.

## Wednesday, November 27, 2013

Just a quick note to myself. VnTeX recently moved its vietnam.ldf file to babel's contrib as vietnamese.dtx. The move happened on April 14, 2013. The babel package in MiKTeX is currently at March 23, 2013. The vntex package in MiKTeX is currently at May 21, 2013. That is to say vntex package no longer provides vietnam.ldf, yet babel package is still not update-to-date enough to have vietnamese.dtx.

The fix is to maintain your own vietnam.ldf file. The code (that was taken before the move) is pasted below.

% Copyright 2000-2005 Werner Lemberg .
% This file is part of vntex.  License: LPPL, version 1.3 or newer,
% according to http://www.latex-project.org/lppl.txt
%
%
% vietnam.ldf
%
% written by Werner LEMBERG
%
% History
%
%   1.0  2000/09/01
%
%     First version.
%
%   1.1  2001/05/26
%
%     Moved \endlinechar downwards.
%
%   post 1.1  ?
%
%     Don't check for dblaccnt.sty.
%     Don't define \captionsvietnam but load vncaps.tex.
%
%   1.2  2005/04/21
%
%     Minor clean-ups.

\ProvidesLanguage{vietnam}
[2005/04/21 v1.2 Vietnamese support from the babel system]

\LdfInit{vietnam}{captionsvietnam}

\ifx\l@vietnam \@undefined
\fi

\let\latinencoding\cf@encoding

\InputIfFileExists{t5enc.def}
{\errhelp{I can't find the file t5enc.def' for Vietnamese fonts}
\errmessage{Since I do not know what the T5 encoding means^^J
I can't typeset Vietnamese.^^J
I stop here, while you get a suitable t5enc.def' file}
\@@end}

{\PackageWarning{babel}{No input encoding specified for Vietnamese}}

\endlinechar \m@ne

\ifx \UnicodeCharFilter \@undefined
%   \UCSProtectionUnichar
\UCSProtectionIeC
\else
\UnicodeCharFilter\IeC
\fi}{}

\DeclareRobustCommand{\viettext}{
\fontencoding{T5}\selectfont
\def\encodingdefault{T5}
\language\l@vietnam}
\let\viet \viettext
\DeclareTextFontCommand{\textviet}{\viet}

\input{vncaps.tex}

\ldf@finish{vietnam}

\endlinechar \^^M

\endinput

% end of vietnam.ldf


## Sunday, September 15, 2013

### Introducing BrowsePass, a KeePass on the web

Update: Please file bugs and feature requests at the project's page.

This post was initially intended to be named "How to have your own open source XXX" where XXX is your favorite commercial online password manager. Then I realized that would have been too deceiving because I don't know jack about them. I have never used them. How can you trust a closed source password management software?

In contrast, BrowsePass is a GPL licensed JavaScript application (and library) to open KeePass password databases in (modern) browsers. It is great when you're on the move and don't bring KeePass with you or cannot install it on your machine but you need to access a password in your vault.

Setting up BrowsePass is as easy as uploading all the files to your web hosting provider. I would recommend you to use MyDrive because it offers WebDAV, and serves files with sane MIME type instead of forcing you to download them. You can use MyDrive as your HTTPS web host, as well as the remote storage for KeePass.

BrowsePass can read a dropped in local database file as well as a remote database file. In the second case, cross origin policy might prevent the loading of remote file, unless the remote server has enabled Cross Origin Resource Sharing (CORS).

In summary, here're the steps to set BrowsePass up for read, with KeePass for write.

1. Register an account with MyDrive.
2. Create a database with KeePass.
4. In KeePass, open URL https://webdav.mydrive.ch/personal.kdbx. From now on, whenever you save, your file on MyDrive will be updated.
6. Unpack and upload all the files to MyDrive.
7. Browse to https://webdav.mydrive.ch/browsepass.html.
8. You can either drag and drop a local KeePass database file to the second box, or type in an URL to your database in the first box. The URL can be either relative such as personal.kdbx or an absolute one such as https://webdav.mydrive.ch/personal.kdbx.

Here are some mandatory screenshots. I hope you'll like it.

### How to read .NET GZipStream with Python zlib

Just a quick post, sort of a note to myself. The code below can be used to inflate (unzip, decompress) the byte string that was created by .NET GZipStream.

import zlib
data = 'abcdef' # get the input bytestring
data = [10 : ]  # skip the first 10 bytes, .gz file header
decompressed_data = zlib.decompress(data, -zlib.MAX_WBITS)


## Saturday, August 10, 2013

### Install Debian on an emulated ARM machine in Mac OS and Windows

A quick post with some commands to create a running ARM machine in your hackintosh or Windows.

1. Install QEMU.
• On Mac:
1. You need Homebrew. If you do not have it, stop everything and go install it.
2. Then install QEMU.
brew install qemu
wget --continue http://ftp.debian.org/debian/dists/unstable/main/installer-armel/current/images/versatile/netboot/initrd.gz
wget --continue http://ftp.debian.org/debian/dists/unstable/main/installer-armel/current/images/versatile/netboot/vmlinuz-3.2.0-4-versatile
3. Create a raw disk image for your virtual machine.
qemu-img create -f raw hda.img 2G
4. Launch the virtual machine and finish installation. You will see a no-boot-loader warning near the end. Do not worry about it. When the machine reboots, you can safely terminate QEMU.
qemu-system-arm -M versatilepb -kernel vmlinuz-3.2.0-4-versatile -initrd initrd.gz -m 256 -hda hda.img
5. Extract the newly installed kernel and init image.
• On Mac:
1. Install ext4fuse. Remember to copy the kernel extension (kext) to the right place and chmod it properly.
brew install ext4fuse
2. Mount the disk image to extract the installed kernel and init ramdisk.
hdiutil attach -noverify -nomount hda.img
# take note of the device name
mkdir tmp_mnt
ext4fuse <device> tmp_mnt
cp tmp_mnt/boot/initrd* tmp_mnt/boot/vmlinuz* .
umount tmp_mnt
rm -rf tmp_mnt
hdiutil detach <device>
• On Windows: Use Ext2Read to mount hda.img and extract the files from /boot.
6. Launch the virtual machine again with the new kernel and init ramdisk. Notice that you need to replace the kernel and init ramdisk in the below command with what you copied in the above command.
qemu-system-arm -M versatilepb -kernel vmlinuz... -initrd initrd... -m 256 -hda hda.img -append "root=/dev/sda1"`

## Wednesday, August 7, 2013

### Notes about DEFCON 21 CTF

Last week was DEFCON 21, one of the many conferences I'd been saving up for. I was fortunate to play in the Capture the Flag game this year with team CLGT. I like the design of the game, so I'm jotting down here a few notes about that.

1. This is a zero sum game. There is a fixed amount of points in the game. These points change hand but they are not produced, nor consumed. When one team earns points, some other team must lose points.
2. Defense is at least as important as offense. Gained points may be taken away quickly due to failure in maintaining a required service level agreement (SLA), and breach of security.

As an analogy, each team is given a patchy water tank filled with some water. The amount of water in the tank is your points. Your goal is to steal water from other teams. If the patch on your tank is broken, the water runs out. Therefore, it is extremely important to properly fix the tank up. Even if you have only one unfixed hole, water still runs out quickly.

Unlike other CTFs, DEFCON 21 CTF placed great emphasis on the blue side of the coin. I like that. It feels more wholesome.

By the way, if you're wondering how we did, the answer is our water ran dry ;).

## Tuesday, August 6, 2013

### Samsung, Apple, and Protectionism

In June, the ITC handed Samsung an import ban on some old Apple's products which violate Samsung's patents.

Then came the presidential veto of ITC's determination, overruling the exclusion order and cease and desist order. I have to emphasize that the US Trade Representative did not veto ITC's finding that Apple had violated Samsung's patents.

The question is if this is an example of protectionism in a free market economy.

If the ban is vetoed, what can the ITC award to Samsung in lieu? If there's no remedy for Samsung, and no punishment for Apple, has the whole thing been a huge waste of time and money?

Who is going to appeal to the higher Courts?

I welcome the US Trade Representative's veto because it protects consumer's interest. At the same time, the veto brings with it many more unanswered questions. This might signal the beginning of some rework in the US intellectual property system.