Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrés Villarreal andrezrv

View GitHub Profile
@andrezrv
andrezrv / varnish-purge-cache.sh
Created Nov 2, 2013
Purge all Varnish cache.
View varnish-purge-cache.sh
# Purge all Varnish cache
varnishadm "ban req.url ~ /"
@andrezrv
andrezrv / tar-examples.sh
Created Dec 24, 2013
Examples on how to compress and uncompress using Tar.
View tar-examples.sh
###################
# 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 / get-admin-path.php
Created Oct 30, 2014
Obtain path to wp-admin directory in WordPress.
View get-admin-path.php
<?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 / upload-public-key.sh
Created Dec 26, 2013
Upload your public key to a remote server without using ssh-copy-id (i.e. for Windows/MINGW32 systems).
View upload-public-key.sh
# 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"
View fix-yoast-smart-issue.php
<?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 Jul 26, 2017
Fix toggle inner in demo importer.
View fix-demo-importer-toggle.css
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 Feb 2, 2017
For WordPress, prevent Airplane Mode plugin from blocking Google Fonts.
View airplane-mode-google-fonts.php
<?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 / submodules.sh
Created Jul 3, 2014
Using Git submodules.
View submodules.sh
# 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 / matrix.sh
Created Dec 19, 2013
Trigger a Matrix effect in your command line. Very unuseful, but nice and cool.
View matrix.sh
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 Dec 28, 2015
How to slow the scrolling of an HTML element to create a simple parallax effect using jQuery.
View parallax.js
jQuery( document ).ready( function( $ ) {
var scrollable = $('#branding .navbar-inner');
var difference = 5;
if ( scrollable.length ) {
var a = document.body;
var e = document.documentElement;