Skip to content

Instantly share code, notes, and snippets.

View felipe-prenholato's full-sized avatar

Felipe Prenholato felipe-prenholato

View GitHub Profile
{
"results" : [
{
"address_components" : [
{
"long_name" : "01310-100",
"short_name" : "01310-100",
"types" : [ "postal_code" ]
},
{
@felipe-prenholato
felipe-prenholato / show_singleton.py
Created October 9, 2012 05:03
Show how use singletons in tests.
# coding: utf-8
from django.test import TestCase
from breadcrumbs.breadcrumbs import Breadcrumbs
class BreadcrumbsTest(TestCase):
def setUp(self):
# instantiate the singleton
@felipe-prenholato
felipe-prenholato / singleton_tests.py
Created October 9, 2012 04:51
Django unit tests to test singleton
""" Django unit tests to test singleton """
from django.test import TestCase
class Singleton(object):
__instance__ = None
def __new__(cls, *a, **kw):
@felipe-prenholato
felipe-prenholato / date_range.py
Created September 26, 2012 14:07
Date Range widget and field.
# -*- coding: utf-8 -*-
#
# This code have contributions of Augusto Men (https://github.com/augustomen)
# and Nando Florestan (https://github.com/nandoflorestan)
#
from __future__ import (absolute_import, division, unicode_literals)
from datetime import date
@felipe-prenholato
felipe-prenholato / gist:3756123
Created September 20, 2012 14:03
Snippet to create errors with complete info in sentry
import sys, logging
exc_info = sys.exc_info()
# this is important to get request info like url, browser, etc.
data = sentry_cli.get_data_from_request(request)
# and this to say what level of msg (error in case) and module of app current app
data.update({
'level': logging.ERROR,
'logger': __name__,
})
# than in extra you put all additional info u want.
@felipe-prenholato
felipe-prenholato / nginx-rrd_new.pl
Created September 11, 2012 20:24
Script that plot nginx_status for localhost, run each minute in crontab
#!/usr/bin/perl
use RRDs;
use LWP::UserAgent;
# define location of rrdtool databases
my $rrd = '/opt/rrd';
# define location of images
my $img = '/opt/rrd/html';
# define your nginx stats URL
# HTTPS server
server {
listen 443;
server_name localhost;
root /usr/share/nginx/www;
index index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/server.crt;
[user]
name = Felipe Prenholato
email = [email protected]
[core]
editor = vim
excludesfile = /home/felipe/.global_ignore
[alias]
st = status
co = checkout
br = branch
[
{ "keys": ["ctrl+["], "command": "fold" },
{ "keys": ["ctrl+]"], "command": "unfold" },
{ "keys": ["super+f1"], "command": "py_help" }
]
Jun 21 15:54:10 felipe-G51JX kernel: [21865.212277] usb 2-1.4: USB disconnect, device number 14
Jun 21 15:54:12 felipe-G51JX kernel: [21867.971911] usb 2-1.4: new high-speed USB device number 15 using ehci_hcd
Jun 21 15:54:12 felipe-G51JX kernel: [21868.067397] scsi15 : usb-storage 2-1.4:1.0
Jun 21 15:54:12 felipe-G51JX mtp-probe: checking bus 2, device 15: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4"
Jun 21 15:54:12 felipe-G51JX mtp-probe: bus: 2, device: 15 was not an MTP device
Jun 21 15:54:13 felipe-G51JX kernel: [21869.069274] scsi 15:0:0:0: Direct-Access Samsung File-CD Gadget 0000 PQ: 0 ANSI: 2
Jun 21 15:54:13 felipe-G51JX kernel: [21869.070269] scsi 15:0:0:1: Direct-Access Samsung File-CD Gadget 0000 PQ: 0 ANSI: 2
Jun 21 15:54:13 felipe-G51JX kernel: [21869.072789] sd 15:0:0:0: Attached scsi generic sg2 type 0
Jun 21 15:54:13 felipe-G51JX kernel: [21869.073292] sd 15:0:0:1: Attached scsi generic sg3 type 0
Jun 21 15:54:13 felipe-G51JX kernel: [21869.082133] sd 15:0:0:0: [sdb] At