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
function getMicroDataFromElement(element) { | |
element = element || document.body | |
function descendToAttribute(scope, attribute) { | |
return [].slice.apply(scope.children).reduce(function(props, child) { | |
return props.concat( | |
child.hasAttribute(attribute) ? [child] : descendToAttribute(child, attribute) | |
) | |
}, []) | |
} |
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
1:00 | |
one o'clock | |
2:05 | |
five past two | |
3:10 | |
ten past three | |
4:15 |
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
const express = require("express"); | |
const cheerio = require("cheerio"); | |
const httpism = require("httpism"); | |
if (process.env.PORT) { | |
startApp({ port: process.env.PORT, fetchCities }) | |
} else { | |
module.exports = startApp | |
} |
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 hyperdom = require('hyperdom') | |
var h = hyperdom.html | |
class App { | |
render() { | |
return h('.container', | |
h('#example', | |
h('div.foo div', h('input[type=submit]')) | |
), | |
h.component({ |
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
const assert = require('assert') | |
const lolex = require('lolex') | |
class CountdownTimerWithSetTimeout { | |
countdownFrom(n, element) { | |
element.innerText = n | |
setTimeout(() => { | |
n-- | |
element.innerText = n | |
if (n > 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
window.grecaptcha = { | |
getResponse: function() { | |
return 'FAKE-RECAPTCHA-RESPONSE' | |
}, | |
reset: function() { | |
console.log("FAKE-RECAPTCHA-RESET", arguments) | |
}, | |
render: function() { |
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
/* | |
# stateful-promise | |
Encapsulates a repeatable asynchronous operation, and exposes the state of the | |
current invocation. | |
``` | |
model.documents = new StatefulPromise(() => | |
http.get('/documents').then(response => response.body); | |
); |
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 plastiq = require('plastiq'); | |
var h = plastiq.html; | |
function render(model) { | |
return h('form', | |
renderFieldWithPlaceholder('First name', [model, 'firstName']), | |
renderFieldWithPlaceholder('Last name', [model, 'lastName']), | |
h('pre', JSON.stringify(model)) | |
); | |
} |
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 browserMonkey = require('browser-monkey'); | |
var builder = require('promise-builder'); | |
function append(html) { document.body.innerHTML += '<p>' + html + '</p>'; } | |
append('<div id="x"><button id="A">A</button></div>'); | |
append('<div id="y"><button id="B">B</button></div>'); | |
append('<div id="z"><button id="C">C</button></div>'); | |
function apiForScope(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
echo | |
echo "DELETE INDEX" | |
echo | |
curl -w "\r\n" -X DELETE http://localhost:9200/temp-index | |
echo | |
echo "CREATE MAPPINGS" | |
echo | |
curl -w "\r\n" -X POST http://localhost:9200/temp-index -d '{"mappings":{"asset":{"properties":{"name":{"type":"string","analyzer":"snowball"},"description":{"type":"string","analyzer":"snowball"}}}},"settings":{}}' |
NewerOlder