Skip to content

Instantly share code, notes, and snippets.

View kjlape's full-sized avatar
🤝
nice to meet you

Kaleb Lape kjlape

🤝
nice to meet you
View GitHub Profile
@kjlape
kjlape / seeders.rb
Last active December 11, 2021 02:20
module Seeders
class Base
def seed!(builder, findable_attributes, unstable_attributes = {})
builder.find_or_create_by!(findable_attributes) do |config|
config.assign_attributes(unstable_attributes)
end
end
end
class Builder
@kjlape
kjlape / README.md
Last active October 6, 2020 14:25
Experimental Minitest around_each hook

Characteristics

  • Completely wraps the minitest test lifecycle (setup, teardown, and friends…). This may lead to surprising results.
  • Supports multiple calls to around_each. Each subsequent around_each call wraps around the previous one. Is this unintuitive? I don't know. 🤷‍♂️
@kjlape
kjlape / apps.txt
Last active September 6, 2020 02:08
My brews as of now.
1Password 7.app
Alacritty.app
App Store.app
Atom.app
Audacity.app
Automator.app
Basecamp 3.app
Be Focused Pro.app
Be Focused.app
Beaker Browser.app
@kjlape
kjlape / compose.rb
Created September 1, 2020 16:45
Playing with functional composition in ruby.
if Gem::Version.new("2.6") <= Gem::Version.new(RUBY_VERSION)
def compose(*funcs)
funcs.map(&:to_proc).reduce(:<<)
end
else
def compose(*funcs)
funcs.map(&:to_proc).reduce { |f, g| ->(*x) { f.call(g.call(*x)) } }
end
end
def gauss(x:, σ:, µ:)
Math.exp(-(x - µ)**2 / (2.0 * σ**2))/(σ * 2.5)
end
@kjlape
kjlape / .dockerignore
Created July 4, 2020 22:46
dockerignore example demonstrating negative matchers
*/*
!/*.js
!/*.json
!/lib
!/vendor
# node_modules
# npm-debug.log
# out
# dist
# Vanilla
Thing1.transaction do
Thing2.transaction do
Governor.allowing_malarkey do
Logger.with_context(some: :context) do
Auditor.with_context(some: [:more, :context]) do
do_a_thing
end
end
copy(Array.from(new Set(Array.from(document.getElementsByTagName("a")).filter(element => element.textContent.startsWith("Check")).map(element => element.textContent.replace(/Check failure on line \d+ in /, '')))).join(" "))
@kjlape
kjlape / keybase.md
Created August 1, 2019 19:20
Proof of GitHub account ownership for https://keybase.io

Keybase proof

I hereby claim:

  • I am pingortle on github.
  • I am pingortle (https://keybase.io/pingortle) on keybase.
  • I have a public key ASDdzMBjB_KEboIXEmrJvAuon9g6lIZR3Z0KREwT5svJUAo

To claim this, I am signing this object: