Skip to content

Instantly share code, notes, and snippets.

View felipe-prenholato's full-sized avatar

Felipe Prenholato felipe-prenholato

View GitHub Profile
@felipe-prenholato
felipe-prenholato / memoize.py
Last active August 29, 2015 14:07
memoize.py
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from functools import partial, update_wrapper
try:
from cPickle import dumps
except ImportError:
from pickle import dumps
@felipe-prenholato
felipe-prenholato / ips_teste.txt
Created September 9, 2014 19:03
IPs de teste
Argentina: ['179.61.47.218', '179.63.239.70', '186.0.132.123', '186.18.167.154', '190.103.129.152', '200.0.181.30']
Brazil: ['131.100.239.83', '177.21.69.152', '186.216.188.176', '187.62.201.140', '191.243.240.63', '191.37.252.75']
Chile: ['179.61.104.149', '186.2.255.167', '191.115.207.136', '200.91.7.9', '201.220.121.42', '201.241.15.107']
Costa Rica: ['179.43.29.28', '179.51.207.163', '186.64.202.199', '190.211.94.219', '191.102.59.236', '200.9.209.91']
Dominican Republic: ['148.101.241.245', '190.110.46.230', '190.80.202.106', '190.94.36.245', '200.88.37.156', '66.98.47.231']
Ecuador: ['179.49.20.62', '186.66.244.12', '190.123.51.5', '190.131.18.225', '192.188.59.83', '200.7.76.84']
El Salvador: ['190.53.140.154', '190.53.36.31', '190.57.112.77', '190.57.47.68', '190.87.195.148']
Guatemala: ['181.189.134.7', '186.151.43.15', '191.98.194.76', '200.12.51.204', '200.94.250.180', '207.248.101.171']
Honduras: ['186.179.1.43', '190.109.193.10', '190.15.76.191', '190.211.136.116', '200.107.213.56', '200.107.215.
@felipe-prenholato
felipe-prenholato / utc_to_timezone.py
Created June 3, 2014 20:47
utc_to_timezone converts a time string from a timezone to another
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import errno
def error(msg):
print >> sys.stderr, msg
@felipe-prenholato
felipe-prenholato / output.text
Last active August 29, 2015 14:01
Python locale use sample
$ LC_ALL='es_MX.UTF-8' python foo.py
{'Default locale': ('es_MX', 'UTF-8'), 'Default locale data': ''}
{'Current locale data': '', 'Current locale': (None, None)}
{'Default locale': ('es_MX', 'UTF-8'),
'New locale': ('pt_BR', 'UTF-8'),
'New locale data': 'BRL '}
{'Current locale data': 'MXN ', 'Current locale': ('es_MX', 'UTF-8')}
@felipe-prenholato
felipe-prenholato / devpi-server-article.md
Created November 25, 2013 04:00
Article/how to about how install devpy-server (not finished yet)

dev-pi install howto

This guide follow instructions in the devpi quickstart server guide. We will install in own user home using virtualenvs, than, will setup a nginx instance. Server used here is Ubuntu Server 12.04 LTS in one virtualbox instance.

Create devpi user

root ~ # useradd -m -U -s /bin/bash devpi
root ~ # passwd devpi
@felipe-prenholato
felipe-prenholato / gist:7439737
Created November 12, 2013 22:13
meld dark theme, add it to ~/.gtkrc-2.0
style "meld-color-scheme-user"
{
# inserted line(s), also edge color block for added file in dir diff
color["insert-bg"] = "#006000"
color["insert-outline"] = shade(1.5, @insert-bg)
# In dir diff, an added file's name
color["insert-text"] = "white"
# Color block on edge for missing file in dir diff
color["delete-bg"] = "#800000"
@felipe-prenholato
felipe-prenholato / foo__app.py
Last active December 25, 2015 20:19
__ indicates / in file name
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
@felipe-prenholato
felipe-prenholato / 20_custom-kbd-backlight
Last active December 18, 2015 03:38
pm script to halt keyboard backlight allowing Asus G51 notebooks to suspend.
#!/bin/sh
# File: "/etc/pm/sleep.d/20_custom-kbd-backlight".
# Based on http://ubuntuforums.org/showthread.php?t=1546748&p=9744985#post9744985
BRIGHTNESSTMPFILE=/tmp/kbd-brightness
BRIGHTNESSFILE=/sys/devices/platform/asus_laptop/leds/asus::kbd_backlight/brightness
case "${1}" in
hibernate|suspend)
STATUS="`cat $BRIGHTNESSFILE`"
STATUS=$(($STATUS-128))
@felipe-prenholato
felipe-prenholato / exemplo_completo
Last active December 15, 2015 08:19
Exemplo usado em lista de discussão para mostrar uma relação com um model e como obter ela sem fazer muita query.
>>> from posts.models import User, Post, Amigos
>>> # Cria joao
>>> joao = User(username="joao", first_name="João", email="[email protected]")
>>> joao.save()
>>> # Cria jose
>>> jose = User(username="jose", first_name="José", email="[email protected]")
>>> jose.save()
@felipe-prenholato
felipe-prenholato / settings-__init__.py
Last active December 15, 2015 06:09
A splitted settings version
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, unicode_literals
import os
from django.utils.importlib import import_module
from unipath import Path
SETTINGS_ROOT = Path(__file__).parent
PROJECT_ROOT = SETTINGS_ROOT.parent