This code is no longer needed. Heroku has provided syslog drains for all users for free.
For better Heroku logging with Papertrail, check this out:
http://help.papertrailapp.com/kb/hosting-services/heroku#standalone
#!/usr/bin/env ruby | |
# Author: László Bácsi <lackac@lackac.hu> | |
require 'rubygems' | |
require 'httparty' | |
require 'json' | |
require 'sequel' | |
require 'htmlentities' |
function GithubBadge(json) { | |
if (json) { | |
var badge = new Object(); | |
badge['username'] = json.user.login; | |
badge['repos'] = _.select(json.user.repositories, function(r) { | |
return !r.fork && '' != r.description; | |
}).sort(function() { | |
return (Math.round(Math.random()) - 0.5); | |
}).slice(0, 12); | |
$('#github-badge').html(Jaml.render('github-badge', badge)); |
/** | |
IMPORTANT: Requires this version of jquery | |
until 1.3.3 comes out http://gist.github.com/186325 | |
ALSO: This is very dirty still and has not been | |
abstracted for use. It is just solving our immediate problems. | |
Use cases that must pass (and should be tested someday): | |
* Clicking on links updates layout | |
* Click around a bit and then use back/forward buttons |
module Core | |
def self.included(mod) | |
url = ENV['CORE_URL'] ? URI.parse(ENV['CORE_URL']) : URI.parse('postgres://postgres@localhost/heroku') | |
mod.establish_connection( | |
:adapter => "postgresql", | |
:host => url.host, | |
:username => url.userinfo.split(':')[0], | |
:password => url.userinfo.split(':')[1], | |
:database => url.path[1..-1] | |
) |
## /config/initializers/dynamic_job.rb | |
require 'heroku' | |
# base class for all jobs that you wish to automatically scale and go down in Heroku | |
class DynamicJob | |
#set a cap on maximum number of users ever - just in case. | |
MAX_CONCURRENT_WORKERS = 100 | |
def initialize |
desc "cache assets" | |
task :cache_assets => :environment do | |
paths = ['public/javascripts/all.js', 'public/stylesheets/all.css'] | |
puts "-----> caching assets..." | |
paths.each do |path| | |
puts "-----> #{path}" | |
end |
#as seen in https://github.com/mooktakim/heroku_deployment | |
class AppTemplatesController < ApplicationController | |
def app | |
render :inline => "SUCCESS", :layout => 'master' | |
end | |
def cms | |
render :inline => "SUCCESS", :layout => 'cms_admin' | |
end | |
end |
This code is no longer needed. Heroku has provided syslog drains for all users for free.
For better Heroku logging with Papertrail, check this out:
http://help.papertrailapp.com/kb/hosting-services/heroku#standalone
def parse filename, content | |
offset = 0 | |
begin | |
FasterCSV.parse(content) do |row| | |
# do stuff | |
offset += row.to_s.size | |
end | |
rescue FasterCSV::MalformedCSVError => e | |
@file_offset ||= 0 | |
@file_offset += offset |
# Stick the following in an initializer. | |
module Heroku | |
class StaticAssetsMiddleware | |
def cache_static_asset(reply) | |
return reply unless can_cache?(reply) | |
status, headers, response = reply | |
headers['Cache-Control'] = 'public, max-age=31556926' # 1 year |