Skip to content

Instantly share code, notes, and snippets.

Matthew Setter settermjd

Block or report user

Report or block settermjd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@settermjd
settermjd / retrieve-github-pr-commit-hashes.sh
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.
View retrieve-github-pr-commit-hashes.sh
#!/bin/bash
$username=<your username>
$password=<your password>
$owner=<repository owner>
$repo=<repository>
$pull_request_id=<pull request id to filter by>
curl --silent -u $username:$password https://api.github.com/repos/$owner/$repo/pulls/$pull_request_id/commits \
| jq --raw-output '.[].sha' | tr '\r\n' ' '
View vim-cheatsheet.md

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.

Regexes

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
settermjd / generate-commit-range.sh
Created Aug 9, 2017
Generate a git commit frange
View generate-commit-range.sh
git log --format=%h stable10..master | (head -n1 && tail -n1) | xargs -n 2 | awk '{ print $1".."$2 }'
View phpinfo
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
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
ENV XDEBUG_IDE_KEY PhpStorm
ENV XDEBUG_REMOTE_CONNECT_BACK 1
ENV XDEBUG_REMOTE_ENABLE true
ENV XDEBUG_REMOTE_HANDLER dbgp
ENV XDEBUG_REMOTE_PORT 9000
@settermjd
settermjd / download-file-in-expressive.php
Last active Aug 31, 2018
Quick example of how to download/stream a file using Zend Expressive.
View download-file-in-expressive.php
<?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
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
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
<?php
/**
* @param string $directory
*/
function emptyDirectoryContents($directory)
{
$Iterator = new RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
realpath($directory),
@settermjd
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
<?php
$this->insert
->into('foo')
->columns(['col1', 'col2', 'col3'])
->values(['val1', 'val2', 'val3']);
$this->assertEquals(
'INSERT INTO foo ("col1", "col2", "col3") VALUES("val1", "val2", "val3")',
$this->insert->getSqlString(new TrustingSql92Platform())
);
@settermjd
settermjd / dependencies.global.php
Created Oct 30, 2015
Zend-Expressive Dependencies configuration which adds Zend\Db and Zend\Cache support.
View dependencies.global.php
<?php
return [
'dependencies' => [
'invokables' => [
App\Action\PingAction::class => App\Action\PingAction::class,
],
'factories' => [
App\Action\HomePageAction::class => App\Action\HomePageFactory::class,
Zend\Expressive\Application::class => Zend\Expressive\Container\ApplicationFactory::class,
You can’t perform that action at this time.