Skip to content

Instantly share code, notes, and snippets.

View andersonfreitas's full-sized avatar

Anderson Freitas andersonfreitas

View GitHub Profile
/* Put your CSS here */
html, body {
margin: 20px;
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andersonfreitas
andersonfreitas / .gitignore
Last active August 29, 2015 14:01 — forked from wrobstory/.gitignore
Up and Down the Python Data and Web Visualization Stack
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

@Entity
@FilterDef( name="tenantFilter", parameters=@ParamDef( name="tenantId", type="string" ) )
@Filters(
@Filter( name="tenantFilter", condition="tenant_id = :tenantId" )
)
@Filter( name="tenantFilter", condition="tenant_id = :tenantId" )
)
public class Customer {
@Id
private Long id;
#!/usr/bin/ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
file = open(ARGV[1]) if ARGV[1]
file ||= STDIN
doc = Hpricot(file)
puts doc / ARGV[0]
@andersonfreitas
andersonfreitas / gist:1073841
Created July 9, 2011 18:51 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@andersonfreitas
andersonfreitas / .irbrc
Created July 22, 2011 01:29 — forked from gerred/.irbrc
My .irbrc file
if defined?(::Bundler)
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
$LOAD_PATH << gem_path
end
end
end