Skip to content

Instantly share code, notes, and snippets.

View AlekVolsk's full-sized avatar

AlekVolsk AlekVolsk

View GitHub Profile
@AlekVolsk
AlekVolsk / date.php
Created February 10, 2019 09:01
Кастомная дата для джумлы, месяц прописью
<?php
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
function getDateAlt($date, $format)
{
$months = array(
Text::_('JANUARY') => 'Январь',
Text::_('FEBRUARY') => 'Февраль',
@AlekVolsk
AlekVolsk / guv.php
Created February 10, 2019 09:03
Get UIkit 3 variables
<?php
/*
* Collector of all UIkit3 variables into one file
* PHP 7.1+ !!!
* version 1.1.3
*/
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
@AlekVolsk
AlekVolsk / numberFormat.js
Created February 10, 2019 09:05
Форматирование числа на js
/*
num number
thSeparator thousands separator
floatSeparator decimal separator
floatFixed fixed number of digits after the decimal point
*/
function numberFormat(num, thSeparator, floatSeparator, floatFixed)
{
var n;
if (!thSeparator) { thSeparator = ''; }
@AlekVolsk
AlekVolsk / svg.js
Last active March 14, 2019 10:11
Set href to svg-use (for svg-sprite)
function svgHref() {
var
uses = document.querySelectorAll('use'),
lhref = location.href.split("#")[0];
for (var i = 0; i < uses.length; i++) {
var href = uses[i].getAttribute('xlink:href');
if (href.indexOf('#') == 0) {
uses[i].setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', lhref + href);
}
@AlekVolsk
AlekVolsk / setGridFilter_UIkit2.js
Created February 10, 2019 09:11
Установить фильтр uikit2 dinamic grid при переходе на страницу с привязкой в url?
jQuery(document).ready(function($)
{
var loc = window.location.hash.replace('#', '');
history.pushState('', document.title, window.location.pathname);
if (loc != '' && $(loc) && $('.tm-grid-filtering')) {
$('.tm-grid-filtering').attr('data-uk-grid', $('.gridClass').data('uk-grid').replace('}', ', filter:\'' + loc + '\'}'));
}
});
@AlekVolsk
AlekVolsk / ol.css
Last active February 10, 2019 10:55
Нестандартная нумерация списков, когда номер доолжен начинаться не с 1, <ol start="num">...</ol>
ol {
counter-reset: list+N; /* here N = value at which to start numbering – 1 */
}
ol > li {
position: relative;
list-style-type: none;
}
ol > li:before {
position: absolute;
content: counter(list);
@AlekVolsk
AlekVolsk / num_str.php
Created February 10, 2019 09:14
Сумма прописью
<?php
function numStr($num)
{
$m = [
['ноль'],
['-','один','два','три','четыре','пять','шесть','семь','восемь','девять'],
['десять','одиннадцать','двенадцать','тринадцать','четырнадцать','пятнадцать','шестнадцать','семнадцать','восемнадцать','девятнадцать'],
['-','-','двадцать','тридцать','сорок','пятьдесят','шестьдесят','семьдесят','восемьдесят','девяносто'],
['-','сто','двести','триста','четыреста','пятьсот','шестьсот','семьсот','восемьсот','девятьсот'],
['-','одна','две']
@AlekVolsk
AlekVolsk / array_ksort_nested.php
Last active October 11, 2020 11:19
Мультисортировка массива
<?php
/**
* array_ksort_nested
* en:sorting an array by multiple arbitrary keys
* ru:сортировка массива по нескольким произвольным ключам
*
* @param array $array
* @param array $args key in $array => acs|desc
* @param bool $saveKeys whether or not to keep the original keys
@AlekVolsk
AlekVolsk / svg-viewer.php
Created February 10, 2019 09:19
SVG viewer
<?php
$list = [];
$err = '';
$path = filter_input( INPUT_GET, 'path');
if ( !$path )
{
$err = 'Path is empty';
<?php
function vd(...$args)
{
print_r('<pre style="margin:0;padding:20px;font:14px/1.6 Consolas,monospace;' .
'background-color:#eee;color:#333">===<br>');
foreach ($args as $i => $context) {
if ($i > 0) {
print_r('<br>===<br><br>');
}