Skip to content

Instantly share code, notes, and snippets.

View nggit's full-sized avatar
💭
alele...

nggit nggit

💭
alele...
View GitHub Profile
@nggit
nggit / expandsrtrange.sh
Last active July 7, 2023 02:12
Expand subtitle (srt) range
#!/usr/bin/env sh
INFILE="file.srt"
OUTFILE="out-$INFILE"
START=
tac "$INFILE" | while IFS= read -r line; do
if sub_range="$( echo "$line" | grep " --> " )"; then
END="$( echo "$sub_range" | cut -d" " -f3 )"
@nggit
nggit / eventloop.php
Last active January 14, 2024 21:18
A simple event loop with Fibers (PHP 8 >= 8.1.0)
<?php
// a simple event loop with Fibers (PHP 8 >= 8.1.0)
// in a style slightly inspired by Python's asyncio
// this will not immediately increase the throughput of your code
// since the functions are still executed sequentially in the event loop
// unless you can combine it with a non-blocking stream/socket
// to create the impression of io parallelism