Skip to content

Instantly share code, notes, and snippets.

Jay McGavren jaymcgavren

Block or report user

Report or block jaymcgavren

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
jaymcgavren /
Last active Nov 7, 2019
A checklist to help you apply the principles described in Practical Object-Oriented Design in Ruby to your code.

Class Cohesion (Single Responsibility Principle)

  • Pretend you're talking to a sentient instance of your class. Pretend each of its methods is a question you're asking it. Do those questions all make sense? ("Mr. Gear, what is your tire size?" probably does not.)
  • Describe the class's purpose in one sentence. If that sentence contains an "and" or an "or", it probably has more than one responsibility.
  • Classes should call their own attribute reader and writer methods instead of reading and writing instance variables directly. (Controllers might be an acceptable exception to this rule.)
  • Are there any complex data structures (2-dimensional arrays, etc.) that should be encapsulated in classes with named accessor methods?
  • Are there any methods with more than one responsiblity? If you break them down into smaller methods, the new methods may be self-documenting (through their names) and may reveal additional beneficial refactorings.

Managing Dependencies

jaymcgavren / tree.rb
Last active May 15, 2019
"tree" sample from ruby-processing, ported to Visor.
View tree.rb
# by Joe Holt
color_mode RGB, 1
@x = 0.0
@dx = width / 100
def draw
jaymcgavren / quadraticvertex.rb
Created May 15, 2019
"quadraticvertex" sample from ruby-processing, ported to Visor.
View quadraticvertex.rb
# sketch by Jan Vantomme
# Part of a series of articles on Processing 2.
# Blog post here:
# translated for ruby-processing by Martin Prout
# translated for Visor by Jay McGavren
attr_reader :debug, :step_angle, :cr, :detail
@debug = false
jaymcgavren / orbit.rb
Created May 15, 2019
The "orbit" sketch from ruby-processing, ported to work with Visor.
View orbit.rb
# Ported from
# This sketch demonstrates how to use the frame rate as orbital state,
# as well as how to use system fonts in Ruby-Processing.
attr_reader :d_font
@d_font = create_font('Helvetica', 40, false, ('a'..'z').to_a)
# Note: Colors inverted from original to ease layer blending.
stroke 255
jaymcgavren / wishy.rb
Last active May 15, 2019
Classic "wishy worm" example from ruby-processing, adapted for use in Visor.
View wishy.rb
# This one has a long lineage:
# It was originally adapted to Shoes in Ruby,
# from a Python example for Nodebox, and then, now
# to Ruby-Processing.
# -- omygawshkenas
attr_reader :alpha, :back_color, :bluish, :hide, :magnitude, :panel
attr_reader :x_wiggle, :y_wiggle
@hide = false
jaymcgavren / ghc.rb
Last active Apr 9, 2019 — forked from felixbuenemann/ghc.rb
Homebrew formula for official ghc 8.6.4 binaries
View ghc.rb
class Ghc < Formula
desc "Glorious Glasgow Haskell Compilation System"
homepage ""
url ""
sha256 "cccb58f142fe41b601d73690809f6089f7715b6a50a09aa3d0104176ab4db09e"
def install
system "./configure", "--prefix=#{prefix}"
ENV.deparallelize { system "make", "install" }
jaymcgavren /
Created Aug 10, 2018
Notes on The Art of Public Speaking: Lessons From the Greatest Speeches in History [From The Great Courses, Prof. John R. Hale]

Overcoming Stage Fright

  • Arrive early so you can become familiar with the space you'll be speaking in.
jaymcgavren /
Created Aug 3, 2018
Convert the current clipboard contents to a fenced code block
pbpaste | ruby -e 'puts "```"; puts; puts "```"' | pbcopy
jaymcgavren / random_names.txt
Last active Jul 25, 2018
A list of random names, loosely based on data from the 1990 United States Census.
View random_names.txt
Mary Townzen
Patricia Gooden
Linda Spinelli
Barbara Luth
Elizabeth Blackmon
Jennifer Vanness
Maria Aricas
Susan Stepro
Margaret Galbavy
Dorothy Faull
View temp.rb
class Mousetrap
attr_accessor :marble_count
def initialize(marble_count)
self.marble_count = marble_count
def press_button
print "presses the button which "
def flip_bucket
You can’t perform that action at this time.