Saturday, December 13, 2008

screen

when to I use screen :

* When "nohup" is just not enough
* When the power goes off and you are left in the middle of nowhere
* When I need to log on to 10 different terminals each day
* When I do not want to enter 10 different username passwords each day

"screen" is a terrific unix utility that allows you to start a terminal without having to worry about you job being interreputed mid-way. It is better than nohup in that respect nohup only allows unix commands to be started in a "nohup" fashion. If for instance you are working with an interactive program like sqlplus and your internet connection happen to break, you will loose your context and any transactions that you were working on.

It essentially allows you following :
* Multiple sessions in a single ssh window (screen multiplexing)
* Ability to "resume" a session in the state you left it - irrespective of power outage, internet connection termination etc

Here is how you use it :

1. Make sure it is installed on your system by typing "screen --help"
2. If it is not installed, you can install it by "yum install screen" on a fedora box.
3. start a screen session by typing "screen" and you should be in a screen session.
4. If you are disconnected or closed the terminal, type "screen -r -d" to reattach to the session

Here are some of the short-cuts available (All after CTRL+A)

c : creates a new
n : next screen window
p : previous screen window
a : toggle between two screen windows
[0-9] : Go to a specific screen window identified by a number
A : Set the name of a screen window
" : List all the existing screen
ESC : Scroll up or down on a screen

Saturday, November 15, 2008

Man on the moon (well almost)

India becomes the 4th Nation to put a lunar probe on the moon ! I am proud to be the 4th country to do that(as against the alleged 3rd world country banter from Matthew Hayden who knows nothing more than being a sore loser)

Sunday, October 19, 2008

pasting code in vim

:set paste

paste the code

:set nopaste

set pastetoggle=F3 in your vimrc file is an alternative.

Friday, October 17, 2008

Renaming Files in Linux

Type the following on commandline of a bash shell and change the logic as needed.


for i in `ls /home/ssinghal` ; do mv "$i" "$i.new" ; done

Tuesday, September 30, 2008

sudo without password

1. Log in to a unix box as root
2. Execute "visudo" to open sudo editor
3. Enter the following line
ALL=(ALL) NOPASSWD: ALL

Tuesday, September 23, 2008

Database Objects - Finding Dependencies

You come across tables in databases that are being populated by other pl/sql procs, triggers e.t.c what becomes difficult is to figure out which process is actually updating a table.

The following query will list objects that refer a table "TABLE_A" which belongs to a schema "SCHEMA_A"


select name,owner
from dba_dependencies
where referenced_name='TABLE_A'
and referenced_owner='SCHEMA_A'

Tuesday, August 19, 2008

JQuery - Getting Started


// Makes an element visible which has the id 'mydiv'
$("#mydiv").show();

// Makes each odd tr element to have a blue backcolor
$("tr:odd").css("background-color", "blue");


// What if we want to make the header row have a different look ? Show Me
$("#results tr:first").css("background", "black");
$("#results tr:first").css("color", "white");
$("#results tr:first").css("font-weight", "bold");


// We also could have assigned a class name to the header tr element like this
$("#results tr:first").addClass("header");


//All span that are inside a div element (may not be immediate child of the div) will be selected.
$("div span").css("border", "1px solid");

//Here is how we select the links that are descendent of span which are direct children of a div
$("div > span a")

//Here is how we can select a div with id mydiv
$("div#mydiv")


// Here is how we select all links under div elements that have css class set to mycss
$("div.mycss a")

// if we want to find a link that points to http://www.google.com then we would write
$("a[href=http://www.google.com]")


// Modifications
$("body").prepend("");
$("div#mydialog").html("

Hi There!

");
$("#mytable").wrap("
");


// How to replace all hr elements (horizontal line) with a br element
$("
").replaceAll("hr");


Reference : http://www.shafqatahmed.com/2008/08/mybutton-font-f.html