Skip to content

Instantly share code, notes, and snippets.

View lastobelus's full-sized avatar

Michael Johnston lastobelus

View GitHub Profile

Graphing Widget

The graphing widget shows graphs using the Rickshaw graphing library. The names of data fields should be (vaguely) familiar if you've used Rickshaw before.

It's recommended that you replace the /assets/javascripts/rickshaw.min.js from your dashboard with the latest from here.

Supported HTML data fields

@lastobelus
lastobelus / gist:0b76dc715a48f4004f5e
Created June 3, 2015 20:57
rspec one at a time with alias to run the last one
alias rsp1="script -q /dev/null rspec spec --fail-fast --order defined | tee /tmp/lastrspec; ansifilter /tmp/lastrspec > /tmp/tmplastrspec; mv /tmp/tmplastrspec /tmp/lastrspec"
rsplast() {
local rcmd=`grep -e '^rspec ' /tmp/lastrspec | cut -f 2 -d ' '`
# local rcmd=`grep -e '^rspec ' /tmp/lastrspec`
echo "rspec $rcmd"
bundle exec rspec $rcmd
history -s bundle exec rspec $rcmd
}
require 'spec_helper'
describe "shopify api nested resources", unless: ENV['LIVE_SHOPIFY_SPECS_TOKEN'].nil? do
before(:all) do
session = ShopifyAPI::Session.new(ENV['LIVE_SHOPIFY_SPECS_DOMAIN'], ENV['LIVE_SHOPIFY_SPECS_TOKEN'])
ShopifyAPI::Base.activate_session(session)
@old_ar_logger = ActiveResource::Base.logger
@created = []
ActiveResource::Base.logger = Logger.new STDOUT if ENV['LOG_SHOPIFY']
WebMock.disable!
@lastobelus
lastobelus / gist:11358852
Created April 28, 2014 00:21
shell functions to convert erb to slim
# will skip *.js.erb files
function slimify() {
# because gem install is slow, particularly if installing nokogiri
if gem list html2haml | grep html2haml;then
if gem list haml2slim | grep haml2slim; then
gem update html2haml haml2slim -N
else
gem update html2haml -N
gem install haml2slim -N
@lastobelus
lastobelus / gist:7943705
Last active December 31, 2015 05:49
An asynchronous, debounced, optionally caching validator for ember-validations (requires my patch in pull request 64)
var UrlExists = Ember.Object.extend({
test: function(url){
var promise = Ember.Deferred.create();
if(Ember.isEmpty(url)){
promise.reject(false);
} else {
$.getJSON("http://query.yahooapis.com/v1/public/yql?"+
"q=select%20*%20from%20html%20where%20url%3D%22"+
encodeURIComponent(url)+"%22&format=json'&callback=?",
function(data){
@lastobelus
lastobelus / gist:7681172
Created November 27, 2013 18:57
Today I realized TextMate lets you put options in snippet placeholders, so `${2|model,controller,value|}` will result in a little popup with options one, two, and three when you tab to that expansion. I definitely wanted to use this, particularly in my Ember snippets for this.get('xxxx') and this.set('xxx'). But I didn't want to guess which opti…
egrep -rh --exclude=ember* --exclude=*raphael* --exclude=*jquery* "this.get\(.*\)" * | sed -E "s/.*this.get..([^'\"]+)['\"].*/\\1/g" | sort | uniq -c | sort
@lastobelus
lastobelus / gist:7650673
Created November 25, 2013 23:19
kill currently running unicorns
# assuming alias pgrep="ps axu | grep -v 'grep' | grep "
kill `pgrep "unicorn master" | awk '{print $2}' | tr "\n" " "`
@lastobelus
lastobelus / jsbinsettings
Created November 25, 2013 01:25
jsbin custom settings
settings = {
jshint: true,
editor: {
theme: "blackboard",
indentUnit: 2,
smartIndent: true,
tabSize: 2,
indentWithTabs: false,
autoClearEmptyLines: true,
lineWrapping: true,
mkdir -p $rvm_path/patches/ruby/1.9.3/p385
curl https://github.com/funny-falcon/ruby/compare/p385...p385_falcon.diff > $rvm_path/patches/ruby/1.9.3/p385/falcon.patch
rvm reinstall 1.9.3-p385 --patch falcon
// JQuery Best Practices
/************* Scope *********************/
// write methods that add handlers etc. so that they can be re-used in scopes other than document.ready
// http://www.braindonor.net/blog/jquery-best-practices-part-1-managing-scope/406/
function my_button(scope) {
scope.find('.button').click(function(){