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 / DefaultKeyBinding.dict
Created August 2, 2012 15:09
Keybinding for multiple kill rings
// > defaults write -g NSTextKillRingSize -string 6
// replace yank: command with yankAndSelect for use with the kill ring
"^y" = (yankAndSelect:);
@ttscoff
ttscoff / campl.us_partial.rb
Created August 3, 2012 04:12
Very partial code for parsing out campl.us urls and finding source image url
require 'net/http'
# in the main tweet parser. tweet_text is the status.text string
# match short campl.us urls:
if tweet_text =~ /\((http:\/\/campl.us\/\w+?)\)/
picurl = $1
# grab the source and parse out the full size image url
final_url = get_body(picurl).match(/"(http:\/\/pics.campl.us\/f\/c\/.+?)"/)
return false if final_url.nil?
@ttscoff
ttscoff / gistloggertest.txt
Created August 4, 2012 15:21
Just testing the Gist logger for Day One
The standard CGI environmental variables are available as read-only attributes of a CGI object. The following is a list of these variables:
AUTH_TYPE HTTP_HOST REMOTE_IDENT
CONTENT_LENGTH HTTP_NEGOTIATE REMOTE_USER
CONTENT_TYPE HTTP_PRAGMA REQUEST_METHOD
GATEWAY_INTERFACE HTTP_REFERER SCRIPT_NAME
HTTP_ACCEPT HTTP_USER_AGENT SERVER_NAME
HTTP_ACCEPT_CHARSET PATH_INFO SERVER_PORT
HTTP_ACCEPT_ENCODING PATH_TRANSLATED SERVER_PROTOCOL
HTTP_ACCEPT_LANGUAGE QUERY_STRING SERVER_SOFTWARE
@ttscoff
ttscoff / keys.m
Created August 5, 2012 14:48
Command line utility for checking whether a modifier key is held
#import <Carbon/Carbon.h>
// `keys` utility for checking whether a modifier key is held
// From <http://lists.apple.com/archives/applescript-users/2009/Sep/msg00374.html>
//
// $ clang keys.m -framework Carbon -o keys
int main (int argc, const char * argv[]) {
unsigned int modifiers = GetCurrentKeyModifiers();
if (argc == 1)
@ttscoff
ttscoff / Launch All in Dock.applescript
Created August 5, 2012 14:58
Launch all Dock apps with exclusions based on modifier keys
-- Launch All in Dock.applescript
-- Brett Terpstra 2012
--
-- Modified version of an AppleScript to launch all
-- persistent (Keep in Dock) apps[^1]. Allows you to exclude
-- apps based on modifier keys held when it runs.
--
-- Uses the `keys` utility found on the Apple Mailing Lists[^2].
@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 / skypevolume.md
Created September 7, 2012 16:23
Skype Volume Tip
@ttscoff
ttscoff / nvAIR.rb
Created September 29, 2012 17:43
If you've ever wondered whether I have psychological issues, see what happened to this script before I even finished it.
#!/usr/bin/env ruby
# encoding: utf-8
# nvAir: a First Class way to use nvALT/Notational Velocity with the worst documentation ever!
# Built by: Brett Terpstra, <http://brettterpstra.com>
# Destination: WikiLinks and [[wiki links]] to nvALT notes from anywhere on your system.
# This script is at your Service. (You can make it into a System Service with Automator, I mean).
#
# Security line is short today! Please have a photo id in hand. |
# I just need to see your ticket and the folder where you store your note files. o_________(_)________o
$notes_path = '~/Dropbox/nvALT2.2/' # o^o X \_/ X o^o
@ttscoff
ttscoff / imgtag.rb
Created October 9, 2012 17:45
Create image tag using sips
#!/usr/bin/ruby
img = ARGV[0]
width = %x{sips -g pixelWidth #{img}|tail -n 1}.gsub(/pixelWidth: /,'').strip
height = %x{sips -g pixelHeight #{img}|tail -n 1}.gsub(/pixelHeight: /,'').strip
output = %Q{<img src="#{File.basename(img)}" style="width:#{width}px;height:#{height}px">}
print output
@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);