Skip to content
View rails_rendering_stack.txt
#<Class:ActionController::Parameters>#always_permitted_parameters=:126 ([[:req, :obj]])
ActionDispatch::Http::ParameterFilter#initialize:6 ([[:opt, :filters]])
ActionDispatch::Http::ParameterFilter#initialize:6 ([[:opt, :filters]])
ActiveSupport::Callbacks::ClassMethods#normalize_callback_params:594 ([[:req, :filters], [:req, :block]])
ActiveSupport::Callbacks::ClassMethods#normalize_callback_params:594 ([[:req, :filters], [:req, :block]])
ActiveSupport::Callbacks::ClassMethods#normalize_callback_params:594 ([[:req, :filters], [:req, :block]])
#<Class:ActiveModelSerializers::SerializableResource>#_render_callbacks=:83 ([[:req, :val]])
ActiveModelSerializers::Logging::ClassMethods#instrument_rendering:18 ([])
ActiveModelSerializers::Callbacks::ClassMethods#around_render:50 ([[:rest, :filters], [:block, :blk]])
ActiveSupport::Callbacks::ClassMethods#normalize_callback_params:594 ([[:req, :filters], [:req, :block]])
View irb3.rb
#!/usr/bin/env ruby
# encoding: utf-8
# irb3 - Runs an IRB-esque prompt (but it's NOT really IRB!) over multiple
# versions of Ruby at once (using RVM)
# By Peter Cooper, BSD licensed
# Main dependency is term-ansicolor for each impl:
# rvm exec gem install term-ansicolor
#/usr/bin/env bash
json_url() {
local base=""
local day="$1"
local url="${base}&start_time__day=${day}"
echo -e "$url"
for day in 4 5 6; do
curl -XGET $(eval "json_url $day") -o "may_${day}.json"
View autodoc_config.diff
diff --git a/Gemfile b/Gemfile
index f34a069..cb26600 100644
--- a/Gemfile
+++ b/Gemfile
@@ -100,6 +100,8 @@ group :test do
gem 'rspec', '~> 3.3'
gem 'rspec_junit_formatter', '~> 0.2' # per
gem 'rspec-rails', group: :development
+ gem 'autodoc', require: false
+ gem 'redcarpet', require: false
for f
# Change this value to increase maximum size
dir="$(dirname "$f")"
name="$(basename "$f")"
cd "$dir"
View 20160307172445_change_paperclip_attachment_path.rb
class MoveAttachmentsToNewLocation < ActiveRecord::Migration
def initialize(name =, version = nil)
access_key = Rails.application.secrets.g3_access_key_id
secret_key = Rails.application.secrets.g3_secret_access_key
storage = google_storage_access_key_id: access_key,
google_storage_secret_access_key: secret_key
@bucket_name = Rails.application.secrets.g3_bucket
@bucket = storage.directories.get(@bucket_name)
super(name, version)

Let's say you have a model, with an files attached, using Paperclip. You have a couple millions of those files and you're not sure that every one of them (and all its thumbnails) are still used by a database record.

You could use this rake task to recursively scan all the directories and check if the files need to be kept or destroyed.

In this example, the model is called Picture, the attachment is image and the path is partitioned like images/001/412/497/actual_file.jpg

The task is going down the path. Each time the path ends with 3 triplets of digits ("001/412/497" for example) it looks for a record with the ID 1412497. If such a record doesn't exist, the whole directory is moved to a parallel images_deleted directory. At the end you can delete the files if you like, or move them to an archive location.

You can use the "dry run" mode : to print which files would be removed

View ams_jsonapi.rb
# config/initializers/active_model_serializers.rb
ActiveModelSerializers.config.key_transform = :unaltered
ActiveModelSerializers.config.schema_path = 'docs/schema/schemata'
ActiveSupport.on_load(:action_controller) do
require 'active_model_serializers/register_jsonapi_renderer'
# Routing constraint:
# Request 'Content-Type' must be 'application/vnd.api+json'
View globals.rb
global_variables.sort.each do |name|
puts "#{name}: #{eval "#{name}.inspect"}"
View logfmt.rb
# Based on logfmt:
# For more complete implementation see:
# see
# For usage see:
# For Ruby parser see:
Something went wrong with that request. Please try again.