Skip to content

Instantly share code, notes, and snippets.

View oleg-andreyev's full-sized avatar
🎯
Focusing

Oleg Andreyev oleg-andreyev

🎯
Focusing
  • Riga, Latvia
View GitHub Profile
@Seldaek
Seldaek / ext-requires.txt
Last active February 15, 2020 18:52
PHP Extension Requirements on Packagist.org
Taken from packagist.org
Packages with a master branch update since June 1st 2018: 98977
Of those, package having requires on PHP extensions: 11676 (11.79%)
As only ~12% of packages declare their extension requirements,
and even then it might not be a complete list, take all this with
a big grain of salt, it is informative but definitely not a
complete picture of the most used extensions.

Native mocks versus PHPUnit mocks

Mock type Tests duration
Native mocks 160.10 seconds
Mockery 177.01 seconds (+10%)
PHPUnit mocks 232.29 seconds (+45%)
Prophecy 3868.80 seconds (+2416%)
@dbalabka
dbalabka / ignore_notices_warning_selectively_test.php
Created July 22, 2019 09:23
iddqd for PHP to ignore notices and warning selectively, while using Symfony ErrorHandler. Helps to upgrade PHP smoothly.
<?php
use Symfony\Component\Debug\BufferingLogger;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Debug\ErrorHandler;
$loader = require_once __DIR__ . '/vendor/autoload.php';
class ConfigurableErrorHandler extends ErrorHandler
{
@Yoric
Yoric / Binary AST benchmarks.csv
Last active February 23, 2020 15:44
Binary AST benchmarks
Parsing benchmark duration (ms) Text (ideal syntax parsing heuristics) Text (full parsing) Pure syntax parsing Binary Binary vs ideal syntax parsing heuristics Binary vs full parsing Binary vs pure syntax parsing
frameworks/angular.1.6.5 1106 1061 1240 671 0.61 0.63 0.54
frameworks/backbone.1.3.3 135 138 105 76 0.56 0.55 0.72
frameworks/bootstrap.4.1.0 242 242 198 150 0.62 0.62 0.76
frameworks/chart.2.7.2 844 852 703 533 0.63 0.63 0.76
frameworks/ember.2.18.2 2583 2392 2155 1673 0.65 0.70 0.78
frameworks/foundation.6.4.3 659 652 544 427 0.65 0.65 0.78
frameworks/jquery.3.3.1 644 521 415 322 0.50 0.62 0.78
frameworks/moment.2.22.1 283 292 233 184 0.65 0.63 0.79
frameworks/react-dom.production.16.3.2 493 498 409 294 0.60 0.59 0.72
@seanhandley
seanhandley / docker-compose.yml
Last active June 7, 2024 19:25
How To Set Up Docker For Mac (Mojave) with Native NFS
version: '2'
services:
api:
volumes:
- "nfsmount:${CONTAINER_DIR}"
volumes:
nfsmount:
driver: local
driver_opts:
@begriffs
begriffs / uuid-insert-profile.md
Last active March 24, 2023 13:01
Profiling insertion of UUIDs with btree and hash indices

Is this a fair benchmark?

  • I'm comparing the speed of inserting UUIDs into columns which are indexed with btree vs hash
  • Want to ensure that I'm measuring both insert queries at their best performance
  • Profiled each of them to check whether there is interference by server misconfiguration

Flame graph results

Both were sampled with perf record -F 99 -u postgres -g --call-graph dwarf -- sleep 180

@hattwj
hattwj / docker-compose-to-etc-hosts
Last active August 22, 2022 16:29
Quickly add hostname aliases for running docker-compose containers
#!/usr/bin/env bash
# Run this file on the host machine that is running dockerd
# It will allow you to access your docker containers via hostname aliases
# Remove old lines with suffix
sed -i -e "/#docker-temp/d" /etc/hosts
# Collect ip-addresses and hostnames of running docker-compose containers
ADDR=$(docker-compose ps -q | xargs --no-run-if-empty -I --- docker exec --- hostname -I| sed -e 's/ /-/')
@AgentO3
AgentO3 / errorcodes.csv
Created July 18, 2016 15:55
mysql-error-codes
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 2 columns, instead of 3. in line 9.
1000, hashchk
1001, isamchk
1002, NO
1003, YES
1004, Can't create file '%s' (errno: %d - %s)
1005, Can't create table '%s' (errno: %d)
1006, Can't create database '%s' (errno: %d)
1007, Can't create database '%s'; database exists
1008, Can't drop database '%s'; database doesn't exist
1009, Error dropping database (can't delete '%s', errno: %d)
@cupracer
cupracer / varnishlog-examples.sh
Last active May 12, 2024 17:50
varnishlog examples (version 4.x)
# filter by request host header
varnishlog -q 'ReqHeader ~ "Host: example.com"'
# filter by request url
varnishlog -q 'ReqURL ~ "^/some/path/"'
# filter by client ip (behind reverse proxy)
varnishlog -q 'ReqHeader ~ "X-Real-IP: .*123.123.123.123"'
# filter by request host header and show request url and referrer header
@discordier
discordier / gist:ed4b9cba14652e7212f5
Created December 4, 2014 06:23
options for phpStorm @noinspection annotation
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection