Skip to content

Instantly share code, notes, and snippets.

View rudfoss's full-sized avatar

Thomas Haugland Rudfoss rudfoss

View GitHub Profile
<#
.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]
@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="
@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 / 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 / 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 / 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 / multi-job-variable-azure-pipeline.yml
Created January 29, 2021 07:34
This gist shows how to use variables defined in one deployment job in another with the runOnce strategy.
name: TEST-$(Date:yyyyMMdd)-$(Build.BuildId)
trigger: none
parameters:
- name: env
type: string
default: 'test'
variables:
@rudfoss
rudfoss / MemoryCache.ts
Created January 31, 2021 21:11
A really simple memory cache class that supports running functions on cache expiration.
/**
* A key for an entry in the cache.
*/
type CacheKey = string | symbol
export class CacheError<TInnerError extends Error, TData> extends Error {
public constructor(public innerError: TInnerError, public data: TData) {
super(innerError.message)
}
}
@rudfoss
rudfoss / Set-AppReplyUrlMSGraph.ps1
Last active February 5, 2021 11:13
A small script demonstrating how to authenticate with MS Graph and update redirect uris for an application.
<#
.SYNOPSIS
This script demonstrates how to authenticate with the Microsoft Graph and update the redirect uris for an app registration
Requirements:
1. Register an application in the tenant (management app)
2. Grant the app the following API permissions:
- Application.ReadWrite.All
@rudfoss
rudfoss / sanityConditions.ts
Created March 10, 2021 12:38
A recursive schema for building conditions within Sanity.io Condition functions must be implemented as separate input components and handled accordingly, but the basic structure is present.
export const conditionFunction = {
title: "Condition function",
name: "conditionFunction",
type: "object",
fields: [
{
title: "Function name",
name: "name",
type: "string",
description: "The type of condition",