This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# A nifty GUI controlling the window controls position | |
# | |
# Depends on python-gconf (started from a python-gconf example) | |
# | |
# @version 0.1 | |
# @author alex(at)eftimie(dot)ro | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
jQuery.fn.dummyEmailBox = function() { | |
var domains = [ | |
'gmail.com', | |
'hotmail.com', | |
'hotmail.es', | |
'live.com', | |
'live.es', | |
'yahoo.com', | |
'yahoo.es', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
(SELECT name | |
FROM ubigeo u0 | |
WHERE u0.province_code = ubigeo.province_code | |
AND u0.department_code = ubigeo.department_code LIMIT 1) AS "provincia", | |
(SELECT name | |
FROM ubigeo u0 | |
WHERE u0.department_code = ubigeo.department_code LIMIT 1) AS "departamento", | |
"ubigeo"."id", "ubigeo"."department_code", "ubigeo"."province_code", "ubigeo"."district_code", "ubigeo"."name" FROM "ubigeo" WHERE "ubigeo"."id" = 758 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def edad_gestacional_fur(self): | |
if self.ultima_menstruacion: | |
# 40 semanas | |
days = (date.today() - self.ultima_menstruacion).days | |
return '{0} {1}/7'.format(days / 7, days % 7) | |
return None | |
def edad_gestacional_1eco(self): | |
"""Retorna la edad gestacional segun la primera ecografia.""" | |
if self.primera_ecografia: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from fabric.api import * | |
env.user = '' | |
env.hosts = [''] | |
env.password = '' | |
LOCAL_PATH = os.path.abspath('.') | |
SERVER_PATH = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
from lxml.html import fromstring | |
strip_html = lambda html: fromstring(html).text_content() | |
except ImportError: | |
try: | |
from bs4 import BeautifulSoup | |
strip_html = lambda html: ''.join( | |
BeautifulSoup(html).findAll(text=True)) | |
except ImportError: | |
from HTMLParser import HTMLParser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[core] | |
excludesfile = /path/to/gitignore_global | |
[alias] | |
serve = daemon \ | |
--reuseaddr --verbose --export-all \ | |
--base-path=/path/to/projects/ \ | |
--interpolated-path=/path/to/projects%D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import hmac | |
import base64 | |
import hashlib | |
def parse_signed_request(signed_request, secret): | |
encoded_sig, payload = signed_request.split('.') | |
sig = base64.b64decode(encoded_sig + '==') | |
data = json.loads(base64.b64decode(payload + '==')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xlwt | |
from django.http import HttpResponse | |
def export_xls(modeladmin, request, queryset): | |
meta = modeladmin.model._meta | |
filename = '%s.xls' % meta.verbose_name_plural.lower() | |
def get_verbose_name(fieldname): | |
name = filter(lambda x: x.name == fieldname, meta.fields) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
URL = 'http://api.tropo.com/1.0/sessions' | |
TOKEN = '' | |
def send_sms(to, shout): | |
params = urllib.urlencode({ | |
'action': 'create', | |
'token': TOKEN, | |
'shout': shout, |