Skip to content

Instantly share code, notes, and snippets.

public class AuthenticatingHandler<T> : DelegatingHandler where T : ISecurityTokenAccessor
{
private readonly Policy<HttpResponseMessage> _policy;
private readonly T _securityTokenAccessor;
private IAccessToken _accessToken;
private AuthenticationHeaderValue _authenticationHeader;
public AuthenticatingHandler(T securityTokenAccessor)
{
_securityTokenAccessor = securityTokenAccessor;
@DustinCampbell
DustinCampbell / using-msbuildworkspace.md
Created April 10, 2018 21:36
Using MSBuildWorkspace

Introduction

Roslyn provides a rich set of APIs for analyzing C# and Visual Basic source code, but constructing a context in which to perform analysis can be challenging. For simple tasks, creating a Compilation populated with SyntaxTrees, MetadataReferences and a handful of options may suffice. However, if there are multiple projects involved in the analysis, it is more complicated because multiple Compilations need to be created with references between them.

To simplify the construction process. Roslyn provides the Workspace API, which can be used to model solutions, projects and documents. The Workspace API performs all of the heavy lifting needed to parse SyntaxTrees from source code, load MetadataReferences, and construct Compilations and add references between them.

@kizzx2
kizzx2 / with-env.ps1
Last active February 26, 2025 21:11
Run command with environment variables in PowerShell
$ori = @{}
Try {
$i = 0
# Loading .env files
if(Test-Path $args[0]) {
foreach($line in (Get-Content $args[0])) {
if($line -Match '^\s*$' -Or $line -Match '^#') {
continue
}
@umidjons
umidjons / youtube-dl-download-audio-only-on-best-quality.md
Last active November 14, 2024 21:20
Download Audio from YouTube with youtube-dl

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

@Warchant
Warchant / sonarqube-docker-compose.yml
Last active December 7, 2024 03:37
docker-compose file to setup production-ready sonarqube
version: "3"
services:
sonarqube:
image: sonarqube
expose:
- 9000
ports:
- "127.0.0.1:9000:9000"
networks:
List<Point> points = new List<Point>();
List<int> tempX = new List<int>();
List<int> tempY = new List<int>();
using (StreamReader reader = new StreamReader("Your_Source_File.SIG"))
{
while (!reader.EndOfStream)
{
Regex reg = new Regex(@"^\d+\s\d+$");
string checkLine = reader.ReadLine();
@rogeliodh
rogeliodh / x1ii_fw_pack.sh
Created January 20, 2017 22:32
script to repack Fiio's X1ii firmware files
#!/bin/sh
set -e
cd myfw
# mkyaffs2 from mkyaffs2 0.2.9_20120815
sudo ../mkyaffs2 fifo_rootfs fifo_rootfs.yaffs2
echo -n `md5sum fifo_rootfs.yaffs2 | cut -c1-32` > fifo_rootfs.yaffs2.md5
tar zcvf ../X1II.repacked.fw fifo_uimage fifo_uimage.md5 fifo_uimageesmt fifo_uimageesmt.md5 fifo_rootfs.yaffs2 fifo_rootfs.yaffs2.md5
@rogeliodh
rogeliodh / x1ii_fw_unpack.sh
Created January 20, 2017 22:31
script to unpack Fiio's X1ii firmware files
#!/bin/sh
set -e
mkdir -p myfw
tar zxvf X1II.fw -C myfw
# unyaffs2 from yaffs2utils is not working
#sudo ./unyaffs2 myfw/fifo_rootfs.yaffs2 myfw/fifo_rootfs
# Use unyaffs from ubuntu's unyaffs package (apt-get install unyaffs)
sudo unyaffs myfw/fifo_rootfs.yaffs2 myfw/fifo_rootfs
@fearthecowboy
fearthecowboy / Test.csproj
Last active February 13, 2025 07:40
The definitive way to use PowerShell from an msbuild script
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- #1 Place this line at the top of any msbuild script (ie, csproj, etc) -->
<PropertyGroup><PowerShell># 2>nul || type %~df0|find /v "setlocal"|find /v "errorlevel"|powershell.exe -noninteractive -&amp; exit %errorlevel% || #</PowerShell></PropertyGroup>
<!-- #2 in any target you want to run a script -->
<Target Name="default" >
<PropertyGroup> <!-- #3 prefix your powershell script with the $(PowerShell) variable, then code as normal! -->
<myscript>$(PowerShell)
@maartenba
maartenba / inspectcode.xslt
Last active May 8, 2024 13:15
R# InspectCode XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:key name="ISSUETYPES" match="/Report/Issues/Project/Issue" use="@TypeId"/>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/" name="TopLevelReport">
<html>
<head>
<title>Resharper InspectCode Report</title>