Skip to content

Instantly share code, notes, and snippets.

View leobessa's full-sized avatar

Leonardo Bessa leobessa

View GitHub Profile
@jbenet
jbenet / simple-git-branching-model.md
Last active April 17, 2025 09:30
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@maxim
maxim / rails_load_path_tips.md
Last active January 9, 2025 00:59
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

public void testKafka() throws Exception {
Properties props = new Properties();
props.put("zk.connect", "zookeeper.cloudfront.io:2181");
props.put("zk.sessiontimeout.ms", "300000");
props.put("serializer.class", "kafka.serializer.DefaultEncoder");
props.put("key.serializer.class", "kafka.serializer.StringEncoder");
props.put("compression.codec", "1"); // gzip
props.put("producer.type", "async");
props.put("batch.size", "248");
props.put("queue.enqueueTimeout.ms", "-1");
# ledger v3.0 fish completions
# Tim Gray - 2013-05-22
# vim: set ft=fish norl ts=2 sw=2 sts=2 :
# check to see if we have an empty 'ledger' command.
function __fish_ledger_bare
set cmd (commandline -opc)
if [ (count $cmd) -eq 1 -a $cmd[1] = 'ledger' ]
return 0
end
@gr2m
gr2m / account_dreamcode.js
Last active May 7, 2022 08:22
Imagine the typical backend tasks for user authentication would exist right in the browser. How would the code look like? This is what I came up with. Forks & comments much appreciated! #nobackend #dreamcode
// sign up
account.signUp('[email protected]', 'secret');
// sign in
account.signIn('[email protected]', 'secret');
// sign in via oauth
account.signInWith('twitter');
// sign out
@itaifrenkel
itaifrenkel / DefaultEventHandlerMonitorAspect.java
Created April 20, 2013 21:01
Hack to monitor Kafka 0.8 producers
import kafka.producer.KeyedMessage;
import kafka.producer.async.DefaultEventHandler;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import scala.collection.JavaConversions;
import scala.collection.Seq;
#download http://www.maxmind.com/app/geolitecountry - GeoIPCountryCSV.zip
#download http://www.maxmind.com/app/geolitecity - GeoLiteCity_20120207.zip
#download http://www.maxmind.com/app/asnum - GeoIPASNum2.zip
tail +3 GeoLiteCity-Location.csv >/tmp/location.csv
tail +3 GeoLiteCity-Blocks.csv >/tmp/blocks.csv
sed 's/^\("[^"]*","[^"]*",\)"[^"]*","[^"]*",\("[^"]*","[^"]*"\)/\1\2/' GeoIPCountryWhois.csv >/tmp/countries.csv
curl https://raw.github.com/tvondra/geoip/master/sql/geoip--0.1.0.sql | psql yourdatabase
@kenn
kenn / gist:5105175
Last active December 11, 2024 19:08
Unicorn memory usage improvement with Ruby 2.0.0

Unicorn memory usage improvement with Ruby 2.0.0

Here's a preliminary experiment to see how much memory is saved with the new copy-on-write friendly (bitmap marking) GC.

Calculated by memstats.rb https://gist.github.com/kenn/5105061 on Debian x86_64.

Master process:

# ./memstats.rb 20547
@nathany
nathany / config.ru
Last active May 3, 2019 17:10
Magical Unicorn Configuration for Heroku
# add something like this to config.ru
# see https://github.com/kzk/unicorn-worker-killer
if Integer(ENV['UNICORN_KILLER'] || 0) != 0
require 'unicorn/worker_killer'
# Max memory size (RSS) per worker
use Unicorn::WorkerKiller::Oom, (350*(1024**2)), (400*(1024**2)), 30, true
end
@xxuejie
xxuejie / geometries.js
Last active March 17, 2020 13:50
Webruby code vs JavaScript code, both use three.js
// The original JS code for WebGL geometries example in three.js repository
// I only changed the order of the functions for better comparison
// with the Ruby version.
// You can still find the original version inline at http://mrdoob.github.com/three.js/examples/webgl_geometries.html
var container, stats;
var camera, scene, renderer;
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();