Skip to content

Instantly share code, notes, and snippets.

View samir's full-sized avatar
:octocat:
I may be slow to respond.

Samir M. Braga samir

:octocat:
I may be slow to respond.
View GitHub Profile
@fxposter
fxposter / sass_initializer.rb
Created June 16, 2011 23:22
asset_path method to be used in sass files
# Usage
# body {
# background: url(asset_path('background.png')) #FFFFFF;
# }
module Sass::Script::Functions
include Sprockets::Helpers::RailsHelper
def asset_path(path)
assert_type path, :String
Sass::Script::String.new(super(path.value), :string)
end
@henkm
henkm / gist:952240
Created May 2, 2011 19:55
Add new items via JQuery TokenInput / Ruby on Rails
#model (idea 100% stolen from ryanb)
def author_tokens=(ids)
ids.gsub!(/CREATE_(.+?)_END/) do
Author.create!(:name => $1).id
end
self.author_ids = ids.split(",")
end
# jquery.tokeninput.js
@allthingscode
allthingscode / Bash Colors
Created January 28, 2011 21:32
Dumps a nicely formatted table with all bash colors
#!/bin/bash
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what is available. Each
# line is the color code of one foreground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
@samir
samir / gist:707793
Created November 20, 2010 12:41
Show current version of git, svn and rvm in prompt
# I made this gist to build my shell prompt based in various references on the web
# I will try to list the most of references, but sorry if I not put your here -
# http://henrik.nyh.se/2008/12/git-dirty-prompt (GIT)
# GIT
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {