Skip to content

Instantly share code, notes, and snippets.

View baldwicc's full-sized avatar

Chris Baldwin baldwicc

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
@baldwicc
baldwicc / ExpandAllRecords.M
Last active September 7, 2020 10:42 — forked from Mike-Honey/ExpandAllRecords.M
ExpandAllRecords function for Power Query or Power BI - expands all record-type columns recursively
// Based on Chris Webb's blog post - http://blog.crossjoin.co.uk/2014/05/21/expanding-all-columns-in-a-table-in-power-query/
let
// Define function taking two parameters - a table and an optional column number
Source = (IncomingTableToExpand as table, optional ColumnNumber as number) =>
let
// Buffer the table for performance
TableToExpand = Table.Buffer(IncomingTableToExpand),
@baldwicc
baldwicc / decodeUrlDefensev3.js
Created January 22, 2020 03:57
Proofpoint urldefense.com URL Decoder (v3)
/**
* Decodes a Proofpoint urldefense.com (v3 format)
* Reference: https://help.proofpoint.com/@api/deki/files/177/URLDefenseDecode.py?revision=2
* @param {String} link typical format: 'https://urldefense.com/v3/__<encoded url>__;<replacement characters>!!<assorted click tracking goodness>$'
*/
function decodeUrlDefensev3(link) {
var matches = link.match(new RegExp('v3/__(.+?)__;(.*?)!'))
// love me a mutable array
var decode_pile = Array.from(matches[1]);
let
FnType = type function (
DataTable as (type table meta [
Documentation.FieldCaption = "DataTable",
Documentation.FieldDescription = "Table that contains columns that need renaming."
]),
DataMapTable as (type table meta [
Documentation.FieldCaption = "DataMapTable",
Documentation.FieldDescription = "Table that contains at least 2 text columns; ""Variable"" and ""Variable Label"""
@baldwicc
baldwicc / Pseudonymise.pq
Last active May 28, 2021 12:24
Replaces sensitive identifiers with a freshly generated random GUID
let
// Replaces a column's contents with a psuedononymous identifier that is designed not to be reversible.
//
// Note that this does not guarantee reversibility is impossible; the only assertions are that:
// - they are unique and randomly generated upon each refresh
// - they are designed not to be reversible
// - they are *not* cryptographically secure (i.e. entropy may be derived from a simple source, such as the current time)
fn = (DataTable as table, SensitiveIdentifier as text) =>
let