Skip to content

Instantly share code, notes, and snippets.

View khoipro's full-sized avatar
💭
#devops #wordpress #vuejs #docker

Nguyễn Minh Khôi khoipro

💭
#devops #wordpress #vuejs #docker
View GitHub Profile
@khoipro
khoipro / .htaccess
Created May 12, 2016 05:01
Optimization: Add Expires headers in .htaccess
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
@khoipro
khoipro / .htaccess
Created May 12, 2016 05:08
Font CSS Blocked - Cross-Origin Resource Sharing policy
<IfModule mod_headers.c>
<FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
<IfModule mod_mime.c>
# Web fonts
AddType application/font-woff woff
AddType application/vnd.ms-fontobject eot
@khoipro
khoipro / .editorconfig
Created May 19, 2016 04:08
Editorconfig to prevent using CRLF in Atom code editor
# EditorConfig is awesome: http://EditorConfig.org
# Remember to install a plugin https://github.com/sindresorhus/atom-editorconfig
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
@khoipro
khoipro / mixin_ratio_background_image.scss
Created June 21, 2016 08:27
Mixin to create a background image with fixed ratio (like square) in all devices
@mixin image-aspect($ratio) {
position: relative;
height: auto;
display: block;
&:before {
display: block;
content: "";
width: 100%;
padding-top: percentage(1/$ratio);
var $ = require( 'jquery' ),
throttle = require( 'modules/throttle' );
module.exports = function( el ) {
var $el = $( el ),
$window = $( window ),
$bar = $( '#bottom-bar' ),
$close = $bar.find('.close-icon'),
$footer = $( '.footer' );
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
@khoipro
khoipro / tinymce_customfont_wp.php
Created January 20, 2017 17:45
Add custom style to tinyMCE editor in WordPress
/* Hook */
add_action( 'admin_head', 'load_custom_fonts' );
/* Function */
function load_custom_fonts() {
echo '<link type="text/css" rel="stylesheet" href="' . get_template_directory_uri() .'/assets/css/editor.min.css">';
}
@khoipro
khoipro / gist:663ba6b90216079f28c4b1bd3dd73e28
Created March 28, 2017 08:30 — forked from croxton/gist:4073583
Install xdebug 2.2.0 for AMPPS on OSX
Grab the 'PHP Remote Debugging Client' (the pre-complied xdebug binary for OSX) from here:
http://code.activestate.com/komodo/remotedebugging/
Unzip it, find the folder that corresponds to the version of PHP you want to install it for and copy the xdebug.so file from there into your php extensions folder in the relevant PHP version directory. E.g. for PHP 5.4:
/Applications/AMPSS/php-5.4/lib/extensions/ext/
Now open PHP.ini in a text editor:
/Applications/AMPSS/php-5.4/etc/php.ini
@khoipro
khoipro / functions.php
Created August 13, 2017 04:16
Register custom widget
// Register and load the widget
function load_custom_widgets() {
register_widget( 'ebook_cat_menu' );
}
add_action( 'widgets_init', 'load_custom_widgets' );
// Creating the widget
class ebook_cat_menu extends WP_Widget {
@khoipro
khoipro / functions.php
Created August 14, 2017 08:19
Gallery Shortcode WordPress - Hacking Output
<?php
/*
* Change WordPress default gallery output
*/
add_filter('post_gallery', 'ct_post_gallery', 10, 2);
function ct_post_gallery($output, $attr) {
global $post;
if (isset($attr['orderby'])) {
$attr['orderby'] = sanitize_sql_orderby($attr['orderby']);