Skip to content

Instantly share code, notes, and snippets.

View severin's full-sized avatar

Severin Schoepke severin

  • Zürich, Switzerland
View GitHub Profile
@natematykiewicz
natematykiewicz / unroutable_routes.rake
Last active June 9, 2022 19:47
Find routes that will raise a routing error when requested
desc 'Find routes that will raise a routing error when requested'
task unroutable_routes: :environment do
# A lot of this code was taken from how `rake routes` works
# https://github.com/rails/rails/blob/f95c0b7e96eb36bc3efc0c5beffbb9e84ea664e4/railties/lib/rails/commands/routes/routes_command.rb
require 'action_dispatch/routing/inspector'
unroutables = Rails.application.routes.routes.
map { |r| ActionDispatch::Routing::RouteWrapper.new(r) }.
reject { |r| r.internal? || r.engine? || r.path.starts_with?('/rails/') || !r.controller }.
@jopotts
jopotts / default_values.rb
Last active August 13, 2022 16:26
Simple default values on creation of ActiveRecord models
module DefaultValues
def has_default_values(default_values = {})
class_attribute :default_values
self.default_values = default_values
after_initialize :assign_default_values
include InstanceMethods
@floere
floere / prettyprint.sh
Created May 9, 2013 12:22
Printing with line numbers, color, and wrapping into a PDF.
~/bin $ cat prettyprint
#!/bin/sh
PDF_FILE=/tmp/temp.pdf
PS_FILE=/tmp/temp.ps
vim \
"+set number" "+syntax on" "+color slate" \
"+set printoptions=number:y" \
"+set printfont=courier:h9" \