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
// FORKED FROM: https://gist.github.com/cowboyd/74c0fd9e7aa3cccaeda0b84604c0136a | |
// | |
// using CAF instead of Effection. | |
/** | |
* Implements an operation to fetch the data as described in https://twitter.com/BenLesh/status/1455597411385098242 | |
* The "winner" is unambiguous. It is the request corresponding to the latest click, guaranteed. | |
* Other important things to note: | |
* | |
* 1. The HTTP request is cancelled every time along with its containing task |
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
// Doesn't throw an error, but doesn't return an object | |
const getObj = () => { a: 1 }; | |
console.log(getObj()); //=> val 'undefined' : void | |
// Reason: It looks like an arrow function returning an object, but it isn't. | |
// It's an arrow function with a function body (containing a labeled | |
// statement) that returns nothing. | |
const getObj = () => | |
{ // <- Start function body | |
a: // <- A label to use when break/continue; e.g. break a; |
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
//COMPILER: Scope, can you register an `Animal` and a `dog`? | |
//SCOPE: Sure. | |
var Animal, dog; | |
//ENGINE: Scope, do you have `Animal` available? | |
//SCOPE: Sure, here it is. | |
//ENGINE: I'm assigning a reference to the anonymous function to `Animal` | |
//COMPILER: I see a function expression with a parameter called `inLove` | |
//COMPILER: Scope, can you register `inLove` inside this function scope? |
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
var transform = function(contents, doneTransform) { | |
var authExpiry = 60 * 60 * 1000, | |
authId = uuid.v4(), | |
authKey = 'file:auth:' + authId; | |
redis.client.set(authKey, JSON.stringify({ | |
userId: req.user.id | |
})); | |
redis.client.expire(authKey, authExpiry); |
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
// This function takes a contents object with a files array. | |
// The goal is to cache each file details in redis then replace | |
// the file's path with a secure, obscured url. | |
// Finally the contents object is returned with the updated array | |
// in place of the old one. | |
// async = require('async') | |
// uuid = require('node-uuid') | |
// redis.client = require('node-redis').createClient() |
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
console.log('test'); |
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
var x = '/x/'; | |
/x/==x |
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
/* | |
* Forked Zakas' attempt at a `type()` "class" maker/extender utility. | |
* This variation just makes and links objects, without the unnecessity | |
* of using constructor functions. You can however specify `init()` | |
* functions to use upon creation of the object. NOTE: because there are | |
* no more constructor functions, comparisons with `instanceof` and | |
* `constructor` no longer apply. | |
*/ | |
function make(delegateTo, declaration) { |
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
/* | |
* Forked Zakas' attempt at a `type()` "class" maker/extender utility. | |
* Mainly, this approach automatically calls a type's super-type (if any) | |
* `constructor` upon construction of the type, if you didn't specify | |
* a `constructor` for the type itself. | |
*/ | |
function type(prototype, declaration) { | |
function mixin(receiver, supplier) { | |
if (Object.getOwnPropertyDescriptor) { |
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
var fs = require("fs"); | |
var jParser = require("jParser"); | |
var eof = false; | |
fs.readFile("sample.jpg",function(err,data) { | |
if (!err) { | |
var view = new jDataView(data, undefined, undefined, false); | |
var parser = new jParser(view,{ | |
// JPG |
NewerOlder