Pages

Wednesday, March 12, 2008

ntp time server correction

ntp time server

sudo /etc/init.d/ntp stop
sudo ntpdate time.nist.gov
sudo /etc/init.d/hwclock.sh restart
sudo /etc/init.d/ntp start

Sunday, March 2, 2008

Mac OSX Key Bindings

~/Library/KeyBindings/DefaultKeyBinding.dict
{
/* Remap Home / End to be correct :-) */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
}

/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
{
"^f" = "moveWordForward:"; /* Ctrl-f = next word */
"^b" = "moveWordBackward:"; /* Ctrl-b = previous word */
"^v" = "pageUp:"; /* Ctrl-v = page up */
"\UF729" = "moveToBeginningOfLine:"; /* Home = start of line */
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl-Home = start of doc */
}

Key Modifiers

^ : Ctrl
$ : Shift
~ : Option (Alt)
@ : Command (Apple)
# : Numeric Keypad

Non-Printable Key Codes

Up Arrow: \UF700 Backspace: \U0008 F1: \UF704
Down Arrow: \UF701 Tab: \U0009 F2: \UF705
Left Arrow: \UF702 Escape: \U001B F3: \UF706
Right Arrow: \UF703 Enter: \U000A ...
Insert: \UF727 Page Up: \UF72C
Delete: \UF728 Page Down: \UF72D
Home: \UF729 Print Screen: \UF72E
End: \UF72B Scroll Lock: \UF72F
Break: \UF732 Pause: \UF730
SysReq: \UF731 Menu: \UF735
Help: \UF746


Supported Actions

alignCenter: newDocument:
alignJustified: openDocument:
alignLeft: orderBack:
alignRight: orderFront:
breakUndoCoalescing orderFrontLinkPanel:
cancelOperation: orderFrontListPanel:
capitalizeWord: orderFrontSpacingPanel:
center orderFrontTablePanel:
centerSelectionInVisibleArea: outline:
changeCaseOfLetter: pageDown:
checkSpelling: pageUp:
clearRecentDocuments: paste:
complete: pasteAsPlainText:
copy: pasteAsRichText:
copyFont: pasteFont:
copyRuler: pasteRuler:
cut: performClose:
delete: performMiniaturize:
deleteBackward: performZoom:
deleteBackwardByDecomposingPreviousCharacter: printDocument:
deleteForward: raiseBaseline:
deleteToBeginningOfLine: revertDocumentToSaved:
deleteToBeginningOfParagraph: runPageLayout:
deleteToEndOfLine: saveAllDocuments:
deleteToEndOfParagraph: saveDocument:
deleteToMark: saveDocumentAs:
deleteWordBackward: saveDocumentTo:
deleteWordForward: scrollLineDown:
hide: scrollLineUp:
ignoreSpelling: scrollPageDown:
indent: scrollPageUp:
insertBacktab: selectAll:
insertContainerBreak: selectLine:
insertLineBreak: selectParagraph:
insertNewline: selectToMark:
insertNewlineIgnoringFieldEditor: selectWord:
insertParagraphSeparator: setMark:
insertTab: showContextHelp:
insertTabIgnoringFieldEditor: showGuessPanel:
insertText: startSpeaking:
loosenKerning: stopSpeaking:
lowerBaseline: subscript:
lowercaseWord: superscript:
moveBackward: swapWithMark:
moveBackwardAndModifySelection: terminate:
moveDown: tightenKerning:
moveDownAndModifySelection: toggleBaseWritingDirection:
moveForward: toggleContinuousSpellChecking:
moveForwardAndModifySelection: toggleRuler:
moveLeft: transpose:
moveLeftAndModifySelection: transposeWords:
moveRight: turnOffKerning:
moveRightAndModifySelection: turnOffLigatures:
moveToBeginningOfDocument: underline:
moveToBeginningOfDocumentAndModifySelection: unscript:
moveToBeginningOfLine: uppercaseWord:
moveToBeginningOfLineAndModifySelection: useAllLigatures:
moveToBeginningOfParagraph: useStandardKerning:
moveToEndOfDocument: useStandardLigatures:
moveToEndOfDocumentAndModifySelection: yank:
moveToEndOfLineAndModifySelection:
moveToEndOfLine:
moveToEndOfParagraph:
moveUp:
moveUpAndModifySelection:
moveWordBackward:
moveWordBackwardAndModifySelection:
moveWordForward:
moveWordForwardAndModifySelection:
moveWordLeft:
moveWordLeftAndModifySelection:
moveWordRight:
moveWordRightAndModifySelection:

references:
http://evansweb.info/articles/2005/03/24/mac-os-x-and-home-end-keys
http://www.lsmason.com/articles/macosxkeybindings.html

Thursday, February 28, 2008

Audio file from video file

$ ffmpeg -vn -acodec copy -i infile.avi outfile.mp3

$ mplayer -vo null -dumpaudio video.avi -dumpfile audio.mp3

Thursday, February 21, 2008

setup clock in linux

$ sudo emacs /etc/ntp.conf

server time.nist.gov
fudge time.nist.gov stratum 10

$ sudo timeconfig
$ sudo dateconfig

Wednesday, February 20, 2008

Linux as the WebDAV Server

Linux as the WebDAV Server:

On Linux, use your favorite package manager to install Apache. Most distributions will use Apache httpd 2.0 which has mod_dav built-in, so the only editing of the httpd.conf file needed are the DAVLockDB and Directory definitions. Note that you can also authenticate against Active Directory or LDAP using the mod_auth_kerb or mod_auth_ldap Apache modules. For this example, we’ll stick with using htpasswd:

$ sudo vi /etc/httpd/conf/http.conf
..
DAVLockDB /var/lib/dav/DAVLockDB

DAV On
AuthName "WebDAV Login"
AuthType Basic
AuthUserFile /etc/httpd/.htpasswd

require valid-user

Order allow,deny
Allow from all


Now create the directories and set permissions:

$ sudo su
# mkdir /usr/local/apache/var
# chown apache:apache /usr/local/apache/var
# mkdir /var/www/html/webdav
# chown www:www /var/www/html/webdav

Finally, on Linux create the user and password file and restart the httpd daemon:

# htpasswd -m -c /etc/httpd/.htpasswd testuser
New password:
Re-type new password:
Adding password for user testuser
# /sbin/service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

Now let’s try it out by connecting some clients!

reference:
http://weblog.bignerdranch.com/?p=18

Linux as the WebDAV Server:

On Linux, use your favorite package manager to install Apache. Most distributions will use Apache httpd 2.0 which has mod_dav built-in, so the only editing of the httpd.conf file needed are the DAVLockDB and Directory definitions. Note that you can also authenticate against Active Directory or LDAP using the mod_auth_kerb or mod_auth_ldap Apache modules. For this example, we’ll stick with using htpasswd:

$ sudo vi /etc/httpd/conf/http.conf
..
DAVLockDB /usr/local/apache/var/DAVLockDB

DAV On
AuthName “WebDAV Login”
AuthType Basic
AuthUserFile /etc/httpd/.htpasswd

require valid-user

Order allow,deny
Allow from all

Now create the directories and set permissions:

$ sudo su
# mkdir /usr/local/apache/var
# chown apache:apache /usr/local/apache/var
# mkdir /var/www/html/webdav
# chown www:www /var/www/html/webdav

Finally, on Linux create the user and password file and restart the httpd daemon:

# htpasswd -m -c /etc/httpd/.htpasswd testuser
New password:
Re-type new password:
Adding password for user testuser
# /sbin/service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

Now let’s try it out by connecting some clients!

reference:
http://weblog.bignerdranch.com/?p=18

apache, DocumentRoot must be a directory

You got "DocumentRoot must be a directory" error even it is really a
directory because of SELinux extensions. Run
system-config-securitylevel (or redhat-config-securitylevel) to
disable SELinux for httpd or give SELinux permissions to that
directory:
chcon -R -h -t httpd_sys_content_t /path/to/directory

More help at: http://fedora.redhat.com/docs/selinux-faq-fc3/index.html

reference:
http://www.issociate.de/board/post/186682/DocumentRoot_must_be_a_directory.html

Monday, January 28, 2008

Install Ruby on Rails

1) Install Ruby

sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby ruby1.8-dev

2) Install RubyGems via source (recommended):

For me, the below installed the gem executable to /usr/bin/gem1.8. I created a symbolic link so the rest of these commands will work: sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
tar xzvf rubygems-1.0.1.tgz
cd rubygems-1.0.1
sudo ruby setup.rb
ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system

2)(alternate) Install RubyGems from ubuntu repository and update it (not recommended because apt-get will complain about files changed by gem update --system):

sudo apt-get install rubygems
sudo gem update --system

3) Install Rails and it's dependencies (with RubyGems)

sudo gem install rails -y

Here is a good time to install any gems you may need.

4) Create your first Rails app, as the current user (i.e., no sudo):

$ rails /path/to/new/railsapp

Of course, replace /path/to/new/railsapp with the path to the location where you'd like the source code for your new Rails application to exist. This can be /home/myhome/rails/myapp.


Reference: https://help.ubuntu.com/community/RubyOnRails

Getting strat PostgreSQL 8.2.6

Settings for PostgreSQL in Ubuntu 7.04 (Feisty Fawn)

1. create user
$ su -
# su - postgres
$ createuser husylvan
$ su - husylvan


2. create cluster
$ sudo pg_createcluster -u husylvan -d ~/pgdata 8.2 pgdata

*Configuration files(postgresql.conf, pg_hba.conf, and pg_ident.conf) are in /etc/postgresql/8.2/pgdata/

3. start PostgreSQL server
$ pg_ctlcluster 8.2 pgdata start


4. create database
$ createdb mydb


5. start PostgreSQL interactive terminal
$ psql mydb

* commands introduced by TA are in /usr/lib/postgresql/8.2/bin
** for ruby on rails
$ sudo gem install ruby-postgres -- --with-pgsql-include-dir=/usr/include/postgresql --with-pgsql-lib-dir=/usr/lib/postgresql/8.2/lib


Settings for PostgreSQL in Mac OS

1. download PostgreSQL 8.2.5 for Mac OS
http://www.postgresqlformac.com

2. install server only
double click PostgreSQL.mpkg in Server folder

3. it will be installed in /Library/PostgreSQL8

4. change postgres account password
sudo passwd postgres

5. create my account role in the db
su -m postgres -c 'createuser Hwal'

6. create db using Create Database icon in Applications/PostgreSQL folder

# for ruby on rails
$sudo gem install ruby-postgres -- \
--with-pgsql-include-dir=/Library/PostgreSQL8/include \
--with-pgsql-lib-dir=/Library/PostgreSQL8/lib

## other way (not recommended)
$ initdb -D ~/Documents/ClassDocs/cs186/pgdata
$ pg_ctl -D ~/Documents/ClassDocs/cs186/pgdata start
$ createdb depot_development
$ psql depot_development
% CREATE TABLE countries (
name char(20),
latitude int,
longitude int,
area int,
population int,
gdp int,
gdpYear int);

Tuesday, January 22, 2008

Eclipse Java debugging problem

To install proprietary Java, you must have the Multiverse repository enabled.

Ubuntu 7.04

  • Sun Java6: sun-java6-bin, sun-java6-jre

sudo apt-get install sun-java6-bin sun-java6-jre
Now you need to open Eclipse and specify that the default workspace JRE
should be SUNs JRE. Go to Window - Preferences - Java - Installed JREs
and click add to add SUN JRE.
The JRE home directory is: /usr/lib/jvm/java-6-sun