Skip to content

Instantly share code, notes, and snippets.

View alexeiramone's full-sized avatar

Alexei Martchenko alexeiramone

View GitHub Profile
@alexeiramone
alexeiramone / config.json
Last active August 29, 2015 14:06 — forked from anonymous/config.json
Setup inicial do Bootstrap 3 experimental com 18 colunas
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 46.7%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#428bca",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
# Orignal version taken from http://www.djangosnippets.org/snippets/186/
# Original author: udfalkso
# Modified by: Shwagroo Team and Gun.io
import sys
import os
import re
import hotshot, hotshot.stats
import tempfile
import StringIO
def cpf_valid(cpf, d1=0, d2=0, i=0):
try:
while i < 10:
d1, d2, i = (d1 + (int(cpf[i]) * (11-i-1))) % 11 if i < 9 else d1, (d2 + (int(cpf[i]) * (11-i))) % 11, i + 1
return (int(cpf[9]) == (11 - d1 if d1 > 1 else 0)) and (int(cpf[10]) == (11 - d2 if d2 > 1 else 0))
except:
return False
@alexeiramone
alexeiramone / postgres_id_default.sql
Created April 16, 2013 18:51
Postgresql id serial sequence default value restoration
ALTER TABLE {tablename} ALTER COLUMN id SET DEFAULT nextval('{tablename}_id_seq'::regclass);
-- replace {tablename} with the curly braces with the table name
-- the sequence name is generally in the form of {tablename}_id_seq but it can be anything, check in pgadmin its name
-- some softwares accidentaly delete this while doing some table operations