Skip to content

Instantly share code, notes, and snippets.

View n8henrie's full-sized avatar

Nathan Henrie n8henrie

View GitHub Profile
@n8henrie
n8henrie / fabric_keychain_passphrase.py
Created September 28, 2015 17:45
Example of how to get Fabric to automatically retrieve an SSH Passphrase from OSX Keychain
"""fabric_keychain_passphrase.py
Example of how to get Fabric to automatically retrieve an SSH Passphrase from OSX Keychain
"""
from fabric.api import *
import re
from paramiko.config import SSHConfig
@task
@n8henrie
n8henrie / annotate_requirements.sh
Created September 14, 2015 16:50
Annotates Python requirements files with metadata from PyPI
#! /bin/bash -e
# Takes a python requirements file as input and annotates each line with info from PyPI as a comment,
# outputs as file_annotated. I use it for taking one site_packages and deciding which packages I want to
# reinstall into the system python.
requirements_file=$1
filename=${requirements_file%.*}
ext=${requirements_file##*.}
outfile="$filename"_annotated."$ext"
@n8henrie
n8henrie / gen_groups.py
Created August 20, 2015 04:37
Split lines of a text file by a rule (delimiter) and add the delimiter either before or after matching chunks of text.
def gen_groups(iterable, test, to_beginning=True):
group = []
for line in iterable:
# If the line is a delimiter
if test(line):
# and you want delimiters to start groups
if to_beginning:
# And there is already a group that has
# been accumulating non-delimiters
if group:
@n8henrie
n8henrie / google_form_to_email.gs
Created August 16, 2015 21:56
Send the response content from a simple Google Form to an email address.
// google_form_to_email.gs
// Google App Script to take response content from a Google Form and send it to an email address.
// Make a publically accessible Google Form, share as a "secret link," and if desired shorten
// with a custom Bitly link (assuming you have a free domain sitting around).
// Installation: From the *form* (not the spreadsheet with the responses), copy this into
// Tools -> Script Editor. In Script Editor, set up your trigger to be "on form submit."
// Customize the values in SETUP, and customize the message if desired.
// The script will loop over all the rows in the spreadsheet except the header row, email
@n8henrie
n8henrie / .vimrc_basic
Last active June 22, 2016 16:43
My basic vim settings that should work without needing any extra packages.
set nocompatible
syntax on
set modeline
set showmode
set encoding=utf-8
set laststatus=2
" Leader is space
let mapleader="\<Space>"
@n8henrie
n8henrie / osx_tags_to_evernote.applescript
Last active November 21, 2016 17:25
Hazel script to import files with OSX tags to Evernote and preserve tags
-- Find original post here: http://n8henrie.com/2012/06/converting-openmeta-tags-to-evernote/
-- set theFile to alias "Path:To:Your:Test:File" -- uncomment this line for testing in Applescript Editor!
local targetNotebook, the_tags
--Which notebook do you want the notes to end up in? **Case Sensitive**
set targetNotebook to "Inbox"
set the_tags to paragraphs of (do shell script "mdls -raw -name kMDItemUserTags " & quoted form of POSIX path of theFile & " | sed 's/^[()]$//g' | ruby -ne 'each = $_.strip.end_with?(\",\") ? $_.strip[0...-1] : $_.strip; puts each if each != \"\"'")
@n8henrie
n8henrie / everytrail_backup.py
Created April 3, 2015 00:24
Uses the Everytrail API to back up trip info as a .csv file and all the .gpx files. Files will populate into whatever directory the script is in, so I recommend you first make an "everytrail_backup" folder, move the script there, then run.
#! /usr/bin/env python3
"""everytrail_backup.py
Uses the Everytrail API to back up trip info as a .csv file and all the
.gpx files. Files will populate into whatever directory the script is in,
so I recommend you first make an "everytrail_backup" folder, move the script
there, then run."""
import csv
import requests
import urllib.parse

Keybase proof

I hereby claim:

  • I am n8henrie on github.
  • I am n8henrie (https://keybase.io/n8henrie) on keybase.
  • I have a public key whose fingerprint is F21A 6194 C9DB 9899 CD09 E24E 434B 2C14 B8C3 3422

To claim this, I am signing this object:

  • Update HISTORY.md
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python3 setup.py develop
  • Run the tests:
python3 setup.py test
@n8henrie
n8henrie / sql_to_csv.py
Created February 11, 2015 04:05
Accepts an sql database and converts all tables to separate csv files.
#! /usr/bin/env python3
"""sql_to_csv.py
Accepts an sql database and converts all tables to separate csv files.
"""
import sqlite3
import csv
import sys
conn = sqlite3.connect(sys.argv[1])