Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
🤘Grokking Out 🤘

Matt Petty lodestone

:octocat:
🤘Grokking Out 🤘
View GitHub Profile
@lodestone
lodestone / TrueColour.md
Last active Apr 30, 2021 — forked from XVilka/TrueColour.md
Terminal/Console/Shell Color Sequence Cheat Sheet
View TrueColour.md

Terminal Colors

There exists common confusion about terminal colors. This is what we have right now:

  • Plain ASCII
  • ANSI escape codes: 16 color codes with bold/italic and background
  • 256 color palette: 216 colors + 16 ANSI + 24 gray (colors are 24-bit)
  • 24-bit true color: "888" colors (aka 16 milion)
@lodestone
lodestone / me-and-blade-chatting.csv
Last active Nov 6, 2020
Log of me and Blade the Vampire Hunter have a chat. (Just testing CSV rendering on gist.github.com)
View me-and-blade-chatting.csv
date person message
2020-10-21 22:04:50 Matt Oh hey! Are you Blade? That half-vampire vampire-hunter?
2020-10-21 22:04:52 Blade ___
2020-10-21 22:05:45 Matt Um. Okay yeah. You're busy all hackin' and slashin' all these vamparoonies about.
2020-10-21 22:04:47 Blade ___
2020-10-21 22:05:55 Matt Uh if you ever want to keep your black leather clothes clean and still hack n slash - you can join my D&D game.
2020-10-21 22:06:08 Blade ___
2020-10-21 22:06:15 Blade I will play this Dee and Dee. On one condition - I must play a bard.
2020-10-21 22:06:25 Blade Text the number carved into the chest of this dying vampire before it turns to dust.
@lodestone
lodestone / appify
Created Jun 23, 2020 — forked from mathiasbynens/appify
appify — create the simplest possible Mac app from a shell script
View appify
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@lodestone
lodestone / bytes.rb
Created Jun 11, 2020 — forked from ttscoff/bytes.rb
Convert file sizes between human-readable and machine representations
View bytes.rb
#!/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
@lodestone
lodestone / bulk-remove-iterm-colors.sh
Created May 5, 2020 — forked from kecebongsoft/gist:11312110
Bulk remove iTerm2 color schemes.
View bulk-remove-iterm-colors.sh
# There was a day where I have too many color schemes in iTerm2 and I want to remove them all.
# iTerm2 doesn't have "bulk remove" and it was literally painful to delete them one-by-one.
# iTerm2 save it's preference in ~/Library/Preferences/com.googlecode.iterm2.plist in a binary format
# What you need to do is basically copy that somewhere, convert to xml and remove color schemes in the xml files.
$ cd /tmp/
$ cp ~/Library/Preferences/com.googlecode.iterm2.plist .
$ plutil -convert xml1 com.googlecode.iterm2.plist
$ vi com.googlecode.iterm2.plist
@lodestone
lodestone / b.rb
Created Jan 19, 2020 — forked from junegunn/b.rb
b - browse Chrome bookmarks with fzf
View b.rb
#!/usr/bin/env bash
# vim: set filetype=ruby:
# b - browse Chrome bookmarks with fzf
[ $(uname) = Darwin ] || exit 1
which fzf > /dev/null 2>&1 || brew reinstall --HEAD fzf || exit 1
/usr/bin/ruby -x "$0" |
fzf-tmux -u 30% --ansi --multi --no-hscroll --tiebreak=begin |
awk 'BEGIN { FS = "\t" } { print $2 }' |
@lodestone
lodestone / coc_fzf.vim
Created Oct 9, 2019 — forked from RobertBuhren/coc_fzf.vim
Display coc.nvim diagnostics using FZF
View coc_fzf.vim
function! s:format_coc_diagnostic(item) abort
return (has_key(a:item,'file') ? bufname(a:item.file) : '')
\ . '|' . (a:item.lnum ? a:item.lnum : '')
\ . (a:item.col ? ' col ' . a:item.col : '')
\ . '| ' . a:item.severity
\ . ': ' . a:item.message
endfunction
function! s:get_current_diagnostics() abort
" Remove entries not belonging to the current file.
@lodestone
lodestone / rails_annotate_query.rb
Created May 2, 2019
Example of annotating a sql query from Rails
View rails_annotate_query.rb
Post.for_user(user).annotate("fetching posts for user ##{user.id}").to_sql
#=> SELECT "posts".* FROM "posts" WHERE ... /* fetching posts for user #123 */
@lodestone
lodestone / searchlink.rb
Created Mar 26, 2019 — forked from ttscoff/searchlink.rb
SearchLink creates Markdown links from automatic searches based on special syntax.
View searchlink.rb
@lodestone
lodestone / HOWTO-Dissassociate-Xcode-From-All-File-Types.md
Created Feb 15, 2019
HOWTO: Dissassociate/Unassociate Xcode from ALL file types in one fell swoop!
View HOWTO-Dissassociate-Xcode-From-All-File-Types.md

HOWTO: Disassociate/Unassociate File Types From a Mac App

I got super tired of Xcode opening everything: .rb, .sh, etc etc etc....

Here is how to stop Xcode from opening everything!

NOTE: It may be helpful to know that I found the lsregister command right here:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister