Skip to content

Instantly share code, notes, and snippets.

@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)
@bennylope
bennylope / config.py
Created December 17, 2015 15:32
Use Fabric to manage envdir compatible configuration data
"""
Remote environment variable configuration using envdir
This should be set up using a `fabfile/` module rather than
an individual `fabfile.py` file.
$ fab <env> config -- list environment variables (incl. values)
$ fab <env> config.set:DEBUG=False -- set a single variable
$ fab <env> config.set:DEBUG=False,SECRET=jdkjkjk -- set multiple variables
@bennylope
bennylope / envcopy.py
Last active December 18, 2015 15:23
Copy the contents of a Foreman compatible .env file to an envdir compatible configuration directory
#!/usr/bin/env python
"""
Script that copies contents of .env file to envdir compatible folder
:copyright: Ben Lopatin
:license: BSD
"""
import os
import sys
@bennylope
bennylope / todo.hs
Created December 10, 2015 19:20
Vaguely terrible Haskell
-- from http://www.haskellforall.com/2015/10/basic-haskell-examples.html
import System.Directory
import System.Environment
import System.IO
putTodo :: (Int, String) -> IO ()
putTodo (n, todo) = putStrLn (show n ++ ": " ++ todo)
prompt :: [String] -> IO ()
prompt todos = do

Keybase proof

I hereby claim:

  • I am bennylope on github.
  • I am bennylope (https://keybase.io/bennylope) on keybase.
  • I have a public key whose fingerprint is 515A 85FE D3A7 9935 5E9E 2F6C CA23 6BC4 054B 7C47

To claim this, I am signing this object:

@bennylope
bennylope / todo.hs
Created October 11, 2015 15:57
Example #1: TODO program from Gabriel Gonzalez's Basic Haskell Examples
-- From http://www.haskellforall.com/2015/10/basic-haskell-examples.html
putTodo :: (Int, String) -> IO ()
putTodo (n, todo) = putStrLn (show n ++ ": " ++ todo)
prompt :: [String] -> IO ()
prompt todos = do
putStrLn ""
putStrLn "Current TODO list:"
mapM_ putTodo (zip [0..] todos)
@bennylope
bennylope / prepend.sh
Created April 6, 2015 22:34
Insertion shell script for prepending text to a file
#!/usr/bin/env sh
#
# Prepend the text from file in argument $1 to file in argument $2
#
#
# Usage, inserting license front matter into all Python files in a directory,
# including subdirectories:
#
# find . -name "*.py" -print0 | xargs -0 -n 1 ./prepend.sh frontmatter.txt
@bennylope
bennylope / pr.md
Last active August 29, 2015 14:14 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@bennylope
bennylope / heroku.sh
Last active August 31, 2015 14:01
A script to chain Heroku commands for deploying Django projects
STAGINGAPP=staging-app-name
PRODUCTIONAPP=production-app-name
case "$1" in
staging)
APPNAME=$STAGINGAPP
;;
production)
APPNAME=$PRODUCTIONAPP
;;