Skip to content

Instantly share code, notes, and snippets.

@chrisobriensp
chrisobriensp / COB_PP_AzureOpenAI.yaml
Last active February 26, 2023 12:37
Azure OpenAI - Power Platform custom connector
swagger: '2.0'
info:
title: Default title
description: Azure OpenAI - Completions API
version: '1.0'
host: [YOUR ENDPOINT PREFIX HERE].openai.azure.com
basePath: /openai
schemes:
- https
consumes: []
@chrisobriensp
chrisobriensp / SP_ColumnFormatting_BingMaps.json
Last active April 24, 2021 15:09
SharePoint column formatting JSON to render a small map from latitude/longitude co-ordinates (e.g. from Power Apps GPS) - expected column name is "MapLocation"
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "img",
"attributes": {
"class": " ms-borderColor-neutralLighter",
"src": "='https://dev.virtualearth.net/REST/v1/Imagery/Map/Road/'+[$MapLocation]+'?mapSize=280,215&key=[Your Bing Maps key here]'"
},
"txtContent": "[$MapLocation]"
}
@chrisobriensp
chrisobriensp / GetTextFromSpeech.cs
Created September 5, 2020 20:17
A sample console app using the Azure Speech SDK to get text from speech in a recording.
using System;
using System.Threading.Tasks;
using Microsoft.CognitiveServices.Speech;
using Microsoft.CognitiveServices.Speech.Audio;
namespace COB.SpeechAPI
{
class Program
{
private static string WAV_FILEPATH = @"C:\Users\chris.obrien\Documents\Voicemeeter\Recording-_17_.wav";
@chrisobriensp
chrisobriensp / Azure_CognitiveServices_VisionAPI
Last active January 12, 2020 18:01
Basic sample to call the Azure Cognitive Services Vision API to obtain tags, objects, a description and more from an image.
using System;
using System.Collections.Generic;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;
using System.Threading.Tasks;
using System.IO;
namespace COB.Azure.ComputerVision
{
class Program
@chrisobriensp
chrisobriensp / SPFx_FormLink.json
Created July 14, 2019 11:37
Some JSON to use with SharePoint JSON column formatting to provide a link to a custom form.
@chrisobriensp
chrisobriensp / PnPJS_TaxonomyPickerHelperMethods.ts
Created July 1, 2019 21:33
TypeScript helper methods related to use of PnP Taxonomy Picker SPFx React control.
// used to get object suitable for writing a single-valued taxonomy value to SharePoint from the PnP taxonomy picker control..
private static getTaxonomyTerm(termDetails: IPickerTerm): ITaxonomyTerm {
let taxonomyTerm: ITaxonomyTerm;
if (termDetails) {
taxonomyTerm = {
TermGuid: termDetails.key,
Label: termDetails.name,
WssId: -1
};
@chrisobriensp
chrisobriensp / IsolatedWebPart_SampleComponent.tsx
Last active April 17, 2019 15:05
Extract of code used in SPFx isolated web part to call AAD-secured web API.
const requestHeaders: Headers = new Headers();
requestHeaders.append('Content-type', 'application/json');
requestHeaders.append('Cache-Control', 'no-cache');
const functionUrl: string = 'https://[FUNCTION HOST URL].azurewebsites.net/api/TeamCreator';
const cobAadFunctionsAppClientId: string = '[CLIENT ID RELATED TO AZURE FUNCTION APP HERE]';
const options: IHttpClientOptions = {
headers: requestHeaders,
body: `{ 'teamName': '${this.state.teamName}', 'teamDesc': '${this.state.teamDesc}' }`
@chrisobriensp
chrisobriensp / IsolatedWebPart_Sample.manifest.json
Created April 17, 2019 10:59
Extract of SPFx web part manifest file for an isolated web part.
"isDomainIsolated": true,
"webApiPermissionRequests": [
{
"resource": "COB-AAD-Functions",
"scope": "user_impersonation"
}
]
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
namespace COB.Teams.Provisioning
{
public class TeamDetails
{
private JObject _teamTemplate = null;
using System;
using System.Globalization;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Newtonsoft.Json;
using COB.Teams.Provisioning.Entities;