Skip to content

Instantly share code, notes, and snippets.

View ltvolks's full-sized avatar

Lucas Taylor ltvolks

View GitHub Profile
angular.module('myMdl', []).config(['$httpProvider', function($httpProvider) {
$httpProvider.responseInterceptors.push([
'$q', '$templateCache', 'activeProfile',
function($q, $templateCache, activeProfile) {
// Keep track which HTML templates have already been modified.
var modifiedTemplates = {};
// Tests if there are any keep/omit attributes.
var HAS_FLAGS_EXP = /data-(keep|omit)/;
@ltvolks
ltvolks / ampclient_example.php
Last active December 16, 2015 14:29
AMP PHP client example
<?php
/*
Protocol details: http://amp-protocol.net/
Full client implementation of the protocol: http://twistedmatrix.com/trac/browser/sandbox/jerub/ampclient.php
*/
require('ampclient.php');
// Create an AMP client
$client = new AMP($host, $port);
@ltvolks
ltvolks / redis upstart script
Last active December 10, 2015 19:08
Redis upstart script (slightly modified from PPA: https://launchpad.net/~rwky/+archive/redis)
# redis-server - Redis Datastore Server
#
# Redis is a key value in memory persistent datastore
# . Assumes certain config options:
#
# * bind 127.0.0.1
# * daemonize yes
# * pid, data, log, and config directories are expected to live in: /var/run/redis/redis.pid, /var/lib/redis/ , /var/log/redis/, /etc/redis/redis.conf
description "Redis server"
@ltvolks
ltvolks / gist:2821469
Created May 28, 2012 22:28
Combine results from separate Django querysets linearly
# Combine results from separate Django querysets linearly
from itertools import chain
good_ids = (2,8,13,11,22,42,56,61,46)
good = Money.filter(id__in=good_ids).order_by('id')
bad = Money.exclude(id__in=good_ids)
# Throwing good money after bad
money = list(chain(bad, good))
# Assumes user/pass of admin/aaa, md5 hashed in the server password file
def logincram(user='admin', password='47bce5c74f589f4867dbd57e9ca9f808', port=2025):
s = smtplib.SMTP(host='localhost', port=port)
s.ehlo()
s.esmtp_features["auth"] = 'CRAM-MD5'
s.debuglevel = 5
s.login(user, password)
def loginplain(user='admin', password='aaa', port=2025):
@ltvolks
ltvolks / mate_pdb.py
Created March 23, 2010 20:32
Use TextMate Bookmarks as PDB breakpoints
#!/usr/bin/env python
"""
mate_pdb.py
Execute a script file in the debugger using breakpoints set
via Bookmarked Lines in TextMate.
Intended usage is to call from within a TextMate Command in
your Python bundle