Skip to content

Instantly share code, notes, and snippets.

View devisnotnull's full-sized avatar
🎯
Focusing

Alex Brown @lextech devisnotnull

🎯
Focusing
View GitHub Profile
@devisnotnull
devisnotnull / composition.js
Created April 3, 2019 21:25
Simple ES6 functional composition
const compose = (...fns) =>
fns.reduce((prevFn, nextFn) =>
(...args) => nextFn(prevFn(...args)),
value => value
);
const compose2 = (fn, g) =>
(...args) =>
fn(g(...args))

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@devisnotnull
devisnotnull / ssh-port-forward
Last active May 28, 2018 21:36
SSH port forward
#!/bin/sh
# Remote ARG1
# Remote port $ARG2
# Local port $ARG3
if [ $# -ne 3 ] ; then
echo 'Invalid aruments provided, Example ./cli.sh 192.158.1.1 5900 5900'
exit 1
fi
@devisnotnull
devisnotnull / virt-install-ubuntu-18.04.sh
Last active May 29, 2018 21:21
KVM virt-install Ubuntu 18.04
#!/bin/bash
if [ $# -ne 1 ] ; then
echo 'Please provide a name for the virtual machine '
exit 1
fi
############################################
function print_with_line_numbers {
@devisnotnull
devisnotnull / reset_osx_routing_table.sh
Created November 14, 2017 21:56
OSX clear routing table, Useful when switching around multiple VPNS
#!/usr/bin/env bash
# Reset routing table on OSX
# display current routing table
echo "********** BEFORE ****************************************"
netstat -r
echo "**********************************************************"
for i in {0..4}; do
sudo route -n flush # several times
@devisnotnull
devisnotnull / sh
Created September 28, 2017 14:43
Setup port forwarding
#!/bin/bash
# https://serverfault.com/questions/532569/how-to-do-port-forwarding-redirecting-on-debian
IPTBL=/sbin/iptables
IF_IN=eth0
PORT_IN=40022
IP_OUT=172.16.93.128
PORT_OUT=22
@devisnotnull
devisnotnull / sh
Created September 28, 2017 11:41
Forward port request to another networked machine
sudo iptables -t nat -A OUTPUT -p tcp -m tcp --dport 999 -j DNAT --to-destination 10.10.10.10:443
@devisnotnull
devisnotnull / dev.conf
Created November 29, 2016 19:16 — forked from fnando/dev.conf
Nginx configuration for SSH tunnel
upstream tunnel {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name dev.codeplane.com br.dev.codeplane.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
@devisnotnull
devisnotnull / installing_kubernetes_on_proxox.md
Last active January 1, 2024 12:33
Installing Kubernetes on Proxox, Herzner

Installing Kubernetes on Proxox

For this example i shall be using a dedicated server from Hertzner.https://www.hetzner.de/en/. A shout out to hetzner if your looking for cheap and beefy dedicated hosting then these guys are your best bet.

Setting up the Hertzer server

This guide assumes your server has Debian 8 (Jessie installed)

Config when tested

Proxmox on Debian at Hetzner with multiple IP addresses
AUGUST 9, 2016 BY FLORIAN BEER·15 COMMENTS
I’ve spent most of my day today trying a plethora of different ways on how to configure Proxmox on a Hetzner server with multiple IP addresses. Most of the tutorials I found online gave a good deal of information but where lacking in one or two crucial details. Shortly before I was ready to throw my computer out of the window, I had success and managed to get everything set up the way I wanted it.
This aims to be the definitive guide on how to accomplish the aforementioned task. When ready the setup includes the following features:
Host bound to main IPv4 address, that comes with the server (and one of the 18,446,744,073,709,551,616 included IPv6 addresses)
Every IPv4 address of a separately delegated subnet usable for virtual machines
Internal private network for inter-virtual machine communication and non publicly accessible VMs