Skip to content

Instantly share code, notes, and snippets.

#!/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"
#!/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"
@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
}
@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 / 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 / gist:741425
Created December 15, 2010 00:46
Transcript from "sudo port install postgresql83-server" on MBP 10.6.5
---> Computing dependencies for postgresql83-server
---> Fetching postgresql83-server
---> Verifying checksum(s) for postgresql83-server
---> Extracting postgresql83-server
---> Configuring postgresql83-server
---> Building postgresql83-server
---> Staging postgresql83-server into destroot
---> Creating launchd control script
###########################################################
# A startup item has been generated that will aid in
@boscomonkey
boscomonkey / .bash_rvm
Created April 16, 2011 01:15
rvm goodies for your Bash prompt
# add git branch and rvm ruby@gemset in addition to the usual \u \h \w
source "$rvm_path/contrib/ps1_functions"
ps1_set
@boscomonkey
boscomonkey / iterate_over.js
Created May 10, 2011 00:50
JavaScript code to iterate over an array and add its item values to an ordered list and append to a div
function iterateOver(arry, div) {
var ol = $(document.createElement("ol"););
ol.class("records_list");
div.append(ol);
$.each(arry, function(i, item) {
ol.append("<li>" + item.value + "</li>");
});
}
@boscomonkey
boscomonkey / .gitconfig
Created May 12, 2011 23:16
typical Git config preamble
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
@boscomonkey
boscomonkey / get_head.rb
Created May 24, 2011 00:02
Perform an HTTP HEAD on an URL. Returns a Net::HTTPResponse object to access the status code and headers.
class GetHead
# Returns a Net::HTTPResponse. Get the status code (as string):
# resp = with_http "http://imaiku.me/"
# code = resp.code # => "301"
# resp.each {|k,v| puts k + "\t" + v}
def with_http url
uri = URI.parse url
http = Net::HTTP.start uri.host, uri.port
resp = http.head uri.path