Skip to content

Instantly share code, notes, and snippets.

View ttscoff's full-sized avatar

Brett Terpstra ttscoff

View GitHub Profile
ttscoff / gen_random_filename.bash
Last active August 29, 2015 14:02
Bash function to generate random 2-word underscore strings for filenames. Uses aspell and shuf (gnu coreutils).
View gen_random_filename.bash
# Bash function gen_random_filename
# Description: Generates random two-word names
# Requires a dictionary file, easily generated with `aspell dump master > dictionary.txt`
# or grab it from
# Requires shuf (brew install coreutils)
# Example results:
# darkest_pickpockets
# besets_struts
# unzip_Malone
ttscoff / bitlyize.rb
Created October 25, 2014 22:30
Bitlyize Service/CLI to shorten links and automatically add affiliate tags
View bitlyize.rb
# encoding: utf-8
# Bitlyize by Brett Terpstra 2014
# Shortens all URLs in input and automatically adds Amazon and iTunes affiliate codes
# A single bitly link passed to this script will return the long url
# This script was designed for use in an OS X System Service, but runs
# as a CLI and can be included as a Ruby library in other scripts
# The bitly_username and bitly_key variables are required
# Optionally configure the custom domain, and itunes and amazon affiliate variables
View a.txt
# Overtired 26
Brett and Christina skip CES to reminisce about Mean Girls. Yeah, Taylor Swift came up, but we didn't dwell on it. We're growing.
From drunken, -20° snow shoveling to watching some great new movies by the fire, this is a mid-winter show that has it all. Don't they always, though? Jack of all trades, master of, well, we're pretty good at pop culture...
## Links
* [The amazing Taylor Swift mashup of the two best songs from 1989](
* [Regarding the Gossip Girl and Tech Overlap](
View Songza Lucky Link TextMate Command
View Songza Link Selection (TextMate Command)
View NerdTool RSS Script
#!/usr/bin/env ruby -rjcode -Ku
require 'rss/2.0'
require 'open-uri'
require 'time'
class RSSFetcher
RED = "\033[1;31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
View TextMate Drag Command for Base64-encoded images in CSS
# Drag command set to handle: jpg,png,gif
# scoped to: text.html.basic source.css.embedded.html, source.css
openssl base64 -in "$TM_DROPPED_FILE" | awk -v ext="${TM_DROPPED_FILE#*.}" '{ str1=str1 $0 }END{ print "background:url(data:image/"ext";base64,"str1");" }'
ttscoff / DefaultKeyBinding.dict
Created November 8, 2011 23:45
Flexible DefaultKeyBinding trick to continue plain text lists
View DefaultKeyBinding.dict
// Add to (or create) ~/Library/KeyBindings/DefaultKeyBinding.dict
// Incorporated change by Lri to not require additional words on the line to work
// fixed to handle first character of list item being non-alphanumeric
// Issues:
// If there are more than one symbols ([[, ![, etc.) at the beginning of the line, anything beyond the first one is captured and added to new line
// FIXED: Entering more than one blank item in a row and then using ⌘Z leaves a placeholder character on the previous line.
ttscoff / doc2mmd.rb
Created February 5, 2012 17:53
rough draft of a Markdown converter for .doc files
View doc2mmd.rb
# doc2mmd.rb
# rough draft of a Markdown converter for .doc files
# requires python html2text, edit path in last shell call
def e_sh(str)
str.to_s.gsub(/(?=["\\])/, '\\')
ARGV.each {|f|
ttscoff / hamlet.js
Created February 9, 2012 21:42
To be or not to be...
View hamlet.js
#!/bin/shakespeare -hamlet
function suffer() {
outrageous_fortune = true;
return false;
function oppose() {
if (take_arms(sea_of_troubles)) sleep;