Skip to content

Instantly share code, notes, and snippets.

Avatar
🛠️
Improving everything

Alexander Makarov samdark

🛠️
Improving everything
View GitHub Profile
@samdark
samdark / git_distinct_author.sh
Created Aug 16, 2021
How many distinct authors worked on the repository in a given timeframe
View git_distinct_author.sh
git shortlog -s --group=author --group=trailer:co-authored-by --since=2012.01.01 --until=2013.01.01 | wc -l
View yii3flood.md
@samdark
samdark / timestamp_refactoring.php
Created Apr 8, 2020
Timsetamp case refactoring
View timestamp_refactoring.php
<?php
// see https://gist.github.com/Nex-Otaku/622ce7f2f336f27b4953e85efffa7c45
class Timestamp
{
private int $intTimestamp;
private function __construct(int $intTimestamp)
{
View yii_di_benc_2020_02_20.md

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%
View opencfp_reset.md

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 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 https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"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 u.id = m.member_id
where
(
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
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" />
<colors>
<option name="WHITESPACES" value="f2f2f2" />
</colors>
@samdark
samdark / squash-merge.sh
Last active Oct 22, 2015
sqash-merge pull request
View squash-merge.sh
git checkout -b local-branch-name master
git pull https://github.com/username/repo.git 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 <email@example.com>"
git push origin master