Skip to content

Instantly share code, notes, and snippets.

View ttscoff's full-sized avatar
💭
Breathing

Brett Terpstra ttscoff

💭
Breathing
View GitHub Profile
@ttscoff
ttscoff / bitlyize.rb
Created October 25, 2014 22:30
Bitlyize Service/CLI to shorten links and automatically add affiliate tags
#!/usr/bin/ruby
# 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
@ttscoff
ttscoff / gifwar.sh
Created September 29, 2014 16:59
It's pronounced "GIF"
#!/bin/bash
say -v Vicki "it's pronounced gif"
say -v Zarvox "it's pronounced jiff"
while true; do
say -v Vicki "no, it's pronounced gif"
say -v Zarvox "it's pronounced jiff"
done
@ttscoff
ttscoff / im.bash
Created September 28, 2014 00:18
An experiment with calling `doing` with an "im" function to see how far natural language status updates will go. "im planning out the book structure" => `doing now @planning out the book structure` (http://brettterpstra.com/projects/doing/)
# experiment with doing
# im planning out the book structure => @planning out the book structure
# im waiting for her to call me back => @waiting for her to call me back
# im done wishing for ponies => wishing for ponies @done()
# im hungry => hungry
im() {
local verb=$1
shift
if [[ $verb =~ ing$ ]]; then
@ttscoff
ttscoff / syslinks.bash
Created September 23, 2014 18:25
A oneliner using wgrep to pull all of the PICKS from Systematic (since I started using the PICK: prefix, anyway)
@ttscoff
ttscoff / brett.theme.bash
Last active November 25, 2015 16:40
My in-progress Bash-it theme
#!/usr/bin/env bash
THEME_PROMPT_HOST='\H'
SCM_THEME_PROMPT_DIRTY=' 💢'
SCM_THEME_PROMPT_CLEAN=' 🌱'
SCM_THEME_PROMPT_PREFIX='[ '
SCM_THEME_PROMPT_SUFFIX=' ] '
export LS_COLORS='di=92:fi=0:ln=94:pi=36:so=36:bd=36:cd=95:or=34:mi=0:ex=31:*.log=1;30:*.txt=34:*.mmd=34:*.markdown=34:*.md=01;34:*.scpt=7:*.rb=35:*.tgz=93:*.gz=93:*.zip=93:*.dmg=93:*.pkg=93:*.taskpaper=95;1:*.pdf=96:*.jpg=33:*.png=33:*.gif=33:*.svg=33'
GIT_THEME_PROMPT_DIRTY=' 💢'
GIT_THEME_PROMPT_CLEAN=' 🌱'
@ttscoff
ttscoff / ezsnippets.rb
Last active March 30, 2024 21:17
ezsnippets v1, define expansions as you write (based on work by Stephen Margheim: http://www.alfredforum.com/topic/4680-snippets-on-the-fly-text-expansion/))
#!/usr/bin/ruby
=begin
# ezsnippets
Brett Terpstra 2014, MIT License
Based on a great idea by Stephen Margheim <http://twitter.com/s_margheim>
- http://www.alfredforum.com/topic/4680-snippets-on-the-fly-text-expansion/
- https://github.com/smargh/alfred_snippets
@ttscoff
ttscoff / forecast.rb
Created July 28, 2014 18:40
Quick Dark Sky forecast script for my GeekTool setup. Needs forecast_io gem and an API key, edit the coordinates as needed
#!/usr/bin/ruby
require 'rubygems'
require 'forecast_io'
ForecastIO.api_key = 'xxxxxxxxxxxx'
forecast = ForecastIO.forecast(44.047889,-91.640439)
if ARGV[0] == "current"
print "#{forecast.currently.temperature.round}, #{forecast.currently.summary}"
@ttscoff
ttscoff / td.bash
Created July 26, 2014 22:33
Bash function for creating and opening per-project TaskPaper files.
# [Create and] open project todo
# If you don't pass a name as an argument, it's pulled from the directory name
td() {
if [[ -n $1 ]]; then
proj=$1
todofile=$proj.taskpaper
else
proj=${PWD##*/}
todofile=$proj.taskpaper
fi
@ttscoff
ttscoff / whereami.sh
Created July 2, 2014 16:08
Uses get-location/CoreLocation on a Mac and Google's geocoding API to tell you the street address of your current location
#!/bin/bash
# So you know whoami, but whereami?
# Relies on this handy hack <https://github.com/lindes/get-location>
latlong=$(/usr/local/bin/get-location 2> /dev/null \
| sed -e 's/.*<\(.*\)>.*/\1/')
address=$(curl -Ss "http://maps.googleapis.com/maps/api/geocode/json?latlng=$latlong&sensor=false" \
| grep formatted_address \
| head -n 1 \
| sed -e 's/[ \t]*"formatted_address" : "\(.*\)",/\1/')
@ttscoff
ttscoff / github_toc.rb
Last active January 24, 2023 23:08
A script to generate tables of contents for GitHub readme files
#!/usr/bin/env ruby
# encoding: utf-8
=begin
github_toc v0.2.0
Brett Terpstra 2014
<http://brettterpstra.com/2014/07/01/github-toc-service/>
Creates a linked table of contents from headers in a GitHub readme
Place a [toc] marker in the file to have it automatically replaced with the TOC