Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mayo
mayo / openpgp.md
Last active December 28, 2023 00:25
OpenPGP Claim

Ariadne OpenGPG Claim: openpgp4fpr:50fec3a364b59bee734d0e9b56a3789ced4d2dd7

@mayo
mayo / secrets.sh
Last active March 10, 2023 07:44
Populate variable names from secret store, and easily clean them up.
#!/bin/sh
# Loads and unloads secrets from pass into shell environment variables.
# Usage:
# # Load secrets:
# $ source secrets.sh
#
# # Unload secrets
# $ source secrets.sh unload
#
@mayo
mayo / input_volume.osa
Last active September 23, 2020 20:37
AppleScript to toggle the input device (microphone) volume between 0 (muted) and set volume
on run
set vol_level to (input volume of (get volume settings))
if (vol_level < 1) then
set volume input volume ReadVolumeLevel()
else
set volume input volume 0
WriteVolumeLevel(vol_level)
return vol_level
end if
@mayo
mayo / banktivity.py
Last active February 16, 2019 06:21
Generate Beancount ledger from Banktivityfor iOS
from datetime import date
import sqlite3
EPOCH_OFFSET = 978278400
conn = sqlite3.connect('banktivity.sql')
conn.row_factory = sqlite3.Row
first_date = None
accounts = set([])
@mayo
mayo / sphinx_string.py
Created January 17, 2019 00:24
Process rST (restructured text) strings using Sphinx
# This is particularly useful when your doc strings are written in rST as part of
# a bigger project, but are also needed to be displayed elsewhere, for when when
# generating code.
"""
This is intended to have similar interface to doctools.core (specifically
publish_string level of methods), but still could use more cleanup. Plaintext
output is assumed. Changing this would require tinkering with the Sphinx writers.
"""
import docutils.io
@mayo
mayo / instagram_import.py
Last active May 29, 2021 19:02
Import instagram data into a static site (Jekyll, Hugo, Hana, Metalsmith, etc)
import codecs
from datetime import datetime
import json
import os
import posixpath
import re
import shutil
import sys
# This script will import your instagram photos to your static site. It should work for most, assuming you customize the POST_TEMPLATE to match what your site uses.
@mayo
mayo / demo.ipnb
Last active October 29, 2015 23:16
Jupyter demo
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
### Keybase proof
I hereby claim:
* I am mayo on github.
* I am mayo (https://keybase.io/mayo) on keybase.
* I have a public key whose fingerprint is 50FE C3A3 64B5 9BEE 734D 0E9B 56A3 789C ED4D 2DD7
To claim this, I am signing this object:
@mayo
mayo / README.md
Created March 11, 2015 07:19
Convert Simplenote Export JSON file into multiple Markdown files

SimpleNote to Markdown

This script converts JSON file from Simplenote Export web service into individual Markdown files.

It's nothing fancy, first argument is the JSON file, second argument is directory to write the notes to. The note files are named by using the first 60 characters (or a little more, up to a full word) of the first line of the note, stripped of any characters outside of letters, simple dash, underscore, brackets, space, single quote, and plug and equal signs.

Tags are stored on the bottom of the note on a line starting with "TAGS:", and the SimpleNote note ID/key as a "KEY:" line.

@mayo
mayo / Import.lua
Created October 25, 2014 17:45
This patch should not be required to import your Aperture library into Lightroom, and I don’t recommend using it. I wrote it when I was having problems with the import, but have since found the source of the problems fixable within the Aperture library. Please see my updated blog post at http://oyam.ca/blog/2014/10/aperture-importer.html. This g…
--- Import.lua.orig 2014-10-25 10:13:07.000000000 -0700
+++ Import.lua 2014-10-25 10:41:34.000000000 -0700
@@ -154,15 +154,15 @@
local kwdInf, outputPath, err = Utils.getKeywordInfo( aperturePkg, workDir )
- if props.importOnlyUsedKeywords then
+ if props.importOnlyUsedKeywords and kwdInf then
for i, root in ipairs( kwdInf.keywords ) do
dropUnusedKeywords( root, kwdInf.keywords, i, kwdInf.usedKeywords )