Skip to content

Instantly share code, notes, and snippets.

View alexandre's full-sized avatar
🎯
Focusing

Alexandre Souza alexandre

🎯
Focusing
View GitHub Profile
@alexandre
alexandre / garoa_shield.ino
Created May 30, 2015 23:54
Uma tentativa de criar interfaces "didáticas" para o GaroaShield.
//SENSORES
potenciometro = A0
sensor_de_luz = A1
//LEDs do display de 7 segmentos
//superior esquerda
int superior_esquerda = 13;
// superior base(teto)

Keybase proof

I hereby claim:

  • I am alexandre on github.
  • I am ubbersith (https://keybase.io/ubbersith) on keybase.
  • I have a public key whose fingerprint is 126A A78E DB9F FA73 9154 7C53 2B77 21EE 04D9 7D87

To claim this, I am signing this object:

@alexandre
alexandre / doctest_example.py
Created March 13, 2015 18:12
An example of python doctest
def factorial(number):
"""Return the factorial of the parameter 'number'
:number: an int object.
:returns: an int object.
>>> factorial(5)
120
"""
return ((number <= 1 and 1) or number * factorial(number - 1))
@alexandre
alexandre / update_listfield.md
Last active August 29, 2015 14:16
Atualizar um atributo ListField(ReferenceField) no Mongoengine.
from app import db  # db == MongoEngine(app)


class Day(db.Document):
    week_day = db.IntField()
    # another attribute
    # ...
@alexandre
alexandre / lambda_or_repeat.py
Last active August 29, 2015 14:16
a way to substitute a lambda in a map
#!/usr/bin/python3
import itertools
def gen_string(num, foo):
return '{} - {}'.format(num, foo)
def list_number_and_foo_sp(): #sp == situation problem
foo = 'Something'
@alexandre
alexandre / bool_or_range.py
Created March 10, 2015 23:06
boolean or range?
>>> import dis
>>>
>>> def foo_with_bool(foo): return foo < 1 or foo > 12
...
>>> def foo_with_range(foo): return foo in range(1,13)
...
>>> dis.dis(foo_with_bool)
1 0 LOAD_FAST 0 (foo)
3 LOAD_CONST 1 (1)
6 COMPARE_OP 0 (<)
@alexandre
alexandre / foo.py
Created March 10, 2015 20:29
Tentando usar Python para criar um pseudo código sobre simétrico, assimétrico, transitivo e conexo
"""
Lendo o livro Introdução a filosofia matemática...no capitulo que fala sobre a definição de ordem...
"""
def sim_assim_trans_con(x, y, z=None, A=[]):
"""Exemplo de um pseudo código com um exemplo para
difenciar elementos simétricos, assimétricos, transitivos e conexos.
Serve como exemplo de como substituir if/else por avaliação de expressões
booleanas.
@alexandre
alexandre / haskell-beginners
Created March 10, 2015 02:36
haskell-beginners
Hi guys/girls
<ubbersith> I'm trying to repeat a python test with Haskell...can someone help me? https://gist.github.com/alexandre/442ec9dc189e222d3aae
<ubbersith> I didn't understand why the interpreter don't just evaluates the first acess (it is trying evaluate everything?)
<bitemyapp> ubbersith: you created an infinite list.
* firebird1 ([email protected]) has joined #haskell-beginners
<bitemyapp> ubbersith: actually, cyclic reference, sorry.
<bitemyapp> > take 10 $ cycle [1, 2]
<lambdabot> [1,2,1,2,1,2,1,2,1,2]
<ubbersith> ok, but my bool test (==) should works, shouldn't?
<bitemyapp> no.
@alexandre
alexandre / recur.md
Created March 10, 2015 02:08
tests with Python and Haskell...
>>>x = [1, 2]
>>> x.append(x)
>>> x[2][2][2][2] ==x
True
let x = [1, 2]
let x = x ++ x
x !! 2 == x
@alexandre
alexandre / recursao.clj
Last active August 29, 2015 14:16
testando recursão e avaliação preguiçosa...se é que eu entendi...
(comment
Tentando onseguir o mesmo resultado em clojure:
#Python3
>>> x = [1, 2, 3]
>>> x.append(x)
>>> x[3][3][3] == x
True
)
user=> (def x (list 1 2 3))
#'user/x