Skip to content

Instantly share code, notes, and snippets.

View baldwicc's full-sized avatar

Chris Baldwin baldwicc

View GitHub Profile
@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
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 / 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]);
@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),
<!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>
<!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 / brew-update-notifier.sh
Created September 13, 2016 01:29 — forked from SimonSimCity/brew-update-notifier.sh
Extended the script, written by @streeter to exclude the pinned formulae in the list of formulas to update.
#!/bin/bash
#
# Notify of Homebrew updates via Notification Center on Mac OS X
#
# Author: Chris Streeter http://www.chrisstreeter.com
# Requires: terminal-notifier. Install with:
# brew install terminal-notifier
TERM_APP='/Applications/Terminal.app'
BREW_EXEC='/usr/local/bin/brew'
@baldwicc
baldwicc / jquery.debounce.js
Last active October 2, 2015 01:24
Verbatim copy of underscore.js' debounce function, as a jquery plugin (amd friendly)
;(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(jQuery);
}
}(function ($) {
// Thefted from Underscore.js 1.8.3
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
@baldwicc
baldwicc / jquery.galleriffic.js
Last active August 29, 2015 14:26
Galleriffic is a jQuery photo gallery optimized to handle high volumes of photos while conserving bandwidth (http://www.twospy.com/galleriffic/index.html)
/**
* jQuery Galleriffic plugin
*
* Copyright (c) 2008 Trent Foley (http://trentacular.com)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* Much thanks to primary contributer Ponticlaro (http://www.ponticlaro.com)
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(function () {
return (root.returnExportsGlobal = factory());
});
}
else if (typeof exports === 'object') {
module.exports = factory();
}
else {