Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am sumdog on github.
  • I am djsumdog (https://keybase.io/djsumdog) on keybase.
  • I have a public key ASC2qIxUbImlbNqXtlKPQNjsbt6nVee1M9zT7OXQE-Oy-Qo

To claim this, I am signing this object:

# Records = [ 'something.example.com', 'some.other.example.com', 'example.net', 'somethingelse.example.net', 'example.org' ]
def domain_records(records)
records.map { |r|
base = r.split('.')[1..2].join('.')
sub_domain = .split('.')[-3].join('.')
}
end
# Is there a functional way to get a result like..
# { 'example.com' => [ 'something', 'some.other' ], 'example.net' => ['somethingelse'], 'example.org' => [] }
@sumdog
sumdog / stripfootnotes.rb
Created November 7, 2015 09:05
Jekyll plug-in for stripping footnotes from kramdown encoded text
require 'nokogiri'
module Jekyll
module StripFootnotesFilter
def strip_footnotes(raw)
doc = Nokogiri::HTML.fragment(raw.encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => ''))
for block in ['div', 'sup', 'a'] do
doc.css(block).each do |ele|
module Jekyll
class << self
def sanitized_path(base_directory, questionable_path)
if base_directory.eql?(questionable_path)
base_directory
elsif questionable_path.start_with?(base_directory)
questionable_path
elsif File.exists?(questionable_path)
File.expand_path(questionable_path)
@sumdog
sumdog / gist:f16f7e528ae404d703c8
Created January 28, 2015 23:14
Local Actions don't seem to work on ansible 1.8.2
# Check if password has been generated
- local_action: stat path={{ pgp_password_file }}
register: local_pgp_password_file
# Generate password if it doesn't exist
- local_action: command pwgen -s 25 1 #TODO: settings for length
register: password
@sumdog
sumdog / gist:db0d4060990197876cc5
Created September 30, 2014 22:56
Ruby syntax error parsing args
options = {}
opts = OptionParser.new do |opts|
opts.banner = 'Usage: create_env [-f] [-e (build|run)] [-d (mysql|postgres|mssql)] <environment name>'
opts.on_tail("-h", "--help", "Show this message") do
puts STDERR.opts
exit
end