Skip to content

Instantly share code, notes, and snippets.


Eliot Sykes eliotsykes

View GitHub Profile
eliotsykes / jobs.rb
Last active Dec 21, 2020 — forked from webmat/dashboards.rb
Active Admin for DelayedJob
View jobs.rb
# Place this file in app/admin/jobs.rb
ActiveAdmin.register Delayed::Job, as: 'DelayedJob' do
# menu parent: 'Some Existing Menu' # optional
permit_params :priority, :queue, :run_at
actions :index, :show, :edit, :update, :destroy
config.batch_actions = true
index do
eliotsykes / erb_parser.rb
Last active Dec 12, 2019
Parse ERB template ruby output expressions (using the temple gem)
View erb_parser.rb
# An example to extract the ruby output expressions from an ERB template using the temple gem:
# 1. Install 'temple' gem
# 2. Require this erb_parser.rb file and run:
# Dynamics will be:
# [[[:dynamic, " @page.title "],
# [:dynamic, " an_image "],
eliotsykes /
Last active Aug 15, 2018
ActiveRecord::Base.configurations usage

Usage of ActiveRecord::Base.configurations with surrounding lines to help answer

Source: ~200 open source Rails apps and engines

~/dev/real-world-rails (master)
$ ag --ruby -C 15 'ActiveRecord::Base.config'
apps/alaveteli/config/initializers/alaveteli.rb:60-require 'user_spam_scorer'
apps/alaveteli/config/initializers/alaveteli.rb:61-require 'alaveteli_rate_limiter'
apps/alaveteli/config/initializers/alaveteli.rb:62-require 'alaveteli_spam_term_checker'
eliotsykes / versioned_migrations.rb
Last active Oct 21, 2019
Versioned migrations support in Rails 4.2
View versioned_migrations.rb
# This file lives at config/initializers/versioned_migrations.rb
def supports_versioned_migrations?
Rails::VERSION::MAJOR >= 5
if supports_versioned_migrations?
"Versioned migrations are supported in your Rails version, you can delete file: #{__FILE__}"
eliotsykes /
Created Jan 22, 2018
Some open source Rails apps that use/used Skylight gem

Some open source Rails apps that use/used Skylight gem

Search done on collected Rails codebases at

$ ag -G Gemfile skylight
181:    skylight (0.10.6)
233:  skylight
eliotsykes / check_rollbar.rake
Last active Jul 27, 2017
Check Rollbar is reporting errors raised in rake tasks
View check_rollbar.rake
# Create file at lib/tasks/check_rollbar.rake
require 'securerandom'
# Run this with `heroku run rake check_rollbar`
desc "Check Rollbar reports errors raised in Rake tasks"
task check_rollbar: :environment do
unique_msg = "Hello from rake check_rollbar (unique identifier: #{SecureRandom.hex})"
raise ActiveRecord::RecordNotFound, unique_msg

Open Source AngularJS Rails Apps

Expect some false positives here, but hopefully most of these are open source Rails apps that use (or once used) AngularJS.

If you'd like to help update the list, please comment below with any of these apps you discover do not use AngularJS and include my username (@eliotsykes) in your message.

Confirmed using AngularJS

View original_bracket_validator.rb
require 'set'
def is_valid(code)
openers_to_closers = {
'(' => ')',
'{' => '}',
'[' => ']'
openers =
eliotsykes /
Created Apr 28, 2017
Open Source Rails apps using Sidekiq
eliotsykes /
Last active Aug 21, 2021
Multiline expressions in Ruby

How to break long lines up in Ruby

This page lists the options for breaking single-line expressions into multiple lines in Ruby.

Developers and teams need to come to their own decisions about which guideline(s) they prefer (preferences below are just my personal choices and I encourage you to disregard them).

# With trailing parens
x = [1, 2, 3].join(