Skip to content

Instantly share code, notes, and snippets.

class FunctionParser
def test
# How do I access @vals from sim.rb?
# puts @vals.inspect
end
end
@forced-request
forced-request / migration.rb
Last active December 20, 2015 04:39
== ConvertFriendshipTable: migrating ========================================= -- rename_column(:friendships, :sender, :user) rake aborted! An error has occurred, this and all later migrations canceled: undefined method `to_sym' for nil:NilClass/Users/web/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/ab…
class ConvertFriendshipTable < ActiveRecord::Migration
def change
rename_column :friendships, :sender, :user
end
end
<!DOCTYPE html>
<html>
<head>
<title>TwitterBootstrapPoc</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="twitter-flash">
class UserController < ApplicationController
def show
flash[:error] = "User ID: #{params[:id]}did not exist"
end
end
<body>
<% flash.each do |name, msg| -%>
<%= content_tag :div, msg, class: name %>
<% end -%>
<%= yield %>
</body>
module BootstrapFlashHelperPatched
ALERT_TYPES = [:error, :info, :success, :warning] unless const_defined?(:ALERT_TYPES)
def bootstrap_flash_patched
flash_messages = []
flash.each do |type, message|
# Skip empty messages, e.g. for devise messages set to nothing in a locale file.
next if message.blank?
type = type.to_sym
module BootstrapFlashHelperPatched
ALERT_TYPES = [:error, :info, :success, :warning] unless const_defined?(:ALERT_TYPES)
def bootstrap_flash_patched
flash_messages = []
flash.each do |type, message|
# Skip empty messages, e.g. for devise messages set to nothing in a locale file.
next if message.blank?
type = type.to_sym
@forced-request
forced-request / all-encodings-of-gt
Created April 3, 2014 23:00
This file is based off the fuzzdb list of all encodings of lt
>
%3E
&gt
&gt;
&GT
&GT;
&#62
&#062
&#0062
&#00062
class ApplicationController < ActionController::Base
ensure_authorization_performed :except => [:index, :search], :if => :auditing_security?, :unless => :devise_controller?
private
def auditing_security?
Rails.env != 'production'
end
# Send 'em back where they came from with a slap on the wrist
def authority_forbidden(error)
@forced-request
forced-request / request_forgery_protection.rb
Last active April 18, 2017 23:46
protect_from_forgery
def protect_from_forgery(options = {})
self.request_forgery_protection_token ||= :authenticity_token
prepend_before_filter :verify_authenticity_token, options
end
def verify_authenticity_token
unless verified_request?
logger.warn "WARNING: Can't verify CSRF token authenticity" if logger
handle_unverified_request
end