Skip to content

Instantly share code, notes, and snippets.

View VandeurenGlenn's full-sized avatar
💭
I may write messy code.

Glenn Vandeuren VandeurenGlenn

💭
I may write messy code.
View GitHub Profile
@VandeurenGlenn
VandeurenGlenn / index.html
Created September 6, 2017 18:55
es-import support
<html>
<head>
<script type="module">
window.imports = true;
import './app-shell-es.js';
</script>
<script src="app-shell.js" nomodule></script>
</head>
</html>
@VandeurenGlenn
VandeurenGlenn / base64-buffer-ext
Created August 1, 2017 23:35
Create base64 buffer and get extension
const image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABH0lEQVRYhWN0jUr5zzCAgGkgLWdgYGBgoUTzrqWzKXYA44iPglEHjDpg1AGjDhh1wIA7gKLaEBewNjFkCPf1YPj05StDTfckrGpignwZgj1daRMCAe7ODKqK8gysLNj9Z6qvw+BmZ8Wwafd+2jigtLWH4dL1WzjlzQ30GH7/+cOw69Ax2kQBNmCko8VQkp7AcOLcJQZJMRGGT5+/Mjx98ZJ+ifDclWsMUbllDJPmL2FgYmJi+PXrFwMDwwDlgn///sHZA+KApy9eMQgK8DNwcrAPjANOXrjEwMHOxhDh58XArKxr1EBtCzorixgMdTQZJMVEGXTUVRn2HDnOYKSjxdBbW8ogLSHOsH7HHgY+Hh6GYC/X0VbxqANGHTDwDgAA+4tGGj9PrTsAAAAASUVORK5CYII='
const regex = /^data:.+\/(.+);base64,(.*)$/;
const matches = image.match(regex);
const extension = matches[1];
const data = matches[2];
const buffer = new Buffer(data, 'base64'); // write, stream, something ...
@VandeurenGlenn
VandeurenGlenn / get-npm-package-version
Created July 11, 2017 12:53 — forked from DarrenN/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@VandeurenGlenn
VandeurenGlenn / requestIdleCallback.js
Last active April 13, 2016 21:42 — forked from paullewis/requestIdleCallback.js
Shims rIC in case a browser doesn't support it.
/*!
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@VandeurenGlenn
VandeurenGlenn / auto-deploy.md
Created February 9, 2016 22:00 — forked from domenic/0-github-actions.md
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with Travis

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

Create a compile script

You want a script that does a local compile to e.g. an out/ directory. Let's call this compile.sh for our purposes, but for your project it might be npm build or gulp make-docs or anything similar.

The out/ directory should contain everything you want deployed to gh-pages. That almost always includes an index.html.

@VandeurenGlenn
VandeurenGlenn / import.js
Last active January 29, 2016 17:07
import dynamically
function import(href, options) {
var link = document.createElement('link');
var target = options.target ? options.target : document.head;
if (options.async) {
link.setAttribute('async', '');
}
link.rel = 'import';
link.href = href;
target.appendChild(link);
}
@VandeurenGlenn
VandeurenGlenn / script.js
Created January 17, 2016 21:59
uppercaseFirstLetter
// uppercase the first letter
String.prototype.firstToUpperCase = function() {
return this.charAt(0).toUpperCase() + this.substr(1);
}
@VandeurenGlenn
VandeurenGlenn / app.js
Created December 26, 2015 13:38
webcomponents feature detection
(function(document) {
'use strict';
// Feature detection
// Check if Web Components are supported
var webComponentsSupported = ('registerElement' in document
&& 'import' in document.createElement('link')
&& 'content' in document.createElement('template'));
// Load Web Components when not supported
if (!webComponentsSupported) {
@VandeurenGlenn
VandeurenGlenn / README.md
Created November 21, 2015 22:00 — forked from mbostock/.block
Twitter SVG Logo

How to install Node.js on Chrome Os.

Prerequisites:

  • Chrome Os running in Developer Mode.
  • crouton (Chromium OS Universal Chroot Environment).

When not in Developer Mode check the official chromium poking-around-your-chrome-os-device page.

Installing

Open a command prompt