Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View wshaddix's full-sized avatar

Wes Shaddix wshaddix

View GitHub Profile
/*
* 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.
// 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 August 29, 2015 14:01
Asp.Net MVC UI Controller Base Class
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 00:12
Cookie based TempData provider for Asp.Net MVC applications that don't want to use Session to store TempData content
public class CookieTempDataProvider : ITempDataProvider
{
private const string CookieName = "TempData";
private readonly IFormatter _formatter;
public CookieTempDataProvider()
{
_formatter = new BinaryFormatter();
}
@wshaddix
wshaddix / ILog.cs
Created July 29, 2014 22:48
ILog Interface
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 / RollbarLogger.cs
Created July 29, 2014 22:57
RollbarLogger
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 / IoC.cs
Created July 29, 2014 23:21
IoC Class for minimal configuration of Rollbar logging and StatHat stats
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 / StructureMapDependencyResolver.cs
Created July 29, 2014 23:30
A custom dependency resolver for Asp.Net MVC 5 that utilizes StructureMap for dependency resolution
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 / gist:82525200ed5ca0395fde
Created April 7, 2015 22:02
Wrong way to do aurelia dependencies
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 = '';
package main
import (
"log"
"net/http"
"os"
)
func main() {