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
geraldvillorente / grok-pattern.md
Created Jan 3, 2020
Pantheon nginx-access.log Grok pattern
View grok-pattern.md
%{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
#!/usr/bin/php
<?php
/**
* The Analyzer class.
*/
class Analyzer {
private $fp;
@geraldvillorente
geraldvillorente / htaccess.md
Created Jul 23, 2018
Apache htaccess hardened
View htaccess.md
# Hardened Apache Mod_Rewrite Security Rule 
# Provided by Aung Khant,http://yehg.net 
# 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: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
# rewritecond 
# NC = 'nocase|NC' (no case-sensitive) 
# OR = 'ornext|OR' (or next condition) 
# L = last rule 
@geraldvillorente
geraldvillorente / clipcleaner.md
Created Jul 9, 2018
A small bash script to clear the clipboard in MacOS.
View clipcleaner.md

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
geraldvillorente / wp-debug.md
Last active Mar 7, 2019
Managing Wordpress debug.log on Pantheon
View wp-debug.md

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 );
View lando.md
Logged in as xxxxx@getpantheon.com
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.
@pantheon.janus.dev
@geraldvillorente
geraldvillorente / token.md
Created Jun 6, 2018
Get Terminus machine token from cache
View token.md

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

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

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

@geraldvillorente
geraldvillorente / note.md
Created Apr 10, 2018
How to cross check RSA fingerprint?
View note.md

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

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

Problem: WP is slow or dead when editing pages.

Possible Cause: MySQL slow query related to wp_postmeta or wp_options

SELECT DISTINCT meta_key 
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.