Skip to content

Instantly share code, notes, and snippets.

View jpda's full-sized avatar
🤔
ok

John Patrick Dandison jpda

🤔
ok
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
namespace Stuff
{
public class Log
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Stuff.Formatters;
using Microsoft.ServiceBus.Messaging;
namespace Stuff.Subscribers
{
public class EventHubSubscriber : SubscriberBase, IAsyncObserver<string>
@jpda
jpda / aa-asb-sample-1.json
Created February 8, 2018 00:58
aa-asb-sample-data
[{
"shipmentId": "1Z1234ABC",
"timestamp": "2018-02-01T01:13:45Z",
"status": "Left carrier facility, Seattle WA"
},
{
"shipmentId": "1Z1234ABC",
"timestamp": "2018-02-01T16:49:17Z",
"status": "Arrived carrier facility, Des Moines IA"
},
@jpda
jpda / chromium-updater.ps1
Created March 12, 2018 20:47
chromium win64 updater
param(
[string]$InstallDir = "drive:\path\to\folder\chrome-win32",
[switch]$Verbose = $false
)
$rootDir = $InstallDir
$latest = Invoke-WebRequest -Uri "https://www.googleapis.com/storage/v1/b/chromium-browser-snapshots/o/Win_x64%2FLAST_CHANGE" -Verbose:$Verbose
$data = ConvertFrom-Json -InputObject $latest.Content
$build = $data.metadata.'cr-commit-position-number'
Write-Host Latest is $build, looking for your version...
@jpda
jpda / aad-func.csx
Last active March 27, 2018 22:00
azure ad protected function
using System.Net;
using System.Security.Claims;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
var stuff = System.Security.Claims.ClaimsPrincipal.Current.Claims.Select(x => new { x.Type, x.Value });
return req.CreateResponse(HttpStatusCode.OK, stuff);
}
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using Microsoft.Azure.Services.AppAuthentication;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
var target = "<target app client ID>";
var azureServiceTokenProvider = new AzureServiceTokenProvider();
string accessToken = await azureServiceTokenProvider.GetAccessTokenAsync(target);
{
"frameworks":{
"net46": {
"dependencies": {
"Microsoft.Azure.Services.AppAuthentication": "1.1.0-preview"
}
}
}
}
@jpda
jpda / add.ps1
Created March 27, 2018 21:48
add MSI service principal to approle
# you may not need tenantId, but if it is ambiguous you should set it here
Connect-AzureAd -TenantId
# name of your MSI service principal, in my case msi-func. You can also get the ID from Enterprise Applications in AAD (not App Reg)
$msifunc = Get-AzureADServicePrincipal -SearchString "msi-func"
# name of your AAD service principal, in my case aad-func. You can also get the ID from App Registrations in AAD
$aadapp = Get-AzureADServicePrincipal -SearchString "aad-func"
# Id - the ID of the role. You can get it from the app's manifest
# PrincipalId - the object ID of the MSI principal
# ObjectId - the object ID of the MSI principal
@jpda
jpda / function.proj
Last active July 24, 2018 22:06
Simple graph query by attribute
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.19.8" />
</ItemGroup>
</Project>
@jpda
jpda / Contact.cs
Last active June 14, 2022 10:55
Xamarin.Android RecylerView adapter
public class Contact
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
}