Skip to content

Instantly share code, notes, and snippets.

View viniciussbs's full-sized avatar

Vinícius Sales viniciussbs

  • Rio de Janeiro, Brasil
View GitHub Profile
# Returns a copy of self with all +true+ elements removed.
# [ "a", true, "b", true, "c", true].compact_true #=> [ "a", "b", "c" ]
#
def compact_true
remove_elements(TrueClass)
end
# Returns a copy of self with all +false+ elements removed.
# [ "a", false, "b", false, "c", false].compact_true #=> ["a","b","c" ]
#
#!/usr/bin/env ruby
git_dir = '/home/i0n/git'
# git_dir = '/Users/i0n/sites/bin/'
app_name = ARGV
Dir.chdir git_dir
Dir.mkdir "#{app_name}.git"
Dir.chdir "#{git_dir}/#{app_name}.git"
system "git init --bare"
puts "SUCCESS!"
~ % ruby -v
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10]
~ % rvm list
rvm rubies
ruby-1.9.2-p0 [ x86_64 ]
~ % rvm use 1.9.2@rails2
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@tapajos
tapajos / gist:1811460
Created February 12, 2012 23:05
Migrando do Heroku para a Amazon Web Services

Migrando do Heroku para a Amazon Web Services

Recentemente eu comentei sobre a migração que fizemos no [Myfinance][mf] saindo do [Heroku][h] e indo para a [Amazon Web Services][a] e diversas pessoas me perguntaram as razões pela qual fizemos essa mudança. O objetivo desse post é apenas explicar a decisão que a nossa equipe tomou, como foi e as conseguências dessa migração.

Antes de começar eu gostaria de deixar claro que o objetivo desse texto não é comparar hospedagens e nem dizer que uma é melhor do que a outra. Trata-se apenas do relato de uma experiência.

A motivação

Antes de explicar a motivação por trás da migração é interessante mostrar como era a nossa estrutura.

@cgallagher
cgallagher / milestone.rb
Created June 13, 2012 10:28
Active Admin Image Upload Form
ActiveAdmin.register Milestone do
scope :all, :default => true
scope :global
scope :user_specific
index do
column :title
column :description
column :required_litres
column :is_active
@viniciussbs
viniciussbs / dev.conf
Created November 5, 2012 20:21 — forked from fnando/dev.conf
Nginx configuration for SSH tunnel
upstream tunnel {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name dev.codeplane.com br.dev.codeplane.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
@vagnerzampieri
vagnerzampieri / .bash_aliases
Last active October 25, 2017 20:18
Alias público, se tiver coisas interessantes, contribua.
function mkcd(){
mkdir $1;
cd $1;
}
# Apt
alias apti='sudo apt-get install'
alias apts='sudo apt-cache search'
alias aptp='sudo apt-get --purge remove'
alias aptr='sudo apt-get remove'
@brandur
brandur / twitter-auth.md
Last active February 13, 2020 22:13
Twitter auth

Easy Twitter API OAuth 2 Access

  1. Go to your applications. Create a new one, and find the values in the Consumer Key and Consumer Secret fields.

  2. Use OAuth client information to produce an OAuth 2 access token:

    curl -i --user <consumer_key>:<consumer_secret> -X POST https://api.twitter.com/oauth2/token -d "grant_type=client_credentials"
    
    {"access_token":"<oauth2_token>","token_type":"bearer"}% 
    
@brandur
brandur / heroku-api-stub.md
Last active December 20, 2015 22:09
Engineering API-driven Applications Using Service Stubs

Engineering API-driven Applications Using Service Stubs

Developing applications against foreign services like the Heroku Platform API can unlock a powerful set of otherwise unavailable features, but can come with drawbacks: development must occur online, valid credentials are required, calls your code makes will reveal and manipulate real data, and API calls in tests have to stubbed out individually.

This article will offer a short overview on how these pain points can be