Skip to content

Instantly share code, notes, and snippets.

View jrunning's full-sized avatar

Jordan Running jrunning

View GitHub Profile
@jrunning
jrunning / bookmarklet.md
Last active July 19, 2021 17:20
Bookmarklet to remove dark mode styles from a web page

Copy the following URL to a bookmark and give it a cheeky name like "Let there be light":

javascript:(()=>{let e=(e,s)=>{let l=0;for(let o=0;o<s.length&&!(++l>1e4);o++)t(e,o,s[o])},t=(t,s,l)=>{"conditionText"in l&&(/prefers-color-scheme:\s*dark/.test(l.conditionText)?t.deleteRule(s):e(l,l.cssRules))};for(let t of document.styleSheets)try{e(t,t.cssRules)}catch(e){}})();
@jrunning
jrunning / Gemfile
Last active August 1, 2019 17:45
Sorbet weird $global type behavior
gem 'sorbet', :group => :development
gem 'sorbet-runtime'
@jrunning
jrunning / functions.sh
Last active July 18, 2018 17:03 — forked from junegunn/functions.sh
Key bindings for git with fzf (https://junegunn.kr/2016/07/fzf-git/)
# GIT heart FZF
# -------------
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
fzf-down() {
fzf --height 50% "$@" --border
}
@jrunning
jrunning / terminal-eyes.rb
Created January 12, 2018 16:55
terminal-eyes.rb
at_exit { stop! }
require "io/console"
$last_click_pos = nil
LEFT_EYE_OFFSET = -3
RIGHT_EYE_OFFSET = 3
EYE_CENTER_OFFSET = 2
# Xterm control sequences
@jrunning
jrunning / az.js
Last active October 30, 2017 16:52
require('readline',{stdin:i,stdout:o,exit:e}=process).emitKeypressEvents(i)
w=s=>o.write(s)
n=0
i.on('keypress',c=>w(c)&&c.charCodeAt()-97-n?e(w(`
Fail`)):!n++?s=d():n>25&&e(w(`
`+(d()-s)))).setRawMode(d=Date.now)
@jrunning
jrunning / decimal-to-unary.sed
Created June 19, 2017 16:35
decimal↔unary in GNU sed
#!/usr/bin/env sed -rf
# 2017 Jordan Running <[email protected]>
s/^0$//
tZ
s/$/!:9876543210/
:
s/0!/!9/
t
s/(.)!(.*):(.*\1)(.)/\4\2:\3\4/
s/(.*):/;\1!:/
#!/usr/bin/env bash
sed --version | head -1
printf "%s\n%s" "$1" "$2" | gsed -r '
x;N
G
s/\n/!@/
:
/@\n/bZ
s/-!(.*)@ /\1 !@/
require "benchmark/ips"
A_SIZE_RANGE = 0..1000
B_SIZE_RANGE = 2..5
VAL_RANGE = 0...10000
def a
Array.new(rand A_SIZE_RANGE) { rand VAL_RANGE }
end
@jrunning
jrunning / test-child.html
Last active March 24, 2017 18:14
load-order-test
<script src="test-script.js"></script>
<script>
console.log('Hello from test-child.html');
</script>
<!-- output:
Hello from test-script.js
Hello from test-child.html
require "benchmark/ips"
NUM_WORDS = 10_000
file = File.open("/usr/share/dict/words")
# Get all the "bo" words
WORDS = file.each_line.grep(/^bo/).map(&:chomp)
file.rewind
puts "#{WORDS.size} \"bo\" words"