Skip to content

Instantly share code, notes, and snippets.

@boscomonkey
boscomonkey / extract_vid_frames.sh
Created December 9, 2010 20:34
extract frames from a video using VLC
#!/bin/sh
T_START=01:00:00
T_END=${FROM}
FNAME=sample.mp4
cvlc --video-filter scene -V image --start-time ${T_START} --stop-time ${T_END} --scene-format jpg --scene-ratio 24 --scene-prefix snap ${FNAME} vlc://quit 2>&1
@boscomonkey
boscomonkey / ruby-mysql-gem.sh
Created October 29, 2010 01:14
install MySQL gem on Mac OSX
export ARCHFLAGS="-arch x86_64"
gem install mysql \
-- \
--with-mysql-dir=/usr/local/mysql \
--with-mysql-config=/usr/local/mysql/bin/mysql_config
@boscomonkey
boscomonkey / heroku_accounts.sh
Created October 22, 2010 01:08
Switch between different Heroku accounts with Bash functions
# Set heroku account credentials where each account file is named ~/.heroku/credentials_XXX
# http://www.mail-archive.com/[email protected]/msg03850.html
function hset() {
ln -s ~/.heroku/credentials_$1 ~/.heroku/credentials
}
# Clear current Heroku account
function hclear() {
[ -L ~/.heroku/credentials ] && rm ~/.heroku/credentials
}
#!/bin/bash
# forward my local port (e.g., 3000) to REMOTE_HOST's port
# and run top to keep tunnel from closing
ssh -t -g -R :$REMOTE_PORT:0.0.0.0:$LOCAL_PORT $REMOTE_HOST "top d 15"
#!/bin/sh
# Use mencoder to create a video from image and audio files
# http://fmtyewtk.blogspot.com/2009/10/how-to-create-video-from-mp3-using.html
# suggests that we cannot use just 1 image file but the following seems to work (though
# vlc reports the video codec is NOT h264)
mencoder "mf://$1" -mf fps=1/60 -audiofile "$2" -oac mp3lame -ovc lavc -lavcopts vcodec=libx264 -noskip -mc 0 -ovc copy -o "$3"
#
# personal account
#
Host personal.repositoryhosting.com
Hostname personal.repositoryhosting.com
IdentitiesOnly yes
IdentityFile ~/.ssh/id_dsa
#
# corporate account
#
// Java snippet for GWT to trap keyboard keyUp events at the document level.
// In other words, no KeyUpHandler needed (nor does Document provide a hook).
Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
if (event.getTypeInt() == Event.ONKEYUP) {
// do something with the key code
// doSomething(event.getNativeEvent().getKeyCode());
# This RoR controller uses "protect_from_forgery" declaration to let anyone
# perform a POST to create another instance of an UnsafeObject.
#
class UnsafeObjectsController < ApplicationController
protect_from_forgery :except => :create
# ...
end
#!/bin/sh
# Transcode an MMS into an H.264 in an .mp4 container.
# Usage: transcode_vlc.sh mms://foo.com/bar.wmv bar.mp4
vlc $1 :sout '#transcode{vcodec=h264,vb=800,scale=1,acodec=mp4a,ab=128,channels=2}:duplicate{dst=std{access=file,mux=mp4,dst=$2}}' :sout-all
#/bin/sh
# git-zip.sh
#
# Creates a zip file of the HEAD of the current git repository
CWD=`basename $PWD`
git archive --format=zip --prefix=${CWD}/ -9 HEAD > ../${CWD}.zip