Skip to content

Instantly share code, notes, and snippets.

View martijnlentink's full-sized avatar

Martijn Lentink martijnlentink

View GitHub Profile
let
Base64Encode = (str as text) => Binary.ToText(Text.ToBinary(str, BinaryEncoding.Base64)),
CreateContinuationTokens = (partitionkey as text, rowkey as text) =>
let
tokenPrefix = "1",
combineToken = "!",
encodedPartition = Base64Encode(partitionkey),
encodedRow = Base64Encode(rowkey),
nextPartKey = Text.Combine({tokenPrefix, Text.From(Text.Length(encodedPartition)), encodedPartition}, combineToken),
nextRowKey = Text.Combine({tokenPrefix, Text.From(Text.Length(encodedRow)), encodedRow}, combineToken),
// RecursiveTableStorage
let
Base64Encode = (str as text) => Binary.ToText(Text.ToBinary(str, BinaryEncoding.Base64)),
CreateContinuationTokens = (partitionkey as text, rowkey as text) =>
let
tokenPrefix = "1",
combineToken = "!",
encodedPartition = Base64Encode(partitionkey),
encodedRow = Base64Encode(rowkey),
nextPartKey = Text.Combine({tokenPrefix, Text.From(Text.Length(encodedPartition)), encodedPartition}, combineToken),

Power Queries (M expressions)

NAME EXPRESSION
Fact let
` Source = Sql.Database(".", "IP", [Query="SELECT #(lf) concat([GJAHR] , substring([PERDE], 2, 2) ) + 400 YearPeriod#(lf) ,[KNDNR] [Customer Key]#(lf) --,[ARTNR] [Product]#(lf) --,[FKART] [Billing Type]#(lf) --,[FRWAE] [Currency Key]#(lf) --,[VTWEG] [Distribution Channel]#(lf) ,[VTWEG] [Product Key]#(lf) --,[PRCTR] [Profit Center]#(lf) ,pc.[Profit Center Key] [BU Key]#(lf) ,1 [Scenario Key]#(lf) --,[KMMAKL] [Material Group]#(lf) ,[ERLOS]*1.20 [Revenue]#(lf) ,[VVMAT] [Material Costs]#(lf) ,[VVLCV] [Labor Costs Variable]#(lf) ,[VVN30] [Taxes]#(lf) ,[VV910] [Rev for Exp Travel]#(lf) ,[VV950] [Travel Expenses]#(lf) ,[VV970] [Cost Third Party]#(lf) ,[VVYSV] [Subscription Revenue]#(lf) FROM OSQ.[osq].[CE11010] f, mds.mdm.profitcenter pc#(lf)where [MANDT] = 2
@martijnlentink
martijnlentink / PC6_coordinates.csv
Last active September 5, 2022 12:17
Postcode 6 to coordinates
We can't make this file beautiful and searchable because it's too large.
postcode,lat,long
1011AB,52.37782757754373,4.90559460005345
1011AC,52.37735188579582,4.907706824594355
1011AD,52.376405612677885,4.904196309163696
1011AE,52.375215149587916,4.910662873299679
1011AG,52.3759204920198,4.902957046730409
1011AH,52.37570242328806,4.90298559086755
1011AJ,52.37546157787706,4.902770942420245
1011AK,52.37457230862705,4.903767343062783
1011AL,52.368861804813484,4.901960765116629
@martijnlentink
martijnlentink / ValidateSignature.cs
Created November 8, 2023 15:26
Validate Hubspot V3 signature in C#
private async Task<bool> ValidateSignature(HttpRequestData req, string privateAppValidationSecret)
{
var signatureHeader = req.Headers.GetValues("X-HubSpot-Signature-v3").FirstOrDefault();
var timestampHeader = req.Headers.GetValues("X-HubSpot-Request-Timestamp").FirstOrDefault();
if (string.IsNullOrWhiteSpace(signatureHeader) || string.IsNullOrWhiteSpace(timestampHeader))
{
return false;
}
@martijnlentink
martijnlentink / UrlFunctionsHelper.cs
Created December 5, 2023 09:34
Get the URL of HTTP triggered Azure Function including path/query parameters. GetUrl(nameof(FunctionClass.Run))
namespace Namespace.Helpers
using Microsoft.Azure.Functions.Worker;
using Microsoft.AspNetCore.Routing.Template;
using System.Reflection;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Internal;