Skip to content

Instantly share code, notes, and snippets.

fopina /
Created October 22, 2021 23:55
python: split list into fixed number of evenly distributed sublists
Googling a solution for this seems to always end with [numpy array_split](
This avoids having numpy as dependency just for this
def array_split(array, parts):
split an array into parts arrays, evenly size
>>> list(array_split(list(range(12)), 10))
fopina /
Created September 3, 2021 01:01
onion-pi setup (reversed, WiFi as WAN)

Walkthrough to setup a raspberry pi as an onion router. Pretty much like onion-pi but WiFi as WAN instead (bonus: no hostapd required).

As a Pi0w or a Pi1 can easily be powered by the laptop USB, this setup makes a TOR-WiFi (bulky) dongle out of a Pi!!

This should (will?) be converted into an ansible playbook (or even pre-cooked image)


  • Download latest raspios
  • Dump it on an sd card, eg:
fopina /
Created August 12, 2021 22:56
customize networking in vmware fusion 12 *community* edition

After so many years with VMWare Player being free for Windows and Linux, VMware finally released a free/community version of Fusion!

One of the main restrictions in the free version is that you cannot create/edit any networks.
But sometimes you need that little change such as using a different network range on your VMware NAT interface or the Host-only one.

It's quite easy after all. The settings are stored in /Library/Preferences/VMware Fusion/networking:

answer VNET_1_DHCP yes
fopina /
Last active August 11, 2022 05:39
SD Card Speed Test (from Raspberry Pi Agnostics package)
#NAME=SD Card Speed Test
#DESC=Determines whether an SD card can read and write data fast enough to provide adequate performance.\n\nShould be run on a new or newly-formatted SD card.
# Original at
# run with
# curl -s | sudo bash -
# default test file location will be in /var/tmp, you can choose other directory as first parameter of the script
# curl -s | sudo bash -s /mnt/usb
fopina /
Created May 28, 2020 10:01
pytest-django --debug-sql
__force_django_debug = False
def pytest_runtest_setup():
if __force_django_debug:
# required for logging SQL as pytest always sets DEBUG to False (why?)
from django.conf import settings
settings.DEBUG = True
- hosts: all
gather_facts: True
become: True
- role: fluentbit
- systemd:
- Tag: docker
- Systemd_Filter: _SYSTEMD_UNIT=docker.service
- cpu:
fopina / handlers_main.yml
Created July 9, 2019 23:18
fluentbit ansible role
- name: Restart Fluentbit
name: td-agent-bit
enabled: true
state: restarted
fopina /
Last active January 8, 2022 17:30 quick tester
# directly from
import concurrent.futures
import urllib.request
def check_port(port):
print('testing %d \r' % port, end='')
# smaller response text!
r = urllib.request.Request('' % port, headers={'User-Agent': 'curl'})
fopina /
Last active January 8, 2022 17:30
Poor Man's Lenticular
#!/usr/bin/env python
import argparse
from PIL import Image
package main
import (
const (