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 / grab links.bookmarklet
Last active November 14, 2023 06:39
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.
View grab links.bookmarklet
@ttscoff
ttscoff / dontforget.bash
Last active November 8, 2023 06:42
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 / editscript.rb
Created July 7, 2012 01:26
Fuzzy CLI file search through configured directories, ranked results displayed as menu
View editscript.rb
#!/usr/bin/env ruby
# encoding: utf-8
# == Synopsis
# Proof of concept using Fuzzy File Finder to locate a script to edit
# Searches a set of predefined locations for a fuzzy string
# e.g. "mwp" matches both "myweatherprogram" and "mowthelawnplease"
# ................on "(m)y(w)eather(p)rogram" and "(m)o(w)thelawn(p)lease"
#
# Results are ranked and a menu is displayed with the most likely
# match at the top. Editor to be launched and directories to search
@ttscoff
ttscoff / Marker.js
Created December 22, 2013 05:19
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:
@ttscoff
ttscoff / grabicon.rb
Created October 22, 2023 20:07
Grab an iOS or Mac app icon from local version or iTunes search
View grabicon.rb
#!/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 / grabicon.rb
Last active October 22, 2023 18:10
Retrieve and process an icon for a local or App Store app
View grabicon.rb
#!/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
#
@ttscoff
ttscoff / bear_preprocessor.rb
Last active October 13, 2023 14:37
Marked Preprocessor for Bear
View bear_preprocessor.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'cgi'
input = $stdin.read.force_encoding('utf-8')
# Handle [[links]]
input.gsub!(/\[\[(?<content>.*?)\]\]/) do
m = Regexp.last_match
@ttscoff
ttscoff / appinfo.md
Last active October 13, 2023 11:19
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.
View appinfo.md

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 / namecheap_ddns.sh
Created August 26, 2021 13:22
Namecheap DDNS for Synology
View namecheap_ddns.sh
#!/bin/bash
## Namecheap DDNS updater for Synology
## Brett Terpstra <https://brettterpstra.com>
PASSWORD="$2"
DOMAIN="$3"
IP="$4"
PARTS=$(echo $DOMAIN | awk 'BEGIN{FS="."} {print NF?NF-1:0}')
@ttscoff
ttscoff / new_podcast.rb
Last active September 14, 2023 14:28
Create a new Sublime Text workspace with 4 vertical columns and starter note buffers
View new_podcast.rb
#!/usr/bin/ruby
# new_podcast.rb
# Create a new Sublime Text workspace with 4 vertical columns and starter note buffers
# Brett Terpstra 2014
# Free to use and modify (WTF license)
# Usage: new_podcast.rb episode_title
require 'fileutils'
# By default new workspaces are created in subdirs off the current directory
# modify project_root to always have them built in a specific location, (e.g. project_root = "~/Dropbox/Podcasts")