Skip to content

Instantly share code, notes, and snippets.

View rickychilcott's full-sized avatar

Ricky Chilcott rickychilcott

View GitHub Profile
@rickychilcott
rickychilcott / pm.rb
Last active March 27, 2024 12:33
Ruby Pattern Matching Shenanigans
def example(label)
puts "## #{label}"
yield
puts
puts
end
example("Foo.===(v)") do
class Foo
def self.===(v)
@rickychilcott
rickychilcott / slim_select_helper.rb
Last active February 22, 2024 13:23
slim-select capybara helpers
## from @dinshaw in https://github.com/brianvoe/slim-select/pull/246
## Assumption is that you have a label who's parent also contains the select list you are choosing from.
def js_select(item_text, options)
container = find(:xpath, "//parent::*[label[text()='#{options[:from]}']]")
within "##{container[:id]}", visible: false do
find('.ss-arrow').click
input = find(".ss-search input").native
input.send_keys(item_text)
find('div.ss-list').click
@rickychilcott
rickychilcott / ffmpeg_merge.thor
Last active January 28, 2024 16:16
FFMpeg multi video overlay
class Ffmpeg < Thor
package_name "ffmpeg"
desc "install", "install ffmpeg"
def install
`brew install ffmpeg`
end
desc "merge FILE1 FILE2 FILE3 FILE4 OUTPUT", ""
def merge(file_1, file_2, file_3, file_4, output_file)
# frozen_string_literal: true
class SalesListOrganizationCsvDownload < Avo::BaseAction
self.name = "CSV Download"
self.may_download_file = true
self.confirm_button_label = "Download"
def handle(**args)
_models, _fields, _current_user, resource = args.values_at(:models, :fields, :current_user, :resource)
require "active_support/all"
Resource = Struct.new(:absolute_path)
paths = [
Resource.new("/bread/crumbs/three"),
Resource.new("/bread"),
Resource.new("/bread/crumbs"),
Resource.new("/bread/crumbs/one"),
Resource.new("/bread/crumbs/two"),
@rickychilcott
rickychilcott / avo-test-helpers.rb
Created December 8, 2022 17:39
Some Example Avo Test Helpers
def avo_flatpickr_pick(selector, with:)
base_field = find(selector, visible: false)
flatpickr_field_identifier = base_field["data-resource-edit-target"]
flatpickr_field = find("[data-resource-edit-target='#{flatpickr_field_identifier}'].flatpickr-input", visible: false)
new_selector_id = flatpickr_field["id"]
flatpickr_pick("##{new_selector_id}", with: with)
end
def avo_tagify_select(field_selector, with:, retries: 3)
raise("Unable to select '#{with}' from '#{field_selector}'") if retries == 0
@rickychilcott
rickychilcott / goal_and_strategies.rb
Created July 13, 2022 13:28
Fun with Goals and Strategies
class Base
def initialize(id)
@id = id
end
def name
"#{self.class.name} #{@id}"
end
end
@rickychilcott
rickychilcott / render.com.log
Created March 11, 2022 03:00
Bridgetown render.com log
Mar 10 09:56:57 PM ==> Cloning from https://github.com/mission-met/bridgetown-test...
Mar 10 09:56:57 PM ==> Checking out commit 8942612de1fb5c174fbbf51067e51ca6172d6f5d in branch main
Mar 10 09:56:59 PM ==> Downloading cache...
Mar 10 09:57:10 PM ==> Downloaded 177MB in 5s. Extraction took 4s.
Mar 10 09:57:15 PM ==> Installing dependencies with Yarn...
Mar 10 09:57:15 PM yarn install v1.22.17
Mar 10 09:57:15 PM [1/4] Resolving packages...
Mar 10 09:57:15 PM success Already up-to-date.
Mar 10 09:57:15 PM Done in 0.16s.
Mar 10 09:57:15 PM ==> Installing dependencies with bundler...
@rickychilcott
rickychilcott / trace.log
Created February 23, 2022 00:14
Thredded DB Pool Exhaustion Stacktrace
Feb 21 18:20:41 app-name app/web.1 #<Thread:0x00007fe73838ea10 /app/vendor/bundle/ruby/3.0.0/bundler/gems/thredded-9a7158d4a307/lib/thredded/collection_to_strings_with_cache_renderer.rb:84 run> terminated with exception (report_on_exception is true):
Feb 21 18:20:41 app-name app/web.1 /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:210:in `block in wait_poll': could not obtain a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use (ActionView::Template::Error)
Feb 21 18:20:41 app-name app/web.1 from /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:199:in `loop'
Feb 21 18:20:41 app-name app/web.1 from /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:199:in `wait_poll'
Feb 21 18:20:41 app-name app/web.1 from /app/vendor/bundle/ruby/3.0.0/gem
@rickychilcott
rickychilcott / cloudSettings
Last active February 12, 2022 20:34
Visual Studio Code Settings Sync Gist
{"lastUpload":"2022-02-12T20:34:47.219Z","extensionVersion":"v3.4.3"}