Skip to content

Instantly share code, notes, and snippets.

View dennissterzenbach's full-sized avatar

Dennis Sterzenbach dennissterzenbach

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@dennissterzenbach
dennissterzenbach / convertStringToDOMNodes.js
Last active June 8, 2017 06:33
Converts a given String to DOM Nodes and adds them as children to a given parent DOM Node
let HTMLString = `<div class="wrapper">
<p>some</p>
<span>very fancy</span>
<ul>
<li>html</li>
<li>inside of</li>
<li>a simple</li>
</ul>
<p>String</p>
@dennissterzenbach
dennissterzenbach / ArrayHelpers.js
Last active May 16, 2017 07:51
A list of helpers for handling copying, clearing arrays quickly and easily.
/* Array.isArray polyfill - taken from https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray */
if (!Array.isArray) {
Array.isArray = function (arg) {
return Object.prototype.toString.call(arg) === '[object Array]'
}
}
function ArrayHelpers() {
}
@dennissterzenbach
dennissterzenbach / interview-algorithm-performance.js
Created May 16, 2017 17:27
Job Interview Question about to find an algorithm and performance for a certain situation
/**
* This are your TODOs:
*
* Given is a list of random integers inside of an array. You have to implement
* a JavaScript function which finds the first pair of entries which summ up to
* the given integer value.
*
* Example:
* - sum should be 8
* - example arrays are: a = [ 1, 2, 3, 9 ] b = [ 1, 2, 4, 4 ]
.DS_Store
node_modules/
# folders with generated artefacts
bin/
dist/
# temporarily generated or built files and folders
.tmp/
build/
# This file has been generated using '.gitattributes Generator'.
# You can generate yours at http://ihopepeace.github.io/gitattributes_generator
* text=auto
# Explicitly declare text files that should be normalized and converted
# to native line endings on checkout.
*.md text
# Declare files that should have CRLF line endings on checkout.
# EditorConfig defining and maintaining consistent coding styles between different editors and IDEs
# see http://editorconfig.org for more information
#
root = true
[**]
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
@dennissterzenbach
dennissterzenbach / cssVariablesReplacer.js
Last active May 22, 2017 06:33
simple cli tool to strip CSS variables and replace by their declared values so the resulting file becomes CSS3 cross browser compatible
/**
* Simple JavaScript CLI helper to strip out CSS Variable from your CSS
* and pipe this into a new output file which is completely cross browser
* compatible.
*
* Provided under ISC license:
*
* Copyright (c) 2017, Dennis Sterzenbach
*
* Permission to use, copy, modify, and/or distribute this software for any
#!/bin/bash
## Install docker on AWS
### See http://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
const applyTemplate = (templateElement, data) => {
const element = templateElement.content.cloneNode(true);
const treeWalker = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT, () => NodeFilter.FILTER_ACCEPT);
while(treeWalker.nextNode()) {
const node = treeWalker.currentNode;
for(let bindAttr in node.dataset) {
let isBindableAttr = (bindAttr.indexOf('bind_') == 0) ? true : false;
if(isBindableAttr) {
let dataKey = node.dataset[bindAttr];