Skip to content

Instantly share code, notes, and snippets.

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

YaroslavB YaroslavB

🏠
Working from home
  • Kiev/Ukraine
View GitHub Profile
@YaroslavB
YaroslavB / remove-from-git-index
Created January 26, 2021 16:02 — forked from cheshirrrcat/remove-from-git-index
Удалить файл из индекса git-репозитория без его физического удаления
Для удаления файла из git-репозитория без его физического удаления:
git rm --cached mylogfile.log
Для удаления папки (рекурсивно) можно сделать так:
git rm -r --cached folderName
А для того, чтобы ситуация не повторялась, лучше добавьте файл или папку в .gitignore.
@YaroslavB
YaroslavB / download-file-in-expressive.php
Created December 19, 2020 14:38 — forked from settermjd/download-file-in-expressive.php
Quick example of how to download/stream a file using Zend Expressive.
<?php
/**
* This is a quick example of how to stream a file to a client, likely a browser,
* using Zend Expressive. There are a lot of factors which it doesn't take in to
* account. But for the purposes of a quick intro, this should suffice.
*/
class ViewDocumentPageAction
{
protected function downloadFile()
{
<?php
/********* универсальное решение ****************/
function sendRequest($url, array $params = [], $post = false){
$curl = curl_init();
$headers = array(
'Content-Type: application/json-patch+json',
'accept: application/json',
);
if ($post == true) {
@YaroslavB
YaroslavB / Dockerfile
Created December 8, 2020 08:28 — forked from md5/Dockerfile
Testing docker-php-ext-install sockets
FROM php
RUN docker-php-ext-install sockets
COPY test.php /
CMD ["php", "/test.php"]
@YaroslavB
YaroslavB / Sudoku.php
Last active December 7, 2020 06:35
Sudoku
<?php
class Sudoku {
private $comming_arr = array();
private $grids = array();
private $columns_begining = array();
private $time_tracking = array();
public function __construct() {
@YaroslavB
YaroslavB / nginx-tuning.md
Created October 8, 2020 10:47 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

<?php
class Ball
{
public $dataSets = array();
public function run($input)
{
$this->set($input);
$results = array();
foreach ($this->dataSets as $d) {
@YaroslavB
YaroslavB / iteration-and-recursive-iteration.php
Created September 24, 2020 13:33 — forked from hakre/iteration-and-recursive-iteration.php
Iteration and Recursive Iteration Examples Code
<?php
/*
* Iteration and Recursive Iteration Examples Code
*
* @link http://stackoverflow.com/questions/12077177/how-does-recursiveiteratoriterator-works-in-php
* @author hakre <http://hakre.wordpress.com>
*/
### To have these examples to work, a directory with subdirectories is needed,
### I named mine "tree":
@YaroslavB
YaroslavB / tokens.md
Created July 30, 2020 12:25 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 20.04.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@YaroslavB
YaroslavB / composer.json
Created April 6, 2020 11:54 — forked from andyshinn/composer.json
Docker Compose PHP Composer Example
{
"require": {
"mfacenet/hello-world": "v1.*"
}
}