Skip to content

Instantly share code, notes, and snippets.

View opensourceame's full-sized avatar

David Kelly opensourceame

View GitHub Profile
@opensourceame
opensourceame / gist:24f43ccc42a47d246931fbcd84afa668
Last active August 31, 2017 22:36
fibonacci series in Ruby
# output the fibonacci series to n in the series
#
def fibonacci(n, last = 1, previous = 0)
puts previous
current = last + previous
return if n == 0
@opensourceame
opensourceame / application.rb
Created April 21, 2020 13:45
fix to make Rails 4 work with Postgres gem > 0.20.0
# fix to make Rails 4 work with Postgres gem > 0.20.0
#
# place this in your config/application.rb just after the Bundler.require() line
module Kernel
def gem_with_pg_fix(dep, *reqs)
if dep == "pg" && reqs == ["~> 0.15"]
reqs = ["~> 1.0"]
end
gem_without_pg_fix(dep, *reqs)
end
@opensourceame
opensourceame / redis-cli-aliases.sh
Created June 9, 2020 09:49
Useful redis command line aliases - e.g. delete keys using a wildcard / pattern
#!/bin/sh
#
# usage: redis-del-keys these:ones:*
redis-del-keys() {
redis-cli --scan --pattern $1 | xargs redis-cli del
}
@opensourceame
opensourceame / import_zone_to_hover.rb
Created December 22, 2020 10:35
Import a DNS zone file into hover.com
#!/usr/bin/env ruby
# import am DNS zone file into Hover
#
# first get your domain ID from here:
# https://www.hover.com/api/domains/yourdomain.com/dns/
#
# install the required gems:
#
# gem install hover dns-zone