Skip to content

Instantly share code, notes, and snippets.

View lodestone's full-sized avatar
:octocat:
🤘Grokking Out 🤘

Matt Petty lodestone

:octocat:
🤘Grokking Out 🤘
View GitHub Profile
@lodestone
lodestone / gist:ca0adf22a9e64457d45c29c7ce78a718
Created October 17, 2023 09:42 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
MIT License
Copyright (c) 2016 Matt Menzenski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@lodestone
lodestone / gfxutil.sh
Created October 26, 2021 17:59 — forked from joevt/gfxutil.sh
macOS nvram boot variables, device properties, EFI device paths
#!/bin/bash
# joevt Oct 11, 2021
# https://forums.macrumors.com/threads/documentation-on-all-parameters-for-nvram.2239034/post-28518123
gfxutilcmd=~/Downloads/gfxutil/gfxutil
if [[ ! -f $gfxutilcmd ]]; then
gfxutilcmd=~/Downloads/gfxutil
fi
if [[ ! -f $gfxutilcmd ]]; then
gfxutilcmd="/Volumes/Work/Programming/EFIProjects/gfxutil/joevt-gfxutil/DerivedData/gfxutil/Build/Products/Debug/gfxutil"
@lodestone
lodestone / TrueColour.md
Last active April 30, 2021 13:38 — forked from XVilka/TrueColour.md
Terminal/Console/Shell Color Sequence Cheat Sheet

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 November 6, 2020 15:36
Log of me and Blade the Vampire Hunter have a chat. (Just testing CSV rendering on gist.github.com)
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 June 23, 2020 13:17 — forked from mathiasbynens/appify
appify — create the simplest possible Mac app from a shell script
#!/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 June 11, 2020 10:08 — forked from ttscoff/bytes.rb
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
@lodestone
lodestone / bulk-remove-iterm-colors.sh
Created May 5, 2020 23:50 — forked from dedy-purwanto/gist:11312110
Bulk remove iTerm2 color schemes.
# 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 January 19, 2020 05:55 — forked from junegunn/b.rb
b - browse Chrome bookmarks with fzf
#!/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 October 9, 2019 02:23 — forked from RobertBuhren/coc_fzf.vim
Display coc.nvim diagnostics using FZF
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.