This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(/Safari/i.test(navigator.userAgent)){ //Test for Safari | |
var _timer=setInterval(function(){ | |
if(/loaded|complete/.test(document.readyState)){ | |
clearInterval(_timer) | |
walkmydog() // call target function | |
}}, 10) | |
} | |
// h/t @jresig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#shinypenny DSL | |
module MyAchievements | |
include :shiny_penny | |
translation_scope 'my_achievements' #=> winds up looking like en.my_achievements.ten_deals_closed | |
achievement :ten_deals_closed do | |
# What model(s) might trigger this? The achievement matching logic fires after every create/update on these models. | |
watches :deal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stuff | |
def to_sql | |
'where `stuff` = "bar"' | |
end | |
end | |
Foo.where(Stuff.new) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper('each_property', function(object, options) { | |
var out = ''; | |
for(key in object) { | |
out += options.fn({ | |
key: key, | |
value: object[key] | |
}); | |
} | |
return out; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script> | |
<script type="text/javascript"> | |
$(function() { | |
$ = function(selector) { | |
$ = jQuery; | |
return jQuery('#foobar').find(selector); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 192.168.2.1 (192.168.2.1) 6.516 ms 1.458 ms 1.265 ms | |
2 big (192.168.1.1) 2.893 ms 2.762 ms 11.572 ms | |
3 10.1.10.1 (10.1.10.1) 3.474 ms 3.490 ms 3.196 ms | |
4 73.98.104.1 (73.98.104.1) 58.097 ms 14.632 ms 13.373 ms | |
5 te-4-6-ur02.ferndale.wa.seattle.comcast.net (68.87.207.153) 17.316 ms 48.839 ms 19.630 ms | |
6 te-0-2-0-7-ar01.seattle.wa.seattle.comcast.net (68.86.96.49) 24.872 ms 24.388 ms 44.562 ms | |
7 ae-1-0-ar03.seattle.wa.seattle.comcast.net (68.85.240.70) 77.599 ms 22.968 ms 31.430 ms | |
8 pos-1-4-0-0-cr01.seattle.wa.ibone.comcast.net (68.86.90.209) 16.578 ms 29.505 ms 17.792 ms | |
9 be-12-pe03.seattle.wa.ibone.comcast.net (68.86.84.106) 17.729 ms 22.959 ms 17.169 ms | |
10 66-208-229-102-ubr01a-muncie01-in.hfc.comcastbusiness.net (66.208.229.102) 15.890 ms 22.610 ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/adrian/Dropbox/src/adrianpike/sass-rails/lib/sass/rails/helpers.rb:41:in `resolver' | |
/Users/adrian/Dropbox/src/adrianpike/sass-rails/lib/sass/rails/helpers.rb:45:in `public_path' | |
/Users/adrian/Dropbox/src/adrianpike/sass-rails/lib/sass/rails/helpers.rb:12:in `asset_path' | |
/Users/adrian/Dropbox/src/adrianpike/active_admin/lib/active_admin/sass/helpers.rb:34:in `active_admin_image_path' | |
sass (3.1.10) lib/sass/script/funcall.rb:88:in `_perform' | |
sass (3.1.10) lib/sass/script/node.rb:40:in `perform' | |
sass (3.1.10) lib/sass/script/funcall.rb:76:in `block in _perform' | |
sass (3.1.10) lib/sass/script/funcall.rb:76:in `map' | |
sass (3.1.10) lib/sass/script/funcall.rb:76:in `_perform' | |
sass (3.1.10) lib/sass/script/node.rb:40:in `perform' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.2-p290 :024 > ActiveSupport::TimeZone.us_zones | |
=> [(GMT-10:00) Hawaii, (GMT-09:00) Alaska, (GMT-08:00) Pacific Time (US & Canada), (GMT-07:00) Arizona, (GMT-07:00) Mountain Time (US & Canada), (GMT-06:00) Central Time (US & Canada), (GMT-05:00) Eastern Time (US & Canada), (GMT-05:00) Indiana (East)] | |
ruby-1.9.2-p290 :025 > ActiveSupport::TimeZone.us_zones.first.to_s | |
=> "(GMT-10:00) Hawaii" | |
ruby-1.9.2-p290 :026 > ActiveSupport::TimeZone.us_zones.first.name | |
=> "Hawaii" | |
ruby-1.9.2-p290 :027 > Time.zone = ActiveSupport::TimeZone.us_zones.first.name | |
=> "Hawaii" | |
ruby-1.9.2-p290 :028 > Time.zone = ActiveSupport::TimeZone.us_zones.first.to_s | |
ArgumentError: Invalid Timezone: (GMT-10:00) Hawaii |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Asset < AR | |
end | |
class Alert < AR | |
belongs_to :asset | |
has_many :logs | |
accepts_nested_attributes_for :logs | |
end | |
class Log < AR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def page_title() | |
object_name = controller_name.singularize | |
if controller.instance_variables.include?(('@' + object_name).to_sym) | |
locals = { | |
object_name.to_sym => controller.instance_variable_get('@' + object_name).to_s | |
} | |
else | |
locals = {} | |
end |