Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# coding: utf-8
# How Twisted's inlineCallbacks work?
# If you use it but don't know exactly what it does,
# and didn't understand the code shipped with Twisted,
# keep reading.
import types, functools
from twisted.python import failure
from twisted.web.client import getPage
@douglascamata
douglascamata / gist:2878100
Created June 5, 2012 21:23 — forked from bernardobarreto/gist:2877446
Sete Atitudes para Hackear a Indústria de Software
Sete Atitudes para Hackear a Indústria de Software
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 1, 2024 03:34
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@andrewsmedina
andrewsmedina / gist:4128516
Created November 21, 2012 23:23
custom context manager
import sys
from StringIO import StringIO
class redirect_stdout:
def __init__(self, target):
self.stdout = sys.stdout
self.target = target
def __enter__(self):
@andrewsmedina
andrewsmedina / gist:4128574
Created November 21, 2012 23:40
ordered dict
from collections import OrderedDict
d = OrderedDict()
d["ble"] = "bla"
d["bla"] = "x"
@andrewsmedina
andrewsmedina / gist:4128579
Created November 21, 2012 23:41
annotations
def hello(name: str, age: int) -> int:
print(name, age)
hello.__annotations__
@andrewsmedina
andrewsmedina / gist:4128582
Created November 21, 2012 23:42
memoryview
a = b"Heelo World"
v = memoryview(a)
import io
f = io.FileIO("texto.txt", "w")
f.write("ble")
f.close()
from concurrent.futures import ProcessPoolExecutor
with ProcessPoolExecutor(max_workers=4) as executor:
future = executor.submit(pow, 323, 1235)
print(future.result())
@andrewsmedina
andrewsmedina / gist:4128588
Created November 21, 2012 23:44
futures2
from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor(max_workers=1) as executor:
future = executor.submit(pow, 323, 1235)
print(future.result())