This file contains 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 | |
import hashlib | |
import hmac | |
import time | |
import requests | |
import datetime | |
# Q. Do you have A Websocket API? | |
# A. Yes, and we strongly recommend you to use it. Please, check our JavaScript websocket implementation for our WebSocket API here: | |
# https://github.com/blinktrade/frontend/blob/master/jsdev/bitex/api/bitex.js |
This file contains 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
# executando algo antes da criação | |
class MeuTipo(type): | |
def __new__(cls, name, parents, dct): | |
print 'aqui!' | |
return super(MeuTipo, cls).__new__(cls, name, parents, dct) | |
class MinhaClasse(object): | |
__metaclass__ = MeuTipo | |
# trocando o nome da class |
This file contains 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
# Copy and self modified from ys.zsh-theme, the one of default themes in master repository | |
# Clean, simple, compatible and meaningful. | |
# Tested on Linux, Unix and Windows under ANSI colors. | |
# It is recommended to use with a dark background and the font Inconsolata. | |
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white. | |
# http://xiaofan.at | |
# 2 Jul 2015 - Xiaofan | |
# Machine name. | |
function box_name { |
This file contains 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
import asyncio | |
import json | |
import aiohttp | |
SCHOOL_URL_FMT = 'http://educacao.dadosabertosbr.com/api/escola/{}' | |
SEARCH_SCHOOL_URL = ( | |
'http://educacao.dadosabertosbr.com/api/escolas/buscaavancada?' | |
'situacaoFuncionamento=1&energiaInexistente=on&aguaInexistente=on&' |
This file contains 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
#The context of this program is a course of an hour to journalists who know nothing about programming in a lab with Python 3 only. | |
import urllib.request | |
url = 'http://www.portaltransparencia.gov.br/copa2014/api/rest/empreendimento' | |
resp = urllib.request.urlopen(url).read().decode('utf-8') | |
total = 0 | |
j = 0 | |
and1 = '<andamento>' | |
and2 = '</andamento>' | |
abre = '<valorTotalPrevisto>' | |
fecha = '</valorTotalPrevisto>' |
This file contains 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
#The context of this program is a course of an hour to journalists who know nothing about programming in a lab with Python 3 only. | |
import urllib.request | |
import json | |
def analisa_detalhe(cod): | |
url = 'http://educacao.dadosabertosbr.com/api/escola/' | |
resp = urllib.request.urlopen(url+str(cod)).read() | |
resp = json.loads(resp.decode('utf-8')) | |
if int(resp['salasExistentes']) > 1: | |
print ('Salas Existentes:', resp['salasExistentes']) |
This file contains 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
""" | |
Test (data) migrations in Django. | |
This uses py.test/pytest-django (the `transactional_db` fixture comes from there), | |
but could be easily adopted for Django's testrunner: | |
from django.test.testcases import TransactionTestCase | |
class FooTestcase(TransactionTestCase): | |
def test_with_django(self): |
This file contains 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 sqlalchemy import create_engine | |
from sqlalchemy.orm import Session | |
from myapp.models import BaseModel | |
import pytest | |
@pytest.fixture(scope="session") | |
def engine(): | |
return create_engine("postgresql://localhost/test_database") |
This file contains 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
""" | |
Fix for some issues with the original code from Heroku: | |
https://devcenter.heroku.com/articles/s3-upload-python | |
This example is also designed for use with Django, not Flask as in the original. | |
""" | |
import base64 | |
import hashlib | |
import hmac |
This file contains 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
import logging | |
from rest_framework import serializers | |
class GeneralModelSerializer(serializers.ModelSerializer): | |
""" General model serializer that will serialize a model object. It will return all the model fields. | |
""" | |
class Meta: | |
model = None |