Skip to content

Instantly share code, notes, and snippets.

View tolgahanakgun's full-sized avatar
😛
( ͡ ͡° ͜ ʖ ͡ ͡°) \╭☞

Tolgahan Akgun tolgahanakgun

😛
( ͡ ͡° ͜ ʖ ͡ ͡°) \╭☞
View GitHub Profile
@tolgahanakgun
tolgahanakgun / transcoder.py
Created March 11, 2025 22:02
H264 video transcoder
import os
import subprocess
import time
# This script is intended to transcode *.mkv files.
# It uses docker image from https://github.com/lisamelton/other_video_transcoding .
# It transcodes the videos inside the rootdir to max quality H264 mkv files.
# The docker container utilizes intel quick sync hardware encoder.
# This can be run inside a tmux session overnight.
@tolgahanakgun
tolgahanakgun / shell_notes.md
Last active March 10, 2025 20:09
Shell Notes

Foreach file in a directory loop

for file in $( find /path/to/dir -maxdepth 1 -type f -name "*.mp4" | sort ); do
    echo "$file"
done

Find duplicate files in a directory

find . ! -empty -type f -exec md5sum {} + | sort | uniq -w32 -dD
@tolgahanakgun
tolgahanakgun / git_notes.md
Last active February 17, 2025 09:48
Git Notes

Search history of a deleted/renamed file

git log --all --pretty=oneline --follow -- path/to/file.cc

Search a piece of code in all git history

# -I: ignore binary
# -F: fixed string
# -G: basic regex
@tolgahanakgun
tolgahanakgun / tftp.py
Created July 12, 2024 10:01
Single Python file TFTP server implementation with >32MB file support
# This code is based on https://github.com/m4tx/pyTFTP project
import os
import errno
import logging
import socket
import argparse
from pathlib import Path, PurePosixPath
from threading import Thread
from typing import List, NewType, Tuple, Union, Dict
@tolgahanakgun
tolgahanakgun / 10G_server.py
Last active December 13, 2023 13:50
Send 10GB random data via http requests to test the network throughput
#!/usr/bin/env python3
#
# -*- coding: utf-8 -*-
#
# curl -o /dev/null http://SERVER_IP:SERVER_PORT
# time printf 'GET / HTTP/1.1\n\n' | netcat SERVER_IP SERVER_PORT > /dev/null
import os
import argparse
@tolgahanakgun
tolgahanakgun / empty.py
Created November 1, 2023 08:42
Send empty reply for web scrapers
#!/usr/bin/env python3
#
# -*- coding: utf-8 -*-
#
import socket
import argparse
from ipaddress import ip_address
def run_server(ip: ip_address, port: int) -> None:
@tolgahanakgun
tolgahanakgun / 403.py
Last active August 5, 2024 16:02
Return a nice-looking "403 Forbidden" for all HTTP requests to web scrapers
#!/usr/bin/env python3
#
# -*- coding: utf-8 -*-
import socket
from email.utils import formatdate
from ipaddress import ip_address
import argparse
import socketserver
@tolgahanakgun
tolgahanakgun / gist:4a0a99979e684adcc0179329a6957caa
Created October 11, 2023 10:43
TLS 1.3 and SSH ciphersuites performance on Raspberry Pi4
tolgahan@rpi:~ $ uname -a
Linux rpi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
tolgahan@rpi:~ $ openssl version
OpenSSL 1.1.1w 11 Sep 2023
tolgahan@rpi:~ $ openssl speed -aead -evp aes-128-gcm
tolgahan@rpi:~ $ openssl speed -aead -evp aes-256-gcm
tolgahan@rpi:~ $ openssl speed -aead -evp chacha20-poly1305
type 2 bytes 31 bytes 136 bytes 1024 bytes 8192 bytes 16384 bytes
aes-128-gcm 1679.44k 18536.78k 29135.42k 36059.82k 36956.84k 37120.68k
aes-256-gcm 1365.87k 15148.50k 22993.66k 28058.28k 28740.27k 28813.99k
@tolgahanakgun
tolgahanakgun / relay_ssh_agent
Created March 28, 2023 17:24
Relay forwarded ssh-agent to docker
#!/bin/bash
set -ex
set -o pipefail
# THIS MUST BE USED WITH AN SSH-AGENT THAT SUPPORTS CONFIRMATION/NOTIFICATION UPON A SIGNATURE REQUEST.
# Mount the sock to the docker
# docker run --user $(id -u):$(id -g) --rm -it -v "$HOME/.ssh/sshsock:/sshsock" -e SSH_AUTH_SOCK=/sshsock/sock ubuntu bash
#!/usr/bin/env python3
"""Extend Python's built in HTTP server to save files
curl or wget can be used to send files with options similar to the following
curl -X PUT --upload-file somefile.txt http://localhost:8000
wget -O- --method=PUT --body-file=somefile.txt http://localhost:8000/somefile.txt
__Note__: curl automatically appends the filename onto the end of the URL so
the path can be omitted.
Windows upload & download
powershell -ep bypass -c "$wc=New-Object Net.WebClient;$wc.UploadFile('http://target.com/upload.bin', 'PUT', 'c:\\upload.bin');"