Skip to content

Instantly share code, notes, and snippets.

View johnutzm's full-sized avatar

Ionuț Matei johnutzm

  • Ionut Matei
  • Bucharest
View GitHub Profile

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

@johnutzm
johnutzm / session-life-cycle.md
Created June 22, 2018 11:36 — forked from mindplay-dk/session-life-cycle.md
Complete overview of the PHP SessionHandler life-cycle

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

@johnutzm
johnutzm / Dockerfile
Created March 27, 2018 15:46
Dockerfile with PHP and Composer, custom user and PHP version can be set via ARG
ARG PHP_VERSION=7.1
FROM php:${PHP_VERSION}-fpm
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
libfreetype6-dev \
libjpeg62-turbo-dev \
php app/console doctrine:schema:drop --force && php app/console doctrine:schema:create && php app/console doctrine:fixtures:load
@johnutzm
johnutzm / filter.d-nginx-40x.conf
Last active December 30, 2015 08:29
jail.local
[Definition]
failregex = <HOST> - - \[.*\] "(GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT).*HTTP.* 4|50.
ignoreregex =
@johnutzm
johnutzm / gist:6351784
Created August 27, 2013 10:08
Create a new MySQL user and grant privileges on all databases with name starting with his/her name.
CREATE USER 'prod'@'%' IDENTIFIED BY '***';
GRANT ALL PRIVILEGES ON `prod\_%` . * TO 'prod'@'%';