Skip to content

Instantly share code, notes, and snippets.

View woudsma's full-sized avatar
🌌
☀️🛰☁️🌈

Tjerk Woudsma woudsma

🌌
☀️🛰☁️🌈
View GitHub Profile
@woudsma
woudsma / async-trycatch.js
Last active November 27, 2020 22:37
Recursive try/catch statements for async/await functions in a nested object (using .catch)
// Simulates try/catch statements wrapping async functions in (nested) object
// Returns copy of original object with basic promise-rejection handling for async functions using .catch
// Saves the time of writing try/catch statements in every single async function
const trycatch = obj => Object.keys(obj)
.reduce((acc, curr) => ({ ...acc, [curr]: obj[curr] instanceof Function
? (...args) => obj[curr](...args).catch(::console.error)
: trycatch(obj[curr]) }), {})
@woudsma
woudsma / dokku-kirby-autogit.md
Last active May 15, 2021 17:32
Dokku + Kirby + AutoGit

TL;DR

  • Configure Kirby for Dokku
  • Install deployment-keys and host keys Dokku plugins
  • Set up staging and production environments
  • Clone project repository into apps persistent storage folders
  • Mount desired folders including .git folder to apps
  • Add GIT_DIR and GIT_WORK_TREE environment variables to containers
  • Deploy to Dokku
@woudsma
woudsma / dump.md
Last active October 11, 2017 09:12

Install Homebrew

  • xcode-select --install
  • /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install PostgreSQL + PostGIS

  • brew update
  • brew install postgres
  • brew install postgis
  • brew services start postgres
  • createdb paperstorm
  • psql
@woudsma
woudsma / portainer-dokku.md
Last active May 7, 2023 23:04
TLS secured TCP exposed Docker daemon on Dokku host - setup

TLS secured TCP exposed Docker daemon on Dokku host - setup

  1. Create certificates
  2. Edit Docker options
  3. Restart Docker
  4. Copy client certificates from host
  5. (optional) Add remote endpoint in Portainer

Tested on a standard $5/mo DigitalOcean VPS running Ubuntu 16.04.


@woudsma
woudsma / dokku-postgres-postgis.md
Created January 17, 2018 12:38
Using the PostGIS extension on a PostgreSQL database with Dokku

Using the PostGIS extension on a PostgreSQL database with Dokku

docker pull mdillon/postgis:latest  
export POSTGRES_IMAGE="mdillon/postgis"  
export POSTGRES_IMAGE_VERSION="latest"  
dokku postgres:create my-postgis-db
@woudsma
woudsma / k-d-tree.md
Last active February 19, 2018 12:54
Javascript k-d-tree
npm i k-d-tree
const kd = require('k-d-tree')

const data = new Array(1000)
  .fill()
  .map(() => ({
 type: "Point",
#!/bin/bash
echo "Compositing files and ramping up video framerate"
echo "================================================"
rm -rf render && mkdir render
for file in *.mov; do
# Ramp up video framerate, add audio
ffmpeg \
@woudsma
woudsma / retrain-mobilenet-for-the-web.md
Last active November 1, 2022 05:09
Retrain a MobileNet model for the web with TensorFlow for Poets and TensorFlow.js

Retrain a MobileNet model and use it in the browser with TensorFlow.js

DRAFT

Combining TensorFlow for Poets and TensorFlow.js.
Retrain a MobileNet V1 or V2 model on your own dataset using the CPU only.
I'm using a MacBook Pro without Nvidia GPU.

MobileNets can be used for image classification. This guide shows the steps I took to retrain a MobileNet on a custom dataset, and how to convert and use the retrained model in the browser using TensorFlow.js. The total time to set up, retrain the model and use it in the browser can take less than 30 minutes (depending on the size of your dataset).

Example app - HTML/JS and a retrained MobileNet V1/V2 model.

import math
from bigfloat import *
class LazyCartesianProduct:
def __init__(self, sets, context):
self.sets = sets
self.context = context
self.divs = []
self.mods = []
self.maxSize = BigFloat.exact(1)

Dokku ACL plugin

# Dokku host
dokku plugin:install https://github.com/dokku-community/dokku-acl.git acl

dokku ssh-keys:add guest guest-key.pub
dokku ssh-keys:list

mkdir ~dokku/.dokkurc
echo "export DOKKU_ACL_ALLOW_COMMAND_LINE=1" >> ~dokku/.dokkurc/acl