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 / 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 / grabicon.rb
Last active May 2, 2024 07:53
Grab an iOS or Mac app icon from local version or iTunes search
#!/usr/bin/env ruby -W1
# frozen_string_literal: true
# Mac only
#
# Usage: grabicon.rb SEARCH TERMS [%[small|medium|large] [@[mac|ios|iphone|ipad]]
# If the search terms match a local app, that app's icon will be extracted and converted to PNG
# If the search terms don't match a local app, iTunes will be searched
# If the search terms end with "@mac", "@iphone", "@ipad", or "@ios", iTunes will be searched for a match
# If the search terms end with "%large", "%medium", "%small", or "%XXX" icon will be scaled to size
@ttscoff
ttscoff / grab links.bookmarklet
Last active April 3, 2024 19:44
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 / ezsnippets.rb
Last active March 30, 2024 21:17
ezsnippets v1, define expansions as you write (based on work by Stephen Margheim: http://www.alfredforum.com/topic/4680-snippets-on-the-fly-text-expansion/))
#!/usr/bin/ruby
=begin
# ezsnippets
Brett Terpstra 2014, MIT License
Based on a great idea by Stephen Margheim <http://twitter.com/s_margheim>
- http://www.alfredforum.com/topic/4680-snippets-on-the-fly-text-expansion/
- https://github.com/smargh/alfred_snippets
@ttscoff
ttscoff / md_to_bike.rb
Last active March 22, 2024 18:42
This script takes simple Markdown lists and converts them for use in Bike
#!/usr/bin/env ruby
# frozen_string_literal: true
# This script takes simple Markdown lists and converts them for use in
# Bike (https://www.hogbaysoftware.com/bike/), a Mac outliner app from
# Hog Bay Software.
#
# It doesn't handle nested code blocks or any non-list Markdown. It just
# turns simple lists into text Bike will recognize when it's pasted into
# a Bike document. Multiple paragraphs in a list item become additional
@ttscoff
ttscoff / tagfiler.rb
Last active March 22, 2024 18:41
Moves files to folders based on special tags in OS X Mavericks
#!/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
@ttscoff
ttscoff / appinfo.md
Last active March 4, 2024 12:00
appinfo: A quick ruby script for Mac that returns some information for a specified Mac app in Terminal. Includes icon display if using imgcat or chafa are available.

appinfo

A script for getting details of installed Mac apps. Like Get Info but faster and cooler.

Save the script below as appinfo somewhere in your path. Make it executable with chmod a+x appinfo. Then just run appinfo APPNAME to get info on any installed app.

@ttscoff
ttscoff / searchlink.rb
Last active February 26, 2024 07:05
SearchLink creates Markdown links from automatic searches based on special syntax.
@ttscoff
ttscoff / init.lua
Last active January 9, 2024 23:44
Hammerspoon config examples for hyper key
-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")
-- Trigger existing hyper key shortcuts
k:bind({}, 'm', nil, function() hs.eventtap.keyStroke({"cmd","alt","shift","ctrl"}, 'm') end)
-- OR build your own
launch = function(appname)
@ttscoff
ttscoff / bitly.rb
Created December 24, 2023 21:10
Bitlyize script for use in Bitlyize Services
#!/usr/bin/env ruby
require 'json'
require 'yaml'
# Settings is a YAML file containing `:token:` and `:domain:` keys.
settings = YAML.load(IO.read(File.expand_path('~/.config/bitly/config.yaml')))
bitly_key = settings[:token]
bitly_domain = settings[:domain]
debug = false