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
import React from "react"; | |
import http from "http"; | |
import fs from "fs"; | |
import { join } from "path"; | |
import express from "express"; | |
import bodyParser from "body-parser"; | |
import { default as Busboy } from "busboy"; | |
const app = express(), |
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
/** | |
* @returns Image[] | |
*/ | |
function getIncompleteImages() { | |
return Array.from( document.querySelectorAll( "img" ) ) | |
.filter( img => !img.complete || img.naturalWidth === 0 ); | |
} | |
/** | |
* Execute the given callback when all the images in the document loaded | |
* We call this function when markup with images is rendered but images are still loading |
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
#! /bin/bash | |
version=`git diff HEAD^..HEAD -- "$(git rev-parse --show-toplevel)"/package.json | grep -m 1 '^\+.*version' | sed -s 's/[^A-Z0-9\.\-]//g'` | |
if [[ ! $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(\-[A-Z]+\.[0-9]+)?$ ]]; then | |
echo -e "Skip tag: invalid version '$version'" | |
exit 1 | |
fi | |
git tag -a "v$version" -m "`git log -1 --format=%s`" | |
echo "Created a new tag, v$version" |
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 loadJs(url){ | |
return new Promise( (resolve, reject) => { | |
if (document.querySelector(`head > script[src="${src}"]`) !== null) return resolve() | |
const script = document.createElement("script") | |
script.src = url | |
script.onload = resolve | |
script.onerror = reject | |
document.head.appendChild(script) | |
}); | |
} |
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 getCookie( name ) { | |
const value = "; " + document.cookie, | |
parts = value.split( "; " + name + "=" ); | |
if ( parts.length === 2 ) { | |
return parts.pop().split( ";" ).shift(); | |
} | |
return null; | |
} |
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
/* | |
Usage: | |
<If exp={ true }> components to render </If> | |
<If exp={ false }> components not to render </If> | |
*/ | |
import React from "react"; | |
import PropTypes from "prop-types"; | |
export default class If extends React.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
function isPrivateMode() { | |
return new Promise((resolve) => { | |
const on = function(){ resolve( true ); } | |
const off = function(){ resolve(false); } | |
const testLocalStorage = function(){ | |
try { | |
if ( localStorage.length ) { | |
off(); | |
return; | |
} |
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
#!/bin/bash | |
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".*Marketplace.*\.js$") | |
if [[ "$STAGED_FILES" = "" ]]; then | |
exit 0 | |
fi | |
PASS=true |
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
/** | |
* Get round nested ternary operator | |
* | |
* <header>{ | |
* accept() | |
* .when( a == 1, <h1>Case 1</h1>) | |
* .when( a == 2, <h1>Case 2</h1>) | |
* .otherwise( <h1>Case 3</h1>) | |
* .render() | |
* }</header> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Service-worker demo</title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<script> | |
if ( "serviceWorker" in navigator ) { |
NewerOlder