Skip to content

Instantly share code, notes, and snippets.

View Thomascountz's full-sized avatar
💃
LGTM!

Thomas Countz Thomascountz

💃
LGTM!
View GitHub Profile
@Thomascountz
Thomascountz / keyword_nil_arguments_bench.rb
Created September 5, 2020 13:32
Benchmark using ARGS constant for nil method arguments
require 'benchmark/ips'
Benchmark.ips do |benchmark|
benchmark.config(time: 5, warmup: 2)
benchmark.report("keyword-args") do
def foo(a: nil, b: nil, c: nil, d: nil, e: nil)
bar(a: a, b: b, c: c, d: d, e: e)
end
@Thomascountz
Thomascountz / keyword_arguments_bench.rb
Created September 5, 2020 13:26
Benchmark using ARGS constant for method arguments
require 'benchmark/ips'
Benchmark.ips do |benchmark|
benchmark.config(time: 5, warmup: 2)
benchmark.report("keyword-args") do
def foo(a: nil, b: nil, c: nil, d: nil, e: nil)
bar(a: a, b: b, c: c, d: d, e: e)
end
@Thomascountz
Thomascountz / init.vim
Created November 22, 2019 13:52
nvim dotfile
" ------------------------------------------------------------------
" general config
" ------------------------------------------------------------------
set number " show line numbers
let mapleader = "\\" " assign \ as leader
set showmatch " show matching brackets.
set ignorecase " case insensitive matching
set hlsearch " highlight search results
set tabstop=2 " number of columns occupied by a tab character
set softtabstop=2 " see multiple spaces as tabstops so <BS> does the right thing
@Thomascountz
Thomascountz / univariate_polynomial_roots.rb
Created July 31, 2019 22:26 — forked from O-I/univariate_polynomial_roots.rb
Ruby univariate polynomial root finder
require 'matrix'
# Input: an array of the n coefficients [a_n, a_n-1,..., a_1] of
# a univariate polynomial p of degree n ([a_n]x^n + [a_n-1]x^n-1 + ... + a_1)
#
# Output: an array of all n roots of p
#
# Exploits the fact that the eigenvalues of the companion matrix of the
# monic equivalent of p are the roots of p
#
@Thomascountz
Thomascountz / danish_notes_and_tips.md
Created July 15, 2019 13:31
Tips and Notes for Danish from Doulingo
@Thomascountz
Thomascountz / bobby-init.js
Created May 31, 2019 00:25
Initial Bobby Script
let stopCode = "901308"
fetch(`https://bustime.mta.info/api/siri/stop-monitoring.json?key=REDACTED&version=2&MonitoringRef=${stopCode}`)
.then(function (response) {
return response.json();
}).then(function (json) {
console.log(json.Siri.ServiceDelivery.StopMonitoringDelivery[0].MonitoredStopVisit.map(visit => {
return visit.MonitoredVehicleJourney.MonitoredCall.ArrivalProximityText
}))
});
//=> [ "1.2 miles away", "2.3 miles away", "3.1 miles away" ]
@Thomascountz
Thomascountz / damp_or_dry.md
Last active March 22, 2019 18:24
Which Do You Prefer? Why?

Which do you prefer?

Here is a ruby User class with #first_name, #last_name, and #full_name methods, as well as a constructor.

#/lib/user.rb
class User
  
  attr_reader :first_name, :last_name
  
@Thomascountz
Thomascountz / orbital.rb
Created January 6, 2019 16:45
Outputs the predicted passings for the next two days of\nNOAA-15, NOAA-18, & NOAA-19 near New York City, USA
#!/usr/bin/env ruby
Prediction = Struct.new(:sat_name, :local_start, :max_elevation, :local_end, keyword_init: true)
NOAA15 = "25338"
NOAA18 = "28654"
NOAA19 = "33591"
require "HTTParty"
require "json"

Essential & Relevant: A Unit Test Balancing Act

I have never been a fan of "DRYing" out unit tests. I have always preferred to keep all of my test setup inside each individual test, and I pined about how this made my test suite more readable, isolated, and consistent; despite all of the duplication. I've never been any good at articulating why I preferred to do things this way, but I felt that it was better than the alternative: a test suite full of shared setup methods that forced me to scan many lines of code to try to understand how the tests work.

Then, I began reading xUnit Test Patterns by Gerard Meszarso. In his book, he codified some of the most profound formulas for writing unit tests. Throughout, the recurring theme around test setup was to keep things essential & relevant, and as I continued read, I began to understand that writing good unit tests is much more nuanced than I bargained for.

First, we'll define w

[2018.11.29]

Welcome to the Modern Robotics Book Club!

To get started, Visit http://modernrobotics.org/ to download the book for free!

This Saturday, December 1st, 2018, let's have a chat! Until then, introduce yourself, invite your friends and get excited!

This is a just small fun project that I hope gets others as excited about robots as I am, but just make sure everyone is comfortable, there's a Code of Conduct