Skip to content

Instantly share code, notes, and snippets.

View TomHAnderson's full-sized avatar
🏠
Working from home

Tom H Anderson TomHAnderson

🏠
Working from home
View GitHub Profile
query PerformanceCountByArtistId {
performances (filter: { artist: {eq: 2} year: {eq: 1995} } ) {
totalCount
}
}
FROM php:8.1-apache
# Suppress warnings from apt about lack of Dialog
ENV DEBIAN_FRONTEND noninteractive
LABEL author="apiskeletons.com" \
org.label-schema.docker.dockerfile="/Dockerfile" \
org.label-schema.name="PHP using Apache" \
org.label-schema.url="https://apiskeletons.com/" \
org.label-schema.vcs-url="https://gist.github.com/TomHAnderson/a0e2455ede671997038b93086c930961"
##
# Configure Server
#
# This script is to be ran on a fresh droplet from Digital Ocean to prep
# the droplet to host docker for api.etreedb.org. This is not necessary
# for installations where docker is already installed.
##
apt-get update
apt-get install -y apt-transport-https ca-certificates curl \
<script>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
@TomHAnderson
TomHAnderson / DateTimeCorrectTimeZone.md
Created March 22, 2020 03:28
Auto correcting datetimes with timezones which do not match the server or database
<?php

/**
 * This is an example of datetime handling where dates with different timezones are
 * handled in the same application. But of course the server and database are fixed
 * to a single matching timezone.
 */

function date_default_timezone_get__example($timezone = null)

Directions in the Angular Style Guide read:

All of the app's code goes in a folder named src. All feature areas are in their own folder, with their own NgModule.

Angular - Style Guide

Angular Directory Structure is a talk, an application, and documentation detailing Angular application feature areas which may be applied piecemeal

public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null || $value instanceof DateTimeInterface) {
return $value;
}
$val = DateTime::createFromFormat('Y-m-d H:i:s.u', $value);
if (! $val) {
$val = date_create($value);
@TomHAnderson
TomHAnderson / QueryProvider.md
Last active October 12, 2017 05:11
A Query Provider for Updating a Source
namespace DbApi\Query\Provider\Source;

use ZF\Rest\ResourceEvent;
use DbApi\Query\Provider\AbstractQueryProvider;
use Db\Fixture\RoleFixture;

final class Patch extends AbstractQueryProvider
{
 public function createQuery(ResourceEvent $event, $entityClass, $parameters)

Download Composer

Run this in your terminal to get the latest Composer version:

curl -sS https://getcomposer.org/installer | php 

Or if you don't have curl:

php -r "readfile('https://getcomposer.org/installer');" | php
class Module implements ApigilityProviderInterface
{
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$sharedEventManager = $eventManager->getSharedManager();
print_r($sharedEventManger);die('post shared event manager');