Skip to content

Instantly share code, notes, and snippets.

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

Aliaksei Sanikovich asanikovich

🏠
Working from home
View GitHub Profile
@asanikovich
asanikovich / Install-xdebug-php7.1.md
Last active May 24, 2018 14:45 — forked from hollodotme/Install-php7.md
Installing xdebug for php7.1 on Ubuntu 14.04

Install xdebug extension

# Download stable release of xdebug from https://xdebug.org/download.php
wget -c "https://xdebug.org/files/xdebug-2.5.3.tgz"
# Extract archive
tar -xf xdebug-2.5.3.tgz

cd xdebug-2.5.3/
@asanikovich
asanikovich / rets.php
Created April 20, 2017 15:37
RETS implementation for CRMLS
<?php namespace App\Lib;
/**
* This class is customized specifically for the CRMLS
* ( California Regional Multiple Listing Service )
*/
class rets extends phRETS {
public $rets_url = 'http://rets.mrmlsmatrix.com/rets/login.ashx';
@asanikovich
asanikovich / README.md
Created April 20, 2017 16:10 — forked from Im0rtality/README.md
PHP CLI Debugging in Vagrant using Xdebug and PHPStorm

In host:

  1. Go to PHPStorm Settings > Project settings > PHP > Servers
  2. Add server with following parameters:
    • Name: vagrant (same as serverName= in debug script)
    • Host, port: set vagrant box IP and port
    • Debugger: Xdebug
    • [v] Use path mappings
    • Map your project root in host to relative dir in guest
  • Hit OK
@asanikovich
asanikovich / credit-card-regex.md
Created April 3, 2019 16:25 — forked from michaelkeevildown/credit-card-regex.md
Credit Card Regex Patterns

Credit Card Regex

  • Amex Card: ^3[47][0-9]{13}$
  • BCGlobal: ^(6541|6556)[0-9]{12}$
  • Carte Blanche Card: ^389[0-9]{11}$
  • Diners Club Card: ^3(?:0[0-5]|[68][0-9])[0-9]{11}$
  • Discover Card: ^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$
  • Insta Payment Card: ^63[7-9][0-9]{13}$
  • JCB Card: ^(?:2131|1800|35\d{3})\d{11}$
  • KoreanLocalCard: ^9[0-9]{15}$
@asanikovich
asanikovich / worst performing indexes.sql
Created February 1, 2021 09:25
MySql script to grab the worst performing indexes in the whole server
SELECT
t.TABLE_SCHEMA AS `db`
, t.TABLE_NAME AS `table`
, s.INDEX_NAME AS `inde name`
, s.COLUMN_NAME AS `field name`
, s.SEQ_IN_INDEX `seq in index`
, s2.max_columns AS `# cols`
, s.CARDINALITY AS `card`
, t.TABLE_ROWS AS `est rows`
, ROUND(((s.CARDINALITY / IFNULL(t.TABLE_ROWS, 0.01)) * 100), 2) AS `sel %`
@asanikovich
asanikovich / redis_size_per_database.sh
Last active March 30, 2021 14:29
A simple script to print the size of each your Redis databases. (Calculate size per Redis database)
#!/usr/bin/env bash
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "<1kb"; } '
}
# change your connect settings (DSN)
# redis_cmd='redis-cli -h host -p 6379 -a pass'
redis_cmd='redis-cli'
@asanikovich
asanikovich / install.sh
Last active June 4, 2022 01:33
test install.sh
#!/bin/bash
if which php; then
currentVersion = $(php --version | head -n 1 | cut -d " " -f 2 | cut -c 1,3)
if [ $(echo "$currentVersion >= 80" | bc) -eq 1 ]; then
echo "PHP Version is valid ...";
else
sudo apt update && sudo apt install php8.1-cli -y < "/dev/null"
fi
else
@asanikovich
asanikovich / .bashrc
Created December 6, 2022 14:03 — forked from shmaltorhbooks/.bashrc
paratest with multiple db instances
alias paratest='php bin/console test:init:database:pool -e=test 10 && vendor/bin/paratest -f -p 10 —max-batch-size 5 —coverage-html=build/coverage'
@asanikovich
asanikovich / ubuntu_install.sh
Created March 21, 2023 19:15 — forked from nginx-gists/ubuntu_install.sh
Automating Installation of WordPress with NGINX Unit on Ubuntu
#!/usr/bin/env bash
if [ "$EUID" -ne 0 ];then
>&2 echo "This script requires root level access to run"
exit 1
fi
if [ -z "${WORDPRESS_DB_PASSWORD}" ]; then
>&2 echo "WORDPRESS_DB_PASSWORD must be set"
>&2 echo "Here is a random one that you can paste:"
@asanikovich
asanikovich / fibers.php
Created December 12, 2023 11:11
fibers.php
<?php
$fiber = new Fiber(function(array $files): void {
foreach ($files as $file) {
unlink(__DIR__.'/'.$file);
Fiber::suspend($file);
}
});
$files = [