Skip to content

Instantly share code, notes, and snippets.

/*
* Air Hockey Score Board
*
* This project added electronic score keeping to a little tabletop air hockey game
*
* I made light blocking sensors for the goals using pairs of infrared LEDs, one
* emitting light, the other acting as a sensor, amplified through an NPN transistor
*
* The scoreboard itself contains a small speaker, a 4 digit LED display and a push
* button attached to the arduino's reset pin. The display is a TM1637 which is an
@benwtr
benwtr / puppet_attributes_function.rb
Created February 10, 2018 03:01
Replacement for hiera using mixlib-config and a few lines of code
# This is a puppet function similar to the hiera() lookup function.
#
# It can load yaml, json or ruby config files
#
# It uses [mixlib-config](https://github.com/chef/mixlib-config/) so, when writing ruby config files
# you have a flexible DSL at your disposal, similar to the chef attributes DSL.
#
# You could also use ruby any way you like inside these configuration files, including calling out
# to external data sources.
#

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@benwtr
benwtr / format_pov.rb
Created November 5, 2017 18:52
arduino POV fan display
#!/usr/bin/env ruby
# scrappy ruby code to generate data to send over the serial connection to the transmitter
def figlet(str)
`echo #{str} | figlet -f banner3 -w 128 | cut -b1-128 | tr "#" "1" | tr " " "0"`.split("\n")
end
def reorder_for_leds(figlet_output)
reordered = ''
@benwtr
benwtr / http_eyaml_backend.rb
Last active March 9, 2017 00:40
Hiera HTTP+eYAML backend
# hiera-http backend with the decryption bits from the hiera-eyaml bolted on
# see https://github.com/crayfishx/hiera-http/ and https://github.com/voxpupuli/hiera-eyaml/
# Configure this the same way as you would hiera-http, plus the encryption options from eyaml.
# for example, a hiera 3 configuration might look something like this:
#
# ---
# :backends:
# - http_eyaml
#
@benwtr
benwtr / infinity_ergodox_logo.md
Last active December 16, 2016 20:39
Changing the Infinity Ergodox logo

Changing ergodox infinity logo

Assuming Ubuntu16.04 but any OS will do if you have python3 and PIL installed and can satisfy all the required dependencies to build the firmware.

Create a keyboard layout and download a firmware https://input.club/configurator-ergodox/

Unzip the firmware archive and have the .kll files ready

Create a logo, save it as a black on white 128x32 .bmp

# Description:
# Hubot interface for timezone.io
#
# Configuration:
# HUBOT_TIMEZONEIO_URL - full team url eg: https://timezone.io/team/buffer
#
# Commands:
# hubot tz - Show team's local time across time zones via timezone.io
#
# Dependencies:
# Policyfile.rb
name "some_policy"
run_list 'derp'
require 'json'
JSON.parse(File.read('../environments/some_env.json'))['default_attributes'].each_pair{|k,v| default[k]=v}
@benwtr
benwtr / warmup.rb
Last active November 4, 2015 20:21
Ever wish your thermostat had a "turn heat on for x minutes" feature? Me too, but not enough to spend more than 5 minutes writing a script to do it
#!/usr/bin/env ruby
# Tell a nest thermostat to kick the heat on for n minutes
require 'nest_thermostat'
unless ARGV[0]
puts 'Usage: warmup.rb <minutes>'
exit 1
end
@benwtr
benwtr / hubot-twitter-user.coffee
Created October 27, 2015 23:36
Example Hubot script that uses an OAuth PIN flow to authenticate individual users with Twitter
# Description
# Do things on twitter through hubot, as your logged in user after authenticating with an oauth pin.
#
# Configuration:
# HUBOT_TWITTER_CONSUMER_KEY - API key for hubot app registered on dev.twitter.com
# HUBOT_TWITTER_CONSUMER_SECRET - API secret for hubot app registered on dev.twitter.com
#
# Commands:
# hubot t auth <pin_code> - authenticate with pin code
# hubot t clear my credentials - forget any authentication tokens