Skip to content

Instantly share code, notes, and snippets.

Josh Cheek JoshCheek

Block or report user

Report or block JoshCheek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
JoshCheek / tetris
Last active May 25, 2020
CLI tetris
View tetris
#!/usr/bin/env ruby
require 'io/console'
class Grid
def self.from_str(str, color:)
rows = do |line| do |c|
color if c != " ".freeze
View garden1.rb
class Garden
'R' => :radishes,
'C' => :clover,
'G' => :grass,
'V' => :violets,
ABBREVIATIONS.default_proc = lambda do |abbreviations, abbreviation|
raise KeyError,
JoshCheek / 06-recursive-functions.hs
Created Oct 21, 2012
Programming in Haskell, ch6 solutions
View 06-recursive-functions.hs
-- 1: Define the exponentiation operator ↑ for non-negative integers
-- using the same pattern of recursion as the multiplication operator ∗,
-- and show how 2 ↑ 3 is evaluated using your definition.
power base 0 = 1
power base exponent = base * power base (exponent-1)
-- 3: Without looking at the definitions from the standard prelude in Appendix B,
-- define the following library functions using recursion:
-- • Decide if all logical values in a list are True:
myAnd :: [Bool] -> Bool
JoshCheek / json_parse.rb
Created Apr 22, 2020
Not sure why, but I suddenly felt compelled to make a JSON parser 🤷‍♂️
View json_parse.rb
def json_parse(json)
success, index, _ws = json_parse_optional_whitespace(0, json)
success, index, value = json_parse_value(index, json)
raise "Could not parse" unless success
def json_parse_value(index, json)
JoshCheek / touch.c
Created Sep 18, 2011
source code for Gnu's touch command
View touch.c
/* touch -- change modification and access times of files
Copyright (C) 1987, 1989-1991, 1995-2005, 2007-2011 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
JoshCheek /
Last active Mar 20, 2020
How to uninstall Snap Camera on Mac OS X
# these are reconstructed from a shell session without runnig them, so make
# sure you check that it's a sane thing to do before running it, I make no
# guarantees of fitness, and accept no liability. Run at your own risk.
sudo launchctl remove com.snap.SnapCameraRemover
rm -r ~/Library/Caches/Snap/
rm -r ~/Library/Caches/com.snap.SnapCamera/
rm -r ~/Library/Preferences/Snap/
rm ~/Library/Preferences/com.snap.SnapCamera.plist
rm ~/Library/Preferences/com.snap.Snap\ Camera.plist
sudo rm -rf /Applications/Snap\
JoshCheek / Rakefile
Created May 9, 2012
Challenge to create your own struct
View Rakefile
require 'rspec/core/rake_task' :rspec do |t|
t.rspec_opts = ['--fail-fast', '--format', 'documentation']
task default: :rspec
JoshCheek / refining_enumerable_reduce.rb
Last active Feb 27, 2020
Using refinements to monkey patch a reversed `reduce` in Ruby
View refining_enumerable_reduce.rb
module Consistency
original = Enumerable.instance_method :reduce
refine Enumerable do
# I didn't actually check it against the real impl or docs or anything, but its something like this
alias_method :inject, define_method(:reduce) { |*args, &block|
block = args.pop if args.size == 2 do |y|
original.bind(self).call(*args) { |l, r| y.yield r, l }
end.each &block
View rot_13.rb
def rot13(ascii_char)
ascii_offset = 65
alphabet_size = 26
full_index = ascii_char.ord - ascii_offset
cap_bit = full_index & 0b100000
half_index = full_index & 0b011111
rotated = (half_index + alphabet_size/2) % alphabet_size
(rotated + cap_bit + ascii_offset).chr
JoshCheek /
Last active Dec 28, 2019
Why I Chose Fish Over Bash For Students

Why I chose Fish over Bash for students

I'm currently the lead instructor at Code Platoon and an instructor/developer at the Turing School of Software and Design.

I've been advocating the Fish shell and when the choice is up to me, I choose that for my students. Enough people ask about the decision, particularly in relation to the preinstalled Bash shell, that I figured it's worth laying out my reasoning.


You can’t perform that action at this time.