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 BaseClient | |
class APINotFound < StandardError; end | |
attr_reader :auth_strategy | |
def initialize(auth_strategy: :headers, headers: {}) | |
@auth_strategy = auth_strategy | |
@headers = headers | |
end |
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 Admin::DataTable::CellComponent < ApplicationComponent | |
def initialize(tag: :td, header: false, collapse: false, padding: true, numeric: false, centered: true, **args) | |
@args = args | |
@args[:tag] = tag | |
@args[:class] = class_names( | |
@args[:class], | |
"text-end" => numeric, | |
"w-1" => collapse, | |
"text-center" => centered, |
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/views/layouts/application.html.erb %> | |
... | |
<%= javascript_include_tag "locales/#{I18n.locale}", nonce: true %> |
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
require 'fileutils' | |
# Loop through all .jpg and .png files in the current directory | |
Dir.glob("{*.jpg,*.png}").each do |img| | |
# Construct the output filename with .webp extension | |
output_filename = "#{File.basename(img, File.extname(img))}.webp" | |
# Execute ffmpeg command to convert the image | |
system("ffmpeg -i '#{img}' '#{output_filename}'") | |
end |
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 LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG | |
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT. | |
# | |
# | |
# Libraries and infrastructure | |
sudo apt update -y | |
sudo apt install -y \ | |
docker.io docker-buildx \ | |
build-essential pkg-config autoconf bison rustc cargo clang \ |
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
{ | |
"autorun": true, | |
"autokill": true, | |
"terminals": [{ | |
"name": "Server", | |
"description": "Rails Server", | |
"open": true, | |
"focus": true, | |
"commands": ["bundle install", "rails db:migrate", "rails server"] | |
}, { |
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/concerns/has_many_attached.rb | |
module HasManyAttached | |
extend ActiveSupport::Concern | |
class_methods do | |
def has_many_attached(name, dependent: :purge_later, service: nil, strict_loading: false, **options) | |
super(name, dependent: :purge_later, service: nil, strict_loading: false) | |
if options[:file_types].any? | |
validate "validate_#{name}_file_types".to_sym |
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 AttachedValidator < ActiveModel::EachValidator | |
# Active Storage validator to ensure that an attachment is attached. | |
# | |
# usage: | |
# validates :upload, attached: true | |
# | |
def validate_each(record, attribute, _value) | |
return if record.send(attribute).attached? | |
errors_options = {} |
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
# Example of using SQLite VSS with OpenAI's text embedding API | |
# from Ruby. | |
# Note: Install/bundle the sqlite3, sqlite_vss, and ruby-openai gems first | |
# OPENAI_API_KEY must also be set in the environment | |
# Other embeddings can be used, but this is the easiest for a quick demo | |
# More on the topic at | |
# https://observablehq.com/@asg017/introducing-sqlite-vss | |
# https://observablehq.com/@asg017/making-sqlite-extension-gem-installable |
NewerOlder