Skip to content

Instantly share code, notes, and snippets.

View jmshal's full-sized avatar

Jacob Marshall jmshal

  • New Zealand
View GitHub Profile
@jmshal
jmshal / index.js
Created October 6, 2016 09:54
npm i --save gist:53c856c340000421fd7d9fc794b23086
'use strict';
const TEST_OVERFLOW = /(auto|scroll)/;
/**
* Scrolls to an element by scrolling it's parent scroll container.
*
* @param {Element} element The element to scroll to
* @param {boolean} [center] Whether to center the element within it's scroll container
*/
{
"1": "Bulbasaur",
"2": "Ivysaur",
"3": "Venusaur",
"4": "Charmander",
"5": "Charmeleon",
"6": "Charizard",
"7": "Squirtle",
"8": "Wartortle",
"9": "Blastoise",
@jmshal
jmshal / swarm-with-docker-machine.sh
Created February 11, 2016 22:21 — forked from nishanttotla/swarm-with-docker-machine.sh
A bash script to set up a simple Docker Swarm cluster using Docker Machine
################################## INSTRUCTIONS ##################################
# 1. Make sure docker-machine is installed on your machine #
# 2. Download the file #
# 3. Run using $ . swarm-with-docker-machine.sh so that DOCKER_HOST is exported #
##################################################################################
# Clean any existing machines
yes | docker-machine rm manager
yes | docker-machine rm agent1
yes | docker-machine rm agent2
/**
* JS scoping, and this property resolutions rules in ES7/ES8.
*
* Quiz: x is gone, and x is everywhere!
*
* Help find Xs! What's the output?
*/
let x = 1;
@jmshal
jmshal / coverage.js
Created February 26, 2018 21:41 — forked from ebidel/coverage.js
CSS/JS code coverage during lifecycle of page load
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*
* Shows how to use Puppeeteer's code coverage API to measure CSS/JS coverage across
* different points of time during loading. Great for determining if a lazy loading strategy
* is paying off or working correctly.
*
* Install:
* npm i puppeteer chalk cli-table
@jmshal
jmshal / atob.js
Last active April 27, 2024 04:12
Node.js ponyfill for atob and btoa encoding functions
module.exports = function atob(a) {
return new Buffer(a, 'base64').toString('binary');
};
@jmshal
jmshal / create-multi-host-swarm-digitalocean.sh
Last active March 16, 2023 13:22
Setup a Docker Swarm multi-host cluster on DigitalOcean
docker-machine create \
--driver=digitalocean \
--digitalocean-access-token=$DO_TOKEN \
--digitalocean-size=512mb \
--digitalocean-region=nyc3 \
--digitalocean-private-networking=true \
--digitalocean-image=ubuntu-15-04-x64 \
docker-swarm-kv-store
docker $(docker-machine config docker-swarm-kv-store) run -d \
@jmshal
jmshal / golang-tls.md
Created June 21, 2017 08:05 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@jmshal
jmshal / main.go
Created June 11, 2019 22:31 — forked from julz/main.go
containersched minicontainer
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
@jmshal
jmshal / main.go
Created June 29, 2017 10:25 — forked from manishtpatel/main.go
GoLang Encrypt string to base64 and vice versa using AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)