Skip to content

Instantly share code, notes, and snippets.

View lukehoban's full-sized avatar

Luke Hoban lukehoban

View GitHub Profile
@lukehoban
lukehoban / es6features.md
Last active December 6, 2019 01:50
ECMAScript 6 Features

Note: Up to date version now at https://github.com/lukehoban/es6features

ECMAScript 6

Introduction

ECMAScript 6 is the upcoming version of the ECMAScript standard. This standard is targetting ratifcation in December 2014. ES6 is a significant update to the language, and the first update to the language since ES5 was standardized in 2009. Implementation of these features in major JavaScript engines is underway now.

See the draft ES6 standard for full specification of the ECMAScript 6 language.

ES6 includes the following new features:

@lukehoban
lukehoban / topics.md
Last active August 29, 2015 13:58
async.april2014
function $(x: string | Element): { elem: Element } {
if(x instanceof Element) {
return { elem: document.getElementById(x) } // do I have to say <string>x here?
} else {
return { elem: x } // do I have to say <Element>x here?
}
}
@lukehoban
lukehoban / echoHttpRequest.js
Last active August 29, 2015 14:08 — forked from Marak/echoHttpRequest.js
Echo HTTP requests
module['exports'] = function echoHttp (hook) {
hook.debug("Debug messages are sent to the debug console");
hook.debug(hook.params);
hook.debug(hook.req.path);
hook.debug(hook.req.method);
@lukehoban
lukehoban / isTheWebsiteDown.js
Last active August 29, 2015 14:08 — forked from Marak/isTheWebsiteDown.js
Checks to see if a website is down
var http = require('http');
module['exports'] = function isTheWebSiteDown (hook) {
http.get(hook.params.url, function(res){
hook.debug(hook.params.url + " is up and running.")
hook.res.end('false');
}).on('error', function (){
hook.debug(hook.params.url + " is DOWN!")
hook.res.end('true');
});
<h1>Todo List</h1>
<form class="form-inline">
<input type="text" class="form-control" placeholder="Add a new todo..." />
<btn typeof="submit" class="btn btn-primary">Add Todo</btn>
</form>
<br/>
<table class="table table-bordered">
@lukehoban
lukehoban / asyncloops.js
Last active May 31, 2021 23:18
Async/await and parallel loops
// ES6 w/ Promises
// Note: From a React starter template - see https://t.co/wkStq8y3I5
function fetchData(routes, params) {
let data = {};
return Promise.all(routes
.filter(route => route.handler.fetchData)
.map(route => {
return route.handler.fetchData(params).then(resp => {
data[route.name] = resp;
@lukehoban
lukehoban / speech.js
Last active December 28, 2023 15:14
Project Oxford Speech APIs Node.js Sample
var fs = require('fs');
var util = require('util');
var request = require('request');
var clientId = 'test-app'; // Can be anything
var clientSecret = 'f6f0bfec08274b8790520a9079b808af'; // API key from Azure marketplace
var str = 'This is a cool demo to call Microsoft text to speach service in Node.js.';
console.log('Converting from text -> speech -> text.');
@lukehoban
lukehoban / tasks.json
Last active December 16, 2015 20:09
Tasks.json for Delve
{
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"showOutput": "silent",
"args": ["install"],
"osx": {
"options": {
"env": {
"CERT": "dlv-cert"
@lukehoban
lukehoban / testHook.js
Created March 1, 2016 15:23
My first hook.io microservice
// A simple hello world microservice
// Click "Deploy Service" to deploy this code
// Service will respond to HTTP requests with a string
import sleep from 'then-sleep';
export default async function (hook) {
await sleep(500);
hook.res.end("Hello world!");
}