Skip to content

Instantly share code, notes, and snippets.

Pieter Scheffers PieterScheffers

Block or report user

Report or block PieterScheffers

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@PieterScheffers
PieterScheffers / entries.ts
Created Mar 26, 2020
object.entries typescript
View entries.ts
type Entry<T> = [ keyof T, T[keyof T] ]
type Entries<T> = Entry<T>[]
type Key<T> = (keyof T)
type Keys<T> = Key<T>[]
type Value<T> = T[keyof T]
type Values<T> = Value<T>[]
type HasKeys<T> = { [key in keyof T]: any }
const keys = <T>(obj: T): Keys<T> => Object.keys(obj) as Keys<T>
const toEntries = <T>(obj: T): Entries<T> => Object.entries(obj) as Entries<T>
@PieterScheffers
PieterScheffers / pm2
Last active Mar 13, 2020
node.js pm2 startup script for FreeBSD
View pm2
#!/bin/sh
# PM2 Startup script
# Source: https://0x0a14.de/pm2-startup-script-for-freebsd/
# Made by: Johannes Tonn
#
# Download this file
# cd /usr/local/etc/rc.d && fetch https://gist.github.com/457769f2090c6b69cd9d
#
# Make the file executable with:
@PieterScheffers
PieterScheffers / start_docker_registry.bash
Last active Feb 29, 2020
Start docker registry with letsencrypt certificates (Linux Ubuntu)
View start_docker_registry.bash
#!/usr/bin/env bash
# install docker
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
# install docker-compose
# https://docs.docker.com/compose/install/
# install letsencrypt
# https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
View install_forticlient_linux.sh
# install ubuntu in virtual machine
# https://ubuntuforums.org/showthread.php?t=1481300
# Get arch type of ubuntu
# i686 = 32 bit
# x86_64 = 64 bit
uname -m
# download forticlient
https://hadler.me/linux/forticlient-sslvpn-deb-packages
View mysql_get_last_updated_id.sql
# http://stackoverflow.com/questions/1388025/how-to-get-id-of-the-last-updated-row-in-mysql
# single row update
SET @update_id := 0;
UPDATE some_table SET column_name = 'value', id = (SELECT @update_id := id)
WHERE some_other_column = 'blah' LIMIT 1;
SELECT @update_id;
# Multiple rows updated
SET @uids := null;
View CheckboxButton.js
import React from 'react';
import PropTypes from 'prop-types';
const style = {
label: {
display: 'inline',
fontFamily: 'RobotoCondensed-Regular, sans-serif',
userSelect: 'none', // disable text selection
fontWeight: 'bold'
},
@PieterScheffers
PieterScheffers / vncserver
Last active Aug 4, 2019
vncserver rc.d script for FreeBSD
View vncserver
#!/bin/sh
# Download this file
# cd /usr/local/etc/rc.d && fetch --no-verify-peer https://gist.githubusercontent.com/PieterScheffers/1ecd70a1bfe640afb98f3cac9630814b/raw/326033ce1c243fd7ecd018684e748234668cf9ff/vncserver
#
# Make the file executable with:
# /usr/local/etc/rc.d/vncserver (chmod +x)
#
# add to /etc/rc.conf
#
View makefile_windows.txt
https://www.oreilly.com/library/view/managing-projects-with/0596006101/ch07.html
@PieterScheffers
PieterScheffers / docker-raspberry-pi.sh
Created May 30, 2017
Build ARM docker images for Raspberry Pi with QEMU
View docker-raspberry-pi.sh
# https://blog.hypriot.com/post/setup-simple-ci-pipeline-for-arm-images/
### Choose a base image with QEMU binary
# FROM hypriot/rpi-alpine
# FROM resin/rpi-raspbian
# FROM resin/raspberry-pi-alpine-node:slim
### Register QEMU in the build agent
docker run --rm --privileged multiarch/qemu-user-static:register --reset
@PieterScheffers
PieterScheffers / .bashrc
Last active Apr 23, 2019
Download new kubeconfig when it is older as 6 days for DigitalOcean kubernetes
View .bashrc
#!/usr/bin/env bash
# DigitalOcean Kubernetes
# The kubeconfig you download from DigitalOcean invalidates every 7 days
# By appending this to your .bashrc file the kubeconfig gets refreshed every 6 days
#
# Pre
# - install 'doctl': https://github.com/digitalocean/doctl#installing-doctl
# - auth with DigitalOcean API token: https://github.com/digitalocean/doctl#authenticating-with-digitalocean
#
You can’t perform that action at this time.