Skip to content

Instantly share code, notes, and snippets.

@benders
benders / local.create-lo0-alias.plist
Created January 3, 2026 16:24
Add 127.0.0.2 as alias for lo0 on startup, place in /Library/LaunchDaemons
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.create-lo0-alias</string>
<key>RunAtLoad</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
@benders
benders / routes.rb
Created March 16, 2011 23:38
Hack to define helper named routes in Rails 2.3
ActionController::Routing::Routes.draw do |map|
...
end
module CustomRoutes
protected
def incident_url( record, options = {} )
account_application_alert_url(record.account_id, record.application_id, record.id, options)
end
@benders
benders / docker-compose.yml
Created April 15, 2024 15:57
Minecraft Server
version: "3.8"
services:
mc:
image: itzg/minecraft-server
tty: true
stdin_open: true
ports:
- "25565:25565"
environment:
@benders
benders / index-usage.sql
Created May 19, 2009 18:31 — forked from gnarg/gist:114268
Finds unused indexes in a mysql database
// Finds unused indexes in a mysql database
SELECT
t.TABLE_SCHEMA,
t.TABLE_NAME,
s.INDEX_NAME,
s.COLUMN_NAME,
s.SEQ_IN_INDEX,
( SELECT MAX(SEQ_IN_INDEX)
FROM INFORMATION_SCHEMA.STATISTICS s2
@benders
benders / chef-nrsysmond.rb
Created November 8, 2011 18:54
Simple New Relic server monitoring recipe for Chef
#
# Thanks to Eron Nicholson at 37 Signals for providing this,
# send thanks to him and blame to me. -Nic Benders
#
template "/etc/apt/sources.list.d/newrelic.list" do
source "newrelic.list.erb"
owner "root"
group "root"
mode 0640

Upgrading OpenWRT on the DFRobot CM4 IoT Router Carrier Board Mini

The CM4 IoT Router Carrier Board Mini is a great little board, easily capable of handling gigabit routing with OpenWRT. But the stock Raspberry Pi images from OpenWRT won't work, because an additional driver is needed for the second network interface. Luckily, the OpenWRT team has made it very easy to build custom images.

Go to the OpenWRT Firmware Selector, choose the Raspberry Pi 4B/400/4CM (64bit) model, then open the twist-out to "Customize installed packages"

Add these packages:

bcm27xx-userland brcmfmac-firmware-usb kmod-brcmutil kmod-cfg80211 kmod-r8169 kmod-usb-dwc2 r8169-firmware
@benders
benders / rendezvous-hashing-demo.rb
Last active October 12, 2022 19:57
A simple example to show how Rendezvous Hashing maintains minimal disruption even when targets change
#!/usr/bin/env ruby
#
# Demonstrate a simple Rendezvous Hash, which is a form of distributed hash
# which allows clients to consistently map resources to a set of "sites",
# and remap them if a site is removed, without having to change the mapping
# for any resources on other sites.
#
# Example output:
#
# Add to .profile / .zprofile
# Requires 1Password CLI v2 https://app-updates.agilebits.com/product_history/CLI2
# To setup: op account add
#
# Change ITEM to choose where 1Password looks
#
op-clip-okta() {
ITEM="Okta"
echo "Fetching ${ITEM} OTP from 1Password"
@benders
benders / cisco-asa-config.txt
Last active November 23, 2021 05:01
Getting Amazon VPC up and running with Cisco ASAs can be a pain. This is the config that we used to make it work.
! --------------------------------------------------------------------------------
! This example configuration shows what WE did to get Amazon VPC working with our
! ASAs. We use version 8.3(1). This config has not been reviewed or otherwise
! blessed in any way by anyone at Amazon. YMMV.
!
! It differs from Amazon's supplied config by using two different sets of
! crypto maps and ACLs, so it brings both tunnels up simultaneously.
!
! For the purposes of the example, the physical datacenter network is 172.16.1.0/24
! and the VPC is 10.0.0.0/16.
@benders
benders / All-Down-503.tcl
Created June 17, 2011 18:58
F5 BigIP iRules
when LB_FAILED {
HTTP::respond 503 content "System down for maintenance" noserver "Connection" "close"
}