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 / private.xml
Created November 30, 2015 23:05
F19 Hyper Key overlay, Vim keys and other handy keys for V60 layouts in Karabiner
<?xml version="1.0"?>
<root>
<item>
<name>F19 to F19</name>
<appendix>(F19 to Hyper (ctrl+shift+cmd+opt) + F19 Only, send escape)</appendix>
<identifier>private.f192f19_escape</identifier>
<autogen>
__KeyOverlaidModifier__
KeyCode::F19,
KeyCode::COMMAND_L,
BAKER'S FORMULA
(by WEIGHT... eg. for 100g flour, use 62g water... for 50oz flour, use 31oz water, etc)
100 unbleached all-purpose flour
2.5 kosher salt
1 bread machine yeast (comes in a small jar on the baking aisle near the chocolate chips. I recommend Red Star)
3 sugar or honey
62 water, slightly warm (100 degrees)

Keybase proof

I hereby claim:

  • I am bnferguson on github.
  • I am bnferguson (https://keybase.io/bnferguson) on keybase.
  • I have a public key ASApFHyvjnffEraiZ5ep6-KGKf9piAcVmF9zgt87hKZ5ggo

To claim this, I am signing this object:

@bnferguson
bnferguson / gist:9733382
Last active August 29, 2015 13:57
Mezcal, Lime Juice, St Germain, Water, Bitters
2 oz Mezcal (Senorio Reposado, if using something smokier like Vida, go with 1.5oz or half and half with tequilla)
1 oz Lime Juice
1 oz St Germain
3/4th oz Water (optional, you can vary the water and shaking time to adjust the smoothness of the drink)
4 drops Bitterman's Burlesque Bitters
Servo leftWheel;
Servo rightWheel;
int drive(String command);
int stop(String command);
void setup() {
leftWheel.attach(A0);
rightWheel.attach(A1);
Spark.function("drive", drive);
@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 / gist:5859943
Last active December 18, 2015 23:09
Oh EXIF, you so crazy.
{"shutter_speed_value"=>"1/4171261517277002370470245135895331170085810498925532185325970964511636730365148194777118414466694459130583157525117224352830282821856843891507380403811977383737026772608383911501286649822952557228730041328348830539955430739399780497616885078100607261516087156543315111740125571561385540769311243134471864304649466975908886839621461386596155989732613149011239449552293923524311602269588414441547892959489974908123300917232199467429562462314779168173751676481644575275426415789922653435390084580705015360070610825385326678048265796707933592122020963821876035005177951152210295807972086964365890012181086531856426852453233790946808945267217135805930321029462262867408336151650234092631350325781171644248079871337908499022956810856311009988241185929674434685750644659836289250545446824060913375580888575507796300534130365439615640133510264840200171074848244549817728859386831371424972550642277885577854148035103549069177267822458607315617596403469693693956602006599084262977641908333406135526457732081
@bnferguson
bnferguson / gist:5511919
Created May 3, 2013 17:48
Getting at the CFLAGS of your installed ruby. You want to make sure some optimization flags are set. -O2 is the recommended one on GCC 4.x according to http://www.gentoo.org/doc/en/gcc-optimization.xml
# What you might see (note the complete lack of response - esp look for the lack of an optimization flag, eg -O2)
$ ruby -r rbconfig -e 'puts RbConfig::CONFIG["CFLAGS"]'
# What you should see (note the -O2 optimization):
$ ruby -r rbconfig -e 'puts RbConfig::CONFIG["CFLAGS"]'
-fno-strict-aliasing -g -O2 -fPIC'