Skip to content

Instantly share code, notes, and snippets.

View chubas's full-sized avatar

Rubén Medellín chubas

View GitHub Profile
@chubas
chubas / uncompress function
Created September 20, 2010 20:50 — forked from codingpains/bash extract function
GunTarUntarRarBunZipWaitWhat
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
@chubas
chubas / gist:551799
Created August 26, 2010 17:16
Twitter status sanity
require 'json'
require 'net/http'
require 'uri'
status = JSON.parse Net::HTTP.get(URI.parse("http://api.twitter.com/1/account/rate_limit_status.json"))
red, green, reset = "\e[31m", "\e[32m", "\e[0m"
wait = (Time.at(status["reset_time_in_seconds"].to_i) - Time.now).to_i
if (hits = status["remaining_hits"]).zero?
puts "#{red}Oops#{reset}, seems you have to wait another #{red}#{wait / 60} mins, #{wait % 60} secs#{reset}."
else
@chubas
chubas / gist:477067
Created July 15, 2010 15:04
Show git branch name in terminal
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"