Skip to content

Instantly share code, notes, and snippets.

View andrewmclagan's full-sized avatar
:octocat:
Opening The Sauce

(Rew) Andrew McLagan andrewmclagan

:octocat:
Opening The Sauce
  • Atomi
  • Melbourne, Australia
View GitHub Profile
@andrewmclagan
andrewmclagan / sbf_Store.js
Last active November 12, 2015 02:58 — forked from colinf/sbf_Store.js
Base Flux Store class in ES6 ( See http://cl.ly/0J3j3D1k0742 )
import EventEmitter from 'events';
class Store extends EventEmitter {
static CHANGE_EVENT = 'change';
constructor() {
super();
}
@andrewmclagan
andrewmclagan / ResponseFormatter.php
Created April 8, 2016 02:08
Dingo API - Eloquent model attributes as camel case
<?php
namespace App\Http;
use Illuminate\Support\Str;
use Dingo\Api\Http\Response\Format\Json as JsonFormatter;
/**
* Formats json API responses
*
@andrewmclagan
andrewmclagan / drone build
Last active May 12, 2016 06:21
drone yml cache problems
....
RUNNING
started 8 minutes ago
CANCEL
[info] Pulling image plugins/drone-cache:latest
Drone Cache Plugin built from 96d0472
Restoring cache docker/_____/cache-image.tar
Unable to restore docker/_____/cache-image.tar. Cache does not exist
Restoring cache from master branch
@andrewmclagan
andrewmclagan / index.js
Created July 25, 2016 00:34
requirebin sketch
const normalizr = require('normalizr');
const response = {
data: {
id: 1,
title: 'Lord of the Rings',
pages: 9250,
publisher: {
data: {
id: 1,
@andrewmclagan
andrewmclagan / index.js
Last active July 26, 2016 00:07
requirebin sketch
/*
|------------------------------------------------------------------------------------
| Normalizing nested API responses, where entities are keyed. As per JSON-API specs
|------------------------------------------------------------------------------------
*/
const normalizr = require('normalizr');
const response = {
data: {
@andrewmclagan
andrewmclagan / Dockerfile
Created February 9, 2016 23:37
react-redux-universal-hot-example Sample Dockerfile with AWS S3 static asset upload
FROM node:5.1.1
#Install AWS CLI
RUN apt-get update
RUN apt-get install -y python-pip
RUN pip install awscli
RUN mkdir -p /root/.aws
RUN echo '[default]' > /root/.aws/config
RUN echo 'output = json' >> /root/.aws/config
RUN echo 'region = us-east-1' >> /root/.aws/config
@andrewmclagan
andrewmclagan / Dockerfile
Created October 12, 2016 00:15
Docker layer caching with php composer
# create our app directory
RUN mkdir -p /var/www
# Set it as our working dir
WORKDIR /var/www
# add our composer dependancies
ADD composer.json ./
# install our dependancies without running scripts
@andrewmclagan
andrewmclagan / Dockerfile
Last active October 12, 2016 22:33
Example Laravel production alpine dockerfile
FROM andrewmclagan/aphex:latest
#
#--------------------------------------------------------------------------
# Configure
#--------------------------------------------------------------------------
#
ADD ./nginx.conf /etc/nginx/nginx.conf
@andrewmclagan
andrewmclagan / from12to24.js
Last active December 9, 2016 02:11
Testing the conversation of 12 hour to 24 hour format
export function from12to24(hours, minutes, meridian) {
let h = parseInt(hours, 10);
const m = parseInt(minutes, 10);
if (meridian.toUpperCase() === 'PM') {
h = (h !== 12) ? h + 12 : h;
} else {
h = (h === 12) ? 0 : h;
}
return new Date((new Date()).setHours(h,m,0,0));
}
@andrewmclagan
andrewmclagan / ElasticsearchIndexer.php
Created February 2, 2017 21:43
Elasticsearch indexer
<?php
namespace App\Services;
use Illuminate\Support\Collection;
use Illuminate\Database\Eloquent\Model;
use Elasticsearch\Client;
use App\Models;
/**