Skip to content

Instantly share code, notes, and snippets.

@PieterScheffers
PieterScheffers / install_forticlient_linux.sh
Created January 22, 2018 16:28
Install Forticlient on Linux
# 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
@PieterScheffers
PieterScheffers / vncserver
Last active January 1, 2024 12:01
vncserver rc.d script for FreeBSD
#!/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
#
@PieterScheffers
PieterScheffers / start_docker_registry.bash
Last active October 29, 2023 18:26
Start docker registry with letsencrypt certificates (Linux Ubuntu)
#!/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
@PieterScheffers
PieterScheffers / docker-tail-all.bash
Created July 22, 2018 12:39
Tail all running Docker containers
#!/bin/bash
# Source: https://stackoverflow.com/questions/32076878/logging-solution-for-multiple-containers-running-on-same-host
# Creator: Nate
names=$(docker ps --format "{{.Names}}")
echo "tailing $names"
while read -r name
do
@PieterScheffers
PieterScheffers / pm2
Last active March 14, 2023 07:43
node.js pm2 startup script for FreeBSD
#!/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:
#!/bin/bash
# Custom scripts here
echo "This is an extended entrypoint!"
# Run the original entrypoint located at
# /docker-entrypoint.sh
exec /docker-entrypoint.sh "$@"
@PieterScheffers
PieterScheffers / mysql_get_last_updated_id.sql
Created June 21, 2016 10:56
MySQL - Get id of updated rows
# 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;
# Basic login
#### authorized_keys on server
ssh-rsa...rest of local public key (.pub)
#### .ssh/config
Host some_server_alias # custom name of the host
HostName example.nl # hostname of the server
User some_user # user to login as
ForwardAgent yes # forward local keychain, so you can use bitbucket with local key
@PieterScheffers
PieterScheffers / js-micro.js
Created May 23, 2016 07:45 — forked from yuval-a/js-micro.js
Javascript micro-optimizations
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
var obj = {};
// property === undefined is faster than hasOwnProperty(property)
// http://jsperf.com/hasownproperty-vs-in-vs-undefined/17
@PieterScheffers
PieterScheffers / find_processes_with_file_descriptors.sh
Created November 15, 2021 15:46
Find processes with a minimum number of file descriptors
minimum=30
for pid in /proc/[0-9]*; do number_fds=$(ls $pid/fd | wc -l); if [ $number_fds -ge $minimum ]; then printf "PID %6d has %4d FDs\n" $(basename $pid) $(ls $pid/fd | wc -l); ps aux | grep $(echo $pid | cut -d/ -f3) | grep -v grep; fi; done