Skip to content

Instantly share code, notes, and snippets.

CTO @ Educa

Gavin Foley GFoley83

CTO @ Educa
View GitHub Profile
View load-google-maps.js
* JavaScript - loadGoogleMaps( version, apiKey, language, sensor )
* - Load Google Maps API using jQuery Deferred.
* Useful if you want to only load the Google Maps API on-demand.
* - Requires jQuery 1.5
* UPDATES by Gavin Foley
* - Tidied JS & made it JSLint compliant
* - Updated script request to Google Maps API to be protocol relative
GFoley83 / draggableAngularTodoList.js
Last active December 20, 2015 16:18
AngularJS | TodoMVC + AngularFire + Drag & Touch support |
View draggableAngularTodoList.js
/*global angular */
/*jshint unused:false */
'use strict';
* The main TodoMVC app module
* @type {angular.Module}
var todomvc = angular.module('todomvc', ['firebase', 'ui']);
GFoley83 / angular-utility.js
Last active August 29, 2015 13:57
AngularJS / Javascript Utility Service compiled of different functions. See comment below for breakdown.
View angular-utility.js
(function (ng, $) {
.factory('utils', ['$timeout', '$window', function ($timeout, $window) {
var utils = {};
// A nice way of calling $timeout
utils.wait(5).then(function(msg) {
GFoley83 / location-finder.js
Last active January 22, 2020 11:55
A function which returns a jQuery promise that resolves when a user's location has been found. Also handles the scenario where by when not clicking allow/deny the browser never fires the timeout option of `getCurrentPosition()`. If `getCurrentPosition()` fails then the fallback lat lng is used instead.
View location-finder.js
Sample use:
var loc = new LocationFinder(-41.29247, 174.7732);
$.when(loc.findUserLocationAsync()).then(function (lat, lng) {
// console.log("Lat & lng set as: ", loc.usersPosition())
GFoley83 / tw-bs.3.1.1.css
Last active September 13, 2017 15:55
Twitter Bootstrap 3.1.1 namespaced to "tw-bs" so as not to conflict with other libraries/pre-existing css rules.
View tw-bs.3.1.1.css
Bootstrap 3.1.1 namepaced to .tw-bs
// my regular table
<div class="tw-bs">

Owin Authentication with Web API 2

Using Microsoft.Owin.Security along with .NET Web API 2 for authentication on Single Page Applications.

My example is split up into 2 different projects, API which is WebAPI2 project and MyProj which is a basic MVC that contains primarily only JavaScript/CSS/etc and the startup classes.

API > AccountController.cs

namespace API


View gist:6162323ccbde402598ad
private async Task<FacebookUserViewModel> VerifyFacebookAccessToken(string accessToken)
FacebookUserViewModel fbUser = null;
var path = "" + accessToken;
var client = new HttpClient();
var uri = new Uri(path);
var response = await client.GetAsync(uri);
if (response.IsSuccessStatusCode)
var content = await response.Content.ReadAsStringAsync();
View aspnetmvc_discourse_sso.cs
public ActionResult DiscourseLogin()
if (string.IsNullOrEmpty(Request.QueryString["sso"]) || string.IsNullOrEmpty(Request.QueryString["sig"]))
return Content("Invalid");
string ssoSecret = "YOUR SSO SECRET"; //must match sso_secret in discourse settings
string sso = Request.QueryString["sso"];
string sig = Request.QueryString["sig"];
View gist:ac35f56ec4bf20926f5f
public class InventoryController : ApiController
private readonly IInventoryManagementService _inventoryManagementService;
private readonly IUnitOfWork _unitOfWork;
public InventoryController(IUnitOfWork unitOfWork)
_unitOfWork = unitOfWork; //access services
_inventoryManagementService = _unitOfWork.Get<IInventoryManagementService>();
GFoley83 / BlobStorageMultipartStreamProvider.cs
Created October 27, 2015 03:18 — forked from JamesRandall/BlobStorageMultipartStreamProvider.cs
Azure Blob Container Web API Image Upload
View BlobStorageMultipartStreamProvider.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;