Skip to content

Instantly share code, notes, and snippets.

View semanticart's full-sized avatar

Jeffrey Chupp semanticart

View GitHub Profile
@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 / 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 / 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 / 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 / search_and_test.rb
Created December 24, 2010 19:15
search the test files for a phrase and run the tests that match
# you'll probably want to alias this in one of your dotfiles
# i.e. alias st="ruby -I\"lib:test\" search_and_test.rb"
#
# the -I"lib:test" can be important if you get complaints like "no such file to load -- test_helper (MissingSourceFile)"
ack_opts = [
"-i", # case insensitive
"-l", # just return file names
"-G _test.rb", # only search files whose name matches /_test.rb/
ARGV.join(' '), # pass along any options we're passed in (usually just the search string)
#!/bin/sh
# ack the diff with a regexp to
# prevent you from adding lines (the \+ at the beginning indicates an added line in the diff)
# that introduce console.log
# and are not commented out (the \s* before console.log)
has_console_log=$(git diff --cached | ack '^\+\s*console\.log\(.*\)')
if [ "$has_console_log" != "" ]
@semanticart
semanticart / rails3-skeletor.rb
Created October 14, 2010 22:20
a rails 3 template app that gives you a few nifty items
# usage: rails new APP_NAME -m http://gist.github.com/627198.txt -TJ
# the -T drops test-unit and the -J drops prototype
gem "pg"
gem "omniauth"
gem "paperclip"
gem "haml"
gem "sass"
common: &shared
adapter: sqlite3
pool: 5
timeout: 5000
<% %W(development test staging production).each do |env| %>
<%= env %>:
database: rcworkshop_<%= env %>.sqlite3
<<: *shared
<% end %>
en:
users:
show:
title: "{{@user.name}} has {{@user.hair.color}} hair"
description: "{{@user.name}}'s page on my site"
keywords: "user, {{@user.name}}, {{page_keywords}}, etc. etc."
en:
default:
title: "My default title"
users:
index: "My Awesome User index"
show: "{{name}}'s page!"