Skip to content

Instantly share code, notes, and snippets.

Avatar
💃
Dancing

Thomas Countz Thomascountz

💃
Dancing
View GitHub Profile
@Thomascountz
Thomascountz / output.md
Last active Sep 8, 2020
Webpacker 5 Ignoring packs with the same name
View output.md
$ rails -v

Rails 6.0.3.2
$ ruby -v

ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c)
@Thomascountz
Thomascountz / keyword_default_arguments_bench.rb
Created Sep 5, 2020
Benchmark using ARGS constant for default method arguments
View keyword_default_arguments_bench.rb
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: 1)
bar(a: a, b: b, c: c, d: d, e: e)
end
@Thomascountz
Thomascountz / keyword_nil_arguments_bench.rb
Created Sep 5, 2020
Benchmark using ARGS constant for nil method arguments
View keyword_nil_arguments_bench.rb
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 Sep 5, 2020
Benchmark using ARGS constant for method arguments
View keyword_arguments_bench.rb
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
View init.vim
" ------------------------------------------------------------------
" 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 Jul 31, 2019 — forked from O-I/univariate_polynomial_roots.rb
Ruby univariate polynomial root finder
View univariate_polynomial_roots.rb
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 / bobby-init.js
Created May 31, 2019
Initial Bobby Script
View bobby-init.js
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 Mar 22, 2019
Which Do You Prefer? Why?
View damp_or_dry.md

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 Jan 6, 2019
Outputs the predicted passings for the next two days of\nNOAA-15, NOAA-18, & NOAA-19 near New York City, USA
View orbital.rb
#!/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"
You can’t perform that action at this time.