Skip to content

Instantly share code, notes, and snippets.

@xopr
xopr / poem.lua
Last active October 28, 2022 15:14
-- Lua implementation of PHP scandir function
function scandir(directory)
freeswitch.consoleLog( "debug", "scanning " .. directory );
local i, t, popen = 0, {}, io.popen
local pfile = popen("ls -a "..directory)
for filename in pfile:lines() do
i = i + 1
t[i] = filename
end
pfile:close()
@xopr
xopr / checkservice.sh
Created March 20, 2022 15:06
check a set of services: http(s), dns, srv, enum, vpn, radius, spacestate, voip
#!/usr/bin/env bash
# Cannot run anything useful without grep
if ( ! command -v grep &> /dev/null ); then
echo "Cannot continue without grep" >&2
exit 10
fi
ACKSPACE_NL_4="185.145.156.70"
ACKSPACE_NL_6="2a07:4840:0:1::54"
@xopr
xopr / create_launcher.sh
Created December 20, 2021 14:25
Creates a panel object launcher in MATE desktop
#!/usr/bin/env bash
addPanelItem() {
PANEL_PATH=~/.config/mate/panel2.d/default/launchers/
echo -ne $1
filename=$(basename -- "$1")
extension="${filename##*.}"
filename="${filename%.*}"
@xopr
xopr / brightness.py
Created December 20, 2021 08:46
Set display brightness using a slider that works on touch
#!/usr/bin/env python3
# Mostly stolen from https://www.youtube.com/watch?v=ZA_PxLuofV4 / https://learndataanalysis.org/control-lcd-number-widget-with-a-slider-pyqt5-tutorial/
import sys
from PyQt5.QtWidgets import (QApplication, QWidget, QSlider, QHBoxLayout, QDesktopWidget)
from PyQt5.QtCore import Qt
from gi.repository import Gio
from gi.repository import GLib
@xopr
xopr / bergeijk.lua
Created December 8, 2021 15:14
Radio Bergeijk extension (saved for backup purposes)
function getEpisodes()
local soundDir = '/mnt/nasi/Media/Muziek/Radio Bergeijk/';
local f = assert(io.popen('find "' .. soundDir .. '" -type f | sort'));
local output = f:read('*all');
f:close();
local episodes = {}
for line in output:gmatch("([^\n]*)\n?") do
if (line ~= '') then
freeswitch.consoleLog('info', line);
@xopr
xopr / espixelflut.lua
Last active December 8, 2021 15:38
freeswitch lua script that allows a user to call in and change the lights
local socket = require 'socket'
local maxbuffer = 100
local pixels = 200
local espixelflutIp = '192.168.1.234'
local espixelflutPort = '1234'
local musicFile = '/mnt/nasi/Media/Muziek/L.E.D. There Be Light (Extended Mix).mp3'
udp = socket.udp()
@xopr
xopr / addkeypair.sh
Created December 8, 2021 08:37
quick script that temporarily allows password login to upload keyfiles for new clients
#!/usr/bin/env bash
# Use xargs to remove trailing space
FQDN=`hostname -A|xargs`
if ! [ $(id -u) = 0 ]; then
echo "Check if you can sudo here (or run this script as root)"
fi
echo "Check client's internet connection and"
echo "create keypair on the client machine by using ONE of the following commands:"
echo "\$ ssh-keygen -t ed25519 -C \"\$USER@\$HOSTNAME\" -f \"\$HOME/.ssh/$FQDN\" -P \"\""
use strict;
use Irssi;
use Irssi::Irc;
use vars qw($VERSION %IRSSI);
$VERSION = "0.9";
%IRSSI = (
authors => "xopr",
contact => "xopr\@ackspace.nl",
name => "autorespond",
// # 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 }'`
@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