This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change filename for uploads | |
* | |
* @param string $file | |
*/ | |
add_filter( 'wp_handle_upload_prefilter', function($file){ | |
$hash1 = sha1(mt_rand(10000000,99999999)); | |
$hash2 = substr(md5(rand()), 0, 7); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$key = '###############'; | |
$exp = ( new DateTime( "now" ) )->getTimestamp() + 120; | |
$header = [ | |
'typ' => 'JWT', | |
'alg' => 'HS256' | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call plug#begin('~/.vim/plugged') | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'tpope/vim-surround' | |
Plug 'kien/ctrlp.vim' | |
Plug 'tpope/vim-commentary' | |
Plug 'joshdick/onedark.vim' | |
Plug 'pangloss/vim-javascript' | |
Plug 'othree/yajs.vim', {'for': 'javascript'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Manage lazy load for entire site | |
* @link https://developers.google.com/web/fundamentals/performance/lazy-loading-guidance/images-and-video | |
*/ | |
document.addEventListener("DOMContentLoaded", function() { | |
let lazyImages = [].slice.call(document.querySelectorAll("img.lazyload")); | |
let lazyBackgrounds = [].slice.call(document.querySelectorAll(".lazy-background")); | |
let lazyIframes = [].slice.call(document.querySelectorAll('iframe[data-src]')); | |
if ("IntersectionObserver" in window) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Firefox has no support to link[rel="preload"] | |
* This is a workaround to async load non-critical CSS | |
*/ | |
if ( navigator.userAgent.search("Firefox") > -1 ) { | |
const link_elements = document.querySelectorAll('link[rel="preload"]'); | |
if ( link_elements.length ){ | |
link_elements.forEach( link => { | |
if (link.getAttribute('as') == 'style') { | |
link.setAttribute( 'rel', 'stylesheet' ); |