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 / Dropzone Image Filer.dropzone.rb
Last active March 22, 2020 10:31
Dropzone Destination for filing images to a Jekyll uploads folder and returning Markdown links to relative paths
#!/usr/bin/ruby
# Dropzone Destination Info
# Name: Jekyll Image Filer
# Description: Files images in a Jekyll repo
# Handles: NSFilenamesPboardType
# Creator: Brett Terpstra
# URL: http://brettterpstra.com
# IconURL: http://brettterpstra.com/destinations/icons/jekyllfiler.png
# OptionsNIB: ChooseFolder
@ttscoff
ttscoff / Jekyll Filer.rb
Last active April 18, 2020 19:15
OS X System Service script for filing Jekyll images and putting Markdown links on the clipboard
require 'fileutils'
# An OS X System Service for quickly filing image files to a Jekyll blog folder,
# putting Markdown links to the files on the clipboard.
# Copyright Brett Terpstra 2013
# Config
# ======
# Where to store the images
base_path = '~/Sites/dev/octopress/source/uploads/'
@ttscoff
ttscoff / webexcursions.rb
Created January 14, 2013 11:20
A script for gathering new Pinboard links with a certain tag and generating Markdown/Jekyll posts when enough are collected.
#!/usr/bin/ruby
# WebExcursions, a script for gathering new Pinboard links with a certain tag
# and generating Markdown/Jekyll posts when enough are collected.
# Brett Terpstra 2013
#
# -f to force writing out current bookmarks to file regardless of count
%w[fileutils set net/https zlib rexml/document time base64 uri cgi stringio].each do |filename|
require filename
end
@ttscoff
ttscoff / 5by5 Episode Link Grabber.md
Last active December 11, 2015 02:19
Browser bookmarklet which generates a Markdown list of all the show links on a 5by5 episode page, autoselects the result for copying and provides next/prev navigation
@ttscoff
ttscoff / cliptextfile.sh
Created January 15, 2013 15:12
Copy the contents of any text file to the clipboard, intended for use as an OS X System Service
# A stupid script that actually makes a handy system service
# Use it to right click files and extract their text content to the clipboard
# Brett Terpstra 2013, no rights reserved
txtcount=`file "$@"|grep -c text`
response=0
msg=""
if [ $txtcount -eq $# ]; then
cat "$@"|pbcopy
if [ "$?" -ne "0" ]; then
msg="Error running command"
@ttscoff
ttscoff / DefaultKeyBinding.dict
Created January 16, 2013 21:08
Add a shortcut to restore Save As... in Mountain Lion to any application.
{
// Real, honest-to-goodnes Save As...
// Create or add to ~/Library/KeyBindings/DefaultKeyBinding.dict
"@~S" = (saveAs:);
}
@ttscoff
ttscoff / git-ar
Created January 18, 2013 01:08
One liner for adding/removing git changes quickly
alias gitar='git ls-files -d -m -o -z --exclude-standard | xargs -0 git update-index --add --remove'
! --- ~/.Xresources ------------------------------------------------------------
! ------------------------------------------------------------------------------
! --- generated with 4bit Terminal Color Scheme Designer -----------------------
! ------------------------------------------------------------------------------
! --- http://ciembor.github.com/4bit -------------------------------------------
! ------------------------------------------------------------------------------
! --- special colors ---
*background: #12161b
@ttscoff
ttscoff / download.rb
Created January 24, 2013 14:55
Jekyll tag for creating "download cards"
# Title: Download tag for Jekyll
# Author: Brett Terpstra http://brettterpstra.com
# Description: Create updateable download cards for downloadable projects. Reads from a downloads.csv file in the root folder
#
# Example: {% download id %} to read download [id] from the CSV
module Jekyll
class DownloadTag < Liquid::Tag
require 'csv'
@ttscoff
ttscoff / Rakefile.rb
Created January 24, 2013 14:58
Rake task to locate and display a download ID from downloads.csv
desc "Find a download ID"
task :find_download, :term do |t, args|
raise "### You haven't created a download csv yet." unless File.exists?('downloads.csv')
results = CSV.read("downloads.csv").delete_if {|row|
row[0].strip =~ /^\d+$/ && row[1] + " " + row[4] =~ /.*#{args.term}.*/i ? false : true
}
results.sort! { |a,b|
a[0].to_i <=> b[0].to_i
}.map! { |res|
res[0] + ": " + res[1] + " v" + res[3]