Skip to content

Instantly share code, notes, and snippets.

View iamstoick's full-sized avatar

Stoick The Vast iamstoick

  • Philippines
View GitHub Profile
@iamstoick
iamstoick / gist:5b70d0befdaa045cc10fefc610352f2c
Created January 3, 2020 09:30 — forked from mloberg/gist:2852153
MySQL Slow Query Log Analyzer
#!/usr/bin/php
<?php
/**
* The Analyzer class.
*/
class Analyzer {
private $fp;
@iamstoick
iamstoick / 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 
@iamstoick
iamstoick / 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.

@iamstoick
iamstoick / 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 );
@iamstoick
iamstoick / lando.md
Created June 7, 2018 05:52
Lando pull output
Logged in as [email protected]
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
@iamstoick
iamstoick / token.md
Created June 6, 2018 01:15
Get Terminus machine token from cache

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

@iamstoick
iamstoick / 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

@iamstoick
iamstoick / note.md
Created April 10, 2018 23:58
How to cross check RSA fingerprint?

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

@iamstoick
iamstoick / 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 
@iamstoick
iamstoick / 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/');