Skip to content

Instantly share code, notes, and snippets.

View sjkp's full-sized avatar

Simon J.K. Pedersen sjkp

View GitHub Profile
@sjkp
sjkp / sp2013 include reputation
Last active March 17, 2021 10:44
SharePoint 2013, how to enable like/unlike functionality by client side javascript on a publishing pagelayout. - Requirements, like functionality is enabled on the page library. - You must include reputation.js if you are wrapping this in a webcontrol, that can e.g. be done with: ScriptLink.RegisterScriptAfterUI(this.Page, "reputation.js", false);
<%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<SharePointWebControls:ScriptLink language="javascript" name="reputation.js" OnDemand="false" LoadAfterUI="true" runat="server" Localizable="false" />
@sjkp
sjkp / ObservableEventTriggerFilter
Last active August 29, 2015 14:02
Observable filter that blocks specific events with a specific Id from flowing through. The filter is activated when a EventAction.Nothing flows through and deactivated on the subsequent EventAction.Nothing with the same Id.
open System
type EventAction = Nothing | Something
type TimeEvent = {time: DateTime; Id: int; Action : EventAction}
let t,t2 = new System.Timers.Timer(1000.0), new System.Timers.Timer(5000.0)
let timer1Stream = t.Elapsed |> Observable.map(fun _ -> {time = DateTime.Now; Id = 1; Action = EventAction.Something})
let timer2Stream = t2.Elapsed |> Observable.map(fun _ -> {time = DateTime.Now; Id = 1; Action = EventAction.Nothing})
@sjkp
sjkp / CalculatedBlobCost.ps1
Last active February 10, 2017 02:20
Powershell Script for calculating the actual used page blob storage (VHDs) of a storage account. The calculated amount is the amount you are billed for.
<#
.SYNOPSIS
Calculates cost of all blobs in a container or storage account.
.DESCRIPTION
Enumerates all blobs in either one container or one storage account and sums
up all costs associated. This includes all block and page blobs, all metadata
on either blobs or containers. It also includes both committed and uncommitted
blocks in the case that a blob is partially uploaded.
The details of the calculations can be found in this post:
@sjkp
sjkp / AzureVMImageList
Created October 28, 2014 21:22
Azure VM Image List
Executing command vm image list
Fetching VM images
Name Category OS
-------------------------------------------------------------------------------------------------------------------- -------- -------
03f55de797f546a1b29d1b8d66be687a__Visual-Studio-14-Professional-CTP-14.0.22129.1-AzureSDK-2.4-WS2012R2 Public Windows
0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.2-x64-v5.8.8.1 Public Linux
0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.3-x64-v5.8.8 Public Linux
0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.3-x64-v5.8.8.5 Public Linux
0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.3-x64-v5.8.8.6 Public Linux
0b11de9248dd4d87b1862
@sjkp
sjkp / DownloadSharePointOnlineAssemblies
Created November 11, 2014 20:50
Download assemblies from SharePoint Online
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
#replace contoso with your own tenant
$spUrl = "https://contoso.sharepoint.com/"
$dllsVTI = @("Microsoft.BusinessData.dll", "Microsoft.Office.Client.Policy.dll", "Microsoft.Office.Client.TranslationServices.dll",
"Microsoft.Office.DocumentManagement.dll", "Microsoft.Office.Excel.Server.Udf.dll", "Microsoft.Office.Excel.Server.WebServices.dll",
"Microsoft.Office.Policy.dll", "Microsoft.Office.SecureStoreService.Server.Security.dll", "Microsoft.Office.Server.dll",
"Microsoft.Office.Server.Search.Applications.dll", "Microsoft.Office.Server.Search.Connector.dll", "Microsoft.Office.Server.Search.dll",
"Microsoft.Office.Server.Search.ExchangeAdapter.dll", "Microsoft.Office.Server.UserProfiles.dll",
@sjkp
sjkp / ffmpeg encoding
Last active December 4, 2016 04:25
Nook HD+ compatible mp4 ffmpeg encode
ffmpeg -i "input.mp4" -vcodec libx264 -vprofile main -preset slow -b:v 400k -maxrate 400k -bufsize 800k -vf scale=854:trunc(ow/a/2)*2 -threads 0 -acodec libvo_aacenc -ab 128k "output.mp4"
@sjkp
sjkp / enable-sideloading.ps1
Created April 19, 2015 08:11
Enable Side Loading of Apps
[System.Reflection.Assembly]::LoadFile("C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
$ctx = new-object Microsoft.SharePoint.Client.ClientContext("https://<site>")
$pass = "<password>"
$s = ConvertTo-SecureString -String $pass -AsPlainText -Force
Param([string]$publishsettings,
      [string]$storageaccount,
      [string]$subscription,
      [string]$service,
      [string]$containerName="mydeployments",
      [string]$config,
      [string]$package,
      [string]$slot="Staging")
 
Function Get-File($filter){
@sjkp
sjkp / remove-nodemodules
Created June 13, 2015 17:04
Remove node_modules on windows
Install RimRaf:
npm install rimraf -g
And in the project folder delete the node_modules folder with:
rimraf node_modules
@sjkp
sjkp / download-azure-arm-templates
Created June 28, 2015 22:02
Download Azure ARM templates from the gallery
New-Item -path 'C:\Azure\arm-Templates\' -type directory -Force
$microsoftTemplates = Get-AzureResourceGroupGalleryTemplate -Publisher 'Microsoft'
foreach ($item in $microsoftTemplates)
{
$identity = $item.'Identity'
Save-AzureResourceGroupGalleryTemplate -Identity $identity `
-Path C:\Azure\arm-Templates\ `