Skip to content

Instantly share code, notes, and snippets.

@jtadeulopes
jtadeulopes / gist:796052
Created January 26, 2011 01:34
rvm prompt
# colocar dentro do ~/.bash_profile
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
# rvm
@jtadeulopes
jtadeulopes / gist:887684
Created March 25, 2011 21:36
exemplos...
385002 = 38500-200
38500201 = 38500-201
2950 = 00295-000
22923 = 02292-300
125 = 00012-500
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
aula. Ele pratica. Instrumentistas geniais nao aprendem a tocar tendo
aula. Eles praticam. Pratique. Chegue em casa depois do trabalho e da
@jtadeulopes
jtadeulopes / mask.rb
Created August 30, 2011 23:24
ruby exercícios
#
# Deve completar a máscara de acordo com o número informado
#
mask("125")
=> "00012-500"
mask("385002")
=> "38500-200"
@jtadeulopes
jtadeulopes / gist:1302661
Created October 20, 2011 23:02
permalink patch
it "should always update permalink" do
model.permalink :title, :always_update => true
record = model.create(:title => "Some nice post", :permalink => " ")
record.permalink.should == "some-nice-post"
record.title = "another title"
record.save
record.permalink.should == "another-title"
@jtadeulopes
jtadeulopes / elastic.rb
Created November 30, 2011 15:59
elasticsearch sort
# encoding: utf-8
require "tire"
users = [
{ :id => '1', :type => 'user', :name => 'Jesus Lopes', :email => 'jl@zigotto.com' },
{ :id => '2', :type => 'user', :name => 'Alfredo', :email => 'alfredo@email.com' },
{ :id => '3', :type => 'user', :name => 'Éder Costa', :email => 'ec@zigotto.com' }
]
Tire.index("users") do
@jtadeulopes
jtadeulopes / gist:2705477
Created May 15, 2012 21:59
rails upgrade
$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
$ rake stats
Code LOC: 1969 Test LOC: 3407 Code to Test Ratio: 1:1.7
$ time bundle exec rails runner "puts 'hello'"
rails real user sys
3.0.11 12.087 7.673 2.236
@jtadeulopes
jtadeulopes / gist:3085890
Created July 10, 2012 20:07
Mac OSX Lion - mysql instaled with brew and gem mysql already installed
$ rake db:create
WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /Users/jtadeulopes/.rvm/gems/ruby-1.8.7-p370@global/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Users/jtadeulopes/.rvm/gems/ruby-1.8.7-p370/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_init
Referenced from: /Users/jtadeulopes/.rvm/gems/ruby-1.8.7-p370/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace
#include <stdio.h>
#define LIMITE 50
int main(void)
{
int A=0, B=0, C=0, soma;
printf("Digite um número inteiro: \n");
scanf("%d", &A);
@jtadeulopes
jtadeulopes / gist:5041735
Created February 26, 2013 20:13
Ruby 2.0 with rbenv
# https://github.com/sstephenson/rbenv
#
# I'm using rbenv-build to install ruby
# https://github.com/sstephenson/ruby-build
cd ~/.rbenv/
git pull
cd plugins/ruby-build/
git pull
rbenv install 2.0.0-p0