Skip to content

Instantly share code, notes, and snippets.

View andrezrv's full-sized avatar

Andrés Villarreal andrezrv

View GitHub Profile
@andrezrv
andrezrv / get-admin-path.php
Created October 30, 2014 21:18
Obtain path to wp-admin directory in WordPress.
<?php
/**
* Obtain the path to the admin directory.
*
* @return string
*/
function my_plugin_get_admin_path() {
// Replace the site base URL with the absolute path to its installation directory.
$admin_path = str_replace( get_bloginfo( 'url' ) . '/', ABSPATH, get_admin_url() );
@andrezrv
andrezrv / submodules.sh
Created July 3, 2014 15:15
Using Git submodules.
# CREATE: On the root folder of a Git repository:
$ git submodule add git@bitbucket.org:nicethemes/<repo>.git location/of/submodule
# Cloning a repo that contains submodules:
$ git clone --recursive git@bitbucket.org:nicethemes/<repo>.git location/of/repo
# Or:
$ git clone git@bitbucket.org:nicethemes/<repo>.git location/of/repo
$ git submodule init
$ git submodule update
@andrezrv
andrezrv / varnish-purge-cache.sh
Created November 2, 2013 06:07
Purge all Varnish cache.
# Purge all Varnish cache
varnishadm "ban req.url ~ /"
@andrezrv
andrezrv / tar-examples.sh
Created December 24, 2013 19:03
Examples on how to compress and uncompress using Tar.
###################
# Compress a folder
###################
tar czfv test.tar.gz test/
# "czfv" stands for "Compress Zip File Verbose"
# If you want bzip files, use "j" instead of "z".
###################
# Uncompress a file
###################
@andrezrv
andrezrv / upload-public-key.sh
Created December 26, 2013 12:00
Upload your public key to a remote server without using ssh-copy-id (i.e. for Windows/MINGW32 systems).
# Create ssh directory if it doesn't exist
mkdir -p ~/.ssh
# Go to ssh directory
cd !$
# Create public and private keys
ssh-keygen
# Upload your publick key to some server
cat ~/.ssh/id_rsa.pub | ssh user@host -p 22 "cat - >> ~/.ssh/authorized_keys"
<?php // Ignore this line.
add_action( 'save_post', 'nice_fix_yoast_seo_loading', -999 );
add_action( 'delete_post', 'nice_fix_yoast_seo_loading', -999 );
function nice_fix_yoast_seo_loading() {
if ( ! class_exists( 'WPSEO_Link_Watcher' ) ) {
return;
}
nice_loader( 'includes/public/theming/' );
@andrezrv
andrezrv / fix-demo-importer-toggle.css
Created July 26, 2017 13:40
Fix toggle inner in demo importer.
body.nice-framework-page-demos .nice-toggle .nice-toggle-inner {
height: auto !important;
border: 2px solid transparent !important;
}
@andrezrv
andrezrv / airplane-mode-google-fonts.php
Created February 2, 2017 15:10
For WordPress, prevent Airplane Mode plugin from blocking Google Fonts.
<?php
// Prevent Airplane Mode from blocking Google Fonts.
add_filter( 'airplane_mode_parse_style', function( $value, $parsed ) {
if ( 'fonts.googleapis.com' === $parsed ) {
$value = false;
}
return $value;
}, 10, 2 );
@andrezrv
andrezrv / matrix.sh
Created December 19, 2013 00:42
Trigger a Matrix effect in your command line. Very unuseful, but nice and cool.
echo -e "\e[32m";
while :; do for i in {1..16};
do r="$(($RANDOM % 2))";
if [[ $(($RANDOM % 5)) == 1 ]]; then
if [[ $(($RANDOM % 4)) == 1 ]]; then
v+="\e[1m $r ";
else
v+="\e[2m $r ";
fi;
else
@andrezrv
andrezrv / parallax.js
Last active December 28, 2015 16:39
How to slow the scrolling of an HTML element to create a simple parallax effect using jQuery.
jQuery( document ).ready( function( $ ) {
var scrollable = $('#branding .navbar-inner');
var difference = 5;
if ( scrollable.length ) {
var a = document.body;
var e = document.documentElement;