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 / 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 / jenkins.md
Last active August 5, 2021 22:23
How to enable SSL in Jenkins

Enabling SSL in Jenkins is a bit tricky. To do this first you need to convert your keys to PKCS12.

$ sudo openssl pkcs12 -inkey key.pem -in cert.pem -export -out keys.pkcs12

Then created a keystore (password for keystore should be same as password for key).

$ sudo keytool -importkeystore -srckeystore keys.pkcs12 -srcstoretype pkcs12 -destkeystore keystore
@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 / 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 / rsynctify
Last active October 30, 2020 16:09
A simple script of using rsync and inotify to manage two separate repositories.
#!/usr/bin/env bash
#
# @file
# A one directional auto-sync triggered by inotify.
# The inotify-utils must be installed in the system
# before using this script.
#
# @source
# $SOURCE - A git repository.
#
@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 / scan.md
Last active February 28, 2020 14:30
Scan IP with target port

nmap -sS -sV -vv -n -Pn -T5 192.168.1.1-255 -p80 -oG – | grep 'open' | grep -v 'tcpwrapped'
In the above example the target port is 80 and the IP range is 192.168.1.1/24.

@geraldvillorente
geraldvillorente / status.md
Created October 21, 2015 08:00
Check server status
echo ""; echo "Server Status One-liner"; echo ""; echo "Storage: "; df -h | sed -n '2,2p' | awk '{print "Disk:",$3"/"$2,$5}'; df -i | sed -n '2,2p' | awk '{print "Inodes:",$3"/"$2,$5}'; echo ""; echo "Load Average: "; cat /proc/loadavg; echo -ne "Thread Count: "; cat /proc/cpuinfo | grep processor | wc -l; echo ""; echo "Usage: "; mpstat | tail -2; echo ""; echo "Memory: "; free -m; echo ""; echo "Vmstat: "; vmstat; echo ""; echo "Services: ";ps cax | grep mysqld > /dev/null; if [ $? -eq 0 ]; then echo "mysql is running"; else echo "mysql is not running"; fi; ps cax | grep httpd > /dev/null; if [ $? -eq 0 ]; then echo "httpd is running"; else echo "httpd is not running"; fi; ps cax | grep exim > /dev/null; if [ $? -eq 0 ]; then echo "exim is running"; else echo "exim is not running"; fi; ps cax | grep named > /dev/null; if [ $? -eq 0 ]; then echo "named is running"; else echo "named is not running(Are they root?)"; fi; ps cax | grep pure-ftpd > /dev/null; if [ $? -eq 0 ]; then echo "ftpd is running"; else
@geraldvillorente
geraldvillorente / tools.md
Last active February 28, 2020 14:30
My Tools

For full list of tools please see this repo: Development Note

  1. git
  2. geany
  3. letsencrypt
  4. docker
  5. vagrant
  6. meld
  7. git-sweep
  8. htop