Skip to content

Instantly share code, notes, and snippets.

View VijitCoder's full-sized avatar

Valery Kravtsov VijitCoder

View GitHub Profile
@VijitCoder
VijitCoder / .travis.yml
Last active September 8, 2020 11:01 — forked from prisis/tpecl.sh
`tpecl` is a helper to compile and PHP extensions in TravisCI
# Here is an example of travis config with using of `tpecl`
language: php
dist: xenial
os: linux
cache:
directories:
- $HOME/.composer/cache/files
jobs:
@VijitCoder
VijitCoder / determine-images-similarity.php
Last active August 1, 2023 09:19 — forked from akosnikhazy/compare-images-class
PHP class for comparing two images and determine how much they similar, in percentages.
<?php
/**
* Compare two images and determine how much they similar, in percentages.
*/
class ImagesComparator
{
private const ACCEPTED_IMAGE_TYPES = [IMAGETYPE_JPEG, IMAGETYPE_PNG];
/**
* Calculate the images similarity in percentages.
@VijitCoder
VijitCoder / async.php
Last active November 13, 2017 05:25
Тест для прохождения на хакатон. Томск 2017
<?php
/**
* Требуется написать код, в котором будет функция умножающая 2 на X, где X - номер текущей итерации. Функция выдает
* ответ с задержкой в рандомном интервале от 0 до 1000 миллисекунд.
*
* Код должен запускать эту функцию 10 раз в асинхронном режиме и выводить результат в стандартную консоль, таким
* образом, чтобы ответы шли последовательно.
*
* Решение работает только в Linux. Основано на этом примере http://php.net/manual/ru/function.pcntl-fork.php#110790
*
@VijitCoder
VijitCoder / short_tags_replace.php
Created October 3, 2017 11:44
Поиск и замена коротких php-тегов
#!/usr/bin/php
<?php
/**
* Рекурсивный обход каталогов, проверяем файлы с заданным расширением на предмет неверно используемых "short_open_tag",
* т.е. коротких php-тегов там, где их быть не должно.
*
* вызов:
*
* script.php /path/to/files [extension] [replace]
@VijitCoder
VijitCoder / session-life-cycle.md
Created September 29, 2017 07:03 — forked from mindplay-dk/session-life-cycle.md
Complete overview of the PHP SessionHandler life-cycle

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

@VijitCoder
VijitCoder / merge_sort.c
Last active February 2, 2016 13:28
Merge sort (C implemetation)
/**
* Merge sort
*
* @link https://en.wikipedia.org/wiki/Merge_sort
*
* I went from the other side, using the features of the C with memory.
*
* Walk through an array with step equal 2 and get slices of 2 elements. Sort the elements in each
* slice. Get a new array. Then double step, go through the new array, yielding slices
* of the 4 elements. In each slice sort items by comparing them from the left and right side