Skip to content

Instantly share code, notes, and snippets.

View brandondrew's full-sized avatar

Brandon Zylstra brandondrew

  • UC Berkeley
  • the tubes
View GitHub Profile
@brandondrew
brandondrew / button_progress_controller.js
Created February 22, 2024 03:20 — forked from dbreunig/button_progress_controller.js
Poor man's form button progress indicator, in Stimulus, for those long processing requests.
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
addEventListener("turbo:submit-end", ({ target }) => {
clearInterval(this.interval);
this.element.innerHTML = this.originalLabel;
})
this.originalLabel = this.element.innerHTML;
}
@ivan3bx
ivan3bx / generate_previews.rb
Created February 9, 2024 17:33
Ruby script to generate screenshots for a series of URLs crawled from a sitemap.xml
require "selenium-webdriver"
require "nokogiri"
require "net/http"
BASE_URL = "http://localhost:1313"
#
# This expects several things to be true:
#
# 1. Local hugo instance running at localhosts:1313
@dbreunig
dbreunig / button_progress_controller.js
Last active February 22, 2024 03:20
Poor man's form button progress indicator, in Stimulus, for those long processing requests.
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
addEventListener("turbo:submit-end", ({ target }) => {
clearInterval(this.interval);
this.element.innerHTML = this.originalLabel;
})
this.originalLabel = this.element.innerHTML;
}
@bradgessler
bradgessler / component_helper.rb
Last active February 1, 2024 20:15
Component helper
module ComponentHelper
def component(name, *args, **kwargs, &block)
render componentize(name).new(*args, **kwargs), &block
end
private
def componentize(name)
"#{name.to_s.classify}Component".constantize
end
end
@joeldrapper
joeldrapper / example.rb
Last active January 25, 2024 06:57
Table component
render TableComponent.new(@posts) do |t|
t.column("Title", &:title)
t.column("Author") { |post| post.author.name }
end
@joeldrapper
joeldrapper / fingerprinting.rb
Created January 10, 2024 14:30
Rails request fingerprinting concern
# frozen_string_literal: true
module Fingerprinting
def full_fingerprint
generate_fingerprint(
ip_fingerprint,
browser_fingerprint
)
end
@bradgessler
bradgessler / phlex_element.rb
Last active January 3, 2024 22:21
The Phlex::Element class makes creating simple Phlex components easier
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "phlex"
end
require "phlex/testing/view_helper"
include Phlex::Testing::ViewHelper

Bash

Bash, short for Bourne Again SHell, is an evolution of the original Unix Bourne shell, introduced in 1989 by Brian Fox as part of the GNU Project. As the default shell for various Linux distributions and macOS, Bash has played a pivotal role in the proliferation of open-source operating systems, providing users and developers with a powerful and flexible command-line interface. Over the decades, its capabilities have expanded, and it remains a cornerstone tool for system administrators, developers, and everyday users.

clean.sh

#!/bin/bash

# Begin by capturing the user's desired directory, if unspecified, defaulting to the present directory.
TARGET_DIRECTORY=${1:-"."}
@KonnorRogers
KonnorRogers / commands.thor
Last active July 15, 2023 20:01
Create post thor command
require "fileutils"
class Commands < Thor
# @example
# thor commands:create_post wrapping-lit-react-components turbo-vs-htmx
desc "create_post file", "creates a file or files based on a filepath name and prefills data."
def create_post(*files)
base_dir = "src/_posts/"
files.flatten(1).each do |file|
date = Time.now.to_s.split(" ")[0]

OpenBSD logo     Rails logo     Falcon logo


Choose OpenBSD for your Unix needs. OpenBSD -- the world's simplest and most secure Unix-like OS. A safe alternatve to the frequent vulnerabilities and overengineering of Linux and related software (NGiNX & Apache (httpd-asiabsdcon2015.pdf), OpenSSL, iptables/nftables, systemd, BIND, Postfix, Docker etc.)

OpenBSD -- the cleanest kernel, the cleanest userland and the cleanest config