Skip to content

Instantly share code, notes, and snippets.

View jmsfwk's full-sized avatar

James Fenwick jmsfwk

View GitHub Profile
@jmsfwk
jmsfwk / Appendix 3.md
Last active March 13, 2020 11:51
Extract from "Bulk Data Transfer - additional validation valid from 12 November 2015"

BULK DATA TRANSFER: ADDITIONAL VALIDATION FOR CAS UPLOAD

3. UK Postcode Regular Expression

The following is the UK Postcode Regular Expression and the corresponding detail explaining the logic behind the UK Postcode Regular Expression.

3.1 Expression

^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2})$
@jmsfwk
jmsfwk / pre-push
Last active June 6, 2019 15:38 — forked from jgosmann/pre-push
Prevent pushing fixup, squash, and WIP commits to master.
#!/bin/sh
# An example hook script to verify what is about to be pushed to master. Called
# by "git push" after it has checked the remote status, but before anything has
# been pushed. If this script exits with a non-zero status nothing will be
# pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
@jmsfwk
jmsfwk / git-cleanup
Created June 6, 2019 13:46
Git delete merged branches
#!/bin/bash
set -ue
git fetch
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
@jmsfwk
jmsfwk / default.conf
Created January 31, 2019 16:11
Laravel docker compose configuration
server {
listen 80;
root /usr/share/nginx/html;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
@jmsfwk
jmsfwk / default.conf
Last active February 20, 2019 10:23
Nginx conf for an app in different places in different containers
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
}
<?php
abstract class Factory
{
/** @var \Illuminate\Database\ConnectionInterface */
private $database;
/** @var \Faker\Generator */
protected $faker;
protected $attributes = [];
@jmsfwk
jmsfwk / suggestion.md
Last active July 13, 2018 10:37
PSR-15 Middleware vs HttpKernelInterface implemented as middleware

Different middleware implementations for comparison

PSR-15 Middleware

<?php

use Psr\Http\Server\{MiddlewareInterface, RequestHandlerInterface};
use Psr\Http\Message\{ServerRequestInterface, ResponseInterface};

class Middleware implements MiddlewareInterface
@jmsfwk
jmsfwk / listbox.html
Last active February 28, 2018 14:59
<html>
<head>
<meta charset="UTF-8">
<script src="vue.js"></script>
<script>
const data = [
{
"id": "739d8b36-e80f-4c04-9188-757a5bd64e70",
"headline": "Liverpool initiative for renewing housing stock to benefit local contractors"
},
@jmsfwk
jmsfwk / .gitlab-ci.yml
Created February 7, 2018 12:23
Gitlab Ci configuration for simple PHP projects
before_script:
# Install dependencies
- sh docker_install.sh > /dev/null
cache:
paths:
- vendor/
php:7.1:
image: php:7.1-alpine
@jmsfwk
jmsfwk / Context.php
Created February 5, 2018 11:55
Class to send data to template that tries to avoid exceptions when data does not exists
<?php
use ArrayAccess;
use ArrayIterator;
use IteratorAggregate;
class Context implements ArrayAccess, IteratorAggregate
{
/** @var array */
private $data;