Skip to content

Instantly share code, notes, and snippets.

View ckimrie's full-sized avatar

Christopher Imrie ckimrie

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ckimrie on github.
  • I am ckimrie (https://keybase.io/ckimrie) on keybase.
  • I have a public key ASB-F0l2fSFbaeWHkKPvzAEOVqhV52uSOPoINpy2YikFKwo

To claim this, I am signing this object:

@ckimrie
ckimrie / vpc-public-private-eu-west-1.template
Created April 12, 2018 12:04
AWS Cloudformation template to create a VPC with three public/private subnet pairs with default internet gateway routes configured.
Description:
This template deploys a VPC, with a three public and private subnets spread
across three Availability Zones. It deploys an Internet Gateway, with a default
route on the public subnets. It deploys a pair of NAT Gateways (one in each AZ),
and default routes for them in the private subnets.
Parameters:
EnvironmentName:
@ckimrie
ckimrie / UserProfile.ts
Created July 17, 2017 16:23
Reference user profile entity and objects.
interface User {
//Identification & Classification
userId: number;
userName: string; //Unique key for application
type: "MEMBER" | "GUEST" | "ANONYMOUS";
application: Application; //eg User is a member of the Chiltern Arriva system ('application' provides flexibility
// for Chiltern to have many apps with Ace system)
//Profile
firstName: string;
@ckimrie
ckimrie / example.component.ts
Last active December 12, 2023 20:53
Example on how to achieve RxJS observable caching and storage in Angular 2+. Ideal for storing Http requests client side for offline usage.
import { Component, OnInit, OnDestroy } from '@angular/core';
import {Http} from "@angular/http";
import { LocalCacheService } from "./local-cache.service";
@Component({
selector: 'app-example',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class ExampleComponent implements OnInit, OnDestroy {
//-----------------------------------------------//
//On page load
// - Browser -
//-----------------------------------------------//
AWS.config.update({
region: "eu-west-1"
});
var credConfig = {
@ckimrie
ckimrie / signApiGatewayAngular2HttpRequest.ts
Last active January 6, 2019 11:33
How to use AWS Cognito to sign an http request to a custom AWS Api Gateway using IAMs Authorization.
//---- Angular 2 Http Service Example ----
import {Injectable} from "@angular/core";
import {Http, Headers} from "@angular/http";
const AWS = require("aws-sdk");
@Injectable()
export class ApiGatewayService {
constructor(private http:Http){
<link rel="import" href="https://www.polymer-project.org/1.0/components/polymer/polymer.html">
<link rel="import" href="https://gist.githubusercontent.com/ckimrie/22718bfead15b8903b9f7a616342d19f/raw/cedbff08823c585c7d2eebd8ef94d1b204438a50/component.html">
<dom-module id="component-2">
<template>
<style include="component-1">
:host {
display: block;
}
</style>
<link rel="import" href="https://www.polymer-project.org/1.0/components/polymer/polymer.html">
<dom-module id="component-1">
<template>
<style>
:host {
display: block;
}
.red-box {
background-color: red;
color: white;
/**
* $.unserialize
*
* Takes a string in format "param1=value1&param2=value2" and returns an object { param1: 'value1', param2: 'value2' }. If the "param1" ends with "[]" the param is treated as an array.
*
* Example:
*
* Input: param1=value1&param2=value2
* Return: { param1 : value1, param2: value2 }
*
@ckimrie
ckimrie / jsbin.oyecax.html
Created August 23, 2013 16:23
JS Bin math visualisation competition entry. Working version can be seen here: http://jsbin.com/oyecax/2/
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="JS Bin Competition Entry" />
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8/dojo/dojo.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="surface"></div>