Skip to content

Instantly share code, notes, and snippets.

View dcorking's full-sized avatar

David Corking dcorking

View GitHub Profile

Ruby: The future of frozen string literals

What is a literal?

In programming languages, literals are textual representations of values in the source code. This is a syntactical concept.

Some examples:

7 # integer literal
#!/usr/bin/env bash
# Abort sign off on any error
set -e
# Start the benchmark timer
SECONDS=0
# Repository introspection
OWNER=$(gh repo view --json owner --jq .owner.login)
@yahonda
yahonda / ruby31onrails.md
Last active June 8, 2025 17:51
Ruby 3.1 on Rails

Ruby 3.1 on Rails

Actions required to use Ruby 3.1.0 with Rails

Rails 7.0.Z

  • Rails 7.0.1 is compatible with Ruby 3.1.0.
  • Rails 7.0.1 addes net-smtp, net-imap and net-pop gems as Action Mailbox and Action Mailer dependency, you do not need to add them explicitly in your application Gemfile anymore.
  • thor 1.2.1 has been released. You will not see DidYouMean::SPELL_CHECKERS.merge deprecate warnings anymore.

Rails 6.1.Z

  • Use Rails 6.1.5 to support database.yml with aliases and secrets.yml with aliases.
@stevedodson
stevedodson / README.md
Last active June 17, 2025 09:07
Introduction to supervised machine learning in Elastic webinar - Tuesday, February 25, 2020

Introduction to supervised machine learning in Elastic webinar

Tuesday, February 25, 2020

Wednesday, May 27, 2020 - updated customer_churn.ipynb for version 7.7.0

Monday, November 16, 2020 - updated for version 7.10 and eland 7.10b

Monday, September 20, 2021 - updated customer_churn.ipynb for version 7.14

Monday, February 8, 2022 - updated customer_churn.ipynb for version 8.0

@dcorking
dcorking / authentication_spec.rb
Created January 9, 2020 17:20
testing a doorkeeper token request via a password grant
require 'rails_helper'
RSpec.describe '/oauth/', type: :request do
let(:application) { create(:doorkeeper_application, confidential: false) }
let(:user) { create(:user, email: '[email protected]', password: "PASSWORD") }
let(:valid_params) do
{
username: user.email,
password: "PASSWORD",
grant_type: 'password',
@dcorking
dcorking / demo_option_parser.rb
Created December 23, 2019 12:26
lightweight-ish option parsing with Ruby standard library
# run with
# ruby tools/demo-option-parser.rb --skip-download
# or
# bundle exec rails runner tools/demo-option-parser.rb --skip-download
require 'optparse' # not needed for rails runner
skip = nil
p ARGV # ["--skip-download"]
@dcorking
dcorking / footer_helper.rb
Last active November 15, 2019 17:00
year, or range of years with en dash if needed - for example for copyright messages
@dcorking
dcorking / hide-hnq-everywhere.css
Created March 6, 2019 14:48
Hide Hot Network Questions everywhere (to aid concentration)
/* for use as a user style, for example in a browser extension like Stylus for Google Chrome */
#hot-network-questions {
display: none
}
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active July 8, 2025 20:45
set -e, -u, -o, -x pipefail explanation
@mrmartineau
mrmartineau / stimulus.md
Last active May 16, 2025 13:02
Stimulus cheatsheet