Skip to content

Instantly share code, notes, and snippets.

@jpadilla
jpadilla / fields.py
Created February 3, 2014 21:24
CharacterSeparatedField - A Django REST framework field that separates a string with a given separator into a native list and reverts a list into a string separated with a given separator.
from rest_framework import serializers
class CharacterSeparatedField(serializers.WritableField):
"""
A field that separates a string with a given separator into
a native list and reverts a list into a string separated with a given
separator.
"""
def __init__(self, *args, **kwargs):
@jpadilla
jpadilla / gist:8468419
Created January 17, 2014 04:26
List of free email provider domains that responded to a ping.
123box.net
150ml.com
123qwe.co.uk
163.com
1funplace.com
1internetdrive.com
1under.com
1webave.com
24horas.com
2bmail.co.uk
@jpadilla
jpadilla / gist:2275208
Created April 1, 2012 13:08
Facebook locale codes
$list = array(
"ca_ES" => "Català",
"cs_CZ" => "Čeština",
"cy_GB" => "Cymraeg",
"da_DK" => "Dansk",
"de_DE" => "Deutsch",
"eu_ES" => "Euskara",
"en_PI" => "English (Pirate)",
"en_UD" => "English (Upside Down)",
"ck_US" => "Cherokee",
#!/bin/bash
# To run do:
# wget http://url.com/bootstrap.sh && chmod +x bootstrap.sh && ./bootstrap.sh && source ~/.profile
#
# Based on Amazon EC2 AMI ID ami-ccf405a5 Ubuntu Server 10.10
# This script will:
# * install/config apache2
# * install mod_wsgi
# * install/config nginx
@jpadilla
jpadilla / components.my-component.js
Last active April 21, 2023 17:14
Component Lifecycle Hooks
import Ember from 'ember';
export default Ember.Component.extend({
didInitAttrs(options) {
console.log('didInitAttrs', options);
},
didUpdateAttrs(options) {
console.log('didUpdateAttrs', options);
},
@jpadilla
jpadilla / validators.py
Created January 27, 2014 23:46
DomainNameValidator adapted from Django's EmailValidator.
import re
from django.utils.encoding import force_text
from django.core.exceptions import ValidationError
class DomainNameValidator(object):
"""
Domain name validator adapted from Django's EmailValidator.
"""

Server

To run locally, you must have MongoDB running on defaults. The default db name is speedtests If not, go ahead and set an environment variable, MONGOHQ_URL.

mongodb://user:pass@localhost:10047/dbname

You should then create a user with an apiKey. You'll use this as a part of your store URL for speedtests.py.

This file has been truncated, but you can view the full file.
example_1 = [{'number': 1, 'text': '2012-PF0055\nDEPARTAMENTO DE DESARROLLO COMUNAL Y VIVIENDA\nMUNICIPIO AUTONOMO DE MANATI\nESTADO LlBRE ASOCIADO PUERTO RICO\nEn la Ciudad de Manatf, Puerto Rico,\n\nnov\n\n1 de septiembre\n\ndel 2011.\n\nCOMPARECEN\nDE LA PRIMERA PARTE: EI Municipio\n\nde Manatf, representado\n\nAUBIN CRUZ MANZANO, con segura\ncasado\n\ny\n\nvecino\n\nde\n\nManatf,\n\nsocial patronal\n\nPuerto\n\nRico;\n\npor su ALCALDE JUAN\n\n660-43-3486, mayor\n\nen\n\nadelante\n\nde edad,\n\ndenominado\n\nLA\n\nADMINISTRACION.\nDE LA SECUNDA PARTE: EL SR. JESUS COLON DE JESUS nurnero\n05-5177,\n\nmayor\n\ndenominado\n\nde edad,\n\nsottero y vecino\n\nde segura social 599-\n\nruerto\n\nde Manatf,\n\nRico; en adelante\n\nEL CONTRATANTE.\nEXPONEN\n\nPRIMERO:\n\nEL CONTRATANTE se obliga\n\npor la presente\n\nacscrtto a 10SResidenciales publicos Administrados\n\nPINTOR\n\na prestar\n\nservlclos\n\npor el Gobierno\n\ncomo\n\nMunicipal\n\nde Manatf.\n\nSECUNDO:\n\nLOSservicios a ser prestados\n\nnor EL CONTRAT
@jpadilla
jpadilla / qs.py
Last active April 30, 2021 15:42
import jwt
from jwt import PyJWKClient
class AuthError(Exception):
def __init__(self, error, status_code):
self.error = error
self.status_code = status_code
@classmethod
import http.client
conn = http.client.HTTPSConnection("https://YOUR_DOMAIN")
payload = "{ \"roles\": [ \"ROLE_ID\", \"ROLE_ID\" ] }"
headers = {
'authorization': "Bearer MGMT_API_ACCESS_TOKEN",
'cache-control': "no-cache",
'content-type': "application/json"