Skip to content

Instantly share code, notes, and snippets.

View bnferguson's full-sized avatar

Brandon Ferguson bnferguson

View GitHub Profile
@bnferguson
bnferguson / tpm2.md
Created August 21, 2017 15:39 — forked from NyxCode/tpm2.md
TPM2 Protocol Description

TPM2 Protocol Implementation

Introduction

Frame data is transferred inside packets (similar to DMX, for example). A frame is an image representing a matrix or a light scene.

The packets start and end with one-byte characters. In between are a few control bytes followed by the payload. There is no set size for a payload; it is transmitted with each packet. This makes the protocol quite flexible. There are enough bytes in a single packet for an RGB matrix with 21,845 pixels, but if you just want to control an RGBW lamp, that only requires 9 bytes. The variable frame size means there is no overhead, allowing for maximum transfer speed.

TPM2 Packet Structure

@bnferguson
bnferguson / gist:6331903
Last active December 21, 2015 16:09 — forked from jkallner/prime.rb
#!/usr/bin/env ruby
#Ask the user for a number to test if it is a prime number or not
puts "Pleas input a number to test if its a prime number: "
input_number = gets.to_f
#Ensure that the user doesn't put in zero as zero isn't a prime (division by zero)
#Also note that by some definitions negative numbers are in fact prime numbers and therefore valid
while input_number == 0
puts "You submitted and invalid number or zero, please input a different number: "
@bnferguson
bnferguson / test.rb
Created August 22, 2013 14:09 — forked from jkallner/test.rb
#!/usr/bin/env ruby
puts "Please input the radius of the circle:"
input_radius = gets.to_f
# Keep looping until the user gives us a valid number
# Non number entires such as words would equate to 0 with the .to_f method above
while input_radius == 0
puts "Please try a number that doesn't equal 0"
puts "Please input the radius of the circle:"
@bnferguson
bnferguson / solo_data_bags.rb
Created June 30, 2011 17:19 — forked from rcreasey/solo_data_bags.rb
Using data bags with chef-solo
From: Brian Akins < brian@akins.org>
To: chef < chef@lists.opscode.com>
Subject: [chef] Data bag implementation for chef-solo
Date: Tue, 1 Feb 2011 10:42:05 -0500
We often use chef-solo for quick testing, etc. This is our extremely simple implementation of data bags for chef-solo. Add "data_bag_path /some/dir/data_bags" to your solo.rb and add this into your libraries:
if Chef::Config[:solo]
class Chef
module Mixin
module Language
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true