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
source 'https://rails-assets.org' do | |
gem 'rails-assets-dropzone' | |
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
- downcase_modelname = model.class.name.downcase | |
- url = Rails.application.routes.url_helpers.send("#{downcase_modelname}_path", model, format: :json) | |
div[class="#{wrapper_class}" data-controller="inline-edit" data-inline-edit-url="#{url}" data-inline-edit-model="#{downcase_modelname}" data-inline-edit-model-attribute="#{attribute}" data-inline-edit-model-id="#{model.id}"] | |
span[data-target="inline-edit.originalText" id="#{attribute}-original"] | |
span = capture(attribute, &block) | |
a.inline-edit-edit-button[data-action="inline-edit#handleShow"] | |
i.fas.fa-edit | |
= simple_fields_for model do |f| | |
.ui.form.mini.hidden[data-target="inline-edit.form" id="#{attribute}-form"] |
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 CategoriesController < ApplicationController | |
def fields | |
render json: Field.where(category_id: params[:id]).order(:id) | |
end | |
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
- if file.blob.image? | |
= image_tag file.variant(resize: "512x512"), class: 'img-thumbnail w-25 float-left mr-3' | |
- elsif file.blob.content_type =~ /pdf/ | |
= image_tag file.preview(resize: "512x512"), class: 'img-thumbnail w-25 float-left mr-3' |
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 ActiveStoragePreviewable | |
extend ActiveSupport::Concern | |
included do | |
attachments = reflect_on_all_associations.select do |assoc| | |
assoc.klass == ActiveStorage::Attachment | |
end | |
attachments.each do |att| | |
prefix = (/(.*)_attachment\Z/.match att.name.to_s)[1] |
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/lib/easymon/action_cable_connection_statistics.rb | |
module Easymon | |
class ActionCableConnectionStatistics | |
def check | |
count = ActionCable.server.open_connections_statistics.count | |
status = count < 100 | |
[status, "#{status ? "low" : "high"} - #{count}"] | |
rescue |
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
// const cachedAssetPath = ... | |
try { | |
if (fs.existsSync(cachedAssetPath)) { | |
const response = await fetch(res.locals.fetchUrl, { method: "HEAD" }); | |
res.locals.contentLength = response.headers.get("content-length"); | |
res.locals.contentType = response.headers.get("content-type"); | |
res.locals.buffer = fs.readFileSync(cachedAssetPath); | |
} else { | |
const blob = await (await fetch(res.locals.fetchUrl)).blob(); |
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 "benchmark-malloc" | |
require "slim" | |
require "action_view" | |
class BenchmarkView < ActionView::Base | |
def benchmark | |
bench_malloc = Benchmark::Malloc.new | |
stats = bench_malloc.run { |
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
new WorkboxWebpackPlugin.GenerateSW({ | |
clientsClaim: true, | |
exclude: [/\.map$/, /asset-manifest\.json$/], | |
importWorkboxFrom: "cdn", | |
runtimeCaching: [ | |
{ | |
urlPattern: new RegExp("https://images\.ctfassets\.net"), | |
handler: "cacheFirst" | |
}, | |
{ |
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
// const cachedAssetPath = ... | |
try { | |
if (fs.existsSync(cachedAssetPath)) { | |
const response = await fetch(res.locals.fetchUrl, { method: "HEAD" }); | |
res.locals.contentLength = response.headers.get("content-length"); | |
res.locals.contentType = response.headers.get("content-type"); | |
res.locals.buffer = fs.readFileSync(cachedAssetPath); | |
} else { | |
const blob = await (await fetch(res.locals.fetchUrl)).blob(); |
OlderNewer