Skip to content

Instantly share code, notes, and snippets.

View santagada's full-sized avatar

Leonardo Santagada santagada

  • Guerrilla Games
  • Amsterdam
View GitHub Profile
(function(){return 2*3;}).toString() === (function(){return 6;}).toString(); // true in FF & Opera, false in IE & WebKit, because Opera don't put the actual code of the function on the string and FF optimizes the source to be the same.
@santagada
santagada / convert_with_sync.sh
Created December 15, 2010 21:48
convert a google code svn repository but first svnsync it, so you can try the conversion again and easily convert the wiki later. It is way faster too.
#!/bin/sh
set -u
set -e
svnadmin create svn-mirror
echo "#!/bin/sh" > svn-mirror/hooks/pre-revprop-change
echo "exit 0" >> svn-mirror/hooks/pre-revprop-change
chmod +x svn-mirror/hooks/pre-revprop-change
svnsync init file://`pwd`/svn-mirror http://$1.googlecode.com/svn
svnsync sync file://`pwd`/svn-mirror
hg convert file://`pwd`/svn-mirror hg-mirror
BZR_SRC_LOC = "lp:openobject-server/6.1 server\n\
lp:trunk addons-pr\n\
lp:localiz/6.1 localization\n\
lp:openobject-addons/6.1 addons\n\
lp:openobject-addons/extra-trunk addons-extra\n\
lp:openerp-web/6.1 web\n"
BZR_SRC_DIRS = $(shell echo -e $(BZR_SRC_LOC)|cut -d " " -f 3)
@santagada
santagada / gist:3080729
Created July 10, 2012 03:11
função de digito verificador
from itertools import cycle
class A(object):
def nfe_digito_verificador(self, key):
numeros = reversed(map(int, key))
soma = sum(n * m for n, m in zip(numeros, cycle(range(2,10))))
resto = soma % 11
if resto < 2:
def gerar_linha(self):
linha = u'%s|%s|\r\n' % (self.reg, self.ind_mov)
return linha + super(RegistroF001, self).gerar_linha()
Traceback (most recent call last):
File "verificador.py", line 74, in <module>
main()
File "verificador.py", line 68, in main
pool.join()
File "/home/santagada/.virtualenvs/x/local/lib/python2.7/site-packages/gevent/pool.py", line 103, in join
self._empty_event.wait(timeout=timeout)
File "/home/santagada/.virtualenvs/x/local/lib/python2.7/site-packages/gevent/event.py", line 74, in wait
result = get_hub().switch()
File "/home/santagada/.virtualenvs/x/local/lib/python2.7/site-packages/gevent/hub.py", line 164, in switch
@santagada
santagada / gist:5151807
Last active December 14, 2015 21:29 — forked from MrcFoz/gist:5131756
# -*- coding: utf-8 -*-
def sorteio():
"""
Cria a lista com os resultados oficiais publicados pela Caixa.
"""
sorteados = []
while len(sorteados) < 6:
numero = int(input("Digite o número: "))
if numero > 0 and numero <= 60:
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
#!/usr/bin/env python
# _*_ encoding: latin-1
import random
#tipo de verbos
TD='TD'
TI='TI'
TDI='TDI'
NEG = 'NEG'
app.directive('checkbox', function(){
return {
restrict: 'E',
require: 'ngModel',
scope: {
options: '=',
checked: '=ngModel',
label: '=label'
},
/*jshint multistr: true */