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 / idletil.fish
Created December 23, 2024 11:16
A fish function to test for minimum idle time (using beengone) before executing a command.
function idletil --description 'Wait until system idle time has reached X seconds and optionally execute command'
argparse 'h/help' 'c/command=+' -- $argv
or return
if set -q _flag_help
echo "Usage: idletil SECONDS [-c \"command to execute\"]"
echo "SECONDS may be represented as XdXhXmXs or any combination"
return 0
end
@ttscoff
ttscoff / ifgone
Created December 23, 2024 11:12
A bash script that uses beengone to test for a minimum idle time before executing a command.
#! /bin/bash
POSITIONAL_ARGS=()
t2s() {
sed 's/d/*24*3600 +/g; s/h/*3600 +/g; s/m/*60 +/g; s/s/\+/g; s/+[ ]*$//g' <<< "$1" | bc
}
display_help() {
echo "Usage: ifgone [OPTIONS] TIME"
@ttscoff
ttscoff / linkding-cards.css
Last active December 16, 2024 19:26
Custom CSS to give linkding a dark, card-based layout
/*
Card-based layout for Linkding
Large images, fully clickable
Entire card selectable in bulk edit mode
Tags moved to expandable sidebar
Author: Brett Terpstra (https://brettterpstra.com)
GitHub: @ttscoff <https://github.com/ttscoff>
License: MIT
*/
#!/usr/bin/env ruby
# Archive linkding bookmarks to Markdown files
# Can use [Gather](https://brettterpstra.com/projects/gather-cli/)
# for conversion (if installed), or use Marky
# the Markdownifier (web-based).
#
# See options below for configuration
#
# This script is designed to run once initially, and then
# be set to run in the background at intervals using cron
debug1: Remote: /Users/ttscoff/.ssh/authorized_keys:11: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /Users/ttscoff/.ssh/authorized_keys:11: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Sending command: ls
@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
@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 / grabicon.rb
Last active October 22, 2023 18:10
Retrieve and process an icon for a local or App Store app
#!/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
#!/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 / toot.rb
Last active April 28, 2023 04:58
Scans RSS feed for latest post and creates Mastodon toot
#!/usr/bin/env ruby -W1
# frozen_string_literal: true
# This script scans an RSS feed for the latest post, and if
# it hasn't already been posted to Mastodon, creates a new
# toot with a link to it.
require 'json'
require 'optparse'
require 'rss'