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 / 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 / docker-compose.yml
Last active February 12, 2018 13:31
Horizontal Laravel with Docker Compose
load_balancer:
image: tutum/haproxy
links:
- web
ports:
- "80:80"
cache:
image: redis
@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 / actions.js
Last active March 12, 2023 12:23
react-redux-universal-hot-example
export function login(loginHandle, password) {
return {
types: [LOGIN_REQUEST, LOGIN_SUCCESS, LOGIN_FAILURE],
promise: (api) => api.post('/auth/login', { login: loginHandle, password }).then(response => {
setAuthCookie(response.token); // side effect pre success dispatch
return response;
}),
then: (response) => {
postLoginRedirect(browserHistory.push, response.user, response.organisation); // side effect post success dispatch
},
@andrewmclagan
andrewmclagan / CreateUser.js
Last active May 7, 2020 11:51
[6.x.x] ReduxForm testing
import React, { Component, PropTypes } from 'react';
import { reduxForm, Field } from 'redux-form';
export class CreateUser extends Component {
static propTypes = {
createUser: PropTypes.func.isRequired,
initialValues: PropTypes.object,
submitting: PropTypes.bool.isRequired,
invalid: PropTypes.bool.isRequired,
@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 / Normalizr.php
Last active August 3, 2018 22:21
Normalized fractal response
<?php
namespace App\Http;
use League\Fractal\Pagination\CursorInterface;
use League\Fractal\Pagination\PaginatorInterface;
use League\Fractal\Resource\ResourceInterface;
use League\Fractal\Serializer\ArraySerializer;
class Normalizr extends ArraySerializer