Skip to content

Instantly share code, notes, and snippets.

View infovore's full-sized avatar

Tom Armitage infovore

View GitHub Profile
function float_to_fraction (x, error) {
if (error === undefined) {
error = 0.000001;
}
var n = parseInt(Math.floor(x));
x = x-n;
if(x < error) {
return [n,1];
} else if(1-error < x) {

Keybase proof

I hereby claim:

  • I am infovore on github.
  • I am infovore (https://keybase.io/infovore) on keybase.
  • I have a public key ASCAHRw7VQD7Fin5mqPqid4cPDmG2lZ2nuO49e4BFWrkeQo

To claim this, I am signing this object:

#!/usr/bin/env ruby
unless ARGV[0] && ARGV[1]
puts "Usage: fadeinout INPUT OUTPUT [DURATION]"
exit
end
if ARGV[2]
duration = ARGV[2].to_f
else
sudo yum install -y epel-release
# we need this rpmforge release for libmad-devel:
sudo rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
sudo yum install git cmake libmad-devel libsndfile-devel \
gd-devel unzip -y
# next, let's install boost
# from here: http://vicendominguez.blogspot.co.uk/2014/04/boost-c-library-rpm-packages-for-centos.html
sudo wget http://repo.enetres.net/enetres.repo -O /etc/yum.repos.d/enetres.repo
@infovore
infovore / audiowaveform.yml
Created September 14, 2015 14:30
Ansible Playbook to provision audiowaveform
---
- hosts: YOUR_HOST_HERE
tasks:
- name: Install audiowaveform dependencies
apt: pkg={{item}} state=installed
with_items:
- git-core
- make
- cmake
- gcc
@infovore
infovore / gist:b6c4bc71a1bffdfd9846
Last active September 1, 2015 11:47
setTimeout is probably the first place you ever used a callback.
// Let's make an alert 2s after a page loads.
// We'll need to set a timeout.
// What are the ways we can make Timeouts?
// This was the way I first learned.
function hello() {
alert("Hello!");
}
load_sample :loop_amen
load_sample :bass_dnb_f
with_fx(:rlpf, cutoff: 40, cutoff_slide: 4) do |c|
one_to_eight = (1..8)
live_loop :drums do |count|
if (count+1) % 8 == 0
# put a break in every eight bars where you chop the break randomly
slices = one_to_eight.to_a.sort_by { rand }
@infovore
infovore / 6musicnow
Created March 27, 2015 12:25
Ruby script to spit out what's playing, by who, on 6Music right now, into your shell.
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://www.bbc.co.uk/6music'))
artist = doc.css('.realtime-now-playing .rtm-np-artist').text.strip
track = doc.css('.realtime-now-playing .rtm-np-track').text.strip
require 'pi_piper'
include PiPiper
pin = PiPiper::Pin.new(:pin => 17, :direction => :out)
pin.off
loop do
pin.on
sleep 1
pin.off
description "A script controlled by upstart"
author "Tom Armitage - tom@infovore.org"
start on started mountall
stop on shutdown
script
export HOME="/home/pi"
exec /home/pi/src/script.sh
end script