Skip to content

Instantly share code, notes, and snippets.

@davidalger
davidalger / memory-usage-log.md
Created May 4, 2017 16:12
PHP Memory Usage Log

Setup memory log on php-fpm pool

  1. Added the following to /usr/local/lib/strangecode_php_memory_log.php

     <?php
     function strangecode_php_memory_log()
     {
         $current = memory_get_usage() / 1024 / 1024;
         $peak = memory_get_peak_usage() / 1024 / 1024;
    

$uri = $_SERVER['REQUEST_URI'] ?? 'n/a';

@mttjohnson
mttjohnson / gist_search.md
Last active June 6, 2017 21:06
Gist User Search
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active March 27, 2025 04:09
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost