Skip to content

Instantly share code, notes, and snippets.

View jpda's full-sized avatar
🤔
ok

John Patrick Dandison jpda

🤔
ok
View GitHub Profile
@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"
},
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>
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
namespace Stuff
{
public class Log
{
@jpda
jpda / program.cs
Created June 9, 2017 19:44
Azure AD Password grant type
private static string GetUserToken()
{
var cid = "<application client ID>";
var targetCid = "<target resource ID - be careful here, some apps require client/resource ID (GUID), others also accept a URI";
var key = "<URL-encoded client secret key>";
var reqUri = "<authority, usually something like https://login.microsoftonline.com/<tenant ID or domain name>/oauth2/token";
var postData = $"resource={targetCid}&client_id={cid}&grant_type=password&username=user%40jpda.onmicrosoft.com&password={password}&type=openid&client_secret={key}";
// example: "resource=00000002-0000-0000-c000-000000000000&client_id=eeb7d568-2e05-45cf-87eb-d07604340af7&grant_type=password&username=user%40jpda.onmicrosoft.com&password=lol&scope=openid&client_secret=urlencodedsecretkey"
@jpda
jpda / program.cs
Created April 13, 2017 20:34
Azure Service Bus client explosion
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.ServiceBus.Filters;
namespace ConsoleApp2
{
class Program
{

Keybase proof

I hereby claim:

  • I am jpda on github.
  • I am jpda (https://keybase.io/jpda) on keybase.
  • I have a public key whose fingerprint is 57E2 0A64 15FC 9288 006C 0E20 1B0E B0CE C35D 3922

To claim this, I am signing this object:

@jpda
jpda / Startup.Auth.cs
Last active April 19, 2016 15:11
Azure AD Auth Code
private static readonly string ClientId = ConfigurationManager.AppSettings["ida:ClientId"];
private static readonly string AadInstance = ConfigurationManager.AppSettings["ida:AADInstance"];
private static readonly string TenantId = ConfigurationManager.AppSettings["ida:TenantId"];
private static readonly string PostLogoutRedirectUri = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"];
private static readonly string Authority = AadInstance + TenantId;
private static readonly string TargetResourceId = ConfigurationManager.AppSettings["ida:TargetResourceId"];
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
@jpda
jpda / App.config
Created January 6, 2016 21:59
WCF Client sample app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAuthService" />
</basicHttpBinding>
@jpda
jpda / Web.config
Last active January 6, 2016 22:04
WCF Web Host debug web.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
@jpda
jpda / deployment.ps1
Last active September 25, 2015 19:19
Windows 10 IoT Multi-device Deployment
param (
[string][Parameter(Mandatory = $true)]$DeviceName,
[string][Parameter(Mandatory = $false)]$DefaultAppName = "IotCoreDefaultApp",
[string][Parameter(Mandatory = $true)]$TargetAppName,
[string][Parameter(Mandatory = $true)]$TargetAppPath,
[string][Parameter(Mandatory = $true)]$DeviceUsername,
[string][Parameter(Mandatory = $true)]$DevicePassword
)
$ErrorActionPreference = "Stop"
Add-Type -Path "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Net.Http.dll"