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 | |
APP=`echo $1|sed -e 's/\.app$//'` | |
# Removes ".app" if it was passed | |
ICON=`defaults read /Applications/$APP.app/Contents/Info CFBundleIconFile|sed -e 's/\.icns$//'` | |
# Removes ".icns" if the Info.plist has it | |
# Harcoded for /Applications, needs to be rewritten for other locations or droplets | |
## Save icon on Desktop in JPEG format, resized to 256 max width/height |
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 | |
# | |
# 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") | |
} |
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 | |
%w[fileutils ftools set zlib].each do |filename| | |
require filename | |
end | |
# Load the Marshal dump to a hash | |
def load file_name | |
begin | |
file = Zlib::GzipReader.open(file_name) |
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 | |
def e_sh(str) | |
str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''") | |
end | |
def find_headers(lines) | |
in_headers = false | |
lines.each_with_index {|line, i| | |
if line =~ /^\S[^\:]+\:( .*?)?$/ |
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 | |
# change this to your domain to have local links titled appropriately | |
my_site = "http://brettterpstra.com" | |
def e_sh(str) | |
str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''") | |
end | |
def find_headers(lines) |
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
# Adding CSS loading to dot.js Safari Extension | |
################################# | |
# /usr/local/bin/djsd line 33-42 | |
# just need to add "css" to the detect origin function | |
def detect_origin(req) | |
path = req.path | |
origin = req.header['origin'] | |
search = path.gsub('/','').gsub(/\.(js|css)$/,'') + '$' |
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
// Add to (or create) ~/Library/KeyBindings/DefaultKeyBinding.dict | |
// Incorporated change by Lri to not require additional words on the line to work | |
// fixed to handle first character of list item being non-alphanumeric | |
// Issues: | |
// If there are more than one symbols ([[, ![, etc.) at the beginning of the line, anything beyond the first one is captured and added to new line | |
// FIXED: Entering more than one blank item in a row and then using ⌘Z leaves a placeholder character on the previous line. | |
{ |
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 | |
require 'rubygems' | |
require 'wikicloth' | |
@wiki = WikiCloth::Parser.new({ :data => ARGF.read }) | |
puts @wiki.to_html |
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 | |
# ruby script to make an unordered list from indented data. | |
data = %x{__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbpaste}.strip | |
result = "<ul>\n" | |
last_leading_space = "" | |
g_tab_width = 4 |
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 | |
# scrivwatch.rb by Brett Terpstra, 2011 | |
# Modifications to merge into one file for Markdown viewing in Marked by BooneJS, 2012 | |
# Modified to use REXML and add titles by Brett Terpstra, 2012 <https://gist.github.com/1676667> | |
# | |
# Watch a Scrivener project for changes and update a preview file for Marked | |
# Usage: scrivwatch.rb /path/to/document.scriv | |
# <http://markedapp.com> | |
require 'fileutils' |