Skip to content

Instantly share code, notes, and snippets.

View cauethenorio's full-sized avatar
🎯
Focusing

Cauê Thenório cauethenorio

🎯
Focusing
View GitHub Profile
@cauethenorio
cauethenorio / dni_peru.py
Created March 25, 2015 01:50
estudo validação DNI peruano
def dni_validator_1(dni):
multiplos = '32765432'
numbers = list('67890112345')
letters = list('KABCDEFGHIJ')
dni = list(dni)
control = dni.pop()
suma = sum(int(char) * int(mul) for mul, char in zip(multiplos, dni))
@cauethenorio
cauethenorio / angular-request-fake-latency.js
Last active August 29, 2015 14:11
Angular app configuration to add 1s fake latency to xhr json requests
app.config(function ($httpProvider) {
$httpProvider.interceptors.push(
function ($q, $timeout) {
return {
'response': function (response) {
var deferred = $q.defer();
if (response.headers('content-type') == 'application/json')
$timeout(function() {deferred.resolve(response);}, 1000);
else
@cauethenorio
cauethenorio / save-n-restore-files-mtime.py
Created December 13, 2014 22:25
save and restore mtime from all files in a dir
#! /usr/bin/env python
# coding: utf-8
import hashlib
from os import listdir, path, utime
import time
import pickle
import sys
@cauethenorio
cauethenorio / free-folha.js
Created October 13, 2014 19:46
Desbloqueador de matérias da folha
javascript:$("> span",$("body").attr("style","")).remove();for(var m=setTimeout(function(){},0),i=0;m>i;i++)clearTimeout(i);
# coding: utf8
import bdb
import sys
# borrowed from: https://gist.github.com/rctay/3169104
def info(type, value, tb):
if (hasattr(sys, 'ps1')
or not sys.stdin.isatty()
@cauethenorio
cauethenorio / i18n_routing.py
Created February 13, 2013 20:56
Django snippet to make Django do not create URL language prefix for the main language (settings.LANGUAGE_CODE) Usage info in snippet docstring.
# coding: utf-8
"""
Cauê Thenório - cauelt(at)gmail.com
This snippet makes Django do not create URL languages prefix (i.e. /en/)
for the default language (settings.LANGUAGE_CODE).
It also provides a middleware that activates the language based only on the URL.
This middleware ignores user session data, cookie and 'Accept-Language' HTTP header.