View variant.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "rails", "6.0.0" | |
gem "sqlite3" | |
gem "pry" | |
end |
View castaway.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CastIdsToText < ActiveRecord::Migration[6.0] | |
def up | |
add_cast :text, :uuid, function: :inout, context: :implicit | |
add_cast :text, :bigint, function: :inout, context: :implicit | |
end | |
def down | |
remove_cast :text, :uuid | |
remove_cast :text, :bigint | |
end |
View uu58.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Uu58 | |
# Convert a string UUID to a base58 string representation. | |
# | |
# Output will be padded up to 22 digits if necessary. | |
# | |
# Behaviour is undefined if passing something other than a 128-bit | |
# hex string in network order with optional interstitial hyphens. | |
def self.uuid_to_base58(uuid, alphabet = SecureRandom::BASE58_ALPHABET) | |
ary = uuid.delete("-").to_i(16).digits(58).reverse | |
ary.unshift(0) while ary.length < 22 |
View bouquet-controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller } from "stimulus" | |
// Proof of concept for lazy loaded turbo frames | |
export default class extends Controller { | |
static targets = ["click", "events", "root"] | |
static values = { | |
rootMargin: String, | |
threshold: Number, | |
appearEvent: String, | |
disappearEvent: String |
View worry.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'json' | |
module Proxy | |
refine Object do | |
def deconstruct_keys(methods) | |
methods.to_h { |m| [m, ->(*a) { throw m, public_send(m, *a) }] } | |
end | |
end | |
end |
View route-authenticators.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
defaults authenticator: UserAuthenticator do | |
resources :todos | |
end | |
scope :api, defaults: { authenticator: APIAuthenticator, format: :json } do | |
resources :todos | |
end | |
# app/lib/user_authenticator.rb |
View organisation.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/organisation.rb | |
# schema like: | |
# | |
# create_table "organisations", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| | |
# t.string "transponder", default: "my_laps", null: false | |
# | |
class Organisation < ApplicationRecord | |
attribute :transponder, TransponderType.new |
View resprocketize.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Gemfile b/Gemfile | |
index 79cc614..9e03100 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -11,6 +11,8 @@ gem 'sqlite3', '~> 1.4' | |
gem 'puma', '~> 3.11' | |
# Use SCSS for stylesheets | |
gem 'sass-rails', '~> 5' | |
+# Bring back uglifier for sprockets | |
+gem 'uglifier', '>= 1.3.0' |
View application_record.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationRecord < ActiveRecord::Base | |
self.abstract_class = true | |
unless instance_methods.include?(:values_at) | |
def values_at(*methods) | |
methods.flatten.map! { |method| public_send(method) } | |
end | |
end | |
end |
NewerOlder