Skip to content

Instantly share code, notes, and snippets.

View adamdunkley's full-sized avatar

Adam Dunkley adamdunkley

View GitHub Profile
@theorygeek
theorygeek / association_loader.rb
Last active October 31, 2023 07:15
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
@rockymadden
rockymadden / comodo-positivessl-wildcard-chain-aws.pem
Last active August 29, 2015 14:03
Comodo PositiveSSL wildcard chain for AWS.
-----BEGIN CERTIFICATE-----
MIIGCDCCA/CgAwIBAgIQKy5u6tl1NmwUim7bo3yMBzANBgkqhkiG9w0BAQwFADCB
hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G
A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV
BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTQwMjEy
MDAwMDAwWhcNMjkwMjExMjM1OTU5WjCBkDELMAkGA1UEBhMCR0IxGzAZBgNVBAgT
EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
Q09NT0RPIENBIExpbWl0ZWQxNjA0BgNVBAMTLUNPTU9ETyBSU0EgRG9tYWluIFZh
bGlkYXRpb24gU2VjdXJlIFNlcnZlciBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBAI7CAhnhoFmk6zg1jSz9AdDTScBkxwtiBUUWOqigwAwCfx3M28Sh
#target "InDesign"
// run script without install to ScriptPanel
(function(){
var script_path = File.openDialog();
try {
script_path ? $.evalFile(script_path) : exit();
}
catch(e){
alert(decodeURI(script_path) + "\n" + e);
@rikusalminen
rikusalminen / kepler.hs
Last active April 5, 2020 15:20
Computing Kepler's elements with Haskell
module Main where
import Debug.Trace
import Control.Monad (forM_)
epsilon = 1.0e-10 :: Double
add (x1, y1, z1) (x2, y2, z2) = (x1+x2, y1+y2, z1+z2)
sub (x1, y1, z1) (x2, y2, z2) = (x1-x2, y1-y2, z1-z2)
mul (x1, y1, z1) (x2, y2, z2) = (x1*x2, y1*y2, z1*z2)