Skip to content

Instantly share code, notes, and snippets.

View dbalabka's full-sized avatar
🔍
Search for opportunities

Dmitry Balabka dbalabka

🔍
Search for opportunities
View GitHub Profile
@dbalabka
dbalabka / Installation.md
Last active March 12, 2024 09:45
Send notification from Windows WSL console similar to original Linux notify-send command 🎶🔔
  1. Create a file in C:\bin\toast.ps1 from source https://gist.github.com/dend/5ae8a70678e3a35d02ecd39c12f99110:
    curl https://gist.githubusercontent.com/dend/5ae8a70678e3a35d02ecd39c12f99110/raw -o /mnt/c/bin/toast.ps1
  2. Create ~/.local/bin/notify-send from the following source:
    powershell.exe "& { . C:\\bin\\toast.ps1; Show-Notification -ToastTitle \"$1\" -ToastText \"$2\" }"
    like this:
@dbalabka
dbalabka / regexp_trigger.txt
Created June 27, 2023 22:50
RegExp for all official GA4 events
# See https://support.google.com/analytics/answer/9267735?hl=en
^(add_payment_info|add_shipping_info|add_to_cart|add_to_wishlist|begin_checkout|generate_lead|purchase|refund|remove_from_cart|select_item|select_promotion|view_cart|view_item|view_item_list|view_promotion)$
@dbalabka
dbalabka / ffmpeg-speech-quality-enhancement.sh
Created June 13, 2023 07:50
Enhance speech quality for video with single pass using ffmpeg. Read more: https://superuser.com/a/1643035/913241
# Make the video shorter to perform an experiment quicker
docker run --rm -it -v $(pwd):/config linuxserver/ffmpeg:latest -ss 840 -i /config/source.mp4 -c copy -t 120 /config/source-short.mp4
# See https://superuser.com/a/1643035/913241
docker run --rm -it -v $(pwd):/config linuxserver/ffmpeg:latest -i /config/source-short.mp4 -filter:a "speechnorm=e=25:r=0.0001:l=1,highpass=200,lowpass=3000,afftdn" /config/source-short-louder-wo-noise.mp4
@dbalabka
dbalabka / bootstrap_compare_mean.py
Last active May 2, 2021 08:56
Bootstrapping hypothesis testing of mean equality using Efron's algorithm
from math import sqrt
from typing import Tuple
import numpy as np
import time
import numba
from scipy.stats import ttest_ind
@numba.njit(parallel=True, fastmath=True, nogil=True)
def compare_mean(z: np.ndarray, y: np.ndarray, n_samples: int = 10_000) -> Tuple[np.ndarray, float, float]:
@dbalabka
dbalabka / bootstrap_compare_dist.py
Created May 1, 2021 11:19
Bootstrapping hypothesis testing of distribution equality using Efron's alghoritm
from typing import Tuple
import numpy as np
import time
import numba
from scipy.stats import mannwhitneyu
@numba.njit(parallel=True, fastmath=True, nogil=True)
def compare_dist(z: np.ndarray, y: np.ndarray, n_samples: int = 10_000) -> Tuple[np.ndarray, float, float]:
@dbalabka
dbalabka / jackknife_numba.py
Last active April 22, 2021 11:14
scikits-bootstrap Jackknife resampling with Numba and performance testing
import scikits.bootstrap as bootstrap
import numpy as np
import time
import numba
@numba.njit(parallel=True, fastmath=True)
def _calculate_jackknife_mean_stat(data: np.ndarray) -> np.ndarray:
n = data.shape[0]
jstat = np.zeros(n)
sum = data.sum()
@dbalabka
dbalabka / bootstrap_numba.py
Last active April 22, 2021 11:14
scikits-bootstrap Bootstrapping resampling with Numba and performance testing
import scikits.bootstrap as bootstrap
import numpy as np
import time
import numba
@numba.njit(parallel=True, fastmath=True)
def _calculate_boostrap_mean_stat(data: np.ndarray, n_samples: int) -> np.ndarray:
n = data.shape[0]
stat = np.zeros(n_samples)
for i in numba.prange(n_samples):
@dbalabka
dbalabka / ttfb.sh
Last active June 2, 2020 10:43 — forked from sandeepraju/ttfb.sh
cURL command to check the request timing (including TTFB)
#!/bin/bash
# file: ttfb.sh
# curl command to check the time to first byte
# ** usage **
# 1. ./ttfb.sh "https://google.com"
# 2. seq 10 | xargs -Iz ./ttfb.sh "https://google.com"
curl -o /dev/null \
-H 'Cache-Control: no-cache' \
-s \
@dbalabka
dbalabka / main.dart
Created October 1, 2019 18:32
Bidirectional type inference in dart
void main() {
print(foo('bar'));
// will rise an error
foo(1);
}
foo ($s) {
return 'foo' + $s;
}
@dbalabka
dbalabka / ignore_notices_warning_selectively_test.php
Created July 22, 2019 09:23
iddqd for PHP to ignore notices and warning selectively, while using Symfony ErrorHandler. Helps to upgrade PHP smoothly.
<?php
use Symfony\Component\Debug\BufferingLogger;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Debug\ErrorHandler;
$loader = require_once __DIR__ . '/vendor/autoload.php';
class ConfigurableErrorHandler extends ErrorHandler
{