Instantly share code, notes, and snippets.

View memo_me.rb
def MemoMe(superclass)
# Ripped mostly out of
# https://github.com/ruby/ruby/blob/trunk/lib/delegate.rb
klass = Class.new(superclass)
methods = superclass.instance_methods
methods -= [:to_s, :inspect, :=~, :!~, :===, :instance_variable_get, :instance_variable_set]
klass.define_method(:initialize, lambda do |*args|
@__memo_me_instance = superclass.new(*args)
end)
klass.module_eval do
View basketball.md
- Giving it to the best player doesn't make the team better
- Positive reinforcement
- You can't play for them
- You're going to be ignored / Shared understanding takes forever
- The game is not the most important thing

I coached a rec team that had a huge range of talent. One young man was very talented and could have gone on to play junior college basketball. I had a couple that were a level below him and then varying levels all the way down to the kid who was surprised when the basketball was in his hands. I did focus on leveling up everyone in practice, but our in-game style quickly devolved to give it to the best kid and move around him. This was moderately successful, everyone got to contribute, and the games were competitive. Then that kid got sick. Then baseball season started and he wanted to focus on that. All of a sudden my team had no identity and no idea how to win. We couldn't just lean on the next best player, the talent gap was too wide. Before the team could r

View bing-wanikani-results-count.json
{
"関する": 129000000,
"公告": 96800000,
"愛知県": 68200000,
"埼玉県": 67700000,
"神奈川県": 67700000,
"一人": 60400000,
"年中": 60300000,
"一等": 59800000,
"的": 59100000,
View 1-search.js
// Original doc on https://docs.microsoft.com/en-us/azure/cognitive-services/bing-web-search/quickstarts/nodejs#make-a-request-and-print-the-response
// This will not run because the doc's ordering led me to call an undefined method
// Use strict mode.
'use strict';
// Require the https module.
let https = require('https');
// Replace with a valid subscription key.
View calvin-talk-reflections.md

Dear everyone-who-attended-my-talk earlier this week,

First, thank you for coming! It was such a joy to see a large and engaged group interested in hearing a bit of my reflections in my first decade since graduating from Calvin. I'm confident that all of your experiences will emerge in their own right and lead you to profound insights that you can pass on to the folks who come up behind you.

I wanted to send this note to share a handful of resources with you of things that I referenced in the talk (I realize I talk too quickly to take decent notes). Here they are in no particular order:

View add_webcal.md

Add a WebCal (iCalendar) feed URL

Google Calendar

In the Google Cal UI, click the + button above your calendar list and choose "From URL":

screen shot 2018-09-12 at 8 49 28 am

Enter the WebCal URL:

View pry_filter.rb
module Jekyll
module PryFilter
# Usage: {{ site | pry }} to debug the state of the site from the terminal
def pry(input)
require 'pry'
binding.pry
end
end
end
View demo.html
<head>
<style>
body { border: 4px solid red; }
input {
margin-top: 40vh;
font-size: 64px;
}
</style>
</head>
View lol.sql
-- Query to find for a given array of strings whether a PG array
-- column of strings matches any of the given strings after being
-- trimmed and uppercase (where && is the intersection operator)
SELECT assignments.*
FROM assignments
WHERE assignments.user_id = 42
AND (upper(regexp_replace(synonyms::text, '\s+', '', 'g'))::text[]
&& ARRAY['THING1','THING2']::text[])
View jsonb-notes.md

I learned a little bit about building queries (even with Rails/ARel) of postgres JSONB columns in my side project that I wanted to share.

I have a model that represents a Japanese word:

{"id"=>4111,
 "type"=>"vocabulary",
 "characters"=>"洗う",
 "meanings"=>[{
    "meaning"=>"To Wash",