Skip to content

Instantly share code, notes, and snippets.

View henvo's full-sized avatar
💬
Hello world

Henning henvo

💬
Hello world
  • Zürich
  • 17:55 (UTC +01:00)
  • X @henvo
View GitHub Profile
@henvo
henvo / flatten.js
Created October 9, 2024 22:24
Simple flatten function in JavaScript
const flatten = (input, ary = []) => {
if (!Array.isArray(input)) { return ary.push(input) };
input.forEach((v) => flatten(v, ary));
return ary;
};
@henvo
henvo / dsl.rb
Created January 7, 2024 16:38
Simple Ruby DSL for HTML generation
# frozen_string_literal: false
# This is the class that implements the DSL.
class Interpreter
def run(&block)
# Next line calls the block in the context of the instance.
instance_eval(&block)
end
def method_missing(name, **args, &block)
@henvo
henvo / docker-factory-reset
Last active May 20, 2018 13:42
This script stops and removes all docker containers and their images
#!/bin/bash
# WARNING: This script will remove all containers and images
echo -n "Do you want to factory-reset your docker (Y/n)? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
# Stop all containers
docker stop $(docker ps -q)
# Delete all containers
docker rm $(docker ps -a -q)