Skip to content

Instantly share code, notes, and snippets.

@burningTyger
burningTyger / BASH prompt
Created January 7, 2011 23:56
git and rvm enabled BASH prompt
#This is my personal prompt. Script taken from
#http://tammersaleh.com/posts/a-better-rvm-bash-prompt
function __git_dirty {
git diff --quiet HEAD &>/dev/null
[ $? == 1 ] && echo "!"
}
function __git_branch {
__git_ps1 " %s"
@burningTyger
burningTyger / app.rb
Created January 28, 2011 08:07 — forked from lchanmann/app.rb
require 'rubygems'
require 'haml'
require 'sinatra'
require 'sinatra/flash'
require 'file_uploader'
enable :sessions
get '/' do
haml :index
# To just pull changes from Github, forcing Git to use your local changes for any conflicts:
git pull --strategy=ours origin master
# To completely update each of your Git repositories in one command (run this inside each repository):
git add . && git commit -m "Updating to current working version" && git pull --strategy=ours origin master && git push origin master
register({
name: 'moodle.domain.com',
url: 'http://moodle.domain.com/',
icon: 'http://moodle.domain.com/theme/mytheme/favicon.ico',
domains: [ 'moodle.domain.com' ],
sessionCookieNames: [ 'MoodleSession', 'MoodleSessionTest' ],
identifyUser: function() {
var site = this.httpGet('http://moodle.domain.com/user/view.php');
this.userName = site.body.querySelector('div.logininfo a').text;
@burningTyger
burningTyger / gist:1032625
Created June 18, 2011 00:03
rbx bug in IO#lineno
counter={}
File.open('lines.txt', 'r') do |f|
f.each_line do |l|
counter[f.lineno] = l
end
end
counter.each_pair {|k,v| puts "#{k}: #{v}"}
#where lines.txt is
@burningTyger
burningTyger / sparkle.zsh-theme
Created July 20, 2011 19:39
oh-my-zsh sparkle theme
# This theme focuses on the current Ruby and git status/branch
PROMPT='$fg[yellow]$(rvm-prompt i v g) $fg[white]%n@%m:%~$(git_prompt_info)$reset_color $ '
# git theming
ZSH_THEME_GIT_PROMPT_PREFIX="$fg[yellow] "
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="$fg[red]!"
@burningTyger
burningTyger / user.rb
Created August 13, 2011 08:35 — forked from namelessjon/user.rb
Example user with a BCrypt password
require 'bcrypt'
class User
include DataMapper::Resource
attr_accessor :password, :password_confirmation, :password_reset
timestamps :at
property :id, Serial
@burningTyger
burningTyger / gist:1204454
Created September 8, 2011 19:38
useful sinatra template route snippet
# use this snippet for routes that are partly dynamic, partly static.
# For example your jquery.js is static. With this route Sinatra will check
# your public dir and if it finds it there, jquery.js will be served.
# if not, the views dir will be searched. If found it's served as compiuled coffee script
# if not you will get a 404. Seems useful to me...
# btw, namelessjohn remined me that checking for the file first is good because then you
# won't create expensive and possibly leaking symbols of files that don't exist.
# also, we set last_modified which is good for caching.
get '/assets/js/:file.js' do
@burningTyger
burningTyger / gist:1230371
Created September 20, 2011 21:11
get rid of empty sinatra params
# use this line to delete all keys that are empty:
params.delete_if { |k, v| v.empty? }
# now you can simply check if a key exists:
do_something if params[:some_key]
@burningTyger
burningTyger / fix_19_spec.md
Created October 15, 2011 09:11
Rubinius: Fixing a failing spec for 1.9 mode. A simple introduction.

Last week I decided to fix some failing specs for Rubinius 1.9 mode. If you haven't done that before continue reading you will be surprised how easy that can be.

To get started you need a working clone of Rubinius. You can find instructions in the docs.

Now let's see what specs are failing. I consult the failing tags which can be found in:

rubinius/spec/tags/19/ruby/core

There are many specs still failing so I go through some and find something interesting in: