Skip to content

Instantly share code, notes, and snippets.

😎
¯\_(ツ)_/¯

Viktor Petersson vpetersson

😎
¯\_(ツ)_/¯
Block or report user

Report or block vpetersson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vpetersson
vpetersson / gist:f20efe6194460cc28d49
Last active Aug 21, 2019
Parse and dump a sitemap (using Python)
View gist:f20efe6194460cc28d49
#! /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 Jul 11, 2019
Example code for how to use Paho to connect to an MQTT server (such as Mosquitto).
View paho-connect-wott.py
#!/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 Jun 14, 2019
Helper script for cleaning up pkg files
View clean-pkg.sh
#!/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."
View ebpf-probe-clang7
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 \
View ebpf-probe-clang8
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 Mar 15, 2018
Raspberry Pi 3 Model B vs Raspberry Pi 3 Model B+ - network benchmark
View net-benchmark.md

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 Aug 12, 2017
Example on how to create a 'Secret URL' for Nagios in Apache.
View gist:6b1da35edbe3f7dc7ca4
# 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
View screenly-ose-with-flick.py
#!/usr/bin/env python
import flicklib
import subprocess
from time import sleep
from copy import copy
@flicklib.move()
def move(x, y, z):
View cam1.yml
machinery:
image: kerberos/machinery
ports:
- "8889"
restart: always
volumes:
- /media/ext0/kerberosio/cam1/capture:/etc/opt/kerberosio/capture
- /media/ext0/kerberosio/cam1/logs:/etc/opt/kerberosio/logs
- /media/ext0/kerberosio/cam1/config:/etc/opt/kerberosio/config
View cam0.yml
machinery:
image: kerberos/machinery
ports:
- "8889"
restart: always
volumes:
- /media/ext0/kerberosio/cam0/capture:/etc/opt/kerberosio/capture
- /media/ext0/kerberosio/cam0/logs:/etc/opt/kerberosio/logs
- /media/ext0/kerberosio/cam0/config:/etc/opt/kerberosio/config
You can’t perform that action at this time.