Skip to content

Instantly share code, notes, and snippets.

@matthewmueller
matthewmueller / flow-based-programming.md
Last active August 29, 2015 14:05
Some quick notes on flow-based programming

Flow-based Programming is all about reacting to event sources. Event sources in the browser might be:

  • A DOM event
  • AJAX call
  • Onload initial data passing
  • Local DB fetch (local storage, indexdb)

In order to build larger systems, nodes need to be chainable and flows need to be composable. I think the best way to do this in Javascript may look something like this:

dc.ui.Document = Backbone.View.extend({
initialize: function() {
this.model.bind('change', this._onDocumentChange);
this.model.bind('change:selected', this._setSelected);
this.model.bind('view:pages', this.viewPages);
this.model.notes.bind('add', this._addNote);
this.model.notes.bind('reset', this._renderNotes);
this.model.pageEntities.bind('reset', this._renderPages);
}
@TooTallNate
TooTallNate / README.md
Last active October 8, 2015 18:38
Forward port 80 traffic from 127.0.0.1 to port 3000 at bootup on OS X

Copy this file to: /Library/LaunchDaemons/fwd-80-to-3000.plist and then reboot:

$ sudo -s
$ curl -L https://gist.github.com/TooTallNate/3372589/raw/ace6451e9e47f59550f12d09cb924a64531cfd1f/fwd-80-to-3000.plist > /Library/LaunchDaemons/fwd-80-to-3000.plist
$ reboot
@glennansley
glennansley / git-resources.txt
Created November 8, 2011 13:00
Helpful Git Resources
These are some helpful Git resources that I found while climbing the learning curve.
Feel free to append / modify
=======================
== UNDERSTANDING GIT ==
=======================
* The Git Parable
- http://tom.preston-werner.com/2009/05/19/the-git-parable.html
- "Read this parable all the way through and you should have very little trouble mastering the various Git commands and wielding the awesome power that Git makes available to you."
anonymous
anonymous / jsbin.AQAmOnO.css
Created September 14, 2013 23:10
.blue {
height: 200px;
width: 100%;
background: #293e81;
}
.white {
height: 200px;
width: 100%;
background: #F7F7F7
@emilbjorklund
emilbjorklund / breakpoints_via_css.html
Created April 24, 2012 16:03
Width detection via sneaky CSS rules
<!DOCTYPE html>
<!--[if IE 8]> <html lang="sv-SE" class="no-js ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="sv-SE" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<title>Breakpoint detection test</title>
<style type="text/css" media="screen">
@media screen and (min-width: 320px) {
#page:after {
content: 'smallest'; /* represent the current width-bracket */
@tomconroy
tomconroy / Event.swift
Last active December 22, 2016 20:57
A simple Event Emitter for swift (use EmitterKit for something more robust)
class Event <T:Any> {
var handlers = Array<(T) -> Void>()
func listen(handler: (T) -> Void) {
handlers.append(handler)
}
func emit(object: T) {
for handler in handlers {
handler(object)
anonymous
anonymous / index.html
Created January 5, 2017 00:21
nice forms // source http://jsbin.com/yutabo
<style id="jsbin-css">
.form {
font-size: 1em;
color: #4C4C35;
box-sizing: border-box;
}
.form, .form * {
box-sizing: border-box;
}
@developit
developit / preact-vdom-viewer.js
Last active July 11, 2017 15:42
preact vdom viewer
/** Use the built-in document viewer in devtools to inspect your VDOM.
* Usage in console:
* viewComponentTree(document.body)
*/
function viewComponentTree(node) {
let doc = new DOMParser().parseFromString('', 'application/xml');
function visitor(dom) {
let el, c;
if (dom instanceof Node) {
el = dom.cloneNode();