Skip to content

Instantly share code, notes, and snippets.

View cmer's full-sized avatar

Carl Mercier cmer

  • Dallas-Fort Worth, TX
  • 15:54 (UTC -05:00)
View GitHub Profile
@cmer
cmer / gen-ssl.md
Last active May 30, 2020 02:25
Generating a wildcard self-signed SSL cert with custom Certificate Authority
@cmer
cmer / custom.sh
Last active July 6, 2020 07:57
Script to update Wireguard routes in DD-WRT
#!/bin/bash
while :
do
WGPROC=$(wg)
WGIF=$(ip route show gateway | grep -io oet1)
WGSERVER=$(/usr/sbin/nvram get oet1_rem0)
WANGWY=$(/usr/sbin/nvram get wan_gateway)
WANIF=$(/usr/sbin/nvram get wan_iface)
@cmer
cmer / rmssh
Last active August 12, 2019 01:58
Script to remove last attempted SSH host from ~/.ssh/known_hosts
#!/usr/bin/env ruby
host = ARGV[0].to_s
if host == ""
history_output = `cat ~/.bash_history | grep "^ssh\s" | tail -1`
host = history_output.sub(/^ssh\s/i, '').split("@").last.split(" ").first
end
puts `ssh-keygen -R #{host}`
@cmer
cmer / no_automount
Last active December 23, 2018 05:45 — forked from voltechs/no_automount
Add volume (UUID) to fstab to prevent automount (macOS)
#!/usr/bin/env ruby
# Usage: no_automount /Volumes/My\ Disk
if ARGV[0].nil?
puts "Usage: no_automount /Volumes/My\ Disk"
exit 1
end
diskinfo = `diskutil info '#{ARGV[0]}'`.gsub("\n\n", "\n").split("\n").collect do |b|
@cmer
cmer / config.ru
Last active December 31, 2023 15:34
Gem In a Box basic authentication & authorization rackup file
#
# This is a simple rackup file for geminabox. It allows simple role-based authorization.
#
# roles:
# - developer
# - upload
# - delete
# - admin (can do anything)
#
# For example, a developer who can access the service and upload new gems would have the following roles: `%w(developer upload)
@cmer
cmer / ping_check.sh
Last active February 23, 2025 20:33
Auto reboot pfSense if Internet is down
#!/bin/sh
#
# /usr/local/bin/ping_check.sh
#
# First sleep for 3 mins so that we don't run this code if box has only just booted and PPPoE not up yet.
/bin/sleep 180
test_http() {
url=${1:-http://captive.apple.com}
@cmer
cmer / haproxy.cfg
Last active December 17, 2024 14:18
Simple, no bullshit TCP port forwarding using HAProxy
listen l1
bind 0.0.0.0:443
mode tcp
timeout connect 4000
timeout client 180000
timeout server 180000
server srv1 host.example.com:9443

Keybase proof

I hereby claim:

  • I am cmer on github.
  • I am cmer (https://keybase.io/cmer) on keybase.
  • I have a public key whose fingerprint is D086 FC72 06E0 89F8 7FAE C495 E5F6 43EA 38F0 16D0

To claim this, I am signing this object:

@cmer
cmer / gist:6063133
Created July 23, 2013 15:10
Hetzner EX40 UnixBench
# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #
Version 5.1.3 Based on the Byte Magazine Unix Benchmark
Multi-CPU version Version 5 revisions by Ian Smith,
# routes.rb
put '/payment_details' => 'payment_details#update'
# controller
class PaymentDetails < Controller
def update
stripe = Stripe.new
stripe.email = params[:stripe][:email]
stripe.address = params[:stripe][:address]