Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
DATABASE_URL="postgres://MyPostgresUser:MyPostgresPassword@192.168.0.1:5432/MyPostgresDB"
# `cut` is used to cut out the separators (:, @, /) that come matched with the groups.
DATABASE_USER=$(echo $DATABASE_URL | grep -oP "postgres://\K(.+?):" | cut -d: -f1)
DATABASE_PASSWORD=$(echo $DATABASE_URL | grep -oP "postgres://.*:\K(.+?)@" | cut -d@ -f1)
DATABASE_HOST=$(echo $DATABASE_URL | grep -oP "postgres://.*@\K(.+?):" | cut -d: -f1)
DATABASE_PORT=$(echo $DATABASE_URL | grep -oP "postgres://.*@.*:\K(\d+)/" | cut -d/ -f1)
@ackerleytng
ackerleytng / index.js
Created October 22, 2020 02:22
LDAP adapter for Keycloak
const ldap = require('ldapjs');
const fs = require('fs');
const axios = require("axios");
const https = require("https");
const querystring = require('querystring');
const server = ldap.createServer();
const authenticate = async (req, res, next) => {
if (req.dn.toString() !== 'cn=keycloak' ||
@superseb
superseb / rke2-commands.md
Last active May 6, 2024 09:52
RKE2 commands

RKE2 commands

Install

curl -sL https://get.rke2.io | sh
systemctl daemon-reload
systemctl start rke2-server
@pamolloy
pamolloy / README.md
Last active January 23, 2024 07:28
Ubiquiti USG configuration for Wireguard

Download the latest ugw3 package from https://github.com/Lochnair/vyatta-wireguard/releases and install it on your USG using dpkg -i wireguard-ugw3-<version>.deb.

cd /config/auth
umask 077
mkdir wireguard
cd wireguard
wg genkey > wg_private.key
wg pubkey < wg_private.key > wg_public.key
@natemurthy
natemurthy / 23Feb2017-sf-micro-meetup-demo.sh
Last active January 19, 2023 14:34
Demo of chroot and jail in FreeBSD
############################
# chroot demo #
############################
pwd # outside container
mkdir newroot
mkdir -p newroot/{bin,dev,lib,libexec,sbin}
# copy bins
@richsilv
richsilv / local-replica-set-with-oplog.md
Created February 3, 2016 16:47
Setting up a local MongoDB replica set with oplog for use with Meteor

From an appropriate location:

mkdir replica-set
mkdir -p replica-set/rs0-0 replica-set/rs0-1
mongod --port 27018 --dbpath replica-set/rs0-0 --replSet rs0 --smallfiles --oplogSize 128 &
mongod --port 27019 --dbpath replica-set/rs0-1 --replSet rs0 --smallfiles --oplogSize 128 &
mongo localhost:27018
require = function a(b, c, d) {
function e(g, h) {
if (!c[g]) {
if (!b[g]) {
var i = "function" == typeof require && require;
if (!h && i) return i(g, !0);
if (f) return f(g, !0);
var j = new Error("Cannot find module '" + g + "'");
throw j.code = "MODULE_NOT_FOUND", j
}
@NamelessCoder
NamelessCoder / install_typo3_62_ft3.sh
Last active January 13, 2017 10:00
Bash script to install TYPO3 6.2 LTS (dev) and FluidTYPO3 extensions (dev)
#!/usr/bin/env bash
# phase one: core install
# Pro tip: edit the script and use this repository instead to try out the
# codename "Awesome Ocelot" project - which should be even faster than the
# bare 6.2 core: https://github.com/NamelessCoder/TYPO3.CMS.git
# Live demo of "Awesome Ocelot" is at http://staging.namelesscoder.net
git clone https://github.com/TYPO3/TYPO3.CMS.git --depth 1