Skip to content

Instantly share code, notes, and snippets.

Carl Mercier cmer

  • Toronto, ON, Canada
Block or report user

Report or block cmer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cmer
cmer / custom.sh
Last active Nov 5, 2019
Script to update Wireguard routes in DD-WRT
View custom.sh
#!/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 Aug 12, 2019
Script to remove last attempted SSH host from ~/.ssh/known_hosts
View rmssh
#!/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 Dec 23, 2018 — forked from voltechs/no_automount
Add volume (UUID) to fstab to prevent automount (macOS)
View no_automount
#!/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 Aug 8, 2018
Gem In a Box basic authentication & authorization rackup file
View config.ru
#
# 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 Jan 12, 2018
Auto reboot pfSense if Internet is down
View ping_check.sh
#!/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 Nov 5, 2019
Simple, no bullshit TCP port forwarding using HAProxy
View haproxy.cfg
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
View keybase.md

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 Jul 23, 2013
Hetzner EX40 UnixBench
View gist:6063133
# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #
Version 5.1.3 Based on the Byte Magazine Unix Benchmark
Multi-CPU version Version 5 revisions by Ian Smith,
View gist:5226221
# 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]
@cmer
cmer / gist:3821654
Created Oct 2, 2012
Ok, Ruby. What's the real here?
View gist:3821654
[1] pry(#<NotificationCreationService>)> record
=> #<Item id: 58, kind: 1, user_id: 79, community_id: 43, category_id: nil, root_category_id: nil, title: "Autem optio molestias unde laudantium fugit officii...", description: "Aut at quod officiis repellendus. Expedita pariatur...", price: nil, original_price: nil, lowest_price: nil, price_drop_count: 0, for_sale: nil, status: nil, bump_position: 1029, published_at: "2012-09-22 17:48:13", last_bumped_at: "2012-09-23 17:48:13", deleted_at: nil, created_at: "2012-09-22 17:48:13", updated_at: "2012-10-02 17:48:13">
[2] pry(#<NotificationCreationService>)> record.is_a?(Item)
=> false
[3] pry(#<NotificationCreationService>)> record.class.name
=> "Item"
[4] pry(#<NotificationCreationService>)> record.class
=> Item(id: integer, kind: integer, user_id: integer, community_id: integer, category_id: integer, root_category_id: integer, title: string, description: string, price: decimal, original_price: decimal, lowest_price: decimal, price_drop_count: integer, for_sale: b
You can’t perform that action at this time.