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
samdark / 2016-05-03-immutability.md
Last active March 20, 2025 21:17
Immutable objects
@samdark
samdark / how_php_environment_variables_actually_work.md
Last active March 27, 2025 11:50
How PHP Environment Variables Actually work
@samdark
samdark / git_distinct_author.sh
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
samdark / yii3flood.md
Created May 23, 2021 21:54
yii3flood.md
@samdark
samdark / timestamp_refactoring.php
Created April 8, 2020 13:00
Timsetamp case refactoring
<?php
// see https://gist.github.com/Nex-Otaku/622ce7f2f336f27b4953e85efffa7c45
class Timestamp
{
private int $intTimestamp;
private function __construct(int $intTimestamp)
{

master

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

\Yiisoft\Di\Tests\Benchmark\ContainerBench

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
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 https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"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 u.id = m.member_id
where
(
member_banned = 1
@samdark
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) . '.';