Sunday, May 31, 2009

Python 4


getopt.getopt(args, options[, long_options])

Parses command line options and parameter list. args is the argument list to
be parsed, without the leading reference to the running program. Typically, this
means sys.argv[1:]. options is the string of option letters that the
script wants to recognize, with options that require an argument followed by a
colon
(':'; i.e., the same format that Unix getopt uses).

Saturday, May 30, 2009

Install java plugin for Firefox

sudo aptitude install sun-java6-plugin

Python 3

1. Parentheses are optional

2. End of line is end of statement

3. End of indentation is end of block
Inside a block all the indentation should be the same.

4. Multi-statements per line, separate them using semicolon ';'
 
5. One statement span across multiple lines, by putting the statements into a bracketed pair - parentheses "()", square brackets "[]", or dictionary braces "{}".

6. raw_input() for console input

7. print to file: print >> filename, a, b, c

8. Statements execute one after another, until you say otherwise

9. Block and statement boundaries are detected automatically

10. Compound statements=header,":" indented statements

11. Blank lines, spaces, and comments are usually ignored

12. Docstrings are ignored, but saved and displayed by tools

13. A=Y if X else z

14. while
      while <test1>:
               <statements1>
      else:
               <statements2>


15. pass, continue, break, else

16. for
      for <target> in <object>:
               <statements1>
      else:
               <statements2>


17. the else statement in while and loop will be executed only when the loop is terminated because of the testing condition is broken, i.e. else statement won't be executed when the loop is stopped by a break in the <statements1>.

18. File scanners:
read file character by character
      for char in open('test.txt').read():
              print char

read file line by line
     for line in open('test.txt').realines():
             print line

or
     for line in open('test.txt').xreadlines():
              print line

readlines() load the file once, xreadlines() load the file when demanded.
We can also
     for line in open('test.txt')
             print line


19. range()

20. Parallel Traversals: zip and map
Using zip to construct dictionaries.

21. Don't forget the colons

22. Start in column 1

23. Blank lines matter at the interactive prompt

24. Indent consistently.

25. Don't code C in python

26. Use simple for loops instead of while or range

27. Beware of mutables in assignments

28. Don't expect results from functions that change objects in-place

29. Always use parentheses to call a function

30. Don't use extensions or paths in imports and reloads

31. def Statements for function definition
    def <name>(arg1, arg2,..., argN):
           <statements>
           return <value>

32. Python Scope Basics
    a. The enclosing module is a global scope;
    b. The global scope spans a single file only;
    c. Each call to a function creates a new local scope;
    d. Assigned names are local unless declared global;
    e. All other names are enclosing locals, globals, or built-ins.

33. Immutable arguments are passed by value
      Mutable arguments are passed by pointer

34. lambda Expressions
    lambda arg1, arg2,... , argN : expression using args


Python 2

1. Dictionary
Mapping operations:
    d['quantity']+=1
Create a dictionary:
    d={}
    d['name']='bob'
    d['job']='dev'
    d['age']=40

Nesting:
    d={'name':{'first':'Bob','last':'Smith'},'job':['dev','mgr'],'age':40.5}
    res['name']['first'] is the 'Bob'

We can not sort the dictionaries directly, but we can sort the keys.
    ks=d.keys()
    ks.sort()
    for key in  ks: print key, '=>', D[key]

Another way is:
    for key in sorted(D): print key, '=>', D[key]

2. Iteration
    squares=[x**2 for x in [1,2,3]] #result is [1,4,9]

3. Performance
using time and timeit modules and the profile module to find more information about the code.

4. Check missing keys
We can add new keys to dictionaries, but fetching nonexistent keys are still a mistake.
    d.has_key('f')
    if not d.has_key('f'): print 'missing'

5. Tuples
    t=(1,2,3)
tuples are similar to list, but they are immutable, they cannot be changed in place.

6. Files - core type of python
    f=open('data.txt','w')
    f.write('Hello\n')
    f.close()
read mode is the default one.
    f=open('data.txt')
    bytes=f.read()  #read entire file into a string, here bytes is 'Hello\n', noticing the control characters
   
7. Set
    X=set('spam')  #result set(['s','p','a','m'])
    Y=set(['h','a','m'])
    X&Y  #intersection
    X|Y    #union
    X-Y    #difference

8. Decimal

9. check the type
    if type(L)==type([]): print 'list'
    if type(L)==list: print 'list'
    if isinstance(L,list): print 'list'

10. string format of numeric data
    num=1/3.0
    "%e" % num     #result '3.3333e-001'
    "%2.2f"  %  num    #result '0.33'


Friday, May 29, 2009

Python I

1. Unix Shell Scripts
     #! /usr/bin/env python
     ...script goes here...

2. Pause the script
    raw_input()

3. Python built in types
    Numbers      1234, 3.14, 999L, 3+4j, Decimal
    Strings          'spam', "guido's"
    Lists              [1,[2,'three'],4]
    Dictionaries   {'food':'spam', 'taste':'yum'}
    Tuples            (1,'spam',r,'U')
    Files               myfile=open('eggs','r')
    Other types    Sets, types,None,Booleans


4. math module contains more advanced numeric functions
    import math
    math.pi
    math.sqrt(85)

5. random module performs random number generation and random selections
    import random
    random.random()
    random.choice([1,2,3,4])

6. String in python
     len(S) #length
     S[0]    #the first character of string S
     S[-1]   #the last item of string S
     S[1:3]  #substring of S, includes S[1] and S[2], without S[3]
     S[0:]
     S[:3]
     S[:-1]
     S[:]
     s1+s2   # concatenation
     s*8       # repetition

   Notice: string objects in python are immutable, we can never change the content of the string, only can we create new strings.
    s[0]='z'  will cause error
    s='z'+s[1:] is the correct way
    s.find('pa')  # find substring
    s.replace('pa','XYZ') #replace

    These functions don't change the original string.
    s.split(',')
    s.upper()
    s.isalpha() #content tests: isalpha, isdigit, etc
    s.rstrip() #remove whitespace on the right side


7. use dir(object) function to see what methods it has.
 
8. to ask about what each function does, use help(object.function)

9. show the value of character, ord('\n')

10. re module for regular expression
    import re
    match=re.match('/(.*)/(.*)/(.*)','/usr/home/jack')
    match.groups() #output is ('usr','home','jack')

11. List is mutable, i.e. changed in place unlike string.
     l[0]='123'
     l.append('NI')
     l.pop(2)
     l.sort()
     l.reverse()

12. arbitrary nesting is supported
     M=[[1,2],[3,4]]
     M[1]    # result is [3,4]
     M[0][1]   # result is 2

13. List comprehension - accessing columns
     c=[row[1] for row in M]  # result is [2,4]

Thursday, May 28, 2009

QuickNet II

1. Install dpwelib. Get it from http://www.icsi.berkeley.edu/~dpwe/projects/sprach/sprachcore.html (http://www.icsi.berkeley.edu/%7Edpwe/projects/sprach/dpwelib-2009-02-24.tar.gz).

Just type "./configure"
then "make"
last "sudo make install"
It's done.
You will find those tools in "/usr/local/bin" and "/usr/local/lib".

2. Install feacat. Get it from http://www.icsi.berkeley.edu/~dpwe/projects/sprach/sprachcore.html (ftp://ftp.icsi.berkeley.edu/pub/real/davidj/feacat.tar.gz).

Make sure dpwelib and quicknet are installed.
Then type "./configure --with-dpwelib=/usr/local/lib --with-quicknet=/usr/local/lib"
Next "make"
Last "make install".
It's done.
You will find the tool feacat in "/usr/local/bin".

Dawn M. Taylor on Brain-Computer Interfaces

Dawn M. Taylor on Brain-Computer Interfaces
Computerworld (05/18/09) Anthes, Gary
Brain-computer interface research is finally starting to take off because the expansion of computer capacity has broadened people's ability to digitize and process numerous individual neural impulses concurrently and apply more sophisticated mathematical decoding algorithms to those impulses, says Case Western Reserve University professor Dawn M. Taylor. She is a researcher at the Cleveland Functional Electrical Stimulation (FES) Center, where the focus is the restoration of movement and function to paralysis victims through the application of electrical current to the peripheral nerves. "Basically, we are reconnecting the brain to the muscles so people can control their paralyzed limb just by thinking about doing so," Taylor says. "Intended movements can also be used to control other technologies, such as prosthetic limbs, assistive robots, or a computer mouse." Taylor says the least invasive method for recording neural signals is external surface electroencephalograms, while sensors also can be implanted atop the brain, within the skull, or under the scalp. She says that ideally the same neurons should be recorded for decades so the brain can learn how to trigger those neurons to control a device. Taylor postulates that advancements in technology miniaturization and wireless communication should eventually enable the shrinkage of all the equipment and processors used in the lab to a package that can be carried on a wheelchair or implanted within the body. She says the FES Center has developed a hand-grasp system for people who cannot move their hands due to spinal cord injuries, which has been commercialized. Taylor also says that electrode technologies can be used to stimulate the brain and circumvent fissures in the neural pathways that bring sensory information in.

View Full Article | Return to Headlines

Tuesday, May 26, 2009

PSP slim hacked for ISO

This is really exciting. PSP 2000 has been hacked by dark alex for ISO.

What you need:
1. PSP Slim
2. PSP Firmware 5.03 or lower firmware

If you do not have either of the above, you just got to wait a bit longer. Sorry PSP 3000 peeps…

Things to do:
1. Run ChickHEN
2. Check out dark alex’s post.
3. Download the files here.

 

From: http://qisahn.com/blog/2009/05/psp-slim-hacked-for-isos/

 

What is?
A program that activates the functions of the M33 custom firmware using ChickHen.
What do I need?
- A PSP Slim (Slim only works with, regardless of the plate you have)
- Firmware version 5.03.
- ChickHen R2 (minimum)
Compatibility:
- The functions are the same with the 5.00 M33, all work except:
- Recovery (Se cree may be anticipated that an alternative power to set the homebrew CFW)
- Pops (PSX Games)
Installation:
- Copy the folder to your psp CFWEnabler in X: / PSP / GAME /
To be like this: X: / PSP / GAME / CFWEnabler / EBOOT.PBP
How to use:
Starts ChickHen from the picture section. Then start the homebrew called for CFW Loader ChickHEN.
The first time you need CFW to install modules into the flash memory with the option Circle (Do not override, simply add modules, it is a safe process.)
Then press X to start the CFW.
You are in a CFW!
FAQ:
- Can load isos? - Yes, yes you can.
- Do you like my PSP Slim is fucking plate? - Yes, it does not matter.
- Does my PSP3000? - No, not working, at least.
- Can you break my console? - It is true that he writes some files in internal memory, but does not overwrite anything, so this is not problematic.
- When you turn off the console I have to repeat the procedure? - Yes, you have to repeat it, but do not have Flash modules each time.
- And you can not prevent either procedure? - Could be avoided if we could do an IPL compatible, so you need information PreIPL.
- Is expected to be in the future rectify the current problems? - It is possible, but is not guaranteed anything.
- Is expected that a future compatible with PSP3000? - You might try, but is not guaranteed anything.
- Does the M33 SDK? - Yes, it works.
Acknowledgments:
- A Dark_AleX for the M33 modules.
- Especially him, who knows who he is, and that is part of the credit for helping him.
Un Saludo.

 

From:

http://translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&u=http://www.dark-alex.org/forum/viewtopic.php%3Ff%3D5%26t%3D14641%26start%3D0&sl=es&tl=en&history_state0=

 

PSP2000 TA88V3型破解玩ISO完全教程

目前市场上能够买到的全新PSP2000(仅限全新)均是采用TA88V3主板,无法使用神奇电池进行破解的机器。但现在随着PSP3000破解研究的深入,目前PSP2000 V3型主机已经可以通过TIFF漏洞成功模拟器5.00M33自制系统。换句话说,现在的PSP2000 V3已经能够玩ISO了。

破解操作很简单,玩家只需要拥有一台系统版本不高于5.03的PSP2000 V3主机,一根容量不限的记忆棒即可操作。

第一步,将系统升级到5.03官方系统

请先查看你的PSP系统(查看方法),如果低于5.03,请参考这里将PSP升级到5.03官方系统。

第二步,为PSP安装5.03HEN R2

参考这里的教程,在你的系统上运行TIFF漏洞并安装5.03HEN R2。

第三步,将5.03HEN R2模拟成5.00M33

首先请下载CFWEnabler1.0(下载地址),将其解压,拷贝其中的CFWEnabler文件夹到PSP记忆棒中的“PSP/GAME”目录下。

打开PSP,进入“游戏 - Memory Stick”,现在你应该能看到一个名为CFW Loader for ChickHEN的程序,如下图。

运行之后,进入CFWEnabler 1.0的操作界面,首先按○键,稍等几秒钟之后程序会提示写入完成。然后按×键,程序会提示将自动退出。

稍等片刻,我们就回到了PSP的XMB界面(正常界面)下了。现在再去看一下你的PSP系统版本,已经变成5.00M33啦!

特别说明

在玩ISO游戏的时候,需要将ISO文件放到根目录下的ISO文件夹下(无此文件夹请手动新建即可。)

如果ISO无法运行,请在正常的PSP界面下按Select键,会弹出一个菜单,然后将其中的UMD ISO Mode修改成M33 Driver后即可。

PSP汉化版游戏下载地址:http://games.tgbus.com/pspcn/

如果你在使用过程中遇到各种问题,请到这里提问:http://forum.tgbus.com/viewthread.php?tid=130026

 

 

From: http://software.tgbus.com/guide/psp/200905/20090526135026.shtml

Monday, May 25, 2009

Linux Shell Scripting

http://www.freeos.com/guides/lsst/

Linux Shell Scripting Tutorial v1.05r3

A Beginner's handbook


http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

BASH Programming - Introduction HOW-TO


Using QuickNet with tools not SPRACHcore

The SPRACHcore package has not been updated since 2004. We have
switched to releasing new versions of individual components of
SPRACHcore
. We recommend that you use the new versions. The most recent
version of the core neural net code (QuickNet) has many speed
improvements
and other enhancements and it is available here.
The most recent version (compatible with gcc4) of the dpwelib sound utilities
is

dpwelib-2009-02-24.tar.gz.
The most recent versions of feacat, feacalc, noway, and pfile_utils (a set of 18 feature file tools including pfile_klt)
are here.

Not build the whole SPRACHcore again!!!!!!



Soc Linux printing

9.
I
have 300 pages of dm quota. How can I make use of it?


You
can send your printjob to dmdmr. Please note that dmdmr
is not a network printer and it can only accept text file(*.txt).
You can send

printjob from unix env by the following command:


lpr
-Pdmdts filename


You
may collect your printouts in the drawer in front of Technical Services at COM1#01-06.


From: https://www.comp.nus.edu.sg/cf/faq/printingfaq.html#9

QuickNet - 1

Platform
--------

This testbed has only been tested on an x86 Red Hat Linux platform.

NOTE: Quicknet includes versions of the qnstrn MLP training tool that
are optimized for specific architectures such as the Pentium 4 or the
AMD Opteron.  Because these different versions of the tool use
different matrix routines, there may be different patterns of rounding
errors.  Thus if you want maximum scientific comparability of
different results, don't mix different versions of the qnstrn tool in
your experiments. 
(This is not expected to be a significant issue for
the forward pass tool, qnsfwd, because only training involves a
feedback process which can magnify the significance of different
rounding error patterns.)  For maximum comparability with the results
quoted in this README file, the tools/train script specifically
invokes the Pentium 4 qnstrn binary from Quicknet release 3.11, which
is named qnstrn-v3_11-P4SSE2 at ICSI.  (This binary cannot be used with older
processors which predate the Pentium 4, but it will run on an AMD
Opteron.)  To change this, edit the variable $qnstrnBinary in
tools/train.

tools/train invokes single-threaded MLP training.  On a multi-core
machine, training can be sped up by making it multi-threaded using the mlp3_threads option of qnstrn. 
The most convenient way to measure
training speed is by the MCUPS number reported in the qnstrn log
file. If you use more than one thread, you will probably get more
MCUPS if you increase the value of the mlp3_bunch_size option.
However, if it is increased too much, this can reduce the quality of
the trained MLP.  The maximum bunch size before this problem occurs
depends on the corpus.

Feature calculation
-------------------

The neural net software uses the pfile feature file format, which
stores the features for many utterances together in a single file.
The SPRACHcore feacalc tool can calculate a pfile of PLP features
directly.  Pfiles can be created from other feature file formats using
the SPRACHcore feacat tool.




Source for starting using Quicknet for MLP training

Source for starting using Quicknet for MLP training

http://www.icsi.berkeley.edu/Speech/papers/gelbart-ms/hybrid-testbed/

http://www.icsi.berkeley.edu/~dpwe/projects/sprach/sprachcore.html

Noisy Numbers data and Numbers speech recognizer


Noisy ISOLET and ISOLET testbeds


The SPRACHcore software package


ICSI Speech FAQ


Tembusu

1. Connect to the cluster:
ssh tembusu2.comp.nus.edu.sg -l [username]
Then you will be asked for the password. The username and password are the same with the mysoc account.

Official instructions are:
from: https://www.comp.nus.edu.sg/cf/tembusu/login.html
Introduction

Tembusu2 accounts (aka home directories) are SEPARATE and DELINKED from the standard SoC Unix account.



Instructions for Login to Linux-based nodes



You must first have created an account on tembusu2.


To login to any "access" node on the cluster, use


ssh -t -l username tembusu2


You will be directed to an available "access" node in a round robin fashion.


To login to a particular "access" node, eg. access5 or access10, use the following:


ssh -t -p 2005 -l username tembusu2

ssh -t -p 2010 -l username tembusu2


To access any "access" nodes from within the cluster, use:



ssh nodename



eg:

ssh access0


ssh access12


Tembusu2's "comp" nodes are meant for batch jobs and therefore, non login.



Instructions for Login to Solaris-based nodes

(Obsolete)



You must first have created an account on tembusu2.


Currently, there is only one Ultrasparc-based Solaris "access" node on the cluster. This can be accessed using the hostname saga.


ssh -t -l username saga



X11 connections



All
the cluster access nodes are configured to support SSH X11 tunneling.
This provides a secure way to forward any GUI applications to your
desktop. You just need to enable X11 support on your desktop to use
this feature when you connect to the cluster.


Do
note that even though the applications forwards the GUI to your
desktop, the application is really running on the access node you are
connected to. As such, it can only access the file system in tembusu
and have no access to any files on your desktop.


See here for instructions to enable X11 tunneling on you ssh client.




2. Check the available disk space
df
or
df -h /home/l/[username]

More information about this cluster https://www.comp.nus.edu.sg/cf/tembusu/index.html



Saturday, May 23, 2009

QUICKNET installation on Linux

1. Download the QuickNet on http://www.icsi.berkeley.edu/Speech/qn.html . ( ftp://ftp.icsi.berkeley.edu/pub/real/davidj/quicknet.tar.gz )

2. Download the ATLAS BLAS libraries from http://math-atlas.sourceforge.net/ . ( http://sourceforge.net/project/showfiles.php?group_id=23725 )

3. Download the rtst library for testing from http://www.icsi.berkeley.edu/Speech/qn.html . ( ftp://ftp.icsi.berkeley.edu/pub/real/davidj/rtst.tar.gz )

4. Download the example data files from http://www.icsi.berkeley.edu/Speech/qn.html . ( ftp://ftp.icsi.berkeley.edu/pub/real/davidj/quicknet_testdata.tar.gz )

5. Install ATLAS BLAS libraries.
5.1 Turn off CPU throttling.
Use the command: sudo /usr/bin/cpufreq-selector -g performance
Before this command, we can use the command: cat /proc/cpuinfo to see the current CUP information before changing it. Note the one "cpu MHz". Also if more than one processor is listed, do the cpufreq-selecrtor command for each processor, using the command " sudo /usr/bin/cpufreq-selector -c 1 -g performance" to turn off throttling for the second processor, as the first processor is denoted as processor 0 and is the default one when "-c " is not specified.
After issue the command turning off the CUP throttling, we can use the command "cat /proc/cupinfo" to list out the information of the CPU, then you will see that the "cpu MHz" has been increase.
5.2 After all the processors are set to the performance mode, Extract the source from the downloaded tarball file. And create a build folder under the ATLAS folder, for example named with "build".
Then first "cd" to the ATLAS folder.
cd build
../configure -b 64 -D c -DPentiumCPS=2400

"-b 64" set the target to be 64 bit, which is recommanded if no other reasons.
"-D c -DPentiumCPS=2400" tells the configuration the CPU is Cour2Core 2.4GHz.
After I type the above command, it prompts errors saying that no Fortran compiler is found. Then,
sudo apt-get install gfortran
sudo apt-get install fort77

Next redo the command "../configure -b 64 -D c -DPentiumCPS=2400".
At the last line, "DONE configure" is printed out, yes!
5.3 Type command : make build
After several steps during building, i got following errors:
ATL_dset_xp1yp0aXbX.c: Assembler messages:
ATL_dset_xp1yp0aXbX.c:96: Error: bad register name `%rsp)'
ATL_dset_xp1yp0aXbX.c:97: Error: bad register name `%rsp)'
ATL_dset_xp1yp0aXbX.c:101: Error: bad register name `%rsi)'
ATL_dset_xp1yp0aXbX.c:102: Error: bad register name `%rsi'
make[6]: *** [ATL_dset_xp1yp0aXbX.o] Error 1
make[6]: Leaving directory `/home/troy/Software/quicknet/ATLAS/build/src/blas/level1'
make[5]: *** [dgen] Error 2
make[5]: Leaving directory `/home/troy/Software/quicknet/ATLAS/build/src/blas/level1'
make[4]: *** [dlib] Error 2
make[4]: Leaving directory `/home/troy/Software/quicknet/ATLAS/build/src/blas/level1'
make[3]: *** [lib.grd] Error 2
make[3]: Leaving directory `/home/troy/Software/quicknet/ATLAS/build/src/auxil'
make[2]: *** [IStage1] Error 2
make[2]: Leaving directory `/home/troy/Software/quicknet/ATLAS/build/bin'
ERROR 437 DURING CACHESIZE SEARCH!!.  CHECK INSTALL_LOG/Stage1.log FOR DETAILS.
make[2]: Entering directory `/home/troy/Software/quicknet/ATLAS/build/bin'
cd /home/troy/Software/quicknet/ATLAS/build ; make error_report
make[3]: Entering directory `/home/troy/Software/quicknet/ATLAS/build'
make -f Make.top error_report
make[4]: Entering directory `/home/troy/Software/quicknet/ATLAS/build'
uname -a 2>&1 >> bin/INSTALL_LOG/ERROR.LOG
gcc -v 2>&1  >> bin/INSTALL_LOG/ERROR.LOG
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
gcc -V 2>&1  >> bin/INSTALL_LOG/ERROR.LOG
gcc.real: '-V' option must have argument
make[4]: [error_report] Error 1 (ignored)
gcc --version 2>&1  >> bin/INSTALL_LOG/ERROR.LOG
tar cf error_Core264SSE3.tar Make.inc bin/INSTALL_LOG/*
gzip --best error_Core264SSE3.tar
mv error_Core264SSE3.tar.gz error_Core264SSE3.tgz
make[4]: Leaving directory `/home/troy/Software/quicknet/ATLAS/build'
make[3]: Leaving directory `/home/troy/Software/quicknet/ATLAS/build'
make[2]: Leaving directory `/home/troy/Software/quicknet/ATLAS/build/bin'
Error report error_.tgz has been created in your top-level ATLAS
directory.  Be sure to include this file in any help request.
cat: ../../CONFIG/error.txt: No such file or directory
cat: ../../CONFIG/error.txt: No such file or directory
make[1]: *** [build] Error 255
make[1]: Leaving directory `/home/troy/Software/quicknet/ATLAS/build'
make: *** [build] Error 2

Having no idea to go on...
At last I found that somebody install the static library of ATLAS.
Using Synaptic Package Manager to search atlas, and select "libatlas-sse2-dev" to install. At the same time two dependencies "libatlas-headers" and "libatlas3gf-see2" are installed together.
Maybe in the command line, using sudo apt-get install libatlas-sse2-dev will also work.
From: http://seehuhn.de/pages/linear

However, after using that package, I could not find the include and lib file of ATLAS for QuickNet's installation. Thus I removed those package and retry the installation from the source.

Searching the web, I found that the error was caused by the settings of 32 bits or 64 bits. To have a try, I set the configuration to not use the default system archeticuture.
../configure -b 64 -D c -DPentiumCPS=2400 -v 2 -Si archdef 0
make build

Using these two commands, it works. What's more, after the make build command, it automatically make check, make tune and install. Even finally make clean.

In my opinion, maybe for the configuration, -b 64 is changed to be 32 will work either. Or only use the last parameter is enough "-Si archdef".

Finally, it was correctly installed after nearly 3 hours!

However, one thing must be noted is that when type the make install command, do be sure you have the root privillages. Or the operation will be denied. So for this command use "sudo make install".


6. Install QuickNet.
Extract QuickNet source files and the test data files.
"cd" to into the source folder.
mk build
cd build
../configure --with-blas=atlas --with-testdata=/home/troy/Software/quicknet/quicknet_testdata CPPFLAGS="-I/usr/local/atlas/include" LDFLAGS="-L/usr/local/atlas/lib"
make
sudo make install

In this step, errors occurs at the make step.
In file included from ../QN_utils.cc:53:
../QN_fir.h:116: error: extra qualification ‘QN_InFtrStream_FIR::’ on member ‘FillDeltaFilt’
../QN_fir.h:118: error: extra qualification ‘QN_InFtrStream_FIR::’ on member ‘FillDoubleDeltaFilt’
../QN_utils.cc: In function ‘void QN_output_sysinfo(const char*)’:
../QN_utils.cc:87: error: ‘ATL_CCVERS’ was not declared in this scope
../QN_utils.cc:88: error: ‘ATL_CCFLAGS’ was not declared in this scope

What I did is just open the "QN_fir.h" file, remove 'QN_InFtrStream_FIR::'. As in the declearation of the class member function, no need to add the class field.
For the second error, I just commented those two lines as they are just printing out some information.

Also if the option "--with-testdata" is specified, after the install, we can use the scritps built from the source with name "testdata_*.sh" to test the QuickNet.
For example, run command:
cd build
./testdata_qnstrn.sh


Finally, it is installed on my machine. Next thing is to understand how it works, so that I can use it for my experiments. Good luck to myself!

From a Queen Song to a Better Music Search Engine

From: http://ucsdnews.ucsd.edu/newsrel/students/05-09Barrington.asp

New song dissection technology from UC San Diego

May 15, 2009

By Daniel Kane

At a recent IEEE technology conference, UC San Diego electrical engineers presented a solution to their problem with the song “Bohemian Rhapsody,”—and it’s not that they don’t like this hit from the band Queen. The electrical engineers’ issue with “Bohemian Rhapsody” is that it is too heterogeneous. With its mellow piano, falsetto vocals, rock opera sections and crazy guitar solos, Bohemian Rhapsody is so internally varied that machine learning algorithms at the heart of their experimental music search engine have trouble labeling the song. The solution presented at the 2009 International Conference on Acoustics, Speech, and Signal Processing (ICASSP) in Taiwan could lead to improvements in the electrical engineers’ song labeling and search engine system.

Watch a video of the project.

The system “listens” to songs it has never heard before, labels them based on the actual sounds in the song, and then retrieves songs, as appropriate, when people type descriptive words—like “mellow jazz”—into the team’s experimental search engine.

At ICASSP, UC San Diego electrical engineering Ph.D. student Luke Barrington presented a new model for music segmentation that can capture both the sound of a song and how this sound changes over time. By modeling music in this way, Barrington showed how to automatically segment songs such as Bohemian Rhapsody into homogenous sections such as verses, choruses and bridges. This new approach to training computers to dissect songs into heterogeneous segments and then accurately label each chunk could improve the accuracy of the new music search engine built by engineers from the Jacobs School of Engineering at UC San Diego.

The team’s nickname for their experimental music search engine is “Google for music”. Users type descriptive words—rather than song titles, album names or artist names—and
the search engine returns specific song suggestions. The engine currently works for more than 100 words that cover music genres, emotions and instruments. The Jacobs School engineers are working to expand the search engine’s “vocabulary” before opening it up to the public later this year.

Teaching Computers to Label Songs

Luke Barrington, an electrical engineering graduate student, led the team that built Herd It the new Facebook games for music discovery.

In order to “teach” the search engine new words, the engineers need to show it many different examples of songs that fit that description. Initially, the engineers paid UC San Diego undergraduates to manually label songs that would serve as training materials for machine learning algorithms. But instead of continuing to rely on this expensive option, the engineers built online music games that encourage people connected via the Internet to do the song labeling while listening to music online.

In April, the electrical engineers launched their games on Facebook as an application called Herd It (http://apps.facebook.com/herd-it).

To play Herd It, log in to Facebook, open the Herd It app, select a genre of music, and start listening to song clips and playing the games. Some games ask users to identify instruments, while others focus on music genres, artist names, emotions triggered by the song, and activities you might do while listening to a song. The more your answers align with the rest of the online crowd playing the game at the same time, the more points you score.

“The Facebook games are a lot of fun and a great way to discover new music. At the same time, the games deliver the data we need to teach our computer audition system to listen to and describe music like humans do,” said Gert Lanckriet, the electrical engineering professor and machine learning expert from the Jacobs School of Engineering steering the project. Lanckriet also leads UC San Diego’s Computer Audition Laboratory, housed at the UC San Diego division of Calit2.

For the system to “listen and describe music like a human,” it must find patterns in the songs using the tools of machine learning. For example, for the system to learn to identify and label romantic songs, it must be exposed to many different romantic songs during the training period.

A screen shot from the new music discovery game on Facebook: Herd It. View more screen shots on the Jacobs School blog.

This exposure enables the machine learning algorithms find patterns in the wave forms of the songs that make the songs romantic. Once trained, the system can identify romantic songs that it has never before encountered, offering the tantalizing possibility of amassing a huge database of songs that can be tagged and retrieved based on text-based searches with no human intervention.

“The more examples of romantic songs our search engine is exposed to, the more accurately it will be able to identify romantic songs it has never heard before,” explained Barrington.

Part of Barrington’s Ph.D. dissertation will involve demonstrating that data collected from the Facebook games reliably improves the accuracy of the search engine.

“Once enough people play our new music discovery games on Facebook, I’ll have the data I need to both improve our search engine and finish my Ph.D.,” said Barrington.

The song-word combinations collected by the Facebook games will also enable the researchers to grow their music search engine’s vocabulary and increase its coverage in genres and classes of music.

###

2009 ICASSP (IEEE International Conference on Acoustics, Speech, and Signal Processing): “Dynamic Texture Models of Music,” by Luke Barrington, Antoni Chan and Gert Lanckriet from the Electrical and Computer Engineering Department at UC San Diego’s Jacobs School of Engineering. To appear inICASSP 2009.

Herd It game on Facebook:
http://apps.facebook.com/herd-it or http://herdit.org

Online Game Feeds Music Search Engine Project UC San Diego press release from 2007

A Search Engine with Ears Jacobs School of Engineering alumni magazine, Pulse

The National Science Foundation (NSF) funded some of the research leading to this publication, as well as some of the students who contributed.

UC San Diego’s von Liebig Center provided funding that enabled the researchers to create Herd It’s professional interfaces for the music games. The von Liebig Center also provided the engineers with entrepreneurship advisory services and “incubation space”.

Media Contact: Daniel Kane, 858-534-3262 or dbkane@ucsd.edu

Friday, May 22, 2009

MySQL Commands

This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. To use MySQL with Perl you will need to use the Perl modules DBI and DBD::mysql.

Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.

To login (from unix shell) use -h only if needed.

# [mysql dir]/bin/mysql -h hostname -u root -p

Create a database on the sql server.

mysql> create database [databasename];

List all databases on the sql server.

mysql> show databases;

Switch to a database.

mysql> use [db name];

To see all the tables in the db.

mysql> show tables;

To see database's field formats.

mysql> describe [table name];

To delete a db.

mysql> drop database [database name];

To delete a table.

mysql> drop table [table name];

Show all data in a table.

mysql> SELECT * FROM [table name];

Returns the columns and column information pertaining to the designated table.

mysql> show columns from [table name];

Show certain selected rows with the value "whatever".

mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";

Show all records containing the name "Bob" AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';

Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.

mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;

Show all records starting with the letters 'bob' AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';

Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.

mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;

Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.

mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";

Show unique records.

mysql> SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).

mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

Return number of rows.

mysql> SELECT COUNT(*) FROM [table name];

Sum column.

mysql> SELECT SUM(*) FROM [table name];

Join tables on common columns.

mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;

Change a users password from unix shell.

# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'

Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;

Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Set a root password if there is on root password.

# mysqladmin -u root password newpassword

Update a root password.

# mysqladmin -u root -p oldpassword newpassword

Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;

Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;
or
mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

To update info already in a table.

mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';

Delete a row(s) from a table.

mysql> DELETE from [table name] where [field name] = 'whatever';

Update database permissions/privilages.

mysql> flush privileges;

Delete a column.

mysql> alter table [table name] drop column [column name];

Add a new column to db.

mysql> alter table [table name] add column [new column name] varchar (20);

Change column name.

mysql> alter table [table name] change [old column name] [new column name] varchar (50);

Make a unique column so you get no dupes.

mysql> alter table [table name] add unique ([column name]);

Make a column bigger.

mysql> alter table [table name] modify [column name] VARCHAR(3);

Delete unique from table.

mysql> alter table [table name] drop index [colmn name];

Load a CSV file into a table.

mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);

Dump all databases for backup. Backup file is sql commands to recreate all db's.

# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql

Dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql

Dump a table from a database.

# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql

Restore database (or database table) from backup.

# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql

Create Table Example 1.

mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));

Create Table Example 2.

mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');

MYSQL Statements and clauses

ALTER DATABASE

ALTER TABLE

ALTER VIEW

ANALYZE TABLE

BACKUP TABLE

CACHE INDEX

CHANGE MASTER TO

CHECK TABLE

CHECKSUM TABLE

COMMIT

CREATE DATABASE

CREATE INDEX

CREATE TABLE

CREATE VIEW

DELETE

DESCRIBE

DO

DROP DATABASE

DROP INDEX

DROP TABLE

DROP USER

DROP VIEW

EXPLAIN

FLUSH

GRANT

HANDLER

INSERT

JOIN

KILL

LOAD DATA FROM MASTER

LOAD DATA INFILE

LOAD INDEX INTO CACHE

LOAD TABLE...FROM MASTER

LOCK TABLES

OPTIMIZE TABLE

PURGE MASTER LOGS

RENAME TABLE

REPAIR TABLE

REPLACE

RESET

RESET MASTER

RESET SLAVE

RESTORE TABLE

REVOKE

ROLLBACK

ROLLBACK TO SAVEPOINT

SAVEPOINT

SELECT

SET

SET PASSWORD

SET SQL_LOG_BIN

SET TRANSACTION

SHOW BINLOG EVENTS

SHOW CHARACTER SET

SHOW COLLATION

SHOW COLUMNS

SHOW CREATE DATABASE

SHOW CREATE TABLE

SHOW CREATE VIEW

SHOW DATABASES

SHOW ENGINES

SHOW ERRORS

SHOW GRANTS

SHOW INDEX

SHOW INNODB STATUS

SHOW LOGS

SHOW MASTER LOGS

SHOW MASTER STATUS

SHOW PRIVILEGES

SHOW PROCESSLIST

SHOW SLAVE HOSTS

SHOW SLAVE STATUS

SHOW STATUS

SHOW TABLE STATUS

SHOW TABLES

SHOW VARIABLES

SHOW WARNINGS

START SLAVE

START TRANSACTION

STOP SLAVE

TRUNCATE TABLE

UNION

UNLOCK TABLES

USE


String Functions



AES_DECRYPT

AES_ENCRYPT

ASCII

BIN

BINARY

BIT_LENGTH

CHAR

CHAR_LENGTH

CHARACTER_LENGTH

COMPRESS

CONCAT

CONCAT_WS

CONV

DECODE

DES_DECRYPT

DES_ENCRYPT

ELT

ENCODE

ENCRYPT

EXPORT_SET

FIELD

FIND_IN_SET

HEX

INET_ATON

INET_NTOA

INSERT

INSTR

LCASE

LEFT

LENGTH

LOAD_FILE

LOCATE

LOWER

LPAD

LTRIM

MAKE_SET

MATCH AGAINST

MD5

MID

OCT

OCTET_LENGTH

OLD_PASSWORD

ORD

PASSWORD

POSITION

QUOTE

REPEAT

REPLACE

REVERSE

RIGHT

RPAD

RTRIM

SHA

SHA1

SOUNDEX

SPACE

STRCMP

SUBSTRING

SUBSTRING_INDEX

TRIM

UCASE

UNCOMPRESS

UNCOMPRESSED_LENGTH

UNHEX

UPPER


Date and Time Functions



ADDDATE

ADDTIME

CONVERT_TZ

CURDATE

CURRENT_DATE

CURRENT_TIME

CURRENT_TIMESTAMP

CURTIME

DATE

DATE_ADD

DATE_FORMAT

DATE_SUB

DATEDIFF

DAY

DAYNAME

DAYOFMONTH

DAYOFWEEK

DAYOFYEAR

EXTRACT

FROM_DAYS

FROM_UNIXTIME

GET_FORMAT

HOUR

LAST_DAY

LOCALTIME

LOCALTIMESTAMP

MAKEDATE

MAKETIME

MICROSECOND

MINUTE

MONTH

MONTHNAME

NOW

PERIOD_ADD

PERIOD_DIFF

QUARTER

SEC_TO_TIME

SECOND

STR_TO_DATE

SUBDATE

SUBTIME

SYSDATE

TIME

TIMEDIFF

TIMESTAMP

TIMESTAMPDIFF

TIMESTAMPADD

TIME_FORMAT

TIME_TO_SEC

TO_DAYS

UNIX_TIMESTAMP

UTC_DATE

UTC_TIME

UTC_TIMESTAMP

WEEK

WEEKDAY

WEEKOFYEAR

YEAR

YEARWEEK


Mathematical and Aggregate Functions



ABS

ACOS

ASIN

ATAN

ATAN2

AVG

BIT_AND

BIT_OR

BIT_XOR

CEIL

CEILING

COS

COT

COUNT

CRC32

DEGREES

EXP

FLOOR

FORMAT

GREATEST

GROUP_CONCAT

LEAST

LN

LOG

LOG2

LOG10

MAX

MIN

MOD

PI

POW

POWER

RADIANS

RAND

ROUND

SIGN

SIN

SQRT

STD

STDDEV

SUM

TAN

TRUNCATE

VARIANCE


Flow Control Functions



CASE

IF

IFNULL

NULLIF


Command-Line Utilities



comp_err

isamchk

make_binary_distribution

msql2mysql

my_print_defaults

myisamchk

myisamlog

myisampack

mysqlaccess

mysqladmin

mysqlbinlog

mysqlbug

mysqlcheck

mysqldump

mysqldumpslow

mysqlhotcopy

mysqlimport

mysqlshow

perror


Perl API - using functions and methods built into the Perl DBI with MySQL



available_drivers

begin_work

bind_col

bind_columns

bind_param

bind_param_array

bind_param_inout

can

clone

column_info

commit

connect

connect_cached

data_sources

disconnect

do

dump_results

err

errstr

execute

execute_array

execute_for_fetch

fetch

fetchall_arrayref

fetchall_hashref

fetchrow_array

fetchrow_arrayref

fetchrow_hashref

finish

foreign_key_info

func

get_info

installed_versions


last_insert_id

looks_like_number

neat

neat_list

parse_dsn

parse_trace_flag

parse_trace_flags

ping

prepare

prepare_cached

primary_key

primary_key_info

quote

quote_identifier

rollback

rows

selectall_arrayref

selectall_hashref

selectcol_arrayref

selectrow_array

selectrow_arrayref

selectrow_hashref

set_err

state

table_info

table_info_all

tables

trace

trace_msg

type_info

type_info_all

Attributes for Handles


PHP API - using functions built into PHP with MySQL



mysql_affected_rows

mysql_change_user

mysql_client_encoding

mysql_close

mysql_connect

mysql_create_db

mysql_data_seek

mysql_db_name

mysql_db_query

mysql_drop_db

mysql_errno

mysql_error

mysql_escape_string

mysql_fetch_array

mysql_fetch_assoc

mysql_fetch_field

mysql_fetch_lengths

mysql_fetch_object

mysql_fetch_row

mysql_field_flags

mysql_field_len

mysql_field_name

mysql_field_seek

mysql_field_table

mysql_field_type

mysql_free_result

mysql_get_client_info

mysql_get_host_info

mysql_get_proto_info

mysql_get_server_info

mysql_info

mysql_insert_id

mysql_list_dbs

mysql_list_fields

mysql_list_processes

mysql_list_tables

mysql_num_fields

mysql_num_rows

mysql_pconnect

mysql_ping

mysql_query

mysql_real_escape_string

mysql_result

mysql_select_db

mysql_stat

mysql_tablename

mysql_thread_id

mysql_unbuffered_query

How to automatically redirect a browser to another web page from one of your own

This is the preferred method of redirecting to other web pages, and additional information can be found at http://www.w3.org/QA/Tips/reback.

As the P-A Department's main web server uses the Apache HTTP server program, here is how to do it on that system (for other systems' servers, see the references in the www.w3.org web page noted above).

Create a file in the directory in question called ".htaccess" and put into it the line

Redirect /path-of-file-to-be-redirected URL-of-page-to-go-to

For example, if you are a professor teaching the (fictitious - for the sake of the example only)PHY386 course during Spring Semester 2007, but you want to keep your web pages in a subdirectory of your own user area instead of in the courses area provided, you can go to the appropriate courses area on the server, /web/documents/courses/2007spring/PHY386 and put

Redirect /courses/2007spring/PHY386/index.html http://www.pa.msu.edu/people/username/subdir/index.htm

(all on one line, in case the above example is wrapped by your browser) into a file called .htaccesswhich has world-read permissions (that's the default).

The "path" argument is relative to the "web root", so in the above example, "/web/documents" is left off. The "page to go to" URL is a full URL, even if the web page is on the same server. More than oneRedirect command can be put into the .htaccess file, and you can redirect all files in a directory to their equivalents in a "to go to" directory by leaving the filenames off.

A case where more than one Redirect command may be necessary is when a web page may be accessed via more than one URL. In the above "PHY 386" example, in fact, the instructor will have to add a second line, the same as the first, except for lower-case "phy386" instead of "PHY386" in the "path" argument, because the web page may be accessed with the "phy386" URL, too. During Spring Semester 2007, the page could also be accessed with URLs with "current" in place of "2007spring" and with "2007spring" left out entirely, bringing the number of Redirect commands up to six for that one page. Fortunately, a URL which leaves off the "index.html" filename defaults to assuming it, or else three more Redirect commands would be needed to handle those cases. (The folks at w3.org still consider this as preferable to a single "refresh" meta command in the file itself, which would be read and acted upon regardless of how the file was accessed, as described below.)

If there is already a .htaccess file in the subdirectory in question, see the Apache HTTP server documentation to see where in it the Redirect command should be placed. If you are the person running the Apache web server program on a system, you can also put instances of the Redirectcommand into the server configuration file instead of, or in addition to, .htaccess files in specific subdirectories (again, see the Apache HTTP server documentation for the details).


"refresh" meta command

Note that this method is deprecated by the official HTML standards organization in favor of the server-based redirect method described above.

You can set up a web page to inform any browser which happens to load it that there is another web page it should go to instead, after an optional delay.

This is accomplished using a "refresh" meta command in the header section

     <head>
.
.
</head>


of your HTML file, along with the title and any "keywords" or other meta commands.

Syntax

The syntax for the "refresh" meta command is

<meta http-equiv="refresh" content="N; URL=other-web-address">



where N is the approximate number of seconds that you want the current web page to be displayed before the browser automatically goes to the other web address. If N = 0, then the browser should go immediately to the other web address.



Netiquette tip

In case someone's browser doesn't handle these automatic redirects (most browsers do handle them, but some allow them to be turned off, as a way of discouraging "web spam", which often uses this type of "refresh" redirect), you may want to provide a second route to the intended destination by way of a standard link (see the example, below).

Example


<html>
<head>
<title>A web page that points a browser to a different page after 2 seconds</title>
<meta http-equiv="refresh" content="2; URL=http://www.pa.msu.edu/services/computing/">
<meta name="keywords" content="automatic redirection">
</head>
<body>
If your browser doesn't automatically go there within a few seconds,
you may want to go to
<a href="http://www.pa.msu.edu/services/computing/">the destination</a>
manually.
</body>
</html>


Select Example above or here to see how the example works in practice.






Notes on scripting languages

There are also ways of doing this with JavaScript, VBscript, and other internal web page scripting languages, but explaining them in detail is beyond the scope of this web page. A few examples may illustrate the method, however, and encourage users to obtain actual JavaScript documentation (a book, or online) to guide them in developing their own variants suited to their own needs.

The following JavaScript example, which would go ahead of the first <html> flag on the web page, orbetween the <HEAD> and </HEAD> tags, opens the new site in the same browser window (effectivelyinstead of the rest of the contents of the page that the script is in):



 <script language="javascript" type="text/javascript">
<!--
window.location="http://www.pa.msu.edu/services/";
// -->
</script>


This JavaScript example opens the new site in the same browser window after displaying the current page in the window for 2 seconds (2000 ms):



 <script language="javascript" type="text/javascript">
<!--
window.setTimeout('window.location="http://www.pa.msu.edu/services/"; ',2000);
// -->
</script>

(Note that this does exactly what the HTML META tag above does, but as the META tag method does not depend on the browser's having JavaScript available and active, in most cases the META tag method would be preferable).

The next JavaScript example opens the new site in a new* browser window:



 <script language="javascript" type="text/javascript">
<!--
Newsite= window.open("http://www.pa.msu.edu/services/","newsite");
// -->
</script>

* sometimes, the "new" window is one of those already opened in the session; this seems to be somewhat random, and I don't know if it's a browser bug or a "JavaScript thing" with the window.open command. Just note that browser behavior may not always be consistent if you use this script (or the next one, which also useswindow.open). -- GJP.

This JavaScript example opens the new site in a new browser window after a 4.5 second (4500 ms) delay:



 <script language="javascript" type="text/javascript">
<!--
window.setTimeout('window.open("http://www.pa.msu.edu/services/","newsite")',4500);
// -->
</script>



WARNING: With these capabilities for automatic redirection to other web pages, it is possible to set up a redirection loop -- try to avoid making it a no-wait-time infinite loop! (An infinite loop with a reasonable delay, on the other hand, might have its uses as a sort of slide show, among other possibilities).

Thursday, May 21, 2009

Wu Jun's Beauty of Mathematics

Beauty of Mathematics

http://jun.wu.googlepages.com/beautyofmathematics

数学之美

(Written in Chinese)

I am writing a serial of essays introducing the applications of math in natural language processing, speech recognition and web search etc for non-technical readers . Here are the links

0. Page Rank ( 网页排名算法 )

1. Language Models (统计语言模型)

2. Chinese word segmentation  (谈谈中文分词)

3. Hidden Markov Model and its application in natural language processing (隐含马尔可夫模型)

4. Entropy - the measurement of information (怎样度量信息?)

5. Boolean algebra and search engine index (简单之美:布尔代数和搜索引擎的索引)

6. Graph theory and web crawler (图论和网络爬虫 Web Crawlers)

7. Information theory and its applications in NLP  (信息论在信息处理中的应用)

8. Fred Jelinek and modern speech and language processing (贾里尼克的故事和现代语言处理)

9. how to measure the similarity between queries and web pages.  (如何确定网页和查询的相关性)

10. Finite state machine and local search (有限状态机和地址识别)

11. Amit Singhal: AK-47 Maker in Google (Google 阿卡 47 的制造者阿米特.辛格博士)

12. The Law of Cosines and news classification (余弦定理和新闻的分类)

13.  Fingerprint of information and its applications (信息指纹及其应用)

14. The importance of precise mathematical modeling (谈谈数学模型的重要性)

15. The perfectionism and simplism 繁与简 自然语言处理的几位精英

16. Don't put all of your eggs in one basket - Maximum Entropy Principles 不要把所有的鸡蛋放在一个篮子里 -- 谈谈最大熵模型(A)

17. Don't put all of your eggs in one basket - Maximum Entropy Principles不要把所有的鸡蛋放在一个篮子里 -- 谈谈最大熵模型(B)

18.  闪光的不一定是金子 谈谈搜索引擎作弊问题(Search Engine Anti-SPAM)

19.  Matrix operation and Text classification 矩阵运算和文本处理中的分类问题

20. The Godfather of NLP - MItch Marcus 自然语言处理的教父 马库斯

21. The extension of HMM, Bayesian Networks 马尔可夫链的扩展 贝叶斯网络

22. The principle of cryptography 由电视剧《暗算》所想到的 — 谈谈密码学的数学原理

23. How many keys need we type to input a Chinese character 输入一个汉字需要敲多少个键 — 谈谈香农第一定律

吴军主页的中文首页

吴军 (Jun Wu) 的英文首页

Labs

Electronic Visualization Laboratory (EVL) at the University of Illinois at Chicago http://www.evl.uic.edu/index2.php

Wednesday, May 20, 2009

Install KDE Desktop in Ubuntu

From: http://www.debianadmin.com/install-kde-desktop-in-ubuntu.html

KDE
is a powerful graphical desktop environment for
Unix workstations. It combines ease of use, contemporary functionality
and outstanding graphical design with the technological superiority of
the Unix operating system. KDE is a completely new desktop,
incorporating a large suite of applications for Unix workstations.
While KDE includes a window manager, file manager, panel, control
center and many other components that one would expect to be part of a
contemporary desktop environment, the true strength of this exceptional
environment lies in the interoperability of its components.


By default Ubuntu desktop installation will install gnome desktop
enviroment and if you want to install KDE desktop enviroment you have
three options.Those options are


kubuntu-desktop -This is the recommended metapackage to install; the
full Kubuntu installation, with all the Kubuntu recommended packages.
This includes OpenOffice, Kontact, Konversation, amaroK, K3B, and
others.


kde -This will install the following KDE packages: kde-amusements,
kdeaccessibility, kdeaddons, kdeadmin, kdeartwork, kdegraphics,
kdemultimedia, kdenetwork, kdepim, kdesdk, kdeutils, kdewebdev,
kdevelop3 and the kde-core metapackage


kde-core -This will install the core — the bare-minimum required– of KDE. That is, kdebase, kdelibs, arts and fontconfig.


If you choose to not install kubuntu-desktop, then you can still get
all the Kubuntu-specific tweaks by installing the
kubuntu-default-settings package.


First thing you need to make sure you have universe source list under /etc/apt/sources.list file


If you want to install kubuntu-desktop use the following command


sudo apt-get install kubuntu-desktop


This will starts installing all the required packages you can see in the following screen






During this installation process, you will be asked whether you want
to use KDM or GDM as your default display manager. If you think you’ll
use KDE , make KDM your default. If you think you’ll use Gnome , keep
GDM as your default.Select which one is best for you.






This will complete the installation now you need to logout from
ubuntu gnome session and now you are on ubuntu login screen in this you
need to select options—> selectsession






You should see the following screen with gnome and kde options you have select kde and click on change session






Now it will disply the following screen in this you want to change
to KDE just for this session or if you want to make KDE your default
desktop environment.







Once you select the above option it will start loading KDE session you can see this in the following screen





Once it loads complete KDE session here is the KDE desktop for your ubuntu.






Nice KDE Desktop






If you want to switch back to Gnome, just log out and select Gnome from the session menu.


If you want to install only KDE use the following command


sudo apt-get install kde


If you want to install only kde-core use the following command


sudo apt-get install kde-core


Uninstall KDE in ubuntu


If you want to uninstall KDE session use the following command


sudo apt-get remove kubuntu-desktop

[Book] Templates for the Solution of Algebraic Eigenvalue Problems: a Practical Guide

Templates for the Solution of
Algebraic Eigenvalue Problems:

 

a Practical Guide

Online Book:
http://www.cs.utk.edu/~dongarra/etemplates/

Using Linux

1. sun-java
2. qt designer
3. kDevelop
4. matlab
5. irb
6. Bless Hex Editor
7. eclipse
8. weka
9. flikr organizer



Ruby books

http://rs253.rapidshare.com/files/66530970/Regular.Expression.Pocket.Reference.2nd.Edition.Jul.2007.pdf

http://rs216.rapidshare.com/files/61472111/Apress.Practical.Ruby.for.System.Administration.Jun.2007.rar

http://rapidshare.com/files/48876219/Oreilly.Learning.Ruby.0596529864.rar

http://rapidshare.com/files/52119798/No.Starch.Press.Ruby.by.Example.Concepts.and.Code.Jun.2007.eBook-BBL.rar.html

Ruby Cookbook


Everyday Scripting with Ruby - Pragmatic Bookshelf


http://rapidshare.com/files/22953979/BeginningRuby.rar

Practical Ruby Gems


http://rapidshare.com/files/80551269/Course.Technology.PTR.Thinking.Animation.Bridging.the.Gap.Between.2D.and.CG.rar

Thinking Animation: Bridging the Gap Between 2D and CG

http://rapidshare.com/files/83945930/3D.Videocommunication.Algorithms.concepts.and.real.time.systems.rar

3D Videocommunication: Algorithms, concepts and real-time systems in human centred communication


http://rapidshare.com/files/98121523/The.Ruby.Programming.Language.Jan.2008.chm

The Ruby Programming Language



Tuesday, May 19, 2009

Write floats to binary file

1. Randomly create a series of float numbers, then write it in a binary file:

#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>
using namespace std;

int main()
{
    srand(time(NULL));
    ofstream fout("test",ios::binary);
    ofstream fres("res.txt");
    float data;
   
    cout<<sizeof(data)<<endl;
    for(int i=0;i<100;++i)
    {
        for(int j=0;j<21;++j)
        {
            data=rand()*10.0/(RAND_MAX+1.0);
            fres<<data<<endl;
            fout.write((char*)(&data),sizeof(data));
        }
    }
   
    fout.close();
    return 0;
}

2. Decode the binary file:

#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
    ifstream fin("test",ios::binary);
    ofstream fout("de.txt");
    char buffer[5];
    float *data;
   
    cout<<sizeof(data)<<endl;
   
    while(!fin.eof())
    {
        fin.read(buffer,4);
        buffer[4]='\0';
        data=(float*)buffer;
        fout<<*data<<endl;
    }
   
    return 0;
   
}

Qt Development VI: TCP Communication

From: http://xizhizhu.blogspot.com/2009/01/qt-development-vi-tcp-communication.html

1.QTcpSocket


QTcpSocket is used as the TCP socket in Qt. It's used both in client and server side.

To perform as a client, following steps are used:
a) call QTcpSocket.connectToHost() to connect to a server;
b) when connected, QTcpSocket.connected() will be emitted;
c) communicate with the server.

The following code shows a simple client sending "Hello, world" to the server.

// client.h
#include <QtNetwork>
#include <QObject>
#include <QString>
#include <QTcpSocket>

class Client: public QObject
{
Q_OBJECT
public:
 
Client(QObject* parent = 0);
 
~Client();
 
void start(QString address, quint16 port);
public slots:
 
void startTransfer();
private:
 
QTcpSocket client;
};

// client.cc
#include "client.h"
#include <QHostAddress>

Client::Client(QObject* parent): QObject(parent)
{
  connect
(&client, SIGNAL(connected()),
   
this, SLOT(startTransfer()));
}

Client::~Client()
{
  client
.close();
}

void Client::start(QString address, quint16 port)
{
 
QHostAddress addr(address);
  client
.connectToHost(addr, port);
}

void Client::startTransfer()
{
  client
.write("Hello, world", 13);
}

// main.cc
#include "client.h"
#include <QApplication>

int main(int argc, char** argv)
{
 
QApplication app(argc, argv);

 
Client client;
  client
.start("127.0.0.1", 8888);

 
return app.exec();
}

2.QTcpServer

In Qt, the class QTcpServer is used as a TCP server. Generally, the following steps are used:
a) call QTcpServer.listen() to start listening;
b) QTcpServer.newConnection() signal will be emitted when a new connection comes;
c) call QTcpServer.nextPendingConnection() to get the socket object (QTcpSocket) connecting to the client.

The following code shows a simple server receiving and printing a string from its client.

#include <QtNetwork>
#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>

class Server: public QObject
{
Q_OBJECT
public:
 
Server(QObject * parent = 0);
 
~Server();
public slots:
 
void acceptConnection();
 
void startRead();
private:
 
QTcpServer server;
 
QTcpSocket* client;
};

// server.cc
#include "server.h"
#include <iostream>
using namespace std;

Server::Server(QObject* parent): QObject(parent)
{
  connect
(&server, SIGNAL(newConnection()),
   
this, SLOT(acceptConnection()));

  server
.listen(QHostAddress::Any, 8888);
}

Server::~Server()
{
  server
.close();
}

void Server::acceptConnection()
{
  client
= server.nextPendingConnection();

  connect
(client, SIGNAL(readyRead()),
   
this, SLOT(startRead()));
}

void Server::startRead()
{
 
char buffer[1024] = {0};
  client
->read(buffer, client->bytesAvailable());
  cout
>> buffer >> endl;
  client
->close();
}

// main.cc
#include "server.h"
#include <QApplication>

int main(int argc, char** argv)
{
 
QApplication app(argc, argv);
 
Server server;
 
return app.exec();
}

P.S.You should add QT += network in the project file created by qmake -project.
Google+