Skip to content

Instantly share code, notes, and snippets.

View zacheryph's full-sized avatar

Zachery Hostens zacheryph

View GitHub Profile
@zacheryph
zacheryph / api_wrapper.rb
Last active September 5, 2024 21:20
api_wrapper.rb
# just for this example to work
class BigCommerce
def woot(...)
puts "woot"
end
class System
def time(*args, **kwargs)
puts "time: #{args} #{kwargs}"
end
@zacheryph
zacheryph / source.yaml
Created May 6, 2022 13:51
Triggermesh Slack Source
apiVersion: sources.triggermesh.io/v1alpha1
kind: SlackSource
metadata:
name: zro
spec:
appID: REDACTED
signingSecret:
value: REDACTED
sink:
ref:
@zacheryph
zacheryph / keybase.md
Last active April 14, 2020 18:28
keybase.md

Keybase proof

I hereby claim:

  • I am zacheryph on github.
  • I am zacheryph (https://keybase.io/zacheryph) on keybase.
  • I have a public key ASCDPgxfcWLiWhYVg09hdJi9QRrfK4ruGx8qLUluzsEdAQo

To claim this, I am signing this object:

@zacheryph
zacheryph / chart-deployment.yaml
Created February 6, 2018 19:07
Private Gitlab / K8s / helm deployment pipeline
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "pkg.fullname" . }}
labels:
app: {{ include "pkg.name" . }}
chart: {{ include "pkg.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
# Zachery Hostens
# Ensure TPM Installation {{{
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm'"
# }}}
# General {{{
set -g prefix C-a
set-option -g base-index 1
setw -g pane-base-index 1
# this contains development overrides
version: "3.5"
# common for app/sidekiq
# we volume bundler so we aren't constantly re-installing gems
x-app: &app-common
build:
context: .
target: dev
volumes:
@zacheryph
zacheryph / emitter.rb
Created March 20, 2014 16:31
pub/sub with ActiveSupport::Notifications
module Eventable
module Emitter
extend ActiveSupport::Concern
included do
def emit(event_name, payload = {})
full_event = "#{self.class.to_s.underscore}:#{event_name}"
Eventable.emit full_event, self, payload
end
end
@zacheryph
zacheryph / interactor.coffee
Last active August 29, 2015 13:56
Interactor pattern in CoffeeScript
# Interactor pattern
# idea pulled blatently from: https://github.com/collectiveidea/interactor
#
# NEED TO DO:
# - add bluebird, so ALL perform() calls are promises.
# - 'rollback' support to crawl 'backwards' when there is an error
# - 'fail()' for the rollback
#
# Question:
# - Is doing a pattern like this in JS useless?
@zacheryph
zacheryph / bucket_split.rb
Last active August 29, 2015 13:56
spread amount over buckets with no under/over
class BucketSplit
class InvalidSpread < StandardError ; end
def initialize(total, splits, precision = 2)
self.precision = precision
self.total = total.round(precision)
self.splits = splits
self.buckets = calculate_buckets
end
@zacheryph
zacheryph / render_loop_in_helper.rb
Last active December 11, 2015 16:38
collecting render calls from helper method
def account_tree(root, partial, output="")
sorter = ->(n) {[n.content.index_path, n.content.number]}
output += render(partial: partial, object: root.content) if root.content
root.children.sort_by(&sorter).each {|node| output = account_tree(node, partial, output)}
output.html_safe
end