Skip to content

Instantly share code, notes, and snippets.

View jhawthorn's full-sized avatar
⌨️

John Hawthorn jhawthorn

⌨️
View GitHub Profile
@jhawthorn
jhawthorn / gist:f0097bf098e93187064f7f75af3bda9e
Created February 5, 2018 05:37
Ruby startup time with JIT
$ time ruby --disable-gems -e ''
0.006 total
$ time ruby -e ''
0.036 total
$ time ruby --disable-gems --jit -e ''
0.184 total
$ time =ruby --jit -e ''
@jhawthorn
jhawthorn / gist:898305d08ea3b2cdc5bc089bc13f7550
Created February 4, 2018 21:58
Testing out ruby's new MJIT
$ ruby -v
ruby 2.6.0dev (2018-02-05 trunk 62211) [x86_64-linux]
$ time =ruby --disable-gems 15b.rb
313
=ruby --disable-gems 15b.rb 8.99s user 0.00s system 99% cpu 9.011 total
$ time =ruby --disable-gems --jit 15b.rb
313
=ruby --disable-gems --jit 15b.rb 7.37s user 0.04s system 105% cpu 6.991 total
class I18nLogger
include I18n::Backend::Base
include I18n::Backend::Flatten
def available_locales
['en']
end
def lookup(locale, key, scope = [], options = {})
p [locale, key, {scope: scope, options: options}]
require 'date'
data = File.read("CHANGELOG.md")
versions = []
data.scan(/## Solidus ([0-9\.]+)\.0 \(([0-9]+)-([0-9]+)-([0-9]+)\)/) do
version = $1
release_date = Date.new($2.to_i, $3.to_i, $4.to_i)
eol = [release_date >> 18, Date.new(2018, 05, 05)].max
set -e
git_changed() {
changes=$(git diff)
[ -n "$changes" ]
}
find spec -name '*_spec.rb' | xargs sed -i 's/spree_\(get\|post\|put\|delete\)/\1/g'
if git_changed; then
git commit -am 'Use normal get/post/put/delete test helpers' || true
bundle exec rspec $(ag -s binding.pry spec | sed 's/^\([^:]*:[0-9]*\):.*$/\1/g')
SELECT DISTINCT "spree_shipping_methods".*
FROM "spree_shipping_methods"
INNER JOIN "spree_shipping_method_categories"
ON "spree_shipping_method_categories"."shipping_method_id" =
"spree_shipping_methods"."id"
INNER JOIN "spree_ship ping_method_zones"
ON "spree_shipping_method_zones"."shipping_method_id" =
"spree_shipping_methods"."id"
INNER JOIN "spree_zones"
ON "spree_zones"."id" = "spree_shipping_method_zones"."zone_id"
@jhawthorn
jhawthorn / particle_temperature_sensor.cc
Created November 16, 2015 01:14
A wifi temperature sensor using a particle photon
// This #include statement was automatically added by the Particle IDE.
#include "Particle-OneWire/Particle-OneWire.h"
// This #include statement was automatically added by the Particle IDE.
#include "particle-dallas-temperature/particle-dallas-temperature.h"
// Init Dallas on pin digital pin 6
DallasTemperature dallas(new OneWire(D6));
#!/usr/bin/env ruby
class Example
attr_reader :spec_name, :status
def initialize(example_id, status, run_time, _)
@example_id = example_id
@status = status
@run_time = run_time
end
end
@jhawthorn
jhawthorn / drake_game.md
Last active February 17, 2023 06:09
Parking Spotting

Points given for people parking in smartcar spot outside of the drake

points
100 Actual smart car
150 Motorbike
50 SUV or minivan
25 Regular car
75 Truck