Skip to content

Instantly share code, notes, and snippets.

@anotheredward
anotheredward / synth
Last active August 29, 2015 14:16
List of constants for use with http://studio.substack.net
var otomata = [ 220, 233, 261, 293, 330, 349, 440, 523 ];
var harmonicMinotaur = [ 262, 293, 311, 349, 391 ];
var majorPentatonic = [ 262, 293, 329, 391, 440 ];
var C0 =16.35,
Cs0=17.32,
D0 =18.35,
Ds0=19.45,
E0 =20.60,
F0 =21.83,
@anotheredward
anotheredward / gist:ebbe30c6c2ac8cba0703
Created April 21, 2015 05:47
Functional Programming Exercise
//Copy this over the contents at tddbin.com
//Replace the [] in the assert statements with a functional equivalant
//Reference here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
//Lambda syntax: (x,y) => x + y, works in firefox, try it out :)
function range(start, end, jump) {
jump = jump || 1
if (start && !end)
return actualRange(0, start, jump)
return actualRange(start, end, jump)
@anotheredward
anotheredward / importFromLoopback.js
Created June 22, 2015 22:12
Creates an Ember model body from a loopback json model
var fs = require('fs')
function printFormat(key) {
console.log(key + ": attr('" + model.properties[key].type + "'),")
}
var model = JSON.parse(fs.readFileSync(process.argv[2], {encoding: 'ascii'}))
Object.keys(model.properties).map(printFormat)
@anotheredward
anotheredward / checklist.html
Created October 12, 2015 03:07
Starting point for a Code Review checklist
<h2>Code Review Checklist</h2>
<input type="checkbox"> Read Ticket <br>
<input type="checkbox"> Works from clean install <br>
<input type="checkbox"> Test Functionality: Does it solve the problem/satisfy the AC? <br>
<input type="checkbox"> Green path <br>
<input type="checkbox"> Red path <br>
<hr>
<p>Look for</p>
<input type="checkbox"> Errors in inspector <br>
@anotheredward
anotheredward / checkout.sh
Created November 22, 2015 19:21
checkout.sh
#! /usr/local/bin/zsh
vagrant up
npm prune
npm install
npm run migrate:down && npm run migrate:up
cd client
npm prune
npm install
@anotheredward
anotheredward / swaggerScan.js
Created July 10, 2016 22:49
Script for hitting all of the endpoints of a swagger API exposed by a Loopback Application
// Download swagger.json from /explorer/swagger.json
'use strict'
const api = require('./swagger.json')
const rp = require('request-promise')
const apiUrl = 'http://something.com/api'
let requests = []
for (let path of Object.keys(api.paths)) {
for (let method of Object.keys(api.paths[path])) {
@anotheredward
anotheredward / roguelike.html
Created July 27, 2016 23:08
11 Minute Roguelike
<pre id="maze"></pre>
<script>
'use strict'
const maze = [
'#####',
'#@..#',
'###.#',
'#...#',
'#.#####',
'#.#...###',
@anotheredward
anotheredward / rl2.html
Last active August 2, 2016 02:48
CHCH.js Roguelike with basic Line of Sight
<pre id="maze"></pre>
<script>
'use strict'
const maze = [
'#########',
'#@..#####',
'###.#####',
'#...#####',
'#.#######',
'#.#...###',
@anotheredward
anotheredward / rl.html
Last active August 2, 2016 03:12
CHCH.js Roguelike
<pre id="maze"></pre>
<script>
//Why a roguelike?
//A RL is a sweetspot between effort vs. new features
//You get something awesome every 5 LoC or even just by tweaking a single variable, and this makes it fun to program
//What's exciting about JS is that you can make something you can see in a browser, fast, and then share it with everyone
//JS being a simple to understand, practical, and easy to share language has helped it develop an awesome community
//Things to tweak
//Try adding a ghost trail to the player by not replacing their last position with a .
//Try making an AI that moves randomly, that moves towards the player, that runs away from the player (like tag)
@anotheredward
anotheredward / fpw.html
Created August 9, 2016 23:01
First-person Walker
<canvas id='canvas' width='1000' height='1000'>
<script>
const c = document.getElementById('canvas')
const ctx = c.getContext('2d')
const unit = 100
let player = {x: 1, y: 1}
let wall = {x: 1, y:0 }
//wall position is 1,0, wall is unit size
//wall width and height decrease linerarly with distance