Skip to content

Instantly share code, notes, and snippets.

Josh Cheek JoshCheek

View GitHub Profile
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.


View timing_grape_api.rb
require 'grape'
require 'logger'
require 'json'
class MyApi < Grape::API
version 'v1', :using => :path
format :json
desc "Returns first / last name"
get '/:first/:last' do
JoshCheek / trunk_based_development
Last active Dec 3, 2019
Trunk Based Development
View trunk_based_development
Trunk Based Development
I've never done this on a deployed flagship app at a job.
Continuous integration: all code is merged frequently (perhaps several times per day to once every few days)
Continuous delivery: the integrated code is delivered (tested and deployable)
Continuous deployment: the deliverable code is deployed (shipped)
Release: feature is available to users
JoshCheek / lonpos.rb
Last active Dec 1, 2019
Lonpos Pyramid
View lonpos.rb
class Piece
def self.from_strs(*strs, **opts)
new { |s| { |c| c == "*" } }, **opts
attr_reader :rows, :graphic
def initialize(rows, graphic:)
@graphic, @rows = graphic, do |row| { |cell| cell == true ? graphic : (cell || nil) }
JoshCheek / budding-of-the-brood.js
Last active Nov 23, 2019
Budding of the Brood
View budding-of-the-brood.js
// "Budding of the Brood" by Josh Cheek (@josh_cheek on the twitter)
// Paste it into here:
// Or you can watch me run it here:
// And some explanatino of how it works here:
// Great explanation of the math here:
document.getElementsByClassName('console')[0].style.display = 'none'
function getPoint(time, getX) {
time = (time*5) % points.length
const [x1, y1] = points[Math.floor(time)]
JoshCheek / scrape_sigs
Last active Nov 23, 2019
My hydra signature scraping script
View scrape_sigs
#!/usr/bin/env bash
node -e 'console.log(JSON.stringify(require("./src/composable-glsl-functions.js")))' \
| ruby -r json -e '
puts JSON.parse($, symbolize_names: true)
.map { |name, defn| {**defn, name: name} }
.group_by { |defn| defn[:type] }
.each { |cat, defns| defns.sort_by! { |defn| defn[:name] } }
.map { |category, defns|[category]).map.with_index { |(defn,category),i|
JoshCheek / pg_cursor_example.rb
Created Oct 6, 2017
PostgreSQL cursor example
View pg_cursor_example.rb
require 'pg'
db = PG.connect dbname: 'postgres'
db.exec("DROP DATABASE IF EXISTS just_fkn_around;")
db.exec("CREATE DATABASE just_fkn_around;")
db = PG.connect dbname: 'just_fkn_around'
define_method(:sql) { |sql| db.exec(sql).to_a }
sql <<-SQL
-- some data to query
JoshCheek / dot_is_for_minitest.rb
Created Sep 25, 2019
Experiment that adds `.is` (like the old RSpec `.should`) to Minitest
View dot_is_for_minitest.rb
require 'minitest/autorun'
module DotIs
# Track the current test so that we can run assertions in its context
def self.current_test=(test)
Thread.current[:dot_is_current_test] = test
def self.current_test
Thread.current.fetch :dot_is_current_test
JoshCheek / metaprogrammed_active_record_clone.rb
Created Sep 24, 2019
Metaprogrammed ActiveRecord "clone" (just a fun morning experiment)
View metaprogrammed_active_record_clone.rb
class Query
def initialize(table, db)
@db, @table, @cols, @rest = db, table.downcase, '*', ''
def method_missing(clause, *args)
clause == :select \
? @cols = args.join(', ') \
: @rest << ' ' << [clause, *args].join(' ')
JoshCheek / lambda-calc.js
Created Sep 23, 2019
lambda calc translation
View lambda-calc.js
($true => $false => $if => y => succ => zero => toJs =>
(one => two => three => add => nil => cons =>
(multiply => map => reduce =>
console.log(reduce(arr => n => [...arr, toJs(n)])(
// Translation of this program into lambda calculus
// const arr = [1,2,3]
// const timesTwoPlusIndex = (el, index) => (el*2) + index
You can’t perform that action at this time.