Skip to content

Instantly share code, notes, and snippets.

@richardsonjf
richardsonjf / .NET6Migration.md
Created October 23, 2024 18:30 — forked from davidfowl/.NET6Migration.md
.NET 6 ASP.NET Core Migration
@richardsonjf
richardsonjf / async-database-client.js
Created August 17, 2023 18:04 — forked from dfoverdx/async-database-client.js
JavaScript/TypeScript Data Access Layer that automatically asserts the connection is ready, or waits for the connection to become ready
import Client from 'some-database-api';
import { connectionInfo } from './config';
class AsyncDatabaseClient {
constructor() {
this._connection = null;
this._initialized = Client.connect(connectionInfo).then(c => this.connection = c);
return new Proxy(this, {
get(target, prop, receiver) {

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@richardsonjf
richardsonjf / Azure Blob Chunked Upload Parallel TPL V12.linq
Created March 21, 2023 17:06 — forked from markheath/Azure Blob Chunked Upload Parallel TPL V12.linq
Demonstration of fast Azure blob uploads using a producer consumer pattern with TPL dataflow and using parallel chunked uploads
string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
string SizeSuffix(long value, int decimalPlaces = 0)
{
if (value < 0)
{
throw new ArgumentException("Bytes should not be negative", "value");
}
var mag = (int)Math.Max(0, Math.Log(value, 1024));
var adjustedSize = Math.Round(value / Math.Pow(1024, mag), decimalPlaces);
return $"{adjustedSize} {SizeSuffixes[mag]}";
@richardsonjf
richardsonjf / Producer Consumer TPL
Created March 10, 2023 14:22 — forked from markheath/Producer Consumer TPL
LINQPad demo of the producer consumer pattern with TPL dataflow including back-pressure
<Query Kind="Statements">
<Namespace>System.Collections.Concurrent</Namespace>
<Namespace>System.Threading.Tasks</Namespace>
<Namespace>System.Threading.Tasks.Dataflow</Namespace>
</Query>
var produceSpeed = TimeSpan.FromSeconds(0.5);
var produceCount = 20;
var consumeSpeed = TimeSpan.FromSeconds(2);
var maxParallelConsume = 4;
@richardsonjf
richardsonjf / selected-measure-dependancies_devops_mermaid.csx
Created January 17, 2023 21:28 — forked from data-goblin/selected-measure-dependancies_devops_mermaid.csx
A Tabular Editor C# script to generate a context-dependent mermaid diagram for Azure DevOps Wikis (flowchart) of measure dependencies based on the selected measure.
// This code is still WIP, it doesn't entirely filter the lineage. Feel free to make adjustments.
string dependancies = "::: mermaid\ngraph LR;\n%% Measure dependancy mermaid flowchart";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
foreach(var _measures in Model.AllMeasures )
{
// Deep lineage for upstream measures
@richardsonjf
richardsonjf / selected-measure-dependencies_mermaid.csx
Created January 17, 2023 21:26 — forked from data-goblin/selected-measure-dependencies_mermaid.csx
A Tabular Editor C# script to generate a context-dependent mermaid diagram (flowchart) of measure dependencies based on the selected measure.
// This code is still WIP, it doesn't entirely filter the lineage. Feel free to make adjustments.
string dependancies = "flowchart LR\n%% Measure dependancy mermaid flowchart";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
foreach(var _measures in Model.AllMeasures )
{
// Deep lineage for upstream measures
@richardsonjf
richardsonjf / powerbi-admin-get-workspaces.py
Created January 17, 2023 21:22 — forked from data-goblin/powerbi-admin-get-workspaces.py
Python script to get all workspaces managed in a tenant and containing objects (users, artifacts) with the Power BI Admin REST API
#########################################################################################
# Authentication - Replace string variables with your relevant values
#########################################################################################
import json, requests, pandas as pd
try:
from azure.identity import ClientSecretCredential
except Exception:
!pip install azure.identity
from azure.identity import ClientSecretCredential
@richardsonjf
richardsonjf / all-measure-dependencies_mermaid.csx
Created January 17, 2023 21:21 — forked from data-goblin/all-measure-dependencies_mermaid.csx
A Tabular Editor C# script to get all measures in a model as a mermaid diagram syntax.
string dependancies = "flowchart LR\n%% Measure dependancy mermaid flowchart";
foreach(var _measures in Model.AllMeasures )
{
var _upstream = _measures.DependsOn;
var _upstream_measures = _upstream.Measures.OfType<Measure>().Select(c => c).Distinct();
dependancies += string.Format("\r\n\n%% [{1}] Dependancies:\n\t{0}[\"{1}\"]",
@richardsonjf
richardsonjf / CountModelObjects.csx
Created January 17, 2023 21:14 — forked from data-goblin/CountModelObjects.csx
A Tabular Editor script to count model objects and output their results to a pop-up info box, to give a quick overview of the data model opened.
// Count calculation groups & calculation items
int _calcgroups = 0;
int _calcitems = 0;
foreach ( var _calcgroup in Model.CalculationGroups )
{
_calcgroups = _calcgroups + 1;
foreach ( var _item in _calcgroup.CalculationItems )
{
_calcitems = _calcitems + 1;
   }