Skip to content

Instantly share code, notes, and snippets.

@hcgatewood
hcgatewood / random_note.py
Last active July 25, 2024 23:33
Print a random note at the passed interval, defaulting to every 4 seconds
#!/usr/bin/env python3
"""
random_note.py prints a random musical note at the passed interval (seconds).
If no interval passed, defaults 4 seconds.
"""
import itertools
import random
@hcgatewood
hcgatewood / hash_table.rb
Last active December 23, 2019 08:23
An associative array in Ruby
#!/usr/bin/env ruby
# A simple hash table implementation in Ruby using Ruby's built-in
# prehashing methods, chaining, and variable load factors.
#
# Author:: Hunter Gatewood
# A linked-list node with key, value, and next node attributes.
class Node
attr_accessor(:key, :val, :next_node)