Skip to content

Instantly share code, notes, and snippets.

View ckimrie's full-sized avatar

Christopher Imrie ckimrie

View GitHub Profile
@ckimrie
ckimrie / loadCss.js
Last active December 17, 2015 09:29
Lightweight CSS loader
/**
* Lightweight CSS Loader
*
* Even prepends the correct theme URL location to allow easy script loading
*
* @param {string} name URL to CSS file
* @param {Function} cb Callback function
* @return {null}
*/
function loadCss(name, cb) {

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer

@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>
/**
* $.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 }
*
<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;
<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>
@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){
//-----------------------------------------------//
//On page load
// - Browser -
//-----------------------------------------------//
AWS.config.update({
region: "eu-west-1"
});
var credConfig = {
@ckimrie
ckimrie / example.component.ts
Last active May 5, 2026 15:13
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 {
@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;