Skip to content

Instantly share code, notes, and snippets.

@BeerOnBeard
BeerOnBeard / test.sh
Created March 12, 2020 15:44
MongoDB Docker Backup and Restore Test
#!/bin/bash
set -e;
mongoOne=f06668aa36714d818dfc2105e103f647;
mongoTwo=ea623889303a4e1cb25e7bf2e9b8285c;
function onExit()
{
docker kill $mongoOne;
docker kill $mongoTwo;
@BeerOnBeard
BeerOnBeard / install-kubernetes-on-buster.sh
Created January 24, 2020 15:51
Set up a single-node Kubernetes system on Debian 10 (Bustomer). Use Flannel as the network fabric. Install the Kubernetes dashboard.
#!/bin/bash
set -e;
# Set up a single-node Kubernetes system on Debian 10 (Buster).
# Use Flannel as the network fabric. Install the Kubernetes
# dashboard.
# disable swap
swapoff -a;
@BeerOnBeard
BeerOnBeard / install-docker-ce-on-elementaryos-loki.sh
Last active March 4, 2020 07:27
Install Docker CE on ElementaryOS 0.4.1 Loki
#!/bin/bash
set -e
##########################################################
# Install script for Docker-CE on ElementaryOS 0.4.1 Loki
# Had to update the repository to point to xenial instead
# of using 'lsb_release -cs' because there's no loki
# repository at download.docker.com.
##########################################################
#!/bin/bash
echo 'UPDATE PACKAGE INDEX...';
sudo apt-get update;
echo;echo;echo;echo 'INSTALL PACKAGES TO ALLOW APT TO USE A REPOSITORY OVER HTTPS...'
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common;
echo;echo;echo;echo 'ADD GPG KEYS...';
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg;
@BeerOnBeard
BeerOnBeard / makecert.sh
Created November 12, 2017 11:57
Create self-signed certs using OpenSSL
#!/bin/bash
set -o nounset;
#################################################################################
# Script to generate a private key and pfx.
# Requires the variable $FileName to be set.
# Remember to `chmod +x makecert.sh` in order to run.
# Example: FileName=myfile ./makecert.sh
# This will generate myfile.key, myfile.csr, myfile.crt, and myfile.pfx
#################################################################################
@BeerOnBeard
BeerOnBeard / HTTPS-Proxy-Localhost-Application.blob
Created September 26, 2017 13:02
FiddlerScript for HTTPS Proxy to Localhost Application
// I use this to hijack AJAX requests to subdomains of the site that rely on CORS to function. I want the host
// names to look like they are from the same host but swap out a local server for testing.
// Add this if-statement to the OnBeforeRequest method. It ignores CONNECT methods to allow HTTPS handshake.
// All other requests will be redirected to localhost over HTTP.
if (!oSession.HTTPMethodIs("CONNECT") && oSession.HostnameIs("my.public.site.com"))
{
oSession.host = "localhost:10010"
@BeerOnBeard
BeerOnBeard / NoGMailProxy.bookmarklet.js
Last active April 25, 2021 14:12
Bookmarklet to remove the proxy GMail uses to display images in img tags. It enables me to test content in emails from sites not exposed to wide Internet.
/*
* GMail's image proxy gets in the way when testing emails that are coming from testing websites that we do not expose
* to the general internet. This bookmarklet code will remove the proxy in the URI of all HTML img tags on the current
* page and update the src attribute with the non-proxy version of the content URI. All src tags that do not use the
* Google User Content proxy service will be left alone. To use this, copy the code into the URL field of a new bookmark
* in your browser. Then, when looking at an email that has images provided by the proxy, click the bookmark and the
* images should appear.
*/
javascript:(function() {
@BeerOnBeard
BeerOnBeard / DisposableViewModel.js
Created January 14, 2017 19:54
Ability to dispose subscribers from a view model that contains an observable that will be subscribed to.
/*
I have a collection of view models and I want to track a property on each of them to notify the parent.
However, if the child is removed from the array, the view model will live in memory with no hope of garbage
collection because there is still a subscriber that has a reference to it.
To solve this, I've added a .dispose() method on the view model that will iterate over the change subscriptions
on properties that I know will be subscribed to by higher view models and dispose of the subscriptions from here.
That way I don't have to track the subscriptions in the higher view model. All I have to do is call the .dispose()
method on an item if I remove it from the array.