Skip to content

Instantly share code, notes, and snippets.

@DavidVentura
DavidVentura / tap-linux.py
Created August 2, 2021 21:18 — forked from makcuk/tap-linux.py
A simple python tun/tap udp tunnel example
# Simple linux tun/tap device example tunnel over udp
# create tap device with ip tuntap add device0 tap
# set ip address on it and run tap-linux on that device and set desitation ip
# run same on another node, changing dst ip to first node
import fcntl
import struct
import os
import socket
import threading
@DavidVentura
DavidVentura / file.html
Created May 2, 2021 17:27
explore size in pinetime
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Linker map</title>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.3.1.min.js" integrity="sha384-YF85VygJKMVnHE+lLv2AM93Vbstr0yo2TbIu5v8se5Rq3UQAUmcuh4aaJwNlpKwa" crossorigin="anonymous"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
</script>
</head>
@DavidVentura
DavidVentura / wrapper.py
Created August 24, 2020 17:56
Stackable attributes in a function wrapper
from functools import wraps
def autocomplete(key, complete_fn):
def deco(f):
@wraps(f)
def wrapper(*args, **kwargs):
return f(*args, **kwargs)
if hasattr(wrapper, 'complete_fn'):
wrapper.complete_fn[key] = complete_fn
@DavidVentura
DavidVentura / bootable_gpt.md
Created February 2, 2020 21:30
bootable gpt disk image

Create the following disk partition table (GPT, EFI, Linux)

$ fdisk -l disk.img
Disklabel type: gpt
Disk identifier: 68CF21FF-A7D8-EA4F-84BF-2C1395E85E87

Device     Start    End Sectors  Size Type
disk.img1   2048  43007   40960   20M EFI System
disk.img2  43008 409566  366559  179M Linux filesystem
@DavidVentura
DavidVentura / losetup.py
Created January 26, 2020 22:04
loopback device setup/teardown/offset in python
import ctypes
import fcntl
SetStatus64 = 0x4C04
GetStatus64 = 0x4C05
CLR_FD = 0x4C01
SET_FD = 0x4C00
NameSize = 64
KeySize = 32
@DavidVentura
DavidVentura / gstseamlessloop.py
Created May 30, 2017 03:45 — forked from sphaero/gstseamlessloop.py
Gstreamer seamless loop test
#/usr/bin/env python3
#
# Seamless loop test
# Copyright (c) 2015 Arnaud Loonstra <arnaud@sphaero.org>
#
# This 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.
#
#!/usr/bin/env python3
import csv
import requests
from bs4 import BeautifulSoup
f = open("dalmo.csv", "w")
csvwriter = csv.writer(f)
r = requests.post("http://www.acara.org.ar/guiaprecios/ver_precios.php", data={ "marID": '0' })
soup = BeautifulSoup(r.text, 'html.parser')
@DavidVentura
DavidVentura / LXC-to-Proxmox.sh
Last active May 10, 2018 21:50
Migrate LXC to Proxmox 4
#!/bin/bash
set -e
if [ "$UID" -ne 0 ]; then
echo "Run as root"
exit 1
fi
#CONFIGURE THIS OR IT WON'T WORK
IMAGES_ROOT="/esp/images"