Skip to content

Instantly share code, notes, and snippets.

@hmdhk
hmdhk / redact-id.js
Last active June 10, 2020 10:28
Detect URL pattern
function redactUrlIds (url) {
var parsed = this.parseUrl(url)
var pathname = parsed.pathname
var pathParts = pathname.split('/')
var redactString = '{ID}'
// source: https://www.npmjs.com/package/uuid-regexp
var uuidRegex = /[a-f0-9]{8}-?[a-f0-9]{4}-?[1-5][a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}/i
var separatorsRegex = /[-_]/g
var digitsRegex = /[0-9]/g
using System;
using System.Reflection;
using Microsoft.AspNet.SignalR.Infrastructure;
using Newtonsoft.Json.Serialization;
namespace SignalR
{
public class SignalRContractResolver : DefaultContractResolver
{
private readonly Assembly _assembly;
@hmdhk
hmdhk / app.js
Created November 18, 2015 08:37 — forked from rewonc/app.js
Authenticate a user with angularfire, save to firebase, and make available to controllers with promise
/*
This file is a brief example of how to use angularfire to authenticate a user, save that user's public profile to firebase, then
ensure that both the authenticated and public user are available in your controllers.
The route configuration uses angular-ui-router: https://github.com/angular-ui/ui-router
*/
@hmdhk
hmdhk / WebSocketHelper.ts
Created November 4, 2015 10:55
A websocket helper class written in typescript for use with angularjs
module Utilities {
export class WebSocketHelper {
constructor(private $q: ng.IQService, private url: string, private connectionInterval = 5000) {
}
private wsPromise: ng.IPromise<WebSocket>;
private createWebSocket(): ng.IPromise<WebSocket> {
var d = this.$q.defer();
@hmdhk
hmdhk / NinjectDependencyResolver.cs
Created November 4, 2015 10:39
A ninject dependency resolver for SignalR and Asp.net Web api
using System;
using System.Collections.Generic;
using System.Linq;
using FluentNHibernate.Conventions;
using Ninject;
namespace Ninject
{
public class NinjectDependencyResolver : Microsoft.AspNet.SignalR.DefaultDependencyResolver,
System.Web.Http.Dependencies.IDependencyResolver