Skip to content

Instantly share code, notes, and snippets.

View brettbuddin's full-sized avatar
🤖
Arguing with computers.

Brett Buddin brettbuddin

🤖
Arguing with computers.
View GitHub Profile
$ git checkout topic
$ git cherry master
- 31e27cc5bf02c7b145340a13c9874f729e5bec01
+ 9cf4af52e76adec45a5d63317bce344609406e89
<!DOCTYPE html>
<html>
<head>
<virb load="title" />
<virb load="meta" />
<virb load="css" />
<virb load="icon" />
<!--[if lt IE 8]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script>
<![endif]-->
@brettbuddin
brettbuddin / install.sh
Created May 10, 2011 18:53
New machine setup. SET IT! AND FORGET IT!
#!/bin/sh
# Usage: bash < <(curl -s https://gist.github.com/raw/965142/install.sh)
if [ ! -d "/Developer/Applications/Xcode.app" ]; then
echo "Please install Xcode first. Exiting."
exit 1
fi
# Have sudo ask us for our password before we kick everything off so we can walk away.
sudo echo "Here we go..."
@brettbuddin
brettbuddin / docksend.vim
Created May 9, 2011 18:15
DockSend for Vim
function! DockSend()
let filePath = expand("%:p")
let appleScript = "-e \"on run argv\r
\ignoring application responses\r
\tell app \\\"Transmit\\\" to open POSIX file item 1 of argv\r
\end ignoring\r
\end run\""
silent exec "!osascript " . appleScript . " \"". filePath . "\""
echo filePath." sent to Transmit."
@brettbuddin
brettbuddin / gist:957498
Created May 5, 2011 17:43
Switch between .h and .c, .m, .cc or .cpp files quickly. Change the function name to whatever you want. She's ugly.
function! Switch()
if expand('%:e') == 'h'
try | find %:t:r.m
catch
try | find %:t:r.c
catch
try | find %:t:r.cc
catch
try | find %:t:r.cpp | catch | endtry
endtry
desc "Starts an HTTP server in the current directory"
task :server do
config = {:Port => 3000, :DocumentRoot => '.'}
server = WEBrick::HTTPServer.new config
['INT', 'TERM'].each do |signal|
trap(signal) { server.shutdown }
end
server.start
end
@brettbuddin
brettbuddin / gist:931985
Created April 20, 2011 17:09
Grabs the H.264 version of a video from YouTube.
require 'curb'
require 'cgi'
def youtube_url(video_id)
c = Curl::Easy.new("http://www.youtube.com/watch?v=#{video_id}")
c.cookies = 'PREF: f2=40000000;'
c.perform
content = c.body_str
matches = content.match(/"fmt_url_map":\s"([^"]*)"/)
Started POST "/jobs.xml?type=dynamic&notify_email=brett%40intraspirit.net&sid=9e7425eb91585a8ded7f18933ff27534f87235a741674621a28a18b9a084fb88&inputs[magnitude]=50.0&inputs[source]=http%3A%2F%2Fs3.amazonaws.com%2Fhowdydudeyouareawesome%2Fvideos%2Fuploads%2F146%2Foriginal.mov%3F1302815574&destination=http%3A%2F%2FREDACTED%3A%2FREDACTED%40howdydudeyouareawesome.s3.amazonaws.com%2Fdownloads%2F%3Auuid" for REDACTED 2 at 2011-04-14 21:13:06 +0000
Processing by JobsController#create as XML
Parameters: {"type"=>"dynamic", "notify_email"=>"brett@intraspirit.net", "sid"=>"9e7425eb91585a8ded7f18933ff27534f87235a741674621a28a18b9a084fb88", "inputs"=>{"magnitude"=>"50.0", "source"=>"http://s3.amazonaws.com/howdydudeyouareawesome/videos/uploads/146/original.mov?1302815574"}, "destination"=>"http://REDACTED:REDACTED@howdydudeyouareawesome.s3.amazonaws.com/downloads/:uuid"}
Completed 201 Created in 869ms (Views: 4.1ms | ActiveRecord: 9.5ms)
require "rubygems"
require "ffmpeg"
include FFMpeg
PRESETS = {
:mp4_240x180_400k_aac => {
:block => lambda {
resolution "240x180"
audio_codec "libfaac"
@brettbuddin
brettbuddin / sample_encoding.rb
Created April 8, 2011 15:26
Using the new Preset API to define a preset in another location from where you are actually calling `convert`.
require "rubygems"
require "bundler/setup"
require "ffmpeg" #=> https://github.com/brettbuddin/ffmpeg
include FFMpeg
Presets.define(:mp4_240x180_400k_aac, "mp4") do
resolution "240x180"
audio_codec "libfaac"
video_bitrate "400k"