Skip to content

Instantly share code, notes, and snippets.

View eadz's full-sized avatar

Eaden McKee eadz

View GitHub Profile
@eadz
eadz / supervisor.rb
Created July 10, 2023 09:32
Supervisor - 0 downtime deployments
# No Downtime Deploys
# to setup
# clone your app in ~/app-a and ~/app-b
# use the following caddy server config
# yourdomain.com {
# reverse_proxy * {
# to http://127.0.0.1:4210 http://127.0.0.1:4220
# header_up +Host yourdomain.com
# header_up -X-Forwarded-Host
# health_uri /up
@eadz
eadz / accounting.sql
Created February 16, 2023 04:48 — forked from 001101/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@eadz
eadz / ruby-redux.rb
Last active October 4, 2022 21:24
Redux in Ruby
# Redux in Ruby
class Store
attr_reader :state
def initialize(initial_state, *reducers)
@reducers = reducers
@state = initial_state || {}
end
@eadz
eadz / logparse.rb
Created September 13, 2022 01:21
log parse
# For turning heroku DB logs into a CSV
# getting the logs from papertrail:
# you need your papertrail token available
# echo "token: xxxxxxxx" > ~/.papertrail.yml
# papertrail -S pg_load --min-time "30 days ago" > logs.txt
# where `pg_load` is a saved search which finds the postgres status logs
txt = File.read("./logs.txt")
require 'csv'
CSV.open("logs.csv", "wb") do |csv|
@eadz
eadz / to_proc.curry.rb
Created May 21, 2020 22:53
to_proc.curry
changer = "Hello X World".method(:tr).to_proc.curry.call("X")
changer.call("Z") # => Hello Z World
changer.call("Y") # => Hello Y World
@eadz
eadz / bigredbutton.rb
Created September 13, 2011 21:55
big red button
#!/usr/bin/env ruby
#
# AUTHORS
# Eaden McKee <eadz@eadz.co.nz>
# First Big Red Button Version
# Forked from DelcomLightHid https://raw.github.com/puyo/delcom_light_hid
# ( for a different device)
# Originally by
# Ian Leitch <ian@envato.com>, Copyright 2010 Envato
# * Original single light RGY version
@eadz
eadz / gist:10220496
Created April 9, 2014 02:27
slack custom css
/*
User Stylesheet for Slack.
Use with http://www.squarefree.com/userstyles/make-bookmarklet.html
to make a custom css Bookmarket
*/
.light_theme .message {
@eadz
eadz / keybase.md
Last active October 8, 2016 19:09

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@eadz
eadz / time.rb
Created September 27, 2013 07:18
Ruby missing time
» Time.parse("1 Jan 1111") + 1.year
=> 1111-12-25 00:00:00 +1000
» Time.parse("1 Jan 1500") + 1.year
=> 1500-12-23 00:00:00 +1000
» Time.parse("1 Jan 1900") + 1.year
=> 1901-01-01 00:00:00 +1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
// http://www.selfcontained.us/2009/09/16/getting-keycode-values-in-javascript/
keycode = {
getKeyCode : function(e) {