Skip to content

Instantly share code, notes, and snippets.

View mroach's full-sized avatar
🦖
Jurassic Park

Mike Roach mroach

🦖
Jurassic Park
View GitHub Profile
- name: Disable Challenge-Response authentication
lineinfile:
dest=/etc/ssh/sshd_config
regexp="^ChallengeResponseAuthentication"
line="ChallengeResponseAuthentication no"
state=present
notify: restart ssh
# OR
@mroach
mroach / _breadcrumbs.html.slim
Last active August 29, 2015 14:15
breadcrumbs_on_rails builder for Semanti UI breadcrumbs
- unless breadcrumbs.empty?
div.ui.breadcrumb
= render_breadcrumbs builder: BreadcrumbsOnRails::Breadcrumbs::SemanticUiBuilder
#!/bin/bash
# If your system crashes or shuts-down hard, the PostgreSQL PID file is left
# behind and then it won't startup when your system restarts. Run this script
# to check if it's ok to delete the PID file and start PostgreSQL
prefix=$(brew --prefix)
pid_path="$prefix/var/postgres/postmaster.pid"
if [ ! -f "$pid_path" ]; then
@mroach
mroach / Gemfile
Last active March 16, 2017 08:31
Bootstrapping testing
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
# Spec testing
gem 'rspec-rails'
# Code coverage analysis
gem 'simplecov', require: false
@mroach
mroach / date_time_demo.rb
Created March 13, 2018 10:15
DateTime and Time math
# When adding or subtracting DateTime objects, the return type is a Rational expressing the fraction of a day's number of minutes (1440). So 0.5 would mean half a day, or 720 minutes, or 12 hours.
# When adding or subtracting Time objects, the return type is Float expressing the difference in seconds.
#Here's an example showing the difference between two times that are an hour apart:
MINUTES_IN_A_DAY = 1440
ref1 = "2018-03-13T08:00:00+00:00"
ref2 = "2018-03-13T09:00:00+00:00"
# -3600 = 3600 seconds ago, i.e. 1 hour ago
Time.zone.iso8601(ref1) - Time.zone.iso8601(ref2)
@mroach
mroach / wee-slack-setup.sh
Created June 6, 2018 07:08
Setting-up wee-slack
# deps
pip2 install websocket-client
# weechat itself
brew install weechat --with-aspell --with-python@2
# wee-slack
mkdir -p ~/.weechat/python/autoload
curl -o ~/.weechat/python/autoload/wee_slack.py https://raw.githubusercontent.com/wee-slack/wee-slack/master/wee_slack.py
@mroach
mroach / magic_trackpad_battery_logger.sh
Created July 30, 2018 12:30
Logs Magic Trackpad 2 battery life to log file with timestamp
#!/bin/bash
set -e
tmpfile="${TMPDIR}sys_bluetooth_$(date +%s).plist"
# dump data to temp plist file
/usr/sbin/system_profiler -xml SPBluetoothDataType > "$tmpfile"
# read battery percentage from tempfile and delete percent sign
@mroach
mroach / captive-dns.conf
Created August 6, 2019 05:15
Captive DNS
firewall {
name GUEST_IN {
default-action accept
description "packets from guest network"
rule 1000 {
action accept
description "allow DNS to pihole"
destination {
address 10.65.49.3
#!/usr/bin/env ruby
#
# Convert structured Ruby credentials to JSON that can be easily copy/pasted
# into an EJSON secrets file.
#
# Usage:
#
# rails credentails:show --environment staging | ./conv.rb
require 'yaml'