Skip to content

Instantly share code, notes, and snippets.

View AndrewAllison's full-sized avatar

Andy Allison AndrewAllison

View GitHub Profile
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 / 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)));
@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 / 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 / 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 / lists.sql
Created April 15, 2017 18:26
Lists Changes
ALTER TABLE `talkbe_production`.`lists`
ADD COLUMN `promoted` TINYINT(1) NULL AFTER `temp`,
ADD COLUMN `order` INT(11) NULL AFTER `promoted`;
@AndrewAllison
AndrewAllison / javascript.json
Created April 21, 2017 06:04
Vscode Snippets
{
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
},
"For Loop": {
@AndrewAllison
AndrewAllison / deploy.sh
Created May 19, 2017 07:13
Deploy on Codeship
npm install -g @angular/cli
npm install
ng build --environment=prod
mkdir deploy deploy/`git rev-parse HEAD` commits
cp dist/ deploy/`git rev-parse HEAD` -rf
git rev-parse HEAD > commits/`git rev-parse HEAD`
@AndrewAllison
AndrewAllison / repeat.ts
Created June 15, 2017 08:13
RxJs for retrying to see if a value has changed over a period
const state = Observable.timer(1000) // every second
.map(() => this.loaded)
.repeat(8) // retry 8 times
.retry();
state.subscribe((res) => {
// this is the main body of the retry
console.log('Result: ', res) // will out put false 8 times for the loaded value.
}, (err) => { }, () => {
if (this.loaded === false) {
this.errorLoading = true; // If it hasn't loaded in 8 secs it ain't gonna ;)
@AndrewAllison
AndrewAllison / basics.js
Created July 6, 2017 07:03
Javascript snippits
// Find the shortest word in an arra of words
// Example "Some so WOrds Will Be Longer" would return 2
function findShort(s){
return Math.min.apply(null, s.split(' ').map(w => w.length));
}