Skip to content

Instantly share code, notes, and snippets.

View carrerasrodrigo's full-sized avatar

Rodrigo Nicolas Carreras carrerasrodrigo

View GitHub Profile
@carrerasrodrigo
carrerasrodrigo / keybase.md
Created October 22, 2014 22:37
keybase.md

Keybase proof

I hereby claim:

  • I am carrerasrodrigo on github.
  • I am carrerasrodrigo (https://keybase.io/carrerasrodrigo) on keybase.
  • I have a public key whose fingerprint is 2BA1 FB86 8949 BA7E 3E95 529F 6546 3B9B B602 8499

To claim this, I am signing this object:

@carrerasrodrigo
carrerasrodrigo / cpf.js
Created December 28, 2013 21:14
This functions helps to verify if a CPF (brazilian document) is valid.
function verify_cpf(cpf){
/* This functions helps to verify if a CPF (brazilian document)
it's valid. Returns true if it is, false otherwise */
cpf = cpf.replace(/\./g, "").replace(/\-/g, "");
if (cpf.length != 11){
return false;
}
var tt = 0, d =0;
for (var t=9; t>=9 && t<11; t++){
@carrerasrodrigo
carrerasrodrigo / cpf.py
Created December 28, 2013 21:11
This snippet includes two method that helps you working with CPF (brazilian documents).
import random
def generate_cpf():
"""Generates a random, valid CPF (brazilian document)
Reference: http://www.geradorcpf.com/algoritmo_do_cpf.htm
"""
cpf = [random.randint(1, 9) for i in range(9)]
weight = range(10, 1, -1)
weight2 = range(11, 1, -1)
tmp = [0, 0, 0, 0, 0, 0, 0, 0, 0]