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 / code.rb
Created September 20, 2011 22:21 — forked from caius/code.rb
require "uri"
(URI::REGEXP.constants - ["PATTERN"]).each do |rc|
puts "#{rc}: #{URI::REGEXP.const_get(rc)}"
end
URI::REGEXP::PATTERN.constants.each do |pc|
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}"
end
@abner
abner / attr_acessible_security.rb
Created March 5, 2012 20:37 — forked from rafaelp/attr_acessible_security.rb
How to protect against mass assignment attack
# Put this file on config/initializer
# This will create an empty whitelist of attributes available for mass assignment for
# all models in your app. As such, your models will need to explicitly whitelist
# accessible parameters by using an attr_accessible declaration. This technique is best
# applied at the start of a new project. However, for an existing project with a thorough
# set of functional tests, it should be straightforward and relatively quick to insert this
# initializer, run your tests, and expose each attribute (via attr_accessible) as dictated
# by your failing tests.
@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
@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
file_cache_path "/home/vagrant/chef-solo"
cookbook_path "/home/vagrant/chef-solo/cookbooks"
json_attribs "/home/vagrant/chef-solo/node.json"
@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."},
@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 / 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
Created October 21, 2013 21:52
.gitignore para projetos java/eclipse
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
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