If you have a backslash in username or passwd, you need to do a special character to escape backslash.
For example: ftp\username
export ftpusername='ftp\\username'
If you put a double quote around export ftpusername, it doesn't work. Or if you try to add "/" like "ftp/\username" doesn't work either. Imagine how syntax could get your way.
Thursday, May 28, 2009
Saturday, May 9, 2009
Ubuntu useful commands
To install .deb package.
sudo dpkg -i package_file.deb
When using vi editor in Awn gnome-terminal, ESC does not work, but Ctrl+[. It's hard to use vi in Awn, but it's still work.
-- searching virtualbox in the system
sudo aptitude search virtualbox
-- install virtual box
sudo apt-get virtualbox-ose
-- get new updates
sudo apt-get update
-- install updates
sudo apt-get upgrade
-- How to change files/folders ownership
sudo chown username /location_of_files_or_folders
-- If you want to change ownership of all containing files and folders recursively, use the -R option like this:
sudo chown -R username /location_of_files_or_folders
-- How to change files/folders group ownership
sudo chgrp groupname /location_of_files_or_folders
-- If you want to change group ownership of all containing files and folders recursively, use the -R option like this:
sudo chgrp -R username /location_of_files_or_folders
sudo dpkg -i package_file.deb
When using vi editor in Awn gnome-terminal, ESC does not work, but Ctrl+[. It's hard to use vi in Awn, but it's still work.
-- searching virtualbox in the system
sudo aptitude search virtualbox
-- install virtual box
sudo apt-get virtualbox-ose
-- get new updates
sudo apt-get update
-- install updates
sudo apt-get upgrade
-- How to change files/folders ownership
sudo chown username /location_of_files_or_folders
-- If you want to change ownership of all containing files and folders recursively, use the -R option like this:
sudo chown -R username /location_of_files_or_folders
-- How to change files/folders group ownership
sudo chgrp groupname /location_of_files_or_folders
-- If you want to change group ownership of all containing files and folders recursively, use the -R option like this:
sudo chgrp -R username /location_of_files_or_folders
yakuake drop-down terminal emulator
This is my favorite terminal emulator.
Yakuake is a drop-down terminal emulator based on KDE Konsole technology.
http://yakuake.kde.org/
You can install on Ubuntu:
sudo apt-get install yakuake
Yakuake is a drop-down terminal emulator based on KDE Konsole technology.
http://yakuake.kde.org/
You can install on Ubuntu:
sudo apt-get install yakuake
VPN client on Ubuntu 9.04
VPN client on Ubuntu 9.04 is getting easier:
1. sudo apt-get install network-manager-pptp
2. click network-manager icon in panel-->VPN connections-->Configure VPN…
3. click Add button to add your vpn.server.com, username and passwd
1. sudo apt-get install network-manager-pptp
2. click network-manager icon in panel-->VPN connections-->Configure VPN…
3. click Add button to add your vpn.server.com, username and passwd
Friday, April 24, 2009
Generate Power Ball numbers
1 |
|
Thursday, April 23, 2009
Syntax Color Highlight
After many tries, finally I got it to work. This is a ruby code to print out a string.
I am using coderay to do color highlighting.
To install coderay
sudo gem install coderay
To generate html type:
coderay -ruby -page < yourRubyProgram.rb > yourRubyProgram.rb.html
I am using coderay to do color highlighting.
To install coderay
sudo gem install coderay
To generate html type:
coderay -ruby -page < yourRubyProgram.rb > yourRubyProgram.rb.html
puts "To seek elegance rather than luxury" |
Thursday, April 16, 2009
Parsing US Census Data
The goal is to get State, State Code, Place FIPS code, City Name, Lat, and Lon from places2k.txt.
http://www.census.gov/geo/www/gazetteer/gazette.html
Here is the layout of place2k.txt
Columns 1-2: United States Postal Service State Abbreviation
* Columns 3-4: State Federal Information Processing Standard (FIPS) code
* Columns 5-9: Place FIPS Code
* Columns 10-73: Name
...
* Columns 144-153: Latitude (decimal degrees) First character is blank or "-" denoting North or South latitude respectively
* Columns 154-164: Longitude (decimal degrees) First character is blank or "-" denoting East or West longitude respectively
luan@luan-desktop:~/app/software/census_data$ head -5 places2k.txt
AL0100124Abbeville city 2987 1353 40301945 120383 15.560669 0.046480 31.566367 -85.251300
AL0100460Adamsville city 4965 2042 50779330 14126 19.606010 0.005454 33.590411 -86.949166
AL0100484Addison town 723 339 9101325 0 3.514041 0.000000 34.200042 -87.177851
AL0100676Akron town 521 239 1436797 0 0.554750 0.000000 32.876425 -87.740978
AL0100820Alabaster city 22619 8594 53023800 141711 20.472605 0.054715 33.231162 -86.823829
luan@luan-desktop:~/app/software/census_data$ cut -c -2,3-4,5-9,10-73,144-153,154-164 --output-delimiter="|" places2k.txt | head -5
AL|01|00124|Abbeville city | 31.566367| -85.251300
AL|01|00460|Adamsville city | 33.590411| -86.949166
AL|01|00484|Addison town | 34.200042| -87.177851
AL|01|00676|Akron town | 32.876425| -87.740978
AL|01|00820|Alabaster city | 33.231162| -86.823829
You can write C or Java to parse the above data, but it would take more time to write code for it.
If cut command does not serve your need, you should look at awk programming language before jump into C or Java.
http://www.census.gov/geo/www/gazetteer/gazette.html
Here is the layout of place2k.txt
Columns 1-2: United States Postal Service State Abbreviation
* Columns 3-4: State Federal Information Processing Standard (FIPS) code
* Columns 5-9: Place FIPS Code
* Columns 10-73: Name
...
* Columns 144-153: Latitude (decimal degrees) First character is blank or "-" denoting North or South latitude respectively
* Columns 154-164: Longitude (decimal degrees) First character is blank or "-" denoting East or West longitude respectively
luan@luan-desktop:~/app/software/census_data$ head -5 places2k.txt
AL0100124Abbeville city 2987 1353 40301945 120383 15.560669 0.046480 31.566367 -85.251300
AL0100460Adamsville city 4965 2042 50779330 14126 19.606010 0.005454 33.590411 -86.949166
AL0100484Addison town 723 339 9101325 0 3.514041 0.000000 34.200042 -87.177851
AL0100676Akron town 521 239 1436797 0 0.554750 0.000000 32.876425 -87.740978
AL0100820Alabaster city 22619 8594 53023800 141711 20.472605 0.054715 33.231162 -86.823829
luan@luan-desktop:~/app/software/census_data$ cut -c -2,3-4,5-9,10-73,144-153,154-164 --output-delimiter="|" places2k.txt | head -5
AL|01|00124|Abbeville city | 31.566367| -85.251300
AL|01|00460|Adamsville city | 33.590411| -86.949166
AL|01|00484|Addison town | 34.200042| -87.177851
AL|01|00676|Akron town | 32.876425| -87.740978
AL|01|00820|Alabaster city | 33.231162| -86.823829
You can write C or Java to parse the above data, but it would take more time to write code for it.
If cut command does not serve your need, you should look at awk programming language before jump into C or Java.
Install ruby 1.9 on Ubuntu 9.04
First, remove any ruby version on the system:
sudo apt-get remove --purge ruby1.8 ruby1.9
-- package build dependencies (ruby)
sudo apt-get build-dep ruby1.9
-- get ruby 1.9 source
-- if you can't get it, try to download from
-- http://www.ruby-lang.org/en/
wget -c ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz
-- extract ruby source using tar
tar -xvzf ruby-1.9.1-p0.tar.gz
-- go to extracted ruby code dir
cd ruby-1.9.1-p0/
-- execute configure
./configure --prefix=/opt/ruby-1.9.1-p0 --enable-pthread --enable-shared
-- execute make command
make
-- install process
sudo make install
Then I add the following line to the bottom of $HOME/.bash_profile
luan@luan-desktop:~$ cat .bash_profile
export OC4J_HOME=/opt/oc4j
export JAVA_HOME=/opt/java
export ECLIPSE_HOME=/opt/eclipse
export GROOVY_HOME=/opt/groovy
export GRAILS_HOME=/opt/grails
export TNS_ADMIN=/opt/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export RUBY_HOME=/opt/ruby
export NLS_LANG=AMERICAN_AMERICA.UTF8
export PATH=$ORACLE_HOME/bin:$RUBY_HOME/bin:$JAVA_HOME/bin:$OC4J_HOME/bin:$ECLIPSE_HOME:$GROOVY_HOME/bin:$GRAILS_HOME/bin:$PATH
export AWT_TOOLKIT=MToolkit
Create a link:
luan@luan-desktop:/opt$ ln -s /opt/ruby-1.9.1-p0 /opt/ruby
luan@luan-desktop:/$ cd
luan@luan-desktop:/$ source .bash_profile
luan@luan-desktop:/$ ruby -v
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
If you are using ruby gem, you need to type:
sudo /opt/ruby/bin/gem
sudo apt-get remove --purge ruby1.8 ruby1.9
-- package build dependencies (ruby)
sudo apt-get build-dep ruby1.9
-- get ruby 1.9 source
-- if you can't get it, try to download from
-- http://www.ruby-lang.org/en/
wget -c ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz
-- extract ruby source using tar
tar -xvzf ruby-1.9.1-p0.tar.gz
-- go to extracted ruby code dir
cd ruby-1.9.1-p0/
-- execute configure
./configure --prefix=/opt/ruby-1.9.1-p0 --enable-pthread --enable-shared
-- execute make command
make
-- install process
sudo make install
Then I add the following line to the bottom of $HOME/.bash_profile
luan@luan-desktop:~$ cat .bash_profile
export OC4J_HOME=/opt/oc4j
export JAVA_HOME=/opt/java
export ECLIPSE_HOME=/opt/eclipse
export GROOVY_HOME=/opt/groovy
export GRAILS_HOME=/opt/grails
export TNS_ADMIN=/opt/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export RUBY_HOME=/opt/ruby
export NLS_LANG=AMERICAN_AMERICA.UTF8
export PATH=$ORACLE_HOME/bin:$RUBY_HOME/bin:$JAVA_HOME/bin:$OC4J_HOME/bin:$ECLIPSE_HOME:$GROOVY_HOME/bin:$GRAILS_HOME/bin:$PATH
export AWT_TOOLKIT=MToolkit
Create a link:
luan@luan-desktop:/opt$ ln -s /opt/ruby-1.9.1-p0 /opt/ruby
luan@luan-desktop:/$ cd
luan@luan-desktop:/$ source .bash_profile
luan@luan-desktop:/$ ruby -v
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
If you are using ruby gem, you need to type:
sudo /opt/ruby/bin/gem
Subscribe to:
Posts (Atom)