Brief introduction to “Keyed Redis”. What are the benefits of using it over “vanilla” Redis access? When does it make sense to use it instead of persisting to the database?
What problem are we trying to solve?
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 |
import { Controller } from '@hotwired/stimulus' | |
export default class extends Controller { | |
static classes = ['highlight'] | |
connect () { | |
this.element | |
.querySelector(`a[name='${window.location.hash.slice(1)}']`) | |
?.parentElement?.classList?.add(...this.highlightClasses) | |
} |
class PurgeOrphanedNotificationsJob < ApplicationJob | |
queue_as :default | |
def perform | |
Notification.find_each do |n| | |
n.to_notification.message | |
rescue | |
n.destroy | |
end | |
end |
class PurgeOrphanedNotificationJob < ApplicationJob | |
queue_as :default | |
def perform | |
Notification.find_each do |n| | |
n.to_notification.message | |
rescue | |
n.destroy | |
end | |
end |
#!/usr/bin/env ruby | |
require_relative "../config/environment" | |
require "pagespeed_insights" | |
require "optparse" | |
require "concurrent" | |
options = {} | |
OptionParser.new do |parser| |
Brief introduction to “Keyed Redis”. What are the benefits of using it over “vanilla” Redis access? When does it make sense to use it instead of persisting to the database?
What problem are we trying to solve?
post "events", to: "events#create", constraints: ->(req) do | |
req.user_agent == "SavvyCal Webhooks (https://savvycal.com)" && | |
req.params["type"] == "event.created" | |
end | |
post "events", to: "events#update", constraints: ->(req) do | |
req.user_agent == "SavvyCal Webhooks (https://savvycal.com)" && | |
["event.rescheduled", "event.canceled"].include?(req.params["type"]) | |
end |
import { Controller } from '@hotwired/stimulus' | |
import autoAnimate from '@formkit/auto-animate' | |
export default class extends Controller { | |
connect () { | |
autoAnimate(this.element) | |
} | |
} |
resources :media, shallow: true, | |
constraints: ->(req) do | |
current_user = req.env["warden"].user(:user) | |
Flipper.enabled?(:media_uploads, current_user) | |
end |
class Chart < ApplicationRecord | |
validate do |chart| | |
schema = Rails.cache.fetch("vega_lite_schema/v5") do | |
Faraday.get("https://vega.github.io/schema/vega-lite/v5.json").body | |
end | |
JsonSchemaValidator.new(chart, schema: schema, json: vega_json, field: :vega_json).validate | |
end | |
end |