Skip to content

Instantly share code, notes, and snippets.

@davemcdermid
davemcdermid / update-route53-on-instance-start.js
Created July 28, 2016 12:11
An AWS lambda function to update a Route53 hosted zone with a CNAME to an EC2s public DNS hostname on instance start. Should be triggered by a CloudWatch event.
var AWS = require('aws-sdk');
var domain = '.example.com';
var hostedZone = 'HOSTEDZONEID';
exports.handler = function(event, context, callback) {
var ec2 = new AWS.EC2();
var params = {
InstanceIds : [
event.detail['instance-id']
@davemcdermid
davemcdermid / Spanchor
Last active January 27, 2016 17:38 — forked from anonymous/Spanchor
HtmlHelper extension to toggle between span & anchor easily
using System;
using System.Collections.Generic;
using System.IO;
using System.Web.Mvc;
public static class SpanchorExtension
{
public static Spanchor Spanchor(this HtmlHelper htmlHelper, bool useAnchor, string url, object htmlAttributes = null)
{
var tag = useAnchor ? "a" : "span";
@davemcdermid
davemcdermid / Q JS library.js
Last active March 5, 2017 00:47
A minimalist helper library for simple DOM functions. jQuery style method chaining. Only supports modern browsers, appropriate for mobile.
// Q is a lightweight wrapper around basic DOM functions
// It is similar to jQuery, and follows a similar pattern
// for initialisation and chaining functions.
(function () {
var root,
Q,
fn,
simpleRex = /^(#?[\w-]+|\.[\w-.]+)$/,
periodRex = /\./g,