Skip to content

Instantly share code, notes, and snippets.

View ChristianWitts's full-sized avatar
🦀
Off writing HCL or YAML 🙃

Christian Witts ChristianWitts

🦀
Off writing HCL or YAML 🙃
View GitHub Profile
{
"meta": {
"theme": "elegant"
},
"basics": {
"name": "Christian Witts",
"label": "Director of DevOps @ Impact",
"picture": "",
"email": "cwitts@gmail.com",
"phone": "+27724369170",
#!/usr/bin/env bash
# Script to limit mongoDB memory usage.
# Author: TechPaste.Com
############################################
export _arg="$1"
if [ -z "$_arg" ]
then
echo "Memory to Allocate is empty"
echo "Usage: ./mongodb_memory_limiter.sh 1536"
@ChristianWitts
ChristianWitts / Dockerfile
Created November 9, 2018 06:26
Golang Scratch Builder
# This is the first stage, for building things that will be required by the
# final stage (notably the binary)
FROM golang
# Copy in just the go.mod and go.sum files, and download the dependencies. By
# doing this before copying in the other dependencies, the Docker build cache
# can skip these steps so long as neither of these two files change.
COPY go.mod go.sum ./
RUN go mod download
@ChristianWitts
ChristianWitts / dnstest.sh
Created May 29, 2018 11:35
dns testing script, can't remember the source, but some HN thread when CF went live with `1.{0.0,1.1}.1}
#!/bin/bash
#Check for required utilities
if ! which bc > /dev/null
then
echo "bc was not found. Please install bc."
exit 1
fi
if ! which dig > /dev/null
@ChristianWitts
ChristianWitts / tail-f.py
Created May 29, 2018 10:52
super naive tail -f in python
#!/usr/bin/env python3
import sys
from datetime import datetime
import time
import os
def get_timestamp():
return datetime.now().strftime("[%Y%m%d %H:%M:%S]")
#!/bin/bash
#
# Copyright(c) 2018 Asit Dhal.
# Distributed under the MIT License (http://opensource.org/licenses/MIT)
#
LIGHT_BLUE='\033[1;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color
INTERACTIVE=""
@ChristianWitts
ChristianWitts / rasterize.js
Created March 12, 2018 09:24
Generate a PDF from a URI with PhantomJS
var page = require('webpage').create(),
system = require('system'),
address, output, size;
if (system.args.length < 3 || system.args.length > 5) {
console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
console.log(' image (png/jpg output) examples: "1920px" entire page, window width 1920px');
console.log(' "800px*600px" window, clipped to 800x600');
phantom.exit(1);
@ChristianWitts
ChristianWitts / fetchkeys.js
Created February 2, 2018 06:31 — forked from voxpelli/fetchkeys.js
Check the ssh key length of specified users
// Replace this list with the result of to-run-on-org-page.js
// And remember to do an "npm install"
var users = ["voxpelli"];
var https = require('https');
var fs = require('fs');
var exec = require('child_process').exec;
var tmp = require('temporary-directory')
var cuid = require('cuid');
var chalk = require('chalk');
@ChristianWitts
ChristianWitts / colour_count.py
Created January 22, 2018 14:57
Count the number of pixels in a certain RGB range
#!/usr/bin/env python
# Install OpenCV and numpy
# $ pip install opencv-python numpy
import cv2
import numpy as np
img = cv2.imread("bgr.png")
# minimum value of brown pixel in BGR order -> burleywood
@ChristianWitts
ChristianWitts / serv.py
Created January 22, 2018 12:54
Quick simple
#!/usr/bin/env python
# $ setenforce Permissive
import SimpleHTTPServer
import SocketServer
import logging
import os
PORT = os.getenv("PORT", 8000)