Skip to content

Instantly share code, notes, and snippets.

View andrezrv's full-sized avatar

Andrés Villarreal andrezrv

View GitHub Profile
@andrezrv
andrezrv / vvv-init-setup-plugins-post.sh
Last active August 29, 2015 13:55
Sample additional tasks for WordPress plugins installed via Peasant.
#!/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 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"
@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 / 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;
@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 / 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 / varnish-purge-cache.sh
Created November 2, 2013 06:07
Purge all Varnish cache.
# Purge all Varnish cache
varnishadm "ban req.url ~ /"
@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 / 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 );