Skip to content

Instantly share code, notes, and snippets.

View nigelhanlon's full-sized avatar

Nigel Hanlon nigelhanlon

View GitHub Profile

Keybase proof

I hereby claim:

  • I am nigelhanlon on github.
  • I am nigelhanlon (https://keybase.io/nigelhanlon) on keybase.
  • I have a public key ASDFY4I4W9fjzNAr-NEC2tXrACSE1zQ7Af1sjN4zo6TIrwo

To claim this, I am signing this object:

@nigelhanlon
nigelhanlon / fastify-xclacks.js
Created June 7, 2018 08:29
Add an X-Clacks header to all fastify responses
// See https://xclacksoverhead.org/home/about for more information.
// This adds a simple header via Hooks (https://www.fastify.io/docs/latest/Hooks/)
fastify.addHook('onResponse', (res, next) => {
res.set('X-Clacks-Overhead', 'GNU Terry Pratchett');
next()
})
@nigelhanlon
nigelhanlon / TMP36Reader.c
Created April 30, 2017 14:03
A simple node.js script for reading temperatures via Arduino Serial port.
//
// Source adapted slightly from https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor.
//
//TMP36 Pin Variables
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
/*
@nigelhanlon
nigelhanlon / tocsv.js
Last active April 11, 2017 16:11
Convert JavaScript Object to CSV Row
/*
The MIT License (MIT)
Copyright (c) 2017 Nigel Hanlon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@nigelhanlon
nigelhanlon / working_with_geojson.js
Last active January 1, 2016 03:18
Example JavaScript from the Working with GeoJSON tutorial at http://www.mapwolf.net/geojson
function addGeoJSON(geojson){
// Create a GeoJSON parser that will convert our features
// to something OpenLayers understands.
var geojson_format = new OpenLayers.Format.GeoJSON({
'internalProjection': new OpenLayers.Projection("EPSG:900913"),
'externalProjection': new OpenLayers.Projection("EPSG:4326")
});
// Create a vector layer that our features will sit on.
var vector_layer = new OpenLayers.Layer.Vector("Mountains");
@nigelhanlon
nigelhanlon / carrauntoohil.json
Created December 22, 2013 11:21
An example GeoJSON feature showing the highest peak in Ireland, Carrauntoohil in the Macgillycuddy's Reeks mountain range.
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-9.7427,51.9994]
},
"properties": {
"name": "Carrauntoohil",
"elevation": 1038
}