Skip to content

Instantly share code, notes, and snippets.

View zolbooo's full-sized avatar

Oleg zolbooo

View GitHub Profile
#!/usr/bin/env python3
"""Scrub sensitive values in a JSON file.
Usage:
python scrub.py <file> <json_path>
The JSON path supports:
- JSON Pointer (e.g. `/env`)
- Dot notation (e.g. `env` or `users[0].token`)
"""
@zolbooo
zolbooo / sandbox.py
Created January 29, 2026 08:33
Run untrusted Python scripts within the seccomp sandbox
# /// script
# dependencies = ["pyseccomp"]
# ///
import sys
try:
import seccomp
except ImportError:
import pyseccomp as seccomp
@zolbooo
zolbooo / packer-cookbook.md
Created October 1, 2024 10:09
Cookbook for a GCE VM with prebuilt image

Packer VM cookbook for GCP

This cookbook is used to create a VM image for GCP using Packer.

1. Packer recipe

packer {
  required_plugins {
    googlecompute = {
@zolbooo
zolbooo / read-qr-multiprocessing.py
Last active April 12, 2023 04:44
Read QR codes in parallel with progress
import cv2
qcd = cv2.QRCodeDetector()
def read_qr(user):
filename = user['images'][1]
image = f'mount-folder/kyc/images/{filename}'
try:
data, points, _ = qcd.detectAndDecode(cv2.imread(image))
if points is None:
return (user, None)
return (user, data)
@zolbooo
zolbooo / blink.rs
Created August 16, 2022 07:32
RGB LED blink example for nanoESP32-S3
@zolbooo
zolbooo / snake.cpp
Created November 16, 2021 11:43
Linux/MacOS console implementation of snake game
#include <iostream>
#include <vector>
#include <chrono>
#include <thread>
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
@zolbooo
zolbooo / segment_tree.cpp
Last active April 17, 2021 15:28
Segment tree implementation on C++
#include <iostream>
#include <cassert>
#include <vector>
using namespace std;
struct tree_node {
int value;
int l, r;
tree_node *left, *right;
@zolbooo
zolbooo / lucas_algorithm.cpp
Created April 12, 2021 07:17
Calculate binomial coefficient mod prime number p using Lucas theorem
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdint>
#include <vector>
#include <stack>
#include <map>
using namespace std;
@zolbooo
zolbooo / shagai.py
Created September 11, 2020 05:38
Probability calculation using Monte-Carlo method
from typing import Callable, Sequence
from random import randint
def monte_carlo_3_plus_1(n: int) -> float:
i = 0
positive = 0
while i < n:
counts = [0] * 4
a1 = randint(0, 3)
counts[a1] += 1
@zolbooo
zolbooo / hackateen-challenge-1-writeup.md
Last active July 25, 2021 13:44
Hackateen - challenge #1 writeup

Hackateen challenge #1

Pairs

Time limit: 1 second
Memory limi​t: 64 megabytes

Танд n ширхэг бүхэл тоонууд өгөгдсөн бол нийлбэр нь k байдаг нийт хэдэн ширхэг ялгаатай хос