This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| // once you create a computer vision service in Azure, you'll get the region and service key | |
| // CV OCR docs are here: https://eastus2.dev.cognitive.microsoft.com/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fc | |
| var recognizer = new Recognizer("<REGION OF YOUR CV SERVICE>", "<CV SERVICE KEY>"); | |
| // here's an example if the image to OCR is on the internet somewhere already | |
| recognizer.RecognizeFromImageUrl("<URL TO IMAGE, IF AVAILABLE ON INTERNET>", "ar").Wait(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import azure.functions as func | |
| from azure.keyvault import KeyVaultClient, KeyVaultAuthentication | |
| from azure.common.credentials import ServicePrincipalCredentials | |
| # see https://docs.microsoft.com/en-us/python/api/overview/azure/key-vault?view=azure-python | |
| def auth_callback(server, resource, scope): | |
| credentials = ServicePrincipalCredentials( | |
| client_id = '<CLIENT ID>', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import requests | |
| import json | |
| def main(): | |
| client_id = "<CLIENT ID>" | |
| client_secret = "<CLIENT SECRET>" | |
| resource_id = "https://graph.microsoft.com" | |
| tenant = "<TENANT NAME OR GUID> (like microsoft.com or jpd.ms)" | |
| graph_query = "<GRAPH PATH> - example: users/john@jpd.ms" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Linq; | |
| using System.Net.Http; | |
| using System.Net.Security; | |
| using System.Security.Cryptography.X509Certificates; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| namespace HttpPrivateCa | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task Go() | |
| { | |
| var response = await _client.GetStringAsync("https://<SEARCH_SERVICE>.search.windows.net/indexes/<INDEX>/docs?api-version=2017-11-11&search=*&%24top=100&%24select=metadata_storage_path"); | |
| dynamic data = JsonConvert.DeserializeObject(response); | |
| foreach (dynamic a in data["value"]) | |
| { | |
| string originalPath = a.metadata_storage_path.ToString(); | |
| // remove extra char | |
| string path = originalPath.Substring(0, originalPath.Length - 1); | |
| // fix padding - remove extra characters that the .netfx UrlTokenEncode adds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $currentApps = (Get-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme).AppsUseLightTheme | |
| $currentSystem = (Get-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme).SystemUsesLightTheme | |
| Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value (1 - $currentApps) | |
| Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value (1 - $currentSystem) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Data; | |
| using System.Linq; | |
| using Newtonsoft.Json.Linq; | |
| namespace ConsoleApplication8 | |
| { | |
| public struct VmSize | |
| { | |
| public string Name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # change me | |
| $AppId = "" # client id, with user_impersonation rights on azure svc management | |
| $secret = "" # app secret | |
| $Resource = "https://management.core.windows.net/" | |
| $TenantId = "" # tenant guid | |
| $user = "" # some global admin account, without any extra goop - e.g., no MFA, no conditional access, etc, or you'll have to use app passwords or something similar | |
| # or, if you use a federated account, you can use the active endpoint on your STS to authenticate, which you then use to authenticate to AAD, which you can then use for oauth | |
| $password = "lol no" # as icky as this is, at least make this SecureString | |
| $tokenUrl = "https://login.microsoftonline.com/$TenantId/oauth2/token" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # start with a redirect to 443 | |
| <VirtualHost *:80> | |
| Redirect / https://myapp.example.com | |
| </VirtualHost> | |
| <VirtualHost *:443> | |
| ServerName myapp.example.com # the DNS name users will use to connect to your app | |
| SSLEngine on | |
| SSLCertificateFile /etc/ssl/certs/myapp-example-com.pem # your cert path | |
| SSLCertificateKeyFile /etc/ssl/certs/myapp-example-com-key.pem # your cert's key path | |
| LimitRequestFieldSize 65536 # certain headers can grow larger than the default, 64K is a reasonable size |