Skip to content

Instantly share code, notes, and snippets.

View dlrust's full-sized avatar

Daniel Rust dlrust

View GitHub Profile
@dlrust
dlrust / test
Created August 9, 2016 00:57
test
test
@dlrust
dlrust / django-email-validation-patch.py
Created May 26, 2016 15:51
Hacked patch for django 1.2.3 email validator to suport gTLDs
# old django 1.2.3 validator
# django/core/validators.py
email_re = re.compile(
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE) # domain
# updated validator patch
container_commands:
01_syncdb:
command: "django-admin.py syncdb --noinput"
leader_only: true
02_createadmin:
command: "bin/createadmin.py"
leader_only: true
03_migrate_myapp:
command: "./manage.py migrate --noinput --merge"
leader_only: true
@dlrust
dlrust / basic-json-body.json
Created July 18, 2012 00:51
Basic fields for publishing a local business site
{
"subdomain": "somebusinessname"
"domain": "publisherdomain.com",
"title": "Some Business Name",
"theme_id": 65,
"site_type": "LocalBusinessYellowmagic",
"partner_user_id": 12345,
"first_name": "John",
"last_name": "Doe",
define([
'jquery',
'another_view',
'cs!some_view'
], function($, AnotherView, SomeView) {
var view = new SomeView;
});
@dlrust
dlrust / jinja_asset.py
Created November 8, 2011 01:34
Jinja2 extension to append modified timestamp for cachebreaking
import os
from django.conf import settings
from jinja2 import nodes
from jinja2.exceptions import TemplateSyntaxError
from jinja2.ext import Extension
class AssetExtension(Extension):
'''Jinja2 extension to append modified timestamp for cachebreaking
@dlrust
dlrust / app.html
Created November 4, 2011 07:51
require.js bootstrapping test
<!doctype html>
<html>
<head>
<title>require.js bootstrapping test</title>
</head>
<body>
<script src="require-jquery.js"></script>
<script>
define('config', function() {
@dlrust
dlrust / idkit-javascript-example.html
Last active September 25, 2015 16:57
idkit example for federatedidentity.com
<!doctype html>
<html>
<head>
<title>IDKIT javascript example</title>
</head>
<body>
<div id="idkit-root"></div>
<script src="https://www.federatedidentity.com/static/js/idkit.js"></script>
<script>
doc = Tag('epp', attrs={'xmlns': 'urn:ietf:paramxml:nepp-1.0'}).append(
Tag('response').append(
Tag('result', attrs={'code': '1000'}).append(
Tag('msg', text='Command completed successfully')
),
Tag('resData').append(
Tag('obj:creData', attrs={
'xmlnobj': 'urn:ietf:paramxml:nobj'
}).append(
Tag('obj:name', text='example')
from memcached_stats import MemcachedStats
mem = MemcachedStats('127.0.0.1')
>>> mem.keys()
['key-1',
'key-2',
'key-3',
... ]