Mac/OS X


Cutting up a video file using avconv

avconv -i [input file] -ss [start time hh:mm:ss.milisecs] -t [duration in secs] -codec copy [output file]

Or use -to [end time hh:mm:ss.milisecs] to indicate the time at which to stop cutting instead of the duration.
Note: If you chose to not re-encode (i.e., you use the -codec copy option), in many cases the trimmed/cut output file will not have the first 5 seconds of the video, which is super-annoying. To fix this, just remove the -codec copy, which will take a longer time but give you an actual good cut.



Commands like M-x are executed by typing the Meta key + x (on Linux, Meta key is Alt)

Commands like C-x are executed by typing the Ctrl key + x




Setting up an SSH tunnel

Suppose you have a machine at that has a service running on port 3333, but you cannot access that port on due to a firewall.

You can forward that port to a local port 9999 on your machine, if you can SSH into

ssh -f -N -L 9999:

-f puts ssh in background
-N makes it not execute a remote command

You can simplify this whole process with a config file.

Host tunnel
    # this is optional, if you have a special key for
    IdentityFile ~/.ssh/private.key
    LocalForward 3333
    User user


Using sed to redo your #include's

sed 's/#include \"..\/Core\/Core.h\"/#include \<Core.h\>/g'


Adding whitespace

There were a lot of cout<<"hsds"<<i<<endl; calls in the code, and I wanted to space out the <<.

Search: (\S)(<<)(\S) Replace with: $1 $2 $3

Be sure to check "Regular expressions." You probably don't need to capture the << part.


How to compute a delta and patch a file

alinush@x220 [~] (master %) $ vim new-file.txt     #  hello alin has apples;
alinush@x220 [~] (master %) $ vim old-file.txt     #  hello johnny has apples.
alinush@x220 [~] (master %) $ rdiff signature old-file.txt sig
alinush@x220 [~] (master %) $ rdiff delta sig new-file.txt delta.txt
alinush@x220 [~] (master %) $ rdiff patch old-file.txt delta.txt patched.txt
alinush@x220 [~] (master %) $ cat old-file.txt ; cat new-file.txt ; cat patched.txt ;
hello alin has apples;
hello johnny has apples.
hello johnny has apples.