Skip to content

Instantly share code, notes, and snippets.

View rx's full-sized avatar
👾
Bit twiddling

Russell Edens rx

👾
Bit twiddling
View GitHub Profile
@rx
rx / script-template.sh
Created February 16, 2022 17:17 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@rx
rx / gist:1118201
Created August 1, 2011 14:18 — forked from cmorss/gist:1076315
Jammit Handlebar Template funciton
Handlebars.template = function(templateString) {
return function () {
if (arguments.length < 1) {
// With no arguments, return the raw template -- useful for rendering
// partials.
return templateString;
} else {
Handlebars.templates = Handlebars.templates || {}
Handlebars.templates[templateString] = Handlebars.templates[templateString] || Handlebars.compile(templateString);
return Handlebars.templates[templateString](arguments[0], arguments[1]);
@rx
rx / gist:267225
Created January 1, 2010 19:39 — forked from JonCrawford/gist:44415
Multitenent subdomain controller
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base