Skip to content

Instantly share code, notes, and snippets.

View JamesRandall's full-sized avatar

James Randall JamesRandall

View GitHub Profile
@JamesRandall
JamesRandall / RedirectRootToSwagger.cs
Created August 13, 2016 09:29
Redirect the root path of an Owin hosted application to the swagger end point
using System.Net;
using Owin;
namespace MyApplication.Api.Extensions
{
// ReSharper disable once InconsistentNaming
public static class IAppBuilderExtensions
{
public static IAppBuilder RedirectRootToSwagger(this IAppBuilder app)
{
@JamesRandall
JamesRandall / MapAppServiceDomain.cs
Last active March 25, 2017 08:12
Demonstrates how to map a domain name to an Azure website programmatically
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Newtonsoft.Json.Linq;
static class DomainMapper
@JamesRandall
JamesRandall / routeProfileRenderer.js
Last active February 20, 2017 14:39
3d GPS Route Profile Rendering
// When given a set of GPS points and a container DOM element the code below will render a 3d profile of your GPS route.
// It requires three.js and that libraries associated Orbit Controls to run.
// The gpsPoints parameter should be an array with the following structure:
// [{latitude:0.323234,longitude:56.23244,altitude:1.8},...]
// To use in most browers compile with Babel as it uses a smattering of ES2015
export default function attachRenderer(container, gpsPoints) {
const THREE = window.THREE
// haversine formula calcuates the distance in km between two points of lon,lat
function haversineDistanceKm(lon1,lat1,lon2,lat2) {
function toRad(deg) {
@JamesRandall
JamesRandall / todo.jsx
Last active August 2, 2016 06:56 — forked from caike/todo.jsx
Simple Todo app demo using React + ES6
var allItems = []
allItems.push("Buy ingredients for Crock Pot");
allItems.push("Pick up chair at IKEA");
allItems.push("Go see mom");
class TodoList extends React.Component {
constructor(props){
super(props);
}
getInitialState() {
@JamesRandall
JamesRandall / AllowMarkdownCorsModule.cs
Last active April 9, 2016 19:53
Enable serving of static Markdown content to JavaScript running on any domain
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MyWebsite.Helpers
{
public class AllowMarkdownCorsModule : IHttpModule
{
public void Init(HttpApplication context)