Skip to content

Instantly share code, notes, and snippets.

Avatar

Jordan Running jrunning

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

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 Aug 1, 2019
Sorbet weird $global type behavior
View Gemfile
gem 'sorbet', :group => :development
gem 'sorbet-runtime'
View functions.sh
# GIT heart FZF
# -------------
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
fzf-down() {
fzf --height 50% "$@" --border
}
View 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
View az.js
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 Jun 19, 2017
decimalunary in GNU sed
View decimal-to-unary.sed
#!/usr/bin/env sed -rf
# 2017 Jordan Running <jordan@jordanrunning.com>
s/^0$//
tZ
s/$/!:9876543210/
:
s/0!/!9/
t
s/(.)!(.*):(.*\1)(.)/\4\2:\3\4/
s/(.*):/;\1!:/
View just.sh
#!/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 !@/
View 01_intersect_benchmark.rb
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 Mar 24, 2017
load-order-test
View test-child.html
<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
View 01_get_indexes_benchmark.rb
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"