# Category Archives: tips

## How to use DecimalFormat in Java

The DecimalFormat class in Java is used to format numbers based on the pattern you specify yourself. This post explains how to use the DecimalFormat class to format different types of numbers.

## Correct/Repeat the last command under Bash

If you often type the wrong command (or repeat the simmilar commends) under bash shell (like me), you may need to read this post:

cp file1.txt /path/to/dst
cp file1.a1 /path/to/dst
cp file1.a2 /path/to/dst


### Substitute the first occurrence

How do I replace .txt with a1 and a2 and repeat the last command? The syntax is as follows for quick substitution and repeat the last command, replacing WORD1 with WORD2:

## Proxy Firefox through a SSH tunnel

Have you ever wanted to visit sites during the day from a location that denied access to those sites? What you need is the ability to create a secure and encrypted ssh connection to tunnel your browser traffic through. If you have access to a remote machine by way of ssh, you can set up Firefox to visit these sites.

The following method is only tested on Windows XP, with cygwin installed.

LOCAL_PORT: localhost port for ssh tunnel
SERVER_NAME: remote machine

1. set up firefox proxy
• preferences –> advanced –> network –> settings
• choose SOCKS v5
• manual proxy configurations: SOCKS
• Host: 127.0.0.1:LOCAL_PORT
• No Proxy for: localhost, 127.0.0.1
• leave the rest of entries BLANK
2. set up firefox DNS
• open “about:config” page in Firefox
• search “network.proxy.socks_remote_dns”, set the value to “true”
3. establish ssh tunnel

## dpkg: error processing tex-common

Got the problem while installing latex-cjk-chinese

fmtutil-sys failed. Output has been stored in
/tmp/fmtutil.t6EnBlWW
Please include this file if you report a bug.

dpkg: error processing tex-common (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
tex-common
E: Sub-process /usr/bin/dpkg returned an error code (1)


After checking the file fmtutil.t6EnBlWW, I find the problem is

! I can’t find file loadhyph-zh-latn.tex’. This is due to the inconsistence between texlive 2011 and tex2012. In tex2012, the file is renamed to loadhyph-zh-latn-pinyin.tex’. Therefore, the solution is
1. go to /etc/texmf/hyphen.d
2. change loadhyph-zh-latn.tex to loadhyph-zh-latn-pinyin.tex
3. reinstall tex-common

## Install brat

download, unzip and run ./install.

## Change the webapp location in Apache2

1. in etc/apache2/sites-avialble, in default add Alias /brat "/home/brat"
2. restart apache2:
sudo service apache2 reload


## Install texlive 2012/2013 on Ubuntu 12.04

### From repository

sudo add-apt-repository ppa:texlive-backports/ppa
sudo apt-get update


## MathJax with blogger.com

MathJax in blogger.com is useful when I need to input equation in my blog. This is a instruction and test of using MathJax in blogger.com.

1. set blogger.com template to “Simple”. “Dynamic Views” seems not working.
2. edit HTML by adding the following code between <head> and </head>: <script src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' type='text/javascript'/>
3. type math equation in the blog.

Inspired by the resume of Eric Gandhi, I created this Google-themed resume for summer intern hunting 2014. I also shared my resume on Google Drive, in order for others to apply the theme on their resumes as well. If anyone is interested and has open positions, feel free to contact me. 🙂

## How to set terminal title dynamically to the current working directory?

It is sometimes helpful to set a terminal window title from a script, so that you can put a couple of reminders of how to do things there. The Xfce4-terminal preference tells me it can be done by setting the “Dynamically-set title” position, but never says how to dynamically put text in the title bar.

## Using Zsh

As I’m gradually switching to Zsh, this short post explains how to dynamically set pwd, or current working directory, to xfce terminal in Zsh. Actually, it only contains two steps:

1. open ~/.zshrc
case \$TERM in