View elasticsearch.sh
#!/bin/bash | |
# Install a custom ElasticSearch version - https://www.elastic.co/products/elasticsearch | |
# | |
# To run this script in Codeship, add the following | |
# command to your project's test setup command: | |
# \curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/elasticsearch.sh | bash -s | |
# | |
# Add at least the following environment variables to your project configuration | |
# (otherwise the defaults below will be used). | |
# * ELASTICSEARCH_VERSION |
View index.js
const nextTick = () => Promise.resolve(); | |
class DataLoader { | |
constructor( batch ) { | |
this.batch = batch; | |
this.queue = []; | |
this.cache = new Map(); | |
} | |
View .nvmrc
10.6.0 |
View .babelrc
{ | |
"plugins": [ | |
"transform-flow-strip-types" | |
] | |
} |
View cfp.js
function CF() {} | |
CF.P1 = 'somevalue'; | |
CF.P2 = 'somevalue'; | |
var CFp = { | |
CFP1: 'somevalue' | |
}; | |
CF.prototype = CFp; |
View hibp.js
// convert an unsigned int to hex string | |
const toHex = b => ( '00' + b.toString( 16 ) ).slice( -2 ); | |
// return the SHA-1 hash of a given string | |
// note: crypto.subtle is unavailable on non-HTTPS pages | |
const sha1 = async str => { | |
const msg = new TextEncoder('utf-8').encode( str ); | |
const buf = await crypto.subtle.digest( 'SHA-1', msg ); | |
return [ ...new Uint8Array( buf ) ].map( toHex ).join(''); |
View konami.js
( () => { | |
const expect = [ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65 ]; | |
const pressed = []; | |
document.addEventListener( 'keyup', e => { | |
pressed.push( e.keyCode ); | |
for ( let i = 0; i < pressed.length; ++i ) { | |
if ( pressed[ i ] !== expect[ i ] ) { | |
pressed.length = 0; |
View example.js
'#ddd'.darker // '#a0a0a0' | |
'#ddd'.lighter // '#f0f0f0' | |
'#ddd'.darker.darker // '#808080' |
View has-dynamic-import.js
function hasDynamicImport() { | |
try { | |
const f = new Function( 'x', 'return import("foo")' ); | |
return true; | |
} catch ( err ) { | |
if ( err instanceof SyntaxError ) { | |
return false; | |
} | |
return true; | |
} |
View tinyquery.js
function $( selector, ctx = document ) { | |
if ( !( this instanceof $ ) ) { | |
return new $( selector, ctx ); | |
} | |
return this.push( ...ctx.querySelectorAll( selector ) ); | |
} | |
$.prototype = { | |
length: 0, |
NewerOlder