Skip to content

Instantly share code, notes, and snippets.


John Ellis deckerego

View GitHub Profile
deckerego / tokenCount.js
Created Sep 3, 2018
Count token frequency (word count) for a string in JavaScript
View tokenCount.js
var testString = "cat you cat are a cat who is a cat nope not a cat";
var tokenized = testString.split(" ");
var tokenFreq = tokenized.reduce((acc, val) => { acc[val] ? acc[val]++ : acc[val] = 1; return acc; }, {});
Object.entries(tokenFreq).forEach(entry => console.log(entry[0], ": ", entry[1]));
deckerego / JSTest.swift
Created Jun 14, 2018
Example of executing JavaScript in iOS using Swift
View JSTest.swift
let context = JSContext()!
let myNumber = 12
context.setObject(myNumber, forKeyedSubscript: "myNumber" as NSString)
let result = context.evaluateScript("myNumber + 20;")
print("JavaScript eval: \(result!.toInt32())")
deckerego /
Created May 29, 2018
Upgrade Node.JS on MacOS
node --version
npm install -g n
npm cache clean -f
sudo n stable
npm update -g
deckerego /
Created Mar 29, 2018
Update & package a Helm chart
helm dependency update
helm package -d "$HELM_CHART_DIR" .
helm repo index "$HELM_CHART_DIR"
deckerego /
Created Mar 28, 2018
Clean up local Docker images
docker system prune --all --volumes
deckerego /
Created Mar 18, 2018
Generate a wildcard SSL certificate from Let's Encrypt
mkdir -p log lib etc
sudo docker run -it --rm --name certbot -v $PWD/etc:/etc/letsencrypt -v $PWD/lib:/var/lib/letsencrypt -v $PWD/log:/var/log/letsencrypt certbot/certbot certonly --debug --manual --preferred-challenges dns --server
deckerego / display-off.conf
Created Feb 9, 2018
Turn off the console monitor when Ubuntu starts
View display-off.conf
start on startup
exec /usr/sbin/vbetool dpms off
deckerego / landscape.cfg
Last active Dec 21, 2017
ArchRetro MAME Config Examples
View landscape.cfg
video_allow_rotate = "true"
video_rotation = "3"
aspect_ratio_index = "19"
video_aspect_ratio_auto = false
video_aspect_ratio = .75
deckerego / Dockerfile
Created Dec 5, 2017
A test Docker container with interactive output
View Dockerfile
FROM ubuntu:latest
RUN apt-get --assume-yes update
RUN apt-get --assume-yes install iputils-ping net-tools netcat bash
ENTRYPOINT ["ping", "localhost"]
deckerego /
Created Oct 19, 2017
Sleep while waiting for a TCP port to open, then execute a command
while [[ $RUNNING -ne 0 ]]; do
echo "Waiting for $HOST:$PORT..."
sleep 3
nc -z "$HOST" "$PORT"
You can’t perform that action at this time.