Skip to content

Instantly share code, notes, and snippets.

View gwhitelaw's full-sized avatar

Jorje Whitelaw gwhitelaw

View GitHub Profile
@gwhitelaw
gwhitelaw / gist:5488195
Created April 30, 2013 11:44
Validate UUID
validateUuid = (text) -> (text || "").match(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/)
validateUuid(null) # returns null
validateUuid("") # returns null
validateUuid("not-a-valid-uuid") # returns null
validateUuid("73963155-27db-48ad-abee-7afa2dd14af1") # returns regex match array
@gwhitelaw
gwhitelaw / go-go-gadget-sugar.coffee
Last active December 25, 2015 21:09
Allow sugarjs to parse multiple friendly dates in the format 1 month 1 day ago
require 'sugar'
{ compact } = require 'underscore'
parseFriendlyDate = (friendlyDate) ->
date = new Date().getTime()
dateOffset = date
dateSections = compact((friendlyDate.trim()).split(/(\d+\s\w+)\s/))
dateEnding = dateSections.splice(-1)
dateSections.forEach((section) -> dateOffset -= (date - Date.create("#{section} #{dateEnding}").getTime()))
new Date(dateOffset)
@gwhitelaw
gwhitelaw / aws-glue-zepplin.md
Last active January 26, 2022 01:39
Easily connect to an AWS Glue Dev endpoint

This is how I quickly got an Apache Zepplin notebook running against the AWS Glue Dev endpoint. None of the guides out there seemed concise, and I found some custom Docker containers doing what you can do easily. This gives you the power - it sets up port forwarding & runs the official Docker image.

  1. Create your Glue Dev endpoint (this involves creating a keypair, I just used ssh-keygen)
  2. Once READY, select it and copy the "SSH tunnel to remote interpreter"
  • eg: ssh -i <private-key.pem> -vnNT -L :9007:169.254.76.1:9007 glue@..compute.amazonaws.com
  1. Connect to the endpoint in a terminal session, modifying the above to match: ssh -i ~/.ssh/glue-dev -vnNT -L :9007:*127.0.0.1*:9007 glue@<ec2-endpoint>.<region>.compute.amazonaws.com
  2. Run the Apache Zepplin Docker container `docker run -p 8080:8080 --rm -v $PWD/logs:/logs -v $PWD/notebook:/notebook -e ZEPPELIN_LOG_DIR='/l