Skip to content

Instantly share code, notes, and snippets.

View mkimg
#!/usr/bin/env bash
if [[ $# -eq 0 ]] ; then
echo 'You must provide a size'
exit 0
fi
# first make the image with no content
convert -size $1 xc:hotpink $1.png
# now add in the size
View wkhtmltopdf.rb
require 'formula'
class Wkhtmltopdf < Formula
url 'http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9.tar.bz2'
homepage 'http://code.google.com/p/wkhtmltopdf/'
# md5 'df2bb84b7d15140ca14732898155dd6a'
sha1 '41f598c0103326e7c13101391447b0284b4ba3cb'
depends_on 'qt'
View README.md
@semanticart
semanticart / template_method.rb
Created Sep 12, 2013
quick & dirty hack at implementing template method / abstracts / insanity
View template_method.rb
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?
@semanticart
semanticart / letter.rb
Last active Dec 21, 2015
letterpress word finder
View letter.rb
# 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
View vim_with_clientserver.sh
# 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
View redo.vim
" 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()
@semanticart
semanticart / gist:1285976
Created Oct 14, 2011 — forked from mariovisic/gist:1281432
ruby 1.9.3 working with ruby-debug
View gist:1285976
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
@semanticart
semanticart / app.rb
Created Sep 11, 2011
example sinatra app
View app.rb
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
itunes ratings in tmux
View tmux.conf
# 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'"