Skip to content

Instantly share code, notes, and snippets.

View standingwave's full-sized avatar

Gabriel Williams standingwave

  • Self Employed
  • San Francisco, CA
View GitHub Profile
@lfender6445
lfender6445 / gist:9919357
Last active May 12, 2024 19:09
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@bradgessler
bradgessler / .rvmrc
Created July 29, 2011 01:40
rvmrc file that controls the version of Ruby, the Gemset, Rubygems, and Bundler. Use this if you want to control this stuff in your development workflow.
#!/usr/bin/env bash
# Bare minimum Gems that are needed to keep a Ruby development environment in sync. This assumes
# that you use bundler in your workflow to control the installation of all other gems. If you need
# to bump the bundler or rubygem version across your team, change that here, then run bundler and
# and keep going.
RVMRC=1.9.2@my_gem_set
RUBYGEM_VERSION="1.6.2"
BUNDLER_VERSION="1.0.15"
@chanks
chanks / gist:998124
Created May 29, 2011 20:46
Override static asset cache expiration on Heroku.
# 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
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
@eric
eric / DISCLAIMER.md
Created March 28, 2011 22:59
Log directly to Papertrail or any remote syslog target from Heroku
#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
@trevorturk
trevorturk / cache_assets.rake
Created January 13, 2011 17:38
rake deploy and rake cache_assets for heroku
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
## /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
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]
)
/**
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