Skip to content

Instantly share code, notes, and snippets.

View stephenhowells's full-sized avatar
🏜️
In the desert

Stephen Howells stephenhowells

🏜️
In the desert
View GitHub Profile
@stephenhowells
stephenhowells / no_widows.exs
Created December 23, 2015 22:38
Remove widows from blog post titles by adding a non breaking space in Elixir.
defmodule Text do
def widows(some_str) do
title_list = some_str |> String.split(" ") |> Enum.map(&String.capitalize/1)
title_str = Enum.join(title_list, " ")
if Enum.count(title_list) > 2 do
String.replace(title_str, ~r/\s+\S*$/, "&nbsp;" <> List.last(title_list))
else
title_str
end
end
#!/bin/bash
# Encode a WAV to a finalized podcast MP3 with metadata, in the current directory
# Requires lame
# With Homebrew on Mac OS X: brew install lame
SHOW_AUTHOR="ATP"
EPISODE_NUMBER=104
EPISODE_TITLE="Minutiæ"
@stephenhowells
stephenhowells / Markdown.sublime-settings
Created October 17, 2014 15:15
Syntax specific settings for Markdown files in Sublime Text 3 using the Markdown Editing package.
{
"extensions":
[
"markdown",
"md",
"mdown",
"txt"
],
"wrap_width": 80,
"font_size": 15,

Keybase proof

I hereby claim:

  • I am stephenhowells on github.
  • I am howells (https://keybase.io/howells) on keybase.
  • I have a public key whose fingerprint is 5B56 3BC1 82E1 B949 0D8D C359 4901 4837 D2FF E5EA

To claim this, I am signing this object:

//## Moment.JS Holiday Plugin
//
//Usage:
// Call .holiday() from any moment object. If date is a US Federal Holiday, name of the holiday will be returned.
// Otherwise, return nothing.
//
// Example:
// `moment('12/25/2013').holiday()` will return "Christmas Day"
//
//Holidays:
#! /usr/bin/python
from sys import argv
from os.path import exists
from os import makedirs
from os import symlink
from os import system
import getopt
#
@stephenhowells
stephenhowells / Gruntfile.js
Created January 26, 2014 00:22
LiveReload in Both Gulp and Grunt
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
livereload: {
files: ['_site/*'],
options: {
livereload: true
}
},
@stephenhowells
stephenhowells / powerline.sh
Last active January 3, 2016 17:48
The Powerline install process for OS X 10.10
#!/usr/bin/env bash
# Check that /usr/local/bin comes before /usr/bin in your PATH
brew install python
brew install cmake
brew install libgit2
#! /usr/bin/python
from sys import argv
from os.path import exists
from os import makedirs
from os import symlink
import getopt
#
# Show Usage, Output to STDERR
@stephenhowells
stephenhowells / gist:6718627
Created September 26, 2013 18:38
Python Script to generate a policy and signature. Useful when using CORS uploads to S3.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import base64, hmac, sha
private_key = 'YOUR PRIVATE KEY'
input = open("policy.txt", "rb")
policy = input.read()
policy_encoded = base64.b64encode(policy)
signature = base64.b64encode(hmac.new(private_key, policy_encoded, sha).digest())