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 / require-js-build.js
Created June 9, 2014 10:36
NodeJS build RequireJS app
var requirejs = require('requirejs');
// Build config file. See example in https://github.com/jrburke/r.js/blob/master/build/example.build.js
var jsBuildFile = '../../static/js/app/build.js'
try {
var buildConfig = eval(
String(fs.readFileSync(jsBuildFile))
)
}
@radist2s
radist2s / affix-it.js
Last active August 29, 2015 14:03
Affixed header
/* 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 ($) {
var $window
$(function () {
$window = window.$window || $(window)
})
@radist2s
radist2s / scrollbar-width-detect.js
Last active February 4, 2016 18:40
Scrollbar width detect
var scrollBarWidth
window.getScrollBarWidth = function getScrollBarWidth() {
if (scrollBarWidth !== undefined) {
return scrollBarWidth
}
var scrollDetector = document.createElement('div')
scrollDetector.style.width = '50px'
@radist2s
radist2s / transform-property-name.js
Last active August 29, 2015 14:05
Get style transform property name
var transformStylePropertyName
window.getTransformStyleProperty = function getTransformStyleProperty() {
if (transformStylePropertyName !== undefined) {
return transformStylePropertyName
}
var detectedTransform,
el = document.createElement('transformdetector'),
transforms = [
@radist2s
radist2s / model-extend.js
Created October 9, 2014 14:12
Backbone Model previousAttributes() delta
Backbone.Model.prototype.set = function(key, val, options) {
var attr, attrs, unset, changes, silent, changing, prev, current;
if (key == null) return this;
// Handle both `"key", value` and `{key: value}` -style arguments.
if (typeof key === 'object') {
attrs = key;
options = val;
} else {
(attrs = {})[key] = val;
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@radist2s
radist2s / ffmpeg.php
Last active February 22, 2021 15:59
Jaksta youtube WEBM video encoding fix (Bash and PHP versions of script)
#!/usr/bin/php
<?
// Rename this file to ffmpeg (without extention)
$dir = __DIR__;
$ffmpeg_bin = 'ffmpeg-bin';
setlocale(LC_CTYPE, 'ru_RU.UTF-8');
/*
Array
(
@radist2s
radist2s / functions.php
Last active July 9, 2023 10:07 — forked from jaredatch/gist:11239971
Create ACF options page under custom post type menu
<?php
/**
* Create ACF options page under custom post type menu
*
* @since 1.0.0
*/
if ( function_exists( 'acf_add_options_sub_page' ) ){
acf_add_options_sub_page(array(
'title' => 'Event Settings',
'parent' => 'edit.php?post_type=events',
@radist2s
radist2s / bind.js
Created April 5, 2015 21:01
Function.prototype.bind polyfill with underscore _.bind
if (!Function.prototype.bind) {
Function.prototype.bind = function () {
return _.bind.apply(_, [this].concat(_.toArray(arguments)))
}
}
@radist2s
radist2s / better-afterlag.js
Created April 11, 2015 08:36
Better Afterlag. Little fork of https://github.com/iserdmi/afterlag-js . Written by using requestAnimationFrame instead setInterval for better results.
/**
* BetterAfterlag 1.0.0 — Plugin for tracking page load lags.
* Author: Alex Batalov
* Based on Afterlag Plugin (https://github.com/iserdmi/afterlag-js) of Sergey Dmitriev (serdmi.com). Licensed MIT.
**/
;(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], function () {
return (root.Afterlag = factory());
});