Skip to content

Instantly share code, notes, and snippets.

@FluffyCode
FluffyCode / info.txt
Created February 19, 2015 00:13
acts-as-taggable-on in Rails 4
This information originally found at:
http://www.reddit.com/r/rails/comments/2chtgw/tagging_in_rails_4/
Saving it here, in case it helps/is lost in the future.
Installation
Gemfile
@FluffyCode
FluffyCode / application_controller.rb
Created October 15, 2014 15:14
CanCan ActiveModel::ForbiddenAttributesError with rails 4
before_filter do
resource = controller_name.singularize.to_sym
method = "#{resource}_params"
params[resource] &&= send(method) if respond_to?(method, true)
end
@FluffyCode
FluffyCode / example.css
Created September 22, 2014 21:00
Foundation: Off-canvas w/ fixed top-bar
.off-canvas-fixed {
-webkit-transition: -webkit-transform 500ms ease;
transition: transform 500ms ease;
}
.move-right > .off-canvas-fixed {
height: 100%;
-webkit-transform: translate3d(15.625rem, 0, 0);
transform: translate3d(15.625rem, 0, 0);
}
@FluffyCode
FluffyCode / logic_gates.rb
Last active August 29, 2015 14:06
Logic Gates in Ruby
# logic gates, via
# http://www.dzone.com/snippets/logic-gates-ruby
NAND = lambda { |i, j| !(i && j) }
NOT = lambda { |i| NAND[i, i] }
AND = lambda { |i, j| NOT[NAND[i, j]] }
OR = lambda { |i, j| NAND[NAND[i, i], NAND[j, j]] }
NOR = lambda { |i, j| NOT[OR[i, j]] }
XOR = lambda { |i, j| NAND[NAND[i, NAND[i, j]], NAND[j, NAND[i, j]]] }
XNOR = lambda { |i, j| NOT[XOR[i, j]] }
# config/initializers/logger_customizations.rb
# Production-only monkeypatches to make our logs awesome
# Monkeypatch 1
# Don't log common poller-style requests, they are just noise
class CustomLogger < Rails::Rack::Logger
def initialize(app, opts = {})
@app = app
@opts = opts
@opts[:silenced] ||= []
# Original method
#def process(input)
# if input == 'q'
# puts 'Goodbye'
# elsif input == 'tweet'
# puts 'tweeting'
# elsif input == 'dm'
# puts 'direct messaging'
# elsif input == 'help'
  1. Check if a page variable has been defined
    1. Set variables in a page (page.html.haml) at the very biginning of the file:

      ---
      variable: value
      variable2: value 2
      ---