Skip to content

Instantly share code, notes, and snippets.

View brianonn's full-sized avatar

Brian Onn brianonn

  • Vancouver, Canada
View GitHub Profile
@brianonn
brianonn / :home:brian:t.sh
Last active July 4, 2019 16:57
Create an OSX Mojave ISO from the downloaded (full install) Install Mojave.app
#!/usr/bin/env bash
BuildTmpDir="$HOME/tmp"
hdiutil info | \
awk target="${BuildTmpDir}/MojaveBase.cdr.dmg" '
/image-path/ {
path=$3$4$5$6$7$8$9
start=1
next
@brianonn
brianonn / ci_detect.awk
Created June 10, 2019 04:07
awk script to detect the CI/CD environment
#!/usr/bin/awk -f
function usage() {
print "Usage: ci_detect [ detect | get envvar | dump ]"
exit -1
}
function dumpargs() {
printf "ARGC = %d\n", ARGC
for (i = 0; i < ARGC ; ++i) {
@brianonn
brianonn / 00_timestables_test.txt
Last active June 10, 2019 03:36
test print out times tables in golang and erlang
00_timestables_test
This is a test gist to try out times tables in golang and erlang
@brianonn
brianonn / entropy.py
Created May 5, 2019 09:09
Calculates the Shannon entropy of a string
import math
def entropy(string):
"Calculates the Shannon entropy of a string"
# get probability of chars in string
prob = [ float(string.count(c)) / len(string) for c in dict.fromkeys(list(string)) ]
# calculate the entropy
entropy = - sum([ p * math.log(p) / math.log(2.0) for p in prob ])
@brianonn
brianonn / cf-nop-worker.js
Created April 25, 2019 22:04
NOP Cloudflare Worker
addEventListener('fetch', event => {
event.respondWith(bulkRedirects(event.request));
});
async function bulkRedirects(request) {
// this does nothing but return what you asked for
return fetch(request);
}
@brianonn
brianonn / new_git_repo.md
Created November 24, 2018 05:09
new git repo
touch README.md
git init
git add README.md
git commit -m "first commit"

## push to remote
# the remote repository must already exist 
git remote add origin https://github.com/brianonn/newrepo.git
git push -u origin master
@brianonn
brianonn / Vagrantfile
Created November 4, 2018 01:20
vagrant with ansible
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cpus", "1"]
vb.customize ["modifyvm", :id, "--memory", "768"]
vb.name = "novoansible"
@brianonn
brianonn / create_eth_wallet.py
Last active October 30, 2018 23:58
make an ethereum address
#!/usr/bin/env python3
import os
import gnupg
from pywallet import wallet
# OS X hack fixed in a newer release of gnupg
gnupg._parsers.Verify.TRUST_LEVELS["ENCRYPTION_COMPLIANCE_MODE"] = 23
seed=wallet.generate_mnemonic()
@brianonn
brianonn / gist:66d7cb476f85d978a620461729925f29
Created July 30, 2018 16:33 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@brianonn
brianonn / keybase.md
Created June 24, 2018 08:40
keybase.md

Keybase proof

I hereby claim:

  • I am brianonn on github.
  • I am brianonn (https://keybase.io/brianonn) on keybase.
  • I have a public key ASAAUGO9rSvZRo6AoFeFjpB4IOt1FrftRqeEqn42O9b2kAo

To claim this, I am signing this object: