Skip to content

Instantly share code, notes, and snippets.

View thelemonyfresh's full-sized avatar

Daniel Porter thelemonyfresh

View GitHub Profile
use_bpm 75 # change this to change the tempo
live_loop :conductorator do
root = :E # change this to an musical note to change the 'key' (i.e. :A, :E, :G)
use_random_seed 6 # change this to any integer get different songs (I like 6, 1337, 74)
# uncomment/comment any of the 'nil' lines to stop/start any instruments from playing on the next iteration
# change any of the "amp: x" (0<x<1) params to adjust relative volume
set(:kick_pattern, {times: spread_to_pattern(spread(range(2,8,1).choose,16),0.5), length: 8, amp: 0.5})
@thelemonyfresh
thelemonyfresh / rails_anagram_finding.md
Last active August 31, 2022 21:14
Anagram finding in Rails, optimized.

TLDR

I optimize bulk anagram record creation from ~15 minutes (using the "naive" ActiveRecord approach) to ~10 seconds.

Intro

I'm making an app to practice for anagram games (think Scrabble, Words with Friends, etc.). Given a list of words, I need a way to quickly lookup anagrams that exist as words in that list.

I'll be using the TWL06 (tournament word list used for Scrabble in the US and Canada), which has ~180k words, stored as a .txt file separated with line breaks.

@thelemonyfresh
thelemonyfresh / load_tracer
Last active January 25, 2018 21:04
Print file names as rails app loads
# bin/rails
#
# drop the following into bin/rails to list files as they load -- useful for tracking down order dependency issues
files = []
tp = TracePoint.new(:line) do |tp|
if tp.path =~ /<repository_name>/
unless files.include? tp.path
puts "#{tp.path}".inspect
files.push(tp.path)