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
require 'rubygems' | |
require 'rack' | |
require 'json' | |
Rack::Handler::Thin.run proc{ |env| | |
req = Rack::Request.new(env) | |
begin | |
json = JSON.parse(req.body.read) | |
[200, {"Content-Type" => "text/plain"}, json.inspect] | |
rescue JSON::ParserError |
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
domain = Curl::Easy.http_head(url) do |c| | |
c.follow_location = true | |
c.timeout = 4 | |
end.last_effective_url |
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/draper/railtie.rb b/lib/draper/railtie.rb | |
old mode 100644 | |
new mode 100755 | |
index 598e44f..04d35fa | |
--- a/lib/draper/railtie.rb | |
+++ b/lib/draper/railtie.rb | |
@@ -24,13 +24,13 @@ module Draper | |
initializer "draper.extend_action_controller_base" do |app| | |
ActiveSupport.on_load(:action_controller) do |
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
var s = "translate(-320px, 0)"; | |
var iter = 1000000; | |
var substr = function() { | |
for(var i = 0; i < iter; i++) { | |
parseInt(s.substring(s.indexOf('(')+1, s.indexOf(",")-2)) | |
} | |
} | |
var substr_const = function() { |
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
<html manifest='/application.manifest'> | |
<body> | |
This is a bootstrapper page for the Mashable application manifest. | |
</body> | |
</html> |
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
local foo = {} | |
function foo:Bar(text) | |
-- `self` is foo, `text` is the passed in parameter | |
end | |
foo.Bar(foo, "text") | |
foo:Bar("text") | |
local otherFoo = {} | |
-- In this invocation, "self" will be otherFoo in the method |
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 Host < ActiveRecord::Base | |
validates_associated :access_points, :switches | |
before_validation :set_group_sizes | |
def set_group_sizes | |
associated = (self.access_points + self.switches).group_by(&:ip) | |
associated.each do |ip, o| | |
o.each do |obj| | |
obj.devices_on_ip = o.length | |
end |
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
## ERB | |
hamlerbslim git:(master*) ruby-1.9.3 % ab -n 1000 -c 1 http://0.0.0.0:5423/erb | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 0.0.0.0 (be patient) | |
Completed 100 requests | |
Completed 200 requests | |
Completed 300 requests |
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
require 'rubygems' | |
require 'benchmark' | |
require 'erubis' | |
class Context | |
def initialize | |
@items = { | |
"Headline 1" => %w[Link1 Link2 Link3 Link4 Link5 Link6 Link7], | |
"Headline 2" => %w[Link1 Link2 Link3 Link4 Link5 Link6 Link7], | |
"Headline 3" => %w[Link1 Link2 Link3 Link4 Link5 Link6 Link7], |