Sunday, November 28, 2010

Configure gtalk in pidgin

Basic Tab
Protocol: xmpp
Username ; username_only (no need for @gmail)
Domain: gmail.com
Resource: Home
Password: Your_GMAIL_ Password

Advance tab
Force old (port 5223) SSL: Checked
Allow plaintext auth over unencrypted streams: Un-Checked
Connect Port: 443
Connect Server: talk.google.com
File Transfer For Proxies: Leave blank or proxy.jabber.org

Proxy type
Use Global Proxy Settings

Tuesday, November 23, 2010

create shared C library

How to create and use your own shared C library using gcc? This can be done in 4 steps.
  1. write your library code, say sum.c with header file sum.h, and save them in your library folder, say ~/local/lib for the source, and ~/local/include for the header file.

  2. compile it using gcc

    gcc -I ~/local/include -c sum.c

    This will produce a object file sum.o

  3. create a static library named "hash", do

    ar rcs libhash.a sum.o

    More than one *.o files can be included in single library

  4. you are ready to use it by :
    • include the "sum.h"
    • compile it using gcc -I ~/local/include -L ~/local/lib -lhash ...
    To save typing -I xxx and -L xxx every time to use the library, save the path for auto lookup by adding the following lines to ~/.bashrc or ~/.bash_profile:

    # for header files
    export C_INCLUDE_PATH=~/local/include:$C_INCLUDE_PATH
    # for linking library
    exprot LD_LIBRARY_PATH=~/local/lib:$LD_LIBRARY_PATH
    export LIBRARY_PATH=~/local/lib:$LIBRARY_PATH
For more readings on differences of shared and static library, see here.

Thursday, November 18, 2010

Timing in C

#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>


typedef
uint64_t u64;
static inline
u64 T2L()
{

struct
timeval tv;
gettimeofday(&tv, NULL);
return
1000000ULL * tv.tv_sec + tv.tv_usec;
}


static
u64 _t_start_;
u64 tstart()
{

_t_start_ = T2L();
return
_t_start_;
}


u64 tdiff()
{

return
T2L() - _t_start_;
}


void
ptdiff()
{

u64 d = T2L() - _t_start_;
printf("%lu sec %lu usec\n", d/1000000, d%1000000);
}

Monday, July 12, 2010

My Experience with Latex

Most of the papers on Maths, especially those with mathematical formulas, are typeset with Latex. Here I list some of tips:

  1. To include images with different formats:
    • PDF, one can use pdflatex to compile
    • ps, eps, use latex
    Sometimes, when one has to latex (because of some other packages used), one can convert the formats of the images, using the command
    convert

  2. To draw and include pictures, as I mentioned in previous posts, I use JPicEdt for editing to pst files, and then include them by
\include{picture.pst}

However, when pst format is used for Latex, one has to use three steps to compile:
latex -> dvi2ps -> ps2pdf

in order to get the PDF file.

Monday, May 31, 2010

reinstalled ubuntu 9.10

Here is what I do to customize it according to my working package:
  1. sudo apt-get update
  2. Chinese Support:
    sudo apt-get install ibus ibus-qt4 ibus-pinyin
    im-switch -s ibus
  3. vim: my favorite editor and copy my customized .vimrc file
    sudo apt-get install vim
  4. To add me to sudoer list, and enable the nopasswd function to avoid keep keying in the password. see: /etc/sudoers
  5. Customize my firefox:
    • enable the add-on Xmarks, and greasemonkey for downloading google PDF documents
    • sudo aptitude install ubuntu-restricted-extras (flashplayer)
    • sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts(jre)
  6. IM - pidgin with integrated skype
    • sudo apt-get install pidgin
    • download http://www.skype.com/go/getskype-linux-beta-ubuntu-32
    • http://eion.robbmob.com/skype4pidgin.deb
    • sudo dpkg -i *.deb
  7. workspace: kile, latex, etc
    • sudo apt-get install kile jabref rapidsvn meld okular
    • configure rapidsvn to use kile and meld
    • download and install: http://downloads.sourceforge.net/jpicedt/jpicedt-install_1_4_1_03_20071021.jar?download
    • add llncs.cls to /usr/share/texmf/tex/latex/guojian/; sudo texhash
  8. Eclipse with C/C++
    • sudo apt-get install eclipse
    • Help >> Install New Software, select "Galileo Update Site - http://download.eclipse.org/releases/galileo/", and choose "Eclipse C/C++ Development Tools"
  9. Lastly, copy my customized .bashrc, download from: here
That's all for today :-)

Saturday, November 7, 2009

Install Chinese input method

Recent ubuntu versions switch to use ibus as the system input. ibus supports chinese well also, so I switch from scim. To install

sudo apt-get install ibus ibus-qt4 ibus-pinyin
im-switch -s ibus

Saturday, October 24, 2009

clone ubuntu to new disk

source is from here.

"I always make this, booting from Ubuntu live cd and using dd to make a copy from older disk to newer disk

Assuming /dev/hda size is <>

Open a terminal and type:

sudo -i

fdisk -l

dd if=/dev/hda of=/dev/hdb

Replace /dev/hda with your Ubuntu Drive
Replace /dev/hdb with the drive you wish to copy TO!

check & double check the fdisk -l output

Unplug the older disk and keep it as secure backup of your current installation for a while and plug the new hard disk as primary and boot your pc.
After you can put your old disk as secondary on the same pc or use it on a different pc (it usually works, you might need to reconfigure graphics layer) .

Then booting from Ubuntu live cd and using System → Administration → Partition editor, increase the just copied partitition size to fill new disk size (bigger than previous disk).

This is my usual Ubuntu cloning method...

Hope this helps"