Skip to content

Instantly share code, notes, and snippets.

View maurobaraldi's full-sized avatar

Mauro Navarro Baraldi maurobaraldi

View GitHub Profile
@maurobaraldi
maurobaraldi / gist:953e910f37ab78dce77c5a5b428c2f43
Created May 24, 2018 00:30 — forked from ptigas/gist:2820165
linked list implementation in python
class Node :
def __init__( self, data ) :
self.data = data
self.next = None
self.prev = None
class LinkedList :
def __init__( self ) :
self.head = None
@maurobaraldi
maurobaraldi / snake.py
Created November 11, 2016 15:21 — forked from jsbueno/snake.py
Simple Snake Game using Pygame - used in the workshop in Guarulhos at 2016-10-21
# coding: utf-8
import pygame
import random
# [email protected]
TAMANHO = (640, 480)
T = 640 / 32
TX = 640 / T
TY = 480 / T
@maurobaraldi
maurobaraldi / test_temp_directory.py
Created April 2, 2016 11:22 — forked from odyniec/test_temp_directory.py
An example Python unittest test case that creates a temporary directory before a test is run and removes it when it's done.
import shutil, tempfile
from os import path
import unittest
class TestExample(unittest.TestCase):
def setUp(self):
# Create a temporary directory
self.test_dir = tempfile.mkdtemp()
def tearDown(self):
  1. Plain Strings (207): foo
  2. Anchors (208): k$
  3. Ranges (202): ^[a-f]*$
  4. Backrefs (201): (...).*\1
  5. Abba (169): ^(.(?!(ll|ss|mm|rr|tt|ff|cc|bb)))*$|^n|ef
  6. A man, a plan (177): ^(.)[^p].*\1$
  7. Prime (286): ^(?!(..+)\1+$)
  8. Four (199): (.)(.\1){3}
  9. Order (198): ^[^o].....?$
  10. Triples (507): (^39|^44)|(^([0369]|([147][0369]*[258])|(([258]|[147][0369]*[147])([0369]*|[258][0369]*[147])([147]|[258][0369]*[258])))*$)
@maurobaraldi
maurobaraldi / life.py
Created February 20, 2016 10:53 — forked from jsbueno/life.py
Game of Life (Python + Pygame)
# coding: utf-8
import pygame
import random
rr = random.randrange
SIZE = 800, 600
cellsize = 20
try:
@maurobaraldi
maurobaraldi / bbtree.py
Created February 3, 2016 22:23 — forked from olomix/bbtree.py
Balanced binary tree in Python
#!/usr/bin/env python2.7
import random
import subprocess
class Node(object):
def __init__(self, key, value):
self.key = key
self.value = value
@maurobaraldi
maurobaraldi / echo.py
Created February 1, 2016 13:11 — forked from benburry/echo.py
Python 2 - mock & unittest example for Popen
from subprocess import Popen, PIPE
def shell_out(command):
return Popen(command.split(' '), stdout=PIPE,stderr=PIPE).communicate()[0].strip('\n').split('\n')
def main():
return shell_out('echo one\ntwo\nthree\n')
@maurobaraldi
maurobaraldi / nina.zsh-theme
Created January 27, 2016 17:08 — forked from nnja/nina.zsh-theme
My zshell prompt theme, a bastardization of robbyrussel & kolo themes
autoload -Uz vcs_info
zstyle ':vcs_info:*' stagedstr '%F{green}●'
zstyle ':vcs_info:*' unstagedstr '%F{yellow}●'
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{11}%r'
zstyle ':vcs_info:*' enable git svn
theme_precmd () {
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]] {
zstyle ':vcs_info:*' formats '%c%u%B%F{green} '
@maurobaraldi
maurobaraldi / gist:899a88fe0bf7471574c1
Created December 29, 2015 16:56 — forked from anonymous/gist:dc9c249318f3f92d716b
Download math books from springer
from urllib2 import urlopen
from re import findall, search
base_url = "http://link.springer.com"
links = []
for i in xrange(1, 13):
index = base_url + '/search/page/%d?facet-series="136"&facet-content-type="Book"&showAll=false' % i
links.extend(findall('<a class="title" href="(.*?)"', urlopen(index).read()))
@maurobaraldi
maurobaraldi / gist:e9a57a366cf5c3dea9ff
Last active August 29, 2015 14:08 — forked from ThiagoAnunciacao/gist:cc54b806d4a10bf3408f
Informações para parser de dados da Bovespa
# Retorna dados sobre o pregão
http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoCarregarDados.asp?CodDado=IBOV,ticker&CA=undefined
# Retorna ações e seus últimos valores negociados
http://www.bmfbovespa.com.br/Pregao-OnLine/ExecutaAcaoCarregarDados.asp?CodDado=Ticker
# Retorna o histórico do dia de um papel
http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoCarregarDadosPapeis.asp?CodDado=petr4
# Retorna dados de um papel