Skip to content

Instantly share code, notes, and snippets.

View manuelmeurer's full-sized avatar
🤷‍♂️

Manuel Meurer manuelmeurer

🤷‍♂️
View GitHub Profile
# config/initializers/aaa_load_app_config.rb
#
# Prefixed with "aaa_" so that it is loaded first and app configs can be used in later initializers
require 'ostruct'
::AppConfig = OpenStruct.new(YAML.load_file(Rails.root.join('config', 'app_config.yml')).with_indifferent_access)
set :shared_files, %w(config/database.yml config/app_config.yml public/sitemap_index.xml)
namespace :deploy do
desc 'Symlink shared configs and folders on each release.'
task :symlink_shared do
global_shared_files.each do |shared_file|
run "ln -nfs #{shared_path}/#{shared_file} #{release_path}/#{shared_file}"
end
end
end
#!/usr/bin/ruby
if ARGV.length != 2
puts <<-TEXT
Error: wrong number of arguments. Include your app's consumer token and secret:
get_twitter_oauth_credentials.rb CONSUMER_TOKEN CONSUMER_SECRET
Get your consumer token and secret by registering your app at https://twitter.com/apps
# old
httpauth = Twitter::HTTPAuth.new(username, password)
base = Twitter::Base.new(httpauth)
# new
oauth = Twitter::OAuth.new(consumer_token, consumer_secret)
oauth.authorize_from_access(access_token, access_secret)
base = Twitter::Base.new(oauth)
Encoding::CompatibilityError: incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)
GEM_ROOT]/gems/activesupport-3.0.3/lib/active_support/cache/mem_cache_store.rb:161:in `gsub'
[GEM_ROOT]/gems/activesupport-3.0.3/lib/active_support/cache/mem_cache_store.rb:161:in `escape_key'
[GEM_ROOT]/gems/activesupport-3.0.3/lib/active_support/cache/mem_cache_store.rb:128:in `read_entry'
[GEM_ROOT]/gems/activesupport-3.0.3/lib/active_support/cache/strategy/local_cache.rb:124:in `read_entry'
@manuelmeurer
manuelmeurer / aaa_load_app_config.yml
Created February 26, 2011 05:41
My app config setup
# in config/initializers/
# prefixed with 'aaa_' so it's loaded first and app configs can be used in the following initializers
require 'ostruct'
config = File.read(Rails.root.join('config', 'app_config.yml'))
unless config.empty?
::AppConfig = OpenStruct.new(YAML.load(ERB.new(config).result).with_indifferent_access)
rails_env = ENV['RAILS_ENV'] or raise "RAILS_ENV not set"
rails_root = ENV['RAILS_ROOT'] or raise "RAILS_ROOT not set"
num_workers = rails_env == 'production' ? 1 : 1
num_workers.times do |num|
God.watch do |w|
w.dir = "#{rails_root}"
w.name = "resque-#{num}"
w.group = 'resque'
w.interval = 30.seconds
@manuelmeurer
manuelmeurer / qad_amazon_export.rb
Created September 6, 2011 11:49
Quick and dirty Amazon product export to a CSV file
#!/usr/bin/env ruby
require 'amazon_product'
require 'csv'
AWSKey = ''
AWSSecret = ''
AWSAssociateTags = {
:de => '',
@manuelmeurer
manuelmeurer / gist:1214173
Created September 13, 2011 15:50
Error with JS Routes
=> Booting WEBrick
=> Rails 3.0.10 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/activesupport-3.0.10/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `failure_app=' for nil:NilClass (NoMethodError)
from /Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/devise-1.4.2/lib/devise.rb:405:in `configure_warden!'
from /Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/devise-1.4.2/lib/devise/rails/routes.rb:7:in `finalize_with_devise!'
from /Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.10/lib/rails/application.rb:128:in `block in reload_routes!'
from /Users/me/.rvm/gems/ruby-1.9.2-p290@rails3/gems/activesupport-3.0.10/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
@manuelmeurer
manuelmeurer / gist:1228943
Created September 20, 2011 12:07
Heroku: removed and added Cron daily addon
2011-09-20T12:06:55+00:00 heroku[api]: Add-on remove cron:daily by manuel.meurer@gmail.com
2011-09-20T12:06:55+00:00 heroku[api]: Release v24 created by manuel.meurer@gmail.com
2011-09-20T12:06:56+00:00 heroku[web.1]: State changed from up to bouncing
2011-09-20T12:06:56+00:00 heroku[web.1]: State changed from bouncing to created
2011-09-20T12:06:56+00:00 heroku[web.1]: State changed from created to starting
2011-09-20T12:06:57+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-20T12:06:57+00:00 app[web.1]: >> Stopping ...
2011-09-20T12:06:57+00:00 app[web.1]: Exiting
2011-09-20T12:06:57+00:00 heroku[web.1]: Process exited
2011-09-20T12:06:58+00:00 heroku[web.1]: Starting process with command `bundle exec rails server thin -p 4269`