Skip to content

Instantly share code, notes, and snippets.

View wwerner's full-sized avatar

Wolfgang Werner wwerner

View GitHub Profile
#! /bin/echo Usage:.
#
# getopts_long -- POSIX shell getopts with GNU-style long option support
#
# Copyright 2005-2009 Stephane Chazelas <stephane_chazelas@yahoo.fr>
#
# Permission to use, copy, modify, distribute, and sell this software and
# its documentation for any purpose is hereby granted without fee, provided
# that the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
@wwerner
wwerner / Dockerfile.go.build
Last active March 27, 2024 12:12
Example multi stage docker file for go builds
FROM golang:1.11.2 as build-image
WORKDIR /go/src
RUN go get -d -v golang.org/x/net/html
COPY app.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app app.go
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=build-image /go/src/app .
const CFG = require('../codecept.conf.js').config.myConfig
const MailSlurpClient = require('mailslurp-client') // https://www.npmjs.com/package/mailslurp-client
const emailApi = new MailSlurpClient.InboxcontrollerApi()
var assert = require('assert')
class EmailHelper extends Helper { // eslint-disable-line no-undef
async setupMailbox () {
var data =
await emailApi.createRandomInboxUsingPOST(CFG.emailApiKey)
.catch(err => { console.log(err); assert.fail(err) })
@wwerner
wwerner / restore-heroku-db-dump.locally.txt
Last active June 20, 2018 10:35 — forked from kagemusha/gist:1569836
Dump Heroku Postgres DB and load locally into postgres
Get the Heroku db as detailed here:
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup
$ heroku pg:backups:capture # outputs backup_num in the last line
$ heroku pg:backups:url <backup_num> #=> backup_url
$ curl -o /tmp/latest.dump <backup_url>
Then locally do:
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb /tmp/latest.dump
@wwerner
wwerner / Dockerfile
Last active December 22, 2023 10:48
Enable heroku ps:exec in docker containers
FROM openjdk:8-jdk-alpine
VOLUME /tmp
# see https://devcenter.heroku.com/articles/exec#enabling-docker-support
RUN apk add --no-cache curl bash openssh python
ADD src/main/docker/heroku-exec.sh /app/.profile.d/heroku-exec.sh
RUN chmod a+x /app/.profile.d/heroku-exec.sh
ADD src/main/docker/sh-wrapper.sh /bin/sh-wrapper.sh
RUN chmod a+x /bin/sh-wrapper.sh
@wwerner
wwerner / docker-cleanup.sh
Created December 12, 2017 11:46
Docker: Stop all containers, remove all containers and images
#!/bin/bash
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
@wwerner
wwerner / db.changelog-master.xml
Last active November 20, 2022 09:28
Spring Security DB model w/ ACLs & OAuth2 as Liquibase Changeset. Works at least on H2 & Postgres.
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"
objectQuotingStrategy="QUOTE_ALL_OBJECTS">
<changeSet id="1" author="wwerner">
<comment>Spring Security Authentication - Users, Authorities and ACLs</comment>
@wwerner
wwerner / heroku-db-url-to-spring-boot.sh
Last active April 29, 2021 07:26
Parse Heroku DB URL into Spring Boot Datasource Environment Variables
# Two possibilities to parse a Postgres DB URL from heroku into environment variables
# that Spring Boot understands.
# You would need that, if you do not build on heroku but push docker images
# from another source
# Does not need bash. Works on alpine linux / busybox. Tested with openjdk:8-jdk-alpine base image.
export DATABASE_URL=postgres://user:password@host:port/database
# Naive way, would break with [@:/] in username or password.
DB_TYPE=$(echo $DATABASE_URL | awk -F'[:@/]' '{print $1}')"ql"

Keybase proof

I hereby claim:

  • I am wwerner on github.
  • I am wgw (https://keybase.io/wgw) on keybase.
  • I have a public key ASCGLdmzXqy2Ax5008dkCKvo5Tp3QJYbMjYH2znhErRhyAo

To claim this, I am signing this object:

@wwerner
wwerner / reading-list.adoc
Last active May 10, 2022 18:41
Reading list for young developers
Table of Contents

The Pragmatic Programmer

Straight from the programming trenches, The Pragmatic Programmer: From Journeyman to Master cuts through the increasing specialization and technicalities of modern software development to examine the core process—what do you do, as an individual and as a team, if you want to