Skip to content

Instantly share code, notes, and snippets.

View benlesh's full-sized avatar
🐶
☕ 🔥 🔥 this is fine

Ben Lesh benlesh

🐶
☕ 🔥 🔥 this is fine
View GitHub Profile
@benlesh
benlesh / happy-promises.js
Last active February 5, 2016 00:59
I reject your reality
/**
* Running this file in Node (>4) will demonstrate that unhandled exceptions in promises will
* cause the process to continue running in a happy way, logging all 3 numbers.
* */
setTimeout(function () {
console.log(3);
}, 100);
console.log(1);
new Promise(function () {
@benlesh
benlesh / example.hbs
Created April 28, 2015 21:48
Car model update thing for jamesarosen
<h3>{{carMake}}</h3>
{{input value=model.car}}
<button {{action 'saveCar' model.car}}>Save</button>
var Observable = Rx.Observable;
// get a stream of keypresses (or even keyups)
var keypresses = Observable.fromEvent(myinput, 'keypress');
var subscription;
// throttled to every 500ms
subscription = keypresses.throttle(500).
// to a stream of values
map(function() {
@benlesh
benlesh / gist:ab8517a54b3e39b196ae
Created March 30, 2015 17:32
Generator Return Values are Weird
window.console.clear();
function* gen1() {
yield 1;
yield 2;
return 3;
}
function printForOf(iter) {
for(var x of iter) {
@benlesh
benlesh / demo.hbs
Last active August 29, 2015 14:17
Help me obi-bryn kenobi... you're my only hope
I have a table component that works like this (basically):
{{#nf-table data=someData}}
{{#nf-column}}
{{#nf-header}}Foo{{/nf-header}}
{{#nf-cell}}<button {{action 'fooClicked'}}>{{foo}}</button>{{/nf-cell}}
{{/nf-column}}
{{#nf-column}}
{{#nf-header}}Bar{{/nf-header}}
{{#nf-cell}}{{bar}}{{/nf-cell}}
<h3>{{title}}</h3>
{{multline-graph dataSourceName="NetflixFancyData"
otherThings="wee" whatNow="whatever"
brushAction="brush"}}
<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.3.22/rx.all.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<h1>Just say something</h1>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.3.22/rx.all.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
body {
font-family: Sans-serif;
@benlesh
benlesh / _web-workers.md
Last active August 29, 2015 14:06
dynamic-worker-blog-entry
@benlesh
benlesh / custom-circle.js
Last active August 29, 2015 14:06
Angular 1.3.0-beta.19 SVG custom element
/**
creates a circle in the upper left corner of its container
with the given radius. `<custom-circle radius="10"/>`
*/
app.directive('customCircle', function(){
return {
// the following two configuration options are
// required for SVG custom elements.
templateNamespace: 'svg',
replace: true,