Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jo du Plessis joduplessis

🏠
Working from home
View GitHub Profile
@joduplessis
joduplessis / index.js
Created Nov 10, 2020
Replacing the classNames library with 9 lines.
View index.js
const classNames = (object) => {
const classArray = [];
for (let property in object) {
if (object[property]) classArray.push(property)
}
return classArray.join(' ')
}
@joduplessis
joduplessis / config.yml
Created Jun 10, 2020
CircleCI file for building Windows electron apps - actual Docker image doesn't always work so well.
View config.yml
version: 2
jobs:
build_windows:
docker:
- image: electronuserland/builder:wine
steps:
- checkout
- run: npm i
- run: npm run build:electron
- run: npm run pack:win
@joduplessis
joduplessis / convert.sh
Created May 31, 2020
Favourite bash command for converting almost any video to H.264/AAC (web video).
View convert.sh
#!/bin/bash
ffmpeg -i input.mp4 -vcodec libx264 -acodec aac output.mp4
@joduplessis
joduplessis / letsencrypt-acme-challenge.conf
Created Apr 28, 2020
Generating LE certs manually with acme challenges.
View letsencrypt-acme-challenge.conf
#############################################################################
# Configuration file for Let's Encrypt ACME Challenge location
# This file is already included in listen_xxx.conf files.
# Do NOT include it separately!
#############################################################################
#
# This config enables to access /.well-known/acme-challenge/xxxxxxxxxxx
# on all our sites (HTTP), including all subdomains.
# This is required by ACME Challenge (webroot authentication).
# You can check that this location is working by placing ping.txt here:
@joduplessis
joduplessis / .gitlab-ci.yml
Created Oct 19, 2019
GitLab CI, Ansible & Docker workflow for deploying a node app to a private VPS via SSH.
View .gitlab-ci.yml
image: docker:18.09.7
services:
- docker:18.09.7-dind
stages:
- build
- push
- deploy
@joduplessis
joduplessis / matchPathToUrl.js
Created Sep 19, 2019
Simplistic matching of Express style URL parameters NOT using Regex.
View matchPathToUrl.js
function matchPathToUrl(path, url) {
const sanitizedUrl = url[0] == '/' ? url.substring(1) : url
const sanitizedPath = path[0] == '/' ? path.substring(1) : path
const sanitizedUrlParts = sanitizedUrl.split('/')
const sanitizedPathParts = sanitizedPath.split('/')
const pathBoundaries = sanitizedPath.split('/').map(part => part[0] == ':' ? -1 : part)
let values = {}
const passes = pathBoundaries.reduce((pass, part, index) => {
if (sanitizedUrlParts.length != sanitizedPathParts.length) return false
@joduplessis
joduplessis / Keg.js
Last active Sep 19, 2019
Exploring synchronous queues in JS - base for one of projects I'm working on (contain lib & implementation). See https://github.com/joduplessis/keg
View Keg.js
class Keg {
static instance;
taps = {};
queue = {};
constructor() {
setInterval(() => {
//console.log(this.taps)
//console.log(this.queue)
@joduplessis
joduplessis / Dockerfile.development
Created Aug 29, 2019
Docker files for a Nodejs websocket service using Redis.
View Dockerfile.development
FROM node:10
MAINTAINER Jo du Plessis <jo@joduplessis.com>
WORKDIR /var/www/websocket
@joduplessis
joduplessis / gitty
Last active Aug 22, 2019
A super convenient script to automate committing to repos. Simply say: gitty "Commit my stuff" to commit your changes to the current branch.
View gitty
#!/bin/bash
branch=$(git branch | grep \* | cut -d ' ' -f2)
echo "Commit to '$branch', with message '$1'"
read -p "Wnat to continue? (y): " choice
if [ $choice == "y" ]; then
env -i
git add -A
@joduplessis
joduplessis / Andromeda.itermcolors
Created Aug 19, 2019
The excellent iTerm Andromeda color scheme. Keeping it here for backup.
View Andromeda.itermcolors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.0</real>