Skip to content

Instantly share code, notes, and snippets.

Improving everything

Alexander Makarov samdark

Improving everything
View GitHub Profile
samdark /
Created Aug 16, 2021
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 / timestamp_refactoring.php
Created Apr 8, 2020
Timsetamp case refactoring
View timestamp_refactoring.php
// 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 Jun 11, 2019
yii-demo 2019.06.11
View composer.lock
"_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",
View ipb3_db_pre_import_cleanup.sql
-- 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
View phpunit_array_assertions.php
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) . '.';
samdark / Sam Dark.icls
Created Aug 11, 2016
My PhpStorm color schema
View Sam Dark.icls
<scheme name="Sam Dark" version="142" parent_scheme="Default">
<option name="LINE_SPACING" value="1.05" />
<option name="EDITOR_FONT_SIZE" value="15" />
<option name="EDITOR_LIGATURES" value="true" />
<option name="CONSOLE_FONT_NAME" value="Monospaced" />
<option name="CONSOLE_FONT_SIZE" value="13" />
<option name="EDITOR_FONT_NAME" value="Fira Code" />
<option name="WHITESPACES" value="f2f2f2" />
samdark /
Last active Oct 22, 2015
sqash-merge pull request
git checkout -b local-branch-name master
git pull remote-branch-name
git --no-pager show -s --format='%an <%ae>' FETCH_HEAD
git merge --squash local-branch-name
git commit -am 'commit message' --author="author name <>"
git push origin master