Skip to content

Instantly share code, notes, and snippets.

$words = ['кит', 'кот', 'тик', 'кти', 'ток', 'ков'];
$hash = [];
foreach($words as $word) {
$lowerWord = strtolower($word);
$wordArray = preg_split('//u', $lowerWord, null, PREG_SPLIT_NO_EMPTY);
sort($wordArray);
$sorted = implode('',$wordArray);
@kerstvo
kerstvo / phpstorm-wa-live-templates.xml
Last active July 31, 2020 19:18
PHPStorm WA live templates
<template name="wa-fields" value="&lt;div class=&quot;block fields&quot;&gt;&#10;&#10; &lt;div class=&quot;field-group&quot;&gt;&#10; &lt;div class=&quot;field&quot;&gt;&#10; &lt;div class=&quot;name&quot;&gt;&lt;/div&gt;&#10; &lt;div class=&quot;value&quot;&gt;&lt;/div&gt;&#10; &lt;/div&gt;&#10; &lt;/div&gt;&#10;&#10; &lt;div class=&quot;field-group&quot;&gt;&#10; &lt;div class=&quot;field&quot;&gt;&#10; &lt;div class=&quot;value&quot;&gt;&#10; &lt;input type=&quot;button&quot; class=&quot;button&quot; value=&quot;Save&quot; /&gt;&#10; &lt;/div&gt;&#10; &lt;/div&gt;&#10; &lt;/div&gt;&#10; &#10;&lt;/div&gt;" description="fields" toReformat="true" toShortenFQNames="true">
<context>
<option name="HTML" value="true" />
<option name="PHP" value="true" />
<option name="Twig" value="true" />
<option name="Vue" value="true" />
</context>
</template>
<template name="wa-form-field" value="&lt;div class=&quot;field&quot;&gt;&#1
/**
* var long = $.wa.kmLongAction();
* long.start({
process_url: 'url_to_walongaction_controller',
start: {
data: { id: some_id }
}
});
*/
(function ($) {
// source https://github.com/medius/utm_form
var UtmCookie;UtmCookie=function(){function e(e){null==e&&(e={}),this._cookieNamePrefix="_uc_",this._domain=e.domain,this._sessionLength=e.sessionLength||1,this._cookieExpiryDays=e.cookieExpiryDays||365,this._additionalParams=e.additionalParams||[],this._utmParams=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],this.writeInitialReferrer(),this.writeLastReferrer(),this.writeInitialLandingPageUrl(),this.setCurrentSession(),this.additionalParamsPresentInUrl()&&this.writeAdditionalParams(),this.utmPresentInUrl()&&this.writeUtmCookieFromParams()}return e.prototype.createCookie=function(e,t,i,r,o,a){var n,s,l,m,d,u;u=null,i&&(d=new Date,d.setTime(d.getTime()+24*i*60*60*1e3),u=d),s=null!=u?"; expires="+u.toGMTString():"",l=null!=r?"; path="+r:"; path=/",n=null!=o?"; domain="+o:"",m=null!=a?"; secure":"",document.cookie=this._cookieNamePrefix+e+"="+escape(t)+s+l+n+m},e.prototype.readCookie=function(e,t){var i,r,o,a;for(t=t||!1,a=t?e+"=":this._cookieName
<?php
var_dump(gaSendRefund('2642236223'));
function gaSendRefund($transaction_id)
{
$url = 'https://www.google-analytics.com/collect';
$tid = 'UA-XXXXXXX-X';
$params = http_build_query(
array(
// Countdown section
var $countdown_section = $('<section class="clearfix" style="padding: 50px 0;">' +
'<div class="row">' +
' <div class="col-sm-8" style="padding-top: 17px;">' +
' <div class="col-sm-6 col-md-3 text text-center" style="padding: 0;">Order within</div>' +
' <div class="col-sm-6 col-md-3 countdown" style="padding: 0;"></div>' +
' <div class="col-md-6 text text-center" style="padding: 0;">for delivery by <span class="delivery-date"></span></div>' +
' </div>' +
' <div class="col-sm-4 buy-btn"></div>' +
'</div>' +
@kerstvo
kerstvo / gist:6dfcc6f870661ea37d49
Created July 16, 2015 19:48
Add new reviews slider (html wrapper + buttons, right/left button click handler, recalculate buttons position after each slide); remove chat window, when it appears
// Add new reviews slider:
// html wrapper + buttons,
// right/left button click handler,
// recalculate banner`s buttons position after each slide
$('<div class="reviews-title">').css({
'padding': '0 25px 10px'
}).append($happy_clients.icon, $happy_clients.text).insertBefore($new_reviews_wrapper);
$new_reviews_wrapper.find('div.all_reviews').css({
'width': reviews.length * review_width,
//vwo_$ = jQuery;
vwo_$(document).ready(function(){
var $secure_site = vwo_$('img[src="../Images/SecureSite.jpg"]').closest('td'),
$title_wrapper = vwo_$('.cont_heading_td'),
$geotrust_wrapper = $title_wrapper.siblings().contents().css({
'display': 'inline-block',
'vertical-align': 'middle',
'width': '35%'
}),
$info_footer_column = vwo_$('td:contains(INFO):last').closest('table'),
@kerstvo
kerstvo / php-get-next-hour.php
Last active March 5, 2017 11:11
PHP: get next hour
<?php
// Thanks to: http://www.sitepoint.com/forums/showthread.php?708194-Is-it-possible-to-round-up-date()-or-strtotime()-to-nearest-hour&s=086875bf39a87d999fd9db47ac69bcf0&p=4720952&viewfull=1#post4720952
// php >= 5.3
$date = '2014-04-01 18:30:00';
$datetime = DateTime::createFromFormat('Y-m-d H:??:??', $date);
$start = $datetime->format('g A');
$end = $datetime->modify('next hour')->format('g A');
@kerstvo
kerstvo / index.php
Last active August 29, 2015 13:57
resume
<?php
class Place
{
protected $begin;
protected $end;
protected $name;
protected $description;
function __construct($begin, $end, $name, $description)