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 / 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 / ex1-prototype-style.js
Created July 13, 2017 08:11 — forked from getify/ex1-prototype-style.js
OLOO (objects linked to other objects) pattern explored (with comparison to the prototype style of the same code)
function Foo(who) {
this.me = who;
}
Foo.prototype.identify = function() {
return "I am " + this.me;
};
function Bar(who) {
Foo.call(this,"Bar:" + who);
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];
#!/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