Skip to content

Instantly share code, notes, and snippets.

View sphaero's full-sized avatar

Arnaud Loonstra sphaero

View GitHub Profile
@sphaero
sphaero / get_ifs.py
Created January 2, 2014 10:31
Get all interfaces and ipaddressen, python3 compatible. Tested on Linux
# Compatible with Python3, tested on Linux
# Author Arnaud Loonstra <arnaud@sphaero.org>
# based on <http://code.activestate.com/recipes/439093/#c1>
import socket
import fcntl
import struct
import array
import sys
# Based on http://carnivore.it/2012/10/12/python3.3_sendmsg_and_recvmsg
# Example of using the new recvmsg() method of the sockets module
import ipaddress
import socket
import ctypes
# First, we have to tell the socket we want to receive this additional data.
# As the socket module lacks some constants, we need to define them too.
IP_PKTINFO = 8
@sphaero
sphaero / urwid_zmq_event_loop.py
Last active January 18, 2020 03:43
Urwid ZeroMQ event loop class. For all your console joy with 0mq
# A ZeroMQ Event loop class for Urwid. This class inherits from the original
# SelectEventLoop and replaces the filedescriptor polling with the ZeroMQ
# methods.
# Author: Arnaud Loonstra <arnaud@sphaero.org>
import zmq
import time
class ZmqEventLoop(urwid.SelectEventLoop):
@sphaero
sphaero / dyn_dns_app.py
Last active April 6, 2020 16:04
Simple DynDNS Service using (apache) webserver and DNSMasq
#!/usr/bin/env python
# Simple Dynamic DNS update script for use with DNSMasq
#
# Install this WSGI script on a (apache) webserver. Make sure
# DNSMasq runs as the same user as this script does on the webserver
# E.g: /etc/default/dnsmasq add: (Debian and deriatives)
# DNSMASQ_USER='wsgiuser'
#
# ### DNSMASQ.CONF ###
# domain-needed
from pyre import zbeacon
import zmq
import struct
import uuid
import socket
ctx = zmq.Context()
beacon = zbeacon.ZBeacon(ctx, 1200)
transmit = struct.pack('cccb16sH', b'Z',b'R',b'E',
1, uuid.uuid4().bytes,
# win_socket_test.py
#
# Test using netcat:
# nc -un 127.0.0.1 1200
# Broadcast test:
# socat - UDP-DATAGRAM:255.255.255.255:1200,broadcast
import socket
import struct
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
@sphaero
sphaero / glesgeneric.c
Last active June 24, 2019 18:10
Gstreamer glimagesink raspberry pi generic example
/*
* GStreamer GLES2 Raspberry Pi example
* Based on http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/tests/examples/gl/generic/cube/main.cpp
* Modified for Raspberry Pi/GLES2 by Arnaud Loonstra <arnaud@sphaero.org>
* Orginal by Julien Isorce <julien.isorce@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
@sphaero
sphaero / winipaddr.py
Last active April 10, 2023 00:12
Get windows ipadresses info
#!/usr/bin/env python
#
# For the sake of humanity here's a python script retrieving
# ip information of the network interfaces.
#
# Pay some tribute to my soul cause I lost a few years on this one
#
# based on code from jaraco and many other attempts
# on internet.
# Fixed by <@gpotter2> from scapy's implementation to
@sphaero
sphaero / gstreamer-build.sh
Last active February 11, 2023 16:25
Install & build gstreamer from git
#!/bin/bash --debugger
set -e
BRANCH="master"
if grep -q BCM2708 /proc/cpuinfo; then
echo "RPI BUILD!"
RPI="1"
fi
[ -n "$1" ] && BRANCH=$1
@sphaero
sphaero / uae_from_kodi.sh
Last active August 29, 2015 14:11
Start UAE from Kodi on the Raspberry PI (RaspBMC)
#!/bin/bash
#
# Start this script through the Advanced Launcher Addon
#
# This script fixes not getting a display after stopping Kodi
# After quitting UAE it will return to Kodi
#
# Expecting UAE4All in /home/pi/amiga/uae4all
#
# Author: Arnaud Loonstra <arnaud@sphaero.org>