Skip to content

Instantly share code, notes, and snippets.

class ReloaderEventHandler(FileSystemEventHandler):
"""
Listen for changes to modules within the Django project
On change, reload the module in the Python Shell
Custom logic required to reload django models.py modules
Due to the singleton AppCache, which caches model references.
For those models files, we must clear and repopulate the AppCache
"""
def __init__(self, *args, **kwargs):
@devdave
devdave / pyzmq_inline_experiment.py
Last active December 13, 2015 23:29
Messing around with different idea's and hacked together a crude twisted inlineCallbacks decorator.
import time
import zmq
from zmq.eventloop import ioloop
from zmq.eventloop.zmqstream import ZMQStream
from dgbase.messages.kickstart import RequestKickstart
from dgbase.messages.kickstart import RespondWithKickstart
from functools import wraps, partial
message KickStartRequest {
enum WHOTYPE {
CLIENT = 0;
PRODUCER = 1;
HUB = 2;
CLIHUB = 3;
}
optional WHOTYPE whoami = 1 [default = CLIENT];
}
@devdave
devdave / app.js
Created March 7, 2013 23:41
Experimental utility for working in Qt WebKit
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
@devdave
devdave / hw1.cpp
Created March 8, 2013 15:17
Eh, it's going to take a while to relearn c++
/*
* File: main.cpp
* Author: dward
*
* Created on March 8, 2013, 8:13 AM
*/
#include <cstdlib>
#include <iostream>
@devdave
devdave / gist:5514362
Created May 3, 2013 21:29
Script to generate the ec2-authorize calls necessary to add dotCloud access to your EC2 instances.
"""
requires the AWS ec2 command line tools are setup
run this from the base directory of the ec2-tools install directory
security groups provided by DotCloud
"""
groups = """admin-282171928639, gateway-282171928639, lxc-282171928639
admin-557344332487, gateway-557344332487, lxc-557344332487

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#!/usr/bin/sh
set -e
sudo apt-get install openjdk-7-jdk git-core curl -y # Ubuntu 12.04 meets no problem
mkdir -p ~/bin
curl https://raw.github.com/technomancy/leiningen/preview/bin/lein > ~/bin/lein
chmod 755 ~/bin/lein
# Add ~/bin to your $PATH, it has been done if in Ubuntu 12.04
@devdave
devdave / gist:5892749
Last active December 19, 2015 03:49
Python uuid1 colisions with Ubuntu 12.04 LTS Python 2.7.3
from uuid import uuid1
from time import time
def main():
test = dict()
limit = 10 ** 10
while limit:
limit -= 1
x = {n:uuid1().hex for n in range(15)}
if len(set(x.values())) != len(x.keys()):
@devdave
devdave / __run__.py
Created August 23, 2013 17:26
romper/storm-starter for jython. Change to __run__.py Idea is to allow for arbitrary topologies to be executed BUT I don't know if this will work in the cluster submission process via storm command.
import argparse
import sys
from importlib import import_module
from backtype.storm import Config, LocalCluster, StormSubmitter
#from tsync.examples.exclamation import get_topology_builder
def main(run_local=False):
parser = argparse.ArgumentParser(description="Generate a single jar for Storm")