Skip to content

Instantly share code, notes, and snippets.

View andrezrv's full-sized avatar

Andrés Villarreal andrezrv

View GitHub Profile
@andrezrv
andrezrv / MyBuildTestData.groovy
Last active December 24, 2015 00:39
How to test with Spock using Build Test Data Plugin for Grails. Spock Docs: http://docs.spockframework.org/ Build Test Data Docs & Repo: https://github.com/tednaleid/build-test-data
package myapp.downloads
import grails.test.mixin.TestFor
import spock.lang.Specification
import grails.buildtestdata.mixin.Build
/**
* See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions
*/
@TestFor( Download )
@andrezrv
andrezrv / wordpress-admin-notice.php
Last active December 25, 2015 13:29
How to display a notice in the admin section of WordPress.
<?php
/**
* Displays a notice in the admin section under some condition.
*
* @author andrezrv
*/
function my_admin_notice() {
global $current_screen;
@andrezrv
andrezrv / wp-config-no-autoupdates-example.php
Last active December 26, 2015 19:49
Disable autoupdates in WordPress 3.7+.
<?php
# Disables all kind of file modifications:
# core, plugins and themes won't be auto-updated
# and file editors won't appear anymore in wp-admin.
define( 'DISALLOW_FILE_MODS', true );
# Disables all core updates:
define( 'WP_AUTO_UPDATE_CORE', false );
@andrezrv
andrezrv / new-user.sql
Created November 1, 2013 03:33
Create a new MySQL user and grant all privileges.
GRANT ALL PRIVILEGES ON %DB_NAME%.* TO %DB_USER%@%DB_HOST% IDENTIFIED BY '%DB_PASSWORD%';
@andrezrv
andrezrv / nginx-common.conf.c
Created November 2, 2013 06:15
Nginx common configuration for non-WordPress sites.
#server {
# listen 80;
# root /srv/www/mysite;
index index.php index.html index.htm;
# server_name www.mysite.com;
location / {
try_files $uri $uri/ /index.html;
}
@andrezrv
andrezrv / add-to-bin.sh
Last active December 27, 2015 10:39
Make a complete backup of your production website.
# Add scripts to /usr/bin
ln -s /srv/www/website/tasks/website-backup-applications.sh /usr/bin/website-backup-applications
ln -s /srv/www/website/tasks/website-backup-database.sh /usr/bin/website-backup-database
ln -s /srv/www/website/tasks/website-full-backup.sh /usr/bin/website-full-backup
ln -s /srv/www/website/tasks/website-switch.sh /usr/bin/website-switch
@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;
@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 / 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 / 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;
}