Skip to content

Instantly share code, notes, and snippets.

View semanticart's full-sized avatar

Jeffrey Chupp semanticart

View GitHub Profile
@semanticart
semanticart / ternary.coffee
Created December 27, 2010 04:30
coffee-script handles ternaries poorly?
# I want to write
method = condition ? 'show' : 'hide'
# but that compiles to:
# var method;
# method = (typeof condition !== "undefined" && condition !== null) ? condition : {
# 'show': 'hide'
# };
@semanticart
semanticart / campfire.rb
Created December 29, 2010 23:21
a ruby script for speaking the hudson status in campfire with win/fail images
# this is a little messy but it works.
# ran as a post-build task: ruby /path/to/script/campfire.rb 2>&1 >/dev/null &
require 'rubygems'
require 'uri'
require 'net/http'
require 'tinder'
IMAGE_TRANSLATION = { 'OK' => 'win', 'FAILURE' => 'fail' }
@semanticart
semanticart / tmux.conf
Created May 24, 2011 20:52
itunes ratings in tmux
# this lets you do prefix F1-F5 to rate the current song in iTunes
bind F1 run-shell "osascript -e 'tell app \"iTunes\" to set the rating of current track to 20'"
bind F2 run-shell "osascript -e 'tell app \"iTunes\" to set the rating of current track to 40'"
bind F3 run-shell "osascript -e 'tell app \"iTunes\" to set the rating of current track to 60'"
bind F4 run-shell "osascript -e 'tell app \"iTunes\" to set the rating of current track to 80'"
bind F5 run-shell "osascript -e 'tell app \"iTunes\" to set the rating of current track to 100'"
@semanticart
semanticart / app.rb
Created September 11, 2011 16:32
example sinatra app
require 'rubygems'
require 'httparty'
require 'sinatra'
require 'ruby-debug'
require 'baby_tooth'
configure do
enable :sessions
BabyTooth.configure do |config|
config.client_id = 'XXXXXXXX',
@semanticart
semanticart / gist:1285976
Created October 14, 2011 00:59 — forked from mariovisic/gist:1281432
ruby 1.9.3 working with ruby-debug
curl https://github.com/ruby/ruby/pull/47.patch >> /tmp/r193.patch && rvm install 1.9.3-preview1 --patch /tmp/r193.patch && rm /tmp/r193.patch
" within a migration, do :Rredo
" the R* naming convention is to be consistent with rails-vim commands
function! Rredo()
let l:migration_version = matchstr(expand('%:p'), "\\d\\+")
call Send_to_Tmux("rake db:migrate:redo VERSION=" . l:migration_version . " --trace && rake db:test:prepare --trace\n")
endfunction
command! Rredo call Rredo()
# the gtk2 bit is the magic... from http://stackoverflow.com/questions/10231223/compile-vim-7-3-with-clientserver-feature-on-mac-os-x?rq=1
hg clone https://vim.googlecode.com/hg/ vim
cd vim
hg pull
hg update
./configure --enable-gui=gtk2 --enable-multibyte --with-tlib=ncurses --enable-pythoninterp --enable-rubyinterp --with-ruby-command=/usr/bin/ruby --with-features=huge
make
make install
@semanticart
semanticart / letter.rb
Last active December 21, 2015 18:19
letterpress word finder
# letters are either the first argument or something piped in
#
# e.g.
# ruby letter.rb KTVHROBDRBDLCYTPLEWAFZYMB
# or
# echo "KTVHROBDRBDLCYTPLEWAFZYMB" | ruby letter.rb
# or
# ruby -r ./board_parser -e "puts BoardParser.new('light.png').tiles.join" | ruby letter.rb
letters = (ARGV[0] || STDIN.read).downcase
@semanticart
semanticart / template_method.rb
Created September 12, 2013 19:56
quick & dirty hack at implementing template method / abstracts / insanity
module TemplateMethod
module TemplateInitializer
def initialize(*args)
unimplemented = self.class::TEMPLATE_METHODS.select do |method_name|
!respond_to?(method_name)
end
raise "#{self.class} should implement #{unimplemented.join(', ')}" unless unimplemented.empty?