Skip to content

Instantly share code, notes, and snippets.

View sauron's full-sized avatar

Pablo Barrios sauron

  • San Miguel de Tucumán, Argentina
View GitHub Profile
@sauron
sauron / my.zsh-theme
Created June 26, 2013 01:58
Basic zsh theme configuration. Showing the current path, git branch, rvm info Based on robbyrussell ohmyzsh theme
function is_rvm() {
if [[ "$(rvm-prompt)" != "" ]]; then
echo "[%{$fg[red]%}$(rvm-prompt)%{$fg_bold[white]%}]"
fi
}
PROMPT='%{$fg_bold[cyan]%}%c %{$fg_bold[white]%}$(git_prompt_info)%{$fg_bold[white]%}$(is_rvm) %{$fg_bold[cyan]%}• %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
@sauron
sauron / .gitconfig
Created June 28, 2013 20:03
Git aliases and coloring things
[alias]
up = pull --rebase origin
br = branch
st = status
ci = commit
co = checkout
ql = log --abbrev-commit --pretty=oneline
qlr = log --reverse --abbrev-commit --pretty=oneline
pending = log --reverse --abbrev-commit --pretty=oneline master --cherry-pick master...
undo = reset --soft HEAD^
{
"caret_style": "phase",
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"file_exclude_patterns":
[
"*.pyc",
@sauron
sauron / fibo.rb
Created December 5, 2013 22:37
Fibonacci Loves maths :D
def fibo(n)
root5=Math.sqrt(5)
phi=0.5+(root5/2)
Integer(0.5+phi**n/root5)
end
puts fibo(ARGV.first.to_i)
@sauron
sauron / books_general.rb
Created December 10, 2013 00:04
Acciones especificas para un recurso/miembro en particular. Manejo de sessiones
# config/routes.rb
#agregancdo una accion a un recurso/miembro en particular
resources :books do
member do
put :publish
end
end
# o
put "/books/:id/publish", to: "books#publish"
@sauron
sauron / christmass_tree.rb
Last active December 31, 2015 21:09
What it takes to make a scalable Christmas tree in Ruby?
#Simple tree that will look as an arrow :D
height = 20
((1..height).to_a+[6]*height.div(5)).map do |i|
puts ('*'*i*2).center(80)
end
#Simple tree that look more like a doodle christmas tree
height = 20
(
@sauron
sauron / auto.sh
Last active October 7, 2016 23:27
My updated version of https://github.com/postmodern/chruby so it always set the gem_home as the directory where there is a .ruby-version file. Line 14 contains the "super hack"
unset RUBY_AUTO_VERSION
function chruby_auto() {
local dir="$PWD/" version
until [[ -z "$dir" ]]; do
dir="${dir%/*}"
if { read -r version <"$dir/.ruby-version"; } 2>/dev/null || [[ -n "$version" ]]; then
if [[ "$version" == "$RUBY_AUTO_VERSION" ]]; then return
@sauron
sauron / keybase.md
Last active February 8, 2017 16:12

Keybase proof

I hereby claim:

  • I am sauron on github.
  • I am pablo_barrios (https://keybase.io/pablo_barrios) on keybase.
  • I have a public key whose fingerprint is 02A9 9521 52E9 3BC3 8CC8 5995 E577 87B8 4A3C C3CC

To claim this, I am signing this object:

@sauron
sauron / .profile
Last active November 8, 2017 19:26
Prompt bash for GIT with branches - rvm - and git status.For Mac OSX it must be put on the ~/.profile fileFor Linux it must be put on the ~/.bash_rc file or similar.Just a note the "nothing to commit,..." message depends of your git version.
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
@sauron
sauron / Sublime USER Settings.json
Created August 28, 2020 13:25
Sublime Settings
{
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Palenight.tmTheme",
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",