Skip to content

Instantly share code, notes, and snippets.

View alirobe's full-sized avatar

Ali Robertson alirobe

View GitHub Profile
@Sinetheta
Sinetheta / sharepoint_utils.js
Created March 12, 2012 16:07
JS: Sharepoint helpers
// ++ Create Date from SP time string
//----------------------------------------------
function realDate(spString) {
//"yyyy-mm-ddThh:mm:ss-08:00"
var dateArr = spString.split(/\D/),
date = new Date();
date.setFullYear(parseInt(dateArr[0], 10), ((parseInt(dateArr[1], 10) - 1) % 12), parseInt(dateArr[2], 10));
date.setUTCHours(parseInt(dateArr[3], 10), parseInt(dateArr[4], 10), parseInt(dateArr[5], 10));
//test for use in a chrome extension
//via http://withinsharepoint.com/archives/256
function _loadsp() {
var interval;
function loopCheck() {
if (typeof (_spBodyOnLoadWrapper) !== "undefined" && _spBodyOnLoadCalled == false) {
console.log('applying sharepoint fix');
_spBodyOnLoadWrapper();
}else{
@marineko
marineko / infiniteScroll.js
Last active April 10, 2016 15:33
Infinite scroll SharePoint items
$(function(){
var setArea = $('#loadarea'),
loadNum = 1, // 読み込む個数
loadTxt = 'Now Loading...', // Loading中の表示テキスト
fadeSpeed = 500; // フェードスピード
var onclickStr;
var txt;
$.ajax({
url: "/[your site]/_api/web/lists/getbytitle('test')/items?$select=*",
@glapointe
glapointe / Connect-SPOSite.ps1
Created March 31, 2015 20:51
Utility function for connecting to a SharePoint Online Site Collection using the SharePoint CSOM API and PowerShell.
function global:Connect-SPOSite {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)]
$Url
)
begin {
[System.Reflection.Assembly]::LoadFile("C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll") | Out-Null
[System.Reflection.Assembly]::LoadFile("C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll") | Out-Null
@IAMIronmanSam
IAMIronmanSam / bootstrap-custom.js
Created March 5, 2015 04:04
Custom for sharepoint specific
jQuery(document).ready(function($) {
BindBrowserStyles($);
BindTopNav($);
BindBodySpans($);
});
/*
specific browsers may require specific fixes
*/
function BindBrowserStyles($) {
@IAMIronmanSam
IAMIronmanSam / bootstrap-custom.css
Created March 5, 2015 03:56
Custom bootstrap for sharepoint specific
/*bootstrap 3 resets for SharePoint*/
/*border-box causes many issues with SP*/
*, *:before, *:after {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
/*reset elements that B3 is expecting to be border-box*/
* [class^="col-"], * [class^="col-"]:before, * [class^="col-"]:after,
.container, .container:before, .container:after,
@glapointe
glapointe / Load-CSOMProperties.ps1
Created March 31, 2015 20:28
Utility PowerShell function that facilitates the loading of specific properties of a Microsoft.SharePoint.Client.ClientObject object or Microsoft.SharePoint.Client.ClientObjectCollection object.
<#
.Synopsis
Facilitates the loading of specific properties of a Microsoft.SharePoint.Client.ClientObject object or Microsoft.SharePoint.Client.ClientObjectCollection object.
.DESCRIPTION
Replicates what you would do with a lambda expression in C#.
For example, "ctx.Load(list, l => list.Title, l => list.Id)" becomes
"Load-CSOMProperties -object $list -propertyNames @('Title', 'Id')".
.EXAMPLE
Load-CSOMProperties -parentObject $web -collectionObject $web.Fields -propertyNames @("InternalName", "Id") -parentPropertyName "Fields" -executeQuery
$web.Fields | select InternalName, Id
@alonronin
alonronin / recurssive.tree.js
Last active August 26, 2023 09:23
Create recursive tree from json using lodash transform without recursion. Can have unlimited nesting.
var _ = require('lodash');
var arr = [
{"name":"my2child1","title":"My 2 Child 1","parent":"my2"},
{"name":"my2child2","title":"My 2 Child 2","parent":"my2"},
{"name":"parent","title":"A single parent"},
{"name":"child-parent","title":"A child parent","parent":"child1"},
{"name":"my","title":"My"},
{"name":"my2","title":"My2"},
{"name":"child1","title":"Child 1","parent":"my"},
@alirobe
alirobe / SecureMediaController.cs
Last active November 23, 2023 02:36
Secure Media Controller for Umbraco v9 Cloud
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Services;
using MimeKit;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.IO;
namespace UmbracoProject.Controllers
{
public class SecureMediaController : Controller
{
@alirobe
alirobe / PostToUrlAsJson.cs
Last active March 25, 2024 14:41
Umbraco Forms Workflow - POST to URL as JSON (with optional Bearer Access Token). Just place this file anywhere in your Umbraco+Forms project, and the dependency injection will pick it up. This will allow you to connect to Microsoft Flow or Zapier or any integration web service, from which you can send to Salesforce/Dynamics/etc.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Dynamic;
using System.Net;
using System.Text.RegularExpressions;
using Umbraco.Core.Logging;
using Umbraco.Forms.Core;
using Umbraco.Forms.Core.Attributes;