Skip to content

Instantly share code, notes, and snippets.

zplume / AJAXFrames.js
Last active August 29, 2015 14:02
Global (tenant scoped) HTML/JS 'web part' framework for SharePoint Online
// replacement function for console.log(), which avoids 'undefined' exception in IE 8
window.LogMsg = function (msg) {
if (window.console) {
// set up root namespaces
window.LS = window.LS || {};
LS.AJAXFrames = LS.AJAXFrames || {};
zplume / FieldsToConstants.ps1
Last active August 29, 2015 14:02
A PowerShell utility script that outputs C# code listing all custom fields in the RootWeb of a site collection (filtered by a field name prefix) as a set of static classes with constant string properties for Id and Name.
$siteUrl = "http://site/collection/url"
$fieldPrefix = "ClientName_"
$outputPath = "c:\temp\Fields.cs"
$site = Get-SPSite $siteUrl
$fields = $site.RootWeb.Fields
$output = ""
$newLine = "`r`n"
$tab = "`t"
zplume / ComponentView.cshtml
Created October 7, 2015 13:33
Creating a component in MVC 5 to avoid lots of repetition in your Views (DRY!)
@model MyNamespace.ViewModels.User
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
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",
using System.Collections.Generic;
// accesses a control by ID (i.e. a checkbox/button/textbox etc)
private static Control FindControlIterative(Control root, string id)
Control ctl = root;
LinkedList<Control> ctls = new LinkedList<Control>();
while (ctl != null)
if (ctl.ID == id)
zplume / UpdateUserInfo.ps1
Created June 26, 2013 08:09
Update the mobile number and work number values (from Active Directory) for all users in the User Information List, for all site collections in the specified web application.
##### ABOUT #####
# This script updates the mobile number and work number values
# for all users in the "User Information List" for all site collections
# in the specified web application (see variables below)
##### VARIABLES #####
$webAppURL = "http://mywebapp"
$logPath = "C:\temp\UpdateUserInfo\UpdateUserInfo"
zplume / LinqReflectionConsole.cs
Last active December 20, 2015 03:09
Reflection, Linq & Properties demo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using LS.Extensions;
using Properties;
namespace Properties
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 / LS.Extensions.cs
Last active December 27, 2016 06:20
A collection of extension methods both for general .NET and SharePoint 2010/2013 specific usage
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.UI;
using System.Xml; // requires System.Xml reference
using System.Xml.Linq; // requires System.Xml.Linq reference
(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;