Skip to content

Instantly share code, notes, and snippets.

View rjnienaber's full-sized avatar

Richard Nienaber rjnienaber

View GitHub Profile
@rjnienaber
rjnienaber / exams.go
Last active April 15, 2024 17:36
repository pattern in Go
package controllers
import (
"fmt"
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"github.com/rjnienaber/server-sent-events/internal/errorcodes"
"github.com/rjnienaber/server-sent-events/internal/repositories"
@rjnienaber
rjnienaber / orgchartBuilder.py
Created February 18, 2011 06:03
Script to build an organizational chart from Active Directory
'''
Copyright (c) 2011, Richard Nienaber
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
The name of 'Richard Nienaber' may not be used to endorse or promote products derived from this software without specific prior written permission.
@rjnienaber
rjnienaber / install.sh
Created September 6, 2018 10:29
Compile ImageMagick with WEBP and HEIC support on Ubuntu 16.04
# $ lsb_release -a
# No LSB modules are available.
# Distributor ID: Ubuntu
# Description: Ubuntu 16.04.5 LTS
# Release: 16.04
# Codename: xenial
# $ uname -a
# Linux xps 4.4.0-134-generic #160-Ubuntu SMP Wed Aug 15 14:58:00 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
@rjnienaber
rjnienaber / resume.json
Created May 30, 2021 14:43
resume.json
{
"basics": {
"name": "Richard Nienaber",
"label": "Senior Software Engineer at vTail",
"email": "rjnienaber@gmail.com",
"phone": "+44 785 7817 078",
"summary": "A versatile developer with 16+ years of experience across several industries, including finance and healthcare. An experienced remote worker who has been able to effectively engage with developers spread out across multiple timezones.",
"location": {
"countryCode": "GB",
"address": "Christchurch, UK",
#!/usr/bin/env bash
docker build -t snyk_test - << END
FROM alpine:3.9
RUN apk update
RUN apk upgrade
RUN apk add jq
RUN cat /etc/os-release | grep VERSION && jq --version
@rjnienaber
rjnienaber / setup.sh
Last active January 8, 2020 00:26
hotsapi setup
#!/usr/bin/env bash
# bring up mysql service
docker-compose up -d mysql
while ! nc -z localhost 3306; do
sleep 0.1 # wait for 1/10 of the second before check again
done
# install composer dependencies locally because we are using local files instead of content dir from the container
@rjnienaber
rjnienaber / wait_for.sh
Last active December 9, 2019 10:50
Example wait for script
#!/usr/bin/env bash
STOP_TIME=`date -d "now + 30 seconds" +%s`
# loop until we get a connection
until nc -z localhost 3306
do
# if current time is > STOP_TIME, timeout has been exceeded so exit
if [[ `date +%s` -gt $STOP_TIME ]]; then
echo Timed out waiting for connection
exit 1
@rjnienaber
rjnienaber / example.coffee
Last active July 25, 2019 17:45
pick random user from support slack channel
module.exports = (robot) ->
robot.respond /get help/i, (res) ->
# get channel list from slack, might require some extra filtering if there's lot of them
robot.http("https://slack.com/api/channels.list?token=#{process.env.HUBOT_SLACK_TOKEN}")
.header('Accept', 'application/json')
.get() (err, response, body) ->
channels = JSON.parse(body).channels
supportChannelMembers = channels.filter((c) => c.name == 'support')[0].members
# filter users by channel and status
@rjnienaber
rjnienaber / stdout
Created November 20, 2017 20:32
artillery with regex capture
$ DEBUG=http ./node_modules/.bin/artillery run test.yml
Started phase 0, duration: 1s @ 20:31:32(+0000) 2017-11-20
⠦ http request: {
"url": "https://perfa.pamperedchef.com/",
"method": "GET",
"headers": {
"user-agent": "Artillery (https://artillery.io)"
}
} +0ms
@rjnienaber
rjnienaber / py3_flatten.py
Created November 14, 2017 00:29
Simple example of flattening an array in python3
def _flatten(values):
"""Recursively flattens a list using yield from"""
for v in values:
if (isinstance(v, list)):
yield from _flatten(v) # https://www.python.org/dev/peps/pep-0380/
else:
yield v
def flattened_list(values):
"""Recursively flattens a list. If the passed in argument is not a list, an