Skip to content

Instantly share code, notes, and snippets.

View klebervirgilio's full-sized avatar
🎯
Focusing

Kleber Correia klebervirgilio

🎯
Focusing
View GitHub Profile
cd /tmp
git clone git://git.kernel.org/pub/scm/git/git.git
cd git
git checkout v`git --version | awk '{print $3}'`
cp contrib/completion/git-completion.bash ~/.git-completion.bash
cd ~
rm -rf /tmp/git
echo -e "source ~/.git-completion.bash" >> .profile
be rake db:migrate:down VERSION=$(ruby -e 'print Dir["./db/migrate/**"].last.match(/\/(?<s>\d+)/)[:s]')
function add_alias {
echo "alias $1=\"$2\"" >> ~/.aliases
echo 'Reloading...'
sz
}
function show_my_aliases {
echo $my_aliases | sort | grep -e "^$" -v
}
@klebervirgilio
klebervirgilio / gist:4737410
Created February 8, 2013 08:16
Load a mysql database to a local database.
function load_remote_mysql_data{
ssh '$user@$server' mysqldump $mrdb -u$mru -p$mrp | mysql $mldb -u$mlu -p$mlp
echo 'done!'
}
@klebervirgilio
klebervirgilio / helper.rb
Created February 4, 2013 05:36
RUBY: Shows the Class or Instance methods, without too much crap.
module ClearMethods
extend self
def __clear_methods
methods - Object.methods
end
end
class Object
include ClearMethods
end
# Centos 5.8 libyaml anoning warn message.
1 - rvm pkg install libyaml
2 - rvm reinstall all --force --with-opt-dir=~/.rvm/usr
# Based on robbyrussell's theme, with host and rvm indicators. Example:
# @host ➜ currentdir rvm:(rubyversion@gemset) git:(branchname)
# Get the current ruby version in use with RVM:
if [ -e ~/.rvm/bin/rvm-prompt ]; then
RUBY_PROMPT_="%{$fg_bold[blue]%}[%{$fg[green]%}\$(~/.rvm/bin/rvm-prompt)%{$fg_bold[blue]%}]%{$reset_color%} "
fi
# Get the host name (first 4 chars)
HOST_PROMPT_="%{$fg_bold[red]%}➜ %{$fg_bold[cyan]%}%0~ "
@klebervirgilio
klebervirgilio / class.js
Created January 10, 2013 07:39
JS Class
var Class = function(parent){
var klass = function(){
this.init.apply(this, arguments);
}
if(parent){
var subclass = function(){};
subclass.prototype = parent.prototype;
klass.prototype = new subclass;
sudo ifconfig en1 ether `openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
@klebervirgilio
klebervirgilio / data-html-chosen.jquery.js
Created November 10, 2015 04:27
Adds the ability to render html in the list.
$ = jQuery;
$.fn.extend({
chosenDataHtml: function(options) {
return this.each(function(input_field) {
var $this = $(this),
formatSelection = options['formatSelection'] || function(e, data) {
var chosen = data.chosen,