Skip to content

Instantly share code, notes, and snippets.

@bradparker
bradparker / tuning-fork.js
Created September 21, 2014 04:59
Tuning Fork
var context = new AudioContext(),
gainNode = context.createGain(),
oscillator = context.createOscillator();
gainNode.connect(context.destination);
oscillator.frequency.value = 440;
oscillator.connect(gainNode);
oscillator.start();
// ..
// gainNode.gain.value = 0;
@bradparker
bradparker / anthropology
Last active August 29, 2015 14:06
Anthropology - Charlie Parker
|-------------------------|-------------------------|-------------------------|-------------------------|
|-------------------------|-------------------------|-------------------------|-------------------------|
|----7--------8--6--7--10-|----------8-----10-8-----|----7--8--7-----------7--|-------------------------|
|-8-----10-9--------------|-------------------------|-------------10-7--8-----|-10----8--7-----------8--|
|-------------------------|-------------------------|-------------------------|----10-------------------|
|-------------------------|-------------------------|-------------------------|-------------------------|
| + - + - + - + - | + - + - + - + - | + - + - + - + - | + - + - + - + - |
|-------------------------|-------------------------|-------------------------|-------------------------|
|-------------------------|-------------------------|----------------9-----7--|-8-----------------------|
@bradparker
bradparker / unit-matcher.js
Created November 20, 2014 22:32
Unit Matcher
// Take "3mm", "-3inches", or "3.45 cm" and return ['3', 'mm'], ['-3', 'inches'], ["3.45", "cm"] etc
function unitParse (str) {
return (str.match(/([-\d.]+)\s+?([A-Za-z]+)/) || []).slice(1)
}
@bradparker
bradparker / line-slope-intercept.js
Created December 31, 2014 03:33
Line, slope intercept form
function Line (slope, intercept) {
this.slope = slope
this.intercept = intercept
}
function getX (y) {
y = y || 0
return (y - this.intercept) / this.slope
}
Line.prototype.getX = getX;
@bradparker
bradparker / cons.js
Last active August 29, 2015 14:20
Cons!
const cons = (a, b) =>
(member) => {
if (member === 1) {
return a
} else if (member === 2) {
return b
}
}
const car = (pair) =>
@bradparker
bradparker / index.html
Created August 30, 2015 12:32
JS Scratch Pad
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Scratch pad</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.2.5/mocha.min.css" />
</head>
<body>
<div id="mocha"></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/chai/3.2.0/chai.min.js"></script>
@bradparker
bradparker / a_ok.rb
Created September 9, 2015 01:57
Well this is, unsurprisingly, fine
(1..10e6).map {
SecureRandom.uuid
}.reduce(Hash.new(0)) { |counts, uuid|
counts[uuid] += 1
counts
}.values.uniq
@bradparker
bradparker / rough-outline-of-steps.md
Created September 16, 2015 00:44
Design production process

Rough outline of the steps in an isolated design job

  • Define project objectives
  • Review identity standards
  • Develop concepts and prototypes (The Design process)
  • Present solution
  • Evaluate solution (Maybe loops back to Develop)
  • Prepare for production
  • Evaluate finished piece(s) (Maybe loops back to Develop)
  • Deliver finished files for production / distribution
@bradparker
bradparker / method-compose.js
Created November 17, 2015 08:01
Smoosh two object's methods together
const { keys, assign } = Object
const concern = {
doSideEffectyThing () {
this.property1 = 'Hip, hip!'
}
}
const instance = {
someProp: 'Foo',
const range = (start, end) =>
Array.from({
length: end - start
}).map((_, index) => (index + start))
const sum = nums =>
nums.reduce((total, num) => total + num)
sum(range(20, 100))