Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Ready for action

Anton WinterSilence

:octocat:
Ready for action
View GitHub Profile
@WinterSilence
WinterSilence / fn_map_list.scss
Created Mar 28, 2021
SASS functions: merge-maps(), merge-lists(), get()
View fn_map_list.scss
@function merge-maps($map1, $map2, $merge-lists: false) {
@if (type-of($map1) == map or (type-of($map1) == list and length($map1) == 0)) and (type-of($map2) == map or (type-of($map2) == list and length($map2) == 0)) {
$result: $map1;
@each $key, $value in $map2 {
@if (type-of(map-get($result, $key)) == map and type-of($value) == map) {
$result: map-merge($result, ($key: recursive-map-merge(map-get($result, $key), $value)));
}
@else if ($merge-lists and type-of(map-get($result, $key)) == list and type-of($value) == list) {
$result: map-merge($result, ($key: join(map-get($result, $key), $value)));
}
@WinterSilence
WinterSilence / _color-maps.scss
Last active Mar 15, 2021
Bootstrap 5 SASS color maps
View _color-maps.scss
// stylelint-disable declaration-no-important
// Extra color maps
$blues: (
"100": $blue-100,
"200": $blue-200,
"300": $blue-300,
"400": $blue-400,
"500": $blue-500,
"600": $blue-600,
@WinterSilence
WinterSilence / Cookie.php
Last active Apr 9, 2021
Class Enso\Http\Cookie -helper for work with HTTP cookies
View Cookie.php
@WinterSilence
WinterSilence / template.html
Last active Apr 22, 2020
JS bind and template tag// source https://jsbin.com/wifilah
View template.html
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="JS binding and template tag">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS binding and template tag</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script>
</head>
<body>
@WinterSilence
WinterSilence / ArrayConverter.php
Created Feb 1, 2020
Clear way to replace brackets in result of var_export
View ArrayConverter.php
<?php
class ArrayConverter
{
protected const BRACE_OPEN = '(';
protected const BRACE_CLOSE = ')';
/**
* @param array $tokens
* @return array
@WinterSilence
WinterSilence / Enso\ReflectionFile.php
Last active Jan 31, 2020
The reflection class reports information about a PHP7 file. Collects functions, interfaces, classes, traits with his constants, properties, methods.
View Enso\ReflectionFile.php
<?php
namespace Enso;
use Reflector;
use Reflection;
use ReflectionClass;
use ReflectionType;
use ReflectionNamedType;
use ReflectionFunctionAbstract;
@WinterSilence
WinterSilence / Controller_CRUD.php
Last active May 6, 2020
Kohana/Koseven/KO7 CRUD controller
View Controller_CRUD.php
<?php
/**
* CRUD controller.
*
* @link https://en.wikipedia.org/wiki/Create,_read,_update_and_delete CRUD
* @link https://koseven.dev/documentation/kohana/tutorials/basic-controller Controller_Base
*/
class Controller_CRUD extends Controller_Base
{
/**
@WinterSilence
WinterSilence / polyfill_getallheaders.php
Last active Jan 10, 2020
Polyfill for PHP functions getallheaders / apache_request_headers
View polyfill_getallheaders.php
<?php
if (! function_exists('getallheaders')) {
/**
* Returns HTTP headers for the server request.
*
* @return string[] The HTTP headers
*/
function getallheaders()
{
static $headers;
@WinterSilence
WinterSilence / iana_languages.php
Last active Feb 22, 2020
PHP function: returns language list parsed from site "iana.org"
View iana_languages.php
<?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 / litresCoupons.js
Created Aug 19, 2019
Greasemonkey/Tampermonkey script: multi add coupons to litres.ru
View litresCoupons.js
// ==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