Skip to content

Instantly share code, notes, and snippets.

View juandopazo's full-sized avatar

Juan Dopazo juandopazo

View GitHub Profile
@juandopazo
juandopazo / gist:8849263
Created February 6, 2014 17:55
You can expect this to be Node code in <2 years
import { readFile } from 'fs';
import { createServer } from 'http';
createServer(async function (req, res) {
try {
var content = await readFile('foo.html');
res.end(content);
} catch (e) {
res.end('ouch!');
}
PromisePolyfill.async = (function () {
"use strict";
function Queue(capacity) {
this.capacity = this.snap(capacity);
this.length = 0;
this.front = 0;
this.initialize();
}
(function (global) {
"use strict";
function Queue(capacity) {
this.capacity = this.snap(capacity);
this.length = 0;
this.front = 0;
this.initialize();
}
CancellablePromise.all = function (values) {
var CancellablePromise = this;
var child;
var children = [];
return new CancellablePromise(function (resolve, reject) {
if (!A.Lang.isArray(values)) {
reject(new TypeError('CancellablePromise.all expects an array of values or promises'));
return;
}
CancellablePromise.all = function (values) {
var CancellablePromise = this;
var child;
var children = [];
return new CancellablePromise(function (resolve, reject) {
if (!A.Lang.isArray(values)) {
reject(new TypeError('CancellablePromise.all expects an array of values or promises'));
return;
}
@juandopazo
juandopazo / gist:dfc6c067f1442fa8fa23
Last active August 29, 2015 14:01
Loader hooks API surface
interface LoadRequest {
name: string;
address?: string;
source?: string;
metadata: Object;
}
interface Eventual<T> = T | Promise<T>;
interface ModuleInstantiator {
class QueueItem {
constructor(value) {
this.value = value;
this.next = void 0;
}
}
class Queue {
constructor() {
this.first = void 0;
<span id="yui_3_3_0_1_129815707302415" class="yui3-widget yui3-combobox yui3-combobox-focused">
<input type="text" class="yui3-combobox-input" role="combobox" aria-expanded="true" aria-autocomplete="list"
aria-owns="yui_3_3_0_1_129815707302418" style="width: 106px; "/>
<ul class="yui3-combobox yui3-combobox-content" id="yui_3_3_0_1_129815707302418" role="listbox">
<li class="yui3-combobox-option yui3-widget yui3-option yui3-option-content yui3-combobox-option-selected
yui3-option-selected" id="yui_3_3_0_1_129815707302446" role="option" tabindex="0">hello</li>
<li class="yui3-combobox-option yui3-widget yui3-option yui3-option-content" id="yui_3_3_0_1_129815707302466"
role="option" tabindex="-1">world</li>
</ul>
</span>
<!DOCTYPE html>
<html>
<head>
<title>ScrollView With Pagination</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>
/* Avoid resource latency for these, since they hide unenhanced content */
.yui3-js-enabled .yui3-scrollview-loading {
visibility:hidden;