Skip to content

Instantly share code, notes, and snippets.

@matt-morris
matt-morris / editHierNode.html
Created February 6, 2019 22:18 — forked from rbelew/editHierNode.html
editHierNode: adding and editing nodes in d3.hierarchy
<!DOCTYPE html>
<!-- https://bl.ocks.org/mbostock/1093025 -->
<meta charset="utf-8">
<style>
.node rect {
cursor: pointer;
fill: #fff;
@matt-morris
matt-morris / components.draggable-item.js
Last active January 23, 2019 00:11
Drag and Drop Components
import Ember from 'ember';
export default Ember.Component.extend({
draggable: true,
attributeBindings: ['draggable'],
classNames: ['p-4 border'],
dragEnd() {
alert("the drag ended")
},
@matt-morris
matt-morris / README.md
Created July 25, 2018 17:25 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@matt-morris
matt-morris / development.ts
Created July 12, 2018 13:36 — forked from romelgomez/development.ts
Express Server with TypeScript
import * as server from "./server";
new server.App
@matt-morris
matt-morris / development.ts
Created July 12, 2018 13:36 — forked from romelgomez/development.ts
Express Server with TypeScript
import * as server from "./server";
new server.App
@matt-morris
matt-morris / sexp.peg
Created March 8, 2018 17:33 — forked from nightscape/sexp.peg
S-Expression grammar for PEG.js
/*
* Grammar to generate an S-Expressions parser for Javascript using http://pegjs.majda.cz/
*/
start
= expression*
integer "integer"
= digits:[0-9]+ { return parseInt(digits.join(""), 10); }
@matt-morris
matt-morris / express-async.js
Created December 12, 2017 19:55 — forked from q42jaap/express-async.js
A way to allow async await style middleware
import Layer from 'express/lib/router/layer';
const Promise = global.Promise;
/**
* "fixt" express mbt promises. Als een stukje middleware een promise returnt dan moeten errors eigenlijk aan next worden gegeven.
*
* We hadden ook de suffix `Async` kunnen gebruiken om naast de bestaande functies nieuwe te maken. Dat heeft een flink nadeel
* omdat de api op verschillende manieren te benaderen is.
*/
@matt-morris
matt-morris / quine-eye.rb
Created April 28, 2017 03:37
An ASCII Art Quine in Ruby
;;;def+;'@doubleEmms';end;;;class Quine;class<<self;def save;;;;;;;;;;;#
;;;;File.write('output.rb', File.read(__FILE__));end;end;end;require'pp';;
;;;; ;;;;
;;;; ;;;;
;;;; ;;;;
;;;; ;;;;
;;;; ;;;;
;;;; class XMYNETWZDz ;;;;
;;;; ;def foo;puts self.name#\. ;#;#
;;;; ;end;class VWXXy; ;#;#
@matt-morris
matt-morris / snowflake2a.pde
Created January 3, 2017 19:10 — forked from anonymous/snowflake2a.pde
Math Mondays: "snowflake" drawing app
/*
Snowflake 2.0a
Open-source "snowflake" drawing app with true vector output.
Click the "save" button to create a PDF document of your snowflake,
suitable for editing in Inkscape, Corel, Illustrator, or so forth.
Written by Windell H. Oskay, www.evilmadscientist.com
@matt-morris
matt-morris / renameToHash.sh
Created November 27, 2016 06:09 — forked from SimplGy/renameToHash.sh
Rename files with a hash based on their contents. eg: `abc.jpg` to `3101ace8db9f.jpg`. Useful for detecting duplicates.
#!/bin/bash
# TODO: skip tiny files (so small they couldn't be photos)
# TODO: make sure sym links and other file system oddities are handled
#
# Constants
#
CHAR_COUNT=12
BLOCK_COUNT=6
SKIP_SIZE=3 # Every new block is sampled by skipping this amount of blocks to the next position