Skip to content

Instantly share code, notes, and snippets.

View javierg's full-sized avatar

Javier Guerra javierg

View GitHub Profile

Chapter 2

Hours in a year (assuming is not a leap year)

hours_per_year = 365*24
puts hours_per_year

Minutes in a decade

minutes_per_decade = hours_per_year1060

#!/bin/bash
##
## .git/hooks/post-merge
##
## Runs all special post-merge hooks
##
this_dir="$(dirname "$(test -L "$0" && readlink "$0" || echo "$0")")"
"$this_dir/require_signoff"
@javierg
javierg / commit-msg
Created September 26, 2011 18:50 — forked from remi/commit-msg
Git commit message spell check hook (kind of a proof of concept, but still usable)
#!/usr/bin/env ruby
# 1. Install hunspell
# $ brew install hunspell
# 2. Download a dictionary and install it in a path listed by `hunspell -D`
# $ open http://wiki.services.openoffice.org/wiki/Dictionaries
# 3. Move this file into your repository
# $ mv commit-msg /path/to/repo/.git/hooks
@javierg
javierg / _logo.haml.html
Created November 9, 2011 00:47
rotating cube
.logo_container
#cube.default
.figure.front
.figure.back
.figure.right
.figure.left
.figure.top
.figure.bottom
@javierg
javierg / fines-comunidad-ruby-tijuana.md
Created April 17, 2012 17:58
fines-comunidad-ruby-tijuana
  1. Sin fines de lucro
  2. Moderación abierta. Administrador sólo quita el spam
  3. Compartir código bajo una cuenta de organización de Github
  4. El grupo es una democracia
  5. Cuando la democracia no es suficiente (empate etc), entra la meritocracia
  6. Comete errores (quien no los comete no aprende)
  7. Pide ayuda
  8. Diviértete, quien no disfruta lo que hace, lo hace mal...
@javierg
javierg / current-rules
Created May 21, 2012 20:51 — forked from EnriqueVidal/current-rules
rubytij.org config
# Generated by iptables-save v1.4.10 on Sun Apr 22 03:00:29 2012
*filter
:INPUT DROP [59:1664]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [49:5928]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 11 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 4 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 3 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
@javierg
javierg / gist:4708386
Created February 4, 2013 18:06
my.cnf.tmpl
[mysqld_safe]
socket = /tmp/mysql.sock
[server]
character_set_server=utf8
collation_server=utf8_unicode_ci
skip_character_set_client_handshake
default_table_type=innodb
transaction-isolation=READ-COMMITTED
@javierg
javierg / gist:4741870
Last active December 12, 2015 08:08
Fortuna por moneda stateless
class FortuneTellerMachine
def initialize
@coins = 0
end
def start
puts "Hola ¿Quiéres saber tu fortuna?"
@coins += 1
if @coins == 1
puts "necesito otra moneda, yo quiero moneda."
@javierg
javierg / gist:4742784
Created February 8, 2013 23:21
Fortune Teller Machine
class FortuneTellerMachine
WELCOME = "Hola ¿Quiéres saber tu fortuna?"
REQUEST = "Fortuna por monedas, yo quiero yo quiero monedas (2): "
CHANGE_BACK = "Here is your change"
COST = 2
def initialize
clear
end
@javierg
javierg / all_view.erl
Created December 7, 2013 16:01
This is an Erlang couchdb view for getting all the documents that meet the "namespace/id" criteria, emiting the namespace as document type.
% Document design: {"_id": "namespace/edf42", ...}
fun({Doc}) ->
Id = proplists:get_value(<<"_id">>, Doc, null),
NameSpace = binary:bin_to_list(Id),
case re:split(NameSpace, "[/]") of
[_] -> null;
[Type, BaseId] -> Emit(Type, BaseId)
end
end.