Skip to content

Instantly share code, notes, and snippets.

View tscolari's full-sized avatar

Tiago Scolari tscolari

View GitHub Profile
@tscolari
tscolari / hyperkube
Last active August 29, 2015 14:20
kubernetes 0.16.0
binaries
@tscolari
tscolari / shared_examples_default_crud_routing.rb
Created May 6, 2011 00:00
This is a set of tests for default CRUD routing in rails. Also works with namespaces.
shared_examples_for "default crud routing" do
let(:random_id_for_routing) {rand(2000)}
let(:controller_name) {described_class.to_s.underscore.gsub(/_controller/, '')}
it "should route to index action" do
{:get => "/#{controller_name}"}.should route_to(
:controller => controller_name,
:action => 'index'
)
@tscolari
tscolari / Gemfile
Created August 15, 2012 21:20
Octopress S3 Deploy Method
# ....
gem 'aws-s3'
# ....
@tscolari
tscolari / s3_upload_files.rb
Created August 16, 2012 19:05
S3 multiple file uploader
#!/usr/bin/env ruby
require 'rubygems'
require 'aws/s3'
## USAGE
#
# If you use a directory as parameter, every file inside it will be uploaded.
# ex: ./s3_upload_files /system/backups/
# If you use a text file as parameter, it should have one file name per line, all files listed will be uploaded.
# ex: ./s3_upload_files changeset
@tscolari
tscolari / factories_spec.rb
Last active October 9, 2015 06:18
Spec for all factories
require 'spec_helper'
describe FactoryGirl do
FactoryGirl.factories.each do |factory|
context "with factory for :#{factory.name}" do
subject {FactoryGirl.build(factory.name)}
it "is valid" do
subject.valid?.should be, subject.errors.full_messages.join(',')
end
@tscolari
tscolari / vim.rb
Created September 26, 2012 16:45 — forked from bmatheny/vim.rb
Vim Formula with Ruby & Python support for OS X
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
version '7.3.666'
url 'https://vim.googlecode.com/hg/', :revision => '1e22adc6176e'
head 'https://vim.googlecode.com/hg/'
def ruby_bin
@tscolari
tscolari / kd_tree.rb
Created December 14, 2012 20:15
Simple KDTree implementation to find the nearest point to another
# Simple KDTree class with sorting for finding nearest neighbor
#
class KDTree
class Node < Struct.new(:value, :left, :right)
# Public: Returns the distance of the object to the
# point
#
def distance_to(point)
throw "Points have different dimensions" if point.size != value.size
square_sum = 0
@tscolari
tscolari / rcodetools.vim
Last active December 19, 2015 19:39
rcodetools.vim to use with vundles source: https://github.com/tnoda/rcodetools
" Copyright (C) 2006 Mauricio Fernandez <mfp@acm.org>
" rcodetools support plugin
"
if exists("loaded_rcodetools")
finish
endif
let loaded_rcodetools = 1
let s:save_cpo = &cpo
@tscolari
tscolari / aaa-prepare-commit.md
Last active December 20, 2015 05:38
Commit with story id
  • add prepare-commit-msg it to ./.git/hooks/
  • Make it executable (chmod +x filename)

It should prepend [#STORY_ID] into your commit message when the editor pops up. Your branch must be in this format to work: branch-description-blabla-STORY_ID

it skips the prepaend if:

  • The branch doesn't end in a story id (integer)
  • The original commit message starts with "Merge"
@tscolari
tscolari / aa.md
Created July 26, 2013 09:07
Work in progress
  • Avoids files with debugger/binding.pry to be commited
  • Avoids files with spaces in the end of the line to be commited

Instalation

  • Copy the file to .git/hooks/pre-commit
  • Make it executable chmod + x .git/hooks/pre-commit
  • Have fun