Skip to content

Instantly share code, notes, and snippets.

View mauricio's full-sized avatar

Maurício Linhares mauricio

View GitHub Profile
class SampleFormBuilder < ActionView::Helpers::FormBuilder
attr_accessor :object_class
helpers = field_helpers +
%w{date_select datetime_select time_select} +
%w{collection_select select country_select time_zone_select} -
%w{hidden_field label fields_for submit} # Don't decorate these
helpers.each do |name|
@mauricio
mauricio / gist:152039
Created July 22, 2009 15:12
Email do Eliziário sobre o mercado de ti
=== Email do Marcos Eliziário sobre o mercado de TI ===
Os clientes são grandes responsáveis pelo que as consultorias fazem
e como elas fazem. O modelo de negócios atual é assim, porque é o
que vende. O que importa são resultados de curto prazo, essa é a
mentalidade atual.
Foda-se se o projeto é impossível de manter. Depois que ele estiver
no ar, o cara que contratou a bosta já vai ter sido promovido,
e ainda vai se dar bem nas costas do pobre coitado que tiver a
EMAIL_VALIDATION_REGEX = begin
qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'
dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'
atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' +
'\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'
quoted_pair = '\\x5c[\\x00-\\x7f]'
domain_literal = "\\x5b(?:#{dtext}|#{quoted_pair})*\\x5d"
quoted_string = "\\x22(?:#{qtext}|#{quoted_pair})*\\x22"
domain_ref = atom
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="tutorial_hibernate"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.wordpress.alinhavado.Pessoa</class>
<exclude-unlisted-classes />
ActiveRecord::AttributeMethods.class_eval do #:nodoc:
def method_missing(method_id, *args, &block)
method_name = method_id.to_s
if self.class.private_method_defined?(method_name)
raise NoMethodError.new("Attempt to call private method", method_name, args)
end
# If we haven't generated any methods yet, generate them, then
# as we’re going to use Unicorn as the application server
# we’re not going to use common sockets
# but Unix sockets for faster communication
upstream shop {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
# for UNIX domain socket setups:
server unix:/tmp/shop.socket fail_timeout=0;
@mauricio
mauricio / .gemrc
Created September 21, 2010 02:20
---
:verbose: true
:bulk_threshold: 1000
install: --no-ri --no-rdoc --env-shebang
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
:benchmark: false
:backtrace: false
@mauricio
mauricio / books-to-buy.txt
Created November 29, 2010 01:28
List of nice books to have.
Rocket Surgery Made Simple - http://www.amazon.com/Rocket-Surgery-Made-Easy--Yourself/dp/0321657292/ref=sr_1_2?ie=UTF8&qid=1290993870&sr=8-2
Seven Languages in Seven Weeks - http://www.amazon.com/gp/product/193435659X/ref=ord_cart_shr?ie=UTF8&m=ATVPDKIKX0DER
The Pragmatic Programmer - http://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X/ref=sr_1_1?s=books&ie=UTF8&qid=1290993962&sr=1-1
Clean Code - http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882/ref=pd_sim_b_2
Even Faster Websites - http://www.amazon.com/Even-Faster-Web-Sites-Performance/dp/0596522304/ref=sr_1_1?ie=UTF8&s=books&qid=1290994010&sr=1-1
Restful Web Services - http://www.amazon.com/Restful-Web-Services-Leonard-Richardson/dp/0596529260/ref=sr_1_1?s=books&ie=UTF8&qid=1290994033&sr=1-1
Programming Collective Intelligence - http://www.amazon.com/Programming-Collective-Intelligence-Building-Applications/dp/0596529325/ref=sr_1_1?s=books&ie=UTF8&qid=1290994085&sr=1-1
int method( int a, int b, int c ) {
int result = a;
if ( a + b > c ) {
result = a + b;
}
return result;
}