Skip to content

Instantly share code, notes, and snippets.

View ggilder's full-sized avatar

Gabriel Gilder ggilder

View GitHub Profile
@ggilder
ggilder / compare.py
Created May 26, 2023 22:25
Audio file fingerprint comparison tool
# Code adapted from: https://shivama205.medium.com/audio-signals-comparison-23e431ed2207
import argparse
import subprocess
import numpy
# seconds to sample audio file for
sample_time = 500
# number of points to scan cross correlation over
span = 150
[Bb F g d g d Eb F] x3
Bb Eb F d
the sharpest girl at the party house
g Eb Bb F
you laughed at all the right times
Bb Eb F d
your eyes are like a ferrari, girl,
g Eb Bb F
you've got eyes with brains behind
@ggilder
ggilder / test_connection_pool.rb
Last active August 29, 2015 14:13
Test connection_pool with Timeout interrupts
#!/usr/bin/env ruby
# Uncomment & fix the following line to test against a local checkout of connection_pool
# $LOAD_PATH.unshift '/Users/gabriel/oss/connection_pool/lib'
require 'redis'
require 'connection_pool'
require 'timeout'
pool = ConnectionPool.new(size: 5, timeout: 5) do
@ggilder
ggilder / selecta.go
Created July 30, 2014 07:45
selecta (go)
package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
)
@ggilder
ggilder / log.txt
Created December 15, 2012 19:16
Demo of default command with commander
→ ./tester.rb
initialized with .
Compile called
→ ./tester.rb --dir .
initialized with .
Compile called
→ ./tester.rb deploy
initialized with .
Deploy called
→ ./tester.rb deploy --dir .
@ggilder
ggilder / dropbox_empty_files.sh
Created October 27, 2012 21:31
Check for files affected by Dropbox bug
#!/usr/bin/env bash
# Dropbox apparently has a potential bug where files can be zeroed out.
# Description here:
# http://konklone.com/post/dropbox-bug-can-permanently-lose-your-files
#
# The script in that article to detect zero-byte files is pretty naive about
# files that normally would be zero bytes, so here's an improved version that
# ignores some common cases:
# - Mac OS icons
@ggilder
ggilder / linked_stack.js
Created August 1, 2012 07:29
Linked List Javascript implementation (node.js)
var assert = require('assert');
var LinkedStack = (function(){
function Item(data){
this.data = data;
this.next = null;
}
Item.prototype = {
tail: function(){
@ggilder
ggilder / linked_stack.rb
Created August 1, 2012 07:03
Linked List Ruby implementation
require 'minitest/autorun'
class LinkedStack
class ElementNotFound < RuntimeError; end
attr_reader :head
def empty?
@head == nil
end
@ggilder
ggilder / ruby_koan_greed.rb
Created July 24, 2012 05:25
Ruby Koans - Greed
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used to calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
#
@ggilder
ggilder / fizz.rb
Created June 8, 2012 05:14
Fizzbuzz bitwise math
messages = [nil, "Fizz", "Buzz", "FizzBuzz"]
acc = 810092048
(1..100).each do |i|
c = acc & 3
puts messages[c] || i
acc = acc >> 2 | c << 28
end
# Explanation
#