Skip to content

Instantly share code, notes, and snippets.

View samdark's full-sized avatar
Improving everything

Alexander Makarov samdark

Improving everything
View GitHub Profile
samdark /
Created April 22, 2023 07:13
The ministry

The ministry

Humanity had finally succeeded in its mission to destroy the planet. The last tree had been felled, the final river had run dry, and the earth was now a barren wasteland. But as they stood at the edge of the abyss, a strange thing happened.

As they began to plant new trees, the barren earth suddenly began to thrive. The soil was now rich with nutrients, and the trees grew at an unprecedented rate. Birds returned, and animals appeared out of nowhere. The planet was now more vibrant and alive than it had ever been.

Confused by this paradoxical turn of events, humanity searched for an explanation. Had they been wrong about the effects of their actions? Or was this some sort of cosmic joke?

As they pondered this strange turn of events, they realized the truth: their destruction had inadvertently created the conditions for new life to emerge. It was a paradoxical twist that they could never have predicted.

samdark /
Last active January 5, 2024 07:15
How PHP Environment Variables Actually work
samdark /
Created August 16, 2021 20:43
How many distinct authors worked on the repository in a given timeframe
git shortlog -s --group=author --group=trailer:co-authored-by --since=2012.01.01 --until=2013.01.01 | wc -l
samdark /
Created May 23, 2021 21:54
samdark / timestamp_refactoring.php
Created April 8, 2020 13:00
Timsetamp case refactoring
// see
class Timestamp
private int $intTimestamp;
private function __construct(int $intTimestamp)


PhpBench @git_tag@. Running benchmarks. Using configuration file: D:\dev\yii-dev\dev\di/phpbench.json


benchConstructStupid....................I4 [μ Mo]/r: 438.566 435.190 (μs) [μSD μRSD]/r: 9.080μs 2.07%
benchConstructSmart.....................I4 [μ Mo]/r: 470.958 468.942 (μs) [μSD μRSD]/r: 2.848μs 0.60%

benchSequentialLookups # 0..............R5 I4 [μ Mo]/r: 2,837.000 2,821.636 (μs) [μSD μRSD]/r: 34.123μs 1.20%

Resetting OpenCFP

If you've used OpenCFP for a conference and want to use it next year you have to reset all talks. It is a good idea to keep users though.

That's how to do it:

  1. Backup your current database.
  2. Adjust dates in config/production.yml.
  3. Clean up database:
samdark / composer.lock
Created June 11, 2019 13:47
yii-demo 2019.06.11
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at",
"This file is @generated automatically"
"content-hash": "3c5ebbee4c63d262290c75bc24c2e892",
"packages": [
"name": "cebe/markdown",
-- Cleans up IPB 3 database before importing it into another forum engine
-- tbl_* are project specific, could be removed
-- Remove banned members and members with no posts
delete m
from ipb_members m
left join tbl_user u on = m.member_id
member_banned = 1
samdark / phpunit_array_assertions.php
Created October 10, 2016 11:21
PHPUnit array assertions
public static function assertArrayStructure($keys, $array)
$arrayKeys = array_keys($array);
$missing = array_diff($keys, $arrayKeys);
$unexpected = array_diff($arrayKeys, $keys);
$message = 'Keys are wrong.';
if ($missing !== []) {
$message .= ' Missing: ' . implode(', ', $missing) . '.';