Skip to content

Instantly share code, notes, and snippets.

View ephrin's full-sized avatar
🎯
Focusing

Volodymyr Myrza ephrin

🎯
Focusing
  • Vinnytsia/Ukraine
View GitHub Profile
<?php
function testEndpoint($url, $iterations = 100)
{
$times = [];
for ($i = 0; $i < $iterations; $i++) {
$start = microtime(true);
$ch = curl_init();
@ephrin
ephrin / mkv2mp4.sh
Created November 10, 2024 11:08
Convert every mkv in the directory found to mp4 via ffmpeg. Linux. Video. mkv to mp4.
for i in *.mkv; do ffmpeg -i "$i" -c:v copy -c:a copy "${i%.mkv}.mp4"; done
@ephrin
ephrin / MessageBus.php
Created August 30, 2024 11:20
bus with smart handling
<?php
class MessageBus
{
private LoggerInterface $logger;
public function __construct(LoggerInterface $logger = null)
{
$this->logger = $logger ?? new NullLogger();
}
#!/bin/bash
adjectives=(
"admiring" "adoring" "affectionate" "agitated" "amazing" "angry" "awesome"
"blissful" "boring" "brave" "clever" "cocky" "compassionate" "competent"
"condescending" "confident" "cranky" "dazzling" "determined" "distracted"
"dreamy" "eager" "ecstatic" "elastic" "elated" "elegant" "eloquent" "epic"
"fervent" "festive" "flamboyant" "focused" "friendly" "frosty" "gallant"
"gifted" "goofy" "gracious" "happy" "hardcore" "heuristic" "hopeful"
"hungry" "infallible" "inspiring" "interesting" "intelligent" "jovial"
ca_certs:
remove_defaults: false
trusted:
- |
-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
@ephrin
ephrin / gist:bf6371f3790c95e998f10f5ba2332b44
Created March 15, 2024 10:48
Grok postfix Datadog rules
queued %{date("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZZ"):date} %{notSpace:hostname} %{notSpace:source}/%{notSpace:proc}\[%{integer:op}\]\: %{notSpace:procCode}\: %{data:attr:keyvalue} \(%{data:message}\)
cleaned %{date("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZZ"):date} %{notSpace:hostname} %{notSpace:source}/%{notSpace:proc}\[%{integer:op}\]\: %{notSpace:procCode}\: %{data:attr:keyvalue}
daemon %{date("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZZ"):date} %{notSpace:hostname} %{notSpace:source}/%{notSpace:proc}\[%{integer:op}\]\:\s+%{data:message}
@ephrin
ephrin / filler.sh
Last active January 24, 2024 16:13
#!/bin/bash
# Directory to fill with files
DIR=$1
# Threshold for free space in KB
THRESHOLD=${2:-104857} # Default is 100MB
# Size of each file in KB
FILESIZE=5120 # 5MB
@ephrin
ephrin / dotenv.sh
Last active December 3, 2023 11:52
eval and substitute from prototype env file
#!/bin/bash
# Default values for source and output files
env_example=".env.example"
env_output=".env"
# Flag to ask for confirmation for each variable (enabled by default)
ask_each_var=1
# Function to display help message
@ephrin
ephrin / traverse.js
Created January 12, 2023 09:13 — forked from sphvn/traverse.js
Recursively traverse object javascript, recurse json js, loop and get key/value pair for JSON
var traverse = function(o, fn) {
for (var i in o) {
fn.apply(this,[i,o[i]]);
if (o[i] !== null && typeof(o[i])=="object") {
traverse(o[i], fn);
}
}
}
// usage
@ephrin
ephrin / mongo-repl-log.js
Created November 16, 2022 14:49
MongoDB Replication Log from mongosh CLI
db.adminCommand( { getLog:'global'} ).log.forEach(x => { var l = JSON.parse(x); if(l.c === "REPL") {console.log(l)}})