Skip to content

Instantly share code, notes, and snippets.

View lampholder's full-sized avatar

Tom Lant lampholder

View GitHub Profile

Keybase proof

I hereby claim:

  • I am lampholder on github.
  • I am lampholder (https://keybase.io/lampholder) on keybase.
  • I have a public key ASA5M0wuhl4VXVwLd2EfchuUBVsz80pbRCBqU05IqILJDwo

To claim this, I am signing this object:

@lampholder
lampholder / progress.py
Created April 22, 2019 16:20
Partial Unicode blocks progress bar in python
def progress(percent, width=20, blocks=['', '▏','▎','▍','▌','▋','▊','▉','█']):
return '{:<{width}}'.format(int(min(percent, 1) * width) * blocks[-1] +
blocks[int(min(percent, 1) * width * len(blocks) % len(blocks))], width=width)
@lampholder
lampholder / gist:dbe6bdc0ab33f314b103b393919e23d6
Created June 6, 2019 16:24
Postgres function to pull the 'best available name' for any given room_id in the Synapse Homeserver db
CREATE OR REPLACE FUNCTION pg_temp.name(TEXT) RETURNS TEXT AS $$
DECLARE
rm_id TEXT;
rm_name TEXT;
rm_alias TEXT;
BEGIN
rm_id := $1;
rm_name := (
SELECT name
FROM matrix.room_names
@lampholder
lampholder / days.sh
Last active January 10, 2020 00:58
Very quick and dirty bash script to do something I need on a regular basis - outputing a sequence of days between an (inclusive) start date and an (exclusive) end date.
#!/bin/bash
if (( $# < 2 )); then
echo "Usage:"
echo
echo "$0 1983-02-20 1983-03-13 [OUTPUT FORMAT] [--inclusive-end]"
echo "Generates sequential dates in the specified format between the start and end dates provided."
echo
echo "$0 1983-02-20 20 [OUTPUT FORMAT] [--inclusive-end]"
echo "Generates sequential dates in the specified format starting at the start date and continuing for the specified number of days."
echo