Skip to content

Instantly share code, notes, and snippets.

View hughrawlinson's full-sized avatar

Hugh Rawlinson hughrawlinson

View GitHub Profile
@hughrawlinson
hughrawlinson / binarycount.ino
Last active February 11, 2016 11:42
Binary Counting LEDs
int analogInput = 0;
int rate = 0;
int val = 0;
int count = 0;
void setup()
{
pinMode(analogInput, INPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
@hughrawlinson
hughrawlinson / js_poem.js
Last active February 11, 2016 11:40
An ode to Javascript
var JavascriptIs = ["wonderful","frustrating","charming","delightful"];
console.log("I love javascript");
// sometimes it does stupid shit
['10','10','10'].map(parseInt);
console.log("but all the time it's:");
setInterval(function(){
console.log(JavascriptIs[Math.round(Math.random()*JavascriptIs.length)]);
},1000);
@hughrawlinson
hughrawlinson / wac1_notes.md
Last active February 26, 2018 19:30
Web Audio Conference Presentation Resources

Monday morning, January 26, 2015

9.15 Keynote #1 Audio and the Web - Chris Wilson

Tools & Components

###Session Moderator: Raphaël Troncy 10.30 Building a Collaborative Digital Audio Workstation Based on the Web Audio API - Jan Monschke

@hughrawlinson
hughrawlinson / wat.js
Last active August 29, 2015 14:19
Function or variable, literally do not care.
// Is this a thing that people do? If so, what is it called? If not, why is it a bad idea? Answers on a tweet please. @hughrawlinson
var π = function(f,obj){
try{
f(obj());
}
catch(e){
f(obj);
}
};
@hughrawlinson
hughrawlinson / summary.md
Last active February 11, 2016 11:39
A Brief Summary of Haskell

A Brief Summary of Haskell

Haskell is a functional programming language, in the ML family of languages, inheriting many of it’s properties from Lambda calculus. The label ‘functional’ refers to the fact that in functional languages, functions are treated as higher order objects. This means that they may be assigned to variables in the functional languages that have a concept of ‘variables’ in the traditional sense, and are otherwise treated as values. Both Haskell and Javascript are ‘functional’ languages in this capacity, however, they differ in many other ways. Javascript is a loosely typed language, meaning that it’s values, expressions, and functions do not have a specific type. One function could return values of different types depending on the arguments it receives, external state, or potentially other factors like internal calls to type unsafe APIs or underlying libraries. Javascript also features type coercion, where the interpreter will automatically convert variables of certain types into other t

//setup
var i = 0;
function log(a){
console.log(a);
}
// read string literals as "string", and = and === as "is"
//haiku starts here
while(i<3){
s = "i like javascript ";if(i===1)s+=" a lot";
log(s);i++;
@hughrawlinson
hughrawlinson / Histogram.java
Last active February 11, 2016 11:39
A histogram class in Java using Lambdas that I was quite proud of
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.function.Function;
@hughrawlinson
hughrawlinson / extractor.py
Created February 1, 2016 21:01
High Resolution Audio Databasing
import librosa
import jams
import os
import mutagen
import argparse
import requests
n_fft = 4096
hop_length = n_fft/2
@hughrawlinson
hughrawlinson / reduce.js
Created February 11, 2016 11:16
I love functional Javascript and the chrome developer tools.
a=Array.prototype.map.bind(document.querySelectorAll('.row>.col-lg-3'))(function(a){
return [
a.children[0].innerText,
Array.prototype.map.bind(a.children[1].children)(function(b){
var anchor = b.children[0];
return {name:anchor.innerText,href:anchor.href};
})
];
}).reduce(function(acc,el){
acc[el[0]] = el[1];
@hughrawlinson
hughrawlinson / catch.php
Created February 11, 2016 14:33
PHP Error Handling
// Excellent work, Simon O'Shea. 😂
<?php
try {
// Something
} catch (Exception $e) {
header("location: https://stackoverflow.com/search?q=[php] ".$e->getMessage());
}
?>