Skip to content

Instantly share code, notes, and snippets.

View deskoh's full-sized avatar
👽
iamdeskoh

Desmond Koh deskoh

👽
iamdeskoh
View GitHub Profile
blueprint:
name: Timer Switch (Lights)
description: Turn off switch after specified duration when lights are off.
domain: automation
input:
switch:
name: Switch
description: Switch entity
selector:
###########################################################
## Additional domain alias for Docker registry
###########################################################
map $http_host $repoKey {
cr.io docker;
p.cr.io docker-private;
m.cr.io docker-mirror;
}
@echo off
if "%2" == "" (
echo Download image from Docker registry into OCI format in "images" directory.
echo.
echo Usage:
echo %0 ^<image-name^> ^<private-image-tag^>
echo.
echo Example usage:
echo %0 nginx:alpine internal-registry:5000/nginx:alpine
exit /b 1
@deskoh
deskoh / pihole.sh
Created June 12, 2022 10:11
Pihole setup
# Install docker
apt install docker.io
# Use following if `apt install docker.io` not available
apt update
apt install apt-transport-https ca-certificates curl gnupg lsb-release -y
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
@deskoh
deskoh / K3D.md
Last active September 15, 2022 02:24
K3D

K3D Setup

Install K3D

curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash

Create Cluster

@deskoh
deskoh / Dockerfile
Created September 20, 2021 01:37
SPA Container Entrypoint
ARG BASE_REGISTRY=docker.io
ARG BASE_IMAGE=library/nginx
ARG BASE_TAG=latest
# Stage 1 - Build base image with nginx
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} as base
# Stage 2 - the build process
FROM $BASE_REGISTRY/webserver as builder
# Clear NODE_ENV variable to allow devDependencies to be installed
@deskoh
deskoh / delete-image-1.js
Last active June 21, 2022 10:33
Docker Registry V2 API
const axios = require('axios')
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
if (process.argv.length < 3) {
console.info(`Usage: node delete-image <image_name>`)
process.exit(1)
}
const imageUrl = new URL(`http://${process.argv[2]}`)
@deskoh
deskoh / docker-nginx-proxy-compose.yaml
Last active July 2, 2021 07:57
Auto NGINX Proxy for Docker Environments
version: '3.1'
services:
nginx-proxy:
image: jwilder/nginx-proxy:alpine
restart: unless-stopped
environment:
# Disable redirect and HSTS
HTTPS_METHOD: noredirect
# Disable Diffie-Hellman parameters
version: '3.7'
services:
zookeeper:
container_name: zookeeper
image: docker.io/bitnami/zookeeper:3.8
ports:
- "2181:2181"
volumes:
- "zookeeper_data:/bitnami"
@deskoh
deskoh / ChannelTests.md
Created April 8, 2021 06:33
FeathersJS Recipes
const feathers = require('@feathersjs/feathers');
const socketio = require('@feathersjs/socketio');
const { socket: commons } = require('@feathersjs/transport-commons');
const assert = require('assert');
const { EventEmitter } = require('events');

const messages = require('../src/messages');

describe('\'messages\' service', () => {