Tuesday, May 13, 2008
Thursday, September 13, 2007
Some random one-liners
The following will generate 8-digit unique number
Getting specific position: begins at 99th position and lasts for exactly 15 bytes
/usr/bin/perl -e '$range=1000000;$min=10000000;$randomN=int(rand($range))+$min;print "$randomN\n";'
Translating Milliseconds to the Localtime
echo "$MILLIS" | /usr/bin/perl -e 'chomp($in=
);$res=localtime($in/1000);print "$res\n";'
Getting specific position: begins at 99th position and lasts for exactly 15 bytes
sed -e 's/^\([^,]\{98\}\)\(.*\)$/\2/g' -e 's/^\([^,]\{15\}\).*$/\1/g' -e 's/^[^0-9][^0-9]*//g' -e 's/ //g' pbt*.ach
Tar-up some dir on local system while piping through ssh to a remote system
(cd $base/$reports/..; tar -cf - $reports) | ssh anotherhost "(test -d $remoteDir || mkdir -p $remoteDir); cd $remoteDir; tar -xf -"
Friday, May 04, 2007
Using mencoder to cut out pieces of video
Following command can be used to cut video starting at 16 seconds - to the end:
=> mencoder -ss 16 -oac copy -ovc copy some_video.avi -o new.avi
this one is to cut starting at 16 seconds to 56 seconds only:
=> mencoder -ss 16 -endpos 56 -oac copy -ovc copy some_video.avi -o new.avi
this is to concatenate a bunch of files into a new one:
=> cat *avi | mencoder -oac copy -ovc copy -o new.avi -
=> mencoder -ss 16 -oac copy -ovc copy some_video.avi -o new.avi
this one is to cut starting at 16 seconds to 56 seconds only:
=> mencoder -ss 16 -endpos 56 -oac copy -ovc copy some_video.avi -o new.avi
this is to concatenate a bunch of files into a new one:
=> cat *avi | mencoder -oac copy -ovc copy -o new.avi -
Tuesday, April 10, 2007
login using ssh shared key
On the same note - using shared keys for authentication:
1. ssh-keygen -t rsa
2. scp .ssh/id_rsa.pub@ :/home/ /.ssh/authorized_keys
Friday, November 10, 2006
SSH forwarding stuff
I allways forget the syntax of these commands. So, finally let's write it somewhere:
mybox> ssh -R 5555:local_box:8080 -l user_name some_host
Explanation:
local_box = the box I am sitting on (same as mybox)
5555 = the port, which will be opened on 'some_host' to map to 'local_box:8080'
8080 = as stated above, this is the port used on 'local_box', which we like to connect to from 'some_host'
Note: 'local_host' can be *any* host on the local side. It could be same as the one we are connecting from, or any other one on the network.
mybox> ssh -R 5555:local_box
Explanation:
local_box = the box I am sitting on (same as mybox)
5555 = the port, which will be opened on 'some_host' to map to 'local_box:8080'
8080 = as stated above, this is the port used on 'local_box', which we like to connect to from 'some_host'
Note: 'local_host' can be *any* host on the local side. It could be same as the one we are connecting from, or any other one on the network.