Skip to content

Instantly share code, notes, and snippets.

@dereklawless
dereklawless / app-version-helper.js
Created June 27, 2014 13:03
Cordova iOS appversion plugin JavaScript wapper
define(function (require, cordova, undefined) {
'use strict';
/**
* @private
*/
var settings = require('settings');
return {
/**
@dereklawless
dereklawless / action-sheet-helper.js
Created June 27, 2014 13:01
Cordova iOS actionsheet plugin JavaScript wrapper
define(function (undefined) {
'use strict';
return {
/**
* Initialises the actionsheet helper on the global scope.
*/
init: function () {
if (this.useNative()) {
console.log('Using native actionsheet');
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace App.API.Handlers
{
/// <summary>
/// A custom handler for adding an MD5 hash of the HTTP response content to the HTTP response headers.
/// </summary>
public class HttpResponseChecksumHandler : DelegatingHandler
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using System;
using Newtonsoft.Json;
namespace App.API.MediaFormatters
{
/// <summary>
/// A custom JSON converter, for serialising a value type as a string.
/// </summary>
public class ValueTypeAsStringJsonConverter : JsonConverter
{
using Microsoft.Practices.ServiceLocation;
using StructureMap;
namespace App.Configuration
{
/// <summary>
/// An Inversion of Control container and service locator, for StructureMap.
/// </summary>
public class StructureMapServiceLocator : ServiceLocatorImplBase
{
@dereklawless
dereklawless / CORSHelpers.cs
Last active January 10, 2020 11:45
CORS support for ASP.NET Web API.
/// <summary>
/// An attribute to allow a CORS preflight request to a decorated action, returning an HTTP 200 OK status code.
/// </summary>
/// <remarks>See <see href="http://www.html5rocks.com/en/tutorials/cors/"/> for more details.</remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)]
public class AllowCorsPreflightAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
var headers = actionContext.Request.Headers;
@dereklawless
dereklawless / MembershipProviderExtensions.cs
Created November 13, 2012 23:23
Convert encrypted ASP.NET membership passwords to clear-form.
/// <summary>
/// Extensions for membership providers.
/// </summary>
public static class MembershipProviderExtensions
{
/// <summary>
/// Switches the specified ASP.NET membership user to a clear password format, updating the associated fields.
/// </summary>
/// <param name="user">The membership user.</param>
/// <exception cref="System.ArgumentNullException" />