Skip to content

Instantly share code, notes, and snippets.

Avatar

Ondřej Caletka oskar456

View GitHub Profile
@oskar456
oskar456 / screencast.sh
Last active Aug 3, 2018
FFmpeg record my desktop
View screencast.sh
#!/bin/sh
SCREEN_SIZE="1920x1080"
ORIGIN="0,0"
# For dual screen setup where projected is on the right side of the desktop:
#ORIGIN="1920,0"
ffmpeg -vaapi_device /dev/dri/renderD128 -framerate 25 -video_size $SCREEN_SIZE \
-f x11grab -i :0+$ORIGIN -f pulse -ac 2 -i default -vf 'format=nv12,hwupload' \
-c:v h264_vaapi -c:a aac screencast-$(date +%H%M%S).mkv
@oskar456
oskar456 / ledclock.py
Created May 1, 2018
PyGTK Cairo LED studio clock
View ledclock.py
#! /usr/bin/env python2
import pygtk
pygtk.require('2.0')
import gtk
import glib
import cairo
import math
import datetime
# Create a GTK+ widget on which we will draw using Cairo
@oskar456
oskar456 / ctlogspotter.py
Created Apr 13, 2018
Preprocess Certificate Transparency log list for Cert Spotter
View ctlogspotter.py
#!/usr/bin/env python3
import requests
import json
log_list = "https://www.gstatic.com/ct/log_list/log_list.json"
logs = requests.get(log_list).json()
outlogs = []
for log in logs["logs"]:
@oskar456
oskar456 / ctlogids.py
Last active Mar 28, 2018
Show Certificate Transparency Log IDs compatible with OpenSSL output
View ctlogids.py
#!/usr/bin/env python3
import requests
import hashlib
import base64
log_list = "https://www.gstatic.com/ct/log_list/all_logs_list.json"
logs = requests.get(log_list).json()
for log in logs['logs']:
@oskar456
oskar456 / fixmime.py
Created Jan 4, 2018
Milter to fix badly formatted MIME messages
View fixmime.py
#!/usr/bin/env python3
import email
from email.mime.multipart import MIMEMultipart
import sys
from subprocess import Popen, PIPE
def reformat(msg):
"""Reformat the MIME parts of the message to a sane one."""
newmsg = MIMEMultipart()
@oskar456
oskar456 / py6server.py
Created Dec 5, 2017
Simple Python-based HTTP Server with IPv6 support
View py6server.py
#!/usr/bin/env python3
import http.server
import socketserver
import socket
class TCP6Server(socketserver.TCPServer):
address_family = socket.AF_INET6
def server_bind(self):
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
@oskar456
oskar456 / mathpractice.py
Last active May 30, 2018
Generate a sheet of random math add/subtraction problems for a pre-school child
View mathpractice.py
#!/usr/bin/env python3
import random
import operator
def generate_problem(min_op=1, max_op=9, min_res=0, max_res=10):
operators = [operator.add, operator.sub]
while True:
opa = random.choice(range(min_op, max_op+1))
opb = random.choice(range(min_op, max_op+1))
oper = random.choice(operators)
@oskar456
oskar456 / dns_compact.py
Created Sep 28, 2017
RIPE Atlas tools custom DNS renderer with compact output (1 result per line)
View dns_compact.py
# Copyright (c) 2017 Ondrej Caletka <ondrej@caletka.cz>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@oskar456
oskar456 / rpz_unbound.sh
Last active May 6, 2020
RPZ policy for unbound - transform RPZ zone into local zone statements
View rpz_unbound.sh
#!/bin/bash
RPZ_ZONE="rpz.cesnet.cz"
RPZ_SERVER="nsa.cesnet.cz"
OUTPUT_FILE="unbound_$RPZ_ZONE.conf"
function resolve_target() {
local domain="$1"
shift
@oskar456
oskar456 / blinkclock-init.sh
Created Nov 22, 2016
LED blink clock – flash LED every second
View blinkclock-init.sh
#!/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"
You can’t perform that action at this time.