Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View geraldvillorente's full-sized avatar

Stoick The Vast geraldvillorente

  • Philippines
View GitHub Profile

Keybase proof

I hereby claim:

  • I am geraldvillorente on github.
  • I am stoickthevast (https://keybase.io/stoickthevast) on keybase.
  • I have a public key ASD1dECCTmvuLrZot45BcLtf1yD6taZCEVQtA_HUDw7jrAo

To claim this, I am signing this object:

@geraldvillorente
geraldvillorente / resolve.md
Last active October 27, 2022 01:40
curl resolve script

Application

This script is useful if there is a proxy or a CDN between the client and the Pantheon Global CDN. This script will allow you to bypass the external CDN/proxy and resolve the request directly to Pantheon GCDN.

Default request flow:

Client browser -> Cloudflare/ Proxy -> GCDN -> Pantheon Origin

With this script:

Client browser -> GCDN -> Pantheon Origin

@geraldvillorente
geraldvillorente / dig.md
Created October 25, 2022 01:59
Get the TTL from the authoritative server
#!/bin/bash

show_help(){
        echo Usage $0 domain
}

if [ -z "$1" ]; then
        show_help
 exit 1
@geraldvillorente
geraldvillorente / cache-warm.php
Created November 22, 2021 23:23
Cache warmer - Pantheon
<?php
if ($_ENV['PANTHEON_ENVIRONMENT'] != 'live') {
die();
}
$config['email'] = '[EMAIL]';
$config['sitemap'] = 'https://www.mydomain.com/post-sitemap.xml';
check_sitemap_urls($config['sitemap'], $config['email'], 30);
@geraldvillorente
geraldvillorente / cloudflare.json
Created November 22, 2021 23:18
Purge Cloudflare cache
{
"zone_id": "[ZONE_ID]",
"api_key": "[API_KEY]",
"email": "[EMAIL]"
}
@geraldvillorente
geraldvillorente / inotify-watch.md
Last active August 9, 2021 22:28
Watch the changes to the directory recursively
inotifywait -m -r /path/to/monitor -e create -e moved_to -e modify -e delete  |
    while read dir action file; do
        echo "The file '$file' appeared in directory '$dir' via '$action'"
        // Do what you want here.
    done

The following events are valid for use with the -e option:

@geraldvillorente
geraldvillorente / thermal.sh
Created June 30, 2021 23:19
Utility script to determine CPU, GPU, and IO thermal level
#!/bin/bash
sysctl machdep.xcpm.cpu_thermal_level
sysctl machdep.xcpm.gpu_thermal_level
sysctl machdep.xcpm.io_thermal_level
@geraldvillorente
geraldvillorente / session.txt
Created August 23, 2020 23:18
Pantheon session handled by Redis
$settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], true);
ini_set('session.save_handler', 'redis');
ini_set('session.save_path', 'tcp://' . $settings['conf']['redis_client_host'] . ':' . $settings['conf']['redis_client_port'] . '?auth=' . $settings['conf']['redis_client_password']);
session_set_cookie_params(15*60, '/', $_SERVER["HTTP_HOST"], true, true);
session_start();
@geraldvillorente
geraldvillorente / grok-pattern.md
Created January 3, 2020 13:03
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}
@geraldvillorente
geraldvillorente / 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;