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
#!/usr/bin/env ruby | |
# Run like `ruby incompat_71.rb ~/path/to/Gemfile.lock` | |
# From the team at infield.ai | |
# | |
PACKAGES = [['activerecord-import', '1.5.0'], | |
['anycable-rails', '1.4.1'], | |
['blazer', '3.0.1'], | |
['bullet', '7.1.2'], | |
['data_migrate', '9.2.0'], | |
['database_cleaner-active_record', '2.1.0'], |
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
KAMAL_REGISTRY_PASSWORD=dckr_pat_xXXxx_x0xXxXx-xX-XXX0xX0x-x | |
RAILS_MASTER_KEY=00x00xxx000xxx000000xx0x000x0x00 | |
POSTGRES_PASSWORD=xXxxx0xXXx0 | |
MEILI_MASTER_KEY=xXxxx0xXXx0 | |
BLAZER_DATABASE_URL=postgres://service:{POSTGRES_PASSWORD}@service-name-postgres:5432/service_production |
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 "@hotwired/stimulus" | |
// use with Rails' `time_Tag` helper like so: | |
// <%= time_tag campaign.starts_at, campaign.starts_at.to_formatted_s(:short), data: { controller: "localized-time", localized_time_type_value: "datetime-short" } %> | |
export default class extends Controller { | |
static targets = [ ] | |
static values = { | |
type: String, | |
style: { type: String, default: 'medium' }, | |
locale: { type: String, default: 'default' }, |
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
// Plain ol' JavaScript module for fetching feature flags from the server | |
// | |
// import { isEnabled } from './flipper.js' | |
// | |
// if (await isEnabled("new_feature")) { | |
// // render new feature | |
// } else { | |
// // render old feature | |
// } | |
// |
For years, people have been using jemalloc with ruby. There were various benchmarks and discussions. Legend had it that Jemalloc 5 didn't work as well as Jemalloc 3.
Then, one day, hope appeared on the horizon. @wjordan offered a config for Jemalloc 5.
FROM ruby:3.1.2-bullseye
RUN apt-get update ; \
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
#!/usr/bin/env ruby | |
# Given a file and method_name | |
# Show all the different implementations across the git history (first commit per implementation). | |
# | |
# show_method_history <file> <method_name> --html | |
# | |
# e.g. show_method_history test/test_helper.rb sign_in --html | |
# | |
# WARNING: the --html output just dumps html files into your current folder. | |
# |
Add the following to application.rb
:
$icallbacks = []
$icallbacks.define_singleton_method(:print) do
puts sort_by { |(a, b)| -b }.map { |(a, b)| "#{b}\t\t#{a}" }.join("\n")
end
ActiveSupport::Notifications.subscribe("load_config_initializer.railties") do |event|
$icallbacks << [event.payload[:initializer], event.duration]
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
# This demonstrates how we create a SEO friendly url for the previews of the artworks we sell. | |
# | |
# This is the URL we want: | |
# https://festalab.com.br/image/invitation/birthday/carnival.jpg | |
# | |
# First, the route. | |
# | |
# "model" is the name of the active storage model that has the preview. | |
# "classification" and "identifier" are together a unique key for the records. |
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
ActiveRecord::Migration.remove_foreign_key(:current_table, :foreign_table) # no lock | |
ActiveRecord::Migration.add_column(:current_table, :column_bigint, :bigint) # no lock | |
copy_data = lambda do | |
CurrentTable.where(column_bigint: nil).where.not(column: nil).in_batches do |batch| | |
batch.update_all("column_bigint = column") | |
end | |
end |
NewerOlder