Skip to content

Instantly share code, notes, and snippets.

@devdave
devdave / namap.py
Created September 14, 2018 22:33
N America cartopy blank using Natural earth for fill in
"""
Features
--------
A demonstration of some of the built-in Natural Earth features found
in cartopy.
modified from caropy examples/features.py
"""
__tags__ = ['Lines and polygons']
@devdave
devdave / run.js
Created April 9, 2018 22:50 — forked from ChuckJHardy/run.js
Express Server for ZeroMQ, Socket.io and Angular.js
'use strict';
var express = require('express'),
app = express(),
http = require('http'),
server = http.createServer(app),
path = require('path'),
io = require('socket.io').listen(server),
fs = require('fs'),
zmq = require('zmq'),
@devdave
devdave / annotated_abuse.py
Last active November 6, 2017 16:27
Messing around with annotations in python3
"""
Command line output
=================================
Test with both arguments supplied
Handling call
Parameter name: always_int
Parameter name: always_str
Original position arguments: ('123',)
Original keyword arguments: {'always_str': 345}
@devdave
devdave / knownpaths.py
Created April 5, 2016 13:54 — forked from mkropat/knownpaths.py
Python wrapper around the SHGetKnownFolderPath Windows Shell function
import ctypes, sys
from ctypes import windll, wintypes
from uuid import UUID
class GUID(ctypes.Structure): # [1]
_fields_ = [
("Data1", wintypes.DWORD),
("Data2", wintypes.WORD),
("Data3", wintypes.WORD),
("Data4", wintypes.BYTE * 8)
@devdave
devdave / config.json
Last active August 29, 2015 14:06 — forked from anonymous/config.json
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 46.7%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#428bca",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
import email
def get_decoded_email_body(message_body):
""" Decode email body.
Detect character set if the header is not set.
We try to get text/plain, but if there is not one then fallback to text/html.
:param message_body: Raw 7-bit message body input e.g. from imaplib. Double encoded in quoted-printable and latin-1
#!/usr/bin/env python
"""
Recipe for creating and updating security groups programmatically.
"""
import collections
import boto
@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")
@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()):
#!/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