Skip to content

Instantly share code, notes, and snippets.

View markwatson's full-sized avatar
💻
hacking the mainframe

Mark Watson markwatson

💻
hacking the mainframe
View GitHub Profile
@sirikon
sirikon / task.py
Last active July 25, 2023 12:09
Task file in Python 3
#!/usr/bin/env python3
def cli():
@command
def hello(*args):
cmd('echo', 'Hello', *args)
@lucasrcosta
lucasrcosta / awslambda.bootstrap.py
Last active October 26, 2021 12:06
AWS Lambda Python Runtime
# -*- coding: utf-8 -*-
# /var/runtime/awslambda/bootstrap.py
"""
aws_lambda.bootstrap.py
Amazon Lambda
Copyright (c) 2013 Amazon. All rights reserved.
Lambda runtime implemention
"""
@niranjv
niranjv / change_lambda_logger_format.py
Last active February 7, 2024 11:03
Change Python logger format in AWS Lambda
# 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)
@jgdavey
jgdavey / trace_paths.clj
Created March 4, 2014 02:26
How to get paths for map of sets?
(use 'clojure.test)
(deftest tracing-paths
(testing "trace-paths"
(is (= (trace-paths {:a nil} :a)
[[:a]]))
(is (= (trace-paths {:a #{:b}
:b nil} :a)
@michaelkirk
michaelkirk / show-remote-branch-info.sh
Created May 4, 2012 16:51
sort remote branches by age
#!/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
@hrldcpr
hrldcpr / tree.md
Last active September 1, 2024 07:04
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@markwatson
markwatson / AdjacencyMatrix
Created March 2, 2011 04:32
Not finished just saving it here...
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