This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Application to store a single message note in the Ethereum blockchain. | |
In order to run this web server, the ethereum node daemon | |
(e.g. the Geth HTTP RPC on 8545) should be running in the same host. | |
Input parameters should be on the following environment variables: | |
export ETH_CONTRACT_ADDRESS=0xAAAA... # Enforced | |
export ETH_NODE_URL='http://localhost:8545' # Optional |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from server import WebServer | |
app = WebServer() | |
@app.route("/") | |
def root(): | |
return "Hello World!" | |
@app.route("/file") | |
def file_route(): | |
with open("server.py", "rb") as f: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Genetic algorithm example that finds the best string match using the | |
hamming distance to define an aptitude function. | |
""" | |
from random import choice, seed, randrange | |
from functools import partial | |
import string | |
def crossover(a, b): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Kruskal's algorithm | |
Pure Python implementation by Danilo J. S. Bellini | |
""" | |
import pytest | |
def kruskal_sets(graph): | |
nodes = frozenset.union(*graph) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
""" | |
>>> "Apresentação sobre doctest e py.test" is "nice" | |
True | |
>>> "O.o heeey, como assim?" | |
HUAHUAHUAHUA | |
>>> "Apresentação sobre doctest e py.test" is "a bad idea" | |
False | |
>>> # Ok, ¬¬ chega de strings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created on Thu Sep 25 00:23:24 2014 | |
// @author: Danilo de Jesus da Silva Bellini | |
// Inline and function pointer example (C++ but that's almost C) | |
// | |
// g++ inline_or_funcptr.cpp | |
// | |
#include <iostream> | |
using namespace std; | |
typedef int (*IntOpPtr)(int, int); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Created on Wed Jan 8 04:03:53 2014 | |
# @author: Danilo J. S. Bellini | |
# Python Nordeste 2014 talk proposal description | |
# http://2014.pythonnordeste.org/ | |
# Type it in IPython Shell. | |
# Using this as a script would need to replace lazy_band assignment to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Clojure | |
(defn mul [value] | |
(fn [data] | |
(map | |
(fn [item] (* item value)) | |
data))) | |
; user=> ((mul 2) [3 2 8 -2]) | |
; (6 4 16 -4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Created on Wed Oct 30 10:55:51 2013 | |
# By Danilo J. S. Bellini | |
# Based on https://gist.github.com/anonymous/7123189 | |
""" | |
Find all the divisors from a given number | |
""" | |
# Ensure compatibility in both Python 2 and 3 |
NewerOlder