Skip to content

Instantly share code, notes, and snippets.

View Tusko's full-sized avatar

Tusko Trush Tusko

View GitHub Profile
@Tusko
Tusko / gap.js
Created May 11, 2016 13:53
GAP Parallax
function exGAP(){
'use strict';
$('.is__gap').each(function(){
var t = $(this),
off = t.offset().top,
step = t.data('step'),
reverse = t.hasClass('__reverse') ? -1 : 1;
if( screen() >= off - screen('height')) {
t.css('background-position','50% '+ reverse * parseInt( ( screen() - off ) / (step || 4) , 10) + 'px');
}
@Tusko
Tusko / deferimg.js
Last active September 27, 2020 09:51
deferimg.js
function load_defer_img(source) {
'use strict';
return $.Deferred(function(task) {
var image = new Image();
image.onload = function() {
task.resolve(image);
};
image.onerror = function() {
task.reject();
};
@Tusko
Tusko / USEinsta.php
Last active January 30, 2018 09:16
Instagram API + Wordpress Cache
<?php
/*
You need to authorize your app with scope=public_content
Example:
https://api.instagram.com/oauth/authorize/?client_id=YOUR_CLIENT_ID&redirect_uri=REDIRECT_URL&response_type=token&scope=public_content
*/
$get_my_insta = instagram_feed('USERNAME', 'APP_IP', 'ACCESS_TOKEN', 10);
if ( $get_my_insta ) {
@Tusko
Tusko / .sh
Created June 7, 2016 15:41
OS X Folders at top in Finder
cd /System/Library/CoreServices/Finder.app/Contents/Resources/English.lproj/ (or whatever language you're running)
sudo plutil -convert xml1 InfoPlist.strings
sudo nano InfoPlist.strings (edit folder here)
sudo plutil -convert binary1 InfoPlist.strings
@Tusko
Tusko / in-numberic.scss
Last active June 23, 2016 13:03
Is Numberic input
.input-number-box {
@include transform(translate3d(0,0,0));
@include border-radius(5px);
position: relative;
background: #000;
overflow: hidden;
text-align: left;
width: 100px;
* {@include transform(translate3d(0,0,0));}
@Tusko
Tusko / woo-tags.php
Last active June 10, 2016 06:44
Alphabet Woocommerce Tags
<?php function alpha_brands(){
$num = range(0, 9);
$alpha = range('A','Z');
$abc_cyr = array();
foreach(range(chr(0xC0), chr(0xDF)) as $b) $abc_cyr[] = iconv('CP1251', 'UTF-8', $b);
$characters = array_merge($num, $alpha, $abc_cyr);
$result = array();
$t_args = array(
'hide_empty' => 0
@Tusko
Tusko / di.js
Last active June 12, 2016 15:24
Deffered iframe
function resizeIframe(iframe) {
iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
}
function iFrameLoaded( id, src ) {
var deferred = $.Deferred(),
iframe = $( "<iframe class='hiddenFrame' onload='resizeIframe(this)' width='100%' scrollin='no'></iframe>" ).attr({
"id": id,
"src": src
});
@Tusko
Tusko / ifix.scss
Last active June 23, 2016 13:53 — forked from jopfre/gist:b8ea1a7ebf39cd8efabb
fix view height support in iOS7
//based on https://gist.github.com/pburtchaell/e702f441ba9b3f76f587
//with added support for iphone 3 and 4 and orinetation support for iphone 5.
//this is for all devices which can run iOS7 in all orientations.
//not a mixin to avoid to much duplicate code when using on multiple selectors.
.selector {
$height: 70; //set your height in vh
$heightPercent: $height/100;
height: #{$height}vh;
@Tusko
Tusko / mobfix.js
Last active June 22, 2016 12:01
Fix for :focus on touch devices, when parent has position:fixed
var supportsTouch = window.hasOwnProperty('ontouchstart') || window.navigator.msPointerEnabled ? true : false,
$.fn.mobileFix = function (options) {
var $parent = $(this),
$fixedElements = $(options.fixedElements);
$(document)
.on('focus', options.inputElements, function(e) {
$parent.addClass(options.addClass);
})
@Tusko
Tusko / yt.player.js
Created July 1, 2016 07:08
YT.player for background
// Load the YouTube API asynchronously
var tag = document.createElement('script'),
firstScriptTag = document.getElementsByTagName('script')[0],
player;
tag.src = "https://www.youtube.com/iframe_api";
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Create the player object when API is ready
window.onYouTubeIframeAPIReady = function () {