This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ClientSecret = "kSRsdf7rU323rf2ff2gfdssfdAnKI1mcOf98djfidIGx38="; // A key you add for your AAD app. | |
var ClientId = "17dfab36-1c33-4ffe-9ddd-533ddddfs378"; // The unique identifier for your AAD app.. | |
var userObjectId = "12345667-1234-1234-1234-123412341234"; // LET'S SAY YOU WANNA GET A USER'S GROUPS... You'll need their ObjectId for querying later. | |
var authority = "https://login.microsoftonline.com/{tenant guid}/oauth2/authorize?api-version=1.0"; // This is the "OAuth Authorize" Endpoint for your AAD app. | |
var authContext = new AuthenticationContext(authority); | |
// Graph endpoint comes from Azure Portal "Graph Connection Endpoint" | |
var client = new ActiveDirectoryClient(new Uri("https://graph.windows.net/{tenant guid}"), () => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only here because the library doesn't provide an enum or anything. | |
public static class StorageAccountType | |
{ | |
public readonly static string LocallyRedundant = "Standard_LRS"; | |
public readonly static string GeographicallyRedundant = "Standard_GRS"; | |
public readonly static string ReadAccessGeographicallyRedundant = "Standard_RAGRS"; | |
public readonly static string ZoneRedundant = "Standard_ZRS"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
//------------------------------------------------------- | |
// You'll need this thing from Symantec! | |
//------------------------------------------------------- | |
using com.symantec.scanengine.api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE DropUnnamedDefaultConstraint (@Table NVARCHAR(MAX), @Column NVARCHAR(MAX)) | |
AS | |
BEGIN | |
DECLARE @Drop NVARCHAR(MAX) = ( | |
SELECT TOP 1 'ALTER TABLE ' + @Table + ' DROP CONSTRAINT '+name | |
FROM sys.default_constraints A | |
JOIN sysconstraints B on A.parent_object_id = B.id | |
WHERE id = OBJECT_ID(@Table) | |
AND COL_NAME(id, colid) = @Column | |
AND OBJECTPROPERTY(constid, 'IsDefaultCnst') = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const usingSorter = <T>(...selectors: ((t: T) => string | number)[]) => (a: T, b: T): -1 | 0 | 1 => { | |
for (const selector of selectors) { | |
const sa = selector(a) | |
const sb = selector(b) | |
if (sa < sb) return -1 | |
if (sa > sb) return 1 | |
} | |
return 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ObjectExtend | |
{ | |
public static dynamic Extend(this object source, params object[] objs) | |
{ | |
var result = new ExpandoObject(); | |
var props = (IDictionary<string, object>)result; | |
foreach (var o in new[] { source }.Union(objs)) | |
{ | |
var expandoProperties = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio | |
const contrastLightAndDark = (lighter, darker) => (lighter + 0.05) / (darker + 0.05) | |
const relativeLuminance = (r, g, b) => 0.2126 * C(r) + 0.7152 * C(g) + 0.0722 * C(b) | |
const C = c => { | |
const colourScalar = c / 255 | |
return colourScalar <= 0.03928 | |
? colourScalar / 12.92 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct StringTemplate<T> { | |
var template: String | |
init(_ template: String) { | |
self.template = template | |
} | |
func fill(_ t: T) -> String { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Found a weird AF SwiftUI bug today. | |
It's hard to articulate succinctly. I have a demo project that replicates it. | |
Basically if you: | |
- Have a modally presented (via sheet) view which contains a NavigationView and a NavigationLink which leads to a destination view which has an EnvironmentObject dependency AS WELL AS a dependency on the .presentationMode environment value, and... | |
- The user partially dismisses the modally presented view (with the swipe down gesture) without committing to the dismissal, and | |
- Your code inside the modally presented view hierarchy accesses the EnvironmentObject dependency... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
extension URLRequest { | |
typealias BuilderFunction = ((MultipartFormDataInclusion) -> Void) -> Void | |
struct MultipartFormDataInclusion { | |
var data: Data |
OlderNewer