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
@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 {
@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).
#
@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
@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
@jsocol
jsocol / data-uri.py
Created July 18, 2011 14:48
Give an image, get a data-uri
#!/usr/bin/env python
"""Command line script to convert a file, usually an image, into a data URI
for use on the web."""
import base64
import mimetypes
import os
import sys
@hilios
hilios / .htaccess
Created August 12, 2011 13:52
YSlow optimize DreamHost apache configuration (Gzip + Far late expire header)
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html M3600
ExpiresByType text/css M3600
ExpiresByType application/javascript M3600
ExpiresByType image/bmp M3600
ExpiresByType image/gif M3600
@jaryl
jaryl / template.rb
Created December 9, 2011 18:11
Rails 3.1 Templater
# set up git and perform initial commit
git :init
append_file '.gitignore' do
<<-EOS
*.rbc
*.sassc
.sass-cache
@seyhunak
seyhunak / gist:1471973
Created December 13, 2011 12:29 — forked from moro/gist:1024620
Kaminari and pushState
(function($){
$('.pagination a[data-remote=true]').live('ajax:success', function(e){ window.history.pushState('', '', $(e.target).attr('href')) })
$(window).bind('popstate', function(){ $.ajax({url:window.location, dataType:'script'}) ; return true });
})(jQuery);
@zhengjia
zhengjia / definition.rb
Created January 6, 2012 00:53
Vagrant box with 'ubuntu' as the default user
# modify from veewee
require 'digest/md5'
CURRENT_DIR = File.dirname(__FILE__)
PRESEED_MD5 = "#{Digest::MD5.file("#{CURRENT_DIR}/preseed.cfg").hexdigest}"
Veewee::Session.declare( {
:boot_cmd_sequence => [
"<Esc><Esc><Enter>",
"/install/vmlinuz ",
"noapic ",
@jasny
jasny / mysql_splitdump.sh
Last active August 24, 2024 22:31
Split MySQL dump SQL file into one file per table or extract a single table
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit