Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrés Villarreal andrezrv

View GitHub Profile
@andrezrv
andrezrv / vvv-init-setup-plugins-post.sh
Last active Aug 29, 2015
Sample additional tasks for WordPress plugins installed via Peasant.
View vvv-init-setup-plugins-post.sh
#!/bin/bash
#
# vvv-init-setup-plugins-post.sh
#
# This file will perform some additional tasks on installed plugins.
# Get Peasant from https://github.com/andrezrv/peasant-vvv-provider.
# Include config file.
this_dir="$(dirname `readlink -f $(dirname $0)/vvv-init.sh`)"
. "${this_dir}/config.sh"
@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"
@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 / 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;
@andrezrv
andrezrv / add-to-bin.sh
Last active Dec 27, 2015
Make a complete backup of your production website.
View add-to-bin.sh
# 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 / nginx-common.conf.c
Created Nov 2, 2013
Nginx common configuration for non-WordPress sites.
View nginx-common.conf.c
#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 / 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 / new-user.sql
Created Nov 1, 2013
Create a new MySQL user and grant all privileges.
View new-user.sql
GRANT ALL PRIVILEGES ON %DB_NAME%.* TO %DB_USER%@%DB_HOST% IDENTIFIED BY '%DB_PASSWORD%';
@andrezrv
andrezrv / wp-config-no-autoupdates-example.php
Last active Dec 26, 2015
Disable autoupdates in WordPress 3.7+.
View wp-config-no-autoupdates-example.php
<?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 );