This file contains hidden or 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
{ | |
"name": "What is a collection", | |
"description": null, | |
"displayField": "plainText", | |
"fields": [ | |
{ | |
"id": "plainText", | |
"name": "plainText", | |
"type": "Text", | |
"localized": false, |
This file contains hidden or 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 contentful = require('contentful') | |
var util = require('util') | |
var client = contentful.createClient({ | |
// This is the space ID. A space is like a project folder in Contentful terms | |
space: 'developer_bookshelf', | |
// This is the access token for this space. Normally you get both ID and the token in the Contentful web app | |
accessToken: '0b7f6x59a0' | |
}); | |
// This API call will request an entry with the specified ID from the space defined at the top, using a space-specific access token. |
This file contains hidden or 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 planout = require('planout'); | |
function getOwnPropertyDescriptors (obj) { | |
var descriptors = {}; | |
for (var prop in obj) { | |
if (obj.hasOwnProperty(prop)) { | |
descriptors[prop] = Object.getOwnPropertyDescriptor(obj, prop); | |
} | |
} | |
return descriptors; |
This file contains hidden or 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 planout = require('planout'); | |
function getOwnPropertyDescriptors (obj) { | |
var descriptors = {}; | |
for (var prop in obj) { | |
if (obj.hasOwnProperty(prop)) { | |
descriptors[prop] = Object.getOwnPropertyDescriptor(obj, prop); | |
} | |
} | |
return descriptors; |
This file contains hidden or 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 VNode = require('virtual-dom/vnode/vnode'); | |
var VText = require('virtual-dom/vnode/vtext'); | |
var createElement = require('virtual-dom/create-element'); | |
var patch = require('virtual-dom/patch'); | |
var diff = require('virtual-dom/diff'); | |
var convertHTML = require('html-to-vdom')({ | |
VNode: VNode, | |
VText: VText | |
}); |
This file contains hidden or 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 h = require('virtual-dom/h'); | |
var createElement = require('virtual-dom/create-element'); | |
var VNode = require('virtual-dom/vnode/vnode'); | |
var div = new VNode('div', { | |
contentEditable: true | |
}); | |
var vdom = h('div', { | |
contentEditable: true |
This file contains hidden or 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
(function(global) { | |
"use strict"; | |
function Map() { | |
this.data = {} | |
} | |
Map.prototype = { | |
get: function(key) { | |
return this.data[key + "~"] | |
}, |
This file contains hidden or 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 _ = require('lodash'); | |
var Promise = require('bluebird'); | |
var fakeRequest = function (url) { | |
return new Promise (function (resolve, reject) { | |
console.log(Date.now(), 'Request to', url); | |
setTimeout(function () { | |
console.log(Date.now(), 'Response from', url); | |
resolve(url) | |
}, Math.random() * 5000); |
This file contains hidden or 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 simply calls the callback with some data after a second | |
// Could be an AJAX call for example | |
var doSomethingAsync = function (callback) { | |
setTimeout(function () { | |
callback({ some: 'data' }); | |
}, 1000); | |
}; | |
var fnThatMakesAsyncCall = function () { | |
// From the outside there is no way to change this callback |
This file contains hidden or 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 async = require('async'); | |
var sampleData = [{'name':'name1', 'age':'age1'},{'name':'name2', 'age':'age2'},{'name':'name3', 'age':'age3'}]; | |
async.mapSeries(sampleData, function (data,callback) { | |
return callback(null, data['name']); | |
}, function(err, results) { | |
console.log('results : ', results); | |
}); | |
// Getting data by name | |
async.reduce(sampleData, {}, function (byName, data, callback) { |
NewerOlder