Skip to content

Instantly share code, notes, and snippets.

View alexras's full-sized avatar

Alex Rasmussen alexras

View GitHub Profile
@alexras
alexras / lcd_hello_world.py
Created December 20, 2021 22:13
Character LCD Hello World using RPLCD
#!/usr/bin/env python3
"""
Tested on a Raspberry Pi 3b+ running Raspbian 11 with i2c enabled via raspi-config, Python 3.9.2 and RPLCD 1.3.0.
Display under test is an HD44780 character LCD from Adafruit (https://www.adafruit.com/product/198)
soldered to an i2c backpack (https://www.adafruit.com/product/292). Display's i2c address located with `i2cdetect -y 1`.
"""
from RPLCD import i2c
@alexras
alexras / date-loop.sh
Created February 26, 2020 20:37
Loop through dates by month in bash
#!/bin/bash
start_date=2019-10-01
end_date=2019-10-31
while [ "$start_date" != 2017-10-01 ]
do
echo $start_date $end_date
start_date=$(gdate -I -d "$start_date - 1 month")
end_date=$(gdate -I -d "$start_date + 1 month - 1 day")
@alexras
alexras / sas7bdat2csv.py
Created April 19, 2018 22:19
Convert sas7bdat file to csv
#!/usr/bin/env python
import pandas as pd
import csv
import sys
sas = pd.read_sas(sys.argv[1])
with open(sys.argv[1] + '.csv', 'w+') as fp:
@alexras
alexras / upload-certificates-to-aws.sh
Created November 23, 2017 20:11
Upload LetsEncrypt certs to AWS
#!/bin/bash
if [ $# -ne 1 ]
then
echo "upload-certificate-to-aws.sh <domain name>"
exit 1
fi
DOMAIN_NAME=$1
@alexras
alexras / update-letsencrypt-certs.sh
Created November 22, 2017 22:13
Update LetsEncrypt certs on S3
#!/bin/bash
# Assumes you're running in a virtualenv with
# https://github.com/dlapiduz/certbot-s3front installed
function update_cert
{
BUCKET_NAME=$1
DOMAIN_NAME=$2
DISTRIBUTION_ID=$3
@alexras
alexras / strip_kits_from_rom.py
Created February 9, 2017 04:44
Strip everything but the kits from an LSDJ ROM; written so I can use it in tests
#!/usr/bin/env python
import sys
with open(sys.argv[1], 'rb') as in_fp:
in_fp.seek(0x20000)
with open('lsdj.gb.patched', 'wb') as out_fp:
out_fp.write(bytearray([0xff] * 0x20000))
out_fp.write(in_fp.read(21 * (0x4000)))
@alexras
alexras / service-checklist.md
Created October 9, 2016 04:51 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@alexras
alexras / tag-snapshots-with-ami-id.py
Created October 7, 2016 23:04
Name unnamed EBS snapshots after the image ID and device name to which they're mapped
#!/usr/bin/env python
'''
The association between a snapshot and its corresponding AMI and device name is tedious to extract by hand.
This script names all snapshots "<AMI name> (<AMI id>) <device name>", which makes the associations much easier
to see. It also makes it easy to find "orphaned" snapshots, i.e. those that aren't associated with extant AMIs.
'''
import boto3

Keybase proof

I hereby claim:

  • I am alexras on github.
  • I am alexras (https://keybase.io/alexras) on keybase.
  • I have a public key whose fingerprint is B25D 71A4 8CDE 1333 47BE 04A1 BC0D D264 4980 B3FF

To claim this, I am signing this object:

@alexras
alexras / arc-cover-summarize.py
Created July 26, 2016 22:58
Print number of lines and files covered by each user in `arc cover`
#!/usr/bin/env python
import collections
import fileinput
import operator
import sys
user = None