Skip to content

Instantly share code, notes, and snippets.

Andrew McLagan andrewmclagan

Block or report user

Report or block andrewmclagan

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
@andrewmclagan
andrewmclagan / is_rest.php
Created Sep 5, 2019 — forked from matzeeable/is_rest.php
Checks if the current request is a WP REST API request.
View is_rest.php
<?php
if ( !function_exists( 'is_rest' ) ) {
/**
* Checks if the current request is a WP REST API request.
*
* Case #1: After WP_REST_Request initialisation
* Case #2: Support "plain" permalink settings
* Case #3: It can happen that WP_Rewrite is not yet initialized,
* so do this (wp-settings.php)
@andrewmclagan
andrewmclagan / taxonomy-search-titles.md
Last active Nov 7, 2018
Search title translation reference
View taxonomy-search-titles.md

none

"All jobs"

Location

"Jobs in Melbourne"

"Jobs in {location}"

@andrewmclagan
andrewmclagan / criteriaQuery.php
Last active May 1, 2018
Style of naming and namespacing
View criteriaQuery.php
/*
|--------------------------------------------------------------------------
| Class has function only
|--------------------------------------------------------------------------
*/
use App\Criteria;
$jobs = $repository
->addCriteria(Criteria\Jobs\Approved::class)
View create-cluster.sh
gcloud container clusters create animals-app \
--zone=us-central1-a \
--machine-type=n1-standard-1 \
--num-nodes=3 \
--no-enable-autorepair
View Dockerfile
FROM php:7.2-fpm-alpine3.7
MAINTAINER "Andrew McLagan"
RUN apk --no-cache add \
freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev \
wget \
git \
supervisor \
bash \
@andrewmclagan
andrewmclagan / Dockerfile
Created Apr 11, 2018
docker package manager installation
View Dockerfile
FROM node:8-alpine
# Add package manger file and lock file
COPY package.json yarn.lock /usr/src
# Install dependancies from lockfile and clean package manager cache
RUN yarn install --pure-lockfile && \
yarn cache clean
# Add your application source
View Dockerfile
FROM node:8-alpine
MAINTAINER andrewmclagan
# ...
View repository-interface.php
<?php
namespace EthicalJobs\Foundation\Storage;
use Illuminate\Support\Collection;
interface Repository
{
/**
* Find a model by its id
View CollectionView.js
import React from 'react';
import PropTypes from 'prop-types';
import DataTable from 'components/DataTable';
import CollectionViewControls from 'components/CollectionViewControls';
/**
* Entity collection view
* @author Andrew McLagan <andrewmclagan@gmail.com>
*/
export default ({ collection, children, filters, className }) => (
@andrewmclagan
andrewmclagan / lannisters.js
Created May 22, 2017
React - Interview Question
View lannisters.js
import React from 'react';
window.__state = [
{ name: 'Jaime Lannister', age: 42, avatar: '//api.adorable.io/avatars/134/jaime@adorable.png' },
{ name: 'Cersei Lannister', age: 37, avatar: '//api.adorable.io/avatars/134/cersei@adorable.png' },
{ name: 'Joanna Lannister', age: 16, avatar: '//api.adorable.io/avatars/134/joanna@adorable.png' },
];
// Create react component(s) to display a list of Lannister family members
You can’t perform that action at this time.