Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#
# gpgedit: edit an encrypted file with an associated list of recipients
#
# $ gpgedit secrets.gpg [gpg args]
#
# gpgedit needs the companion file "secrets.rcp" to exist, and contains a list
# of intended recipients, one per line. The recipient file can contain end-of-
# line comments, starting with the "#" character.
@calpaterson
calpaterson / .inputrc
Created October 8, 2013 20:41
Magic to make M-<right> and M-<left> work in gnome-terminal
"\e[1;3D": backward-word
"\e[1;3C": forward-word
from datetime import datetime
import mandrill
def send_email(to_email, to_name, subject, message_text, from_email = '[email protected]', from_name='RPS Exemplar'):
#additional message parameters https://mandrillapp.com/api/docs/messages.JSON.html
api_key = _MANDRILL_APP_KEY_
try:
mandrill_client = mandrill.Mandrill(api_key)
@app.route("/claims/new-employment-end-date", methods=["POST"])
def new_employment_end_date():
def on_success(validated):
draft_id = session.get('draft_id')
day = validated['new_job_end']['day']
month = validated['new_job_end']['month']
year = validated['new_job_end']['year']
date = "{day}/{month}/{year}".format(**locals())
from concurrent.futures import ThreadPoolExecutor
from os import getpid
from time import sleep
executor = ThreadPoolExecutor(max_workers=20)
def print_pid_and_sleep():
while True:
print(getpid())
sleep(10)
@calpaterson
calpaterson / emailfromparser.py
Created January 5, 2021 10:16
parse out names from emails
#!/usr/bin/env python3
# this is designed to be used as part of a command line like:
# find Maildir/cur/ -type f -newermt '02/23/2019 0:00:00' | xargs ./emailfromparser.py | sort | uniq > new_emails.csv
from sys import argv, stdout, stderr
from csv import DictWriter
from email.parser import BytesHeaderParser
from email.utils import parseaddr
@calpaterson
calpaterson / remove-unneeded-kernels.fish
Last active June 22, 2022 08:25
remove-unneeded-kernels.fish
#!/usr/bin/env fish
# Remove kernels older than the latest, but excluding the one currently booted
# from.
## This is ideal for when you've managed to fill your boot partition and can't
## finish an `apt upgrade`
set current_version (uname -r)
set top_version (dpkg --get-selections | grep install | awk '{print $1}' | egrep '^linux-image-[0-9].*$' | sort -r | head -n 1)