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 python3 | |
import time | |
from contextlib import contextmanager | |
@contextmanager | |
def timing(): | |
start = time.time() | |
yield | |
elapsed = time.time() - start |
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 python3 | |
import sys | |
import timeit | |
from concurrent.futures import ThreadPoolExecutor, wait | |
import numpy as np | |
N_THREADS = int(sys.argv[1]) |
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
def somar(a, b): | |
return 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
#!/usr/bin/env python | |
""" | |
Gist to show uvloop problems with aiohttp serving static files. | |
""" | |
import logging | |
import asyncio | |
import uvloop |
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
server { | |
listen 80; | |
server_name static.mysite.com.br; | |
access_log /var/log/nginx/static.mysite.access.log; | |
error_log /var/log/nginx/static.mysite.error.log; | |
add_header Host $server_name; | |
add_header X-Server $hostname; |
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
/** | |
* Bookmarklet para remover o bloqueio de tela das páginas de notícias do Folha.com.br | |
* | |
* Motivação: não quero ter que pagar uma assinatura de Folha só para ver o conteúdo que tem por debaixo do bloqueio de tela deles. A Folha | |
* coloca uma página de propaganda antes de chegar na notícia, enche a própria página de notícia de propagandas, e ainda quer cobrar pra que | |
* possamos ler a notícia? Eu digo não; Se a informação chegou até meu navegador, eu posso fazer o que quiser com ela enquanto ela estiver na minha | |
* máquina. Sendo assim, eu posso alterá-la enquanto está no navegador. Não estou vendendo a informação, não estou republicando-a, estou apenas | |
* manipulando-a dentro de meu próprio navegador, portanto não constitui crime. | |
* | |
* Forma de usar: |
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 | |
import binascii | |
import socket | |
blocks = ''' | |
800d00030000000000000003000000000000000000000000666f6f | |
800d00040000000000000004000000000000000000000000666f6f32 | |
800a00000000000000000000000000000000000000000000 |
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
def create_order(products, user): | |
connection = db_connection() | |
connection.begin_transaction() | |
try: | |
process_order(connection, products, user) | |
except Exception as e: | |
connection.rollback() | |
message = 'Order failed : %s' % e | |
else: |
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
def create_order(products, user): | |
# Start a connection | |
connection = db_connection() | |
connection.begin_transaction() | |
# Create a mail message | |
mail = mailer.create_message() | |
mail.to = user.email | |
mail.from_ = 'The store' |
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
/** | |
* Bookmarklet para remover o bloqueio de tela das páginas de notícias do Estadão.com.br | |
* | |
* Motivação: não quero ter que pagar uma assinatura de Estadão só para ver o conteúdo que tem por debaixo do bloqueio de tela deles. O Estadão | |
* coloca uma página de propaganda antes de chegar na notícia, enche a própria página de notícia de propagandas, e ainda quer cobrar pra que | |
* possamos ler a notícia? Eu digo não; Se a informação chegou até meu navegador, eu posso fazer o que quiser com ela enquanto ela estiver na minha | |
* máquina. Sendo assim, eu posso alterá-la enquanto está no navegador. Não estou vendendo a informação, não estou republicando-a, estou apenas | |
* manipulando-a dentro de meu próprio navegador, portanto não constitui crime. | |
* | |
* Forma de usar: |
NewerOlder