Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# Create an indented, structured CSS skeleton from valid XHTML markup
require 'rubygems'
require 'hpricot'
input = STDIN.read
def recurse_el(el,indent,parentEl)
#!/usr/bin/env osascript
-- For more info, see http://brettterpstra.com
-- Surf Saver 1.0
-- Saves tabs from Safari window to a dated page in VoodooPad, with a timestamp for the link group.
-- format of output is templatable below, defaults to markdown list.
--
-- Script by Brett Terpstra
-- http://brettterpstra.com
-- built off of the amazing Scratchpad scripts by Ian Beck
@macdrifter
macdrifter / PDFMerge.scpt
Created March 2, 2010 03:20
AppleScript that calls the python code buried in an automator action. This is example code for use with Devonthink Office Pro. The script should combine to PDF's into one new original
(* AppleScript that calls the python code buried in an automator action. This is example code for use with Devonthink Office Pro. The script should combine to PDF's into one new original *)
try
set myScript to "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" -- Path to the python script
set sourceOne to "/Path/To/First/PDF/myFile.PDF" -- First PDF
set sourceTwo to "/Path/To/Second/PDF/myFile.PDF" -- Second PDF
set myDestination to "~/final.pdf" -- The new file
#!/usr/bin/env ruby -rjcode -Ku
# From a TextMate command, but without TextMate-specific environment variables.
# Still works in TextMate, but makes a good Snow Leopard service as well.
# requires that MultiMarkdown be installed in ~/Library/Application Support/MultiMarkdown
# That, or edit the script to point to yours :)
input = STDIN.read
contents = ''
tags = ''
title = nil
#!/usr/bin/env ruby -rjcode -Ku
# TaskPaper to Markdown converter
# Usage: tp2md.rb filename.taskpaper > output.md
require 'ftools'
infile = ARGV[0]
title = File.basename(infile,'.taskpaper').upcase
output = "# #{title} #\n\n"
prevlevel = 0
begin
#!/bin/sh
# This function performs app completion (open -a) based on known applications
# Originally by Kim Holburn http://www.holburn.net/
# Modified by Brett Terpstra because it wasn't working on 10.6.
# Added case insensitivity and LC_ALL='C' because unicode chars were breaking it.
# Then I went and modified the completion command
# even though I have little idea what I'm doing.
#
# also add 'o' to complete because I alias o to "open -a"
@ttscoff
ttscoff / Quix commands for domain navigation
Created February 9, 2011 01:46
Bookmarklets for moving up or skipping to top levels of a domain, in [Quix format](http://quixapp.com/help/syntax/)
> See <http://quixapp.com/help/syntax/> for more info on Quix syntax and usage
up javascript:(function(){window.location=document.location.href.replace(/\/$/,'').split('/').slice(0,-1).join('/')+"/";})(); Move up one level in the sites directory structure
top javascript:(function(){window.location=document.location.protocol+"//"+document.location.host;})(); Jump to top level of the current site
@bagrow
bagrow / vimtex_workflow.txt
Created February 10, 2011 10:04
Some details for my macvim/skim/latexmk workflow
MacVim + latexmk + Skim workflow:
MacVim http://code.google.com/p/macvim/
Latexmk http://www.phys.psu.edu/~collins/software/latexmk-jcc/
Skim.app http://skim-app.sourceforge.net/
Open the texfile in macvim:
$ mvim <file>.tex
Watch tex file with latexmk (see also ~/.dotfiles/latexmkrc):
$ latexmk -pdf -pvc <file>.tex
-- starts listed applications
set theAppList to {"GrowlHelperApp", "LaunchBar", "Default Folder X Helper", "MercuryMoverAgent", "HardwareGrowler", "HazelHelper", "BetterTouchTool", "NetworkLocation", "LazyMouseBG", "SteerMouse Manager", "TextExpander", "Optimal Layout", "Dropbox"} as list
set theDelay to 15
set appCount to count of theAppList
repeat with currentApp in theAppList
tell application "System Events"
set isGrowlRunning to ¬
(count of (every process whose name is "GrowlHelperApp")) > 0
@ttscoff
ttscoff / pick_editor.rb
Created April 2, 2011 13:40
Returns the best running editor on a Mac, if any, based on my personal order of preference.
#!/usr/bin/ruby
#
# Returns the best running editor (Mac), if any, based on my personal order of preference.
def pick_editor
editors = ['TextMate','MacVim','Espresso','Coda','TextEdit']
ps = %x{ps Ao comm|grep .app|awk '{match($0,/([^\\/]+).app/); print substr($0,RSTART,RLENGTH)}'}.split("\n")
editors.each {|editor|
return editor if ps.include?(editor+".app")
}