Skip to content

Instantly share code, notes, and snippets.

@anamba
anamba / set_min_tls_version.rb
Last active February 3, 2020 02:40
Set minimum TLS version on all Cloudflare zones
#!/usr/bin/env ruby
# Usage: CLOUDFLARE_TOKEN=[...] ./set_min_tls_version.rb
# Supplied token requires permissions zone:read and zone_settings:edit.
require 'faraday'
require 'json'
# ultra-minimal cloudflare api wrapper to make it easy to follow API docs: https://api.cloudflare.com/
CLOUDFLARE_API_HOST = 'api.cloudflare.com'
@anamba
anamba / dig.cr
Last active December 22, 2018 04:40
crystal: get ip addresses via dig w/ipv4 and ipv6 support
def dig(hostname, ip_addresses_only = true, ipv6 = false)
if ipv6
io = IO::Memory.new
Process.run("dig", [hostname, "AAAA", "+short"], output: io, shell: true)
output = io.to_s.lines
ip_addresses_only ? output.select { |s| s =~ /^[0-9a-f]+[:0-9a-f]+$/ } : output
else
io = IO::Memory.new
Process.run("dig", [hostname, "A", "+short"], output: io, shell: true)
output = io.to_s.lines
@anamba
anamba / link_local_shard
Last active December 22, 2018 05:45
Bash script to symlink a shard into lib to make development easier
@anamba
anamba / user.rb
Created May 14, 2012 04:41
User model
class User
include Dynamoid::Document
attr_reader :password
attr_accessor :password_confirmation
field :username
field :email_address
field :password_hash