Skip to content

Instantly share code, notes, and snippets.

View AndrewAllison's full-sized avatar

Andy Allison AndrewAllison

View GitHub Profile
@AndrewAllison
AndrewAllison / open_md_dialog.ts
Created March 20, 2017 06:47
Using Md DIalog
// TODO
openDialog() {
const dialogRef = this.dialog.open(DialogResultExampleDialogComponent, {
width: '80%',
data: this.selected[0] // will show in config.data on the dialog
});
dialogRef.afterClosed().subscribe(result => {
this.selectedOption = result;
});
}
@AndrewAllison
AndrewAllison / keybindings.json
Last active February 10, 2017 11:56
Visual Studio Code settings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+d",
"command": "editor.action.copyLinesUpAction",
"when": "editorTextFocus"
}
]
@AndrewAllison
AndrewAllison / adding to path.ps1
Created January 12, 2017 11:08
Adds a specific folder to your powershell path for importing modules. Make sure the sub folder names mach the module names.
$originalpaths = (Get-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment’ -Name PSModulePath).PSModulePath
# Add your new path to below after the ;
$newPath=$originalpaths+’;C:\PowerShell\Modules\’
Set-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment’ -Name PSModulePath –Value $newPath
@AndrewAllison
AndrewAllison / json-date.pip.ts
Created October 28, 2016 09:43
Common Pipes for angular 2 in typescript
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'jsonDate'
})
export class JsonDatePipe implements PipeTransform {
transform(value: any, args?: any): any {
if (value) {
return new Date(parseInt(value.substr(6)));
Add-Type -Path "$PSScriptRoot\Serilog.2.1.0\lib\net45\Serilog.dll"
Add-Type -Path "$PSScriptRoot\Serilog.Sinks.RollingFile.2.0.0\lib\net45\Serilog.Sinks.RollingFile.dll"
Add-Type -Path "$PSScriptRoot\Serilog.Sinks.Console.2.1.0\lib\net45\Serilog.Sinks.Console.dll"
Add-Type -Path "$PSScriptRoot\Serilog.Sinks.File.2.2.0\lib\net45\Serilog.Sinks.File.dll"
cls
$Config = New-Object Serilog.LoggerConfiguration
$logPath = "$PSScriptRoot\serilog.log"
$fileSize = 1073741824
@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
{
@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 / 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 / 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 / .bowerrc
Created February 10, 2016 09:18
Gulp & bower build package
{
"directory": "lib",
"scripts": {
"postinstall": "gulp wiredep"
}
}