Skip to content

Instantly share code, notes, and snippets.

View gabrielfalcao's full-sized avatar

Gabriel Falcão gabrielfalcao

View GitHub Profile
@gabrielfalcao
gabrielfalcao / fourtytwo.py
Created February 4, 2013 23:31
The answer for the life, the universe and everything else
#!/usr/bin/env python
print int(((
not not not not not not not not not not not
not not not not not not not not not not not not
not not not not not not not not not not not not
not not not not not not not not not not not not
not not not not not not not not not not not not
not not not not not not not not not not not not
not not not not not not not not not not not not
#include <stdio.h>
#define color(code, format, ...) printf("\033[1;3"code"m"format"\033[0m", ##__VA_ARGS__)
#define gray(fmt, ...) color("0", fmt, ##__VA_ARGS__)
#define red(fmt, ...) color("1", fmt, ##__VA_ARGS__)
#define green(fmt, ...) color("2", fmt, ##__VA_ARGS__)
#define yellow(fmt, ...) color("3", fmt, ##__VA_ARGS__)
#define blue(fmt, ...) color("4", fmt, ##__VA_ARGS__)
#define purple(fmt, ...) color("5", fmt, ##__VA_ARGS__)
#define cyan(fmt, ...) color("6", fmt, ##__VA_ARGS__)
@gabrielfalcao
gabrielfalcao / debug-stack.py
Created February 13, 2013 21:10
debugging the stack call from inside a python function
import inspect
import traceback
frame = inspect.stack()[0][0]
lines = map(utf8_bytes, traceback.format_stack(frame))
tb = b"\n".join(lines)
if not b'/util/tests/helpers.py", line 286' in tb:
with open('business_location_save.traceback', 'a') as f:
f.write("\n")
f.write("=" * 100)
f.write("\n")
@gabrielfalcao
gabrielfalcao / gist:5373404
Created April 12, 2013 16:48
# OM in your PS1
"\033[1;35m \xe0\xa5\x90\033[0m"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import gevent
import requests
from gevent.queue import Queue
@gabrielfalcao
gabrielfalcao / greenbench.c
Created August 20, 2013 19:19
A simple module that knows how to calculate the heap size of a greenlet
#include <Python.h>
#include <string.h>
#include <assert.h>
#include "greenlet.h"
PyGreenlet *
ensure_greenlet(PyObject *obj) {
char err[128];
if (!PyGreenlet_Check(obj)) {
________ .
,88888PP8ba, 8b d8b d8b'
,d8P" "Y8b I8 888 d88b'
a8" 'Yd Yb "*" ,ad8"
" )8 "8aaaaa8b"
,dP """"""
,a8" ________
"8gggggg88I ,d88888888b,
"8' 'a8b,88" "Y8)
"Y8b' d8)
from geventhttpclient import HTTPClient
from geventhttpclient.url import URL
import gevent
import gevent.monkey
from gevent.queue import Queue
gevent.monkey.patch_all()
urls_to_download = [