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