Skip to content

Instantly share code, notes, and snippets.

View stolsma's full-sized avatar
🙂
Coding away...

Sander Tolsma stolsma

🙂
Coding away...
View GitHub Profile
@stolsma
stolsma / 1-Install.md
Last active August 7, 2022 16:19
Centos repo files for installing KVM, docker, kubernetes, Helm and Tiller

Installing KVM, libvirt, Docker-CE and Kubernetes on Centos 7.x

First of all be root while doing this... sudo su

Set hostname

Set the hostname:

hostnamectl set-hostname 'k8s-master'

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)

@stolsma
stolsma / readme.md
Last active January 16, 2020 11:09 — forked from ubergesundheit/readme.md
systemd traefik.service

systemd Service Unit for Traefik

Adapted from the forked gist and this blog. Adjusted to our own implementation.

The provided file should work with systemd version 219 or later. It might work with earlier versions. The easiest way to check your systemd version is to run systemctl --version.

Instructions

@stolsma
stolsma / consul.service
Created July 24, 2017 19:30 — forked from rossedman/consul.service
Consul Installation
#
# This needs to be installed here:
# /etc/systemd/system/consul.service
#
[Unit]
Description=consul
Requires=network-online.target
After=network-online.target
@stolsma
stolsma / installNodejs.md
Last active October 11, 2015 01:18
Compile and install receipe for ubuntu

Install first for ubuntu:

sudo apt-get install build-essential libssl-dev curl git-core

Compile the required node version and put in global reach:

# install nodejs from Github (replace 0.8.9 with required version)
git clone git://github.com/joyent/node.git node0.8.9
@stolsma
stolsma / test.js
Created August 25, 2012 13:42
Lower worker privilege with cluster or fork when run as root and still able to use unprivilaged ports
var cluster = require('cluster');
var util = require('util');
var http = require('http');
var numCPUs = 2; //require('os').cpus().length;
//
// general functions
//
function isRoot() {
return process.getuid() == 0;
@stolsma
stolsma / getPeerCertificate.js
Created October 1, 2011 05:08
getPeerCertificate example
var https = require('https'),
fs = require('fs');
var options = {
key: fs.readFileSync('./ssl/privatekey.pem'),
cert: fs.readFileSync('./ssl/certificate.pem'),
requestCert: true
};
https.createServer(options, function (req, res) {
@stolsma
stolsma / pimp_prompt.sh
Created September 27, 2011 07:08 — forked from jamiew/pimp_prompt.sh
Put this in your ~/.bash_profile or ~/.bashrc file. Then type source ~/.bashrc or source ~/.bash_profile to reload.
parse_git_branch() {
ref=$(git symbolic-ref -q HEAD 2> /dev/null) || return
printf "${1:-(%s)}" "${ref#refs/heads/}"
}
pimp_prompt() {
local BLUE="\[\033[0;34m\]"
local BLUE_BOLD="\[\033[1;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
@stolsma
stolsma / explaination.md
Created September 26, 2011 19:29
Why only IPv6 will also listen for IPv4 on most Linux systems...

The best approach is to create an IPv6 server socket that can also accept IPv4 connections. To do so, create a regular IPv6 socket, turn off the socket option IPV6_V6ONLY, bind it to the "any" address, and start receiving. IPv4 addresses will be presented as IPv6 addresses, in the IPv4-mapped format.

The major difference across systems is whether IPV6_V6ONLY is a) available, and b) turned on or off by default. It is turned off by default on Linux (i.e. allowing dual-stack sockets without setsockopt), and is turned on on most other systems.

In addition, the IPv6 stack on Windows XP doesn't support that option. In these cases, you will need to create two separate server sockets, and place them into select or into multiple threads.

Found on: http://stackoverflow.com/questions/1618240/how-to-support-both-ipv4-and-ipv6-connections

@stolsma
stolsma / clone.js
Created September 25, 2011 18:51 — forked from polotek/clone.js
Real, deep copied objects.
function hasOwnProperty(key) {
if(this[key]) {
var proto = this.prototype;
if(proto) {
return ((key in this.prototype) && (this[key] === this.prototype[key]));
}
return true;
} else {
return false;
}