Skip to content

Instantly share code, notes, and snippets.

@burningTyger
burningTyger / BASH prompt
Created Jan 7, 2011
git and rvm enabled BASH prompt
View 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"
View app.rb
require 'rubygems'
require 'haml'
require 'sinatra'
require 'sinatra/flash'
require 'file_uploader'
enable :sessions
get '/' do
haml :index
View git.sh
# 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
View moodle.js
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 Jun 18, 2011
rbx bug in IO#lineno
View gist:1032625
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 Jul 20, 2011
oh-my-zsh sparkle theme
View sparkle.zsh-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 Aug 13, 2011 — forked from namelessjon/user.rb
Example user with a BCrypt password
View user.rb
require 'bcrypt'
class User
include DataMapper::Resource
attr_accessor :password, :password_confirmation, :password_reset
timestamps :at
property :id, Serial
@burningTyger
burningTyger / gist:1204454
Created Sep 8, 2011
useful sinatra template route snippet
View gist:1204454
# 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 Sep 20, 2011
get rid of empty sinatra params
View gist:1230371
# 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 Oct 15, 2011
Rubinius: Fixing a failing spec for 1.9 mode. A simple introduction.
View fix_19_spec.md

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:

You can’t perform that action at this time.