Thursday, March 6, 2008

Getting Started with Rails 2.0 on ruby

create a rails project called student with mysql as database (default is sqllite)

rails -d mysql student

vim config/database.yml and edit username/password if required

create the database if not already created through backend
rake db:create:all

Generate a scaffold for a student
ruby script/generate scaffold studen name:string address:string

edit db/migrate/001_create_students.rb to add more tables or columns to existing table. This step can be skipped.

Create the Database tables
rake db:migrate

Run server
ruby scripts\server

Access the project through a browser
http://localhost:3000/students

tada

Sunday, March 2, 2008

vim - stop autoindent while pasting text

On a putty terminal, when you copy-paste code from other sources, it results in a complete mess, due to vim trying to format it again. To avoid this, type

:set pastetoggle=

Now you can use to toggle between paste mode (and no paste mode).

When in paste-mode auto indent will be turned off. This is very useful when pasting text that's already indented.

source:
http://amix.dk/blog/viewEntry/19083

vim - going back in time

supported since vim 7

" Go back 1 minute
:eariler 1m

g+ and g- can be used for redo and undo ( u and CTRL + r still applies)

Saturday, March 1, 2008

Long Operations in Oracle

It is nice to know what queries are taking time to finish. The following sql figures out the "long operations" currently being processed


SELECT username,time_remaining,sofar/totalwork,message,target_desc
FROM gv$session_longops where sofar<totalwork
ORDER BY message

Wednesday, February 13, 2008

Apache Web Service Framework

http://incubator.apache.org/cxf/

Monday, February 11, 2008

vim - recording keystrokes and reusing

http://www.vim.org/tips/tip.php?tip_id=144

The most useful feature that I find in VIM is the "recording" feature (:help recording). I have used this to automatically insert function headers, re-indent lines, and convert some 34 source files into HTML.

This feature is most useful when you want to do some repeated jobs, which you cant do easily using ".". You can set about writing a function, define a mapping, etc, but then these things might take time. By recording, you can try out and find the actual keystrokes that does the job.

To start recording, press "q" in normal mode followed by any of "0-9a-z". This will start recording the keystrokes to the register you choose. You can also see the word "recording" in the status(?) line. You can start the key sequences that you want to record. You can go to insert mode and type if you want.

To stop recording, press "q" in the normal mode.

To playback your keystrokes, press "@" followed by the character you choose. Pressing "@@" will repeat the same again.

Friday, February 8, 2008

subversion : clean non-versioned files from svn source tree

svn status|egrep "^\?"|awk '{print $2}'|xargs rm -rf