Skip to content

Instantly share code, notes, and snippets.

"use strict"
var request = require( "request" );
var sensorIds = [
"TAP_TEMP",
"PARTY_TENT_TEMP",
"ARMY_TENT_TEMP",
"TAP_OPEN",
"FISSA_ENABLED",
];
@xopr
xopr / check_fs.sh
Last active April 12, 2017 08:36
Check FreeSWITCH services, space|nl|de node
# 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)
@xopr
xopr / https.py
Created October 30, 2018 08:28
ssl test webserver in python
# 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 )
// 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`
// 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 / reverse_tunnel.sh
Created April 11, 2018 07:31
Use autossh and screen to create a tunnel back to the local host publicly available on 'remote'
#!/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 / autoblock.pl
Last active April 16, 2020 03:28
auto block IP based registrations and invites in FreeSWITCH
#!/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 / spacephonebook.py
Last active July 21, 2020 04:31
Spacephone.org NAPTR to CSV/JSON/VCF phonebook generator
#!/usr/bin/env python3
#pip-3 install dnspython
import dns.resolver
import dns.e164
import re
import sys
import optparse
@xopr
xopr / mosaicbg.sh
Last active November 8, 2020 19:04
Generate mosaic from testcards
#!/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]..]"
// # compile this with
// ./openwrt-sdk-19.07.7-ramips-mt76x8_gcc-7.5.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-7.5.0_musl/bin/mipsel-openwrt-linux-gcc fartnet.c -o fartnet
// # copy over the file:
// # at the pc, run:
// nc -l 9999 -w0 < fartnet
// # at the router, run:
// nc 192.168.2.116 9999 > fartnet
// chmod +x fartnet
// # next, kill everything that accesses the device node:
// kill -9 `ps w|grep watchdog_loop|grep -v grep|awk '{ print $1 }'`