This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
def cli(): | |
@command | |
def hello(*args): | |
cmd('echo', 'Hello', *args) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# /var/runtime/awslambda/bootstrap.py | |
""" | |
aws_lambda.bootstrap.py | |
Amazon Lambda | |
Copyright (c) 2013 Amazon. All rights reserved. | |
Lambda runtime implemention | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python logger in AWS Lambda has a preset format. To change the format of the logging statement, | |
# remove the logging handler & add a new handler with the required format | |
import logging | |
import sys | |
def setup_logging(): | |
logger = logging.getLogger() | |
for h in logger.handlers: | |
logger.removeHandler(h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'clojure.test) | |
(deftest tracing-paths | |
(testing "trace-paths" | |
(is (= (trace-paths {:a nil} :a) | |
[[:a]])) | |
(is (= (trace-paths {:a #{:b} | |
:b nil} :a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Too many crusty old git branches? Run this to find likely candidates for deletion | |
# It lists all the remote branches and sorts them by age. | |
# | |
# Folks at pivotal shared this with me | |
# | |
#$ . show-remote-branch-info.sh | |
# 2012-05-04 09:42:29 -0700 4 minutes ago Ted & Bill \torigin/hey_Bill |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdjacencyMatrix[T: Manifest](size: Int) { | |
// initialize it | |
// (It's in column vector format) | |
val matrix = Array.ofDim[T](size, size) | |
// helper functions | |
// takes a list of 3-tuples in the form: (from, to, weight) | |
def setConnections(connections: List[(Int, Int, T)]) = { | |
for (x <- connections) { | |
// make matrix[to][from] = weight |