Skip to content

Instantly share code, notes, and snippets.

/Users/matt/.rvm/gems/ruby-1.9.2-p290@healthism/gems/json-1.4.6/lib/json/common.rb:146:in `parse': 375: unexpected token at 'OK]' (JSON::ParserError)
from /Users/matt/.rvm/gems/ruby-1.9.2-p290@healthism/gems/json-1.4.6/lib/json/common.rb:146:in `parse'
from /Users/matt/.rvm/gems/ruby-1.9.2-p290@healthism/gems/gibbon-0.3.5/lib/gibbon.rb:41:in `rescue in call'
from /Users/matt/.rvm/gems/ruby-1.9.2-p290@healthism/gems/gibbon-0.3.5/lib/gibbon.rb:38:in `call'
from /Users/matt/.rvm/gems/ruby-1.9.2-p290@healthism/gems/gibbon-0.3.5/lib/gibbon.rb:56:in `method_missing'
@mattsmith
mattsmith / quiet_assets.rb
Created February 21, 2012 02:22
quiet_assets.rb
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets
@mattsmith
mattsmith / case.rb
Created February 21, 2012 20:27
switch
case @questionnaire
when Screening
# do stuff for Screening
when Quizzes::Questionnaire
# do stuff for Quizzes
when Surveys::Questionnaire
# do stuff for Surveys
when Surveys::Questionnaire
# do stuff for Inventories
end
@mattsmith
mattsmith / issue-panda.log
Created August 29, 2012 05:41
Issue with Panda Gem
NoMethodError: undefined method `hydra' for Typhoeus::Hydra:Class
from /Users/matt/.rvm/gems/ruby-1.9.3-p194@thinkific/gems/faraday-0.8.0/lib/faraday/adapter/typhoeus.rb:7:in `setup_parallel_manager'
from /Users/matt/.rvm/gems/ruby-1.9.3-p194@thinkific/gems/faraday-0.8.0/lib/faraday/adapter/typhoeus.rb:21:in `perform_request'
from /Users/matt/.rvm/gems/ruby-1.9.3-p194@thinkific/gems/faraday-0.8.0/lib/faraday/adapter/typhoeus.rb:14:in `call'
from /Users/matt/.rvm/gems/ruby-1.9.3-p194@thinkific/gems/faraday-0.8.0/lib/faraday/request/url_encoded.rb:14:in `call'
from /Users/matt/.rvm/gems/ruby-1.9.3-p194@thinkific/gems/faraday-0.8.0/lib/faraday/request/multipart.rb:13:in `call'
from /Users/matt/.rvm/gems/ruby-1.9.3-p194@thinkific/gems/faraday-0.8.0/lib/faraday/connection.rb:226:in `run_request'
from /Users/matt/.rvm/gems/ruby-1.9.3-p194@thinkific/gems/faraday-0.8.0/lib/faraday/connection.rb:99:in `post'
from /Users/matt/.rvm/gems/ruby-1.9.3-p194@thinkific/gems/panda-1.5.0/lib/panda/adapters/faraday.rb:27:
@mattsmith
mattsmith / watchr.rb
Created October 4, 2012 21:26
Watchr Autotest workflow with Zeus
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)
@mattsmith
mattsmith / bundle log
Created November 25, 2012 00:35
Installing capybara
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.2)
Using i18n (0.6.1)
Using multi_json (1.3.7)
Using activesupport (3.2.9)
Using builder (3.0.4)
Using activemodel (3.2.9)
Using erubis (2.7.0)
Using journey (1.0.4)
@mattsmith
mattsmith / dynamic_stylesheet.rb
Created October 11, 2013 06:31
Renders a scss stylesheet with erb using Tilt templates.
class DynamicStylesheet
# logical_path = 'app/assets/stylesheets/custom.css.scss.erb'
def render(logical_path, data={})
path = Rails.root.join(logical_path)
context = env.context_class.new(env, logical_path, Pathname.new(path))
# TODO Change to Tilt.templates_for(file) in Tilt 2.x
templates = [Tilt::ERBTemplate, Sass::Rails::ScssTemplate]
//In the page Head:
<script type="text/javascript">
(function(f,b){if(!b.__SV){var a,e,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" "); for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=f.createElement("script");a.type="text/javascript";a.async=!0;a.src="//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";e=f.getElementsByTagName("script")[0];e.parentNode.insertB