Skip to content

Instantly share code, notes, and snippets.

View windbridges's full-sized avatar

alexey.d windbridges

View GitHub Profile
@windbridges
windbridges / userscript.js
Created November 13, 2023 03:35
Tampermonkey userscript to fix title for new brach from merge request in GitLab
// ==UserScript==
// @name Fix title for new brach from merge request
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Adds small button to insert correct branch name
// @author Me
// @match https://gitlab.com/*/issues/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=gitlab.com
// ==/UserScript==
// Argument type based on value of another argument
type OrderType = 'Simple' | 'Extended'
interface OrderOptionsSet = {
Simple: {
name: string
age: number
},
Extended: {
@windbridges
windbridges / studio.md
Last active January 2, 2021 02:17
Adding local package to composer for parallel development

Documentation: https://github.com/franzliedke/studio

Quick guide:

  1. Install Studio if not installed:
$ composer global require franzl/studio
  1. Tell to Studio which package you want to use locally by specifying it's path (package name is taken automatically):
<?php
trait WithEvents
{
private $eventHandlers;
public function on(string $event, callable $handler): self
{
$this->eventHandlers[$event][] = $handler;
@windbridges
windbridges / IsGenerator.php
Last active December 5, 2020 16:46
Checks if function is also a generator
<?php
function isGenerator (callable $handler)
{
$r = new ReflectionFunction($handler);
return $r->isGenerator();
}
@windbridges
windbridges / WithCleanupDirectory.php
Created December 3, 2020 17:31
Recursive directory cleanup
<?php
use FilesystemIterator;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
trait WithCleanupDirectory
{
public function cleanupDirectory(string $path, bool $deleteDir = false)
{
@windbridges
windbridges / WithIntervalFormatter.php
Last active December 3, 2020 17:32
Human readable interval formatter trait
<?php
trait WithIntervalFormatter
{
private function formatInterval($seconds, $day_lbl = 'd', $hour_lbl = 'h', $minute_lbl = 'm', $second_lbl = 's', $skip_zero = false)
{
$secondsInAMinute = 60;
$secondsInAnHour = 60 * $secondsInAMinute;
$secondsInADay = 24 * $secondsInAnHour;
@windbridges
windbridges / gist:3d1dff2e4f294f1d3b2bb14e8fcee2a7
Created December 30, 2019 23:45
Install v8js on Ubuntu 18.04 and PHP 7.3
sudo apt-get update
sudo apt-get upgrade -y
# add PPA
sudo add-apt-repository ppa:ondrej/php -y
sudo add-apt-repository ppa:stesie/libv8 -y
sudo apt-get update
# install PHP
sudo apt-get install -y php7.3 php7.3-{fpm,cli,common,apcu,mbstring,pdo,xml,curl,bcmath,mysql,redis,sqlite3,zip,geoip,dev}