Skip to content

Instantly share code, notes, and snippets.

@iOnline247
iOnline247 / test.js
Created August 12, 2020 06:10
util.format example
// https://nodejs.org/api/util.html#util_util_format_format_args
// util.format() is a synchronous method that is intended as a debugging tool.
// Some input values can have a significant performance overhead that can block
// the event loop. Use this function with care and never in a hot code path.
const { format } = require("util");
function log(...args) {
// Note the subtle difference in the output. The %j is converted to JSON.
const msg = format("%j %s %s %s", ...args);
@iOnline247
iOnline247 / log4net.ps1
Created April 23, 2020 05:11
log4net in PowerShell
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Push-Location $scriptDir
Add-Type -Path "$scriptDir\dll\log4net.dll"
$FileAppender = New-Object log4net.Appender.FileAppender(
(
[log4net.Layout.ILayout](New-Object log4net.Layout.PatternLayout('%date{yyyy-MM-dd HH:mm:ss.fff} | %level | %property{correlationId} | [%thread] | Department | App_Name | %c | $property{jobId} | %message%n')),
"$scriptDir\LogOutputInConsoleAndFile.log", # $LogFileName
@iOnline247
iOnline247 / ActiveMQ-POST.ps1
Created January 4, 2020 06:04
POST a simple message to an ActiveMQ Topic
$i = 0
while($true) {
$password = ConvertTo-SecureString "admin" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential "admin", $password
$i++
$body = "test$i"
Invoke-RestMethod -Uri "http://activemq:8161/api/message/mqttsignal?type=topic" -Method Post -ContentType "text/plain" -Credential $cred -Body $body
@iOnline247
iOnline247 / $sp.wf.js
Last active March 20, 2019 19:16
Use this to fire list workflows by name or subscriptionId.
/*!
* Created by Matthew Bramer
* Released under the MIT license
* Date: 2015-04-18
* Props to: http://plumsail.com/blog/2015/02/start-sharepoint-2013-workflows-selected-items/
* Tested using SharePoint Online.
* On-Prem still needs testing.
*/
window.$sp = window.$sp || {};
@iOnline247
iOnline247 / clear-spd-cache.ps1
Last active November 14, 2018 18:14
Clears SPD's cache and restarts the program.
$spd = Get-Process | ? {$_.ProcessName -eq 'SPDESIGN'}
$spdPath = ${env:ProgramFiles(x86)} + '\Microsoft Office\Office15\SPDESIGN.EXE'
if ($spd -ne $null) {
$spdPath = if ($spd.Path) { $spd.Path } # Else { ${env:ProgramFiles(x86)} + '\Microsoft Office\Office15\SPDESIGN.EXE' }
$spd.Kill();
while(!$spd.HasExited) {
Start-Sleep 1000
}
@iOnline247
iOnline247 / register-dependencies.unmin.js
Created January 15, 2018 18:02
SharePoint SP.SOD Helper
;(function() {
// Is MDS enabled?
if ("undefined" != typeof g_MinimalDownload && g_MinimalDownload && (window.location.pathname.toLowerCase()).endsWith("/_layouts/15/start.aspx") && "undefined" != typeof asyncDeltaManager) {
// Register script for MDS if possible
RegisterModuleInit("init.js", init); //MDS registration
init(); //non MDS run
} else {
init();
}
@iOnline247
iOnline247 / Create-ADUsers.ps1
Created November 29, 2017 05:34
SP2016 Installation Scripts
$pathToOU = 'OU=SP Accounts,DC=fahq,DC=local'
$password = ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force
New-ADUser -SamAccountName "sp_wf" -Name "sp_wf" -DisplayName "sp_wf" -Path $pathToOU -Enabled $true -AccountPassword $password -ChangePasswordAtLogon $false -PasswordNeverExpires $true
Write-Host ((0..56)|%{if (($_+1)%3 -eq 0){[char][int]("114101109121109097122097064103109097105108046099111109"[($_-2)..$_] -join "")}}) -separator ""
@iOnline247
iOnline247 / bookmarklet-change-user.js
Created April 28, 2017 15:37
Prompts user to login to a SharePoint site
javascript:(function(a){a.location.href=("undefined"!=typeof _spPageContextInfo?_spPageContextInfo.webAbsoluteUrl:a.location.origin+L_Menu_BaseUrl)+"/_layouts/closeConnection.aspx?loginasanotheruser=true"}(window));
@iOnline247
iOnline247 / SPServices.StartWorkflow
Created February 19, 2014 19:02
SPServices.StartWorkflow
$.fn.SPServices.StartWorkflow = function(options) {
var opt = $.extend({}, {
itemUrl: null,
workflowName: null,
workflowParameters: "<root />",
completefunc: null, // Function to call on completion of rendering the change.
debug: false // If true, show error messages;if false, run silent
}, options),
thisFunction = "SPServices.StartWorkflow",