My solutions to http://adventofcode.com/2018
I chose Ruby this year because I'm going for speed I guess?
// Add GH usernames to this list to assign them as reviewers | |
var team = []; | |
var menu = document.getElementById('reviewers-select-menu') | |
var summary = menu.getElementsByTagName('summary')[0] | |
// Open assignee modal | |
summary.click(); |
package main | |
import ( | |
"crypto/tls" | |
"crypto/x509" | |
"flag" | |
"io" | |
"io/ioutil" | |
"log" | |
"net/http" |
# Compares a set of npm jquery files to nuget's wrapped jquery files, for the given versions. | |
versions = "1.11.0,1.11.0-beta3,1.11.0-pre,1.11.0-rc1,1.11.1,1.11.1-beta1,1.11.1-rc1,1.11.1-rc2,1.11.2,1.11.3,1.12.0,1.12.1,1.12.2,1.12.3,1.12.4,1.5.1,1.6.2,1.6.3,1.7.2,1.7.3,1.8.2,1.8.3,1.9.1,2.1.0,2.1.0-beta2,2.1.0-beta3,2.1.0-rc1,2.1.1,2.1.1-beta1,2.1.1-rc1,2.1.1-rc2,2.1.2,2.1.3,2.1.4,2.2.0,2.2.1,2.2.2,2.2.3,2.2.4,3.0.0,3.0.0-alpha1,3.0.0-beta1,3.0.0-rc1,3.1.0,3.1.1,3.2.0,3.2.1,3.3.0,3.3.1,3.4.0,3.4.1,3.5.0,3.5.1" | |
mismatches = [] | |
missing_on_nuget = [] | |
versions.split(',').each do |v| | |
print "#{v}, " | |
# Nuget doesn't publish prerelease version |
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"sync" | |
"time" | |
) |
My solutions to http://adventofcode.com/2018
I chose Ruby this year because I'm going for speed I guess?
My solutions to http://adventofcode.com/2017
# Param-based count loader (for params and foreign keys). | |
# | |
# Example: | |
# CountLoader.for(Category).load(category_id) | |
# | |
class CountLoader < GraphQL::Batch::Loader | |
def initialize(model, param: :id, scope: nil) | |
@model = model | |
@param = param | |
@scope = case scope |
# Run in Rails 5.0 active_record folder with: | |
# bundle exec rake test:sqlite3 TEST=test/cases/attribute_test.rb | |
require 'cases/helper' | |
class PriceEstimate < ActiveRecord::Base | |
validates :price, presence: true, numericality: { only_integer: true } | |
# Accepts float (1.23), rounds it (1.0), stores it as integer (1). | |
def price=(float_val) |
# This piggy-backs off RescueMiddleware by using the same exception handling | |
# rules you've defined using rescue_from(), and applying them to lazy fields | |
# (which would otherwise run after middleware has been run). | |
# Add this to your schema: | |
# | |
# instrument(:field, RescueInstrumentation.new) | |
# | |
class RescueInstrumentation | |
def instrument(type, field) | |
old_lazy_resolve_proc = field.lazy_resolve_proc |