Skip to content

Instantly share code, notes, and snippets.

@tgautier
tgautier / README.md
Created February 24, 2013 23:27 — forked from lucasmazza/README.md

Devise / Warden Tagged logging

I wrote a middleware (actually two, but they do the same with different implementations) that logs information about signed in scopes in a Rails + Devise application. The solution works with multiple logins (like having a person logged both as an Admin and a User). I tested against Rails 4 and Devise HEAD, but it should work fine in any Rails 3 application.

This solution doesn't use the log_tags configuration option since it isn't very helpful when you need to retrieve information stored in cookies/session. That information isn't 'ready' when the Rails::Rack::Logger is executed, since it happens way down in the middleware chain.

Add one of the following implementations to your application load path and use the following configuration to add the middleware to your application stack:

# application.rb
- if taxonomy_products.products.present?
p class="l-title--large"
strong
=' taxonomy_products.title
= taxonomy_products.taxonomy_title
ul
- taxonomy_products.products.each_with_index do |product, index|
- present(product, Front::Catalog::ProductPresenter) do |presenter|
li class="m-vignette-product m-large-vignette-list #{'last' if (index + 1) % 3 == 0}"
= link_to(presenter.image_tag(:large), taxonomy_products.path_for_catalog_product(product))
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'parallel_assets_compiler'
s.version = '0.2.0'
s.platform = Gem::Platform::RUBY
s.author = 'Jørgen Orehøj Erichsen'
s.email = 'joe@erichsen.net'
s.summary = 'Compile assets in parallel'
s.description = 'Compile assets in parallel to speed up deployment'
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH
# With thanks to https://github.com/optoro/activerecord-callback_notification for original inspiration
if Rails.env.development?
module ActiveRecord
module CallbackNotifications
extend ActiveSupport::Concern
module ClassMethods
def notify_all_callbacks
# Make sure all models are loaded before trying to enumerate
==> Downloading https://go.googlecode.com/files/go1.1.2.src.tar.gz
Already downloaded: /Library/Caches/Homebrew/go-1.1.2.tar.gz
tar xf /Library/Caches/Homebrew/go-1.1.2.tar.gz
==> Patching
/usr/bin/patch -f -p1 -i 000-homebrew.diff
patching file src/cmd/ld/lib.c
Hunk #1 succeeded at 665 with fuzz 2.
==> ./make.bash --no-clean
# Building C bootstrap tool.
cmd/dist
# Building C bootstrap tool.
cmd/dist
# Building compilers and Go bootstrap tool for host, darwin/amd64.
lib9
libbio
libmach
misc/pprof
cmd/addr2line
cmd/cov
@tgautier
tgautier / block_faker.rb
Created October 23, 2014 08:36
Faker method to illustrate blocks @lewagon
def fake_complexity(number)
puts "Launching very smart computation with the most clever algorithm...."
sleep(1)
puts ".."
sleep(1)
puts "...."
sleep(1)
puts "......."
result = yield(number, 4)
def greet(arg1, arg2, name)
puts "#{arg1} ---- #{arg2} #{yield(name)}"
end
me = 'John'
greet(1, 2, me) { |name| "Hello #{name}" }
greet(1, 2, me) { |name| "Bonjour #{name}" }
@tgautier
tgautier / file.json
Created October 24, 2014 09:25
[Le Wagon] JSON & Arrays
{
"name": "Paris",
"population": 2211000
}