Skip to content

Instantly share code, notes, and snippets.

View mattfitzgerald's full-sized avatar

Matt Fitzgerald mattfitzgerald

View GitHub Profile
# will not pair people with a member of their houshold
households = [%w(Jeannie Terry\ Snr), ["Benton"], ["Terry"], %w(Mandy Marcos Elías Mateo), %w(Erin Matt)]
households.sort!{|a,b| b.length <=> a.length}
names = households.flatten
pairs = {}
names.each do |name|
household = households.find{|h| h.include?(name)}
available_names = (names - pairs.values - household)
@mattfitzgerald
mattfitzgerald / TalkBox.rb
Created February 14, 2018 23:43
TalkBox api with RestClient
class Talkbox
USER = ENV['TALKBOX_USER']
PASS = ENV['TALKBOX_PASS']
BASE_URL = ENV['TALKBOX_API_URL']
def self.get entity
url = "#{BASE_URL}/#{entity}"
response = RestClient::Request.execute method: :get, url: url, user: USER, password: PASS
JSON.parse(response.body)
#print-only {
visibility: hidden;
}
@media print {
body * {
visibility: hidden;
}
#print-only, #print-only * {
@mattfitzgerald
mattfitzgerald / report.rb
Created March 4, 2015 06:51
Start of basic comms report with API
require 'HTTParty'
class SquawkboxAPI
include HTTParty
def initialize(username, password)
@auth = {:username => username, :password => password}
@squawkbox_host = 'app.mysquawkbox.com'
self.class.base_uri URI::HTTPS.build(host: @squawkbox_host, path: '/service/v1').to_s
end
package main
import "math"
func main() {
s := Sphere{center: Point{0, 0, 0}, radius: 1}
p := Point{0.1, 0.1, 0.1}
println(s.contains(p))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TrelloView</title>
<!-- Bootstrap -->
require 'sinatra'
require 'trello'
get '/' do
Trello.configure do |config|
config.developer_public_key = ASK_MATT
config.member_token = ASK_MATT
end
require 'sinatra'
require 'zendesk_api'
require 'logger'
require 'haml'
# launch with > rerun 'rackup'
class ZenDash < Sinatra::Base
def initialize
@mattfitzgerald
mattfitzgerald / gist:7366268
Last active December 27, 2015 17:59
Log file parser
require 'time'
# TODO:
#
# add enquire links (done)
# and enquire link responses (done)
# add restart events on a thread (done)
#
#
# looking at a simple set of back prices ('payouts')
class Book
def initialize (payouts)
@payouts = payouts
end
def probabilities
@payouts.map{|p| 1.0/p}
end