Skip to content

Instantly share code, notes, and snippets.

@aejh
aejh / skeleton.py
Last active December 10, 2019 08:15
A skeleton for python scripts.
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
An example script
"""
import logging
from os.path import basename
@aejh
aejh / .vimrc
Last active December 11, 2015 15:08
vimrc file, with specific customisations for editing python and makefiles.
set tabstop=4
set shiftwidth=4
set softtabstop=4
set hlsearch
set ai
set expandtab
set ruler
autocmd Filetype python match Todo '\%>79v.\+'
autocmd FileType make setlocal noexpandtab
"match Todo /\s\+$/
@aejh
aejh / .screenrc
Created January 24, 2013 09:10
My screenrc file
startup_message off
autodetach on
vbell on
bell_msg 'Ding dong %n'
caption always "%H %{= rr}%{+b w} %n %h %=%t %c:%s"
hardstatus alwayslastline "%-Lw%{= rW}%50>%n%f* %t%{-}%+Lw%<"
termcapinfo xterm*|rxvt*|kterm*|Eterm* 'hs:ts=\E]0;:fs=\007:ds=\E]0;\007'
termcapinfo xterm* ti@:te@
@aejh
aejh / plot_example.py
Created March 26, 2013 12:26
Simple matplotlib (pylab) example.
from pylab import figure, show
fig = figure()
ax = fig.add_subplot(111)
x = range(0,20)
#Silly XOR example
for i in range(10):
ax.plot(x, [_^i for _ in x])
show()
@aejh
aejh / test-openvpn.sh
Created December 10, 2019 06:03
Check OpenVPN
# https://serverfault.com/questions/262474/how-to-check-that-an-openvpn-server-is-listening-on-a-remote-port-without-using
echo -e "\x38\x01\x00\x00\x00\x00\x00\x00\x00" |
timeout 10 nc -u openvpnserver.com 1194 | cat -v
# answer: @$M-^HM--LdM-t|M-^X^@^@^@^@^@@$M-^HM--LdM-t|M-^X^@^@^@^@^@@$M-^HM--LdM-t|M-^X...
@aejh
aejh / podman-aliases.sh
Created October 20, 2020 07:49
Podman aliases
# Default podman ps output is very wide, shows the infra containers and isn't column
alias podps='podman ps --format "{{.Names}} {{.Image}} {{.Status}}" | fgrep -v k8s.gcr.io/pause | co
# Set UK timezone
Backlog TimeZone 99; TimeDST 0,0,3,1,1,60; TimeSTD 0,0,10,1,2,0
@aejh
aejh / Common Mikrotik commands
Last active January 4, 2021 09:59
Common Mikrotik settings easier to add by cli
# Used in a typical home environment, WAN IP to internet, with NAT to LAN
# Add a port foward
/ip firewall nat add chain=dstnat dst-address=<WAN-IP> dst-port=<PORT> protocol=[tcp|udp] action=dst-nat to-addresses=<LAN-IP>
# Add a static DHCP lease
/ip dhcp-server lease add address=<LEASED-ADDRESS> mac-address=<MAC-ADDR> server="<DHCP-SERVER-NAME>" disabled=no
# Add hostname to DNS server
/ip dns static add name=<HOSTNAME> address=<IP-ADDRESS>
@aejh
aejh / _boot_cmdline.txt
Last active July 2, 2021 08:08
Rpi zero USB networking, with Linux host
# After rootwait:
modules-load=dwc2,g_ether
@aejh
aejh / mt-static-to_hosts.sh
Created February 2, 2021 15:29
Mikrotik static DNS records to hostsfile
ssh 10.0.0.1 /ip dns static print terse without-paging | sed -n 's/.*name=\(.*\) address=\([0-9.]*\) .*/\2 \1/p'