Skip to content

Instantly share code, notes, and snippets.

Gerald Villorente geraldvillorente

Block or report user

Report or block geraldvillorente

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
geraldvillorente /
Created Jan 3, 2020
Pantheon nginx-access.log Grok pattern
%{IPORHOST:remoteaddress} - - \[%{HTTPDATE:timelocal}\]  "%{WORD:httpmethod} %{URIPATHPARAM:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response} (?:%{NUMBER:bytes}|-) (?:"(?:%{URI:referrer}|-)"|%{QS:referrer}) %{QS:useragent} %{BASE10NUM:request_duration} %{QS:xforwardedfor}
View gist:5b70d0befdaa045cc10fefc610352f2c
* The Analyzer class.
class Analyzer {
private $fp;
geraldvillorente /
Created Jul 23, 2018
Apache htaccess hardened
# Hardened Apache Mod_Rewrite Security Rule 
# Provided by Aung Khant, 
# Last Updated: 2011-02-24 
# Note: You must experiment which strings make access denied in normal clean traffic. Remove such rules. Contact me if you can't. 
# Ref:
# rewritecond 
# NC = 'nocase|NC' (no case-sensitive) 
# OR = 'ornext|OR' (or next condition) 
# L = last rule 
geraldvillorente /
Created Jul 9, 2018
A small bash script to clear the clipboard in MacOS.

Create a file in /usr/local/bin/ and place the below into it.

#!/usr/bin/env bash
pbcopy < /dev/null

Then make the file executable.

geraldvillorente /
Last active Mar 7, 2019
Managing Wordpress debug.log on Pantheon

Wordpress has its own debugging system that Pantheon customers can leverage. Below is the setup that should be able to work regardless of environment connection mode.

Place this code on wp-config.php:

if (defined('PANTHEON_ENVIRONMENT')) {
    // Wordpress debug settings in Development and Test environments.
    if (!in_array(PANTHEON_ENVIRONMENT, array('live'))) {
      // Debugging enabled.
      if (!defined( 'WP_DEBUG' )) {
        define( 'WP_DEBUG', true );
Logged in as
Detected that janus is a drupal8 site
Checking for /lando/keys/pantheon.lando.id_rsa
Destroying all current tables in database...
Dropping cache_config table from lando database...
Dropping cache_container table from lando database...
Downloading drush aliases...
 [notice] Aliases file written to ~/.drush/pantheon.aliases.drushrc.php.
geraldvillorente /
Created Jun 6, 2018
Get Terminus machine token from cache

grep -o '"token":"[^"]*' ~/.terminus/cache/tokens/{EMAIL} | grep -o '[^"]*$'

geraldvillorente /
Created Apr 16, 2018
Sort nginx access by total amount to visit.

cat nginx-access.log | awk -F\" '{print $8}' | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20

geraldvillorente /
Created Apr 10, 2018
How to cross check RSA fingerprint?

ssh-keygen -l -E md5 -f ~/.ssh/

geraldvillorente /
Last active May 6, 2018
Wordpress slow query related to wp_postmeta and the solution

Problem: WP is slow or dead when editing pages.

Possible Cause: MySQL slow query related to wp_postmeta or wp_options

FROM wp_postmeta 
WHERE meta_key NOT BETWEEN '_'
AND '_z' 
HAVING meta_key NOT LIKE '\\_%'
ORDER BY meta_key 
You can’t perform that action at this time.