This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Once bound, apply does nothing. | |
(function () {console.log(this.bar);}).bind({bar: true}).apply({bar: false}); | |
// Output: true. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @license | |
* Copyright 2016 Xingchen Hong | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Start from a Promise. | |
var foo = new Promise(function (resolve, reject) { | |
// Has to resolve to run callbacks in `.then()`. | |
resolve(1); | |
}); | |
foo.then(function (result) { | |
// Received final resolve value from the Promise. | |
// result === 1; | |
console.log('result 1', result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const nodePath = process.argv[0], | |
exePath = process.argv[1], | |
inputPath = process.argv[2], | |
fs = require('fs'); | |
if (typeof inputPath === 'undefined') { | |
throw new Error('Need to specify input file path.'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
namespace CsTests | |
{ | |
class Program | |
{ | |
public static void Main (string[] args) | |
{ | |
Console.WriteLine ("Hello World!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Omit the last argument (the callback) of the original function and use promise instead. | |
function wrapAsPromise (func) { | |
var expectedArgCount = func.length - 1; | |
return function () { | |
// Only the last argument (the callback) can be missing. | |
switch (true) { | |
case arguments.length < expectedArgCount: | |
throw new Error('Not enough arguments given. Expecting ' + expectedArgCount + '.'); | |
break; | |
case arguments.length < expectedArgCount: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {function} func - The function to call. The payload of the promise. | |
* @param {Array.<*>} args - The list of arguments for `func`. | |
* @param {*} ctx - The context for `func`. | |
*/ | |
function makePromise(func, args, ctx) { | |
return new Promise(function (resolve, reject) { | |
try { | |
func.apply(ctx, Array.prototype.concat.call(args, function (err, result) { | |
if (err) { reject(err); } else { resolve(result); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dockerfile for the TerraRef hyperspectral image conversion extractor | |
# August 17, 2016 | |
FROM ubuntu:14.04 | |
MAINTAINER Yan Y. Liu <yanliu@illinois.edu> | |
# install common libraries and python modules | |
USER root | |
RUN apt-get update | |
RUN apt-get upgrade -y -q | |
RUN apt-get install -y -q build-essential m4 swig antlr libantlr-dev udunits-bin libudunits2-dev unzip cmake wget git libjpeg-dev libpng-dev libtiff-dev |
OlderNewer