Skip to content

Instantly share code, notes, and snippets.

View tnightingale's full-sized avatar

Tom Nightingale tnightingale

  • Test Double
  • Vancouver, Canada
View GitHub Profile
// let rec reverse p1 p2 =
// match p1 with
// [] -> p2
// | n :: p1’ -> reverse p1’ (n :: p2)
function reverse(p1, p2=[]) {
if (!p1.length) {
return p2;
}
const [n, ..._p1] = p1;
class Task extends EventEmitter {
_innerResolve;
constructor() {
super();
}
get running() {
return this._innerResolve !== undefined;
@tnightingale
tnightingale / index.js
Created October 15, 2016 08:13
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var getOrientedImage = require('exif-orientation-image');
fileUpload = document.createElement('input');
fileUpload.setAttribute('type', 'file');
document.body.appendChild(fileUpload);
fileUpload.addEventListener('change',function(e) {
var file = e.target.files[0];
getOrientedImage(file,function(err,canvas) {
gulp.task('release-js', ['build-js'], function (cb) {
pump([
gulp.src(DEST + '/main.js'),
uglify(),
gulp.dest(DEST)
], cb);
});
gulp.task('release-deps', ['deps'], function (cb) {
pump([
import StateProxy from "./state-proxy";
const {params, dispatch, state} = this.props,
{organization, trip} = params;
// Proxy objects are light-weight & contain very little of own state. Just a mechanism for
// traversing a state tree.
// Only StateProxy instance holds reference to state tree.
// The idea is it would be created after memoized selectors are run in mapStateToProps() or render().
let stateProxy = new StateProxy(dispatch, state),
"use strict";
const fs = require('fs'),
path = require('path');
const filestocopy = [
{
"res/android/drawable/logo.png":
"platforms/android/res/drawable-hdpi/logo.png"
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
#root {
height: 500px;
}
<?php require_once __DIR__.'/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Silex\Application;
$app = new Application();
$app['debug'] = true;
/**
* TODO: Need to add error handling and then submit pull request to 'blob-util'
* library.
*/
export function objectURLToBlob(url) {
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onreadystatechange = () => {
//
// Actions
//
export const CONFIRM_MODAL_RESPONSE = "CONFIRM_MODAL_RESPONSE";
export const SHOW_CONFIRM_MODAL = "SHOW_CONFIRM_MODAL";
export function confirmDeleteItem(id) {
let message = `Are you sure you want to delete item: ${id}`,
context = {id};
return showConfirmModal(message, 'confirmDeleteItem', context);