Skip to content

Instantly share code, notes, and snippets.

@xopr
xopr / spacephonebook.py
Last active Jul 21, 2020
Spacephone.org NAPTR to CSV/JSON/VCF phonebook generator
View spacephonebook.py
#!/usr/bin/env python3
#pip-3 install dnspython
import dns.resolver
import dns.e164
import re
import sys
import optparse
View SPI_slave.ino
// NOTE: make sure you disable the Arduino reset when using as serial terminal
// run: `systemctl enable serial-getty@ttyACM0.service` (or the appropriate Arduino serial device
// edit: `/etc/systemd/system/getty.target.wants/serial-getty@ttyACM0.service`
// and change
// ExecStart=...... $TERM
// into:
// ExecStart=...... vt52
// then run: `systemctl daemon-reload`
// and: `systemctl restart serial-getty@ttyACM0.service`
View Expander.c
// Standard includes
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
// System include
#include <Gigatron.h>
const int tinyfont[96] = {
#include "../Utils/BabelFish/tinyfont.h"
@xopr
xopr / mosaicbg.sh
Last active Nov 8, 2020
Generate mosaic from testcards
View mosaicbg.sh
#!/bin/bash
WIDTH=1280
HEIGHT=720
if [ $# -eq 0 ]; then
echo "Testcard mosaic generator: generate 1 to 9 mosaic labeled testscreens"
echo -e "\tUses read, sed, wget and ImageMagick (convert and montage)"
echo -e "\tIt also uses Terence Eden's Testcard <https://github.com/edent/SVGtestcard>"
echo -e "\tUsage: $0 <name>[,subtitle>] [name[,subtitle]..]"
@xopr
xopr / autoblock.pl
Last active Apr 16, 2020
auto block IP based registrations and invites in FreeSWITCH
View autoblock.pl
#!/usr/bin/env perl
# Blocks IP adresses in 3 steps:
# * unknown REGISTER (Can't find user) is blocked immediately
# * unauthorized INVITE is flagged (and blocked after 3 strikes)
# * authorized INVITES are unflagged (and the IP block is removed when the counter hits 0 (or less))
# * IP based incoming call which is not from a trunk (defined in ACL) is blocked immediately
# this needs some adjustments in the FS config:
# An ACL list of ip adresses of trunks that setup calls to you: <list name="trunks" default="deny">
@xopr
xopr / https.py
Created Oct 30, 2018
ssl test webserver in python
View https.py
# Create certificate
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.pem -out mycert.pem -subj "/C=NL/ST=Limburg/L=Heerlen/O=ACKspace/OU=demo/CN=localhost.ackspace.nl"
# Copied from https://www.piware.de/2011/01/creating-an-https-server-in-python/
import BaseHTTPServer, SimpleHTTPServer
import ssl
# add localhost to limit interfaces
httpd = BaseHTTPServer.HTTPServer(('', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket( httpd.socket, certfile='mycert.pem', server_side=True )
@xopr
xopr / hybrid.bat
Created Sep 27, 2018
batch bash hybrid script
View hybrid.bat
:<<"::CMDLITERAL"
@ECHO OFF
echo Welcome to %COMSPEC%
GOTO :CMDSCRIPT
::CMDLITERAL
echo "Welcome to ${SHELL}"
function REM {
# REM is used to execute linux shell code
@xopr
xopr / reverse_tunnel.sh
Created Apr 11, 2018
Use autossh and screen to create a tunnel back to the local host publicly available on 'remote'
View reverse_tunnel.sh
#!/bin/bash
echo Setting up remote tunnel in screen session
screen -dmS tunnel autossh -N -R *:2222:localhost:22 -i .ssh/cypher tunnel@remote -p22
@xopr
xopr / check_fs.sh
Last active Apr 12, 2017
Check FreeSWITCH services, space|nl|de node
View check_fs.sh
# Add it to `crontab -e` with
# */10 * * * * ~/check_fs.sh PUBLICNODEPART_OR_SPACE
# where space as node name is a special scenario
# NOTE: crontab uses `sh` which is somewhat spartan compared to `bash`
# Column number to place the status message
RES_COL=60
# Command to move out to the configured column number
MOVE_TO_COL="echo -en \\033[${RES_COL}G"
# Command to set the color to SUCCESS (Green)
View fetchIoTaps.js
"use strict"
var request = require( "request" );
var sensorIds = [
"TAP_TEMP",
"PARTY_TENT_TEMP",
"ARMY_TENT_TEMP",
"TAP_OPEN",
"FISSA_ENABLED",
];