Skip to content

Instantly share code, notes, and snippets.

View plukevdh's full-sized avatar
🔥

Luke van der Hoeven plukevdh

🔥
View GitHub Profile
# as discovered at: http://stackoverflow.com/questions/711418
before_filter :set_cache_buster, :only => ["view_bill_detail"]
def set_cache_buster
# apparently IE doesn't like having the following two tags set for send_file...
unless request.env['HTTP_USER_AGENT'] =~ /msie/i
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
end
# might be needed for apps deployed to a sub uri. IE has trouble with this...
<%= javascript_tag "var uri = '/#{request.request_uri.gsub("/", "")}';" -%>
@plukevdh
plukevdh / Gemfile
Created March 18, 2010 15:41 — forked from jamiecobbett/Gemfile
Bundler for Rails2.x (from http://gembundler.com/rails23.html)
source :gemcutter
gem "rails", "~> 2.3.5"
gem "sqlite3-ruby", :require => "sqlite3"
# bundler requires these gems in all environments
# gem "nokogiri", "1.4.2"
# gem "geokit"
group :development do
# bundler requires these gems in development
@plukevdh
plukevdh / oracle.rb
Created May 13, 2010 13:26
oracle + rails3 stuff
# monkey patches for Rails 3 beta that are needed for oracle_enhanced adapter
require 'rails3_oracle_patches'
# it's recommended to set time zone to ensure that Oracle session time zone
# will be the same as Ruby Time.local time zone
ENV['TZ'] = 'Eastern Time (US & Canada)'
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class_eval do
# some sample settings that I use in my projects
undefined method `<=>' for class `ActiveSupport::Multibyte::Chars'
/Users/hungerandthirst/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-3.0.0.beta4/lib/active_support/multibyte/chars.rb:49:in `<class:Chars>'
/Users/hungerandthirst/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-3.0.0.beta4/lib/active_support/multibyte/chars.rb:36:in `<module:Multibyte>'
/Users/hungerandthirst/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-3.0.0.beta4/lib/active_support/multibyte/chars.rb:6:in `<module:ActiveSupport>'
/Users/hungerandthirst/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-3.0.0.beta4/lib/active_support/multibyte/chars.rb:5:in `<top (required)>'
/Users/hungerandthirst/.rvm/gems/ruby-1.9.1-p378/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/quoting.rb:13:in `quote'
/Users/hungerandthirst/.rvm/gems/ruby-1.9.1-p378/gems/oracle_enhanced-1.3.0.pre2/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:519:in `quote'
/Users/hungerandthirst/.rvm/gems/ruby-1.9.1-p378/gems/activerecord-3.
@plukevdh
plukevdh / daemonr.rb
Created June 11, 2010 15:09
quick daemonizer for ruby processes
#!/usr/bin/env ruby
pid = fork do
Signal.trap('HUP', 'IGNORE') # Don't die upon logout
loop do
#Some code
sleep 60
end
end
@plukevdh
plukevdh / gist:439713
Created June 15, 2010 20:50
mysql install command
#mysql install
env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
# defined in big-fat-proprietary-library
class MyParentClass
attr_accessor :x
def initialize(x=nil)
@x = x
end
def print_value_of_x
puts @x
end
@plukevdh
plukevdh / kthxbye_job.rb
Created September 1, 2010 16:06
Gist for Kthxbye readme
# dummy job class
class MyJob
def self.perform(data)
puts "Do something with #{data}"
data.gsub(/hello/i, "Goodbye")
end
end
# setup options, then connect
Kthxbye::Config.setup(:redis_server => 'localhost', :redis_port => 8080)
-- control frame ----------
c:0112 p:---- s:0549 b:0549 l:000548 d:000548 CFUNC :ping
c:0111 p:0036 s:0545 b:0545 l:000544 d:000544 METHOD /Users/hungerandthirst/.rvm/gems/ruby-1.9.2-p0/gems/dragonfly-0.7.6/lib/dragonfly/r_magick_utils.rb:30
c:0110 p:0013 s:0536 b:0536 l:000830 d:000830 METHOD /Users/hungerandthirst/.rvm/gems/ruby-1.9.2-p0/gems/dragonfly-0.7.6/lib/dragonfly/analysis/r_magick_analyser.rb:13
c:0109 p:---- s:0532 b:0532 l:000531 d:000531 FINISH
c:0108 p:---- s:0530 b:0530 l:000529 d:000529 CFUNC :call
c:0107 p:0014 s:0526 b:0526 l:000509 d:000525 BLOCK /Users/hungerandthirst/.rvm/gems/ruby-1.9.2-p0/gems/dragonfly-0.7.6/lib/dragonfly/function_manager.rb:37
c:0106 p:---- s:0524 b:0524 l:000523 d:000523 FINISH
c:0105 p:---- s:0522 b:0522 l:000521 d:000521 CFUNC :catch
c:0104 p:0011 s:0518 b:0518 l:000509 d:000517 BLOCK /Users/hungerandthirst/.rvm/gems/ruby-1.9.2-p0/gems/dragonfly-0.7.6/lib/dragonfly/function_manager.rb:36