Skip to content

Instantly share code, notes, and snippets.

View taylorhutchison's full-sized avatar
💭
Working on the Geode library

Taylor Hutchison taylorhutchison

💭
Working on the Geode library
View GitHub Profile
=LOWER(CONCATENATE(
DEC2HEX(RANDBETWEEN(0,4294967295),8),"-",
DEC2HEX(RANDBETWEEN(0,65535),4),"-",
DEC2HEX(RANDBETWEEN(0,65535),4),"-",
DEC2HEX(RANDBETWEEN(0,65535),4),"-",
DEC2HEX(RANDBETWEEN(0,4294967295),8),
DEC2HEX(RANDBETWEEN(0,65535),4)
))
$DownloadPageResponse = Invoke-WebRequest "https://www.microsoft.com/en-us/download/confirmation.aspx?id=56519"
$JsonFileLink = $DownloadPageResponse.Links | Where-Object href -Like '*json' | Select-Object href -first 1 | Select-Object -ExpandProperty href
$JsonFileResponse = Invoke-RestMethod $JsonFileLink
$searchList = @('AzureDevOps.EastUS2', 'AzureDevOps.EastUS')
$JsonFileResponse.values | Where-Object { $searchList.contains($_.name) }
@taylorhutchison
taylorhutchison / angular.json
Created January 7, 2023 18:08
Angular CLI schematic changes for components, directives, and services.
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"schematics": {
"@schematics/angular": {
"component": {
"inlineTemplate": true,
"inlineStyle": true,
"skipTests": true,
"flat": true,
"changeDetection": "OnPush"
@taylorhutchison
taylorhutchison / local.settings.json
Created January 3, 2023 03:18
Allow CORS when running Azure Functions locally
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
},
"Host": {
"CORS": "*"
}
}
@taylorhutchison
taylorhutchison / Program.cs
Last active April 27, 2022 13:51
Writing to the log stream in a Window Azure App Service.
// This is a ASP.NET 6 sample showing how to write to the log stream in a Window Azure App Service.
// It seems standard out (stdout) is disabled in a Window Azure App Service.
// The key for me was adding the Microsoft.Extensions.Logging.AzureAppServices package
// To see logs in the Log Stream
// 1. go to "App Service logs" panel under monitoring
// 2. turn on Application logging (Filesystem)
// 3. set the level to Verbose or whatever is appropriate for the level of logging you want to see.
// Note: This will automatically turn back off after 12 hours by design.
// 4. Now you can see the logs in the Log Stream panel of your App Service.
@taylorhutchison
taylorhutchison / Program.cs
Created December 27, 2021 05:22
Output the distribution of English words by their first letter (ignoring case).
// Steps to reproduce assuming you have dotnet installed (using version 6).
// mkdir english-word-distribution && cd english-word-distribution
// dotnet new console
// curl https://raw.githubusercontent.com/dwyl/english-words/master/words.txt --output words.txt
// dotnet run
var letterCount = new Dictionary<char, int>();
foreach (var word in File.ReadLines("words.txt"))
{
var letter = word.ToLower()[0];
if (!letterCount.ContainsKey(letter))
@taylorhutchison
taylorhutchison / TaskLock.cs
Created December 14, 2021 03:16
C# example of using a lock to prevent multiple threads from starting a long running task when it only needs to be run once.
// C# top-level statements
// The goal of this code is to create a method that simulates a long-running task that
// only needs to be computed once, but that multiple threads might request before the computation is finished.
// It uses a lock object to check if the computation has been requested. If not it starts the work.
var t1 = Task.Run(async () =>
{
var result = await TaskRunner.LongRunningTask();
Console.WriteLine(result);
@taylorhutchison
taylorhutchison / CTE.sql
Created June 27, 2021 19:31
Using Common Table Expressions to recursively grab employee reporting structures
-- Traces up from leaf to root
WITH org(id, name, title, department, manager) AS (
SELECT
id, name, title, department, manager
FROM
employee
WHERE id = '9E033E7A-9D49-445F-BB8E-C6B777DFC19E'
UNION ALL
SELECT
e.id, e.name, e.title, e.department, e.manager
@taylorhutchison
taylorhutchison / ADAL_with_vanilla_JS.md
Created April 29, 2021 21:13 — forked from psignoret/ADAL_with_vanilla_JS.md
Minimal sample app using ADAL.JS and vanilla JavaScript

Using ADAL.JS with vanilla JavaScript

A minimal sample app using ADAL.JS and plain old vanilla JavaScript to obtain an access token from Azure Active Directory and use that access token to make an API request. In this case, the API we're requesting a token for is the Microsoft Graph API, which is used to retrieve the signed-in user's basic profile.

You can see (and test) this live at: https://bl.ocks.org/psignoret/raw/50e88652ae5cb6cc157c09857e3ba87f/

@taylorhutchison
taylorhutchison / SnackbarInterceptor.ts
Last active December 2, 2022 13:17
An Angular interceptor to show a Material Snackbar on success or error of an HTTP POST/PUT.
import { Injectable } from '@angular/core';
import {
HttpRequest,
HttpHandler,
HttpEvent,
HttpInterceptor,
HttpResponse
} from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError, tap, } from 'rxjs/operators';