Skip to content

Instantly share code, notes, and snippets.

@photomattmills
photomattmills / usb_hid_keys.h
Created July 25, 2019 18:37 — forked from MightyPork/usb_hid_keys.h
USB HID Keyboard scan codes
/**
* USB HID Keyboard scan codes as per USB spec 1.11
* plus some additional codes
*
* Created by MightyPork, 2016
* Public domain
*
* Adapted from:
* https://source.android.com/devices/input/keyboard-devices.html
*/

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

Dates in Ruby

So, you want to calculate some arbitrary date things? Easy! Let's use IRB! Open up the terminal (don't worry, there aren't any dragons here unless you've brought them). Then type irb and hit enter. it should bring up another prompt that looks something like this:

 > irb
irb(main):001:0>

@photomattmills
photomattmills / Legacy code jabberwocky
Last active April 22, 2017 15:15 — forked from kerrizor/gist:6accb502be6bf93ee572
Legacy code jabberwocky , originally by @kerrizor, cloned here so I can find it in a year
’Twas brillig, and the slithy git repos
Did gyre and gimble in the wecks:
All mimsy were the borogoves,
And the mome raths Mutex.
“Beware the legacy code, my son!
The classes that bite, the patches that catch!
Beware the Gemfile.lock, and shun
The frumious monkey patch!”
require 'net/http'
require 'open-uri'
require 'csv'
uri = URI('http://xi.hope.net/schedule.html')
html = Net::HTTP.get(uri)
entries = html[2601..-1752].split('<h3')
CSV.open("/tmp/schedule.csv", "wb")do |csv|
require 'typhoeus'
require 'json'
require 'uri'
domain = 'https://silver-jellyfish.rmq.cloudamqp.com/'
#get your username and password and put them here
userpass = "user:pass"
connections_req = Typhoeus::Request.get("#{domain}api/connections", userpwd: userpass )
connections = JSON.parse(connections_req.body)
@photomattmills
photomattmills / wb
Created February 11, 2016 07:16
whois with the cruft removed
#! /usr/bin/env bash
# put this somewhere in your $PATH, and enjoy! most of the regex was @cczona, and the sort | uniq was me.
whois $1 | sed "s/^ *//g" | grep -i -v "^(Please|Billing|Admin|Tech|register|\d\|>>>|Registr|Sponsoring)|whois" | grep ":" | grep -v "^(with|NOTICE|by the|to:|please)" | sort -f | uniq -i
@photomattmills
photomattmills / mouse.ino
Created October 24, 2015 18:16
Joystick mouse code for arduino micro
/*
Joystick Mouse Control
Controls a PC mouse from a joystick on an Arduino Micro. Adapted from
Adafruit's code for the Pro Trinket (https://learn.adafruit.com/pro-trinket-usb-hid-mouse/example-joystick-mouse)
by Matt Mills. Released under the same license, GPLv3.
Uses the joystick pushbutton to click the left mouse button
Hardware:
* 2-axis joystick connected to pins A0 and A1 with pushbutton on D10
#! /Users/matt/.rvm/rubies/ruby-2.2.1/bin/ruby
class Foo
attr_accessor :bar
def initialize
puts "initialized"
@bar = 5
end