Skip to content

Instantly share code, notes, and snippets.

View rybakit's full-sized avatar

Eugene Leonovich rybakit

View GitHub Profile
@yohgaki
yohgaki / pg_mongo_bench.php
Last active August 29, 2015 14:16
Simple PostgreSQL and MongoDB benchmark PHP script
<?php
const RECORDS = 1000000;
const SEARCHES = 10000;
$pgsql = pg_connect('host=localhost dbname=test') or die('Failed to connect PostgreSQL');
$version = pg_version();
!version_compare($version['server'], '9.4', '<') or die('Need PostgreSQL 9.4 or later');
$mongo = (new MongoClient())->test->test;
composer install --optimize-autoloader --prefer-dist --no-scripts
./vendor/bin/phpunit
composer install --optimize-autoloader --prefer-dist --no-scripts --no-dev
docker build -t <appname>_img:$CI_BUILD_REF_NAME .
docker tag <appname>_img:$CI_BUILD_REF_NAME quay.io/<username>/<appname>:$CI_BUILD_REF_NAME
docker push quay.io/<username>/<appname>:$CI_BUILD_REF_NAME
<?php
$f = fopen("data.txt", "r");
fread($f, 10);
fread($f, 10);
// Run with: strace -e trace=read php test2.
/*
@IGZalbertogregoris
IGZalbertogregoris / increase_network_latency.sh
Created March 17, 2014 07:34
Emulate network latency in Linux
# Install iproute (Ubuntu)
sudo apt-get install iproute
# Increase network latency in eth0 (250 milliseconds)
sudo tc qdisc add dev eth0 root netem delay 250ms
# Delete network modifications
sudo tc qdisc del dev eth0 root netem
# To make this change in localhost you must only replace "eth0" to "lo" ( --- WARNING --- in this case time will double )
@dbalabka
dbalabka / .phpdebug
Last active January 11, 2019 09:47
!!! Script is migrated to https://github.com/torinaki/phpdebug-cli !!! XDebug PHP CLI debugging helper console commands with PhpStorm, NetBeans support.
# Installation steps:
# 1. Put this file under ~/.phpdebug
# $ curl https://gist.githubusercontent.com/torinaki/9059015/raw/.phpdebug > ~/.phpdebug
# 2. Put following lines into ~/.bashrc:
# # Get the aliases and functions
# if [ -f ~/.phpdebug ]; then
# . ~/.phpdebug
# fi
# 3. (optional) Script will try to autodetect your machine IP where runs IDE or use 127.0.0.1 otherwise.
# If automatic detection doesn't work for you, set ip directly via IDE_IP enviroment variable:
@denji
denji / nginx-tuning.md
Last active May 8, 2025 19:46
NGINX tuning for best performance

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.

@webmozart
webmozart / .gitattributes
Last active July 22, 2018 13:39
Automatically replacing variables in PHP files when doing "git add"
*.php filter=subvars
@cyakimov
cyakimov / gist:6456518
Created September 5, 2013 21:34
Allow apache user to exec a git pull command.

Change your PHP to run git via sudo

<?php `sudo git pull [email protected]:my-user/myrepo.git`; ?>

Then change your suoders to allow git to be run by the apache user:

nano /etc/sudoers

Add this to the EOF:

@krakjoe
krakjoe / pthreads.md
Last active September 24, 2024 14:50
pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls
@ralphschindler
ralphschindler / code-complete-stub-generator.php
Last active March 14, 2020 20:52
IDE code-completion stub generation script that utilizes reflection. (Primary use would be for extension stubs.)
<?php
define('T', ' ');
define('N', PHP_EOL);
$functions = array();
$classes = array();
$constant_prefix = 'X_';
$php = '<?php' . N;