Skip to content

Instantly share code, notes, and snippets.

View WinterSilence's full-sized avatar
🙃
explore

Anton WinterSilence

🙃
explore
View GitHub Profile
@WinterSilence
WinterSilence / ExceptionHandler.php
Last active August 29, 2015 14:11
Enso\Core\ShutdownHandler
<?php
namespace Enso\Core;
/**
* Inline exception handler, displays the error message, source of the exception
* and the stack trace of the error.
*
* @package Enso\Core
* @copyright (c) 2014 WinterSilence
@WinterSilence
WinterSilence / IRequest.php
Last active August 29, 2015 14:11
Enso\Core - routing
<?php
namespace Enso\Core;
/**
* Interface for request.
*
* @package Enso\Core
* @copyright (c) 2014 WinterSilence
* @license MIT License
@WinterSilence
WinterSilence / Base.php
Last active January 1, 2016 18:09
Abstract base class, supports magically work with properties. Allows protect tproperties and interact with them only through methods set\get.
<?php
/**
* Abstract base class, supports magically work with properties.
* Allows protect tproperties and interact with them only through methods set\get.
*/
abstract class Base
{
/**
* Get protected property by calling method "getPropertyName" or "propertyName"
* (combines set\get methods). If methods are undefined, get property directly.
@WinterSilence
WinterSilence / Closure.php
Created May 25, 2014 19:31
Class Enso\Closure: used to create serializable anonymous function
<?php
/**
* Used to create serializable anonymous function, based on PHP function
* [create_function](http://php.net/create-function).
*
* @package Enso
* @category Base
* @license http://ensophp.github.io/license
*/
namespace Enso;
<?php
/**
* A general-purpose implementation that includes the optional functionality
* of allowing multiple base directories for a single namespace prefix.
*/
class Psr4Autoloader
{
const EXTENSION = '.php';
/**
* An associative array where the key is a namespace prefix and the value
@WinterSilence
WinterSilence / Sitemap.php
Last active May 6, 2016 09:41
Sitemap refactoring
<?php
namespace Sitemap;
/**
* A class for generating sitemaps.
* @see http://sitemaps.org
*/
class Sitemap
{
/**
@WinterSilence
WinterSilence / litresCoupons.js
Created August 19, 2019 01:43
Greasemonkey/Tampermonkey script: multi add coupons to litres.ru
// ==UserScript==
// @name litresCoupons
// @namespace litres.ru
// @version 0.1
// @description Add coupons
// @author info@ensostudio.ru
// @include https://www.litres.ru/pages/put_money_on_account/*
// @include https://litres.ru/pages/put_money_on_account/*
// @require https://code.jquery.com/jquery-3.4.1.min.js
// @grant unsafeWindow
@WinterSilence
WinterSilence / Sitemap\Url.php
Last active January 31, 2020 17:18
Version of Sitemap\Url
<?php
namespace Sitemap;
/**
* Basic sitemap URL class.
*/
class Url extends UrlAbstract
{
/**
* Valid values of "changefreq" element.
@WinterSilence
WinterSilence / iana_languages.php
Last active February 22, 2020 23:10
PHP function: returns language list parsed from site "iana.org"
<?php
/**
* Returns language list parsed from site "iana.org" and grouped by type ('language', 'variant', 'extlang' and etc.).
*
* @param int $last_update timestamp (optional)
* @param string $url source URL (optional)
* @return array|null return NULL when list not updated
*/
function iana_languages(int $last_update = null, string $url = null): ?array
{
@WinterSilence
WinterSilence / php7_array_polyfills.php
Last active April 22, 2020 07:30
Polyfills of PHP 7.1-7.3 functions: is_iterable, is_countable, array_key_first, array_key_last
<?php
if (! function_exists('is_iterable')) {
/**
* Verify that the contents of a variable is an iterable value.
*
* @link https://php.net/manual/en/function.is_iterable.php
* @param mixed $var Variable to test
* @return bool
*/