Skip to content

Instantly share code, notes, and snippets.

View AndrewAllison's full-sized avatar

Andy Allison AndrewAllison

View GitHub Profile
public static class EnumerableExtensions
{
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> enumerable, Func<TSource, TSource, bool> comparer)
{
return enumerable.Distinct(new LambdaComparer<TSource>(comparer));
}
public static IEnumerable<TSource> Except<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, Func<TSource, TSource, bool> comparer)
{
return first.Except(second, new LambdaComparer<TSource>(comparer));
@AndrewAllison
AndrewAllison / Modifypath.ps1
Created January 6, 2015 13:32
Modify Powershell Path for Modules folder
$CurrentValue = [Environment]::GetEnvironmentVariable("PSModulePath", "Machine")
[Environment]::SetEnvironmentVariable("PSModulePath", $CurrentValue + ";E:\Powershell", "Machine")
@AndrewAllison
AndrewAllison / C# Class from DB object in sql
Last active April 29, 2016 11:40
Create a C# class from DB Table. String output, ready to copy and past..
declare @TableName sysname = 'DBTableName'
declare @result varchar(max) = 'public class ' + @TableName + '
{'
select @result = @result
+ CASE WHEN ColumnDesc IS NOT NULL THEN '
/// <summary>
/// ' + ColumnDesc + '
/// </summary>' ELSE '' END
+ '
public ' + ColumnType + ' ' + ColumnName + ' { get; set; }'
@AndrewAllison
AndrewAllison / index.html
Created April 24, 2015 09:21
Gulp examples
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<title ng-bind="title"></title>
<base href="/">
<style>
@AndrewAllison
AndrewAllison / gist:3dade9a6e71f1c225466
Created October 6, 2015 05:31 — forked from tjrobinson/gist:0ad6c790e90d7a385eb1
ActiveDirectoryUserService.cs
using System;
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Thinktecture.IdentityServer.Core;
using Thinktecture.IdentityServer.Core.Models;
using Thinktecture.IdentityServer.Core.Services;
@AndrewAllison
AndrewAllison / .bowerrc
Created February 10, 2016 09:18
Gulp & bower build package
{
"directory": "lib",
"scripts": {
"postinstall": "gulp wiredep"
}
}
@AndrewAllison
AndrewAllison / controller.ts
Created April 29, 2016 11:38
Sample Layout of a TS controller with additional inheritance
interface IStateInherit extends ng.ui.IStateService {
$current: IResolvedStateInherit;
}
interface IResolvedStateInherit extends ng.ui.IResolvedState {
data: IUrlDataContainer;
}
interface IUrlDataContainer {
title: string;
@AndrewAllison
AndrewAllison / gist:0191f17e815cfb172ec6e2954c2eedf1
Created May 7, 2016 07:17 — forked from Mithrandir0x/gist:3639232
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@AndrewAllison
AndrewAllison / NullRemover.js
Created May 12, 2016 09:40
Removing nulls from a Javascript object
function removeNullIn(prop, obj) {
console.info('We dont want nulls..', prop, obj);
var pr = obj[prop];
if (pr === null || pr === undefined) {
delete obj[prop];
}
else if (typeof pr === 'object') {
for (var i in pr) {
removeNullIn(i, pr)
}
@AndrewAllison
AndrewAllison / ODataController.cs
Last active May 17, 2016 15:17
Mixing Routes with WebAPi and OData - Owin Version
using System.Linq;
using System.Web.Http;
using System.Web.OData;
using System.Web.OData.Routing;
using Web.ODataApi.Views;
namespace Web.ODataApi.Controllers
{
public class PrismSalesSummaryViewController : ODataController
{