Skip to content

Instantly share code, notes, and snippets.

View vgrem's full-sized avatar
🏠
Working from home

Vadim Gremyachev vgrem

🏠
Working from home
View GitHub Profile
@vgrem
vgrem / SPOUpload-Files.ps1
Last active December 3, 2023 04:09
Upload files into Document Library in SharePoint Online
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Function Ensure-Folder()
{
Param(
[Parameter(Mandatory=$True)]
[Microsoft.SharePoint.Client.Web]$Web,
/**
* @name MarkerClustererPlus for Google Maps V3
* @version 2.1.2 [May 28, 2014]
* @author Gary Little
* @fileoverview
* The library creates and manages per-zoom-level clusters for large amounts of markers.
* <p>
* This is an enhanced V3 implementation of the
* <a href="http://gmaps-utility-library-dev.googlecode.com/svn/tags/markerclusterer/"
* >V2 MarkerClusterer</a> by Xiaoxi Wu. It is based on the
@vgrem
vgrem / SPBatchRequest.js
Last active July 13, 2023 17:31
Example: how to execute SharePoint REST Batch request
var jsonSPHeaders = {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"DataServiceVersion": "3.0"
};
OData.request( {
requestUri: _spPageContextInfo.webAbsoluteUrl + "/_api/$batch",
method: "POST",
headers: { "X-RequestDigest": $("#__REQUESTDIGEST").val(),
@vgrem
vgrem / SP.ListItem.moveTo.js
Created March 30, 2016 19:42
The example demonstrates how to move list item into folder via SharePoint JSOM API
var listTitle = "Requests"; //list title
var itemId = 1; //list item id
var targetFolderUrl = "/Lists/Requests/Archive"; //target folder server relative url
var ctx = SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getByTitle(listTitle);
var item = list.getItemById(itemId);
ctx.load(item,['FileRef','FileDirRef']);
ctx.executeQueryAsync(
function(){
@vgrem
vgrem / filterByMM.php
Created June 8, 2023 17:42
The example demonstrates how to retrieve and filter items by Managed Metadata field (column) value
<?php
require_once './vendor/autoload.php';
$settings = include('./settings.php');
use Office365\Runtime\Auth\ClientCredential;
use Office365\SharePoint\CamlQuery;
use Office365\SharePoint\ClientContext;
@vgrem
vgrem / UTMConverter.java
Last active February 4, 2023 10:56
Convert coordinates from Universal Transverse Mercator (UTM) to Geographic (latitude, longitude) coordinate system
package org.vgrem.geotools;
public class UTMConverter {
/* Ellipsoid model constants (actual values here are for WGS84) */
private static final double MAJOR_RADIUS = 6378137.0;
private static final double MINOR_RADIUS = 6356752.314;
private static final double SCALE_FACTOR = 0.9996;
Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type –Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$AdminUrl = "https://tenant-admin.sharepoint.com/"
$UserName = "username@tenant.onmicrosoft.com"
$Password = "password"
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $SecurePassword
$SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
@vgrem
vgrem / sp.rest.search.js
Created February 23, 2015 12:34
Demonstrates how to query all search results using SharePoint 2013 Search REST API
function search(webUrl,queryText,rowLimit,startRow,allResults)
{
var allResults = allResults || [];
var url = webUrl + "/_api/search/query?querytext='" + queryText + "'&rowlimit=" + rowLimit + "'&startrow=" + startRow;
return $.getJSON(url).then(function(data) {
var relevantResults = data.PrimaryQueryResult.RelevantResults;
allResults = allResults.concat(relevantResults.Table.Rows);
if (relevantResults.TotalRows > startRow + relevantResults.RowCount) {
return search(webUrl,queryText,rowLimit,startRow+relevantResults.RowCount,allResults);
}
@vgrem
vgrem / SPHttpClient.cs
Last active July 15, 2021 15:47
Http client for SharePoint Online
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace SharePoint.Client
{
/// <summary>
@vgrem
vgrem / BatchRequest.cs
Last active May 23, 2021 20:13
BatchRequest class for msgraph-sdk-dotnet
using Microsoft.Graph;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;