Skip to content

Instantly share code, notes, and snippets.

View dennissterzenbach's full-sized avatar

Dennis Sterzenbach dennissterzenbach

View GitHub Profile
@dennissterzenbach
dennissterzenbach / yaml-env-vars-groups.rb
Created May 24, 2021 15:02 — forked from SteveBenner/yaml-env-vars-groups.rb
Define Environment variables in your shell using a YAML config file
#!/usr/bin/env ruby
#
# This bit of code lets you define Environment variables in your shell via a YAML file.
# It works by composing Bash commands from the parsed data, meant to be executed within
# a Bash environment, which will export the variables just as in a regular Bash profile.
# This is accomplished by executing this script via the Bash substitution syntax $(...)
# which returns the output of evaluating whatever is inside the parenthesis, which in
# the case of this script would be appropriate 'export' commands that are run by Bash.
#
# This version is designed to parse aliases organized under named groups in the YAML
@dennissterzenbach
dennissterzenbach / parse_yaml.sh
Created May 24, 2021 15:02 — forked from pkuczynski/parse_yaml.sh
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@dennissterzenbach
dennissterzenbach / crypto-aes-256-gcm-demo.js
Created May 21, 2020 22:45 — forked from rjz/crypto-aes-256-gcm-demo.js
example using node.js crypto API with aes-256-gcm
const buffer = require('buffer');
const crypto = require('crypto');
// Demo implementation of using `aes-256-gcm` with node.js's `crypto` lib.
const aes256gcm = (key) => {
const ALGO = 'aes-256-gcm';
// encrypt returns base64-encoded ciphertext
const encrypt = (str) => {
// Hint: the `iv` should be unique (but not necessarily random).
@dennissterzenbach
dennissterzenbach / Instructions.md
Created April 22, 2020 08:07 — forked from pgilad/Instructions.md
Generate SSL Certificate for use with Webpack Dev Server (OSX)

Generate private key

$ openssl genrsa -out private.key 4096

Generate a Certificate Signing Request

openssl req -new -sha256 \
@dennissterzenbach
dennissterzenbach / dnsupdate.sh
Created April 12, 2020 19:16 — forked from TonyFNZ/dnsupdate.sh
Script to update Route53 with the current public IP of an instance
#!/bin/bash
hosted_zone_id="<your Route53 hosted zone id>"
domain_name="<your domain name>"
# Abort script on any errors
set -e
# Get new IP address
ip_address=`curl http://169.254.169.254/latest/meta-data/public-ipv4`
@dennissterzenbach
dennissterzenbach / app-perf.md
Created October 18, 2017 08:07 — forked from larahogan/app-perf.md
Native app performance metrics

Native app performance metrics

This is a draft list of what we're thinking about measuring in Etsy's native apps.

Currently we're looking at how to measure these things with Espresso and Kif (or if each metric is even possible to measure in an automated way). We'd like to build internal dashboards and alerts around regressions in these metrics using automated tests. In the future, we'll want to measure most of these things with RUM too.

Overall app metrics

  • App launch time - how long does it take between tapping the icon and being able to interact with the app?
  • Time to complete critical flows - using automated testing, how long does it take a user to finish the checkout flow, etc.?
  • Battery usage, including radio usage and GPS usage
  • Peak memory allocation
@dennissterzenbach
dennissterzenbach / isES6ClassBased.js
Created August 29, 2017 10:42
check if given argument is ES6 class or ES5 function based class-like
// we can determine whether a given
// function based implementation of a "class" has "writable" attribute set to true.
// ES6 class based implementation has "writable" attribute set to false.
//
// Given any object: it does not matter if it was made from a function or a class,
// there always is the constructor and based on this we get to the same results
// like testing on the function/class itself.
//
// So simply give the isClassBasedFunction any instance or function/class and
// it will tell you if it was made from a ES6 class or not.
@dennissterzenbach
dennissterzenbach / chrome_snippet_gui_export_import_2016.js
Created August 15, 2017 10:56 — forked from soundyogi/2018_chrome_snippet_gui_import_export.js
A snippet to export and import your chrome snippets
void function(){
"use strict"
/*
* Manage and Import / Export snippets from chrome (2016)
* hacked together by: http://github.com/soundyogi
* inspired by: https://github.com/bgrins/devtools-snippets/blob/master/import-export/chrome/devtools_import_export.js
* ALPHA / SILLY SIDE PROJECT
*/
@dennissterzenbach
dennissterzenbach / ErrorHandler.js
Last active June 13, 2018 20:28
This higher order function logic wraps a given function with error handling to make it exception fail safe
/**
* Error Handler dummy
* used to provide a higher order function which allows exception fail safe calling
* and provides some error handling along with.
*
* @author Dennis Sterzenbach <dennis.sterzenbach@gmail.com>
*/
function ErrorHandler(errorHandlerFunctions) {
this.handlers = [];
@dennissterzenbach
dennissterzenbach / mark-angular-translate-translation-keys-with-number-from-file.css
Last active July 21, 2017 05:44
Experiment: show order of translation keys with angular-translate without changing all the application or necessity to implement Angular-Decorating logic
[data-translate]::after {
content: attr(data-key-num) " ";
display: block;
position: absolute;
right: 0;
top: -8px;
font-size: 15px;
font-family: verdana;
background: #aaa;
color: #000;