Skip to content

Instantly share code, notes, and snippets.

@iOnline247
iOnline247 / $sp.ca.js
Last active May 12, 2023 13:01
Create/Delete Custom Actions in SharePoint
/*!
* Created by Matthew Bramer :: @iOnline247
* Released under the MIT license
* Date: 2016-02-12 v1
* Inspired from script written on: 2014-05-17
* https://dl.dropboxusercontent.com/u/21583725/demos/SPSDC-ModalMania/demo/js/iframeDemo.js
* Tested using SharePoint Online.
*
* Helpful Links
* https://msdn.microsoft.com/en-us/library/office/dn531432.aspx#bk_UserCustomActionRequestExamples
@iOnline247
iOnline247 / boilerplate.ps1
Created November 10, 2022 19:10
P0$H Boilerplate
param(
[ValidateSet("DEV","TEST","PROD")]
[parameter(mandatory=$true)]
[string]$Environment = ("DEV","TEST","PROD")
)
# TODO
# Update with newer code patterns
$path = Split-Path -Path $MyInvocation.MyCommand.Path
$scriptName = [System.IO.Path]::GetFileNameWithoutExtension($MyInvocation.MyCommand.Source)
@iOnline247
iOnline247 / ohmyposhv3-v2.json
Last active September 2, 2022 12:39 — forked from shanselman/ohmyposhv3-v2.json
ohmyposhv3-v2
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#00c7fc",
"foreground": "#000000",
"style": "diamond",
@iOnline247
iOnline247 / for-await-concurrrently.js
Created August 12, 2022 14:41
`for await` examples
async function* iteratorGen(arr) {
for (const i of arr) {
if (typeof i === "function") {
yield i();
} else {
yield i;
}
}
}
@iOnline247
iOnline247 / utils.js
Last active September 22, 2021 17:57
JavaScript Utilities and Example Usage
/*
* Helpful JS utils & example usage.
*/
const prop = (k) => (o) => o[k];
const props = (ks) => (o) => ks.map((k) => o[k]);
const map = (f) => (a) => a.map(f);
const filter = (f) => (a) => a.filter(f);
const split = (delim) => (s) => {
s = String(s);
return s.split(delim);
# https://stackoverflow.com/a/22558858
Get-ChildItem -Include *.js, *.css, *.html -Recurse | ForEach-Object {
$_ | Select-Object FullName, @{n = "Lines"; e = { Get-Content $_ | Measure-Object -Line | Select-Object -ExpandProperty Lines}}}
@iOnline247
iOnline247 / querystrings.js
Last active March 16, 2021 04:52
Get QueryStrings from URL (default) or string
function getQueryStrings(v) {
const result = {};
const rstripLeadingQuery = /^(:?\?|#)/;
const queryString = (v ? String(v) : window.location.search).replace(
rstripLeadingQuery,
''
);
const re = /([^&=]+)=([^&]*)/g;
let m;
@iOnline247
iOnline247 / configlist.unmin.js
Last active March 11, 2021 13:01
Create a bulletproof configuration list for custom SharePoint apps.
/*!
* Created by Matthew Bramer
* Released under the MIT license
* Date: 2016-08-05
* Tested using SharePoint Online.
*/
// Get $sp.min.js from here.
// https://gist.github.com/iOnline247/cc8d68cb611b056695434224e6c2aa19
import '../vendor/$sp.min';
@iOnline247
iOnline247 / $sp-no-jquery.js
Last active March 10, 2021 21:03
Wrapper for SharePoint REST API.
/*!
* Created by Matthew Bramer
* Released under the MIT license
* Date: 2016-07-11
* Props to: http://blogs.msmvps.com/windsor/2015/02/13/reduce-code-need-for-rest-api-calls-with-sprestrepository/
* Tested using SharePoint Online & 2013 On-Prem.
*/
// http://sharepoint.stackexchange.com/questions/74978/can-i-tell-what-version-of-sharepoint-is-being-used-from-javascript
@iOnline247
iOnline247 / Compare-DirectoryContents.ps1
Last active November 24, 2020 08:15
Compare checksum of files or directories.
function logMsg($text, $color = [System.ConsoleColor]::green) {
Write-Host $text -foregroundcolor $color
Write-Host "`r`n"
}
<#
function Remove-DirectoryPathInfo ($fileInfo) {
$fileInfo.Path = $fileInfo.Path -replace "$([Regex]::Escape($testFiles[0].Parent.Parent.FullName))\\", ""
$fileInfo.Path = $fileInfo.Path -replace "$([Regex]::Escape($initialFiles[0].Parent.Parent.FullName))\\", ""
# "$([Regex]::Escape($parentDirectoryPath))\\"