Skip to content

Instantly share code, notes, and snippets.

josh-works /
Last active May 21, 2021
Ongoing course notes for Idahosa's Flow School

I often write detailed walk-throughs of difficult learning projects I take on.

This document serves as the same, a bit of an active scratch pad, and a way to quickly ask detailed questions of my team, and perhaps provide detailed answers for my team.

Useful links

1. I am not on a leaderboard, but I want to be

josh-works /
Last active Mar 8, 2021
I'm making a plea for help from others for resolving my display problems. This is basically what I would write in StackOverflow, if I knew which StackOverflow topic to use. Any help is much appreciated!

currently trying: USB-C->DisplayPort cord with SwitchResX to "force" the display up to a reasonable level

My home office setup has suffered some problems of late that are driving me insane.

The most annoying is my wired mouse. I use a wired Redragon Mammoth hooked up to my USB-C hub, and it started giving me problems when dragging anything. Like... a file, a screenshot, a window, it would rapidly (dozens of times a second) "drop" what I was dragging and then pick it up again.

This had extremely unpredictable effects, and was highly disruptive to my workflow.

I don't think my mouse is failing (my bluetooth mouse works fine, and for a variety of reasons I think the problem is my monitor is running at 30hz, not 60. more on that later.)

josh-works /
Last active May 17, 2021
Process & Workflow for solving programming challenges, Turing

"Process" is greater than everything

Having a good process is how you go about doing anything that takes a long time and is hard. A good process can be a faithful tool to help you learn dozens of things, now, and five years from now. It's flexible and it's powerful.

One of the biggest pieces of "having a good process" is "taking plentiful notes, easily and quickly"

I won't try to convince you. Here's Arique, currently in Mod 1, on how she's made use of this general process:

josh-works / exceptional_values.rb
Last active Feb 10, 2021
test, and the code that makes the test pass, to understand whole values and exceptional values, from Avdi Grim's, based on
View exceptional_values.rb
class Object
def exceptional?
Course =, :duration) do
def duration=(new_duration)
self[:duration] = Duration(new_duration)
josh-works /
Last active Apr 13, 2018
ruby, benchmarking, double_inject

Double inject. What does it mean?

i want to know how long it takes to do some stuff. I've got some code like this:

def count_stuff(list)
  list.inject([]) do |results, item|
    results << get_results_from_something_else(values)

I needed a URL validator - it needed to check that URL's had HTTP or HTTPS at the beginning. I initially wrote a "before save" action, but didn't like it cluttering up my model. I found a reference to basically "monkey patching" Rail's default Validator class, so that's what I did!

# concerns/url_validator.rb
require 'uri'

class UrlValidator < ActiveModel::Validator

  def validate(record)
    if record.url?

On Learning

topics: {
      DEEP WORK:
        protect and cultivate (limited) attention,
        ear plugs,
        skeptical of music,
        examine your own process,

Better workflow (leads to) better questions (leads to) better jobs

We'll cover two things:

  1. Have a great workflow
  2. Ask great questions


From Regis, who will cover the "workflow" portion of the spike


On cleaner controllers

A few days ago, I worked on a project that was mostly about serving up basic store data (modeled after Etsy) to an API.

We had a few dozen end-points, and all responses were in JSON.

Most of the action happened inside of our controllers, and as you might imagine, our routes.rb file was bananas.

One of the instructors made an exceptionally simple suggestion, I was embarrassed to not have seen it.


in .psqlrc, I've got:

\set PROMPT1 '\n%[%033[1;31;40m%] ➤ %[%033[32m%]psql%033[36m%]%/ %[%033[K%]%[%033[0m%]\n\n%[%033[1;33m%]%#%[%033[0m%] '
\set PROMPT2 '%[%033[1;33m%]%##%[%033[0m%] '
\set HISTSIZE 2000

\set alldata 'SELECT * FROM '