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
module Rack | |
class NoIE | |
def initialize(app, options = {}) | |
@app = app | |
@options = options | |
@options[:redirect] ||= 'http://www.microsoft.com/windows/internet-explorer/default.aspx' | |
@options[:minimum] ||= 7.0 | |
end | |
def call(env) |
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 Integer | |
def prime? | |
!("1" * self).match(/^1?$|^(11+?)\1+$/).nil? | |
end | |
end | |
class DHHException < Exception; end | |
raise DHHException, 'Whoops!' if !1.prime? | |
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
#!/usr/bin/env ruby | |
## | |
# alertme | |
# | |
# A simple delay timer to send a growl notification at specific time with a | |
# message. Useful for when you need to check on something later | |
# | |
# echo "Go look at system 42" | alertme in 2 hours | |
## |
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
// jQuery._ajax = jQuery.ajax; | |
// jQuery.ajax = function(opts){ | |
// var self = this; | |
// return setTimeout(function(){ | |
// jQuery._ajax.call(self, opts); | |
// }, 2000); | |
// }; | |
// As if man :-) |
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
// Run the code below after you loaded the API with your key, though a separate file | |
// or straight onto the body of the document. | |
(function() { | |
google.load('search', '1'); | |
function loaded() { | |
window.localsearch = new google.search.LocalSearch(); | |
}; |
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
;(function($) { | |
$.progressiveFade = function(element) { | |
var childTag; | |
switch($(element).get(0).tagName) { | |
case 'DIV': | |
childTag = 'div'; | |
break; | |
case 'UL': | |
childTag = 'li'; | |
break; |
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
// Say we got: <ul> <li>Foo</li> <li>Bar</li> </ul> | |
// Fade list entries one by one, with a 200ms interval | |
// | |
// $.withChildren('ul:first', 'li', 'fadeOut', [], 200) | |
// | |
;(function($) { | |
$.withChildren = function(element, childSelector, _method, args, after) { | |
var childTag = childSelector || {'DIV': 'div', 'UL': 'li'}[$(element).get(0).tagName] || 'div'; | |
var children = $(element).find('> ' + childTag); |
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
diff --git a/lib/express/request.js b/lib/express/request.js | |
index 3f08f4f..62460af 100644 | |
--- a/lib/express/request.js | |
+++ b/lib/express/request.js | |
@@ -101,7 +101,7 @@ exports.Request = Class({ | |
return new plugin.klass(plugin.options) | |
}) | |
this.uri.post = | |
- this.header('content-type') == 'application/x-www-form-urlencoded' ? | |
+ /^application\/x-www-form-urlencoded/.test(this.header('content-type')) ? |
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
// Instead of this -> http://gist.github.com/255851 | |
// Use the code below. It's a lot more straightforward. | |
$.fn.oneAtEachTime = function(method, args, after) { | |
var collection = this, index = 0; | |
(function(e) { | |
$(e)[method].apply($(e), args); | |
var closure = arguments.callee, next = collection.get(index++); | |
if (next) { setTimeout(function() { closure(next); }, (parseInt(after) || 1000)); }; | |
})(this.get(index)); |
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
not_found do | |
render_template_if_exists! | |
end | |
def render_template_if_exists! | |
name = File.basename(request.path) | |
Dir["#{Sinatra::Application.root}/views/#{name}.*"].each do |match| | |
@_format = File.extname(match).sub(/^./, '') | |
@_template = File.basename(match, File.extname(match)) | |
end |