Skip to content

Instantly share code, notes, and snippets.

View geraldvillorente's full-sized avatar

Stoick The Vast geraldvillorente

  • Philippines
View GitHub Profile
@geraldvillorente
geraldvillorente / htaccess.md
Created July 23, 2018 06:53
Apache htaccess hardened
# 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 July 9, 2018 11:22
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
geraldvillorente / wp-debug.md
Last active March 7, 2019 16:13
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 );
@geraldvillorente
geraldvillorente / lando.md
Created June 7, 2018 05:52
Lando pull output
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 June 6, 2018 01:15
Get Terminus machine token from cache

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

@geraldvillorente
geraldvillorente / command.md
Created April 16, 2018 17:38
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
geraldvillorente / note.md
Created April 10, 2018 23:58
How to cross check RSA fingerprint?

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

@geraldvillorente
geraldvillorente / solution.md
Last active May 6, 2018 22:22
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

SELECT DISTINCT meta_key 
FROM wp_postmeta 
WHERE meta_key NOT BETWEEN '_'
AND '_z' 
HAVING meta_key NOT LIKE '\\_%'
ORDER BY meta_key 
@geraldvillorente
geraldvillorente / path.md
Last active April 4, 2018 07:00
Working with absolute path on Pantheon.

Wrong way

define( 'WPCACHEHOME', '/srv/bindings/12345678905432167890/code/wp-content/plugins/wp-super-cache/' );

Proper way

define( 'WPCACHEHOME', $_SERVER["DOCUMENT_ROOT"] . '/wp-content/plugins/wp-super-cache/');
@geraldvillorente
geraldvillorente / terminus.md
Created April 1, 2018 23:25
awesome terminus pipe

terminus sites --format=csv --fields=name | xargs -I {} terminus drush {}.live -- pml | grep "mollom"