Skip to content

Instantly share code, notes, and snippets.

View jhnns's full-sized avatar
🧀
When in doubt add cheese!

Johannes Ewald jhnns

🧀
When in doubt add cheese!
View GitHub Profile
@jhnns
jhnns / node-function-wrapper.js
Last active October 23, 2018 04:04
Node function wrapper
const module = {
exports: {}
};
const require = makeRequireFunction();
const filename = "...";
const dirname = "...";
(function (exports, require, module, __filename, __dirname) {
/* YOUR CODE */
})(module.exports, require, module, filename, dirname);
@jhnns
jhnns / webpack-runtime-example.js
Last active September 1, 2018 07:00
Webpack module runtime example
(function(modules) {
// This is the module runtime.
// It's only included once per compilation.
// Other chunks share the same runtime.
var installedModules = {};
// The require function
function __webpack_require__(moduleId) {
...
}
...
@jhnns
jhnns / shadow-dom-example.js
Created August 19, 2018 18:14
shadow-dom-example
customElements.define("my-bubble", class extends HTMLElement {
constructor() {
super();
const template = document.getElementById("my-element-template").content;
const shadowRoot = this.attachShadow({mode: "open"});
shadowRoot.appendChild(template.cloneNode(true));
}
});
@jhnns
jhnns / custom-element-example.js
Last active August 19, 2018 18:08
custom-element-example
customElements.define("my-bubble", class extends HTMLElement {
constructor() {
super();
const template = document.getElementById("my-element-template").content;
const color = this.getAttribute("background") || "white";
template.querySelector(".bubble").style.background = color;
}
});
@jhnns
jhnns / template-example.html
Created August 19, 2018 17:46
Template element example
...
<template id="my-element-template">
<style>
.bubble {
border: .4rem solid black;
border-radius: 2rem;
margin: 1rem;
padding: 1rem .5rem;
cursor: pointer;
font-size: 20px;
@jhnns
jhnns / index.json
Last active April 11, 2018 14:02
The most used JavaScript libraries according to the HTTP archive based on the 2017-5-15 crawl (https://bigquery.cloud.google.com/table/httparchive:scratchspace.2017_05_15_js_libs). The `popularId` property relates to [this list](https://gist.github.com/jhnns/94188ba0904a82bbd0491bb21b041ce8)
[
{
"name": "jQuery",
"count": 394157,
"type": "dom-library",
"onGitHub": true,
"popularId": "jquery/jquery"
},
{
"name": "jQuery UI",
@jhnns
jhnns / index.json
Last active April 6, 2018 01:19
JavaScript library types.
[
{
"name": "web-framework",
"description": "Transforms a given application state into an HTML or DOM representation. Additionally, it is also often concerned with request routing, data fetching and persistence, change propagation, input validation, user session management and build optimizations."
},
{
"name": "testing-framework",
"description": "Provides a CLI and an API to run software tests and report results."
},
{
@jhnns
jhnns / bundle.js
Created November 30, 2016 22:13
Simple webpack 2 bundle (containing ES2015 modules)
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
@jhnns
jhnns / index.json
Last active May 31, 2017 15:39
Github stars history of Redux. Compiled with https://github.com/jhnns/popular-javascript-projects
[
"2015-05-30T00:12:13Z",
"2015-05-30T02:40:26Z",
"2015-05-30T08:24:06Z",
"2015-05-30T10:05:08Z",
"2015-05-30T10:33:28Z",
"2015-05-30T15:12:24Z",
"2015-05-30T17:04:57Z",
"2015-05-30T20:20:12Z",
"2015-05-30T21:58:50Z",
@jhnns
jhnns / index.json
Last active May 31, 2017 15:38
Github stars history of React. Capped at 40.000 entries due to API restrictions. Compiled with https://github.com/jhnns/popular-javascript-projects
This file has been truncated, but you can view the full file.
[
"2013-05-29T20:59:49Z",
"2013-05-29T21:18:36Z",
"2013-05-29T21:19:34Z",
"2013-05-29T21:20:23Z",
"2013-05-29T21:20:24Z",
"2013-05-29T21:20:24Z",
"2013-05-29T21:20:33Z",
"2013-05-29T21:20:55Z",
"2013-05-29T21:22:29Z",