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 / bt-mark.txt
Created May 7, 2013 16:06
BT Ascii Mark 2
# Binary Sig. Because I'm avoiding doing other things
# 100000
# 100000
# 100000
# 100000
# 100000
# 100000
# 10000000000000:.
# 10000000000::
@ttscoff
ttscoff / skypecall.rb
Last active February 20, 2025 09:55
Dial a phone number detected in text with Skype. Part of a [PopClip Extension](https://github.com/ttscoff/popclipextensions).
#!/usr/bin/ruby
input = ENV['POPCLIP_TEXT']
# use a regex to locate all phone numbers
phone_numbers = input.scan(/(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?/)
# send the first one to Skype via AppleScript (osascript)
%x{/usr/bin/osascript -e 'set _cmd to "CALL #{phone_numbers[0].join("")}"' -e 'tell application "Skype" to send command _cmd script name "PCDIALER"'}
@ttscoff
ttscoff / finddayone.rb
Last active December 18, 2015 05:29
Locate your Day One entries folder
#!/usr/bin/ruby
require 'shellwords'
dayonedir = %x{ls ~/Library/Mobile\\ Documents/|grep dayoneapp}.strip
full_path = File.expand_path("~/Library/Mobile\ Documents/#{dayonedir}/Documents/Journal_dayone/entries")
if File.exists?(full_path)
system "echo \"#{Shellwords.escape(full_path)}\"|tr -d '\n'|pbcopy"
puts full_path
puts "Escaped version of your Day One entries path is in your clipboard."
@ttscoff
ttscoff / grab links.bookmarklet
Last active February 20, 2025 09:55
Create a bookmark and paste the code from `grab links.bookmarklet` into the url. Trigger it on a page containing links you want to save and then click the section of the page containing the links. A Markdown list of all links will be generated, and clicking the resulting list will select all for copying.
@ttscoff
ttscoff / customthumbs.sh
Created July 4, 2013 03:48
Create custom thumbnail icons from a file's Quick Look preview on OS X
#!/bin/bash
target=$1
filename=`basename $1`
image="${TMPDIR}${filename}.png"
rsrc="${TMPDIR}icn.rsrc"
# Create a thumbnail from the file preview
qlmanage -t -s 512 -o ${TMPDIR} $target
@ttscoff
ttscoff / a_lazy_youtube_tag.rb
Last active February 20, 2025 09:55
My current setup for embedding YouTube videos in Jekyll. Responsive layout, poster image first/click to load for faster page loads.Provides a `{% youtube VIDEOID 800 600 "optional caption" %}` tag that generates the markup needed for the CSS and jQuery script.
# Title: Responsive Lazy Load YouTube embed tag for Jekyll
# Author: Brett Terpstra <http://brettterpstra.com>
# Description: Output a styled element for onClick replacement with responsive layout
#
# Syntax {% youtube video_id [width height] ["Caption"] %}
#
# Example:
# {% youtube B4g4zTF5lDo 480 360 %}
# {% youtube http://youtu.be/2NI27q3xNyI %}
@ttscoff
ttscoff / WebDev.savedSearch.xml
Last active February 20, 2025 09:55
It was supposed to search for a variety of filetypes with web design-related tags. It was being really spotty until I manually set FinderFilesOnly to false in the PLIST.
<key>RawQueryDict</key>
<dict>
<key>FinderFilesOnly</key>
<false/>
<key>RawQuery</key>
<string>(true) &amp;&amp; (((InRange(kMDItemContentCreationDate,$time.today(-1Y),$time.today(+1d)) &amp;&amp; ((kMDItemOMUserTags = "*jquery*"cd) || (kMDItemOMUserTags = "*javascript*"cd) || (kMDItemOMUserTags = "*responsive*"cd) || (kMDItemOMUserTags = "*webdesign*"cd) || (kMDItemOMUserTags = "*webdev*"cd) || (kMDItemOMUserTags = "html5*"cdw) || (kMDItemOMUserTags = "*css3*"cd) || (kMDItemKeywords = "*jquery*"cd) || (kMDItemKeywords = "*javascript*"cd) || (kMDItemKeywords = "*responsive*"cd) || (kMDItemKeywords = "*webdesign*"cd) || (kMDItemKeywords = "*webdev*"cd) || (kMDItemKeywords = "*html5*"cd) || (kMDItemKeywords = "*css3*"cd)) &amp;&amp; (((kMDItemKind = "Web*"cdw) &amp;&amp; ((kMDItemKind = "Internet*"cdw) &amp;&amp; (kMDItemKind = "Location*"cdw))) || (kMDItemKind = "Markdown*"cdw) || ((kMDItemKind = "Delish*"cdw) &amp;&amp; (kMDItemKind = "Bookmark*"cdw)) || (_kMDItemGroupId = 11)))))</string>
<key>SearchSco
@ttscoff
ttscoff / Bullseye.bookmarklet
Last active February 20, 2025 09:55
A bookmarklet for grabbing just a piece of a web page and converting it to Markdown using heckyesmarkdown.com.
javascript:(function(){var p=document.createElement("p");p.innerHTML="<strong>Loading&hellip;</strong>";p.id="loadingp";p.style.padding="20px";p.style.background="#fff";p.style.left="20px";p.style.top=0;p.style.position="fixed";p.style.zIndex="9999999";p.style.opacity=".85";document.body.appendChild(p);document.body.appendChild(document.createElement("script")).src="https://cdn.rawgit.com/ttscoff/6109434/raw/Bullseye.js?x="+(Math.random());})();
@ttscoff
ttscoff / mmoutline2md.rb
Created August 22, 2013 14:37
Convert a Mindjet MindManager text outline export to Markdown
#!/usr/bin/env ruby
input = STDIN.read
input.gsub!(/^\=+\n ?(.*?)\n\=+/,"# \\1")
input.gsub!(/^-+\n\d+ (.*?)\n-+/,"## \\1")
input.gsub!(/^\d+\.\d+ (.*)/,"### \\1")
input.gsub!(/^\d+\.\d+\./,"@")
input.gsub!(/^@\d+ /,"- ")
input.gsub!(/^@\d+\.\d+ /,"\t- ")
@ttscoff
ttscoff / curio2md.rb
Created August 24, 2013 09:32
Quick conversion to Markdown for Curio list text output (Copy As Plain Text)
#!/usr/bin/ruby
# encoding: utf-8
# Quick conversion to Markdown for Curio list text output (Copy As Plain Text)
# Separates notes into subparagraphs, builds headers and lists based on max_headers setting
# You can insert a line at the top with "max headers: 5" to override the default setting for that text
# Usage:
# pbpaste|curio2md.rb > markdown_file.md
# Also works as a system service
max_headers = 3