Skip to content

Instantly share code, notes, and snippets.

View convert-rails-secrets.rb
#!/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'
View captive-dns.conf
firewall {
name GUEST_IN {
default-action accept
description "packets from guest network"
rule 1000 {
action accept
description "allow DNS to pihole"
destination {
mroach /
Created Jul 30, 2018
Logs Magic Trackpad 2 battery life to log file with timestamp
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 /
Created Jun 6, 2018
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/
mroach / date_time_demo.rb
Created Mar 13, 2018
DateTime and Time math
View date_time_demo.rb
# 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:
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 -
mroach / Gemfile
Last active Mar 16, 2017
Bootstrapping testing
View Gemfile
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
# 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)
if [ ! -f "$pid_path" ]; then
mroach / _breadcrumbs.html.slim
Last active Aug 29, 2015
breadcrumbs_on_rails builder for Semanti UI breadcrumbs
View _breadcrumbs.html.slim
- unless breadcrumbs.empty?
= render_breadcrumbs builder: BreadcrumbsOnRails::Breadcrumbs::SemanticUiBuilder
View gist:a86279af0b027266aa7e
- name: Disable Challenge-Response authentication
line="ChallengeResponseAuthentication no"
notify: restart ssh
# OR