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 / markdownediting_headlines.sublime-keymap
Created August 22, 2012 02:30
Markdown headlines for Sublime Text 2
// Keybinding for Sublime Text to wrap selection in hashmarks with padding space, incrementally up to six marks
{ "keys": ["#"], "command": "insert_snippet", "args": {"contents": "#${0: ${SELECTION/(^ | $)//g} }#"}, "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "#{6}", "match_all": true }
]
}
@ttscoff
ttscoff / luckyduck.rb
Created August 22, 2012 03:50
Markdown Lucky Link from DuckDuckGo
#!/usr/bin/ruby
# Where have all the search API's gone, long time passing
# Where have all the search API's gone, long time ago
# Where have all the search API's gone, gone to graveyards every one
# When will they ever learn?
#
# Inelegantly uses DuckDuckGo's "\" lucky link search and
# scrapes the url from the redirect in the result
#
# $ luckyduck.rb "search term"
@ttscoff
ttscoff / luckyduck.rb
Created August 22, 2012 11:10
Get first web search result as Markdown link
#!/usr/bin/ruby
require 'net/http'
def e_url(string)
string.gsub(/([^a-zA-Z0-9_.-]+)/n) do
'%' + $1.unpack('H2' * $1.size).join('%').upcase
end
end
def do_search(phrase)
@ttscoff
ttscoff / slogger_config.yaml
Created August 24, 2012 04:45
Slogger config
---
storage: icloud
FlickrLogger:
flickr_description:
- Logs today's photos from Flickr.
- Get your Flickr ID at <http://idgettr.com/>
- Get your Flickr API key at <http://www.flickr.com/services/apps/create/noncommercial/>
flickr_api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
flickr_ids:
- 45323279@N00
[Skype volume tip](http://onemansblog.com/2010/05/18/stop-skype-from-auto-adjusting-microphone-volume-on-mac-disable-auto-gain-control-acg/)
<VoiceEng>
<AGC>0</AGC>
<MicVolume>77</MicVolume>
</VoiceEng>
@ttscoff
ttscoff / skypevolume.md
Created September 7, 2012 16:23
Skype Volume Tip
@ttscoff
ttscoff / speedmail.applescript
Last active March 23, 2025 03:08
Speed up Mail.app
(*
Speed up Mail.app by vacuuming the Envelope Index
Code from: http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/
Originally by "pmbuko" with modifications by Romulo
Updated by Brett Terpstra 2012
Updated by Mathias Törnblom 2015 to support V3 in El Capitan and still keep backwards compability
Updated by @lbutlr for V5 and Container folder in High Sierra and use du
*)
tell application "Mail" to quit
@ttscoff
ttscoff / matrixish.sh
Created September 15, 2012 18:23
A Matrix-ish display for Bash terminal
#!/bin/bash
#
# matrix: matrix-ish display for Bash terminal
# Author: Brett Terpstra 2012 <http://brettterpstra.com>
# Contributors: Lauri Ranta and Carl <http://blog.carlsensei.com/>
#
# A morning project. Could have been better, but I'm learning when to stop.
### Customization:
blue="\033[0;34m"
@ttscoff
ttscoff / flavor.rb
Created September 16, 2012 16:01
Quick wrapper to convert Markdown to HTML via Github API
#!/usr/bin/ruby
# Convert a Markdown README to HTML with Github Flavored Markdown
# Github and Pygments styles are included in the output
#
# Requirements: json gem (`gem install json`)
#
# Input: STDIN or filename
# Output: STDOUT
# Arguments: "-c" to copy to clipboard (or "| pbcopy"), or "> filename.html" to output to a file
# cat README.md | flavor > README.html
@ttscoff
ttscoff / unique-footnotes.rb
Created September 21, 2012 01:11
Replace MMD3 footnote ids and references with unique, timestamp-based references
ARGF.each do |input|
random = Time.now.strftime('%s')
print input.gsub(/(fn(ref)?):(\d+)/, "\\1#{random}-\\3")
end