• Install node.js in Ubuntu 10.04

    Posted on 12 Mar 2012

    Ubuntu 10.04 does not have a default node.js package. So if you want to use it, you need to install it manually:

    sudo aptitude install git-core curl build-essential openssl libssl-dev
    git clone https://github.com/joyent/node.git && cd node && git checkout v0.6.11
    ./configure
    make
    sudo make install
    node -v

    “v0.6.11” is the current release version of node.js. If you are not sure, run git tag to check which versions are available.

    Up to this point, you are able to use the node command. You can then install npm which is a package manager of node.js its own:

    curl http://npmjs.org/install.sh | sudo sh 

    After that, it’s easy to install other node.js libraries. For example, to install uglifyjs, simply run:

    sudo npm install uglify-js -g 

    Comments

  • Change PDF File Initial View

    Posted on 10 Mar 2012

    When you open PDF files using Adobe Reader, it will read initial view settings such as single page or double page stored in the PDF file. It’s actually pretty easy to change this information in Linux:

    1. Install pdfedit: sudo apt-get install pdfedit
    2. Open the PDF file in pdfedit, right click the “catalog” node in the tree panel, choose “add item to dictionary”
    3. Add property name: “PageLayout”
    4. Select “name” and input “TwoPageRight”
    5. Click “add and close”
    6. Save the PDF file

    This adds a name in the catalog dictionary of PDF file. It will be used by the Acrobat Reader. There are other possibilities:

    • SinglePage
    • OneColumn
    • TwoColumnLeft
    • TwoColumnRight
    • TwoPageLeft
    • TwoPageRight

    “Column” means continuous page. “Page” means display as a single page. “Left” means start double pages with odd-numbered pages on the left.

    Please note that not all PDF viewers support this setting.

    Comments

  • Convert Mercurial Repository into Git

    Posted on 05 Feb 2012

    I have some old mercurial repositories, and recently I want to convert them into git repositories. It turns out that converting them is pretty easy. First, you need to get hg-fast-export:

    git clone git://repo.or.cz/fast-export.git

    Next, create a new git repository:

    mkdir new_git_repo
    cd new_git_repo
    git init

    Finally, use the hg-fast-export.sh script from the directory you just checked out in the first step:

    /path/to/hg-fast-export.sh -r /path/to/hg_repo
    git-repack -a -d -f
    git checkout BRANCH_NAME

    BRANCH_NAME is the name of mercurial branch, the “default” branch in mercurial will be called “master”.

    hg-fast-export.sh supports --force parameter, you can use it if you get validation errors.

    Comments