Skip to content

Instantly share code, notes, and snippets.

View tdg5's full-sized avatar

Danny Guinther tdg5

View GitHub Profile
2024-06-11T13:55:58.652-0400 [INFO] Terraform version: 1.8.3
2024-06-11T13:55:58.653-0400 [DEBUG] using v1.51.0
2024-06-11T13:55:58.653-0400 [DEBUG] using v2.20.0
2024-06-11T13:55:58.653-0400 [DEBUG] using v0.1.1
2024-06-11T13:55:58.653-0400 [DEBUG] using v1.14.3
2024-06-11T13:55:58.653-0400 [INFO] Go runtime version: go1.22.1
2024-06-11T13:55:58.653-0400 [INFO] CLI args: []string{"terraform", "apply", "-auto-approve"}
2024-06-11T13:55:58.653-0400 [DEBUG] Attempting to open CLI config file: /Users/danny/.terraformrc
2024-06-11T13:55:58.653-0400 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2024-06-11T13:55:58.653-0400 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
tdg5 /
Last active November 2, 2015 13:06
Patch to install Ruby with tail call optimization enabled by default

Installation with RVM:

  $ rvm install 2.2.3 --patch
tdg5 /
Last active October 30, 2015 19:48
Various bits of the cassandra cleanup process code
private void doCleanupCompaction(final ColumnFamilyStore cfs, Collection<SSTableReader> sstables, CounterId.OneShotRenewer renewer) throws IOException
assert !cfs.isIndex();
Keyspace keyspace = cfs.keyspace;
Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName());
if (ranges.isEmpty())
tdg5 / tail_positions.rb
Created October 12, 2015 20:24
Script to explore in which situations tail call elimination can occur in Ruby
require "tco_method"
# Wrap method definitons in a lambda to facilitate recompiling with tail call
# optimization enabled.
tail_calls = lambda do |this|
def start_tail_call_chain
def implicit_tail_call
tdg5 / unary_ampersand_keeping_refs.rb
Last active October 7, 2015 14:19
Example seeming to demonstrate that unary ampersand operator holds on to obj references in Ruby 2.1.x
# Create some special classes to facilitate tracking allocated objects.
class TrackedArray < Array; end
class TrackedString < String; end
STRANG = "a" * 5000
class ClingyObjects
def generate(should_cling = false)
strs =
30000.times { strs << }
tdg5 / gc_friendly_tco.rb
Created October 7, 2015 12:55
Example demonstrating that tail-call optimization in MRI Ruby allows for earlier garbage collection of unreachable objects.
# Create some special classes to facilitate tracking allocated objects.
class TrackedArray < Array; end
class TrackedString < String; end
STRANG = "a" * 5000
# Other than a few extra escapes, the code below can be understood more or less
# as is. Any weirdness is to facilitate interpretting with/without tail-call
# optimization in a DRY manner.
class GcFriendlyTco
tdg5 / better_oo_through_tco.rb
Last active September 30, 2015 12:34
Better Object-Oriented Design Through... Tail-Call Optimization?
# Abstract UnionList base class
class AbstractUnionList
private :initialize
def length
def how_many?(counter)
raise NotImplementedError
tdg5 / pry_hooks.rb
Created June 9, 2015 23:16
Pry Hooks!
].each do |hook|
Pry.config.hooks.add_hook(hook.to_sym, "my_#{hook}_hook") do |_, _, _|
puts "hello from #{hook}"
tdg5 / partially_implemented_interface.rb
Created April 15, 2015 19:00
PartiallyImplementedInterface mixin
module PartiallyImplementedInterface
def self.not_implemented_error(klass, method)
raise NotImplementedError, not_implemented_message(klass, method), caller(2)
def self.not_implemented_message(klass, method_name)
"#{method_name} must be implemented by subclasses of #{}!"
private_class_method :not_implemented_message
tdg5 / itr_pbt_deep_dup_build.rb
Last active August 29, 2015 14:17
iterative pbt_deep_dup_build
def self.pbt_deep_dup_build(clone, original)
mapped =
edges = [[clone, original]]
while edges.any?
builder, twin = edges.shift
pair_hash = "#{}:#{builder.hash}~#{twin.hash}".hash
next if mapped.include?(pair_hash)
mapped << pair_hash
pbt_dup_build(builder, twin)