Skip to content

Instantly share code, notes, and snippets.

View vpetersson's full-sized avatar
😎
¯\_(ツ)_/¯

Viktor Petersson vpetersson

😎
¯\_(ツ)_/¯
View GitHub Profile
#!/usr/env python3
import http.server
import socketserver
import io
import cgi
# Source: https://stackoverflow.com/questions/39788591/python-simplehttpserver-to-receive-files
# Upload using `curl -F 'file=@<FILENAME>' http://host:44444/`
# Change this to serve on a different port
$ dig +short myaccounts.towerhamlets.gov.uk
91.213.110.73
$ whois 91.213.110.73
% IANA WHOIS server
% for more information on IANA, visit http://www.iana.org
% This query returned 1 object
refer: whois.ripe.net
@vpetersson
vpetersson / gist:f20efe6194460cc28d49
Last active October 8, 2019 13:54
Parse and dump a sitemap (using Python)
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Inspired by Craig Addyman (http://www.craigaddyman.com/parse-an-xml-sitemap-with-python/)
Enhanced by Viktor Petersson (http://viktorpetersson.com) / @vpetersson
"""
from bs4 import BeautifulSoup
import requests
@vpetersson
vpetersson / paho-connect-wott.py
Last active July 11, 2019 15:42
Example code for how to use Paho to connect to an MQTT server (such as Mosquitto).
#!/usr/bin/env python
import paho.mqtt.client as mqtt
def on_connect(client, obj, flags, rc):
print("rc: " + str(rc))
def on_message(client, obj, msg):
print(msg.topic + " " + str(msg.qos) + " " + str(msg.payload))
@vpetersson
vpetersson / clean-pkg.sh
Last active June 14, 2019 16:17
Helper script for cleaning up pkg files
#!/bin/bash
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# -*- sh-basic-offset: 4 -*-
set -euo pipefail
IFS=$'\n\t'
if [[ -z ${1} ]]; then
echo "Package name must be used as the argument."
root@arm-lab:/usr/src/falco-0.1.1dev/bpf# make
make -C /lib/modules/4.19.36-v7+/build M=$PWD
make[1]: Entering directory '/mnt/src/linux'
clang -I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h \
-D__KERNEL__ -mlittle-endian \
\
-D__KERNEL__ \
-D__BPF_TRACING__ \
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-address-of-packed-member \
root@arm-lab:/usr/src/falco-0.1.1dev/bpf# make
make -C /lib/modules/4.19.36-v7+/build M=$PWD
make[1]: Entering directory '/mnt/src/linux'
clang -I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h \
-D__KERNEL__ -mlittle-endian \
\
-D__KERNEL__ \
-D__BPF_TRACING__ \
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-address-of-packed-member \
@vpetersson
vpetersson / net-benchmark.md
Last active March 15, 2018 13:50
Raspberry Pi 3 Model B vs Raspberry Pi 3 Model B+ - network benchmark

Intro

  • Raspberry Pi Model B+: 192.168.202.28
  • Raspberry Pi Model B: 192.168.202.30

Raspberry Pi 3 Model B+

$ cat /sys/class/net/eth0/speed
1000
@vpetersson
vpetersson / gist:6b1da35edbe3f7dc7ca4
Last active August 12, 2017 01:58
Example on how to create a 'Secret URL' for Nagios in Apache.
# Example from http://www.screenlyapp.com/use-cases/dashboard/nagios.html
ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
Alias /nagios3/stylesheets /etc/nagios3/stylesheets
Alias /nagios3 /usr/share/nagios3/htdocs
<Location /abc123>
# Hard code credentials
AuthBasicFake nagiosadmin nagiosadmin
#!/usr/bin/env python
import flicklib
import subprocess
from time import sleep
from copy import copy
@flicklib.move()
def move(x, y, z):