Skip to content

Instantly share code, notes, and snippets.

View johnkors's full-sized avatar

John Korsnes johnkors

View GitHub Profile
const xml2js = require('xml2js');
const fs = require('fs');
const xmlFileName = 'deployments.xml';
const environment = 'PROD';
const year = '2019';
xml2js.parseString(fs.readFileSync(xmlFileName), function (err, result) {
if (err) throw err;
@davidfowl
davidfowl / HostedService.cs
Created July 17, 2017 09:31
A base class that allows writing a long running background task in ASP.NET Core 2.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace WebApplication24
{
public abstract class HostedService : IHostedService
@dasMulli
dasMulli / build-with-docker.sh
Last active August 7, 2017 14:03
Sample asp.net core / .net core build setup
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
SRC_DIR="$(cd -P "$(dirname "$SOURCE")"&&pwd)"
WORKDIR="/usr/src"
IMAGENAME="microsoft/aspnetcore-build"
COMMAND="./build.sh"
docker pull "$IMAGENAME"
docker run --rm -w "$WORKDIR" -v "$SRC_DIR":"$WORKDIR" -- "$IMAGENAME" $COMMAND
@johnkors
johnkors / GetToken.ps1
Last active June 12, 2024 08:34
Fetch an accesstoken from IdentityServer3 using PowerShell 3
<#
.SYNOPSIS
Fetches an access token using the IdentityServer3 token endpoint
.DESCRIPTION
Modify the parameters so it matches your IdentityServer3 instance.
.NOTES
File Name : GetToken.ps1
Author : John Korsnes (@johnkors, johnkors)
Prerequisite : PowerShell V3
.LINK
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ngpestelos
ngpestelos / remove-docker-containers.md
Last active May 31, 2024 15:10
How to remove unused Docker containers and images

May 8, 2018

I wrote this four years ago, so instead use this command:

$ docker rmi $(docker images -q -f dangling=true)
(function(){
var log = console.log;
console.log = function(str) {
var css = 'background: linear-gradient(to right, red, yellow, lime, aqua, blue, fuchsia, red); color: white; font-weight: bold; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;';
var args = Array.prototype.slice.call(arguments);
args[0] = '%c' + args[0];
args.splice(1,0,css);
return log.apply(console, args);
}
@mkchandler
mkchandler / DisableNuGetPackageRestore.ps1
Last active February 13, 2018 04:07
Disable the NuGet Package Restore functionality in a Visual Studio solution.
# Usage: .\DisableNuGetPackageRestore.ps1 C:\Path\To\Solution.sln
# Get the path that the user specified when calling the script
$solution = $args[0]
$solutionPath = Split-Path $solution -Parent
$solutionName = Split-Path $solution -Leaf
# Delete the .nuget directory and all contents
Remove-Item (Join-Path $solutionPath ".nuget") -Force -Recurse -ErrorAction 0
@robmiller
robmiller / .gitconfig
Created July 17, 2013 07:52
Some useful Git aliases that I use every day
#
# Working with branches
#
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"