Skip to content

Instantly share code, notes, and snippets.

{"public": {"awsBucketUrl": "http://fake.fake"}}
@Deadarius
Deadarius / .eslintrc
Created May 24, 2015 20:45
YAML .eslintrc with resets
#http://eslint.org/docs/rules/
ecmaFeatures:
binaryLiterals: false # enable binary literals
blockBindings: false # enable let and const (aka block bindings)
defaultParams: false # enable default function parameters
forOf: false # enable for-of loops
generators: false # enable generators
objectLiteralComputedProperties: false # enable computed object literal property names
objectLiteralDuplicateProperties: false # enable duplicate object literal properties in strict mode
objectLiteralShorthandMethods: false # enable object literal shorthand methods
@Deadarius
Deadarius / NinjectDependencyResolver.cs
Created June 24, 2014 22:46
ASP.NET Web Api dependency resolver for Ninject
/// <summary>
/// ASP.NET Web Api dependency resolver for Ninject
/// </summary>
public class NinjectDependencyResolver : IDependencyResolver
{
private IKernel kernel;
public NinjectDependencyResolver(IKernel kernel)
{
this.kernel = kernel;
}
// NOTE: I added the .js extension to this gist so it would have syntax highlighting. This file should have NO file extension
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
@Deadarius
Deadarius / logoutOn401Interceptor.js
Created June 4, 2014 03:06
AngularJS interceptor that redirects user to login page on 401 error
angular.module('interceptors', [])
.factory('logoutOn401Interceptor', ['$rootScope', '$q', '$location', function ($rootScope, $q, $location) {
var success = function (response) {
return response;
};
var error = function (response) {
if (response.status === 401) {
$rootScope.lastUrl = $location.path();
$location.path('/login');
@Deadarius
Deadarius / WebApiExceptionHandler.cs
Created June 4, 2014 03:03
Generic Web Api 2 exception handler.
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.ExceptionHandling;
using System.Web.Http.Results;
namespace QBE.Jadu.Api.Code
{
@Deadarius
Deadarius / WebApiExceptionLogger.cs
Created June 4, 2014 03:00
Generic Web Api 2 exception logger
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using System.Web.Http.ExceptionHandling;
using log4net;
namespace Deadarius
@Deadarius
Deadarius / StopWatchNinjectInterceptor.cs
Created June 4, 2014 02:57
Ninject interceptor to measure time method invocation took
using System.Diagnostics;
using log4net;
using Ninject.Extensions.Interception;
namespace Deadarius
{
public class StopWatchNinjectInterceptor : SimpleInterceptor
{
private readonly Stopwatch stopwatch;
private readonly ILog logger;
@Deadarius
Deadarius / EncryptionService.cs
Last active August 29, 2015 14:02
Simple encryption service for C# based on Rijndael
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Deadarius
{
public interface IEncryptionService
{
string Encrypt(string plainText, string secret, string salt);
@Deadarius
Deadarius / Wildcard.cs
Last active October 19, 2020 13:50
Simple C# method to determine if string matches string with wildcards
using System;
using System.Globalization;
using System.Linq;
namespace Deadarius
{
public static class Wildcard
{
/// <summary>
/// Simple method to determine if string matches string with wildcards