Skip to content

Instantly share code, notes, and snippets.

View pier-oliviert's full-sized avatar

Pier-Olivier Thibault pier-oliviert

View GitHub Profile
def content_tag(*args)
if block_given?
tag = Tag.new(args[0])
old_buf = @output_buffer
@output_buffer = ActionView::OutputBuffer.new
yield(tag)
content = tag.render(@output_buffer)
@output_buffer = old_buf
content
else
<%= content_tag :div do |div| %>
It's a
<% div.css << 'test' %>
div
<% end %>
<%= content_tag :div do |div| %>
<% div.css << :boo %>
Embedded tag awesomeness!
<%= content_tag :p do |p| %>
<%= content_tag :div do |div| %>
<% div.css << 'test' %>
<%= content_tag :h2 do |h| %>
<% h.css << :boo %>
Hi!
<% end %>
<% end %>
@pier-oliviert
pier-oliviert / popup.coffee
Last active August 29, 2015 14:02
Shiny.js proof of concept
Everytime a HTML tag has the [as=*] attribute, Shiny will instantiate a Javascript object on the fly. It's not instantiate until it reaches the main Document. So you can manipulate it off screen and the object will only be created once it's appended to the document.
No need to check for document ready or page:load(turbolinks), everything is instantiated as soon as a valid DOM is found.
/Users/pothibo/Develop/ecrire/lib/ecrire/app/models/label.rb:9: syntax error, unexpected '\n', expecting =>
from /usr/local/var/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:443:in `load'
from /usr/local/var/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:443:in `block in load_file'
from /usr/local/var/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:633:in `new_constants_in'
from /usr/local/var/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:442:in `load_file'
from /usr/local/var/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:342:in `require_or_load'
from /usr/local/var/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:480:in `load_missing_constant'
from /usr/
ip_address_whitelist:
- 127.0.0.1
- 1.2.3.4
- 5.6.7.8
whitelisted_pages:
- /assets/.*
- /
- /login
module MyProject
class Application < Rails::Application
initializer 'configure devise' do |app|
app.config.devise.somethin = 'blabla'
end
end
end
class MyController < ApplicationController
def create
params_array_not_supported.each do |offer| # KABOOOM!
...
end
offers_params_not_chanaible_with_array.each do |offer_param|
Offer.new offer_param # ActiveModel::ForbiddenAttributes
module YouApp
class Applcication < Rails::Application
end
end
@pier-oliviert
pier-oliviert / controller.rb
Created April 21, 2014 21:50
Simple Controller.
class ThingsController
def create
@thing = Thing.new(thing_params)
thing.creator = current_user
thing.save!
Stats.count("Thing Created", 1)
Thing.delay.send_notifications(thing.id)
end
def update