Skip to content

Instantly share code, notes, and snippets.

View maxwells's full-sized avatar

Max Lahey maxwells

View GitHub Profile
app_1 | DATABASE_URL: postgres://admin:password@db:5432/app_development
app_1 | ENV: {"PATH" => "/opt/shards/bin:/app/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "HOSTNAME" => "181af68fff6d", "DATABASE_URL" => "postgres://admin:password@db:5432/app_development", "AMBER_ENV" => "production", "HOME" => "/home/dev"}
app_1 |
app_1 | ENV: {"id" => "4", "FORKED" => "1", "AMBER_ENV" => "production"}
app_1 | DATABASE_URL:
app_1 | no driver was registered for the schema "", did you maybe forget to require the database driver? (ArgumentError)
app_1 |
app_1 |
app_1 | ENV: {"id" => "3", "FORKED" => "1", "AMBER_ENV" => "production"}
app_1 | DATABASE_URL:
@maxwells
maxwells / decorators.rb
Created October 20, 2017 21:11
garbage ruby decorators
module Decorator
def def_decorator(name, &blk)
define_method(name) do |method_name|
new_name = "#{method_name}_"
alias_method new_name, method_name
define_method(method_name) do
lmbda = lambda { send(new_name) }
blk.call(lmbda)
end
@maxwells
maxwells / protocol.rb
Created August 9, 2017 17:17 — forked from omnisis/protocol.rb
Ruby UDP Server/Client Pair with Custom Binary Protocol
require 'bindata'
class CustomProtocol < BinData::Record
endian :big
stringz :command_word
uint8 :op1
uint8 :op2
end
@maxwells
maxwells / immutable_struct.rb
Created July 13, 2016 21:34
~immutable structs
module ImmutableStruct
module PropSetter
attr_reader :props
def use_struct_props(*props)
attr_reader *props
@props = props
end
end
@maxwells
maxwells / light.rb
Last active July 13, 2016 21:06
2 hour sinatra
require 'rack'
require 'json'
require 'erb'
class Application
def self.application
@application ||= new
end
def self.configure(&blk)
@maxwells
maxwells / linearColorInterpolator.js
Created January 4, 2014 03:34
Find the color between any two color points through linear interpolation. Pretty basic & straight forward. Progress bar demo at: http://jsfiddle.net/99ycK/1/
Color = function(hexOrObject) {
var obj;
if (hexOrObject instanceof Object) {
obj = hexOrObject;
} else {
obj = LinearColorInterpolator.convertHexToRgb(hexOrObject);
}
this.r = obj.r;
this.g = obj.g;
this.b = obj.b;