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 / getWebParts.js
Created July 27, 2018 14:40
How to retrieve web parts along with web part type using SharePoint JSOM API
async function executeQuery(context) {
return new Promise((resolve, reject) => {
context.executeQueryAsync(function () {
resolve();
}, function (sender, args) {
reject(args);
});
});
}
@vgrem
vgrem / data.json
Created July 18, 2018 13:24
Sample JSON data
[
{
"photo_id": 27932,
"name": "Atardecer en Embalse",
"photo_url": "http://www.panoramio.com/photo/27932",
"photo_file_url": "http://mw2.google.com/mw-panoramio/photos/medium/27932.jpg",
"lng": -64.404945,
"lat": -32.202924,
"width": 500,
"height": 375,
@vgrem
vgrem / Get-SPOWebs.ps1
Created March 24, 2018 10:54
Retrieve sub webs within a site collection
function Get-SPOWebs(){
param(
$Url = $(throw "Please provide a Site Collection Url"),
$Credential = $(throw "Please provide a Credentials")
)
$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$context.Credentials = $Credential
$web = $context.Web
$context.Load($web)
@vgrem
vgrem / data.json
Last active February 14, 2018 00:02
Positions sample
[
{
"lat": 51.231469,
"lng": 4.402005299999973,
"id": 1
},
{
"lat": 51.2561314,
"lng": 4.372296000000051,
"id": 2
@vgrem
vgrem / LatLng.java
Created November 18, 2017 17:09
A place on Earth, represented by a latitude/longitude pair.
package org.vgrem.geotools;
import java.util.Locale;
/**
* A place on Earth, represented by a latitude/longitude pair.
*/
public class LatLng
{
@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;
@vgrem
vgrem / SPOUploadFile.ps1
Created September 14, 2017 11:17
Demonstrateds how to upload a file into SharePoint Online via WebDAV
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll"
function Connect-SPO ([string] $Username, [string]$Password, [string]$Url) {
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $(ConvertTo-SecureString -AsPlainText $Password -Force))
$Context.ExecuteQuery()
@vgrem
vgrem / CreateCommunicationSite.ps1
Last active August 11, 2017 12:12
Create Office365 Communication Site
#[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.dll")
#[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime.dll")
#[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Online.SharePoint.Client.Tenant.dll")
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll"
function Connect-SPO ([string] $Username, [string]$Password, [string]$TenantUrl) {
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($TenantUrl)
[
{
"name": "Oslo",
"position" : {
"lat": 59.923043,
"lng": 10.752839
}
},
{
"name": "Stockholm",
[
{
"name": "Oslo",
"position" : {
"lat": 59.923043,
"lng": 10.752839
}
},
{
"name": "Stockholm",