$ rails new . -n ActiveAdminDemo -c tailwind -a propshaft --skip-test --skip-system-test
$ rails g active_admin:install --skip-users
$ rails tailwindcss:install
$ rails generate active_admin:assets
$ cat tailwind-active_admin.config.js | sed 's/require(`@activeadmin\/activeadmin\/plugin`)/require(`${activeAdminPath}\/plugin.js`)/g' > config/tailwind-active_admin.config.js
$ rm tailwind-active_admin.config.js
$ bundle binstub tailwindcss-rails
$ rails generate active_admin:views
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
namespace :db do | |
namespace :migrate do | |
task archive: :environment do | |
Rake::Task["db:migrate"].invoke | |
expires_in = 90.days | |
files = Dir.glob(Rails.root.join("db/migrate/*").to_s) | |
files.each do |path| | |
name = File.basename(path) | |
timestamp, _ = name.split("_", 2) |
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 MetricRecord | |
extend ActiveSupport::Concern | |
included do | |
validates :date, :group, :period, presence: true | |
validates :date, uniqueness: {scope: %i[group period]} | |
scope :for_date, | |
->(date) do | |
where(date: date_for_period(date, periods.keys.first)) |
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 CreateSystemMetrics < ActiveRecord::Migration[7.1] | |
def up | |
safety_assured do | |
create_range_partition :system_metrics, partition_key: -> { "date" } do |t| | |
t.decimal :value, null: false, default: 0 | |
t.integer :group, null: false | |
t.integer :period, null: false | |
t.date :date, null: false |
2024-01-01T01:02:03 [METADATA_MANAGE ]E: RetCode: SQL_ERROR SqlState: 08001 NativeError: 101 Message: [unixODBC]FATAL: no pg_hba.conf entry for host "172.27.32.78", user "app_production", database "app_production", no encryption [1022502] (ar_odbc_conn.c:579)
Any driver which does not support SSL and/or password encryption. E.g. PowerBI ODBC or even AWS DMS might be the affected software.
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
Rails::Application.send(:attr_accessor, :importmaps) | |
module Importmap::CustomImportmapTagsHelper | |
def javascript_custom_importmap_tags(name, entry_point: "application") | |
importmap = Rails.application.importmaps[name.to_sym] | |
return unless importmap | |
javascript_importmap_tags(entry_point, importmap: importmap) | |
end | |
end |
Let's you automate registering of new controllers for Stimulus.js by using TypeScript decorator @stimulusController. Good alternative for stimulus-vite-helpers.
- developer can set custom name for the controller
- developer can set custom application for every controller
- by default it uses window.StimulusApplication, also initialises one
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
<html> | |
<head> | |
<%= vite_client_tag %> | |
<%= view_asset_render_head %> | |
</head> | |
<body> | |
<%= yield %> | |
<%= view_asset_render_body %> | |
<% if Rails.env.development? %> | |
<%= view_asset_render_debug %> |
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
# PATH: config/initializers/sidekiq_alive.rb | |
# AUTHOR: Andrei Makarov (github.com/amkisko) | |
# NOTE: now available as gem sidekiq_status_monitor (https://rubygems.org/gems/sidekiq_status_monitor) | |
class SidekiqAliveServer | |
attr_accessor :workers_size_threshold, | |
:process_set_size_threshold, | |
:queues_size_threshold, | |
:queue_latency_threshold, |
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
#!/bin/sh | |
. "$(dirname "$0")/_/husky.sh" | |
if [ -t 1 ]; then | |
exec < /dev/tty | |
echo "\033[31m$1\033[0m" | |
read -p "Do you want to run lint-staged? [y/n] " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then |
NewerOlder