Skip to content

Instantly share code, notes, and snippets.

View ehrenmurdick's full-sized avatar

Ehren Murdick ehrenmurdick

View GitHub Profile

This is a tool to find association paths between different models in a rails app.

Example output - the paths from Job to Invoice:

[3] pry(main)> G.from(Job).to(Invoice)
Job.active_fleet_managed_invoice_from_swoop -- Invoice

Job.invoice >- Invoice

Job.owning_company >- Company.fleet_managed_clients -- FleetCompany.end_user_invoices -< Invoice
@ehrenmurdick
ehrenmurdick / r.rb
Last active September 13, 2023 19:54
Make ActiveRecord style queries using block syntax
class Query
attr_accessor :mappings
attr_accessor :filters
def initialize
@mappings = []
@filters = []
end
class ConditionProxy
@ehrenmurdick
ehrenmurdick / config.h
Last active September 11, 2021 23:33
Let's split config with rgb underglow
/* keyboards/lets_split/config.h */
/*
Copyright 2012 Jun Wako <wakojun@gmail.com>
Copyright 2015 Jack Humbert
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
@ehrenmurdick
ehrenmurdick / flow_peano_numbers.js
Created August 16, 2021 22:28
Peano numbers in facebook flow!
// @flow
type Zero = {}
type Succ<M> = { succ: M } // doesn't matter what the type actually has in it
type P = Zero | Succ<P>
type Increment = <P>(P) => Succ<P>
type Prev = <P>(Succ<P>) => P
type One = $Call<Increment, Zero>
@ehrenmurdick
ehrenmurdick / fareyAlgorithm.swift
Created July 17, 2020 01:19
A function farey such that farey(x) ≅ r where r is a rational number. Implemented using a binary search of Farey sequence
import UIKit
let n = Double.pi
let r = farey(
n: n,
precision: 0.03)
r.inspect() // (22, 7)
r // 3.142857142857143
n // 3.141592653589793
@ehrenmurdick
ehrenmurdick / keybase.md
Created February 21, 2020 23:36
Keybase.md

Keybase proof

I hereby claim:

  • I am ehrenmurdick on github.
  • I am ehren (https://keybase.io/ehren) on keybase.
  • I have a public key ASCzHBECiGUSOF4YWsWnGKDdDMcLBJjkzCVsYsCtZMSu-go

To claim this, I am signing this object:

@ehrenmurdick
ehrenmurdick / .xbindkeysrc
Created February 1, 2020 14:11
Disable middle mouse i n x11
"echo"
b:2
a/keyboards/lets_split/rules.mk b/keyboards/lets_split/rules.mk
index f9d1a0dad..2d0d49aaa 100644
--- a/keyboards/lets_split/rules.mk
+++ b/keyboards/lets_split/rules.mk
@@ -12,7 +12,7 @@ MCU = atmega32u4
# does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate
# software delays.
-F_CPU = 16000000
+F_CPU = 8000000
class Encoder {
constructor(key) {
this.key = key;
this.position = 0;
}
encode(msg) {
let res = [];
for(let i = 0; i < msg.length; i++) {
// @flow
const RED = '\x1b[31m%s\x1b[0m';
const GREEN = '\x1b[32m%s\x1b[0m';
const suite = (tests, failures) => `
${tests} tests, ${failures} faliures
`;