Skip to content

Instantly share code, notes, and snippets.

Scala:
( _.bla() )
Groovy:
{ it.bla() }
class ArcoIris
include Enumerable
def each()
yield "vermelho"
yield "laranja"
yield "amarelo"
yield "verde"
yield "azul"
yield "aniz"
Lean Software Development: An Agile Toolkit by Mary Poppendieck
http://www.amazon.com/gp/product/0321150783/
Agile Estimating and Planning by Mike Cohn
http://www.amazon.com/gp/product/0131479415/
Programming in Scala: A Comprehensive Step-by-step Guide by Martin Odersky
http://www.amazon.com/gp/product/0981531601/
module ActiveRecord
class Base
def self.meu_named_scope_comum(*args)
named_scope(com_os_argumentos_que_precisar)
end
end
end
# aí nos models que precisar usar isso...
class Nando:
def __ass__(dick):
print dick
@fabiokung
fabiokung / insert_utf-8_encoding_line.sh
Created June 26, 2010 23:49
shell one-liner to include encoding annotations in all ruby files
grep -F "# -*- coding: UTF-8 -*-" -L app/**/*.rb | while read file; do sed -e '1i\
# -*- coding: UTF-8 -*-\n' -i '' $file; done
Memory access offset=0 size=9 is out of bounds
.../gems/ffi-0.6.3/lib/ffi/memorypointer.rb:34:in `put_string'
function t3hClosure() {
var globalVariablesSux = "non global";
return function() {
alert(globalVariablesSux);
}
}
closure = t3hClosure();
@fabiokung
fabiokung / fork.rb
Created October 27, 2010 18:01
fork and copy on write behavior
n = 10
fork do
n = 20
puts n #=> 20
end
fork do
n = 30
puts n #=> 30
@fabiokung
fabiokung / HashMap.java
Created March 26, 2011 21:32
snippet of HashMap's default implementation, from Sun's JVM (Mac OSX build 1.6.0_24-b07-334-10M3326)
/**
* Applies a supplemental hash function to a given hashCode, which
* defends against poor quality hash functions. This is critical
* because HashMap uses power-of-two length hash tables, that
* otherwise encounter collisions for hashCodes that do not differ
* in lower bits. Note: Null keys always map to hash 0, thus index 0.
*/
static int hash(int h) {
// This function ensures that hashCodes that differ only by
// constant multiples at each bit position have a bounded