Friday, November 11, 2011

Moses: CMERT vs. MERT

These days, I have compared the minimum error rate training methods inside Moses.

I have run several experiments (English to Chinese) to compare the CMERT and MERT with the same Moses and on the same computer:

Experiment 1, 20 features (2 phrase tables, and 2 language models):
CMERT: MERT=0.304357; TEST=0.3801
MERT: MERT=0.310064; TEST=0.3933

Experiment 2, 15 features (1 phrase table, and 2 language models):
CMERT: MERT=0.297084; TEST=0.3541
MERT: MERT=0.302378; TEST=0.3544

Experiment 3, 16 features (1 phrase table, 2 language models, and lattice input):
CMERT: MERT=0.305125; TEST=0.3668
MERT: MERT=0.302637; TEST=0.3754


Based on my experiments, MERT works better than CMERT.




Monday, September 26, 2011

Installing latest Moses

Today, I have installed the latest Moses decoder (revision 4274) again.

Since lots of volunteers have contributed to Moses development, and lots of new features are added by them, the Moses is becoming more and more complicated. As a results, there are more bugs or incompatible issues in Moses now, which also implies that it is more difficult to install Moses.

I am writing this post to record a successful installation process of Moses, which can be very useful for a starter of Moses:

The first step is to run command ./regenerate-makefiles.sh:
Detected aclocal: aclocal (GNU automake) 1.11.1
Detected autoconf: autoconf (GNU Autoconf) 2.64
Detected automake: automake (GNU automake) 1.11.1
Detected libtoolize: libtoolize (GNU libtool) 2.2.6
Calling /home/w/wangpd/local/bin/aclocal...
Calling /home/w/wangpd/local/bin/autoconf...
Calling /home/w/wangpd/local/bin/automake...
Calling /home/w/wangpd/local/bin/libtoolize
Detected 16 cores

You should now be able to configure and build:
./configure [--with-srilm=/path/to/srilm] [--with-irstlm=/path/to/irstlm] [--with-randlm=/path/to/randlm] [--without-kenlm] [--with-synlm] [--with-xmlrpc-c=/path/to/xmlrpc-c-config]
make -j 16


The second step is to run command:
./configure [--with-srilm=/path/to/srilm] [--with-irstlm=/path/to/irstlm] [--with-randlm=/path/to/randlm] [--without-kenlm] [--with-synlm] [--with-xmlrpc-c=/path/to/xmlrpc-c-config]
, where you really need absolute pathes for all the options.

The latest Moses requires IRSTLM whose version should be not older than 1.70.01, which is what you have to do, otherwise you will fail (I tried 1.50, and failed). Another important point is that you must finish the installation of IRSTLM completely, which means you need to run:
bash regenerate-makefiles.sh
# set parameter force to the value "--force" if you want to recreate all links to the autotools
./configure --prefix=$PWD
# run "configure --help" to get more details on the compilation options
make
make install
in the root directory of IRSTLM. Note that the last command make install is absolutely needed, since I have tried to skip it but of course failed.

The last step is to run make -j 4 .

Friday, September 16, 2011

an error for Moses when decoding large lattices

Once when I was using Moses to decode a large lattice, I got the following error:
ERROR: Jump length 32 in word lattice exceeds maximum phrase length 20.
ERROR: Increase max-phrase-length to process this lattice.

After looking at the input lattice, I have found that I have a node in the lattice which wanted to jump to the 32nd node after it.

Following the error message I have fixed this problem by setting the -max-phrase-length 35 option for the moses decoder.

Wednesday, September 7, 2011

A bug in the Moses tokenizer

when you set the -l option as an unknown language, the Moses tokenizer will say it will fall back to English. However, it does not completely fall back to English. It only falls back to English for tokenizing the period (.) issues, but it will tokenize the single quotation marks (') differently from the English case.

for example, given the input "I'm a boy.", if you set -l en or do not set the -l option, the output is "I 'm a boy ."; if you set -l abc which is an unknown abbreviation of language, the output will be "I ' m a boy ."

Sunday, September 4, 2011

Linux: compare text files at the word level

wdiff is a good choice, which can be found online:
http://www.gnu.org/s/wdiff/

what you need to do is to download it and compile it.

Monday, July 25, 2011

SRILM prunes n-gram when n>=3 by default

Recently, I have used the ngram-count tool of SRILM to find n-grams of a corpus.

However, I have found that when n>=3, the tool will discard low-frequency n-grams by default.

In fact we can find the n-grams using the -write option of the tool, which is a better choice if you only care about n-grams, not the probabilities.

Tuesday, July 5, 2011

does sed support lookahead or lookbehind on Linux?

after investigating for a while, finally I found sed does not support lookahead or lookbehind assertions.

Based on http://sed.sourceforge.net/sedfaq6.html, the modified sed, which is named as ssed, can support it in its Perl mode.

Tuesday, June 28, 2011

Bug of MERT script of Moses when tuning on lattice

I am using some new version of Moses to decode lattice, but when I use the MERT script (mert-moses.pl) to tune on lattice input. I got some errors as follows:
Can't use an undefined value as an ARRAY reference at mert-moses.pl line 684.

After investigating for a while, I realized that the mert-moses.pl has not recognized that the input lattice weight ([weight-i]) is a weight to be tuned. Thus, I have read through the script and changed the procedure named scan_config: after the line "die "$inishortname: File was empty!" if !$nr;" I have added the following code:
################################################
# wangpd
foreach my $k (keys %$config_weights)
{
if (!defined $used_triples{$k})
{
my @triplets = @{$additional_triples->{$k}};
my $needlambdas = scalar(@{$config_weights->{$k}});
for(my $lambda=0; $lambda<$needlambdas; $lambda++)
{
my $triplet = $lambda;
$triplet %= scalar(@triplets)
if $additional_tripes_loop->{$k};
my ($start, $min, $max)
= @{$triplets[$triplet]};
push @{$used_triples{$k}}, [$start, $min, $max];
}
}
}
#################################################

Wednesday, June 1, 2011

Indonesian stop words list

a
abad
acara
aceh
ada
adalah
adanya
adapun
agak
agaknya
agama
agar
agustus
air
akan
akankah
akhir
akhirnya
akibat
aku
akulah
alam
album
amat
amatlah
amerika
anak
and
anda
andalah
anggota
antar
antara
antaranya
apa
apaan
apabila
apakah
apalagi
apatah
api
as
asal
asia
atas
atau
ataukah
ataupun
australia
awal
b
badan
bagai
bagaikan
bagaimana
bagaimanakah
bagaimanapun
bagi
bagian
bahan
bahasa
bahkan
bahwa
bahwasanya
baik
bangsa
bank
banyak
barang
barat
baru
bawah
beberapa
begini
beginian
beginikah
beginilah
begitu
begitukah
begitulah
begitupun
bekerja
belakang
belanda
belum
belumlah
benar
bentuk
berada
berapa
berapakah
berapalah
berapapun
berarti
berasal
berat
berbagai
berbeda
berdasarkan
berhasil
berikut
berjalan
berlangsung
bermacam
bermain
bernama
bersama
bertemu
besar
besok
betulkah
biasa
biasanya
bidang
bila
bilakah
bintang
bisa
bisakah
bola
boleh
bolehkah
bolehlah
buat
bukan
bukankah
bukanlah
bukannya
buku
bulan
bumi
cara
catch
code
copyright
cukup
cuma
daerah
dahulu
dalam
dan
dana
dapat
dari
daripada
dasar
data
datang
dekat
demi
demikian
demikianlah
dengan
depan
desa
desember
di
dia
dialah
dianggap
diantara
diantaranya
dibuat
didirikan
diduga
digunakan
dikarenakan
dikenal
dilakukan
dimana
dimulai
dini
diri
dirilis
dirinya
disebut
disini
disinilah
distrik
ditemukan
document.write
dolar
dong
dua
dulu
dunia
effective
ekonomi
empat
enggak
enggaknya
entah
entahlah
eropa
err
film
gat
gedung
gelar
gettracker
grup
gunung
hal
hampir
hanya
hanyalah
harga
hari
harus
haruslah
harusnya
hasil
hendak
hendaklah
hendaknya
hidup
hingga
https
hubungan
hukum
hutan
i
ia
ialah
ibarat
ibu
ii
ikut
ilmu
indonesia
industri
informasi
inggris
ingin
inginkah
inginkan
ini
inikah
inilah
internasional
islam
italia
itu
itukah
itulah
jadi
jakarta
jalan
jalur
jangan
jangankan
janganlah
januari
jauh
jawa
jelas
jenis
jepang
jerman
jika
jikalau
jiwa
juga
jumat
jumlah
juni
justru
juta
kabupaten
kala
kalau
kalaulah
kalaupun
kali
kalian
kalimantan
kami
kamilah
kamis
kamu
kamulah
kan
kantor
kapal
kapan
kapankah
kapanpun
karena
karenanya
karya
kasus
kata
katanya
kawasan
ke
kebutuhan
kecamatan
kecil
kedua
kegiatan
kehidupan
kejadian
kelompok
keluar
keluarga
kelurahan
kembali
kemudian
kemungkinan
kenapa
kepada
kepadanya
kepala
keputusan
kerajaan
kerja
kesempatan
keterangan
ketiga
ketika
ketua
khusus
khususnya
kini
kinilah
kiranya
kita
kitalah
km
kok
kondisi
korban
korea
kota
kurang
lagi
lagian
lagu
lah
lain
lainnya
lalu
lama
lamanya
langsung
lanjut
laut
lebih
lembaga
lewat
lima
lingkungan
lokasi
luar
luas
macam
maka
makanya
makin
malah
malahan
malam
malaysia
mampu
mampukah
mana
manakala
manalagi
mantan
manusia
masa
masalah
masih
masihkah
masing
masing-masing
masuk
masyarakat
mata
mau
maupun
measure
media
mei
melainkan
melakukan
melalui
melawan
melihat
memang
membantu
membawa
memberi
memberikan
membuat
memiliki
meminta
mempunyai
mencapai
mencari
mendapat
mendapatkan
menerima
mengaku
mengalami
mengambil
mengapa
mengatakan
mengenai
mengetahui
menggunakan
menghadapi
meninggal
meningkatkan
menjadi
menjalani
menjelaskan
menteri
menuju
menunjukkan
menurut
menyatakan
menyebabkan
menyebutkan
merasa
mereka
merekalah
merupakan
meski
meskipun
milik
militer
minggu
minyak
misalnya
mobil
mulai
muncul
mungkin
mungkinkah
musik
musim
nah
nama
namun
nanti
nantinya
nasional
negara
negeri
new
nomor
november
nya
nyaris
of
oktober
oleh
olehnya
orang
organisasi
pada
padahal
padanya
pagetracker
pagi
paling
panjang
pantas
para
partai
pasar
pasti
pastilah
pasukan
pekan
pemain
pembangunan
pemerintah
pemerintahan
pemimpin
pendidikan
penduduk
penggunaan
penting
per
perancis
perang
percuma
perlu
pernah
persen
pertama
pertandingan
perubahan
perusahaan
pesawat
pihak
polisi
politik
posisi
presiden
program
proses
provinsi
pt
pubdate
pukul
pula
pulau
pun
punya
pusat
rabu
raja
rakyat
rasa
raya
republik
resmi
ribu
ruang
rumah
rupanya
saat
saatnya
sabtu
saja
sajalah
sakit
salah
saling
sama
sambil
sampai
sana
sangat
sangatlah
satu
saya
sayalah
se
sebab
sebabnya
sebagai
sebagaimana
sebagainya
sebagian
sebaliknya
sebanyak
sebegini
sebegitu
sebelah
sebelum
sebelumnya
sebenarnya
seberapa
sebesar
sebetulnya
sebisanya
sebuah
secara
sedang
sedangkan
sedemikian
sedikit
sedikitnya
segala
segalanya
segera
seharusnya
sehingga
sejak
sejarah
sejenak
sejumlah
sekali
sekalian
sekaligus
sekalipun
sekarang
seketika
sekiranya
sekitar
sekitarnya
sekolah
sela
selagi
selain
selaku
selalu
selama
selamanya
selasa
selatan
seluruh
seluruhnya
semacam
semakin
semasih
semaunya
sementara
sempat
semua
semuanya
semula
sendiri
sendirinya
senin
seolah
seorang
sepak
sepanjang
sepantasnya
sepantasnyalah
seperti
sepertinya
september
serangan
serikat
sering
seringnya
serta
serupa
sesaat
sesama
sesegera
sesekali
seseorang
sesuai
sesuatu
sesuatunya
sesudah
sesudahnya
setelah
seterusnya
setiap
setidaknya
sewaktu
siapa
siapakah
siapapun
sini
sinilah
sistem
stasiun
suara
suatu
sudah
sudahkah
sudahlah
suku
sumber
sungai
supaya
surat
tadi
tadinya
tahu
tahun
tak
tampil
tanah
tanggal
tanpa
tapi
teknologi
telah
teman
tempat
tengah
tentang
tentara
tentu
tentulah
tentunya
terakhir
terbesar
terdapat
terdiri
terhadap
terhadapnya
terjadi
terkait
terkenal
terlalu
terlebih
terletak
terlihat
termasuk
ternyata
tersebut
tersebutlah
tertentu
terus
terutama
tetap
tetapi
the
tiap
tidak
tidakkah
tidaklah
tiga
tim
timur
tinggal
tinggi
tingkat
toh
tokoh
trackpageview
try
uang
udara
ujar
umum
unescape
universitas
untuk
upaya
usai
utama
utara
var
versi
waduh
wah
wahai
wakil
waktu
walau
walaupun
warga
wib
wilayah
wong
ya
yaitu
yakni
yang
zaman

Malay stop words list

abdul
abdullah
acara
ada
adalah
ahmad
air
akan
akhbar
akhir
aktiviti
alam
amat
amerika
anak
anggota
antara
antarabangsa
apa
apabila
april
as
asas
asean
asia
asing
atas
atau
australia
awal
awam
bagaimanapun
bagi
bahagian
bahan
baharu
bahawa
baik
bandar
bank
banyak
barangan
baru
baru-baru
bawah
beberapa
bekas
beliau
belum
berada
berakhir
berbanding
berdasarkan
berharap
berikutan
berjaya
berjumlah
berkaitan
berkata
berkenaan
berlaku
bermula
bernama
bernilai
bersama
berubah
besar
bhd
bidang
bilion
bn
boleh
bukan
bulan
bursa
cadangan
china
dagangan
dalam
dan
dana
dapat
dari
daripada
dasar
datang
datuk
demikian
dengan
depan
derivatives
dewan
di
diadakan
dibuka
dicatatkan
dijangka
diniagakan
dis
disember
ditutup
dolar
dr
dua
dunia
ekonomi
eksekutif
eksport
empat
enam
faedah
feb
global
hadapan
hanya
harga
hari
hasil
hingga
hubungan
ia
iaitu
ialah
indeks
india
indonesia
industri
ini
islam
isnin
isu
itu
jabatan
jalan
jan
jawatan
jawatankuasa
jepun
jika
jualan
juga
julai
jumaat
jumlah
jun
juta
kadar
kalangan
kali
kami
kata
katanya
kaunter
kawasan
ke
keadaan
kecil
kedua
kedua-dua
kedudukan
kekal
kementerian
kemudahan
kenaikan
kenyataan
kepada
kepentingan
keputusan
kerajaan
kerana
kereta
kerja
kerjasama
kes
keselamatan
keseluruhan
kesihatan
ketika
ketua
keuntungan
kewangan
khamis
kini
kira-kira
kita
klci
klibor
komposit
kontrak
kos
kuala
kuasa
kukuh
kumpulan
lagi
lain
langkah
laporan
lebih
lepas
lima
lot
luar
lumpur
mac
mahkamah
mahu
majlis
makanan
maklumat
malam
malaysia
mana
manakala
masa
masalah
masih
masing-masing
masyarakat
mata
media
mei
melalui
melihat
memandangkan
memastikan
membantu
membawa
memberi
memberikan
membolehkan
membuat
mempunyai
menambah
menarik
menawarkan
mencapai
mencatatkan
mendapat
mendapatkan
menerima
menerusi
mengadakan
mengambil
mengenai
menggalakkan
menggunakan
mengikut
mengumumkan
mengurangkan
meningkat
meningkatkan
menjadi
menjelang
menokok
menteri
menunjukkan
menurut
menyaksikan
menyediakan
mereka
merosot
merupakan
mesyuarat
minat
minggu
minyak
modal
mohd
mudah
mungkin
naik
najib
nasional
negara
negara-negara
negeri
niaga
nilai
nov
ogos
okt
oleh
operasi
orang
pada
pagi
paling
pameran
papan
para
paras
parlimen
parti
pasaran
pasukan
pegawai
pejabat
pekerja
pelabur
pelaburan
pelancongan
pelanggan
pelbagai
peluang
pembangunan
pemberita
pembinaan
pemimpin
pendapatan
pendidikan
penduduk
penerbangan
pengarah
pengeluaran
pengerusi
pengguna
pengurusan
peniaga
peningkatan
penting
peratus
perdagangan
perdana
peringkat
perjanjian
perkara
perkhidmatan
perladangan
perlu
permintaan
perniagaan
persekutuan
persidangan
pertama
pertubuhan
pertumbuhan
perusahaan
peserta
petang
pihak
pilihan
pinjaman
polis
politik
presiden
prestasi
produk
program
projek
proses
proton
pukul
pula
pusat
rabu
rakan
rakyat
ramai
rantau
raya
rendah
ringgit
rumah
sabah
sahaja
saham
sama
sarawak
satu
sawit
saya
sdn
sebagai
sebahagian
sebanyak
sebarang
sebelum
sebelumnya
sebuah
secara
sedang
segi
sehingga
sejak
sekarang
sektor
sekuriti
selain
selama
selasa
selatan
selepas
seluruh
semakin
semalam
semasa
sementara
semua
semula
sen
sendiri
seorang
sepanjang
seperti
sept
september
serantau
seri
serta
sesi
setiap
setiausaha
sidang
singapura
sini
sistem
sokongan
sri
sudah
sukan
suku
sumber
supaya
susut
syarikat
syed
tahap
tahun
tan
tanah
tanpa
tawaran
teknologi
telah
tempat
tempatan
tempoh
tenaga
tengah
tentang
terbaik
terbang
terbesar
terbuka
terdapat
terhadap
termasuk
tersebut
terus
tetapi
thailand
tiada
tidak
tiga
timbalan
timur
tindakan
tinggi
tun
tunai
turun
turut
umno
unit
untuk
untung
urus
usaha
utama
walaupun
wang
wanita
wilayah
yang

Friday, May 27, 2011

How to project the screen of iPad or iPhone to the projector

I have investigated this issue for several months, and finally come to a good solution.

1. The first simple solution without paying any money is to do it on the programming level: you can capture the screen image of the iPhone inside your app, so this is the clue that you can use to first take the screen shot and send it via TCP network connection to a remote computer which can show the screen image. You can use the following code to capture the screen and convert the image to jpeg format. Of course you should use asynchronize TCP connection to send the image data, otherwise the user interface of your app will stop working for some time while sending the image. On the remote computer, you also need to build an application which first listens to a port of the computer, and then receives an image and displays it.
// Capture Screenshot
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data=UIImageJPEGRepresentation(screenshotImage,self.jpegCompressionRate);
NSUInteger len=[data length];

2. another solution is to use the Apple VGA cable:
http://store.apple.com/sg/product/MC552ZM/B?fnode=MTc0MjU4NjE&mco=MjEzNTM1NjI
, together with the TVOutManager as described on the following web page:
http://www.touchcentric.com/blog/archives/123
The steps of using this TVOutManager are quite clear and simple.

I first used the TVOutManager in my app on iPhone, and it works really very well.
I then used it in my app on iPad, and unfortunately it slowed down my app.
I guess the reason is that the TVOutManager needs lots of computing power to show the screen.
After investigating for a long time, I finally found the way: in the source file TVOutManager.m, you can find two lines:
// #define USE_UIGETSCREENIMAGE
// CGImageRef UIGetScreenImage();
, and you just need to let the two lines work. As a result, your app will work much faster.


3. in fact the Apple VGA cable can directly project the real-time screen output of iPad 2 to the projector, but can only show the video and pictures for the iPhone 4 or iPad 1. If you have iPad 2, then you just need to buy the cable to project anything to the projector.

Wednesday, May 18, 2011

哈尔滨工业大学新加坡校友会召集信

亲爱的哈尔滨工业大学校友:

我们在此发起成立哈工大新加坡校友会的号召。
事缘五月初中国教育展在新加坡举行,哈工大也来参展,几位校友不约而同询问哈工大人在新加坡有没有校友会。答案是否定的。随后大家通过网络相互联系,反响积极在意料之中,但热烈程度却是意料之外。显然,开始筹备并成立正式的校友会,时机已经成熟。
哈工大的发展令人瞩目,秉持“规格严格,功夫到家”的校训,哈工大人在世界各地踏实努力地工作。在新加坡,留学、工作的校友数以千计,成立校友会迫在眉 睫。校友会的正式成立有利于我们与母校保持联系,及时了解哈工大的发展动态,并为母校献计献策;通过校友会,我们也可加强相互之间的联系,有利于事业发 展,又可为社会做出更大贡献。校友会将举办各种活动,丰富我们的社交生活,并提供各种支援和帮助。当然,我们也会与世界各地的哈工大校友会及其它高校的校 友会保持联系。
总而言之,成立哈工大新加坡校友会有利于在新加坡及其它地区的哈工大人,有利于哈工大,也有利于新加坡社会和新中友谊。我们随时欢迎您加入哈工大新加坡校友会,请大家相互转告或转发此信息:

1. 校友信息登记
哈工大在新加坡的校友,请尽快在如下网址登记信息:
http://bit.ly/hitsingapore
2. 如果您有任何建议或愿义务参与校友会的筹备工作,请发邮件至以下邮箱:hitaas@gmail.com

哈尔滨工业大学新加坡校友会期待您的加入!

哈尔滨工业大学新加坡校友会临时筹备小组
2011年5月18日

Saturday, May 14, 2011

新加坡 哈尔滨工业大学(哈工大)校友召集 ( HIT alumni association in singapore )

Hi 大家好,

我们正在联合在新加坡的哈工大校友,准备组建哈工大新加坡校友会,HITAAS(HIT Alumni Association in Singapore),我们已经建立了一个Google group,hitsingapore@googlegroups.com,希望大家可以加入,有什么关于建立校友会的信息也会在这个google group里面发布。加入这个group后,所有的信息就会直接发到你的email帐户。谢谢大家支持!

加入方法:
您只需要用你的email帐户(最好是私人的固定email帐户)发一个email到
hitsingapore+subscribe@googlegroups.com
管理员就可以看到你申请加入这个group了。

如果您遇到什么问题,请发email与hitaas@gmail.com联系。

再次感谢大家的支持!

HITAAS

Wednesday, May 4, 2011

Latex: how to control the column width of a table

Latex will automatically adjust the width of a cell in a table, but it will not consider the width of the page, so sometimes parts of the table are out of the page. If you want to control the column width of a table, you may want to use p option instead of l, c or r for left, center or right alignment.


For example:


\begin{table}[ht]
\centering
\begin{tabular}{|c|p{2cm}|p{1cm}|}
\hline
a & bb & c\\
\hline
\end{tabular}
\end{table}

Good luck!

Wednesday, April 20, 2011

How to add a new metric to ZMERT

1. you need to download ZMERT from its official homepage:
http://www.cs.jhu.edu/~ozaidan/zmert/

2. decompress the zip file that you just downloaded:
unzip zmert_v1.50.zip

3. you can find the jar file (zmert.jar) in the ./lib directory

4. extract zmert.jar content by using command:
jar xf zmert.jar

5. following the video: http://www.youtube.com/watch?v=Yr56pD8bTUc&fmt=18
to add new metric java file

6. after adding the new metric java source file, you need to recompile the java files:
javac *.java

7. the last step is to create a new version of zmert.jar by typing:
jar cvfM zmert.jar *.java* *.class

Tuesday, April 12, 2011

Python Repeatable Timer Example

def hello():
print "hello, world"
global t
t = Timer(3.0, hello)
t.start()

t = Timer(3.0, hello)
t.start() # after 3 seconds, "hello, world" will be printed

Sunday, February 20, 2011

VIM keyboard shotcuts

vim file +54
open file and go to line 54 any : command can be run using + on command line

vim -O file1 file2

open file1 and file2 side by side


:qa close all windows add trailing ! to force

undo/redo
u undo
Ctrl+r redo
. repeat

navigation
gg Goto start of file
G Goto end of file

search/replace
/regexp searches forwards for regexp ? reverses direction
n repeat previous search N reverses direction
* searches forward for word under cursor # reverses direction
:%s/1/2/gc search for regexp 1 and replace with 2 in file c = confirm change
:s/1/2/g search for regexp 1 and replace with 2 in (visual) selection
:%s/
^[\ \t]*\n//g # replace all the empty lines
:5,12s/foo/bar/g # changes each 'foo' to 'bar' for all lines between line 5 and line 12.
:.,$s/foo/bar/g # changes each 'foo' to 'bar' for all lines between the current line (.) and the last line ($).

windows

:e set buffer for current window you can optionally specify a new file or existing buffer number (#3 for e.g.). Note if you specify a directory a file browser is started. E.g. :e . will start the browser in the current directory (which can be changed with the :cd command).
:sp new window above ditto
:vs new window to left ditto
:q close current window
:qa close all windows add trailing ! to force
Ctrl+w {left,right,up,down} move to window
Ctrl+w Ctrl+w toggle window focus
Ctrl+w = autosize windows to new terminal size for e.g.
:ba new window for all buffers ":vert ba" tiles windows vertically

Tuesday, January 4, 2011

How to setup NUS SoC VPN on MAC OS

This is supported on Mac OS X 10.5 (Leopard) and 10.6 (Snow Leopard), on Intel platforms, only.

Installation and setup:

1. Download and install the most current non-beta version of Tunnelblick from http://code.google.com/p/tunnelblick/wiki/DownloadsEntry?tm=2.
2. Run Tunnelblick once, select "OPENVPN configuration file". Exit the text editor that is automatically opened. Exit tunnelblick. The Tunnelblick application support folder will be created in your home directory.
3. Configure OpenVPN with SoC-VPN connection profiles:
3.1. Download the SoC-VPN configuration file: http://download.comp.nus.edu.sg/download/socvpn.conf or http://download.comp.nus.edu.sg/download/socvpn-staff.conf (for SoC staff only)
3.2. Download the certificate file: http://download.comp.nus.edu.sg/download/ca.txt
3.3. Save the downloaded files socvpn.conf and/or socvpn-staff.conf, and ca.txt, into ~/Library/Application Support/Tunnelblick/Configurations.

Connect to SoC-VPN:

1. Launch Tunnelblick. Tunnelblick icon appears in the menu bar (top right of your screen).
2. Click on "Connect 'socvpn'" or "Connect 'socvpn-staff'" to connect to the VPN.
3. Enter your NUSNET userid (e.g. nusstu\g0123456) and password when prompted.
4. When the VPN connection has been established, your browser will launch and load a webpage with the message "Welcome to SoC-VPN". You are now securely connected to SoC-VPN.

To disconnect from SoC-VPN:

1. Right-click on the OpenVPN icon in the menu bar.
2. Click on Disconnect.
3. You're now disconnected from SoC-VPN.


Note that this page is following https://docs.comp.nus.edu.sg/node/2454

How to connect to Windows Remote Desktop on the MAC OS

1. there is an official Windows Remote Desktop client for MAC OS:
http://www.apple.com/downloads/macosx/networking_security/remotedesktopconnectionclient.html



Some notes:
1. Microsoft also provides many good applications for MAC, some of which are free:
http://www.microsoft.com/mac/downloads
2. if you are a NUS SoC student and you may also want to use the SoC VPN to connect to the PC in your office: please refer to http://wangpidong.blogspot.com/2011/01/how-to-setup-nus-soc-vpn-on-mac-os.html