Ubuntu
google-chrome --args --disable-web-security --allow-running-insecure-content
OSX
open -a Google\ Chrome --args --disable-web-security --allow-running-insecure-content
/** | |
* Checks if the passed element is dom object or not | |
* @param element | |
* @returns {boolean} | |
*/ | |
function isDomElement(element) { | |
return element && typeof element === 'object' && 'nodeType' in element; | |
}; |
import { css } from 'styled-components'; | |
const sizes = { | |
big: 1600, | |
desktop: 1024, | |
laptop: 768, | |
tablet: 430, | |
}; | |
// taken from: https://github.com/styled-components/styled-components/blob/master/docs/tips-and-tricks.md#media-templates |
const elements = [ | |
'animate', | |
'circle', | |
'defs', | |
'ellipse', | |
'g', | |
'line', | |
'linearGradient', | |
'mask', | |
'path', |
// https://stackoverflow.com/a/26227662 | |
const singleton = Symbol(); | |
const singletonEnforcer = Symbol() | |
class SingletonClass { | |
constructor(enforcer) { | |
if(enforcer != singletonEnforcer) throw "Cannot construct singleton"; | |
} |
import indexedDB from './indexedDB' | |
if (!indexedDB) { | |
// console.log("Your browser does not support a stable version of IndexedDB. Some features will not be available.") | |
} | |
const DATABASE_NAME = 'db_name'; | |
const READ_WRITE_PERMISSION = 'readwrite'; | |
import styled from 'styled-components'; | |
const Toggle = styled.input` | |
-moz-appearance: none; | |
-webkit-appearance: none; | |
-o-appearance: none; | |
position: relative; | |
height: 20px; | |
width: 40px; | |
border-radius: 10px; |
/** | |
* | |
* @param items An array of items. | |
* @param fn A function that accepts an item from the array and returns a promise. | |
* @returns {Promise} | |
*/ | |
export default function forEachPromise(items = [], fn = Promise.resolve) { | |
return items.reduce( | |
(promise, item) => promise.then(() => fn(item)), | |
Promise.resolve() |
// Timeout Promise wrapper | |
export default function timeoutPromise(timeout, err, promise) { | |
return new Promise(function(resolve,reject) { | |
promise.then(resolve,reject); | |
setTimeout(reject.bind(null,err), timeout); | |
}); | |
} | |
/* |
export default function promiseWhen(condition, timeout = 2000) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
reject(); | |
}, timeout); | |
const loop = () => { | |
if (condition()) { | |
return resolve(); | |
} |
Ubuntu
google-chrome --args --disable-web-security --allow-running-insecure-content
OSX
open -a Google\ Chrome --args --disable-web-security --allow-running-insecure-content