Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Nienaber rjnienaber

View GitHub Profile
@rjnienaber
rjnienaber / exams.go
Last active Jul 25, 2021
repository pattern in Go
View exams.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"
View 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",
View false_positive.sh
#!/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 Jan 8, 2020
hotsapi setup
View setup.sh
#!/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 Dec 9, 2019
Example wait for script
View wait_for.sh
#!/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 Jul 25, 2019
pick random user from support slack channel
View example.coffee
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 / install.sh
Created Sep 6, 2018
Compile ImageMagick with WEBP and HEIC support on Ubuntu 16.04
View install.sh
# $ 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 / stdout
Created Nov 20, 2017
artillery with regex capture
View stdout
$ 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 Nov 14, 2017
Simple example of flattening an array in python3
View py3_flatten.py
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
@rjnienaber
rjnienaber / Dockerfile
Created Oct 2, 2017
PHP 5.5 on Alpine Linux
View Dockerfile
# base for this file taken from here: https://github.com/GitHub30/php/blob/5.5/5.5/alpine/Dockerfile
FROM alpine:3.6
ENV BASE_LINUX alpine
RUN apk add --no-cache --virtual .persistent-deps \
ca-certificates \
curl \
tar \
xz \
apache2 \