Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Breathing

Brett Terpstra ttscoff

💭
Breathing
View GitHub Profile
@ttscoff
ttscoff / github_toc.rb
Last active Jan 24, 2023
A script to generate tables of contents for GitHub readme files
View github_toc.rb
#!/usr/bin/env ruby
# encoding: utf-8
=begin
github_toc v0.2.0
Brett Terpstra 2014
<http://brettterpstra.com/2014/07/01/github-toc-service/>
Creates a linked table of contents from headers in a GitHub readme
Place a [toc] marker in the file to have it automatically replaced with the TOC
@ttscoff
ttscoff / volumetoggle.rb
Created Sep 11, 2020
Script for macOS to save and restore audio input/output device and volume settings
View volumetoggle.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
# Brett Terpstra <https://brettterpstra.com>
#
# macOS: Stores all input/output devices and volume settings to a
# text file, restores on demand
#
## Dependencies
# SwitchAudioSource <https://github.com/deweller/switchaudio-osx>
@ttscoff
ttscoff / mindmeister_store.rb
Last active Dec 19, 2022
Store Markdown exports (as well as PDF and other formats) of all MindMeister maps in an account. See https://brettterpstra.com/2014/05/27/mirror-your-mindmeister-maps-to-nvalt/ for usage
View mindmeister_store.rb
#!/usr/bin/env ruby
require 'digest/md5'
require 'uri'
require 'net/http'
require 'yaml'
require 'rexml/document'
require 'fileutils'
require 'time'
require 'open-uri'
@ttscoff
ttscoff / Marker.js
Created Dec 22, 2013
Bookmarklet for Markdownifying webpage selections
View Marker.js
// Marker, a bookmarklet for Markdownifying webpage selections
// 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://gist.github.com/ttscoff/8078727/raw/Marker.js?x="+(Math.random());})();
(function () {
function callback() {
(function ($) {
var raw, userSelection;
if (window.getSelection) {
// W3C Ranges
userSelection = window.getSelection ();
// Get the range:
View dnsflush.md

Yosemite DNS cache flush:

sudo discoveryutil mdnsflushcache
sudo discoveryutil udnsflushcaches
@ttscoff
ttscoff / ReadingListCatcher.py
Created Jan 6, 2015
A script for exporting Safari Reading List items to Markdown files and Pinboard bookmarks
View ReadingListCatcher.py
#!/usr/bin/python
# ReadingListCatcher
# - A script for exporting Safari Reading List items to Markdown and Pinboard
# Brett Terpstra 2015
# Uses code from <https://gist.github.com/robmathers/5995026>
# Requires Python pinboard lib for Pinboard.in import:
# `easy_install pinboard` or `pip install pinboard`
import plistlib
from shutil import copy
import subprocess
@ttscoff
ttscoff / searchlink.rb
Last active Dec 3, 2022
SearchLink creates Markdown links from automatic searches based on special syntax.
View searchlink.rb
View speedmail.applescript
(*
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 / dontforget.bash
Last active Oct 18, 2022
Quick reminders from Terminal (bash)
View dontforget.bash
#!/bin/bash
# dontforget
#
# A stupid script for short term reminders in bash
#
# Arguments just need to contain a number and a bunch of words.
#
# The number can be anywhere in the arguments, but there shouldn't
# be any other numeric digits.
#
@ttscoff
ttscoff / tagfiler.rb
Last active Oct 10, 2022
Moves files to folders based on special tags in OS X Mavericks
View tagfiler.rb
#!/usr/bin/env ruby
# encoding: utf-8
# tag primary folders =Tagname
# target them with #Tagname
# tag subfolders with @nickname
# target them with :nickname
# if no tagged folder exists but there's a matching folder name, that's used
# otherwise it will create folders based on :tags
# :tags can be strung together :bt:Drafts:testing for nesting
# Only one #Tag and one :path should exist in a file's tags