Skip to content

Instantly share code, notes, and snippets.

View f3ath's full-sized avatar
🐴
If I had ever learnt, I should have been a great proficient.

Alexey f3ath

🐴
If I had ever learnt, I should have been a great proficient.
View GitHub Profile
@f3ath
f3ath / spiral.php
Last active August 26, 2016 21:20
<?php
class Spiral
{
const RIGHT = 'RIGHT';
const DOWN = 'DOWN';
const LEFT = 'LEFT';
const UP = 'UP';
private $xMin = 0;
private $xMax = 0;
<?php
/**
* Returns sorted array of all versions reachable from $version
* @param string $version
* @return string[]
*/
public function getReachableVersions($version)
{
$migrations = $this->migration_manager->getMigrations();
$versions = array_keys($migrations);
@f3ath
f3ath / spiral.php
Last active November 1, 2016 07:11
<?php
function spiral(array $m)
{
$x_max = sizeof($m) - 1;
if ($x_max < 1) {
return;
}
$y_max = sizeof($m[0]) - 1;
if ($y_max < 1) {
return;
#!/usr/bin/env bash
#
# Usage: bin/deploy.sh [-s] [-i] [-t <tag>]
#
# Configuration
RELEASE_DIR=/www/release
CURRENT=/www/current
while getopts ":sit:" OPT; do
<php
function implode_recursive(string $glue, array $pieces) {
return implode(
$glue,
array_map(function ($v) use ($glue) {
return is_array($v) ? implode_recursive($glue, $v) : $v;
}, $pieces)
);
}
<?php
public function upload(Request $request): array
{
$tmp_file = tmpfile();
stream_copy_to_stream($request->getContent(true), $tmp_file);
fflush($tmp_file);
$tmp_file_name = stream_get_meta_data($tmp_file)['uri'];
$this->logger->debug("File uploaded to $tmp_file_name");
$tmp_file_type = mime_content_type($tmp_file_name);
if (!in_array($tmp_file_type, $this->allowed_mime_types)) {
<?php
function three_asc(array $a) {
if (count($a) < 3) {
return false;
}
$min = $max = $new_min = 0;
for ($i = 1; $i < count($a); $i++) {
if ($min < $max) {
if ($a[$max] < $a[$i]) {
return [$min, $max, $i];
<?php
class Config
{
/**
* @var string
*/
private $root;
public function __construct(string $root)
{
$this->root = $root;
<?php
class Node
{
/**
* @var string
*/
private $value;
/**
* @var Node
@f3ath
f3ath / class.php
Last active December 24, 2016 06:43
<?php
namespace F3\Changelog;
use Composer\Semver\Semver;
use F3\Changelog\Exception\NoTagsFound;
use F3\Changelog\Exception\TagNotFound;
use F3\ReleaseNotesGenerator\GitGateway;
class ReleaseNotes
{