This file contains hidden or 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 | |
# Enhance string class with roman numeral conversion methods | |
# To use, put `using RomanNumerals` | |
# @see https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html | |
module RomanNumerals | |
refine String do | |
# Convert a roman numeral string into an arabic numeral | |
def to_arabic(zero_pad: 0) | |
result = 0 |
This file contains hidden or 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
mysql_version=$(brew list --versions mysql | tr ' ' '\n' | tail -1) | |
mysql_path=$(brew --cellar mysql)/$mysql_version | |
gem install mysql2 -- \ | |
--with-mysql-lib=$mysql_path/lib \ | |
--with-mysql-dir=$mysql_path \ | |
--with-mysql-config=$mysql_path/bin/mysql_config \ | |
--with-mysql-include=$mysql_path/include \ | |
--with-openssl-dir=/usr/local/Cellar/openssl@3/3.1.2 |
This file contains hidden or 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 | |
if Rails.env.development? | |
require 'rails-erd' | |
require 'yard' | |
namespace :docs do | |
desc 'updates documentation' | |
task all: :environment do |
This file contains hidden or 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 '@hotwired/stimulus' | |
export default class extends Controller { | |
static targets = [ 'header', 'row', 'operator' ] | |
headerToggle() { | |
let switch_status = this.headerTarget.checked | |
this.rowTargets.forEach(box => { | |
if (!box.disabled) { box.checked = switch_status; } | |
}) |
This file contains hidden or 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
%div{data: {controller: 'text-with-limit'}} | |
- limit = 1000 | |
%label Message: | |
= form.text_area :custom_message, value: default_message, maxlength: limit, rows: 9, data: { 'text-with-limit-target': 'field', action: 'keyup->text-with-limit#updateCounter' } | |
.right | |
%small | |
Chars left: | |
%span{data: {'text-with-limit-target': 'counter'}}= limit - default_message.length | |
\/ | |
= limit |
This file contains hidden or 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 "@hotwired/stimulus" | |
export default class ToggleableController extends Controller { | |
static targets = [ 'toggle', 'enableSection', 'disableSection', 'hideSection' ] | |
toggle() { | |
let checked = this.toggleTarget.checked | |
if (this.hasEnableSectionTarget) { | |
this.enableSectionTarget.disabled = !checked |
This file contains hidden or 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
# source: https://twitter.com/yarotheslav/status/1793259765902024940 | |
def country_code_to_emoji(country_code) | |
base_emoji_code = 0x1F1E6 | |
country_code.upcase.each_char.map do |char| | |
((char.ord - 'A'.ord) + base_emoji_code).chr(Encoding::UTF_8) | |
end.join | |
end |
This file contains hidden or 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/application.rb | |
require_relative "boot" | |
require "rails/all" | |
# Require the gems listed in Gemfile, including any gems | |
# you've limited to :test, :development, or :production. | |
Bundler.require(*Rails.groups) |
OlderNewer