Skip to content

Instantly share code, notes, and snippets.

View andrewabest's full-sized avatar

Andrew Best andrewabest

View GitHub Profile
@jackawatts
jackawatts / Add an Azure Resource Manager service connection.md
Last active April 1, 2020 10:35
Adding an Azure Resource Manager Service Connection in AzureDevOps

Taken from: https://blogs.msdn.microsoft.com/mihansen/2018/03/31/granular-vststfs-deployment-privileges-using-service-principals/

AzureDevOpsAR is simply the name of the app registration AzureDevOps will be associated with, don't like the name? Simply change the references below.

  1. Create an App Registration to act as a Service Principal:
    1. Log in to portal.azure.com
    2. Azure Active Directory => App Registrations => New Application Registration
    3. Name: AzureDevOpsAR, Type: Web app/API, Url: http://azuredevopsar (Url isn't important as it won't be used)
    4. Copy the Application ID as this will be the Service principal client ID
  2. Settings => Keys => Add
@SynCap
SynCap / remove_node_modules_recursively.ps1
Last active May 3, 2024 21:37
Remove `node_modules` folders in Windows in all subfolders recursively with PowerShell to avoid exceeding path max_length
<#
Note: Eliminate `-WhatIf` parameter to get action be actually done
Note: PS with version prior to 4.0 can't delete non-empty folders
#>
Get-ChildItem -Path "." -Include "node_modules" -Recurse -Directory | Remove-Item -Recurse -Force -WhatIf
@leoloobeek
leoloobeek / get_gists.py
Created April 26, 2017 21:34
Download all gists for a specific user
# first: mkdir user && cd user && cp /path/to/get_gists.py .
# python3 get_gists.py user
import requests
import sys
from subprocess import call
user = sys.argv[1]
r = requests.get('https://api.github.com/users/{0}/gists'.format(user))
@gertjvr
gertjvr / Autofac.SignalR.md
Last active August 4, 2023 06:56
Autofac.SignalR hub scoped dependencies per instance.

SignalR generates a hub for each method invoke ie onConnected, onDisconnect or any other methods on the hub. Autofac.SignalR all hub dependencies are resolved from the root container making them singletons.

I did find another solutions https://github.com/lethek/SignalR.Extras.Autofac but this required inheriting from a special lifetimehub, retro fitting this into an large existing solution would take a lot of work an re-testing.

The solutions below allows you to scope all dependencies per hub instance.

  • Install-Package Autofac.SignalR
  • Install-Package Castle.Core
@teyc
teyc / WriteSeq.cs
Last active September 26, 2018 05:12
Pipes objects to Seq
// How to debug your powershell scripts by piping the intermediate results to Seq
// 1. Compile this into WriteSeq.dll
// 2. > Import-Module .\WriteSeq.dll
// 3. > Get-ChildItems C:\ | ? { $_.Name -ilike { "*Program*" } | Write-Seq | Format-Table
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management.Automation;
@paulirish
paulirish / what-forces-layout.md
Last active May 6, 2024 07:54
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@Sam-Martin
Sam-Martin / Invoke-KMSEncrypt-Example.ps1
Last active June 16, 2020 17:53
PowerShell Example for using Invoke-KMSEncrypt and Invoke-KMSDecrypt
# Stolen from http://ctrlf5.net/?p=263 and http://www.dailycoding.com/posts/convert_image_to_base64_string_and_base64_string_to_image.aspx
function ConvertFrom-StringToMemoryStream{
param(
[parameter(Mandatory)]
[string]$InputString
)
$stream = New-Object System.IO.MemoryStream;
$writer = New-Object System.IO.StreamWriter($stream);
$writer.Write($InputString);
@sheastrickland
sheastrickland / Landlord.cs
Created September 7, 2015 06:22
Landlord: The Com Destroyer. A simple utility class to wrap those nasty little devils.
using System;
using System.Runtime.InteropServices;
namespace Things
{
public static class LandLordExtensions
{
public static LandLord<TWrapped> AsDisposable<TWrapped>(this TWrapped tenant)
{
return new LandLord<TWrapped>(tenant);
@droyad
droyad / gist:30097e1f8c02df781ac2
Created August 10, 2015 07:35
Test Autofac registrations by inspection
public abstract class ContainerTestsBase
{
private IContainer _container;
private HashSet<Type> _registeredServices;
readonly Autofac.Core.Activators.Reflection.DefaultConstructorFinder _ctorFinder = new Autofac.Core.Activators.Reflection.DefaultConstructorFinder();
private HashSet<Type> _genericServices;
private HashSet<Type> _registeredConcretions;
[TestFixtureSetUp]
@jackawatts
jackawatts / XmlExpando
Last active August 29, 2015 14:23
Simple XmlExpando
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Xml.Linq;
namespace Expando
{
public static class XmlExpando
{