A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.
posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord
ruby '2.7.1' | |
gem 'rails', github: 'rails/rails' | |
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data | |
# Action Text | |
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra' | |
gem 'okra', github: 'basecamp/okra' | |
# Drivers |
#!/usr/bin/env sh | |
# Multiple vulnerabilities have been disclosed in RubyGems: | |
# https://www.ruby-lang.org/en/news/2018/02/17/multiple-vulnerabilities-in-rubygems/ | |
# | |
# And again in March 2019: | |
# https://blog.rubygems.org/2019/03/05/security-advisories-2019-03.html | |
# | |
# If you're an Rbenv user, here's any easy one-liner to upgrade to a | |
# safe version of Rubygems (2.7.8 / 3.0.3 or later) for each installed Ruby version: |
# Cleans up branches like: | |
# if Shopify.rails_next? | |
# # Rails 5 login | |
# else | |
# # Rails 4 login | |
# end | |
module RuboCop | |
module Cop | |
module ShopifyRails | |
class RailsNextUnless < Cop |
namespace :docs do | |
desc "Updates the documentation on the gh-pages branch" | |
task :update do | |
branch = `git symbolic-ref --short HEAD`.chomp | |
if "master" != branch | |
puts "You are on the #{branch} branch. You must be on the master branch to run this rake task." | |
exit | |
end | |
require_relative "../lib/my_gem/version.rb" |
#!/usr/bin/env ruby | |
require 'redis' | |
# Clear a large number of keys matching a pattern using SCAN and | |
# pipelining to avoid killing the server. | |
class ClearKeys | |
def initialize(pattern, host='localhost', postprocess_pattern=nil) | |
@redis = Redis.new(host: host) | |
@pattern = pattern |
module Kernel | |
alias :old_puts :puts | |
def puts(val) | |
old_puts val | |
old_puts caller.inspect | |
end | |
end |
I have moved the regular expression example repository to the regular GitHub site to encourage contributions.
# config/routes.rb | |
resources :documents do | |
scope module: 'documents' do | |
resources :versions do | |
post :restore, on: :member | |
end | |
resource :lock | |
end | |
end |
#git tag `date "+staging-%Y%m%d%H%M%S"` | |
git tag `date "+production-%Y%m%d%H%M%S"` | |
git push --tags |