Skip to content

Instantly share code, notes, and snippets.

@oskar456
oskar456 / kmlbbox.py
Created May 9, 2014 19:49
KML bounding box
#!/usr/bin/env python3
import lxml.etree
tree = lxml.etree.parse('pl.kml')
root = tree.getroot()
ns= 'http://earth.google.com/kml/2.1'
pmarks = tree.findall('//{{{0}}}Placemark'.format(ns))
for pmark in pmarks:
coor= pmark.find('{{{0}}}Point/{{{0}}}coordinates'.format(ns))
long, lat, alt = (float(x) for x in coor.text.split(',',3))
@oskar456
oskar456 / icecast.cgi
Created June 14, 2014 16:25
MPEG TS to IceCast CGI script
#!/usr/bin/env python
import subprocess
import shlex
import sys
import signal
sys.stdout.write("""Content-Type: audio/mpeg\r
icy-br:192\r
ice-audio-info: ice-samplerate=48000;ice-bitrate=192;ice-channels=2\r
@oskar456
oskar456 / czalloc.sh
Last active August 29, 2015 14:10
Czech IP allocations from RIPE NCC
#!/bin/bash
allocurl="ftp://ftp.ripe.net/pub/stats/ripencc/membership/alloclist.txt"
#The workdir have to exist and be empty! It's content will be deleted after each run.
workdir="/var/tmp/czalloc"
function alloc2lir() {
local dstdir="$1"
local lirfile=""
while read line; do
@oskar456
oskar456 / findword.py
Last active August 29, 2015 14:19
Find a word that consists of certian letters in dictionary (a.k.a. 4 Pics 1 Word helper)
#!/usr/bin/env python3
import argparse
import collections
import re
parser = argparse.ArgumentParser(
description='Find a word consisting of certain letters in dictionary'
)
parser.add_argument('letters',
@oskar456
oskar456 / ifcfg-eth0
Created May 2, 2013 14:27
OpenSUSE Policy Based Routing for IPv6
BOOTPROTO='static'
IPADDR='2001:718:1:fff0:50:56ff:feef:4/64'
STARTMODE='onboot'
NAME='VMXNET3 Ethernet Controller MGMT'
PRE_UP_SCRIPT='local-disablera'
POST_UP_SCRIPT='local-postup-pbr6'
PRE_DOWN_SCRIPT='local-predown-pbr6'
LOCAL_PBR6_PRIO='40001'
LOCAL_PBR6_DEFAULTPRIO='60001'
@oskar456
oskar456 / ripe-db-demo-VM-in-KVM
Last active December 25, 2015 18:49
Run Sample RIPE DB virtual Appliance under QEMU on Gentoo Linux. Before first start, coverting VMDK to QCOW2 disk image is needed. To watch VM console, open VNC viewer to localhost:42
qemu-img convert -O qcow2 -o preallocation=off -p RIPEDB-disk1.vmdk RIPEDB-disk1.qcow2
@oskar456
oskar456 / ipnetworks.py
Created August 30, 2012 07:03
GrepCIDR in Python
#!/usr/bin/env python
import ipaddr
class IPNetworks():
"""Represent a set of IP ranges.
Support testing if an IP addres matches any prefix by simple
networks = IPNetworks(['10.0.0.0/8','192.168.0.0/16'])
'10.20.30.40' in networks #True
"""
@oskar456
oskar456 / authenticatordb2qr.sh
Created May 15, 2016 16:55
Recover installation QR codes from Google Authenticator App DB
#!/bin/sh
echo "select original_name, secret, issuer from accounts;" |\
sqlite3 authenticator.sqlite |\
sed -rn 's_^([^|]+)\|([^|]+)\|(.+)$_otpauth://totp/\1?secret=\2\&issuer=\3_p' |\
while read line
do
ttyqr $line
echo $line
echo ""
@oskar456
oskar456 / emailer.py
Last active October 31, 2016 15:10
LinuxDays e-mailer
#!/usr/bin/env python3
import email.mime.text
import email.utils
import email.header
import smtplib
import copy
import sys
import re
import argparse
@oskar456
oskar456 / blinkclock-init.sh
Created November 22, 2016 09:53
LED blink clock – flash LED every second
#!/bin/sh /etc/rc.common
# Copyright (C) 2016 OpenWrt.org
START=99
USE_PROCD=1
start_service()
{
procd_open_instance
procd_set_param command "/root/blinkclock.py"