2009-11-12

tips

tips

= unison (bi-directional synchronization)
    -testServer
    $ unison -sshargs -axC teal ssh://joulee.dyndns.org/proj/teal

= rsync (uni-directional synchronization)
    rsync -e 'ssh -ax' -avz ./teal joulee.dyndns.org:proj/teal

= LVM:
  • pvdisplay - display attributes of a physical volume
  • lvdisplay - display attributes of a logical volume
= LVM: Moving a volume group to another system
  • pvscan
  • vgexport vg_backup
  • vgimport vg_backup
  • vgchange -ay vg_backup
  • mount /dev/vg_backup/LogVol00 /mnt/backup
= LVM: add a disk partition to current system
  • initializing disk partition
    $ pvcreate /dev/sda2
  • adding physical volume to an existing
    volume group
    $ lvdisplay
    $ lvextend -l +100%FREE /dev/vg_system/eda_tools
    $ umount /dev/vg_system/eda_tools
    $ e2fsck -f /dev/vg_system/eda_tools
    $ resize2fs /dev/vg_system/eda_tools
    $ mount /tools

= octave, rlab: replacement of matlab

= gnuplot
    * gnuplot -persist <script>: keep x11 window after exec <script>
    * x11 plot window
        - help: move to x11 plot window; press 'h'
        - u: unzoom
        - p: previous zoom region
        - right-mouse-button: select zoom region
        - e:

= ssh: Warning: No xauth data; using fake authentication data for X11 forwarding
    details are here ; to fix this problem, run the following command on the local host:
    $ xauth add `echo "${DISPLAY}" | sed 's/.*\(:.*\)/\1/'` . `mcookie`

= Cygwin/X and ssh ForwardX11
    - copy ssh_config to ~/.ssh/config; and set ForwardX11 as yes
    - Or, ssh -Y <remote_host>

= Cygwin/X: Clean way to auto-read ~/.Xresources
    add the following to startxwin.bat:
        %RUN% xrdb -wait -merge ~/.Xresources

=Ten Steps To Higher Cygwin Productivity
    $ updatedb --localpaths='c:/ d:/'
    $ crontab ...
    $ ssh daemon ...

= ssh per-host configuration: specify to login as "ethan" for Host "pc*"
    - ~/.ssh/config:
            Host      pc*
            User      ethan

= keychain
    IBM article OpenSSH key management, Part 1
    - generate ssh key pairs (id_dsa)
    $ ssh-keygen.exe -t dsa
    - copy public DSA key to remote host
    $ scp .ssh/id_dsa.pub ethan@pc2005:
    - login to remote host and concatenate id_dsa.pub to .ssh/authorized_keys
    $ cat id_dsa.pub >> .ssh/authorized_keys
    - edit .bash_profile; add the following to it
        keychain ~/.ssh/id_dsa
        source ~/.keychain/`uname -n`-sh

= emacs
    - indent region: C-M-\
    - mark region:
M-< C-SPC M-> C-M-\

= vim
    - include-search /  definition-search [I, ]I, [i, ]i
        :checkpath
        :set path+=../inc
        :set path+=/usr/include/*
    - TODO: apply auto command for "set path"

= cscope
    - cscope -Rb
    - vim: ctrl \ s




= C: Bit Operators (Programming in C:  A Tutorial)
C has several operators for logical bit-operations.
For example,
x = x & 0177;
forms the bit-wise AND of x and 0177, effectively
retaining only the
last seven bits of x.  Other operators are
| inclusive OR
^ (circumflex) exclusive OR
~ (tilde) 1's complement
! logical NOT
<< left shift (as in x<<2)
>> right shift

= bzr
    Bazaar for CVS Users   
    - bzr pull
    - bzr revert
    - bzr update
    - bzr missing
    Using Launchpad and Bazaar
  bzr init-repo libmodbus
  cd libmodbus
  bzr branch lp:libmodbus/trunk
  bzr branch trunk mou
  cd mou
  (hack, hack, hack)
  bzr commit -m "..."
  cd ../trunk
  bzr pull
  cd ../mou
  bzr status
  bzr info
  bzr merge
  (resolve any conflicts)
  bzr commit -m "initial modbus_over_usb"
  bzr push lp:~yishin-li/libmodbus/mou

   
= svn
    - setup subversion on CentOS
    - Note for SELinux / Fedora Core 3+ / Red Hat Enterprise users:
       
$ chcon -R -h -t httpd_sys_content_t PATH_TO_REPOSITORY
    - consult docs and faqs from svn site
    - CVS to SVN Crossover Guide
    - Choosing a Repository Layout        . repo/
            projA/
                branches/
                tags/
                trunk/
            projB/
                branches/

                tags/

                trunk/
    $ create Repository Layout;
    $ cd repo;
svn import . file:///wrk/svn/ssd/repos (import empty layout dirs only)    $ svn import teal/ file:///wrk/svn/ssd/repos/teal/trunk --message "initial teal import"
    $ svn import csim/ file:///wrk/svn/ssd/repos/csim/trunk --message "initial csim import"
    $ svn co file:///wrk/svn/ssd/repos/teal/trunk teal
    $ svn co file:///wrk/svn/ssd/repos/csim/trunk csim
    - how to patch [1 ] [2]
  
    $ sudo svn import proto/ file:///home/svn/repos/proto/trunk --message "initial proto import"
    $ svn co http://taipei/repos/proto/trunk proto

= x264 related (TODO)
x264.exe -b 1 --qp 10 -B 1000 -o output.h264 foreman_part_qcif.yuv 176x144
mplayer.exe -vo yuv4mpeg -vf dect -nosound dolby-city.vob
x264 -o output.h264 stream.y4m --frames 200 --crf 24 -b3 -m9 -r3 --me tesa -8 -t1 --mixed-refs --progress
gprof path-to-x264.exe gmon.out > x264.profile
the most critical part is Motion Estimation (~50%)

what are you trying to do ? output a raw video file ?

ffmpeg -i input -f rawvideo -vcodec rawvideo output

or -f yuv4mpegpipe -vcodec rawvideo (or -f rawvideo -vcodec yuv4mpegpipe ?)

= change login shell: ypchsh
    3  cp ~ethan/.bash_profile .
    4  cp ~ethan/.bashrc .
    5  cp ~ethan/.sh_alias .
    6  cp ~ethan/.profile .
   15  cp ~ethan/bin/* .
   23  cp ~ethan/.eda_tools .
   77  cp -a ~ethan/.vim .
   78  cp -a ~ethan/.vimrc .
   79  cp -a ~ethan/.gvimrc .

= dnsmasq: a light weight tool for DHCP and DNS

= gdbtui
    + CTRL-L to refresh/redraw the screen

= hime (中文輸入法), ubuntu 12.04
    sudo apt-get install hime
    gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"
    sudo glib-compile-schemas /usr/share/glib-2.0/schemas
    sudo cp noseeing.gtab /usr/share/hime/table/

= gcin, ubuntu 10.04
    + im-switch -s gcin
    + noseeing: /usr/share/gcin/script/noseeing-inst (install boshimi)
    + 系統->偏好設定->gcin 輸入法設定->Default input method and toggle key->勾選 Remote client support (port 9999-) (解決 gcin 被 GDM 預先啟動的問題)

= wagig, ubuntu
    sudo apt-get install wajig

    installr Install package and associated recommended packages
    installrs Install package and recommended and suggested packages
    installs Install package and associated suggested packages

       sudo wajig installrs mozilla-thunderbird
       (replace wajig with apt-get)
       http://ubuntuforums.org/showthread.php?t=43382

= update-rc.d, ubuntu
    - update-rc.d cadence defaults 99
    - How-To: Managing services with update-rc.d

= how to create torrent file
    - maketorrent: http://www.dessent.net/btfaq/#maketorrent
    - tracker list: http://torrentfreak.com/how-to-create-a-torrent/
    - example:
        maketorrent-console http://open.tracker.thepiratebay.org/announce <file/dir>

= dpkg-query -S (Find the package a file is from)

= Setting up VMWare shared folders on Ubuntu guest (for both 12.04 and 10.04)

2009-11-05

ubuntu tips

Ubuntu Server Settings
  • pppoe: sudo pppoeconf
  • Network Time Protocol: sudo apt-get install ntp
  • How-To: Manage services with "update-rc.d"
    sudo update-rc.d _service_name_ defaults 99
  • Internet Connection Sharing: dnsmasq(dns+dhcpd) + Firewall(ufw)
    sudo ufw allow 22
    sudo ufw allow 80
    sudo ufw allow from 10.1.1.0/24

    # to enable DHCPD on eth0:
    sudo ufw allow in on eth0 from any port 68 to any port 67 proto udp
    check also "ufw Masquerading"
  • Firewall (ufw) setting for vsftpd:
    sudo ufw allow ftp
    sudo ufw allow 20/tcp
  • DynDNS
  • gitosis: step to restore git repositories
    • restore ssh keys to /etc/ssh
    • restore git directory to /home/git
    • chown -Rf git:git git


2009-11-01

Ubuntu 安裝中文字型

從 vista 安裝標楷體、細明體等字型到 ubuntu :
sudo mount /dev/sda2 /mnt
sudo mkdir /usr/share/fonts/truetype/ttf-microsoft
cd /mnt/Windows/Fonts
sudo cp mingliu.ttc kaiu.ttf simkai.ttf simfang.ttf \
            simhei.ttf simsunb.ttf simsun.ttc msjh* \
            /usr/share/fonts/truetype/ttf-microsoft/
sudo fc-cache -f -v

sudo apt-get install ttf-mscorefonts-installer


參考文章:
[Ubuntu] 安裝中文字型(文鼎字型、微軟正黑體)
「親愛的」搞定ttf-mscorefonts-installer安裝時出現的錯誤