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 / searchlinkoutput.md
Created October 16, 2012 15:53
SearchLink output
  • A search for specified text: [Marked][1].
  • A simple software search for [Fantastical][2].
  • A simple google search [neat neat neat][3]
  • A Last.fm track search [neat neat neat][4] (with specified search terms)
  • Mac app store search: [Marked on the MAS][5]
  • Mac App Store search [Marked direct][1] with direct dev site link.
  • iTunes app search: [Boost 2][6]
  • iTunes search, direct dev site link: [Boost direct][6]
  • This search: [Purple][7] will have its link text filled in with the title of the first result.
  • This is a wikipedia entry for [Sid Vicious][8]
@ttscoff
ttscoff / searchlink.rb
Last active February 20, 2025 10:07
SearchLink creates Markdown links from automatic searches based on special syntax.
@ttscoff
ttscoff / formd-pythonista.py
Created October 17, 2012 18:24
A modified version of formd for use with Pythonista on iOS
# encoding=utf8
"""
formd by Seth Brown, 02-24-12
modified for iOS use (Pythonista) by Brett Terpstra, 10-17-12
"""
from sys import stdin, stdout
import clipboard
import re
from collections import OrderedDict
@ttscoff
ttscoff / GoogleSearch.py
Created October 17, 2012 22:55 — forked from omz/GoogleSearch.py
GoogleSearch
# Google Search for Pythonista (iOS)
# Searches Google and copies the first result to the clipboard as
# a Markdown link in the form [title](url).
#
# Inspired by Brett Terpstra's SearchLink:
# http://brettterpstra.com/searchlink-automated-markdown-linking-improved/
import clipboard
def google(terms):
@ttscoff
ttscoff / octopress.js
Created October 19, 2012 01:53
Quick function to check viewport size and chop/crop images (CSS3) for mobile views.
var bt = {}; // to call the functions outside of the jQuery wrapper because OctoPress is a bit of a JS mess. Hey, that rhymes.
(function($){
bt = {
checkWinWidth: function() {
var width = $(window).width();
if (width <= 500) {
if (!$('body').hasClass('mobile')) {
$('img').each(function(){
var $this = $(this);
@ttscoff
ttscoff / coughscraps.md
Created October 20, 2012 20:34
First draft of an iPhone-controlled cough button for my Mac

Rough start: iPhone cough button for Mac

Video: http://ckyp.us/mLi+

Not all that smart yet, but a little jQuery with Hammer.js:

	(function($){
		window.scrollTo(0,1);
 $("#cough")
@ttscoff
ttscoff / galleryimport.rb
Created October 22, 2012 13:18
Routine to replace [gallery] shortcodes during Jekyll WordPress import
# create a 150x150 thumbnail of the passed image using `sips`
# img is an absolute path to the base image file
def thumbnail_image(img)
return_dir = Dir.pwd
Dir.chdir(File.dirname(img))
width = %x{sips -g pixelWidth #{img.strip}|tail -n 1}.gsub(/pixelWidth: /,'').strip.to_i
height = %x{sips -g pixelHeight #{img.strip}|tail -n 1}.gsub(/pixelHeight: /,'').strip.to_i
thumb_name = img.strip.gsub(/^(.*?)(\..{3,4})$/,"\\1-150x150\\2").strip
thumb = File.expand_path(thumb_name)
FileUtils.cp(File.expand_path(img),thumb)
@ttscoff
ttscoff / todo.rb
Created October 22, 2012 14:16
Ruby function to find the first TaskPaper project matching a title fragment
def first_matching_project(fragment)
%x{osascript <<'APPLESCRIPT'
tell application "TaskPaper"
tell front document
set projectlist to name of projects
set frag to "#{fragment}"
repeat with aproject in projectlist
if (offset of "#{fragment}" in aproject) > 0 then return (aproject as string)
end repeat
return "Inbox"
@ttscoff
ttscoff / Chrome.applescript
Created October 23, 2012 18:50
AppleScript to reset font server and launch Chrome, avoiding bad font issues.
tell application "Google Chrome" to quit
do shell script "atsutil server -shutdown"
set _running to missing value
repeat until _running is equal to "ATSServer is running"
set _running to do shell script "atsutil server -ping"
delay 1
end repeat
@ttscoff
ttscoff / com.brettterpstra.slogger.plist
Created November 2, 2012 20:40
slogger "since" argument
<key>ProgramArguments</key>
<array>
<string>/path/to/slogger</string>
<string>-s</string>
</array>