Skip to content

Instantly share code, notes, and snippets.

View kivanio's full-sized avatar
🏠
Working from home

Kivanio Barbosa kivanio

🏠
Working from home
View GitHub Profile
module Rack
class GoogleAnalytics
TRACKING_CODE = <<-EOCODE
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("{{ID}}");
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)
module Rack
class RequestStatisticTracker
def initialize(app)
@app = app
end
def call(env)
status, headers, response = @app.call(env)
path = env['REQUEST_PATH'] || env['PATH_INFO']
module Harmony
# Allows accessing config variables from harmony.yml like so:
# Harmony[:domain] => harmonyapp.com
def self.[](key)
unless @config
raw_config = File.read(RAILS_ROOT + "/config/harmony.yml")
@config = YAML.load(raw_config)[RAILS_ENV].symbolize_keys
end
@config[key]
end
#
# = Rails Title Helper
#
# Provides helpers for managing page title.
#
# Category:: Rails
# Package:: Helpers
# Author:: Simone Carletti <[email protected]>
# Copyright:: 2007-2008 The Authors
# License:: MIT License
require(File.dirname(__FILE__) + '/../config/environment') unless defined?(Rails)
class DbIndexes
def initialize(app, message = "Database Indexes")
@app = app
@message = message
end
def call env
module Rack
# A rack middleware for validating HTML via w3c validator
class Validate
def initialize( app )
@app = app
end
def call( env )
# Hi! I'am rack middleware!
# I was born for show right way to you JavaScript
# My author's name was Aleksandr Koss. Mail him at [email protected]
# Nice to MIT you!
require(File.dirname(__FILE__) + '/../config/environment') unless defined?(Rails)
class RoutesJs
def initialize app, options = {}
@kivanio
kivanio / snapshot.rb
Created November 17, 2009 12:13 — forked from reagent/snapshot.rb
require 'snip_snap'
require 'hpricot'
module Rack
# = Rack::Snapshot
#
# Takes the image tags in your page and expands them using some of the popular
# image sharing services. Currently supports these services:
#