Skip to content

Instantly share code, notes, and snippets.

Array.prototype.slice.call(document.querySelectorAll("#onetidMngCytpeRptrTable a")).forEach(function(a) { a.setAttribute("href", "\u002fsites\u002fcontentTypeHub/_layouts/15/ManageContentType.aspx?ctype=" + a.getAttribute("id").replace("LinkEditType", "")); });
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Utilities;
using System.Collections.Generic;
public static class Email
{
public static void Send(ClientContext ctx, string[] to, string subject, string body, bool html = false)
{
var properties = new EmailProperties();
properties.To = to;
(function() {
var allResults = [],
queryText = encodeURIComponent("#ext# contentclass:spspeople"),
rowLimit = 500,
selectProperties = ["AccountName", "PreferredName", "WorkEmail"];
function chunk (arr, len) {
var chunks = [],
i = 0,
n = arr.length;
@zplume
zplume / Collectable.cs
Last active July 19, 2023 04:30
Example of polymorphic serialisation with JsonUtility
using UnityEngine;
using System;
[Serializable]
public class Collectable : PolymorphicObject
{
public string Name;
}
@zplume
zplume / ShareDataBetweenWebparts.js
Last active June 30, 2023 15:06
Pattern to share data between SPFx webparts without using global variables, cookies or web storage
var SharedData = (function () {
function SharedData() {
}
SharedData.prototype.loadData = function () {
console.log("Loading data (should only be called once)");
SharedData.loadingData = true;
// simulate AJAX call to retrieve data
return SharedData.loadingPromise = new Promise(function (resolve, reject) {
setTimeout(function () {
SharedData.loadedData = true;
// make calls against SPO using a user access token passed from ADAL.js
// credit to Kirk Evans: https://blogs.msdn.microsoft.com/kaevans/2014/04/15/calling-o365-apis-from-your-web-api-on-behalf-of-a-user/
using System;
using System.Web.Http;
using System.Configuration;
using System.Threading.Tasks;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System.Globalization;
using System.Net.Http;
/*
==============================================================================
Animated scroll-to-section
------------------------------------------------------------------------------
Fancy animated scroll override for native browser scroll-to hyperlinks
which reference named anchor tags within the current page.
Requires jQuery.
==============================================================================
Sections should be defined in page content like so:
@zplume
zplume / ComponentView.cshtml
Created October 7, 2015 13:33
Creating a component in MVC 5 to avoid lots of repetition in your Views (DRY!)
<!--Views\Shared\User.cshtml-->
@model MyNamespace.ViewModels.User
<div>@Model.Name</div>
<!--
This is a very basic example, obviously you'd have more complex nested HTML
and more properties in use for it to be worth using a component like this
-->
/*
Load non-minified version of JS if debug=1 is present in window.location.search.
This JS file can either be referenced in a master page with a <script> tag or via Custom Action.
Use of document.write ensures the script is inserted immediately below this one, synchronously.
For version string to successfully cache bust, the reference to this script also needs a query string that is updated each time this script is updated.
*/
(function() {
var minUrl = "/script.min.js",
debugUrl = "/script.js",
@zplume
zplume / SP.MDS.OnPageLoad.js
Last active November 11, 2021 13:32
Example code to ensure that a function is executed on all page loads, including MDS page loads (where partial page loading is used for navigation rather than full postbacks).
// define a global function to execute
function $_global_onMDSPageLoad() {
// code to execute on page load goes here
}
ExecuteOrDelayUntilScriptLoaded(function () {
if (typeof asyncDeltaManager != "undefined")
asyncDeltaManager.add_pageLoaded($_global_onMDSPageLoad); // execute on MDS page load
else
$_global_onMDSPageLoad(); // execute on non-MDS page load