Skip to content

Instantly share code, notes, and snippets.

def deeply_sort_hash(object)
return object unless object.is_a?(Hash)
hash = RUBY_VERSION >= '1.9' ? Hash.new : ActiveSupport::OrderedHash.new
object.each { |k, v| hash[k] = deeply_sort_hash(v) }
sorted = hash.sort { |a, b| a[0].to_s <=> b[0].to_s }
hash.class[sorted]
end
@jaredmoody
jaredmoody / sublime_one_column.scpt
Last active December 30, 2015 23:59
Applescripts for positioning sublime and terminal
# sets sublime to single column,
# moves the terminal to right half of 27" iMac
# this helps script work with quicksilver triggers
delay 0.01
# make sublime single column
tell application "System Events"
keystroke "1" using {command down, option down}
end tell
# config yml
tunnels:
client:
hostname: foo
proto:
https: 443
# POST gives => 400 - The plain HTTP request was sent to HTTPS port
17:30:51 - ERROR - Guard::Brakeman failed to achieve its <run_all>, exception was:
> [#05AB2BAC888F] NoMethodError: undefined method `run_checks' for nil:NilClass
> [#05AB2BAC888F] /Users/jaredmoody/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/guard-brakeman-0.8.1/lib/guard/brakeman.rb:58:in `run_all'
> [#05AB2BAC888F] /Users/jaredmoody/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/guard-1.8.3/lib/guard/runner.rb:99:in `block in run_supervised_task'
> [#05AB2BAC888F] /Users/jaredmoody/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/guard-1.8.3/lib/guard/runner.rb:97:in `catch'
> [#05AB2BAC888F] /Users/jaredmoody/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/guard-1.8.3/lib/guard/runner.rb:97:in `run_supervised_task'
> [#05AB2BAC888F] /Users/jaredmoody/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/guard-1.8.3/lib/guard/runner.rb:54:in `block (2 levels) in run'
> [#05AB2BAC888F] /Users/jaredmoody/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/guard-1.8.3/lib/guard/runner.rb:175
@jaredmoody
jaredmoody / unused_progress.rb
Created November 29, 2012 01:25 — forked from natritmeyer/unused.rb
Cucumber formatter for printing unused steps alongside progress
# Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
#
# http://www.natontesting.com
#
# Save this in a file called 'unused_progress.rb' in your 'features/support' directory. Then, to list
# all the unused steps in your project, run the following command:
#
# cucumber -d -f Cucumber::Formatter::UnusedProgress
#
# or...
@jaredmoody
jaredmoody / guard_cucumber.rb
Created November 28, 2012 23:34
guard cucumber
guard 'cucumber', :cli => "-f UnusedProgress" do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end
@jaredmoody
jaredmoody / imp_reed.nut
Created November 19, 2012 03:18
Electric Imp Reed Sensor
// Reed Sensor
function changed()
{
local result = hardware.pin1.read();
server.show(result?"On":"Off");
hardware.pin9.write(result);
}
// configure pin 1 as digital input
> rake db:migrate --trace
(in /Users/jaredmoody/Sites/refinery_git)
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `acts_as_taggable_on' for Blog(Table doesn't exist):Class
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1959:in `method_missing_without_paginate'
/Users/jaredmoody/Sites/refinery_git/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:170:in `method_missing'
@jaredmoody
jaredmoody / gist:116950
Created May 24, 2009 04:12
applescript to show itunes current track with growltunes
tell application "GrowlTunes"
show current track
end tell
@jaredmoody
jaredmoody / gist:116949
Created May 24, 2009 04:00
applescript to show itunes current playing track using iscrobbler
tell application "iScrobbler.app"
«event iSCbNPly»
end tell