Skip to content

Instantly share code, notes, and snippets.

View enjikaka's full-sized avatar

Jeremy Karlsson enjikaka

View GitHub Profile
function imageLoad(imageUrl) {
return new Promise((resolve, reject) => {
const image = new Image();
image.crossOrigin = 'anonymous';
image.onload = () => resolve(image);
image.onerror = err => reject(err);
image.src = imageUrl;
});
@enjikaka
enjikaka / paper-old.svg
Last active February 25, 2020 12:55
paper
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
export default class TidalWebComponent extends HTMLElement {
static css (strings) {
const text = strings.raw.join();
const sheet = new CSSStyleSheet();
sheet.replace(text);
return sheet;
}
@enjikaka
enjikaka / web.js
Created October 8, 2019 13:28
web.js from declinded PR
/**
* Converts a snake-case string to camelCase
*
* @param {string} str kebab-cased string
* @returns {string} camelCased string
*/
export function kebabToCamelCase(str) {
return str.replace(/(-)([a-z])/g, g => g[1].toUpperCase());
}
@enjikaka
enjikaka / README.md
Last active September 12, 2019 08:54

npm install --save-dev gist:8ce270954c48a4092b5dc62a0866792e

@enjikaka
enjikaka / web.js
Created September 11, 2019 20:21
Nightcore-App Web.js
class TemplateStore {
constructor (node) {
if (!(node instanceof HTMLElement)) {
throw new Error('DOM Node for template storage is not set up. Please pass in an HTMLElement to the constructor.');
}
this.parentDOMNode = node;
}
/**
'use latest';
import express from 'express';
import request from 'request';
import { fromExpress } from 'webtask-tools';
import bodyParser from 'body-parser';
const app = express();
app.use(bodyParser.json());
@enjikaka
enjikaka / test.md
Last active February 28, 2018 09:42
Timing differences between Webpack 3.9.0 and Webpack 4.0.0

Timing differences between Webpack 3.9.0 and Webpack 4.0.0

TL;DR

Webpack 3.9.0: 5.3287 minutes

Webpack 4.0.0: 3.86826667 minutes

Webpack 3.9.0

@enjikaka
enjikaka / durationToMinutes.js
Last active January 14, 2018 13:28
HTML 5.1 Duration string / dateTime to minutes
export default function durationToMinutes (durationString) {
return durationString
.match(/\d+\w/g)
.map(u => ([parseInt(u.match(/\d+/g), 10), u.split(/\d+/g)[1]]))
.map(a => {
switch (a[1]) {
case 'D': return a[0] * 1440;
case 'H': return a[0] * 60;
case 'M': return a[0];
case 'S': return a[0] / 60;
@enjikaka
enjikaka / app.mjs
Last active September 23, 2017 20:14
'use latest';
import express from 'express';
import compression from 'compression';
const app = express();
if (process.env.NODE_ENV === 'production') {
app.use(compression());
}