Skip to content

Instantly share code, notes, and snippets.

View turicas's full-sized avatar

Álvaro Justen turicas

View GitHub Profile
#!/usr/bin/env python
# coding: utf-8
from __future__ import print_function
import random
import string
import lxml.etree
import requests
@turicas
turicas / opendata.py
Created April 2, 2014 08:40
The Zen of Open Data, by Chris McDowall (in Python)
# coding: utf-8
# text written by Chris McDowall
# from: http://sciblogs.co.nz/seeing-data/2010/10/12/the-zen-of-open-data/
# and: http://fogonwater.com/blog/2013/06/the-zen-of-open-data/
print('''The Zen of Open Data, by Chris McDowall
Open is better than closed.
Transparent is better than opaque.
@turicas
turicas / populacao_rj.py
Created May 7, 2014 06:52
Exemplo de uso da biblioteca `rows` com dados do IBGE
# coding: utf-8
# Install `rows` executing:
# pip install -U git+https://github.com/turicas/rows.git@develop
import locale
import requests
import rows
@turicas
turicas / python_object_size.py
Created January 28, 2015 00:31
Python memory calculation
#!/usr/bin/env python
# coding: utf-8
import random
import sys
import time
import uuid
generate_uuid = lambda: uuid.uuid4().hex
@turicas
turicas / bitcask_make_entry.py
Created January 28, 2015 00:37
Make a Bitcask entry in Python
# coding: utf-8
import struct
import time
from binascii import crc32
# data file
TIMESTAMP_FIELD = 32
from unicodedata import normalize
SLUG_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'
def slug(text, encoding=None, separator='_', permitted_chars=SLUG_CHARS,
replace_with_separator=' -_'):
if isinstance(text, str):
text = text.decode(encoding or 'ascii')
clean_text = text.strip()
@turicas
turicas / pgram.sh
Last active August 29, 2015 14:22
Configure PostgreSQL to store these databases on RAM. WARNING: you'll lose data once reboot/turn off the machine.
#!/bin/bash
RAMDIR=/mnt/ramfs
DATADIR=$RAMDIR/pgsql-data
PGCONF=/etc/postgresql/9.3/main/postgresql.conf
RAMDISKSIZE=128M
if [ $(id -u) -ne 0 ]; then
echo 'ERROR: must be run as root'
exit 1
@turicas
turicas / android-decompile.sh
Created July 9, 2015 22:33
Decompile Android from APK
#!/bin/bash
# Download dex2jar:
#URL=https://github.com/pxb1988/dex2jar/releases/download/2.0/dex-tools-2.0.zip
#wget $URL -O /tmp/dex-tools.zip
#cd /tmp
#unzip dex-tools.zip
#cd dex2jar-2.0
#chmod +x *.sh
@turicas
turicas / tsuru-bootstrap.sh
Created August 6, 2015 13:58
Script to bootstrap tsuru configurations just after running "now" (work in progress)
#!/bin/bash
# TODO: add services automatically
# Configurations
TSURU_HOST=tsuru.turicas.info
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=admin123
MY_EMAIL=my-user-email@example.com
# coding: utf-8
# pip install requests rows
import datetime
import re
from collections import OrderedDict
from io import BytesIO
import requests