Skip to content

Instantly share code, notes, and snippets.

View ChronoMonochrome's full-sized avatar

Victor Shilin ChronoMonochrome

  • Russian Federation, Stavropol
View GitHub Profile
@ChronoMonochrome
ChronoMonochrome / repo_changes.py
Last active April 27, 2024 08:27
Python script to find uncommitted / unpushed changes in git repositories managed by repo
import os
import subprocess
import xml.etree.ElementTree as ET
import traceback
def get_repo_paths_and_names(manifest_path):
"""Parses the given repo manifest file to extract repository paths and names.
Args:
manifest_path (str): Path to the repo manifest file (.xml).
/* ==UserStyle==
@name habr.com
@version 20240410.12.23
@namespace ?
==/UserStyle== */
@-moz-document domain("habr.com") {
body,
html {
background-color: #181818;
color-scheme: dark;
@ChronoMonochrome
ChronoMonochrome / fb_scrape.py
Last active February 17, 2024 15:00
Facebook profile photo downloader
import argparse
import code
import errno
import getpass
import os
import re
import time
from io import BytesIO
from PIL import Image
from base64 import b64decode
@ChronoMonochrome
ChronoMonochrome / pawp_rtsp_stream.py
Last active January 6, 2024 05:44
Python script for recording audio from speakers and streaming over RTSP
"""
A simple example of recording audio from speakers and streaming over RTSP protocol.
Requires pyaudiowpatch and RTSP server, e.g. https://github.com/bluenviron/mediamtx
"""
import pyaudiowpatch as pyaudio
import subprocess
import time
import wave
@ChronoMonochrome
ChronoMonochrome / create_video.py
Last active April 7, 2024 17:05
Python script to create video from the specified audio track and an image
import argparse
import numpy as np
from PIL import Image
from moviepy.editor import *
import os
import errno
TARGET_WIDTH = 1920
TARGET_HEIGHT = 1080
TARGET_FPS = 24
@ChronoMonochrome
ChronoMonochrome / wlan.cpp
Last active August 10, 2023 18:58
Wifi tethering on Windows
#include <Windows.h>
#include <wlanapi.h>
#include <iostream>
#pragma comment(lib, "wlanapi.lib")
typedef DWORD(WINAPI* P_WlanOpenHandle)(DWORD, PVOID, PDWORD, PHANDLE);
typedef DWORD(WINAPI* P_WlanCloseHandle)(HANDLE, PVOID);
typedef DWORD(WINAPI* P_WlanHostedNetworkStartUsing)(HANDLE, PWLAN_HOSTED_NETWORK_REASON, PVOID);
typedef DWORD(WINAPI* P_WlanHostedNetworkStopUsing)(HANDLE, PWLAN_HOSTED_NETWORK_REASON, PVOID);
@ChronoMonochrome
ChronoMonochrome / merge_frames.py
Created June 2, 2023 08:20
Image stitching with OpenCV
import cv2
from PIL import Image
import numpy as np
def cv2_estimate_dx_dy(prev_filename, curr_filename):
"""
Calculates dx and dy using OpenCV script for two consecutive frames
"""
# Load the previous and current frames
prev_frame = cv2.imread(prev_filename, cv2.IMREAD_GRAYSCALE)
@ChronoMonochrome
ChronoMonochrome / SSH port forwarding cheatsheet.md
Last active May 25, 2023 16:18
A quick reminder for myself how to expose a local machine using an intermediate server

Quick start

Forward port 22 on local machine as server:22222

ssh -R 22222:localhost:22 server_user@server -p PORT

Expose this port on the server to the world using socat *

socat TCP-LISTEN:22223,fork,bind=0.0.0.0 TCP:localhost:22222

Now you can connect to the local machine from outside of the local network

ssh local_user@server -p 22223

@ChronoMonochrome
ChronoMonochrome / video_ssim_search.py
Created May 1, 2023 10:29
A script to search frame in video using SSIM (structural similarity image comparison)
from time import time
import av
import cv2
import numpy as np
from PIL import Image
from SSIM_PIL import compare_ssim
# Load reference image and get its dimensions
ref_img = cv2.imread("preroll_end2_cropped.png")
ref_height, ref_width, _ = ref_img.shape
@ChronoMonochrome
ChronoMonochrome / binpatch.py
Created November 25, 2022 12:54
Patch Windows EXE (DLL) with python script
import os
import shutil
import subprocess
import tempfile
from pwnlib.log import getLogger
log = getLogger(__name__)
def _run(cmd, stdin = None):