Skip to content

Instantly share code, notes, and snippets.

Brighid McDonnell brighid

Block or report user

Report or block brighid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View download-pokemon-cry.py
#!/usr/bin/env python3
import os
import subprocess
import tempfile
import click
DOWNLOAD_DIR = "{}/Downloads".format(os.environ['HOME'])
VEEKUN_CRY_URL = "https://veekun.com/dex/media/pokemon/cries/{}.ogg"
@brighid
brighid / words-from-int.py
Created Aug 20, 2016
Coder calisthenics: a recursive function for naming numbers
View words-from-int.py
def words_from_int(int_or_string):
"""
Given a positive integer (or a string that looks like one), returns a
string that represents the spoken American English (short scale) form of
the given number.
"""
# Numbers' names
ones_place = [None, "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"]
@brighid
brighid / create_sqlite_engine.py
Last active Sep 19, 2016
A function for passing connection parameters to SQLite in the context of SQLAlchemy. See http://stronglyemergent.com/blog/2016/how-to-make-sqlalchemy-pass-connection-flags-to-sqlite/ for explanation.
View create_sqlite_engine.py
import os.path
import re
import sqlite3
from sqlalchemy import create_engine
def create_sqlite_engine(sqlite_path,
read_only=None, create_db=None, **kwargs):
"""
Open SQLite with appropriate use of connection flags.
@brighid
brighid / open_in_chrome_incognito.scpt
Created Jun 4, 2016
A recipe for opening arbitrary links in Chrome, in an incognito window, without blowing away your existing Chrome session. License, if you care: your choice of MIT, BSDv2+, or GPLv2+.
View open_in_chrome_incognito.scpt
-- 1: Open Script Editor, make a new script, and paste this whole file in.
-- 2: Save the script as an app.
-- 3: Open the app's Contents/Info.plist
-- 4: Add the following to the top-level <dict> of the plist:
-- <key>CFBundleURLTypes</key>
-- <array>
-- <dict>
-- <key>CFBundleURLName</key>
-- <string>Web site URL</string>
-- <key>CFBundleURLSchemes</key>
@brighid
brighid / fetlife-mute-button.user.js
Last active Jul 11, 2016
A mute button you can use to sweep away haters in FetLife comment threads.
View fetlife-mute-button.user.js
// -*- mode:js2; -*-
// ==UserScript==
// @name fetlife-mute-button
// @namespace brighid
// @include https://fetlife.com/*
// @version 4
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
@brighid
brighid / vcard_generator.py
Created Nov 28, 2015
Generate a large number of vCard contacts
View vcard_generator.py
#!/usr/bin/python
"""Generates an abitrary number of valid .vcf vCard contacts based on the
parameters set at the beginning of the file. See also:
http://softwareas.com/vcard-for-developers
http://en.wikipedia.org/wiki/VCard
"""
import random, sys
@brighid
brighid / itms_music_link.rb
Created Nov 28, 2015
This is the core of an Octopress plugin that lets you put music data in posts' YAML front-matter and have a link to the iTunes Music Store show up in the post.
View itms_music_link.rb
@brighid
brighid / gist:5234382
Last active Dec 15, 2015
A brittle way to read a conf file in Clojure.
View gist:5234382
(ns my-project.core
(:require [clojure.java.io :as io])
(:import [java.io PushbackReader]))
(with-open
[r (io/reader (io/resource "bar.conf"))]
(read (PushbackReader. r)))
You can’t perform that action at this time.