Skip to content

Instantly share code, notes, and snippets.

View waldekmastykarz's full-sized avatar
🥑
Microsoft 365

Waldek Mastykarz waldekmastykarz

🥑
Microsoft 365
View GitHub Profile
@waldekmastykarz
waldekmastykarz / remove-apipermissions.mjs
Created June 1, 2021 12:02
Removes granted SharePoint API permissions
#!/usr/bin/env zx
$.verbose = false;
console.log('Retrieving granted API permissions...');
const apiPermissions = JSON.parse(await $`m365 spo sp grant list -o json`);
for (let i = 0; i < apiPermissions.length; i++) {
const permission = apiPermissions[i];
console.log(`Removing permission ${permission.Resource}/${permission.Scope} (${permission.ObjectId})...`);
try {
@waldekmastykarz
waldekmastykarz / .zshrc
Last active June 24, 2021 12:05
Celsius to Fahrenheit and vice versa in zsh
# usage
# $ deg 10c # Celsius to Fahrenheit
# 50.0
#
# $ deg 115f # Fahrenheit to Celsius
# 46
deg() {
unit=${1:(-1)}
d=${1:0:(-1)}
if [ $unit = c ]
@waldekmastykarz
waldekmastykarz / .zshrc
Created June 23, 2021 11:34
Calculator in zsh
# usage:
# $ = "1+2"
# 3
# quotes are necessary only for some expressions like *, but better to use them all the time just to be safe
function = {
echo "$1" | bc -l
}
@waldekmastykarz
waldekmastykarz / mgdp-rate-limiting.sh
Created March 30, 2023 06:39
Microsoft Graph Developer Proxy rate-limiting preset
mgdp --config presets/microsoft-graph-rate-limiting.json
@waldekmastykarz
waldekmastykarz / appsettings.json
Created April 25, 2023 11:58
Excluding URLs in Microsoft Graph Developer Proxy
{
"plugins": [
{
"name": "GraphRandomErrorPlugin",
"enabled": true,
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
"configSection": "graphRandomErrorsPlugin"
}
],
"urlsToWatch": [
<html>
<head>
<title>v0.29.0</title>
</head>
<body>
<h1>v0.29.0</h1>
<h2>Update trust-cert.sh prompt to use y|n + ENTER</h2>
<p>
@waldekmastykarz
waldekmastykarz / github-config.json
Last active September 3, 2023 10:21
GitHub m365proxy preset
{
"plugins": [
{
"name": "RateLimitingPlugin",
"enabled": true,
"pluginPath": "plugins\\m365-developer-proxy-plugins.dll",
"configSection": "rateLimiting"
}
],
"urlsToWatch": [
@waldekmastykarz
waldekmastykarz / m365proxy-latency.json
Created September 25, 2023 13:11
Sample simulation of latency on Microsoft Graph API requests using Microsoft 365 Developer Proxy
{
"plugins": [
{
"name": "LatencyPlugin",
"enabled": true,
"pluginPath": "~appFolder\\plugins\\m365-developer-proxy-plugins.dll",
"configSection": "latencyPlugin"
}
],
"urlsToWatch": [
@waldekmastykarz
waldekmastykarz / ConnectionConfiguration.cs
Last active October 12, 2023 09:01
Build Microsoft Graph connector article - ConnectionConfiguration.cs
using System.Text.Json;
using Microsoft.Graph.Models;
using Microsoft.Graph.Models.ExternalConnectors;
static class ConnectionConfiguration
{
public static ExternalConnection ExternalConnection
{
get
{
@waldekmastykarz
waldekmastykarz / ConnectionService.cs
Created October 12, 2023 09:00
Build Microsoft Graph connector article - ConnectionService.cs
static class ConnectionService
{
async static Task CreateConnection()
{
await GraphService.Client.External.Connections
.PostAsync(ConnectionConfiguration.ExternalConnection);
}
async static Task CreateSchema()
{