Skip to content

Instantly share code, notes, and snippets.

View settermjd's full-sized avatar

Matthew Setter settermjd

View GitHub Profile
<?php
declare(strict_types=1);
namespace App\Iterator;
use Laminas\Mime\Part;
class PartsFilterIterator extends \RecursiveFilterIterator
{
@settermjd
settermjd / listing1.php
Created July 6, 2022 12:51
Laminas Article Code Listings
<?php
declare(strict_types=1);
namespace User\Entity;
class User
{
private readonly int $id;
private readonly string $emailAddress;
name: Deploy to DigitalOcean
on:
push:
tags:
- "v*.*.*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
@settermjd
settermjd / JWTMiddleware.php
Last active August 24, 2021 12:51
Create and validate a JWT in Mezzio (PHP)
<?php
// File location: src/App/src/Middleware/Authorization/JWTMiddleware.php
declare(strict_types=1);
namespace App\Middleware\Authorization;
use DateTime;
use DateInterval;
use \Firebase\JWT\JWT;
use Laminas\Diactoros\Response\RedirectResponse;
@settermjd
settermjd / HelloWorld.java
Last active April 14, 2020 19:17
Examples of the same class in multiple c-based languages
class HelloWorld {
private String name;
public HelloWorld(String name) {
this.name = name;
}
public void printName() {
System.out.println(this.name);
}
@settermjd
settermjd / print-ocapps-uniq-dir-names-human-readable.sh
Last active January 30, 2019 09:51
Bash one-liner to print a list of unique names in ownCloud apps
# Create a temporary file to store the results of the script
tmpfile=$(mktemp /tmp/dirnames.XXX);
# Print the directories found in each app directory
for i in $( ls . )
do
ls -A $i >> $tmpfile
done
# Sort and print a unique list of the discovered directories
@settermjd
settermjd / Dockerfile
Last active January 10, 2019 13:32
Custom owncloud-ubuntu Dockerfile
FROM owncloud/ubuntu:18.04
VOLUME ["/mnt/data"]
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["/usr/local/bin/entrypoint"]
CMD ["/usr/local/bin/owncloud"]
@settermjd
settermjd / complexity-example.c
Created July 12, 2018 08:13
A small C program for the sakes of demonstrating cyclomatic complexity
#include <stdio.h>
#include <time.h>
#include <string.h>
int main()
{
time_t t = time(NULL);
struct tm tm = *localtime(&t);
const char * months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
@settermjd
settermjd / zend-db-sql-join-example.php
Created June 6, 2018 13:16
zend-db-sql join example
<?php
// other setup code...
$select
->where([
'id = ?' => $userId
])
->join(
['r' => 'tblroles'],
#!/bin/bash
# Inspired by http://www.devthought.com/code/create-a-github-pull-request-from-the-terminal/
targetbranch=master
if test "$1"; then
targetbranch=$1
fi
repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`