Skip to content

Instantly share code, notes, and snippets.

View abner's full-sized avatar

Ábner Silva de Oliveira abner

View GitHub Profile
@abner
abner / zsh_and_tmux.md
Last active August 29, 2015 13:57 — forked from tsabat/zsh.md
@abner
abner / active_resource_base.rb
Created January 22, 2014 19:45
Making ActiveResource Thread-Safe
# Monkeypatch to turn site, username and passwornd setters in activeresource:base thread safe
# pairwise settings will be environment base, so different environments would have
# different settings. In this case, to avoid racing conditions this monkey patch
# is provided
class ActiveResource::Base
# store the attribute value in a thread local variable
class << self
%w(site user password).each do |attr|
define_method(attr) do
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@abner
abner / .gitignore
Created October 21, 2013 21:52
.gitignore para projetos java/eclipse
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
@abner
abner / docker-postgresql.md
Created June 27, 2013 00:03 — forked from zaiste/docker-postgresql.md
Gist para container dock Postgresql

Docker PostgreSQL How-To

How to use [zaiste/postgresql][1] Docker container.

docker pull zaiste/postgresql
CONTAINER=$(docker run -d -p 5432 \
@abner
abner / .gitignore
Last active December 16, 2015 20:28 — forked from uu59/.gitignore
Rack + Sinatra + NodeJS + Socket.IO Solution
vendor/
.bundle/
node_modules/
Gemfile.lock
@abner
abner / controllers.coffee
Last active December 16, 2015 02:19 — forked from jrmoran/controllers.coffee
Exemplos de testes unitários e funcionais para angular, em CoffeeScript
# = require '../components/jquery/jquery'
# = require '../components/angular-complete/angular'
Controllers = angular.module 'controllers', []
Controllers.controller 'PhoneListCtrl', ['$scope', ($scope)->
$scope.phones = [
{name: "Nexus S", snippet: "Fast just got faster with Nexus S."},
file_cache_path "/home/vagrant/chef-solo"
cookbook_path "/home/vagrant/chef-solo/cookbooks"
json_attribs "/home/vagrant/chef-solo/node.json"
@abner
abner / concurrent.rb
Created April 20, 2012 20:50 — forked from nicksieger/concurrent.rb
JRuby code examples from RailsConf 2011
require 'java'
java_import java.util.concurrent.Executors
@count = java.util.concurrent.atomic.AtomicInteger.new
def send_email(executor)
executor.submit do
puts "email #{@count.incrementAndGet} sent"
end
end
@abner
abner / minitest_spec_expectations.md
Created March 24, 2012 00:34 — forked from ordinaryzelig/minitest_spec_expectations.md
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations