Skip to content

Instantly share code, notes, and snippets.

View nickpoorman's full-sized avatar
Verified

Nick Poorman nickpoorman

Verified
  • US
View GitHub Profile
@nickpoorman
nickpoorman / association_loader.rb
Created April 28, 2017 19:32 — forked from theorygeek/association_loader.rb
Preloading Associations with graphql-batch
# frozen_string_literal: true
class AssociationLoader < GraphQL::Batch::Loader
attr_reader :klass, :association
def initialize(klass, association)
raise ArgumentError, "association to load must be a symbol (got #{association.inspect})" unless association.is_a?(Symbol)
raise ArgumentError, "cannot load associations for class #{klass.name}" unless klass < ActiveRecord::Base
raise TypeError, "association #{association} does not exist on #{klass.name}" unless klass.reflect_on_association(association)
@klass = klass
@nickpoorman
nickpoorman / ACollectionOfGoPlaygroundSnippets.md
Last active December 6, 2019 20:45
A Collection of Go Playground Snippets

Go Playground Snippets

This is a simple collection of my Go Playground snippets for reference later.

@nickpoorman
nickpoorman / flattenSchema.scala
Created September 5, 2019 20:19
Scale Flatten DataFrame - what explode should be
def flattenSchema(schema: StructType, prefix: String = null) : Array[Column] = {
schema.fields.flatMap(f => {
val colName = if (prefix == null) f.name else (prefix + "." + f.name)
f.dataType match {
case st: StructType => flattenSchema(st, colName)
case _ => Array(col(colName).alias(colName))
}
})
}
@nickpoorman
nickpoorman / Gemfile
Created June 24, 2020 23:41 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers