Skip to content

Instantly share code, notes, and snippets.

View iximiuz's full-sized avatar
🪲

Ivan Velichko iximiuz

🪲
View GitHub Profile
@iximiuz
iximiuz / index.md
Created April 19, 2025 18:03
iximiuz Labs tabbed content example (abridged)

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut purus eget sapien. Nulla facilisi.

::tabbed

tabs:

  • name: golang title: Go
  • name: python title: Python
  • name: javascript
#!/bin/sh
set -eu
ln -s / $HOME/.rootfs
curl -fsSL https://code-server.dev/install.sh | sh
mkdir -p $HOME/.local/share/code-server/User
cat <<EOF > $HOME/.local/share/code-server/User/settings.json
{
{"time": "2023-12-11T00:00:01.123Z", "method": "GET", "path": "/foo/bar", "status_code": 200, "content_length": 423}
{"time": "2023-12-11T00:01:01.123Z", "method": "POST", "path": "/foo/bar", "status_code": 200, "content_length": 553}
{"time": "2023-12-11T00:02:01.123Z", "method": "GET", "path": "/foo/baz", "status_code": 200, "content_length": 345}
{"time": "2023-12-11T00:03:01.123Z", "method": "GET", "path": "/foo/baz", "status_code": 401, "content_length": 235}
# syntax=docker/dockerfile:1
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
RUN <<EOF
set -eu
apt-get update
@iximiuz
iximiuz / net_lab_l3_to_l2_mapping.sh
Created March 18, 2021 08:46
Sets up IP subnets over a single Ethernet broadcast domain formed by a Linux bridge.
#!/usr/bin/env bash
set -euo pipefail
create_bridge() {
local nsname="$1"
local ifname="$2"
echo "Creating bridge ${nsname}/${ifname}"
@iximiuz
iximiuz / net_lab_simple_vlan.sh
Last active November 20, 2022 23:33
Configure VLAN tagging on a Linux bridge.
#!/usr/bin/env bash
set -euo pipefail
create_bridge() {
local nsname="$1"
local ifname="$2"
echo "Creating bridge ${nsname}/${ifname}"
@iximiuz
iximiuz / ethsend.py
Last active December 28, 2024 23:14
Send Ethernet frames from Python.
#!/usr/bin/env python3
# Usage: ethsend.py eth0 ff:ff:ff:ff:ff:ff 'Hello everybody!'
# ethsend.py eth0 06:e5:f0:20:af:7a 'Hello 06:e5:f0:20:af:7a!'
#
# Note: CAP_NET_RAW capability is required to use SOCK_RAW
import fcntl
import socket
import struct
@iximiuz
iximiuz / net_lab_broadcast_domains.sh
Last active January 13, 2024 22:17
A bunch of helper functions to create Linux bridges, network namespaces, and interconnect everything using veth pairs.
#!/usr/bin/env bash
set -xeuo pipefail
create_bridge() {
local nsname="$1"
local ifname="$2"
echo "Creating bridge ${nsname}/${ifname}"
#!/usr/bin/env python3
import json
import sys
for line in sys.stdin:
ds = eval(line)
print(json.dumps(ds))
@iximiuz
iximiuz / serv_async.py
Last active February 13, 2024 11:00
Python Web Servers
# python3
import asyncio
import sys
counter = 0
async def run_server(host, port):
server = await asyncio.start_server(serve_client, host, port)
await server.serve_forever()