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
@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) {

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;
@GFoley83
GFoley83 / UploadController.cs
Created December 10, 2015 02:00 — forked from pdcullen/UploadController.cs
ng-flow asp.net api2 upload class
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using System.Web;
@GFoley83
GFoley83 / AzureStorageApi
Created December 14, 2015 03:35 — forked from trailmax/AzureStorageApi
Uploading large files to Azure Blob Storage via REST API. Code for blog post http://tech.trailmax.info/2014/01/uploading-large-files-to-azure-blob-storage-through-rest-api/
public class AzureStorageApi
{
private const string AzureApiVersion = "2012-02-12";
private const int BlockSize = 4 * 1024 * 1024;
public void UploadFile(string fullFilePath, string blobSasUri, Dictionary<string, string> metadata = null, int timeout = 60)
{
var blocks = new List<String>();
var tasks = new List<Task>();
@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 / Camel Casing
Created April 9, 2016 02:05 — forked from jayhjkwon/Camel Casing
JSON Media-Type Formatter
var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();