Skip to content

Instantly share code, notes, and snippets.

@JasonGhent
JasonGhent / Makefile.gitlab
Created June 12, 2020 03:28
self-hosted gitlab baremetal k8s cluster with metallb [persistence mostly disabled; see L54.]
# File: ./Makefile.gitlab
# Usage: make -f Makefile.gitlab
# NOTE: Assumes Debian 9 OS
MAKEFLAGS += --silent
define K8S_METALLB_CMD
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
/* flatten an array of integers
* @param arr {Array} - An array of integers to flatten
* @return {Array} - A flattened array of integers
*/
function flatten(arr) {
return arr.reduce((res, _arr) => {
// typecast to array if not already (for next step)
// otherwise, ensure provided array is flat
_arr = Array.isArray(_arr) ? flatten(_arr) : [_arr];
@JasonGhent
JasonGhent / gist:5032d9ee1ff5a99304a917316d2a5be8
Last active October 22, 2017 02:36
pi-hole docker setup
#!/bin/bash
# Run on raspberry pi
# source: https://github.com/diginc/docker-pi-hole
IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0
IPv6_LOOKUP="$(ip -6 route get 2001:4860:4860::8888 | awk '{ print $10; exit }')" # May not work for VPN / tun0
IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP
IPv6="${IPv6:-$IPv6_LOOKUP}" # use $IPv6, if set, otherwise IP_LOOKUP
DOCKER_CONFIGS="$(pwd)" # Default of directory you run this from, update to where ever.
@JasonGhent
JasonGhent / ddwrt-openvpn-server-config-generator.sh
Last active April 4, 2017 21:01
Creates openVPN server config (and server/client keys) with routing for LAN subnet resources to VPN subnet clients [as OSX/macOS bash script]
PUBLIC_IP=$(curl -s ipecho.net/plain)
COUNTRY="US"
PROVINCE="California"
CITY="San Francisco"
ORG="Copyleft Certificate Co"
EMAIL="me@example.com"
OU="My Organizational Unit"
CN="."
CLIENT_NAME="client1"
PORT=1194
@JasonGhent
JasonGhent / Makefile
Last active November 3, 2016 14:31
Ran Signal as a NW.js OSX app for a while, but NW.js broke this for newer versions. Not a fan of the 'native' Chrome app, so it was easier to just stop using the platform entirely. If this still works, it is invoked with `make signal.app`. More info about the NW.js breakage here: https://github.com/nwjs/nw.js/issues/5295
SDK_URL=http://dl.nwjs.io/v0.14.4/nwjs-sdk-v0.14.4-osx-x64.zip
export SDK_URL
APP_BIN=Signal.app
export APP_BIN
PROJECT=Signal-Desktop
export PROJECT
GIT_URL=https://github.com/WhisperSystems/${PROJECT}.git
export GIT_URL
fetch:
# script insstalls qemu and vagrant, then uses vagrant to build a qemu-
# supported rpi kernel for dev.
# - tested with 2015-02-16-raspbian-wheezy.zip on OSX El Capitan
# Variables
IMAGE=http://downloads.raspberrypi.org/raspbian_latest
IMG_PATH="/vagrant/raspbian_latest.img"
PI_LINUX=https://github.com/raspberrypi/linux
PI_LINUX_BRANCH="rpi-4.2.y"
PI_TOOLS=https://github.com/raspberrypi/tools
@JasonGhent
JasonGhent / pi_qemu.sh
Last active March 24, 2024 14:36
OSX raspberry pi emulation via QEMU. v2 attempt @ https://gist.github.com/JasonGhent/922f38f57c8cb77b10f3
# pulled from http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/
# expanded via http://superuser.com/questions/690060/how-to-enable-network-with-a-raspberry-pi-emulated-on-qemu
# tested with 2015-02-16-raspbian-wheezy.zip on OSX Mavericks
# OSX terminal
brew install qemu
# kernel-qemu is a linux kernel compiled with ARM1176 support.
# learn more here: http://xecdesign.com/compiling-a-kernel/
curl -OL http://xecdesign.com/downloads/linux-qemu/kernel-qemu
curl -o raspbian_latest.zip -L http://downloads.raspberrypi.org/raspbian_latest
@JasonGhent
JasonGhent / index.js
Created February 25, 2015 16:30
BrowserStack job
siteshot: function (email, done) {
var oses = {'ios': [], 'Windows': [], 'OS X': [], 'other': []};
var successes = oses;
var browsers = require(process.cwd() + '/meta/browsers.js');
var settings = { url: 'http://example.com/' };
async.mapSeries(browsers, function (browser, shotDone) {
settings.browsers = [browser];
request({
url: 'http://www.browserstack.com/screenshots',
@JasonGhent
JasonGhent / index.js
Created February 25, 2015 16:28
BrowserStack snippet
$('input[name="screenshots"]').val('http://staging.storydesk.com/case-studies/pharma');
$('.sel').removeClass('sel');
//Non-windows devices
var devices = ['iPad 2 (5.0)','iPad 3rd','iPad 3rd (6.0)','iPhone 5','iPad Mini','LG Nexus 4','Google Nexus 7'];
for(var i in devices) {
$('a[device="'+devices[i]+'"]').addClass('sel');
}
//Windows OSes
@JasonGhent
JasonGhent / index.js
Created January 7, 2015 16:41
Shoddy script for finding max rectangular area under a curve, for histograms in this case.
function maxArea (original, histogram, maxArray) {
if (!histogram) {
histogram = original.slice(0);
}
maxArray = maxArray || new Array(histogram.length);
var currVal = histogram.pop();
if (currVal===0 || !histogram.length) {
maxArray[histogram.length] = currVal;