View Gemfile
gem 'lograge' # more readable logs
gem 'logstash-event' # for logstash json format
gem 'mono_logger' # threadsafe logging
View errors.html.erb
<% if Rails.env.development? || %>
More verbose errors
<% end %>

This was my solution for a polymorphic many-to-many association

class ItemCountry < ActiveRecord::Base
  belongs_to :locatable, :polymorphic => true
  belongs_to :country
  # fields are :locatable_id, :locatable_type, :country_id

class Title < ActiveRecord::Base
  has_many :countries, :through => :item_countries, :as => :locatable
View Gemfile
# A sample Gemfile
source ""
gem 'mechanize'

ways to manually update RubyGems without susceptibility to CVE-2015-3900 (until there is a new ruby release)

because gem update --system uses rubygems to get the newest rubygems-update gem, and the vulnernability is in rubygems...

via ruby:

\curl -sSL | \
  tar xzvf - --include 'update.rb' -O | ruby
View ability.rb
class Ability
include CanCan::Ability
def initialize(user)
user ||= # guest user (not logged in)
if user.has_role? :admin # rolify
can :manage, :all
can :access, :ckeditor
# Performed checks for actions:
can [:read, :create, :destroy], Ckeditor::Picture
View test_schema_jsonapi.json
"$schema": "",
"description": "JSON:API Schema",
"type": "object",
"properties": {
"link": { "$ref": "file://schemata/link.json#" },
"meta": { "$ref": "file://schemata/meta.json#" }

A collection of Linux commands and concepts I tend to forget

View gist:e9a7016e4c5dca2d6b8a19d6e10d23c0

Step 0. Install Docker

Step 1. For your chosen project, decide where you want to store your notebooks and files in a workingfolder.

Step 2. Open that folder in the terminal cd workingfolder

Step 3. Run this command

docker run -it --rm -v $PWD:/home/jovyan/work -p 8888:8888 jupyter/all-spark-notebook