Skip to content

Instantly share code, notes, and snippets.

View johnbintz's full-sized avatar

John Bintz johnbintz

View GitHub Profile
module R18n
class Translation
def iterate(s)
root = self
s.split('.').each { |key| root = root[key] }
root
end
end
end
#
# Get SCSS working in Sinatra
#
configure do
Tilt.register 'scss', Tilt::SassTemplate
set :sass, Compass.sass_options.merge({:syntax => :scss})
end
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " ("${ref#refs/heads/}")"
}
export PS1="\[\e[0;37m\][\[\e[0;31m\]\u\[\e[1;37m\]@\[\e[0;32m\]\h\[\e[0;37m\]] \[\e[1;37m\]\w\$(parse_git_branch) \$ \[\e[0;37m\]"
[[ "${TERM}" == "screen" ]] && echo -n -e '\ek'${HOSTNAME%%.*}'\e\'
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " ("${ref#refs/heads/}")"
}
# Install Local Terminal (Incubation) from the Helios Marketplace
# then set an Env variable for your shell for IS_ECLIPSE=yes
# and be sure to do /bin/bash -l, too
if [ "$IS_ECLIPSE" == "yes" ]; then
@johnbintz
johnbintz / build.watchr
Created November 23, 2010 20:27
Rebuild PHP files in a directory, showing warnings when they fail
require 'open3'
require 'rainbow'
require 'fileutils'
static_dir = 'static'
def growl(title, message)
system %{growlnotify -m "#{message}" "#{title}"}
end
@johnbintz
johnbintz / tools.watchr
Created November 29, 2010 18:24
Watchr script to do things that I want it to do
def growl(title, message)
system %{growlnotify -m "#{message}" "#{title}"}
end
def reek(file)
output = %x{reek #{file}}
puts output
file, warnings = output.split("\n").first.split(" -- ")
@johnbintz
johnbintz / eclipse-colorer-mac-os-x.diff
Created November 30, 2010 20:22
The changes to eclipsecolorer SVN trunk to get it to compile a native library for Mac OS X 10.6 64 bit
Index: colorer/src/zlib/contrib/minizip/ioapi.c
===================================================================
--- colorer/src/zlib/contrib/minizip/ioapi.c (revision 1626)
+++ colorer/src/zlib/contrib/minizip/ioapi.c (working copy)
@@ -1,3 +1,7 @@
+#define fopen64 fopen
+#define fseeko64 fseeko
+#define ftello64 ftello
+
/* ioapi.h -- IO base function header for compress/uncompress .zip
@johnbintz
johnbintz / gist:739193
Created December 13, 2010 16:34
Run rcov with RSpec tests from the command line
def rcov(file = nil)
file = Dir['spec/**/*_spec.rb'].join(' ') if !file
system %{bundle exec ruby -Ilib -S rcov -x '/gems/,config/,spec/' -t $(which rspec) -- #{file}}
end
watch('app/(.*/.*)\.rb') { |m| rcov("spec/#{m[1]}_spec.rb") }
watch('spec/(.*/.*)_spec\.rb') { |m| rcov(m[0]) }
rcov
@johnbintz
johnbintz / remote_site_watchr.rb
Created February 22, 2011 14:56
Use with watchr to reload pages on a remote site periodically to check for changes.
require 'net/http'
require 'mechanize'
class RemoteSiteWatchr
def initialize(host, urls, &block)
@host = host
@urls = urls
@block = block
@agent = Mechanize.new
@johnbintz
johnbintz / autotest.rb
Created April 15, 2011 14:05
Basic Autotest mapping/exception configuration bits
# Actually .autotest and lives at the root of your project, from where you execute autotest
# this is all done in a hook, like this:
Autotest.add_hook :initialize do |at|
# i don't like the default exceptions, get rid of them!
at.clear_exceptions
# exclude stuff that changes between each test, like log
at.add_exception('log/')