Skip to content

Instantly share code, notes, and snippets.

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

Manuel Meurer manuelmeurer

🤷‍♂️
View GitHub Profile
@manuelmeurer
manuelmeurer / gist:3723502
Created September 14, 2012 17:51
Completely flatten a hash
# From: http://www.samlown.com/en/recursive_lambdas_and_how_to_completely_flatten_a_hash_in_ruby
flatten = lambda do |r|
case r
when Hash
r.to_a.map { |v| flatten.call(v) }.flatten
when Array
r.flatten.map { |v| flatten.call(v) }
else
r
@manuelmeurer
manuelmeurer / init
Created August 11, 2012 16:59
Install and secure MySQL 5.5 from source with Sprinkle
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind
# MySQL daemon start/stop script.
# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.
@manuelmeurer
manuelmeurer / store_stylesheet.rb
Last active March 5, 2018 12:16
How to compile custom Sass stylesheets during runtime
# lib/store_stylesheet.rb
class StoreStylesheet
def initialize(store)
@store = store
end
# The path of the compiled stylesheet, i.e. stores/id_timestamp.css
def stylesheet_file
filename = [
@store.id,
@manuelmeurer
manuelmeurer / storefront_stylesheet.rb
Created February 22, 2012 13:11
Storefront Stylesheet
# Usage in view:
# %style{ type: 'text/css' }
# = StorefrontStylesheet.new(@storefront).to_css
class StorefrontStylesheet
def styles
[].tap do |styles|
styles << %(header { background-color: #{@storefront.layout.header_bg_color}; })
styles << %(body { background-color: #{@storefront.layout.body_bg_color}; })
styles << %(footer { background-color: #{@storefront.layout.footer_bg_color}; })
@manuelmeurer
manuelmeurer / log file
Created January 25, 2012 17:22
Error when logging in with Devise 1.4.9 and Rails 3.2.0
Started POST "/login" for 93.205.77.103 at 2012-01-25 18:03:05 +0100
Processing by Admin::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"S721A0kGRl59UL86sEGqeKZfpzwnBn2HPlHdd6f5wUU=", "admin_user"=>{"email"=>"manuel.meurer@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"}
AdminUser Load (0.4ms) SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`email` = 'manuel.meurer@gmail.com' LIMIT 1
(0.1ms) BEGIN
(0.3ms) UPDATE `admin_users` SET `last_sign_in_at` = '2012-01-25 17:02:45', `current_sign_in_at` = '2012-01-25 17:03:06', `last_sign_in_ip` = '93.205.77.103', `sign_in_count` = 185, `updated_at` = '2012-01-25 17:03:06' WHERE `admin_users`.`id` = 1
(2.4ms) COMMIT
Redirected by /home/rails/apps/showspace-staging/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/responder.rb:135:in `redirect_to'
Redirected to http://admin.staging.show-space.com/
Completed 302 Found in 79ms (ActiveRecord: 0.0ms)
@manuelmeurer
manuelmeurer / Gemfile
Created December 1, 2011 11:06
Bundler error: invalid byte sequence in US-ASCII
source :rubygems
gem 'rails', '~> 3.1.3'
gem 'haml', '~> 3.1.2'
gem 'jquery-rails', '~> 1.0.13'
gem 'mysql2', '~> 0.3.7'
gem 'factory_girl_rails', '~> 1.3.0'
gem 'ffaker', '~> 1.8.1'
gem 'paperclip', '~> 2.4.0'
gem 'airbrake', '~> 3.0.2'
@manuelmeurer
manuelmeurer / gist:1340608
Created November 4, 2011 22:04
Error installing mechanize gem via hoe
23:02:43 (ruby-1.9.2-p290@rails-3.1) ~/apps gem list | grep hoe
hoe (2.12.3)
23:02:47 (ruby-1.9.2-p290@rails-3.1) ~/apps git clone git://github.com/tenderlove/mechanize.git
Initialized empty Git repository in /Users/manuel/apps/mechanize/.git/
remote: Counting objects: 6194, done.
remote: Compressing objects: 100% (2105/2105), done.
remote: Total 6194 (delta 4143), reused 6083 (delta 4050)
Receiving objects: 100% (6194/6194), 961.58 KiB | 318 KiB/s, done.
Resolving deltas: 100% (4143/4143), done.
23:02:57 (ruby-1.9.2-p290@rails-3.1) ~/apps cd mechanize
@manuelmeurer
manuelmeurer / Exception
Created September 20, 2011 20:11
Ohm error
NoMethodError: protected method `key_for' called for Activity:Class
# Stacktrace
lib/ohm_model_template.rb:65:in `method_missing'
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:741:in `union_key_for'
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:732:in `block (2 levels) in keys'
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:723:in `each'
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:723:in `block in keys'
[GEM_ROOT]/bundler/gems/ohm-870c88ac4614/lib/ohm.rb:722:in `tap'
@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`
@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'