This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Marked 2 preprocessor | |
# Search a concatenated Marked index file for include comments and adjust | |
# [[image.jpg]] tags to point to paths relative to included file | |
# Update: Converts [[tags]] to Markdown image tags using the generated paths | |
input = STDIN.read | |
includes = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# new_podcast.rb | |
# Create a new Sublime Text workspace with 4 vertical columns and starter note buffers | |
# Brett Terpstra 2014 | |
# Free to use and modify (WTF license) | |
# Usage: new_podcast.rb episode_title | |
require 'fileutils' | |
# By default new workspaces are created in subdirs off the current directory | |
# modify project_root to always have them built in a specific location, (e.g. project_root = "~/Dropbox/Podcasts") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In my tag-filing system where top-level "context" folders are tagged with | |
# "=Context" tags and subfolders are tagged with "@project" tags, this function | |
# lets me quickly cd to any tagged folder in my filing system. The first | |
# argument is a context folder, the rest are a chain of subfolders. The | |
# subfolders don't need to be contiguous, and the matching is fuzzy. | |
cdt() { | |
local fuzzy | |
local root | |
local sub | |
local list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bash function gen_random_filename | |
# Description: Generates random file names | |
# Requires shuf (brew install coreutils) | |
# Requires a list of adjectives and nouns (1 per line) | |
gen_random_filename() { | |
local adjs=~/words/adjectives.txt | |
local nouns=~/words/nouns.txt | |
local adj noun title starts_with_1 starts_with_2 counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 https://gist.githubusercontent.com/ttscoff/55493fe89c35ec1588ba/raw/ | |
# Requires shuf (brew install coreutils) | |
# | |
# Example results: | |
# darkest_pickpockets | |
# besets_struts | |
# unzip_Malone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A custom preprocessor for Marked 2 that will export two files after Marked | |
# does initial inclusion and processing, then cancel the processor and have | |
# Marked resume processing. | |
# Install the latest version of MultiMarkdown: | |
# http://fletcherpenney.net/multimarkdown/download/ | |
function main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'digest/md5' | |
require 'uri' | |
require 'net/http' | |
require 'yaml' | |
require 'rexml/document' | |
require 'fileutils' | |
require 'time' | |
require 'open-uri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_tm_complete() { | |
local rx | |
local token=${COMP_WORDS[$COMP_CWORD]} | |
local IFS=$'\t' | |
local words | |
if [ $COMP_CWORD -eq 2 ]; then | |
words=$(tmux list-windows -t ${COMP_WORDS[1]} 2> /dev/null | awk '{print $2}' | tr -d '*-' | tr "\n" "\t") | |
elif [ $COMP_CWORD -eq 1 ]; then | |
words=$(tmux -q list-sessions 2> /dev/null | cut -f 1 -d ':' | tr "\n" " ") | |
fi |