Skip to content

Instantly share code, notes, and snippets.

@dobbs
dobbs / builder.rb
Last active August 29, 2015 14:12
Simple Abstraction for Builder objects in Ruby
class Builder < Struct
def self.with(spec, &block)
struct = new(*(spec.keys)) do
def initialize(options={})
super
options.each { |opt, value| self[opt] = value }
freeze
end
def with(options, &block)
@dobbs
dobbs / .COMMANDS.sh
Last active August 29, 2015 14:25
kitchen converge fails consistently first time through for chef-server on ubuntu-14.04
# I created a minimal wrapper around the chef-server cookbook
# with these commands. For your convenience I include in this gist the complete .kitchen.yml, metadata.rb, and recipies/default.rb
# You can see the output from 'kitchen converge' in the console.log also included in the gist.
# the kitchen log file is in an earlier revision of this gist:
# https://gist.githubusercontent.com/dobbs/1611a20cdb8232c76617/raw/28e99ec849ee3c42901db3a242f5917d8b78fcce/.kitchen%2520logs%2520default-ubuntu-1404.log
chef generate cookbook wrap-chef-server
cd wrap-chef-server
echo "depends 'chef-server', '~> 4.0.0'" >> metadata.rb
echo "include_recipe 'chef-server'" >> recipes/default.rb
ruby -pi -e 'gsub(/ubuntu-.*/, "ubuntu-14.04"); gsub(/^.*name: centos.*$/, "")' .kitchen.yml
@dobbs
dobbs / ipaddress
Last active December 4, 2016 22:40
just gimme the IP address already
#!/bin/bash
#
# /usr/local/sbin/ipaddress
usage() {
cat <<EOF
Usage: $(basename $0) [interface]
Report the IP 4 address for the default interface (or the one given in the params)
(default interface is computed from the default route)
@dobbs
dobbs / btc-usd-5years.json
Last active February 3, 2018 22:37
Cache of bitcoin to USD prices
{"Response":"Success","Type":100,"Aggregated":false,"Data":[{"time":1359936000,"close":20.43,"high":21.05,"low":19.86,"open":20.59,"volumefrom":52219.14,"volumeto":1066570.21},{"time":1360022400,"close":20.6,"high":20.79,"low":20.2,"open":20.43,"volumefrom":29212.44,"volumeto":600949.67},{"time":1360108800,"close":21.18,"high":21.33,"low":20.6,"open":20.6,"volumefrom":51989.6,"volumeto":1096396.16},{"time":1360195200,"close":22.15,"high":22.22,"low":20.77,"open":21.18,"volumefrom":64263.77,"volumeto":1388465.81},{"time":1360281600,"close":22.66,"high":22.77,"low":22,"open":22.15,"volumefrom":48649.93,"volumeto":1090678.48},{"time":1360368000,"close":23.65,"high":23.99,"low":22.58,"open":22.66,"volumefrom":38133.01,"volumeto":886034.01},{"time":1360454400,"close":23.97,"high":24.11,"low":22.67,"open":23.65,"volumefrom":56426.07,"volumeto":1321513.68},{"time":1360540800,"close":24.65,"high":24.68,"low":23.65,"open":23.97,"volumefrom":29526.73,"volumeto":712458.7},{"time":1360627200,"close":25.17,"high":25.83,"l
@dobbs
dobbs / Dockerfile
Last active May 14, 2018 22:05
npm info lifecycle [email protected]~build: Failed to exec build script
FROM node:8.5 as src
WORKDIR /usr/local/src
RUN git clone "https://github.com/OriginProtocol/demo-dapp.git" \
--branch master
RUN cd demo-dapp && npm install
RUN cd demo-dapp && npm run build
FROM abiosoft/caddy:0.11.0
COPY --from=src /usr/local/src/demo-dapp/build/ /srv