Skip to content

Instantly share code, notes, and snippets.

View jaandrle's full-sized avatar
🚀
Exploring

Jan Andrle jaandrle

🚀
Exploring
View GitHub Profile
@jaandrle
jaandrle / gist:8ce7f40202fb59b96f429ee15ea1b975
Created September 10, 2018 07:59 — forked from juandopazo/gist:2901426
Privates and WeakMaps
// Based on a gist by @rwaldron
// https://gist.github.com/2897761
function privatize() {
var map = new WeakMap();
return function private(obj) {
var data = map.get(obj);
if (!data) {
map.set(obj, data = {});
}
@jaandrle
jaandrle / gist:a69323d8aee92b9083f28d5da28318d2
Created October 17, 2020 18:59 — forked from metaskills/gist:6414713
Jekyll tasks/post to help create a new post.
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Usage: provide a title argument."
exit -1
else
title="$@"
fi
d=$(date +"%Y-%m-%d")
@jaandrle
jaandrle / Module_compile.js
Created June 14, 2023 06:59 — forked from ghaiklor/Module_compile.js
Module.prototype._compile() sources
// Run the file contents in the correct scope or sandbox. Expose
// the correct helper variables (require, module, exports) to
// the file.
// Returns exception, if any.
Module.prototype._compile = function(content, filename) {
// Remove shebang
var contLen = content.length;
if (contLen >= 2) {
if (content.charCodeAt(0) === 35/*#*/ &&
content.charCodeAt(1) === 33/*!*/) {