Posts

Showing posts from August, 2010

[Level 2] Bash completion in Ubuntu

As we know, we can use "tab" for word completion. And now, you can also use "tab" for bash completion. That means when you finished typing your command, ex. # apt-get and you press "tab", then you will get the options for apt-get. # apt-get autoclean        clean            purge            upgrade autoremove       dist-upgrade     remove           build-dep        dselect-upgrade  source           check            install          update How could you enable this feature? add the following command in your ~/.bashrc, if not exists. if [ -f /etc/bas...

[Level 2] Math exam generator

This morning, my son ask me to give him a 50 question math exam. So I wrote a math exam generator to produce the exam. PS. You need OpenOffice to open result file. #!/bin/bash set -f declare -i nQ=${1:-50} declare    sF=$0.csv; [ -f $sF ] && rm $sF; declare -i i=0 declare    aOperator=(+ - * /); declare -i nOperator=4 declare    aOperator=(+ -); declare -i nOperator=2 getRandomNumber() {   declare -i n=$RANDOM*89/32767+10   echo $n } getRandomOperator() {   declare -i n=$RANDOM*$nOperator/32767   echo ${aOperator[$n]} } for i in `seq 1 $nQ` do   declare -i n1=`getRandomNumber`   declare -i n2=`getRandomNumber`   declare    sO=`getRandomOperator`   echo "$n1,$sO,$n2,=,,=if(isblank(e$i);0;if(e$i=(a$i${sO}c$i);1;0))" >> $sF done echo ",,,correct,=,=sum(f1:f$i),/$i" >> $sF echo ",,,score,=,=sum(f1:f$i)/$i*100" >> $sF soffice $sF Wish ...

[Level 1] Upgrade GNOME desktop from 2 to 3 in Ubuntu.

Upgrade your GNOME desktop from 2 to 3. sudo apt-get build-dep gnome-shell sudo apt-get install gnome-shell gnome-shell --replace Wish this helps. regards, Stanley Huang

[Level 1] OpenSolaris is died?!

In these days, friends of mine asked about "Is OpenSolaris is died?". My answer is, "OpenSolaris" is died, but the spirit of "Open" "Solaris" is never die. Because some boarders of OpenSolaris, host a new project call " IllumOS ". If you like OpenSolaris, IllumOS might be your best choice. Wish this helps. regards, Stanley Huang

[Level 3] Menu Bash Script

One day, one friend of mine ask me how to create a menu with timeout limitation in bash, then I wrote the sample code for him. I think this maybe a good idea if I can write a menu bash script with dynamic setting menu item and so on. Therefore I write the script below, any feedback will be appreciate. #!/bin/bash ############################################## ## ## for menu utility ## ## author: Stanley Huang ## licence: Creative Commons Attribution-Share Alike 3.0 Taiwan License ## last release reversion: 0.1 ## last modify date: 2010/08/04 15:30 ## change list: ##   01. 2010/08/04 15:30, Stanley Huang. Build. ## ############################################## showUsage() {   cat< <EOF Usage:   $0      [-e] (expert mode)      [-h] (help menu)      [-t] timeout_sec (default timeout = $nTimeout sec)      [-c] no. of columns to display (default no. of column =...