Skip to content

Instantly share code, notes, and snippets.

@bennylope
bennylope / drain.rb
Last active July 12, 2018 14:31
A funky little script to download Drip broadcast messages and create Jekyll-ready Markdown files. See https://github.com/bennylope/drain.rb for updated version.
#!/usr/bin/env ruby
# A little Ruby script to download your Drip broadcast messages to Jekyll-ready
# Markdown files. These could be used as posts or, better yet, as a collection.
# Inspired by Jonathan Stark's Drain https://github.com/jonathanstark/drain/
#
# Copyright Ben Lopatin, 2018
# Shared with an MIT license: https://opensource.org/licenses/MIT
# Since this is a standalone script, installing the dependencies is your responsibility
@bennylope
bennylope / brew-cleanup.sh
Created November 22, 2017 20:44
A short script for performing brew cleanup for all but specified packages. The 'cleanup' command can either be used for specific packages or for all - there is no exclusion option - and this means cleanup on older packages that I want.
#!/usr/bin/env bash
# Clean all but specified packages of old homebrewed installed packages
declare -a exclude=(python python3 python34 python35 python36 python27 pypy ruby node)
for PACKAGE in $(brew ls)
do
SENTINEL=false
for EXCLUDE in "${exclude[@]}"
@bennylope
bennylope / conftest.py
Created March 4, 2017 18:40 — forked from asfaltboy/conftest.py
A pytest fixture to test Django data migrations
# based on https://gist.github.com/blueyed/4fb0a807104551f103e6
from django.db import connection
from django.db.migrations.executor import MigrationExecutor
import pytest
@pytest.fixture()
def migration(transactional_db):
@bennylope
bennylope / assert_close_enough.py
Created August 26, 2016 19:51
Assertion for ensuring that two values are close enough within a certain threshold, comparing on the percentage difference
class SomeTestMixin:
def assertCloseEnough(self, first, second, diff=0.0001):
"""
Asserts that the percentage difference between the two values
is smaller than given diff value.
Results may depend on the order of the values. A more robust
version might test the difference against both values.
@bennylope
bennylope / trim-movie.sh
Created May 24, 2016 22:38
A short helper script to decode QuickTime .mov files to mp4 files using default settings. Good for creating short screencasts.
#!/bin/bash
#
# A short helper script to decode QuickTime .mov files to mp4 files using default settings.
#
# Usage:
# ./trim-movie.sh path/to/source.mov path/to/destination.mp4
# ./trim-movie.sh path/to/source.mov path/to/destination.mp4 1080
#
# The optional third paramater is width. You may need to respecify this if you encounter
# divisibility by 2 errors. Not sufficiently motivated to bother checking the size and
@bennylope
bennylope / Vagrantfile
Created May 1, 2016 13:54 — forked from pansen/Vagrantfile
Jupyter (aka IPython Notebook) Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
@bennylope
bennylope / export_issues.py
Created March 22, 2016 13:13
Export GitHub issues to a Pivotal Tracker-ready CSV format
#!/usr/bin/env python3
"""
Script for exporting GitHub Issues to an import ready CSV format.
Outputs to stdout for redirection.
It is hard coded (sorry) to include up to 2 comments from an issue.
Usage:
@bennylope
bennylope / leanpub.sh
Last active January 3, 2016 17:51
A Leanpub API client script
#!/usr/bin/env bash
# Copyright 2016, Ben Lopatin
# Licensed freely to use, modify, and redistribute under GNUGPLv3
APIKEY=$LEANPUB_API_KEY
SLUG=$LEANPUB_SLUG
case "$1" in
preview)

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2: