Skip to content

Instantly share code, notes, and snippets.

View alvesjnr's full-sized avatar

Antonio Ribeiro Alves alvesjnr

View GitHub Profile
@alvesjnr
alvesjnr / GEB.md
Created November 28, 2011 16:49
Gödel, Escher, Bach

Lecture about the book Gödel Escher Bach

This is a short resume about what I understood about the masterpiece GEB, from Douglas Hofstadter

What is this book about?

"How do we get I's from None I's?"

@alvesjnr
alvesjnr / sqlalchemy.py
Created June 2, 2011 22:32
First example using sqlalchemy
import sqlalchemy
engine = sqlalchemy.create_engine('sqlite:///:memory:', echo=False)
from sqlalchemy.ext.declarative import declarative_base
from Crypto.Hash import SHA256
from sqlalchemy.orm import relationship, backref
Base = declarative_base()
class User(Base):
@alvesjnr
alvesjnr / a_text.rst
Last active November 10, 2023 01:14
I got trapped by a lambda function.

I got trapped by a lambda function

I consider myself a medium-to-experienced Python programmer (I am using python for 6 years). Today I've lost almos one hour in a very stupid bug with lambda functions. See what happend:

Tkinter, Buttons and Callbacks

I was building a very simple Tkinter GUI (I'm not an GUI expert, so I code in Tkinter because it is easy and simple, but I myself think that it is ugly).

@alvesjnr
alvesjnr / Espirografo.md
Created March 1, 2012 10:17
How does an spirograph work?

How does an spirograph work?

Some of you shall ask yourselves: "How does a spirograph work?". But I'm sure that most of you would ask me: "What the wacko is an spirograph?"

An spirograph is a toy used to draw "weird spirals" using two circles (one inside other). For whom doesn't remember, the toy is these one:

Espirografo

The way that this toy works is simples: One gear spins inside a big circle (also with gears!). The pen is placed in a hole of the gear. When you spin the gear through the major circle, the pen follows tho different movements: An circle movement made by the gear around the center of the great circle (let's call this point as O) and a movement made by the pen around the center of the gear (let's call the center of the gear as C and the point where the pen is placed as P). As the center of the gear is moving, the result position of the point P is the sum of these two movements: P over C

@alvesjnr
alvesjnr / Espirógrafo.md
Created February 29, 2012 15:11
How does a spirograph works?

Como os Espirógrafos Funcionam?

Alguns de vocês devem se perguntar: "Como os espirógrafos funcionam?". Mas a maioria de vocês perguntaria antes "espiro-o-que??".

Bem, espirógrafo é aquele brinquedo que muitos de nós usamos quando pequenos para fazer umas "espirais malucas" desenhadas no papel. O brinquedo é esse aí:

Espirografo

A mecânica do brinquedo é bem simples: uma roda dentada gira dentro de um círculo (também dentado). Sua caneta, que está presa em um orifíco da roda dentada acompanha dois movimentos distintos que são somados: o movimento circular em torno do ponto central do grande cículo (vamos chamar este ponto de O) e um movimento circular em torno do centro da roda dentada (vamos chamar o centro da roda dentada de C). Este centro, por sua vez, está em movimento. É a soma destes dois movimentos que faz surgir aqueles "desenhos muito doidos de São Tomé".

Como os Espirógrafos Funcionam?

Alguns de vocês devem se perguntar: "Como os espirógrafos funcionam?". Mas a maioria de vocês perguntaria antes "espiro-o-que??".

Bem, espirógrafo é aquele brinquedo que muitos de nós usamos quando pequenos para fazer umas "espirais malucas" desenhadas no papel. O brinquedo é esse aí:

Espirografo

@alvesjnr
alvesjnr / clock.py
Created September 20, 2012 12:46
A simple clock using Tkinter
from time import strftime
import Tkinter
numbers = {0:'midnight',
1:'one',
2:'two',
3:'three',
4:'four',
@alvesjnr
alvesjnr / gol.py
Created February 20, 2013 10:30
Yesterday I was showing my wife how does a computer program works, so I end up with this code
#coding: utf-8
"""
Conway's Game of Life implementation with console interface
Author: Antonio Ribeiro - alvesjunior.antonio@gmail.com
license: Do What You Want to
"""
from time import sleep
from random import randint
root@d2b55f66d8dd:/srv/jupyterhub_config# cd /tmp/luceda-packages/
root@d2b55f66d8dd:/tmp/luceda-packages# ls
ipkiss-311-packages-linux64 luceda_cst-0.1.2-py27_1.tar.bz2
root@d2b55f66d8dd:/tmp/luceda-packages# . activate py2
(py2) root@d2b55f66d8dd:/tmp/luceda-packages# conda install -n py2 luceda_cst-0.1.2-py27_1.tar.bz2
(py2) root@d2b55f66d8dd:/tmp/luceda-packages# python
Python 2.7.12 | packaged by conda-forge | (default, Sep 8 2016, 14:22:31)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from luceda_cst.model import CapheModelCST
[D 2017-02-23 11:33:11.390 JupyterHub app:740] Generating new cookie_secret
[I 2017-02-23 11:33:11.390 JupyterHub app:745] Writing cookie_secret to /srv/jupyterhub_config/jupyterhub_cookie_secret
[D 2017-02-23 11:33:11.391 JupyterHub app:796] Connecting to db: sqlite:///jupyterhub.sqlite
[W 2017-02-23 11:33:12.361 JupyterHub app:365]
Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.
Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.
[D 2017-02-23 11:33:12.595 JupyterHub app:1085] Loading state for juno from db
[D 2017-02-23 11:33:12.596 JupyterHub dockerspawner:348] Getting container 'jupyter-juno'
[E 2017-02-23 11:33:12.667 JupyterHub app:1527]