Skip to content

Instantly share code, notes, and snippets.

⚒️
No time for commit, just push!

Pavel Belousov pafnuty

⚒️
No time for commit, just push!
View GitHub Profile
@pafnuty
pafnuty / index.js
Created Aug 21, 2019
index.js for letu-write-version
View index.js
/**
* Create `version.json` and `buildHash`
*/
const path = require('path')
const git = require('git-rev-sync')
const fs = require('fs')
const dotenv = require('dotenv')
dotenv.config({silent: true})
@pafnuty
pafnuty / ko.utils.3.5.0.signatures.js
Created Jul 18, 2019 — forked from hyle/ko.utils.3.5.0.signatures.js
KnockoutJS 3.5.0 utils (ko.utils) signatures
View ko.utils.3.5.0.signatures.js
// knockout 3.5.0
ko.utils.addOrRemoveItem = function (array, value, included) { /* .. */ }
ko.utils.anyDomNodeIsAttachedToDocument = function (nodes) { /* .. */ }
ko.utils.arrayFilter = function (array, predicate) { /* .. */ }
ko.utils.arrayFirst = function (array, predicate, predicateOwner) { /* .. */ }
@pafnuty
pafnuty / group-objects-by-property.md
Created May 16, 2019 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value
View group-objects-by-property.md

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
View sll.json
{
"extends": "stylelint-config-standard",
"rules": {
"indentation": 2,
"string-quotes": "single",
"no-duplicate-selectors": true,
"color-hex-case": "lower",
"color-hex-length": "long",
"color-named": "never",
"selector-no-id": true,
@pafnuty
pafnuty / vds.menu.adclear.css
Created May 20, 2017
Убираем рекламу между строк на vds.menu
View vds.menu.adclear.css
.col-xs-12 div[style="position:relative; display:block;"] + .panel-info {
opacity: 0;
}
.panel > .table > tbody:first-child > tr:first-child td {
border-top: solid 1px #ddd;
}
.table-striped-active {
background: inherit;
}
@pafnuty
pafnuty / image_gallery.tpl
Last active Jan 28, 2017
Выводим галлерею изображений из допполя с именем gallery, типа галерея.
View image_gallery.tpl
@pafnuty
pafnuty / top-list.tpl
Created Aug 12, 2016
Строим многостраничный нумерованный список (топ новостей)
View top-list.tpl
{*
Пример демонстрирует способ, которым можно реализовать многостраничные нумерованные списки.
Бывает полезно при построении топов новостей.
*}
<div id="{$block_id}">
{$pages}
{*
@pafnuty
pafnuty / emath_all.tpl
Created Apr 24, 2016
Пример демонстрирует работу модификатора ematch_all в модуле BlockPro
View emath_all.tpl
{*
Пример демонстрирует работу модификатора ematch_all в модуле BlockPro
показано как можно посчитать количество картинок в новости.
*}
{foreach $list as $key => $el}
{* Счётчик гифок *}
{set $totalGifs = 0}
{* Счётчик остальных картинок *}
@pafnuty
pafnuty / JavaScript.xml
Last active Apr 22, 2016
Live template в шторме
View JavaScript.xml
<templateSet group="JavaScript">
<template name="js_number_format" value="/**&#10; * Separate the price of thousands of&#10; *&#10; * @author Pavel Belousov &#10; * @date 19.02.2015&#10; *&#10; * @method numberFormat&#10; * @param {string} str Price&#10; * @return {string} Formatted price (1 000 000)&#10; */&#10;function numberFormat(str) {&#10;&#9;return (str + '').replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');&#10;}$END$" description="Price Format like: XX XXX XXX" toReformat="true" toShortenFQNames="true">
<context>
<option name="JAVA_SCRIPT" value="true" />
<option name="JS_EXPRESSION" value="true" />
<option name="JSX_HTML" value="true" />
<option name="JS_STATEMENT" value="true" />
</context>
</template>
<template name="ready" value="jQuery(document).ready(function($) {&#10;&#9;$TEXT$&#10;});$END$" description="jQuery Document Ready" toReformat="false" toShortenFQNames="true">
@pafnuty
pafnuty / snippet.xml
Created Apr 20, 2016
синтаксис сниппета ST
View snippet.xml
<snippet>
<content><![CDATA[
jQuery(document).ready(function(\$) {
${1:текст}
});${0}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ready</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.js</scope>
You can’t perform that action at this time.