Skip to content

Instantly share code, notes, and snippets.

View minimul's full-sized avatar
🎯
Focusing

Christian Pelczarski minimul

🎯
Focusing
View GitHub Profile
@minimul
minimul / turbo_stream_tag_controller.js
Last active February 16, 2023 15:39
Turbo Stream Tag Stimulus Controller
//
// Rails View
// <%= tag.div data: { 'turbo-stream-tag-target': 'loadForm' } %>
// Stimulus Controller turbo_stream_tag_controller.js
// ..
loadFormTargetConnected (el) {
// propertyUrlValue was set on data-controller as a value
@minimul
minimul / run-js-after-stream.rb
Created June 21, 2021 15:38
Kicking off JavaScript on a turbo stream
# Needed to close an open modal after streaming in a new select box
# 1. Newly generated select box. Mark "from-stream" true.
# app/views/shipments/create_entity.turbo_stream.erb
<%
dropdown_html = ""
form_with(model: form, url: result.action_url) do |f|
dropdown_html = render partial: "shipments/entity_dropdown",
locals: { f: f, type: type, collection: collection, from_stream: true }
@minimul
minimul / default-render.rb
Created July 29, 2020 20:32
Rails 5.2 ActionController default_render method
# frozen_string_literal: true
module ActionController
# Handles implicit rendering for a controller action that does not
# explicitly respond with +render+, +respond_to+, +redirect+, or +head+.
#
# For API controllers, the implicit response is always <tt>204 No Content</tt>.
#
# For all other controllers, we use these heuristics to decide whether to
# render a template, raise an error for a missing template, or respond with
export default function animateCSS({ element, classes = [], callback }) {
element.classList.add(...classes)
function handleAnimationEnd() {
element.classList.remove(...classes)
element.removeEventListener('animationend', handleAnimationEnd)
if (typeof callback === 'function') callback()
}
import { Controller } from "stimulus"
import animateCSS from 'lib/utils'
export default class extends Controller {
static targets = [ "menu" ]
static values = { invisible: Boolean }
connect() {
this.hide()
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
@import "animate.css/animate.css";
/* Utility classes for animation speeds */
$speeds: 100, 150, 200, 250, 300, 350, 400;
@each $speed in $speeds {
.speed-#{$speed} {
/* Must import in base first */
@import 'animate.css/source/_base.css';
/* Extend animate.css animation speeds to faster */
/* Do this after importing _base.css */
$speeds: 150, 200, 250, 300, 400;
@each $speed in $speeds {
.animated.speed-#{$speed} {
animation-duration: #{$speed}ms;
}
}
// app/javascript/lib/utils.js
export default function animateCSS({ element, classes = [], callback }) {
const finalClasses = ['animated', ...classes]
element.classList.add(...finalClasses)
function handleAnimationEnd() {
element.classList.remove(...finalClasses)
element.removeEventListener('animationend', handleAnimationEnd)
if (typeof callback === 'function') callback()
1. Login to your server.
2. Test that your installed certbot version supports the --system argument
certbot --system
3. If you get the following result => "certbot: error: argument --server: expected one argument" then you're good to go.
4. Example crontab entry
10 6 * * * root certbot --server https://acme-v02.api.letsencrypt.org/directory renew 2>&1 >> /tmp/cerbot-renew.log
window.App ||= {}
App.init = ->
App.Global.applyTooltips()
App.Global.applySelectize()
$(document).on "turbolinks:load", ->
App.init()
new App.ProformaLine($(@)).highlightErrors()