Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
hacking the mainframe

Mark Watson markwatson

💻
hacking the mainframe
View GitHub Profile
@sirikon
sirikon / task.py
Last active Jun 30, 2022
task file in Python 3
View task.py
#!/usr/bin/env python3
def cli():
@command
def hello(*args):
cmd('echo', 'Hello', *args)
@lucasrcosta
lucasrcosta / awslambda.bootstrap.py
Last active Oct 26, 2021
AWS Lambda Python Runtime
View awslambda.bootstrap.py
# -*- 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 Jul 28, 2022
Change Python logger format in AWS Lambda
View change_lambda_logger_format.py
# 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 Mar 4, 2014
How to get paths for map of sets?
View trace_paths.clj
(use 'clojure.test)
(deftest tracing-paths
(testing "trace-paths"
(is (= (trace-paths {:a nil} :a)
[[:a]]))
(is (= (trace-paths {:a #{:b}
:b nil} :a)
View show-remote-branch-info.sh
#!/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 Aug 10, 2022
one-line tree in python
View tree.md

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 Mar 2, 2011
Not finished just saving it here...
View AdjacencyMatrix
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