Friday, September 25, 2009

screen

Use ssh to login to server and start screen:
ssh -t $1 'screen -dRR'

screen -S main = create new screen session named "main"
^a d # log out of screen, but leave running
^a c # new window
^a k # close window
^a n # next window
^a p # previous window

Configuration file to paste in ~/.screenrc:
hardstatus on
hardstatus alwayslastline
startup_message off
termcapinfo xterm ti@:te@
hardstatus string "%{= kG}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
screen -t bash1 1
screen -t bash2 2
screen -t bash3 3
screen -t bash4 4



Good reference

Wednesday, May 20, 2009

Essential Firefox settings

Install these extensions:

Set home page to Google.

Enable master password.

Thursday, October 30, 2008

Regular expressions

email reg exp:
[a-zA-Z0-9._-]+@(([a-zA-Z0-9_-]{2,99}\.)+[a-zA-Z]{2,4})|((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9]))
url reg exp:
[a-zA-Z]{3,4}[sS]?://((([\w\d\-]+\.)+[ a-zA-Z]{2,4})|((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])))((\?|/)[\w/=+#_~&:;%\-\?\.]*)
IP reg exp:
(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])

Thursday, October 2, 2008

Automate sudo password

I'm tired of typing my password to add new packages with Synaptic.

So, one solution is to edit the sudoers list with sudo visudo. To automate the sudo password for all programs add:
%yourgroup ALL = NOPASSWD: ALL
But this is excessive, so to automate the password for just a particular program provide its path like this:
%yourgroup ALL = NOPASSWD: /usr/sbin/synaptic

Now I can add new packages with Synaptic without being prompted for a password.

Sunday, June 1, 2008

Fun with Festival

Festival is a light weight text to speech program originally developed at The University of Edinburgh.

# from the command line
> echo "hello world" | festival --tts

# from a file
> echo "hello world" > file
> festival --tts file

Wednesday, May 28, 2008

file conversion

Open source developers have focussed a lot of energy on the plumbing. Here are some examples for manipulating file types:

# convert between video formats
> ffmpeg -i input.flv output.mpg

# convert between image formats
> convert input.png output.jpeg

# join together audio files
> sox in_1.wav in_2.wav out.wav

# remove sound from video
> mencoder -ovc copy -nosound video.avi -o video_nosound.avi
# add sound to video
> mencoder -ovc copy -audiofile soundtrack.mp3 -oac copy video_nosound.avi -o video_sound.avi

Saturday, April 5, 2008

firefox proxy

If your web browsing is restricted you can use a remote server to get round it. In the firefox network settings choose manual proxy and a port number. Then at the command line type:

> ssh -XfN -D PORT -p 22 user@server

Now when you surf the packets will be redirected through this ssh tunnel.