Skip to content

Instantly share code, notes, and snippets.

View radist2s's full-sized avatar

Alex Batalov radist2s

  • Georgia, Tbilisi
View GitHub Profile
@radist2s
radist2s / gulpfile.js
Last active August 29, 2015 14:19
Gulpfile for using Less compiler with sourcemap support and autoprefixer postcss
var lessSourceFiles = '../../static/less/*.less'
var cssOutPath = '../../static/css'
var gulp = require('gulp')
var watch = require('gulp-watch')
var less = require('gulp-less-sourcemap')
var path = require('path')
var gutil = require('gulp-util')
var notifier = require('node-notifier')
var postcss = require('gulp-postcss')
@radist2s
radist2s / example.html
Last active August 29, 2015 14:20
tympanus.net PageTransitions
<div class="pt-perspective">
<div class="pt-page"></div>
<div class="pt-page"></div>
<div class="pt-page"></div>
</div>
<script>
var $pages = $('.pt-page')
transition.init($('.pt-page'))
@radist2s
radist2s / formatMoney.js
Created May 24, 2015 16:32
Format Money
window.formatMoney = function formatMoney(money) {
money = parseInt(money)
money = isFinite(money) ? money : 0
return String(money).replace(/./g, function(c, i, a) {
return i && c !== '.' && ((a.length - i) % 3 === 0) ? ' ' + c : c
})
}
@radist2s
radist2s / functions.php
Created July 10, 2015 08:17
Worpress Open Embed (Video) content wrapper hook/filter
add_filter('embed_oembed_html', function ($oembed) {
return "<div class='video-wrapper'>$oembed</div>";
}, 10);
@radist2s
radist2s / functions.php
Created July 10, 2015 08:18
Worpress Shortcode template include
add_shortcode('template', function ($templates = array()) {
$templates_render_result = '';
foreach ($templates AS $key => $template)
{
if (is_numeric($key) AND $template)
{
$template = sanitize_file_name($template);
if ($template_path = get_template_directory() . "/parts/templates/$template.html" AND is_readable($template_path))
@radist2s
radist2s / style-mobile-loader.js
Created November 25, 2015 13:00
CSS loading for mobile
!function () {
function addHtmlClass(klass) {
document.documentElement.setAttribute('class', document.documentElement.getAttribute('class') || '' + ' ' + klass + ' ')
}
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera\s+Mini/i.test(navigator.userAgent)) {
window.fullVersionCookieTest = /nomobile\s*=\s*1(;\s*)?/ig
window.isFullVersion = fullVersionCookieTest.test(document.cookie)
if (!isFullVersion) {
@radist2s
radist2s / images-loaded.js
Created November 29, 2015 10:52
Images loaded simple checker with promises
define(['promise'], function () {
// Use any Promise polyfill
var imgClasses = [HTMLImageElement],
imgElementsList = ['img']
if (window.HTMLPictureElement) {
imgClasses.push(HTMLPictureElement)
imgElementsList.push('picture')
}
@radist2s
radist2s / RequestAnimationFrame.js
Last active November 29, 2015 14:52 — forked from paulirish/rAF.js
RequestAnimationFrame Polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
!window.requestAnimationFrame && (window.requestAnimationFrame = null)
!window.cancelAnimationFrame && (window.cancelAnimationFrame = null)
@radist2s
radist2s / fpm.py
Last active December 17, 2015 15:19
ztc php-fpm loging via http; add to config (/etc/ztc/php-fpm.conf) "proto=http"
#!/usr/bin/env python
"""
<description>
This file is part of ZTC and distributed under the same license.
http://bitbucket.org/rvs/ztc/
Copyright (c) 2011 Vladimir Rusinov <vladimir@greenmice.info>
"""
@radist2s
radist2s / scenario.js
Last active December 18, 2015 09:29
Scenario - Build animation based on json
/* jQuery throttle https://github.com/cowboy/jquery-throttle-debounce */
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);
;(function($){
/**
* Scenario - jQuery keyframe animation
* Author: Alex Batalov, radist2s@gmail.com
*
* Usage:
*