Skip to content

Instantly share code, notes, and snippets.

View PasswordHash.cs
/*
* Password Hashing With PBKDF2 (http://crackstation.net/hashing-security.htm).
* Copyright (c) 2013, Taylor Hornby
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
View gist:9774709
// get the password from the user
var clearTextPassword = "Passw0rd";
// create the password hash
var passwordHash = PasswordHash.CreateHash(clearTextPassword);
// store the password hash in a data store
// ...
// (later when the user tries to login)
@wshaddix
wshaddix / UiControllerBase.cs
Last active Aug 29, 2015
Asp.Net MVC UI Controller Base Class
View UiControllerBase.cs
public abstract class UiControllerBase : Controller
{
private readonly ILog _log;
protected UiControllerBase(ILog log)
{
_log = log;
}
internal string LoggedInUsername
@wshaddix
wshaddix / CookieTempDataProvider.cs
Created May 22, 2014
Cookie based TempData provider for Asp.Net MVC applications that don't want to use Session to store TempData content
View CookieTempDataProvider.cs
public class CookieTempDataProvider : ITempDataProvider
{
private const string CookieName = "TempData";
private readonly IFormatter _formatter;
public CookieTempDataProvider()
{
_formatter = new BinaryFormatter();
}
View RollbarLogger.cs
using Insiders.Web.Infrastructure.Logging.Interfaces;
using Insiders.Web.Infrastructure.Stats.Interfaces;
using Newtonsoft.Json;
using RollbarSharp;
using System.Runtime.CompilerServices;
namespace Insiders.Web.Infrastructure.Logging.Implementation
{
public class RollbarLogger : ILog
{
@wshaddix
wshaddix / StructureMapDependencyResolver.cs
Created Jul 29, 2014
A custom dependency resolver for Asp.Net MVC 5 that utilizes StructureMap for dependency resolution
View StructureMapDependencyResolver.cs
using Microsoft.Practices.ServiceLocation;
using StructureMap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Insiders.Web.Infrastructure.IoC
{
public class StructureMapDependencyResolver : ServiceLocatorImplBase
@wshaddix
wshaddix / IoC.cs
Created Jul 29, 2014
IoC Class for minimal configuration of Rollbar logging and StatHat stats
View IoC.cs
using System.Configuration;
using Insiders.Web.Infrastructure.Logging.Implementation;
using Insiders.Web.Infrastructure.Logging.Interfaces;
using Insiders.Web.Infrastructure.Stats.Implementation;
using Insiders.Web.Infrastructure.Stats.Interfaces;
using StructureMap;
using StructureMap.Graph;
namespace Insiders.Web.Infrastructure.IoC
{
@wshaddix
wshaddix / ILog.cs
Created Jul 29, 2014
ILog Interface
View ILog.cs
using System.Runtime.CompilerServices;
namespace Insiders.Web.Infrastructure.Logging.Interfaces
{
public interface ILog
{
void Debug(string message, [CallerMemberName] string memberName = "");
void Debug(object data, [CallerMemberName] string memberName = "");
@wshaddix
wshaddix / gist:82525200ed5ca0395fde
Created Apr 7, 2015
Wrong way to do aurelia dependencies
View gist:82525200ed5ca0395fde
import {HttpClient} from 'aurelia-http-client';
import {Router} from 'aurelia-router';
import {Config} from './my-configurations';
import humane from 'humane';
export class Support {
static inject() { return [HttpClient, Router, Config]; }
constructor(http, router, config){
this.heading = 'Get In Touch';
this.fullName = '';
View main.go
package main
import (
"log"
"net/http"
"os"
)
func main() {
You can’t perform that action at this time.