Skip to content

Instantly share code, notes, and snippets.

View klebershimabuku's full-sized avatar

Kleber Shimabuku klebershimabuku

View GitHub Profile
@klebershimabuku
klebershimabuku / deploy.rb
Created November 28, 2013 22:04
Capistrano receipt to deploy a rails application to DigitalOcean's host. This is a working receipt for: * capistrano 2.15.4 * capistrano-ext 1.2.1 * rvm-capistrano 1.4.4
require 'rvm/capistrano'
require 'bundler/capistrano'
set :normalize_asset_timestamps, false
set :application, "app_name"
set :repository, "git@github.com:username/repository.git"
set :branch, 'master'
set :scm_password, 'yourpassword'
set :user, 'your_user'
set :use_sudo, false
@klebershimabuku
klebershimabuku / correcao.py
Created November 26, 2013 15:15
correção de código em python
a = 5
b = 10
x = a + b
if (b > 10)
print("tudo ok")
@klebershimabuku
klebershimabuku / par100.py
Created November 26, 2013 15:05
dado um número, informa através de uma mensagem se o mesmo é par e se é maior que 100.
n = input("digite um numero: ")
par = (n % 2 == 0)
gt100 = (n > 100)
if par:
print("numero eh par.")
else:
print("numero eh impar.")
if gt100:
@klebershimabuku
klebershimabuku / media.py
Last active December 29, 2015 10:49
dados 6 números, calcular a média e exibir uma mensagem informando que a meta foi atingida caso a media seja maior ou igual a 100.
n1 = input("entre com um numero: ")
n2 = input("entre com um numero: ")
n3 = input("entre com um numero: ")
n4 = input("entre com um numero: ")
n5 = input("entre com um numero: ")
n6 = input("entre com um numero: ")
media = (n1+n2+n3+n4+n5+n6)/6
print("a media foi de: %i" % media)
@klebershimabuku
klebershimabuku / howold.py
Last active December 27, 2015 07:59
playing with python string concatenation
ano_nascimento = input('Digite o seu ano de nascimento:');
ano_atual = input('Digite o ano atual:');
idade = ano_atual - ano_nascimento;
if (idade > 0):
print 'Voce tem %s anos' % idade
else:
print 'Tem certeza que voce ja nasceu.. ?'
@klebershimabuku
klebershimabuku / gist:4338967
Created December 19, 2012 18:15
Importar um dump pelo rails console
RAILS_ENV=<ambiente> rails dbconsole -p < <arquivo.sql>
@klebershimabuku
klebershimabuku / gist:3967349
Created October 28, 2012 03:28
How to configure Gemfile to work with Edge Rails

How to configure Gemfile to work with Edge Rails

You will have to make some changes to your Gemfile to get it working.

Basically what I've changed was:

gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'activerecord-deprecated_finders', git: 'git://github.com/rails/activerecord-deprecated_finders.git'
gem 'journey',   :git => 'git://github.com/rails/journey.git'
@klebershimabuku
klebershimabuku / gist:3967231
Created October 28, 2012 02:34
Example of database.yml for Postgresql
development: &common
adapter: postgresql
database: project_development
username: postgres
password: <your_password>
host: localhost
test:
<<: *common
database: project_test
@klebershimabuku
klebershimabuku / gist:3365879
Created August 16, 2012 02:38
Montain Lion - sh make command not found

Então você resolve atualizar seu Mac para o Montain Lion e de repente se depara com a seguinte mensagem de erro:

$ sh make command not found

Neste momento você provavelmente já possui uma versão do XCode instalado, porém, irá precisar atualizá-lo.

  • Abra a App Store
  • Baixe a atualização do XCode para o Montain Lion, instale.
  • Execute o XCode e vá em Preferências
  • Na aba Downloads e marque a opção para instalar as Ferramentas de linha de comando.
1.9.2p318 :001 > str = "google-com, Awesome-net(Ooops), facebook-com / rocket-yet"
=> "google-com, Awesome-net(Ooops), facebook-com / rocket-yet"
1.9.2p318 :002 > str.match(/(\w+-com)/)
=> #<MatchData "google-com" 1:"google-com">
1.9.2p318 :003 >
1.9.3p125 :001 > str = "google-com, Awesome-net(Ooops), facebook-com / rocket-yet"
=> "google-com, Awesome-net(Ooops), facebook-com / rocket-yet"
1.9.3p125 :002 > str.match(/(\w+-com)/)