View .gitignore
cache
result.html
View sql_needs_a_let_clause.md
View nilmare.rb
# be sure to use 2.3.0, b/c it uses the new "safe navigation" operator
RUBY_VERSION # => "2.3.0"
def show(arg)
arg # => true, {:nil=>:nil?}, {:nil=>false}
end # => :show
nil # => nil
nil.nil? # => true
nil&.nil # => nil
View history_of_shortening.rb
# ruby -e '$.-=~$.;$_=-~$.<<-~-~-~$.;$:<<$_|=$_<<$.;$_|=$_>>$.;$:.<<(-~$.<<$.);$>.<<$/[$....$.]<<$_+$:[-$.]+-~$.+$.<<$:[~$.]+$.<<$_+$:[-$.]<<$/'
# ruby -e '$.-=~$.;$_=-~$.<<-~-~-~$.;$:<<$_|=$_<<$.;$_|=$_>>$.;$:<<(-~$.<<$.);$>.<<$/[$....$.]<<$_+$:[-$.]+-~$.+$.<<$:[~$.]+$.<<$_+$:[-$.]<<$/'
# ruby -e '$.-=~$.;$_=-~$.<<-~-~-~$.;$:<<$_|=$_<<$.;$_|=$_>>$.;$:<<-~$.*-~$.;$>.<<$/[$....$.]<<$_+$:[-$.]+-~$.+$.<<$:[~$.]+$.<<$_+$:[-$.]<<$/'
# ruby -e '$.-=~$.;$;=-~$.<<-~-~$.;$;|=$;<<$.;$:<<$;--$;;$;|=$;--$;;$:<<-~$.-~$.;$>.<<$/[$....$.]<<-~$;--$:[-$.]-~$.<<-~$:[~$.]<<-~$;-~-~$.<<$/'
# ruby -e '$.-=~$.;$;=-~$.<<-~-~$.;$;|=$;<<$.;$>.<<$/[$....$.]<<-~[$;|$;--$;][~-$.]-~$.-~$.-~$.<<-~$;--$;<<-~[$;|$;--$;][~-$.]-~-~$.<<$/'
# ruby -e '$;=$.-=~-~$.;$.<<=$.;$;=--~-$.<<-~-~$;;$>.<<$/[$.-$....$.-$.]<<$;--~-$.<<-~$;-$.-$.<<-~-~-~-~$;<<$/'
require 'stringio'
$stdout = StringIO.new
eval(code=DATA.read.strip)
View commits.md

For Sara https://twitter.com/sarambsimon/status/765197362553761793

Generally used this set of scripts to find stuff:

# A few assumptions in here, glance through it to figure out if you need to swap anything out / add / remove
ruby -r pp -e 'me = "Josh Cheek"; pp Dir["**/.git"].map { |d| File.dirname d }.flat_map { |d| Dir.chdir(d) { remote = %x(git remote --verbose | grep push).chomp; next [] if remote.empty?;  %x(git log --author="#{me}").lines.reject { |line| line =~ /^(Author|Date):/ || line == "\n" }.slice_before { |line| line =~ /^commit/ }.map { |commitline, *messages| [remote, commitline.split.last, messages.join.gsub(/^    /, "")] } } }'

# I redirected the output of the above into a file named "tmp" and then used it like this:
View Readme.md
$ g++ reference.cpp && ./a.out
num1: 0, num2: 0
num1: 1, num2: 1
num1: 2, num2: 2
View central_dogma_of_molecular_biology.rb
# https://vimeo.com/178754362
# Central Dogma of Molecular Biology
# DNA --transcription--> RNA --translation--> proteins (which give us traits... and other stuff :)
# DNA is an arbitrarily long sequence of 4 molecules
# whose initials whose initials are A, T, G, and C
# A pairs with T
# C pairs with G
A = 'A' # => "A"
View runner
#!/usr/bin/env bash
set -eu
set -o pipefail
nasm -f macho -o test.o test.asm
ld -o test -e _main test.o -macosx_version_min 10.7 -lc -no_pie
./test || echo "Exit status: $?"
View fixing_webmock_bug.rb
require 'webmock/rspec'
require 'rack'
require 'robots'
require 'webrick/httpstatus' # picked this one b/c it's in the stdlib
rack_response_filename = $LOADED_FEATURES.find { |filename| filename =~ /rack_response/ }
eval File.read(rack_response_filename).sub(/status$/, "[status, WEBrick::HTTPStatus.reason_phrase(status)]")
RSpec.describe Robots do
specify "StringIO#status contains the reason phrase" do
View 0_tweetable_version.sh
# Tweetable version: https://twitter.com/josh_cheek/status/760926396403310596
# Move with vim keybindings
# Press `d` to quit
# If your terminal gets horked (like you can't see what you're typing, or the cursor or whatever)
# Then press return to clear the buffer, and type `stty cooked`, return once again to submit it
stty raw;ruby -e'b=[2,?_,8,5,3,4,i=1,7,6];loop{$><<"\e[H\e[2J"+"%s%s%s\r\n"*3%b;o=[$1,3,-3,1,-1][$<.getc.ord%5];b[i],b[i+=o]=b[i+o],b[i]}'