Skip to content

Instantly share code, notes, and snippets.

View shentonfreude's full-sized avatar

Chris Shenton shentonfreude

View GitHub Profile
@shentonfreude
shentonfreude / brewsheet.ps
Created October 25, 2020 17:10
LaTeX source for the brewsheet I used for grain, extract, hops, adjunct, history; published to HomeBrewDigest in 1990
%!PS-Adobe-2.0
%%Creator: dvips by Radical Eye Software
%%Title: brewsheet.dvi
%%Pages: 1 1
%%BoundingBox: 0 0 612 792
%%EndComments
%%BeginDocument: tex.pro
/TeXDict 200 dict def TeXDict begin /bdf{bind def}def /bop-aux{}bdf /@rigin{
/@page-height exch def /@page-width exch def 72 Resolution div dup neg scale
translate}bdf /@letter{Resolution dup -10 mul 8.5 11 @rigin}bdf /@landscape{[
#!/usr/bin/env bash
# from http://www.linuxtutorialblog.com/post/solution-converting-flac-to-mp3
OUT_DIR="/home/chris/Music/mp3"
[ ! -d ${OUT_DIR} ] && mkdir -p ${OUT_DIR}
# modify the lame options to your
# preference
lame_opts=" --vbr-new -V 2 -B 256 "
for x in "${@}"
do
@shentonfreude
shentonfreude / aws-ec2-lifecycle-continue.sh
Last active May 15, 2020 13:42
Send the CONTINUE lifecycle hook so the ASG knows our EC2 came up successfully. This allows ASG launches to continue successfully if the UserData is unsuccessful.
#!/bin/bash -x
# Send the CONTINUE lifecycle hook so the ASG knows our EC2 came up successfully.
# If the CONTINUE fails, don't care, assume it already was continued
REGION="us-east-1"
INSTANCE_ID=$1
if [ -z $INSTANCE_ID ] ; then echo Specify INSTANCE_ID ; exit 1; fi
ASG_NAME=`aws --output text --region $REGION autoscaling describe-auto-scaling-instances --query 'AutoScalingInstances[?InstanceId==\`'$INSTANCE_ID'\`].AutoScalingGroupName|[0]'`
@shentonfreude
shentonfreude / gsheet-formula-eur-usd-cell-on-date.txt
Last active April 24, 2020 22:32
Convert Google Sheet cells from EUR to USD on given date
A B C D E
Date (Euro) Item EUR EUR:USD USD
24/3/2019 ExpenseForThing -35,00 1,12965 -39,54
D: Daily rate at mkt close: =index(GOOGLEFINANCE("CURRENCY:EURUSD";"close";A2;1);2;2)
E: Daily rate times cell C3: =index(GOOGLEFINANCE("CURRENCY:EURUSD";"close";A3;1);2;2)*C3
Note: this is for a File->Spreadsheet Settings -> Locale: Spain
For US Locale, you have to use commas in the forula rather than semicolons.
The index() is because even a single day query gives back 2x2 cells with Date, Value headers so we have to pick out the numeric value
@shentonfreude
shentonfreude / pdf2jpg-one-page-lib.py
Created July 26, 2019 14:27
Modified Ned Batchelder's PDF to JPG extractor for python3 and to be used as a library for 1-page extraction
#!/usr/bin/env python3
# Adapted from https://nedbatchelder.com/blog/200712/extracting_jpgs_from_pdfs.html
"""Extract jpg's from pdf's. Quick and dirty."""
import sys
STARTMARK = b"\xff\xd8"
STARTFIX = 0
ENDMARK = b"\xff\xd9"
ENDFIX = 2
@shentonfreude
shentonfreude / pdf2jpg.py
Created July 11, 2019 23:49
Extracts the JPG image from a PDF *scan* and saves to a file; adapted for Python3 from Ned Batchelder's py2 code
#!/usr/bin/env python3
# Extract jpg's from pdf's. Quick and dirty.
# Adapted from https://nedbatchelder.com/blog/200712/extracting_jpgs_from_pdfs.html
import sys
pdf = open(sys.argv[1], "rb").read()
startmark = b"\xff\xd8"
@shentonfreude
shentonfreude / .bashrc-vapor
Created January 15, 2019 15:31
.bashrc/.bash_profile from Macbook Air "Vapor"
# .bashrc: NON-login shells
# .bash_profile: login shells (like iTerm launches, $0 = "-bash")
echo "# \$0=$0"
# if [ argv[0][0] == "-" ] I THINK THIS IS WRONG
# then
# echo "# \$0=$0 Login Shell "
# else
# echo "# \$0=$0 Non-login shell: arvg[0][0]" $arvg[0][0] " argv=$argv" argv[0]=$argv[0]"
# fi
@shentonfreude
shentonfreude / mac-idempotent-setup.sh
Last active May 23, 2019 17:16
Initial install and config of mac based on Jared Short's idea
#!/bin/sh
# Based on ideas from shortjared/mac-idempotent-setup.sh
# First time takes a while; if all's installed, takes 30 seconds.
BREW_CASKS=(
alfred
authy
brave-browser # update to get DuckDuckGo
docker
dropbox
@shentonfreude
shentonfreude / s3videopager.py
Created December 21, 2018 16:43
Loop over S3 videos looking for ones that need new thumbs.
#!/usr/bin/env python3
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/paginators.html
"""Loop over S3 videos looking for ones that need new thumbs.
Finds all the video/assetid/ prefixes and loops over them, then for each
with enough keys, looks to see if they have thumbs (so skip this one) or a
~orig. file we can use to create thumbs.
"""
import os
# Use the Elasticsearch python bindings to connect to Elasticsearch or AWS
# ElasticsearchService (ES). For plain Elasticsearch we only need host and
# port. For ES, we need to create an AWS RequestAuth and pass those to the
# instantiation. This gets the launched EC2/Lambda instances' ID, KEY -- and,
# for Lambda, a TOKEN. See: https://github.com/davidmuller/aws-requests-auth
# Another approach is shown here:
# https://elasticsearch-py.readthedocs.io/en/master/#running-on-aws-with-iam
# using requests_aws4auth: https://pypi.org/project/requests-aws4auth/
import os