Skip to content

Instantly share code, notes, and snippets.

View GFoley83's full-sized avatar
☘️
CTO @ Educa

Gavin Foley GFoley83

☘️
CTO @ Educa
View GitHub Profile
/*!
* 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
GFoley83 / draggableAngularTodoList.js
Last active December 20, 2015 16:18
AngularJS | TodoMVC + AngularFire + Drag & Touch support | http://plnkr.co/edit/gist:6160061?p=preview
/*global angular */
/*jshint unused:false */
'use strict';
/**
* The main TodoMVC app module
*
* @type {angular.Module}
*/
var todomvc = angular.module('todomvc', ['firebase', 'ui']);
@GFoley83
GFoley83 / angular-utility.js
Last active August 29, 2015 13:57
AngularJS / Javascript Utility Service compiled of different functions. See comment below for breakdown.
(function (ng, $) {
angular.module('helper')
.factory('utils', ['$timeout', '$window', function ($timeout, $window) {
var utils = {};
// http://ng.malsup.com/#!/getting-started-with-$q
// A nice way of calling $timeout
/*
utils.wait(5).then(function(msg) {
@GFoley83
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.
/*
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
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.
/*
Bootstrap 3.1.1 namepaced to .tw-bs
E.g.
<table>
// my regular table
</table>
<div class="tw-bs">
<table>

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

{

private async Task<FacebookUserViewModel> VerifyFacebookAccessToken(string accessToken)
{
FacebookUserViewModel fbUser = null;
var path = "https://graph.facebook.com/me?access_token=" + 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();
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"];
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
GFoley83 / BlobStorageMultipartStreamProvider.cs
Created October 27, 2015 03:18 — forked from JamesRandall/BlobStorageMultipartStreamProvider.cs
Azure Blob Container Web API Image Upload
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;