Skip to content

Instantly share code, notes, and snippets.


Michael F. Lamb datagrok

View GitHub Profile
datagrok /
Created Jun 14, 2019
Elixir's Stream.transform doesn't emit its accumulator at the end of the input. What to do?

I want to lazily process an input file, which contains tokens separated by whitespace.

The naive way is to let Elixir hand me lines, then split the lines:

def tokenize_lines(enum)
  |> Stream.flat_map(&String.split/1)
datagrok /
Created Nov 17, 2018
set randr settings by monitor EDID
The xrandr names (DP-1, DP-2) for my monitors tends to flip around depending on
which one happens to become active first. This script figures out which is which
by the EDID, and runs xrandr to apply the layout correctly.
import re
import subprocess
datagrok /
Created Aug 8, 2018
A script to create paper-printable backups of binary data.
Break input data into chunks and use 'dmtxwrite' to create a DataMatrix 2D
barcode for each chunk. Dump all these into an HTML page for easy printing.
The size of the chunk depends on the target size of the barcodes; see
Intended for making hard (paper) copies of small but highly important data,
like GPG keys, that can be retrieved faster and more reliably (one hopes) than
datagrok /
Last active May 30, 2020
Various code snippets

This is an unmodified selection of code I wrote for and under contract to AT&T, so AT&T holds all copyright.

AT&T released it to the public under the terms of the Apache 2.0 License (as described in license headers in the source code) as part of a larger body of work.

I retrieved these copies from their public repositories on 1/9/2018 after I was no longer under contract to them. I am hosting it here in compliance with the terms of their license. The links below point to AT&T's public repositories.

  •, a simplistic Requests-based wrapper for the Ceph RADOS Object Gateway Admin Operations API.
  •, a little context manager to make it easy to perform some function within a temporary director
datagrok /
Last active Mar 12, 2019
What's the best way to write function pipelines in Python?

I agree with Guido, in that I think

[ x * 2 for x in some_list if x < 12 ]

is much easier to read than the equivalent

map(lambda x:x * 2, filter(lambda x:x<12, some_list))
datagrok /
Last active Apr 28, 2017
a list of configuration options for django-storages' boto backends

Configuration options used by S3BotoStorage and S3Boto3Storage

This is a list of common and divergent configuration options for django-storages' boto backends:

  • storages.backends.s3boto.S3BotoStorage
  • storages.backends.s3boto3.S3Boto3Storage and

Created to cope with the documentation which reads:

"Available are numerous settings. It should be especially noted the following:"


Keybase proof

I hereby claim:

  • I am datagrok on github.
  • I am datagrok ( on keybase.
  • I have a public key ASCrSLf3jYbRq3V0I7pJgP1UEqtjxqqP5iTBLfN5VXNq-Qo

To claim this, I am signing this object:

datagrok /
Last active Jan 8, 2018
Home video and photo management system

A home photo and video management system

I want some tools to help me manage my photos and videos, conforming to some of my particular requirements.

I've already begun tinkering on some of my own, but with every line of code I think, "surely, someone must have done this already." Have you?


  • Backup. I have a local fileserver, but I want offsite backup too. Backblaze B2 looks cheapest but I also already have a DreamObjects account.
  • A thing to make it effortless to get photos off devices and into long-term storage.
datagrok /
Last active Dec 4, 2016
How to refactor code that is too reliant on **kwargs

Refactoring from an overuse of **kwargs


def a(**kwargs):
  if 'A' not in kwargs:
    kwargs['A'] = 1
  if 'B' not in kwargs:
    kwargs['B'] = 2
  success, result = b(**kwargs)
datagrok /
Created Aug 17, 2016
A basic git workflow for centralized repositories.

Basic Workflow


Different uses of git will have a different optimal workflow. This document describes a git workflow with the following characteristics:

  • It is a centralized workflow, meaning multiple developers all push to a shared repository. (As opposed to a fork-and-pull-request Github-style workflow.)
  • It is safe to use when collaborating on a feature branch with others, but requires no workflow changes when working alone. (So there's only one set of steps to remember.)
  • Some git users rely heavily on rebases, using them for any and all conflicts. This is an unhealthy coping mechanism born of past git merge trauma. This workflow relies heavily on merges, using rebase only when it is safe to do so (with commits that have yet to be pushed).
  • push --force is never needed (and may be disallowed by the remote repository.)
You can’t perform that action at this time.