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 / 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:
*
@radist2s
radist2s / canvasMatte.html
Last active April 23, 2024 16:31
Simple Canvas cliping with anti aliasing by alpha channel of mask image or canvas shape.
<canvas id="show" width="300" height="300"></canvas>
@radist2s
radist2s / objectSizeof.js
Created July 13, 2013 18:53
Length of Javascript Object
Object.size = function(obj) {
if (obj.hasOwnProperty){
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
}
else {
return Object.keys(obj).length
@radist2s
radist2s / custom-checkbox-ie-lte8-fallback.js
Last active December 20, 2015 00:49
Custom checkbox CSS
//supportsSelector
;(function( global ) {
var doc = global.document,
hasQuerySelect = !!doc.querySelector;
function supportsSelector( selector ) {
var body = doc.body,
ret, div, style;
@radist2s
radist2s / wp-vkontakte-integration.php
Last active December 24, 2015 06:09
WordPress integration for VK or other social via url prefix
<?php
new WP_VK_Templater();
/**
* Class WP_VK_Templater
*
* Add 'vk/' prefix to al links, and load for such links templates
* with '-vk' suffix: index-vk.php, page-vk.php, taxonomy-{name}-vk.php, etc.
*/
@radist2s
radist2s / functions.php
Last active December 24, 2015 07:39
Wordpress Vkontakte new comment email notifier
<?php
/**
* Theme Native Code
**/
add_action('wp_ajax_vk_comment_mail', 'vk_comment_mail');
add_action('wp_ajax_nopriv_vk_comment_mail', 'vk_comment_mail');
function vk_comment_mail()
{
if (!isset($_POST['last_comment'])){
@radist2s
radist2s / functions.php
Created November 11, 2013 19:27
Wordpress Youtube embed autoplay and wmode=opaque filter
<?php
add_filter('oembed_result', 'youtube_autoplay_filter', 10);
function youtube_autoplay_filter($iframe_html){
$matches = array();
if (!preg_match('~src="([^"]+?)"~iu', $iframe_html, $matches))
{
return $iframe_html;
}
@radist2s
radist2s / functions.php
Created November 25, 2013 20:31
Wordpress Custom TinMCE style.
add_filter('tiny_mce_before_init', 'tinymce_before_init_extend');
add_filter('teeny_mce_before_init', 'tinymce_before_init_extend');
function tinymce_before_init_extend($atts)
{
$custom_options = array(
'content_css' => get_bloginfo('template_url') . '/css/editor.css'
);
return array_merge($atts, $custom_options);
}
jQuery.eventSuffix = function(event, suffix){
if (!suffix){
return event
}
return jQuery.map(event.split(' '), function(i){
return i ? i + '.' + suffix : null
}).join(' ')
}