Skip to content

Instantly share code, notes, and snippets.

Matthew Setter settermjd

View GitHub Profile
settermjd /
Created Nov 30, 2017
Find images whose width is greater than X
set -e
# Set the width from the first argument (could do this with getopts).
# Filter the images using a combination of file and awk.
file images/* | awk -v width="$width" '{ if ($5 > width) print $1 }' | tr -d ':'
settermjd /
Created Nov 28, 2017
Retrieve the commit hashes for a GitHub PR and output them on a single line. Suitable for use with git cherry-pick, etc.
$username=<your username>
$password=<your password>
$owner=<repository owner>
$pull_request_id=<pull request id to filter by>
curl --silent -u $username:$password$owner/$repo/pulls/$pull_request_id/commits \
| jq --raw-output '.[].sha' | tr '\r\n' ' '

This is a cheatsheet with little bits and pieces that I've picked up along with way in VIM. I hope that you find it helpful.


Split each sentences in a paragraph onto a newline. It only does a simplistic determination of a sentence, that being a full-stop, followed by a space and a capital letter.

:'<,'>s/\. \(\u\)/.\r\1/g
settermjd /
Created Aug 9, 2017
Generate a git commit frange
git log --format=%h stable10..master | (head -n1 && tail -n1) | xargs -n 2 | awk '{ print $1".."$2 }'
View phpinfo
PHP Version => 7.0.8
System => Linux c179beb02e97 4.4.20-moby #1 SMP Thu Sep 15 12:10:20 UTC 2016 x86_64
Build Date => Jun 23 2016 23:50:23
Configure Command => './configure' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-fpm' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--disable-cgi' '--enable-mysqlnd' '--enable-mbstring' '--with-curl' '--with-libedit' '--with-openssl' '--with-zlib'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => /usr/local/etc/php/php.ini
settermjd / Dockerfile
Last active Sep 16, 2016
Docker Compose configuration
View Dockerfile
FROM interactivesolutions/zf-php-fpm:7.0
ENV PHP_MODULES /usr/local/lib/php/extensions/no-debug-non-zts-20151012/
ENV XDEBUG_CONFIG /usr/local/etc/php/conf.d/xdebug.ini
settermjd / download-file-in-expressive.php
Last active Mar 6, 2020
Quick example of how to download/stream a file using Zend Expressive.
View download-file-in-expressive.php
* This is a quick example of how to stream a file to a client, likely a browser,
* using Zend Expressive. There are a lot of factors which it doesn't take in to
* account. But for the purposes of a quick intro, this should suffice.
class ViewDocumentPageAction
protected function downloadFile()
settermjd / Hydration, Hydration - And Not a Drop to Drink!.md
Last active Jun 22, 2016
This is an abstract for a talk about using the Zend Hydrator package to hydrate and extract simple to sophisticated objects.
View Hydration, Hydration - And Not a Drop to Drink!.md

Data, Data Everywhere And Not a Drop to Drink!

Populating objects with data (commonly referred to hydration), and extraction of said data from objects, are two key aspects of building object-oriented applications. It doesn’t matter whether the data source is a Relational, NoSQL, or Graph database, a flat text file, or a form. We need to hydrate and extract data - a lot. But how do we do it effectively - especially when objects can be quite complex?

In this tutorial, I will teach you how to use the Zend Hydrator package to perform both hydration and extraction. We’ll start off working with simple objects, and hydrate them from a relational database. We’ll then, gradually, increase in complexity, showing how to hydrate increasingly complex objects. We’ll also see how to create flexible and sophisticated hydrators which can use a multitude of data sources, such as forms, along with how to extract data from hydrated o

settermjd / empty-directory-contents.php
Created Feb 24, 2016
A simple script to recursively delete all files and directories within a parent directory
View empty-directory-contents.php
* @param string $directory
function emptyDirectoryContents($directory)
$Iterator = new RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
settermjd / InsertTest.php
Last active Feb 8, 2016
The following test for Zend\Db\Sql\InsertTest fails. Yet I'd have thought it would pass.
View InsertTest.php
->columns(['col1', 'col2', 'col3'])
->values(['val1', 'val2', 'val3']);
'INSERT INTO foo ("col1", "col2", "col3") VALUES("val1", "val2", "val3")',
$this->insert->getSqlString(new TrustingSql92Platform())
You can’t perform that action at this time.