Skip to content

Instantly share code, notes, and snippets.

View progmult's full-sized avatar
🏠
Working from home

Andrey Kapustin progmult

🏠
Working from home
View GitHub Profile
@progmult
progmult / git_branch_merge.bat
Last active September 1, 2024 15:57
Batch script to automate merging many Git branches to master
@echo off
chcp 65001 > nul
setlocal enabledelayedexpansion
:: Fetching the latest changes from the remote repository
git fetch --all
:: Switching to the master branch and getting the latest changes
git switch master
git reset --hard origin/master
@progmult
progmult / git_branch_release.bat
Last active September 1, 2024 15:55
Batch script to automate creation of Git release branch, merge features, and copy push command to clipboard.
@echo off
chcp 65001 > nul
setlocal enabledelayedexpansion
:: Fetching latest changes from remote repository
git fetch --all
:: Finding the latest release branch number
set latestReleaseNumber=0
for /f "tokens=2 delims=-" %%j in ('git branch -r --list "origin/release-*"') do (
@progmult
progmult / convert_utf8.sh
Created August 30, 2021 16:57
convert_utf8.sh
# convert windows-1251 files to utf-8 in folder recursive.
# creates "_backup" folder with original files
# check if file is already encoded
for f in $(find . -name "*.css");
do
if file --mime-encoding $f | grep -wqe "iso-8859-1" -e "unknown-8bit"
then
mkdir -p _backup/$(dirname ${f})
cp $f ./_backup/$(dirname ${f})
@progmult
progmult / EYearFDate
Last active March 21, 2019 16:00
Первое сентября текущего учебного года
/**
* @return false|int Unix Timestamp первого сентября текущего учебного года
*/
function EYearFDate()
{
$format = 'd.m.Y';
$EYearFDate = '01.09.' . date('Y');
if (time() < strtotime($EYearFDate)) $EYearFDate = '01.09.' . (date('Y') - 1);
return strtotime($EYearFDate);
# convert video to telegram autoplay (not as file)
ffmpeg -i input.mp4 -c:v libx264 -crf 26 -vf scale=640:-1 out.mp4
# convert vertical video to horizontal video with blur on both sides
ffmpeg \
-i Sequence02.mpeg \
-i Sequence02.mpeg \
-filter_complex \
"[0:v]scale=-1:720[scaled_video]; \
[1:v]scale=1280:720,boxblur=16[blur_image];\
@progmult
progmult / format-phone-function.php
Created February 22, 2019 14:07
Возвращает отформатированный номер телефона, в виде 8 (987) 123-45-67, можно передавать несколько номеров
<?php
/**
* Возвращает отформатированный номер телефона, в виде 8 (987) 123-45-67
* Если введено несколько номеров (через запятую и т.д.), разделяет результат.
* @param string $phone телефон (возможно несколько номеров через запятую, точку с запятой, слеш или перенос строки)
* @param string $delimiter разделитель результата при возврате ("<br/>" по-умолчанию)
*/
function formatPhone($phone,$delimiter = '<br/>') {
$phone = str_replace(', ', ',', $phone);
$phone = str_replace('; ', ';', $phone);
@progmult
progmult / backup.php
Last active August 8, 2018 03:01 — forked from menzerath/backup.php
PHP: Recursively Backup Files & Folders to ZIP-File
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* MIT-License - Copyright (c) 2012-2017 Marvin Menzerath
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit','1024M');
@progmult
progmult / nginx-pma.conf
Last active November 11, 2016 16:06 — forked from denys281/nginx.conf
phpmyadmin nginx virtual host (php-fpm) freebsd
server {
# Listen on port 81
listen 81;
# Server name being used (exact name, wildcards or regular expression)
# server_name phpmyadmin.my;
root /usr/local/www/phpMyAdmin;
@progmult
progmult / allow_mysql.sh
Created November 9, 2016 14:37
Allow mysql external connection for IP of current ssh-session (if dynamic ip)
ssh_client_ip=`echo $SSH_CLIENT | awk '{ print $1}'`;
ipfw -q add 00431 allow tcp from $ssh_client_ip to me 3306 in via em0 keep-state