Skip to content

Instantly share code, notes, and snippets.

View csaunders's full-sized avatar

Christopher Saunders csaunders

View GitHub Profile
@csaunders
csaunders / import_action.rb
Created January 18, 2014 17:30
Application code that is needed to do an API import into your local database
class Importer
def import
api_products = ShopifyAPI::Product.find(:all)
ShopProductSink::Product.create_from_resources(api_products)
end
end
def request(data, hmac=nil)
options = {
:method => 'POST',
:input => data,
'X-Shopify-Hmac-SHA256' => hmac || calculate_hmac(data)
}
ActionDispatch::Request.new(Rack::MockRequest.env_for("", options))
end
@csaunders
csaunders / studeldoodle.rb
Created February 3, 2014 20:58
doodleldoeldodleo
module Doodle
class Poodle
end
end
module Strudel
module Doodle
class Fancy
def new_poodle
@csaunders
csaunders / migration_guide.md
Last active August 29, 2015 13:57
Metafield Migration Guide

It was brought to our attention that the integer value type in our metafields API wasn't working the way you'd expect and required weird hacks in liquid such as {{ metafield.value | plus: 0}} to coerce the values back into integers. This was anything but desirable and we wanted to correct this discrepancy. There were some side-effects that came out of this which were accidental.

This change fixes the way the Shopify Metafield API behaves. According to the documentation two value_types are supported, string and integer though the integer value wasn't being respected and was simply just a string.

With the changes that have been deployed; if your field was an set to an integer value_type it will be properly coereced into the data-type you are expecting. Though if you were using the field incorrectly such as storing `"some string dat

@csaunders
csaunders / _setup.md
Last active August 29, 2015 14:01
Gosu Demo

If you are on a Mac all you should need to do is:

gem install gosu

To run the game simply:

ruby pawng.rb

You will require 2 png assets:

scorch() {
ps aux | grep $@ | tr -s ' ' | cut -d ' ' -f 2 | xargs kill
}
@csaunders
csaunders / perf.out
Created August 2, 2014 13:43
Import Pipeline Performance
/Users/csaunders/development/ruby/steam-sauna [git::import_data *] [csaunders@OuterHaven] [13:41]
> bx rails c
Loading development environment (Rails 4.0.3)
irb(main):001:0> require 'benchmark'
=> false
irb(main):002:0> games = [201790, 251060, 227600]
=> [201790, 251060, 227600]
irb(main):003:0> pipeline = GameImportPipeline.new
=> #<GameImportPipeline:0x007ff8de129920>
irb(main):004:0> puts Benchmark.measure { pipeline.import(games) }
define :one_up do
use_synth :saw
[:e3, :g3, :e4, :c4, :d4, :g4].each do |n|
play n, release: 0.25
sleep 0.125
end
end
define :powerup do
use_synth :saw
@csaunders
csaunders / pl
Last active August 29, 2015 14:09
Pocket Lint: Remove the paradox of choice from your pocket articles.
#!/bin/bash
#run the app to grab a random URL then die
bundle exec ruby app.rb &
PID=$!
sleep 3
open http://localhost:4567
sleep 10
kill $PID