Skip to content

Instantly share code, notes, and snippets.

View rubiety's full-sized avatar

Ben Hughes rubiety

View GitHub Profile
@rubiety
rubiety / pytorch_cpu_mps_comparison.py
Last active December 20, 2023 06:41
Pytorch CPU vs GPU (Apple Silicon MPS) Performance Comparison (Scaling with Matrix Size)
import torch
import timeit
def compare_cpu_mps(size, dimensions = 2, iterations = 2_500):
a_cpu = torch.rand(size, device='cpu')
b_cpu = torch.rand(tuple((size for n in range(dimensions))), device='cpu')
a_mps = torch.rand(size, device='mps')
b_mps = torch.rand(tuple((size for n in range(dimensions))), device='mps')
print(' - cpu', timeit.timeit(lambda: a_cpu @ b_cpu, number=iterations))
@rubiety
rubiety / usage.coffee
Last active January 1, 2016 16:39
Collection-bound select list with Backbone Marionette
options = new Backbone.Collection([{id: 1, name: "Blue"}, {id: 2, name: "Green"}])
view = new SelectListView({ collection: options })
view.render()
@rubiety
rubiety / 2013_flight_roster.txt
Last active December 31, 2015 21:39
2013 Flight Roster: 155 flight legs | 231,674 miles
Date OR DT Distance
2013-01-25 SAN DEN 853
2013-01-25 DEN STL 770
2013-01-26 STL ORD 258
2013-01-28 SAN ORD 1723
2013-01-28 ORD STL 258
2013-01-28 STL IAH 667
2013-01-28 IAH SAN 1303
2013-02-01 SAN DEN 853
2013-02-01 DEN BNA 1013
@rubiety
rubiety / mileage_runs.txt
Last active October 13, 2015 20:57
January Mileage Runs
* [JAN25] SAN-DEN-STL, STL-ORD-SAN: 4699 for $133.20 (2.83 CPM)
* [JAN28] SAN-ORD-STL-IAH-SAN: 4193 for $127.20 (3.03 CPM)
* [FEB01] SAN-DEN-BNA, BNA-IAH-SAN: 3826 for $140.20 (3.66 CPM)
* [FEB05] SAN-SFO-EWR-PHL, PHL-EWR-SFO-SAN: 7130 (7130 PQM) for $218.80 (3.07 CPM)
* [FEB08] SAN-ORD-STL-SFO-SAN: 4458 for $128.70 (2.89 CPM)
* [FEB11] SAN-IAH-ORD-MCI, MCI-ORD-SFO-SAN: 5574 for $145.30 (2.61 CPM)
* [FEB17] SAN-EWR-ZFV, ZFV-EWR-SAN: 5350 (4850 PQM) for $140.70 (2.63 CPM)
* [FEB21] SAN-EWR-ZFV, ZFV-EWR-SAN: 5350 (4850 PQM) for $140.70 (2.63 CPM)
* [MAR02] SAN-EWR-ZFV, ZFV-EWR-SAN: 5350 (4850 PQM) for $140.70 (2.63 CPM)
* [MAR04] SAN-EWR-ZFV, ZFV-EWR-SAN: 5350 (4850 PQM) for $140.70 (2.63 CPM)
class Project
def penguin
self.class.where(:something => parent_object.something)
end
end
@rubiety
rubiety / jazzity_scale_tones.js
Created April 15, 2012 16:57
Jazzity Scale/Mode Tone Indexes
// Generated from Ruby:
// JSON.pretty_generate Scale.all.map do |s|
// {:name => s.name, :modes => s.modes.inject({}) {|b,m| b[m.name] = m.tones.map(&:tone); b} }
// end
[
{
"name": "Major",
@rubiety
rubiety / png_renderer.rb
Created January 15, 2012 22:51
Jazzity PngRenderer using Capybara Webkit
require "capybara/rails"
class PngRenderer
include Capybara::DSL
DEFAULT_PATH = Rails.root.join("public/images/rendered")
def initialize(url)
@url = url
end
@rubiety
rubiety / staff_to_png.rb
Created January 15, 2012 00:00
Background PNG Generation for Jazzity
require "capybara/rails"
Capybara.javascript_driver = :webkit
class StaffToPng
@queue = :staff_to_png
def self.perform(chord)
visit "/chords/#{chord}"
page.driver.render "generations/#{chord}.png"
@rubiety
rubiety / gist:1448238
Created December 8, 2011 19:46
freezing.rb
class City
def freezing?
case name
when "San Diego"
current_temperature < 60
when "Austin"
current_temperature < 50
when "Rochester"
current_temperature < -10
else