Skip to content

Instantly share code, notes, and snippets.

View rudfoss's full-sized avatar

Thomas Haugland Rudfoss rudfoss

View GitHub Profile
@rudfoss
rudfoss / debug-azure-pipelines.yml
Created January 27, 2021 16:42
Output variable and environment from an Azure Devops Pipelines
# This pipeline simply logs all available variables as well as the folder structure
# It is intended for debugging pipelines
# Predefined variables: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
steps:
- task: PowerShell@2 # This task is for debugging. Enable it to see the entire working directory and all environment variables
displayName: 'Print variables and folder structure'
inputs:
targetType: inline
@rudfoss
rudfoss / AzureTable.ts
Created December 26, 2020 11:23
This is a small class that wraps around an Azure Table service and makes it easier to work with and serialize/deserialize data from the table.
import azureStorage, { TableService } from "azure-storage"
import { promisify } from "util"
const entGen = azureStorage.TableUtilities.entityGenerator
export interface TableRow<TRowData> {
partitionKey: string
rowKey: string
timestamp: Date
data: TRowData
@rudfoss
rudfoss / spChangeTokenUtils.ts
Last active December 12, 2020 13:32
Some types, entities and a class useful when working with SPChangeTokens
import { IChangeToken } from "@pnp/sp-commonjs"
/**
* The number of "ticks" between unix epoch and tick epoch.
*/
const TICK_TIMESTAMP_DIFF = 621355968000000000
/**
* Converts a unix epoch timestamp to a tick.
* @param timestamp The unix epoch timestamp in seconds.
@rudfoss
rudfoss / useWebFont.ts
Last active November 29, 2020 08:41
A small hook for using webfontloader to check whether a font family is loaded. It returns an object where each family and variant loaded is indicated by a boolean.
import { useEffect, useRef, useState } from "react"
import wfl from "webfontloader"
type WebFontConfigWithoutEvents = Omit<
WebFont.Config,
"loading" | "active" | "inactive" | "fontloading" | "fontactive" | "fontinactive"
>
interface FontFamilyLoaded {
[fontFamily: string]: {
[fontVariant: string]: boolean
@rudfoss
rudfoss / pnp-provision-all-fields.xml
Last active August 5, 2025 12:24
A SharePoint PNP Provisioning template file that provisions every site column type (except calculated), associates them with an item based content type and a Site Pages based content type as well as adds them to lists for testing.
<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema">
<pnp:Preferences Generator="OfficeDevPnP.Core, Version=3.17.2001.2, Culture=neutral, PublicKeyToken=5e633289e95c321a" />
<pnp:Templates ID="all-site-columns-template-container">
<pnp:ProvisioningTemplate ID="all-site-columns-template" Version="1" Scope="RootSite">
<pnp:SiteFields>
<Field Type="Note" DisplayName="test-managedmetadata-multi_0" StaticName="p476b49a9b31428dadff0fc41f113eb7" Name="p476b49a9b31428dadff0fc41f113eb7" ID="{72733dbb-ff54-421e-a3e4-cbebfb642da7}" ShowInViewForms="FALSE" Required="FALSE" Hidden="TRUE" CanToggleHidden="TRUE" SourceID="{c3b2fac5-2faf-45f9-bec1-d097cad2993f}" />
<Field Type="Note" DisplayName="test-managedmetadata_0" StaticName="nb91ac28dbe147e5b76fa0c92f261dc0" Name="nb91ac28dbe147e5b76fa0c92f261dc0" ID="{35428a2c-6205-46f5-918b-1fa979bdc865}" ShowInViewForms="FALSE" Required="FALSE" Hidden="TRUE" CanToggleHidden="TRUE" SourceID="
<#
.SYNOPSIS
Returns a hashtable of all parameters from the template file merged with the parameters object you provide
#>
function Get-AzTemplateParameters{
param(
[string]
$ParametersFilePath,
[hashtable]