Skip to content

Instantly share code, notes, and snippets.

View ttscoff's full-sized avatar
💭
Breathing

Brett Terpstra ttscoff

💭
Breathing
View GitHub Profile
@fnky
fnky / ANSI.md
Last active May 12, 2024 13:47
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@ttscoff
ttscoff / font_grabber.rb
Last active May 13, 2021 06:14
Give it a <link> from Google fonts and get back CSS with fonts embedded
#!/usr/bin/ruby
# encoding: utf-8
# Grab google web fonts and embed them as base64 data URIs
# <http://brettterpstra.com/2015/03/14/embedding-google-web-fonts/>
require 'base64'
if ARGV.length > 0
input = ARGV
elsif STDIN.stat.size > 0
input = STDIN.read.strip.split(/\n+/)

Yosemite DNS cache flush:

sudo discoveryutil mdnsflushcache
sudo discoveryutil udnsflushcaches
@visualskyrim
visualskyrim / template.html
Created January 21, 2015 11:01
Lopash nvAlt template with fenced code block enabled
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{%title%}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
@ttscoff
ttscoff / ReadingListCatcher.py
Created January 6, 2015 15:59
A script for exporting Safari Reading List items to Markdown files and Pinboard bookmarks
#!/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 / sizeup.bash
Created January 5, 2015 16:48
A shell function for viewing file sizes and totals within a nested directory structure
__sizeup_build_query () {
local bool="and"
local query=""
for t in $@; do
query="$query -$bool -iname \"*.$t\""
bool="or"
done
echo -n "$query"
}
@mrfabbri
mrfabbri / fsa.py
Last active August 29, 2015 14:11 — forked from danielpunkass/fsa.py
"""
Automate loading of F-Script Anywhere into any app.
By Daniel Jalkut - @danielpunkass - http://indiestack.com/
Revision 0.2 by Marco Fabbri - @mrfabbri - mrfabbri@gmail.com
To set up:
0. Make sure you have FScript.framework installed in /Library/Frameworks (http://www.fscript.org)
1. Copy this script to ~/.lldb/fsa.py
2. Add the following to your ~/.lldbinit file:
@ttscoff
ttscoff / Automator Workflow.sublime-build
Last active October 22, 2018 21:38
A script to take input on STDIN and update a specified Automator (OS X) workflow action with it
{
"shell_cmd": ["cat", "$file", "|", "/usr/bin/ruby", "/Users/ttscoff/scripts/update_workflow.rb"]
}
@ttscoff
ttscoff / image_re.m
Created November 6, 2014 17:18
Regex for Markdown images
@"(?:\\(|:\\s+)(?!http)([^\\s]+\\.(?:jpe?g|gif|png|svg|pdf))"
# matches local images:
# matches "(image.png)"
# matches "]: image.png"
# does not match remote images (http*)
@ttscoff
ttscoff / bytes.rb
Created November 2, 2014 15:34
Convert file sizes between human-readable and machine representations
#!/usr/bin/ruby
module Bytes
def to_human(n,fmt=false)
count = 0
formats = %w(B KB MB GB TB PB EB ZB YB)
while (fmt || n >= 1024) && count < 8
n /= 1024.0