Skip to content

Instantly share code, notes, and snippets.

View technicalpickles's full-sized avatar

Josh Nichols technicalpickles

View GitHub Profile
@technicalpickles
technicalpickles / 1. Description.markdown
Created February 18, 2011 03:21
Rails Operations: Reporting live from the trenches

The Internet is Serious Business. When it comes to your web-based company, being online and open for business is kind of a big deal. And that is exactly what Rails Operations is all about.

We'll be talking about the guidelines and motivations behind Rails Operations, as well as looking at some practical applications of it.

module God
module Conditions
class RestartFileTouched < PollCondition
attr_accessor :restart_file
def initialize
super
end
def process_start_time
Time.parse(`ps -o lstart -p #{self.watch.pid} --no-heading`)
@technicalpickles
technicalpickles / gist:761316
Created December 31, 2010 20:34
moonshine example to redirect to specific domain
# make sure to specify the following in your co
class ApplicationManifest < Moonshine::Rails::Manifest
# snip
@mod_rewrite =<<-MOD_REWRITE
RewriteCond %{HTTP_HOST} !^#{configuration[:domain].gsub('.', '\.')} [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://#{configuration[:domain].gsub('.', '\.')}/$1 [L,R]
MOD_REWRITE
@mod_rewrite_ssl =<<-MOD_REWRITE_SSL
@technicalpickles
technicalpickles / gist:734361
Created December 9, 2010 05:09
Rails view helper for doing jquerymobile navbars
def navigation_link_to(name, options = {}, html_options = {}, &block)
if current_page?(options)
html_options[:class] ||= ""
html_options[:class] += " ui-btn-active"
end
link_to name, options, html_options, &block
end
$ time rake spec
(in thescotchzone)
/Users/technicalpickles/.rvm/rubies/ruby-1.9.2-p0/bin/ruby -S bundle exec rspec
"./spec/acceptance/home_page_spec.rb"
.
Finished in 0.23965 seconds
1 example, 0 failures
real 0m17.173s
@technicalpickles
technicalpickles / gist:654838
Created October 30, 2010 02:36
awful interface. why not tell you right then and there what's up?
'clear_sources' has been removed from the Gemfile DSL, and is no longer supported.
See the README for more information on upgrading from Bundler 0.8.
$ gem install -v=2.3.10 rails
Successfully installed rails-2.3.10
1 gem installed
Installing ri documentation for rails-2.3.10...
Building YARD (yri) index for rails-2.3.10...
Installing RDoc documentation for rails-2.3.10...
$ script/server
Missing the Rails 2.3.10 gem. Please `gem install -v=2.3.10 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
@technicalpickles
technicalpickles / gist:654745
Created October 30, 2010 01:00
capistrano trix to upload `git diff --staged` and `git apply` that, instead of using `:scm: none` with `:deploy_via: copy`
after 'deploy:update_code' do
system("mkdir -p tmp && git diff --staged > #{rails_root}/tmp/staged.diff")
put File.read("#{rails_root}/tmp/staged.diff"), '/tmp/staged.diff'
run "cd #{latest_release} && if test -s /tmp/staged.diff; then git apply /tmp/staged.diff; fi"
end
$ rake gemcutter:test_legacy_indexing --trace
(in /Users/technicalpickles/code/active/gemcutter)
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.7
** Invoke gemcutter:test_legacy_indexing (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute gemcutter:test_legacy_indexing
rake aborted!
incorrect header check
/Users/technicalpickles/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems.rb:550:in `inflate'
# match method names like
# logged_id_super_admin_or_admin?
# or
# logged_in_admin_or_lead?
def method_missing(method_name, *args)
if method_name.to_s.match(/^logged_in_(.*)?$/)
roles = $1.split('_or_')
return false unless logged_in? && current_user.company_id == current_company.id
roles.each do |role|