Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View anoopt's full-sized avatar

Anoop T anoopt

View GitHub Profile
@anoopt
anoopt / useAzureFunctions.ts
Created March 7, 2023 17:31
A custom react hook to call Azure functions
import * as React from 'react';
import { AadHttpClient, AadHttpClientFactory } from "@microsoft/sp-http";
import { APP_ID } from './constants';
export const useAzureFunctions = (aadHttpClientFactory: AadHttpClientFactory) => {
const clientRef = React.useRef<AadHttpClient>();
const getClient = React.useCallback(async () => {
if (!aadHttpClientFactory) {
return undefined;
name: "On pull request"
on:
pull_request:
branches:
- main
jobs:
create-task:
runs-on: ubuntu-latest
steps:
@anoopt
anoopt / gpt-3.5-turbo-get-page-summary-in-different-languages.ps1
Last active March 2, 2023 09:02
Multilingual SharePoint Page Summarization with Open AI API and Microsoft Graph PowerShell SDK
# A script to get summary of a SharePoint site page using GPT-3.5 turbo
# The script accepts the following parameters:
# SiteAbsoluteUrl, PageName
Param(
[Parameter(Mandatory = $true)]
[string]$SiteAbsoluteUrl,
[Parameter(Mandatory = $true)]
[string]$PageName
)
# For better pipelines see - https://www.voitanos.io/blog/sharepoint-framework-azure-pipelines-templates/
parameters:
- name: sppkg_file_name
type: string
default: name_of_the_package.sppkg
- name: site_url
type: string
default: https://contoso.sharepoint.com/sites/teamsite
- name: tenant_name
@anoopt
anoopt / spfx-cicd-with-pnp-poweshell-oidc.yml
Last active November 11, 2022 09:50
SPFx CICD with PnP PowerShell OIDC
name: SPFx CICD with PnP PowerShell OIDC
on:
workflow_dispatch:
push:
branches:
- main
permissions:
id-token: write
@anoopt
anoopt / m365princess-pnp-site-info.png
Last active April 12, 2022 10:16
SharePoint site info in oh-my-posh
m365princess-pnp-site-info.png
@anoopt
anoopt / getTimeBasedOnTimeZone.ts
Last active March 31, 2022 08:12
Get difference between local time and other time zone based time using Temporal or Luxon
<!-- Example -->
//const time = showTimeUsingTemporal ?
//await this.getOfficeLocalTimeUsingTemporal(officeTimeZoneId) :
//await this.getOfficeLocalTimeUsingLuxon(officeTimeZoneId);
<!-- Output -->
<!-- officeTimeZoneId = 'Asia/Kolkata' -->
//🕙 14:32 (4h 30m ahead of you)
<!-- officeTimeZoneId = 'Europe/London' -->
@anoopt
anoopt / msgraph.ts
Last active March 7, 2023 17:12
Helper wrapper for calling Graph
//* Helper wrapper for calling Graph
//* based on https://gist.github.com/wobba/37416d3107b85675d896105554b3df28
//* Thank you Mikael Svenson
import { WebPartContext } from '@microsoft/sp-webpart-base';
import { GraphError } from '@microsoft/microsoft-graph-client';
import { MSGraphClientV3 } from '@microsoft/sp-http';
export class msgraph {
private static _graphClient: MSGraphClientV3;
@anoopt
anoopt / confirmation_before_changing_status.json
Last active March 9, 2022 11:41
Confirmation before changing status
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"style": {
"flex-directon": "row",
"justify-content": "left",
"align-items": "center",
"flex-wrap": "nowrap"
},
"children": [
import * as github from '@actions/github';
...
...
const octokit = github.getOctokit(githubToken);
...
...
const opts = octokit.rest.issues.listForRepo.endpoint.merge({
...context.issue,
state: filterState,
labels: filterLabel