2012年11月29日 星期四

Matlab Graphics: Greek Symbols

text(x,8,’\alpha :’); text(x1,8,’\\alpha’);
text(x,7,’\beta :’); text(x1,7,’\\beta’);
text(x,6,’\gamma :’); text(x1,6,’\\gamma’)
text(x,5,’\delta :’); text(x1,5,’\\delta’)
text(x,4,’\epsilon :’); text(x1,4,’\\epsilon’)
text(x,3,’\kappa :’); text(x1,3,’\\kappa’)
text(x,2,’\lambda :’); text(x1,2,’\\lambda’)
text(x,1,’\mu :’); text(x1,1,’\\mu’)
text(x,0,’\nu :’); text(x1,0,’\\nu’)
text(y,8,’\omega :’); text(y1,8,’\\omega’)
text(y,7,’\phi :’); text(y1,7,’\\phi’)
text(y,6,’\pi :’); text(y1,6,’\\pi’)
text(y,5,’\chi :’); text(y1,5,’\\chi’)
text(y,4,’\psi :’); text(y1,4,’\\psi’)
text(y,3,’\rho :’); text(y1,3,’\\rho’)
text(y,2,’\sigma :’); text(y1,2,’\\sigma’)
text(y,1,’\tau :’); text(y1,1,’\\tau’)
text(y,0,’\upsilon :’); text(y1,0,’\\upsilon’)
text(z,8,’\Sigma :’); text(z1,8,’\\Sigma’)
text(z,7,’\Pi :’); text(z1,7,’\\Pi’)
text(z,6,’\Lambda :’); text(z1,6,’\\Lambda’)
text(z,5,’\Omega :’); text(z1,5,’\\Omega’)
text(z,4,’\Gamma :’); text(z1,4,’\\Gamma’)

[Ref]
http://www.cs.cornell.edu/courses/cs100m/2007fa/Graphics/Greek.pdf

2012年9月23日 星期日

install LDOCE5 on CentOS6

Environment:

CentOS 6 x86_64

1.
> cd 'folder of LDOCE5 iso'/ linux
> sudo linux32 ./setup.sh

2. 
error message:
(ldoce5-bin:16815): Gtk-WARNING **: 'clearlooks'

> yum install gtk2-engines.i686

3.

only the user who installed LDOCE5 can use this software
Others can't execute this software.
Each user must install the software for his own usage
> linux32 ./setup.sh


[Ref]
http://terrywang.net/archives/914
http://tw.myblog.yahoo.com/chrysler-wrangler/article?mid=730&prev=764&l=f&fid=10
http://yang.backoz.info:88/post/1/2010/05/02/918

2012年9月13日 星期四

Install XnViewMp on CentOS 6/7

OS: centos 6.3/7
Desktop: Gnome 2

Steps:
 1.
> su
> cd /opt
> wget  http://download.xnview.com/XnViewMP-linux-x64.tgz

2.
> tar -zxvf  XnViewMP-linux-x64.tgz

3.
> cd /opt/XnView/
> vi XnView.desktop
----------------------------------------

[Desktop Entry]
Encoding=UTF-8
Terminal=0
Exec=/opt/XnView/xnview.sh
Icon=/opt/XnView/xnview.png

Type=Application
Categories=Graphics;
StartupNotify=true
Name=XnView Multi Platform
GenericName=XnViewMP
-------------------------------------------

4.
> cp XnView.desktop /usr/share/applications/

5. execute
> ./xnview.sh

6.
Done

Method 2:
[XnViewMP]
>> yum install qt5-qtbase qt5-qtbase-common qt5-qtbase-gui qt5-qtscript xcb-util-renderutil xcb-util-wm qt5-qtmultimedia qt5-qtsensors qt5-qtsvg qt5-qtwebkit qt5-qtx11extras
>> wget http://download.xnview.com/XnViewMP-linux.x86_64.rpm
conflicts with filesystem:
>> yum install  rpmrebuild
>> rpmrebuild -ep XnViewMP-linux.x86_64.rpm
Your configured editor (probably vi) will pop up with an already loaded file.

Search for the lines containing / and /usr/bin (lines like %dir %attr(0755, root, root) "/"), and remove them. They are starting in about line 340.
(I removed the line with /usr as well.)

Save end exit.
Answer yes. It will then tell you the location of the fixed rpm.
 

>> rpm -ivh  XnViewMP-linux.x86_64.rpm
>> xnview &
done



2012年9月11日 星期二

CentOS reference sites

http://godontop.com/category/red-hat/page/3

http://www.ichiayi.com/wiki/tech/centos-pdf

2012年9月9日 星期日

Charge your motor battery with normal charger






[Ref] http://shopping.pchome.com.tw/CGAA7M-A44738888

Sometimes your motorcycle may be out of power.
Don't change your old battery immediately. In some cases, you can charge your battery as in this case.

Pieces of Equipment: 
1. charger DC out about 12V 1A
2. connectors (hand made)
3. used battery (Lead-acid battery)


Setup:



My charging record:
Measured Voltage @ Time
9.57V @ 0 min
9.58V @ 30 mins
9.59V @ 60mins
9.60V @ 90mins
9.60V@ 120mins
12.04V@ 150mins
12.10V@180mins
12.15V@210mins
12.20V@240mins
12.25V@270mins
------------------------
stop charging
and put the battery back to my motorcycle

2012年9月4日 星期二

Accelerating NFS by cachefilesd

OS: CentOS 6.3

Step 1:
> yum install cachefilesd

Step 2:
> vi /etc/cachefilesd.conf
(I choose the default values and change nothing)

Step 3:  
> /etc/init.d/cachefilesd restart

Step 3:
>mount -t nfs -o fsc 192.168.1.1:/home/nfs /mnt/nfs

in my case
>mount -t nfs -o rw,bg,fsc 192.168.1.1:/nfs /nfs

PS.
1. I still don't figure out how to setup the limitation for the cache files.
I would check it out later
2. Sometimes, the process 'gvfsd-metadata' may occupy 100% CPU performance
sol:
> kill -9 'UID of  "gvfsd-metadata" '
> rm -fr ~/.local/share/gvfs-metadata


[ref]
1. http://www.cyberciti.biz/faq/centos-redhat-install-configure-cachefilesd-for-nfs/

2012年8月19日 星期日

Solution to The Crash Caused by 'Win7 64 + Firefox 13 + Flash 11.3'

Environment:

OS: Win 7 x64
Firefox 13/17
Flash 11.3

Syndrome:
opening the CNN website, and find out the crash screen


















Solution:
Turn off the protected mode for firefox

Method:
1. edit 'C:\Windows\SysWOW64\Macromed\Flash\mms.cfg'
2. add 'ProtectedMode=0' to the bottom of the file
3. restart firefox
4. Done

2012年8月16日 星期四

install CentOS 6 from min installation to Desktop

1. boot from iso
2. minimal installization
3. yum groupinstall "Desktop"
4. yum groupinstall "X Window System"
5. yum groupinstall "Chinese Support"
6. vi /etc/inittab
    init 3 --> init 5
7. 

2012年8月5日 星期日

Laker: export layout with keeping the property of Mcells

In the main window

> File-> export -> stream
check 'Generate MCells to Prop No.' in the 'property' tab

> File -> import -> stream
check 'Generate MCell as Prop No.' in the 'property' tab


2012年7月29日 星期日

Win7 CD/DVD driver missing when installing

Mother Board: GA-X79-UD3
OS: Win7

Syndrome:
boot from DVD--> install program --> warning message "A required CD/DVD drive device driver is missing. If you..."

Valid solution for my case:
1. Boot from DVD
2. Don't install the system (BTW, you can't install your system in normal operation due to the mentioned warning message)
3. Choose 'repair your system' -> 'DOS mode' -> change drive to 'D' -> 'cd sources' --> execute the file 'setup.exe'
4. start installing in my case and everything goes well


2012年7月27日 星期五

Test HDD R/W speed in Linux

The most simple method to test HDD R/W speed in linux system

OS: Centos

> dd if=/dev/zero of=swapfile bs=1024 count=20480000
20480000+0 records in
20480000+0 records out
20971520000 bytes (21 GB) copied, 106.886 s, 196 MB/s

This hard disk should be with the spec of SATA II (3Gbps).

2012年7月21日 星期六

Linux: Pipe and xargs

I want to find certain files in a folder and its sub-folders, and then remove these files..

Here is the best solution I found.

find . | grep bak | xargs rm

or

find -iname "*.bak" | xargs rm

[Ref] http://blog.yam.com/ddy1280/article/13941218

2012年7月2日 星期一

Madedit crashed in Centos 6

After searching the internet, no one provides any solution for this issue.
Here is one solution.

OS: CentOS 6.3 x86_64

Syndrome:
installed by RPM
> madedit &
>> open new tab -> crashed and some message left in the terminal
'(core dumped) madedit'

Solution in 5 steps:
0. add additional lib for yum
> rpm -ivh ftp://ftp.cuhk.edu.hk/pub/linux/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

1.
> yum install boost boost-devel   wxGTK wxGTK-devel gtk2-devel gcc-c++
(i686 version required)

2
>  cd   /usr/local/src/

> wget  http://downloads.sourceforge.net/project/madedit/MadEdit/MadEdit-0.2.9/madedit-0.2.9.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmadedit%2Ffiles%2FMadEdit%2FMadEdit-0.2.9%2F&ts=1347185903&use_mirror=nchc


> tar -zxvf madedit-0.2.9.tar.gz

> cd   /usr/local/src/madedit-0.2.9/src/MadEdit
> vi MadEdit.cpp
//
Modify some content around line 9716
It may looks like the following text.
The red and underlined lines should be inserted.

-----------------------------------------------------------------------
//--- line 9716 ---///
void MadEdit::OnPaint(wxPaintEvent &evt)
{
    //--- add to avoid crash ---//
    if(m_ClientWidth==0 || m_ClientHeight==0) return;
    //--- end ---///


    wxPaintDC dc(this);
    wxMemoryDC memdc, markdc;

    wxWindow *focuswin=FindFocus();

    if(InPrinting())
-----------------------------------------------------------------------

3.
> cd  /usr/local/src/madedit-0.2.9
> ./configure
> make
> make install

4.
 Done

[Ref]  http://forum.ubuntu.org.cn/viewtopic.php?f=95&t=347254&start=15&sid=f4349b8a77616c9e3cda146aae2878e6&view=print
(you can also find the fixed deb package here. I didn't try this package yet.)



2012年6月10日 星期日

Probe in HSpice

1. plot the top level nodes

. option  POSTLVL= N
(N= 1--> top level, N=2--> only the second level)

or

.option POSTTOP

2.  the POSTTOP and POSTLVL options will be ignored if

.option PROBE

is also in the netlist.

[Ref]  http://www.designers-guide.org/Forum/YaBB.pl?num=1241031816

2012年5月8日 星期二

stop the spam from google groups

when you received an invitation from google groups, and
you  think it is a spam..

Just press 'CTRL+END' to the bottom of the mail, and you can find a
report URL to Google..

Wait and see if this behavior works...

BTW, when you received the spam from Yahoo..
The best method to stop it is block the whole content from '@YAHOO.com' & '@YAHOOgroups.com'..
Stupid but effective...

2012年5月3日 星期四

'cp' except for certain files

This is the best solution I found in the internet

final best solution in my case:
I must exclude two file types to accelerate the copy operation.
It looks like this:

rsync -avz --exclude '*.tr0' --exclude '*.wdf' CapDAC_8b CapDAC_8b_bak

Here is the source:

6 rsync Examples to Exclude Multiple Files and Directories using exclude-from

by Ramesh Natarajan on January 25, 2011
Rsync is very powerful tool to take backups, or sync files and directories between two different locations (or servers).
You know this already, as we presented you with practical examples on rsync earlier.
In a typical backup situation, you might want to exclude one or more files (or directories) from the backup. You might also want to exclude a specific file type from rsync.
This article explains how to ignore multiple files and/or directories during rsync with examples.

First, create a sample directory structure as shown below (with some empty files) that can be used for testing purpose.
$ cd ~
$ mkdir -p source/dir1/dir2
$ mkdir -p source/dir3
$ touch source/file1.txt
$ touch source/file2.txt
$ touch source/dir1/dir2/file3.txt
$ touch source/dir3/file4.txt
The above command will create a source directory (under your home directory) with the following structure.
source
- file1.txt
- file2.txt
- dir1
  - dir2
    - file3.txt
- dir3
  - file4.txt

1. Exclude a specific directory

If you don’t want to sync the dir1 (including all it’s subdirectories) from the source to the destination folder, use the rsync –exclude option as shown below.
$ rm -rf destination

$ rsync -avz --exclude 'dir1' source/ destination/
building file list ... done
created directory dest
./
file1.txt
file2.txt
dir3/
dir3/file4.txt
Verify to make sure dir1 is not copied from source directory to destination directory.
$ find destination
destination
destination/file2.txt
destination/file1.txt
destination/dir3
destination/dir3/file4.txt

2. Exclude multiple directories that matches a pattern

The following example will exclude any directory (or subdirectories) under source/ that matches the pattern “dir*”
$ rm -rf destination

$ rsync -avz --exclude 'dir*' source/ destination/
building file list ... done
created directory destination
./
file1.txt
file2.txt
Verify the destination directory to make sure it didn’t copy any directories that has the keyword “dir” in it.
$ find destination
destination
destination/file2.txt
destination/file1.txt

3. Exclude a specific file

To exclude a specific file, use the relative path of the file in the exclude option as shown below.
$ rm -rf destination

$ rsync -avz --exclude 'dir1/dir2/file3.txt' source/ destination/
building file list ... done
created directory destination
./
file1.txt
file2.txt
dir1/
dir1/dir2/
dir3/
dir3/file4.txt
Verify the destination directory to make sure it didn’t copy the specific file ( dir1/dir2/file3.txt in this example).
$ find destination
destination
destination/file2.txt
destination/file1.txt
destination/dir1
destination/dir1/dir2
destination/dir3
destination/dir3/file4.txt

4. Exclude path is always relative

If you are not careful, you might make this mistake.
In the following example, the exclude option seems to have a full path (i.e /dir1/dir2/file3.txt). But, from rsync point of view, exclude path is always relative, and it will be treated as dir1/dir2/file3.txt. In the example below, rsync will look for dir1 under source directory (and not under / root directory).
$ rsync -avz --exclude '/dir1/dir2/file3.txt' source/ destination/
So, the above command is exactly same as the following. Just to avoid confusion (and to make it easy to read), don’t give / in front of the exclude path.
$ rsync -avz --exclude 'dir1/dir2/file3.txt' source/ destination/

5. Exclude a specific file type

To exclude a specific file type that has a specific extension, use the appropriate pattern. For example, to exclude all the files that contains .txt as extension, do the following.
$ rsync -avz --exclude '*.txt' source/ destination/
building file list ... done
created directory destination
./
dir1/
dir1/dir2/
dir3/
Verify the destination directory to make sure it didn’t copy the *.txt files.
$ find destination
destination
destination/dir1
destination/dir1/dir2
destination/dir3
Note: The above is very helpful, when you want to backup your home directory, but exclude all those huge image and video files that has a specific file extension.

6. Exclude multiple files and directories at the same time

When you want to exclude multiple files and directories, you can always specify multiple rsync exclude options in the command line as shown below.
$ rsync -avz --exclude file1.txt --exclude dir3/file4.txt source/ destination/
Wait. What if I had tons of files that I want to exclude from rsync?
I can’t keep adding them in the command line using multiple –exclude, which is hard to read, and hard to re-use the rsync command for later.
So, the better way is to use rsync –exclude-from option as shown below, where you can list all the files (and directories) you want to exclude in a file.
First, create a text file with a list of all the files and directories you don’t want to backup. This is the list of files and directories you want to exclude from the rsync.
$ vim exclude-list.txt
file1.txt
dir3/file4.txt
Next, execute the rsync using –exclude-from option with the exclude-list.txt as shown below.
$ rm -rf destination

$ rsync -avz --exclude-from 'exclude-list.txt' source/ destination/
building file list ... done
created directory destination
./
file2.txt
dir1/
dir1/dir2/
dir1/dir2/file3.txt
dir3/
Verify the desitination directory to make sure the files and directories listed in the exclude-list.txt file is not backed-up.
$ find destination
destination
destination/file2.txt
destination/dir1
destination/dir1/dir2
destination/dir1/dir2/file3.txt
destination/dir3
 
[Ref] http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/

2012年5月2日 星期三

return remote screen

[TCSH]
setenv    DISPLAY    "192.168.100.30:20.0"
 echo $DISPLAY
abc &

[BASH]
export DISPLAY="192.168.100.30:20.0"
 echo $DISPLAY
abc &

2012年4月22日 星期日

DFF counter reference

Synchronous counter (D flipflops)

applet icon
The image above shows a thumbnail of the interactive Java applet embedded into this page. Unfortunately, your browser is not Java-aware or Java is disabled in the browser preferences. To start the applet, please enable Java and reload this page. (You might have to restart the browser.)


Circuit Description
A 4-bit synchronous counter built from D-flipflops with carry-input (count-enable) and carry-output. In this circuit, the single clock signal is directly connected to all flipflops, so that all flipflops change state at the same time.
Click the clock and nreset input switches or type the 'c' (clock), 'r' (reset), and 'x' (carry-in) bindkeys to operate the counter.
Obviously, this counter consists of four identical stages with a D-type flipflop, an XOR-gate, and a two-input AND-gate each. The XOR-gate in front of the D input of the flipflop basically converts the D-type flipflop into a toggle (T-type) flipflop. This is the same structure as the JK-flipflop with both J and K tied to logical-1, as shown in the previous applet.
While the carry-logic shown in the previous applet required an n-input AND gate for stage n, the carry-chain used in this applet is based on two-input gates. The difference in structure is similar to the carry-lookahead and the ripple-carry adders shown in the previous chapter. Obviously, the output of any AND gate is only high when all lower stage AND gates (and the carry input) are also high.
In other words,
Dn = Qn XOR (Qn-1 AND Qn-2 AND ... AND Q1 AND Q0 AND carry_in) 

[ref] http://tams-www.informatik.uni-hamburg.de/applets/hades/webdemos/30-counters/30-sync/sync-dff.html

A CMOS IC implementation of a "true single-phase edge-triggered flip-flop with reset"
 
[ref] http://en.wikipedia.org/wiki/Flip-flop_%28electronics%29
 

2012年4月13日 星期五

SSH login without password

1. execute this command as a normal user
>> ssh-keygen

2. in the ~/.ssh folder
>> cat id_rsa.pub >> authorized_keys

3. done

2012年4月9日 星期一

How to execute m-file in the Linux terminal background/foreground?

foreground execution in the terminal mode:
>> matlab -nojvm -nodisplay -nosplash

background execution in the terminal mode:
>> nohup matlab -nojvm -nodisplay -nosplash < 123.m > report123.log &

Ref:
[1]  http://www.math.ufl.edu/help/matlab/tec1.1.html

fonts in Centos 6 for matlab

'zero' and 'o' are distinguishable
    bitstream Vera Sans Mono
     DejaVu LGC Sans Mono
    Liberation Mono

Every letter has equal width
    Bitstream Vera Sans Mono
    Courier
    Courier 10 Pitch
    DejaVu LGC Sans Mono
     Dialoginput
    Liberation Mono
    Lucida Dans Typewriter
    Luxi Mono
    Monospaced
    Nimbus Mono L
    
Chinese words supported
    
    Dialog
    Dialoginput
    Monospaced
    SansSerif
     Serif
    ... other fonts with Chinese name
   
   
   

2012年4月7日 星期六

install nxserver on centos 6

I use matlab in linux server (centos)
Three remote control methods have different disadvantages..
XDMCP + SSH tunnel +matlab -->very very SLOW
VNC + Matlab--> crash sometimes and keypad disorders
   (press '0123456' in matlab command line, and the result shows '012456')
NXserver + Matlab --> lags when you scroll down in Matlab editor...
I can't find an excellent method in using Matlab in Centos 6...


Due to the application in a small group
the install guides on the internet are not suitable for me
so I write down some tips for myself

Environment:
Centos 6
SSH version 2 works well

Tips:
1. install
>> yum install nx freenx 

2. 
>> vi /etc/nxserver/node.conf
"SSHD_PORT=1234" 
"ENABLE_SSH_AUTHENTICATION="1"
 
>> vi /etc/ssh/sshd_config
"PasswordAuthentication yes" 

3.
service sshd restart 
 
4. 
nxserver --restart
 
5.
cat /var/lib/nxserver/home/.ssh/client.id_dsa.key
tell the client all the content of the file in some secret way
It may look like
"-----BEGIN DSA PRIVATE KEY-----
MIIBuwIBAAKBgQCXv9AzQXjxvXWskX9YomTfyG865gb4D02ZwWuRU/9
C3I9/bEWLdaWgJYkmWjjeSZyTmeoypI1iLifTHUxn3b7WNWi8AzKcVF
QU7TGVLk2CzY4dasrwxJ1f6FsT8DHTNGnxELPKRuR7KeafeFZDf+fJ3
mbX5nxrld3wi5titTnX+8s4IKv29HJguPvOK/SI7cjzA+SqNfD7qEo8CFDIm1xRf
8xAPsSKs6yZ6j1FNklfu
-----END DSA PRIVATE KEY-----" 
 
6.
download the client from the nomachine official website