Skip to content

Instantly share code, notes, and snippets.

John Ellis deckerego

Block or report user

Report or block deckerego

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@deckerego
deckerego / findport.sh
Created Feb 21, 2019
Finding an unused port, starting at 1080
View findport.sh
netstat -aln | awk '
$6 == "LISTEN" {
if ($4 ~ "[.:][0-9]+$") {
len=split($4, a, /[:.]/);
port = a[len];
p[port] = 1
}
}
END {
for (i = 1080; i < 65000 && p[i]; i++){};
@deckerego
deckerego / slack.js
Created Sep 14, 2018
Send a Message to Slack
View slack.js
'use strict';
const https = require('https');
class Slack {
constructor(slackPath) {
this._options = {
hostname: "hooks.slack.com",
method: "POST",
path: slackPath,
@deckerego
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
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
deckerego / node_upgrade.sh
Created May 29, 2018
Upgrade Node.JS on MacOS
View node_upgrade.sh
#!/bin/sh
node --version
npm install -g n
npm cache clean -f
sudo n stable
npm update -g
@deckerego
deckerego / helm_package.sh
Created Mar 29, 2018
Update & package a Helm chart
View helm_package.sh
#!/bin/sh
HELM_CHART_DIR="../../helm_charts"
helm dependency update
helm package -d "$HELM_CHART_DIR" .
helm repo index "$HELM_CHART_DIR"
@deckerego
deckerego / docker_prune.sh
Created Mar 28, 2018
Clean up local Docker images
View docker_prune.sh
#!/bin/sh
docker system prune --all --volumes
@deckerego
deckerego / gencert.sh
Created Mar 18, 2018
Generate a wildcard SSL certificate from Let's Encrypt
View gencert.sh
#!/bin/sh
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 https://acme-v02.api.letsencrypt.org/directory
@deckerego
deckerego / display-off.conf
Created Feb 9, 2018
Turn off the console monitor when Ubuntu starts
View display-off.conf
start on startup
task
exec /usr/sbin/vbetool dpms off
@deckerego
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
You can’t perform that action at this time.