Skip to content

Instantly share code, notes, and snippets.

View bechynsky's full-sized avatar
😺

Štěpán Bechynský bechynsky

😺
  • Microsoft
  • Prague, Czech republic
  • X @stepanb
View GitHub Profile
@bechynsky
bechynsky / CustomVisionObjectDetection.js
Created January 21, 2021 07:28
Quickstart: Create an object detection project with the Custom Vision client library
// https://docs.microsoft.com/en-us/azure/cognitive-services/Custom-Vision-Service/quickstarts/object-detection?tabs=visual-studio&pivots=programming-language-javascript
const util = require('util');
const fs = require('fs');
const TrainingApi = require("@azure/cognitiveservices-customvision-training");
const PredictionApi = require("@azure/cognitiveservices-customvision-prediction");
const msRest = require("@azure/ms-rest-js");
const trainingKey = "";
const predictionKey = "";
@bechynsky
bechynsky / CustomVisionClassification.js
Created January 21, 2021 07:30
Quickstart: Create an image classification project with the Custom Vision client library
// https://docs.microsoft.com/en-us/azure/cognitive-services/Custom-Vision-Service/quickstarts/image-classification?tabs=visual-studio&pivots=programming-language-javascript
const util = require('util');
const fs = require('fs');
const TrainingApi = require("@azure/cognitiveservices-customvision-training");
const PredictionApi = require("@azure/cognitiveservices-customvision-prediction");
const msRest = require("@azure/ms-rest-js");
const trainingKey = "";
const predictionKey = "";
@bechynsky
bechynsky / iotcentral_meteo_rpi_sense_hat.py
Created January 22, 2021 09:50
Simple Azure IoT Hub demo for Sense Hat
# https://pypi.org/project/azure-iot-device/
from azure.iot.device import IoTHubDeviceClient, Message
from sense_hat import SenseHat
sense = SenseHat()
t = sense.get_temperature()
h = sense.get_humidity()
p = sense.get_pressure()
@bechynsky
bechynsky / climate_module_static_website.py
Created February 9, 2021 16:53
Create static file from Hardwario Climate module and publish it to Azure Storage Static website
# https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website-how-to?tabs=azure-portal
# https://tower.hardwario.com/en/latest/hardware/about-climate-module/
import os
import datetime
from paho.mqtt import client as mqtt
from azure.storage.blob import BlobClient
from azure.storage.blob import ContentSettings
@bechynsky
bechynsky / climate_module_to_database.py
Created February 10, 2021 19:09
Saves temperature from Hardwario Climate module to MariaDB
# https://tower.hardwario.com/en/latest/hardware/about-climate-module/
#
# MariaDB database setup
#
# create database climate;
# create user 'python'@'localhost' identified by 'Pyth0n';
# grant all privileges on climate.* to 'python'@'localhost';
# FLUSH PRIVILEGES;
#
# create table temperature(
@bechynsky
bechynsky / get_group_members_msgraph.ps1
Created July 1, 2021 12:06
Simple demo how to get list of group members using Microsoft Graph for M365
# https://docs.microsoft.com/en-us/graph/powershell/installation
# https://docs.microsoft.com/en-us/graph/powershell/get-started
# https://developer.microsoft.com/en-us/graph/graph-explorer
# https://tech.nicolonsky.ch/exploring-the-new-microsoft-graph-powershell-modules/
Connect-MgGraph -Scopes "User.Read.All", "GroupMember.Read.All", "Group.Read.All", "Directory.Read.All"
$GROUP_NAME = 'Workspace'
$group = Get-MgGroup -Filter "DisplayName eq '$GROUP_NAME'"
@bechynsky
bechynsky / grove_node_red_01.json
Created July 17, 2021 11:12
Simple example how to use Raspberry Pi, Grove Base Hat, Grove Temperature sensor SHT31 and Grove 4-digit display
[
{
"id": "f7035dda.42292",
"type": "tab",
"label": "Grove",
"disabled": false,
"info": ""
},
{
"id": "9c65bcd0.754a7",
@bechynsky
bechynsky / rpi_grove_temperature_humidity.py
Last active October 18, 2021 12:49
Reads data from Grove Temperature&Humidity SHT31 sensors ands sends it to webhook (Power Automate)
# Cron
# 0,30 * * * * /usr/bin/python3 /home/pi/rpi_grove_temperature_humidity.py
import time
import requests
# https://wiki.seeedstudio.com/Grove-TempAndHumi_Sensor-SHT31/
# https://github.com/Seeed-Studio/grove.py
# https://seeed-studio.github.io/grove.py/
from grove.i2c import Bus
@bechynsky
bechynsky / ua_flag.py
Created March 3, 2022 15:04
Raspberry Pi Sense HAT Flag of Ukraine
from sense_hat import SenseHat
sense = SenseHat()
# https://en.wikipedia.org/wiki/Flag_of_Ukraine
b = [0, 87, 183] # Strong azure
y = [255, 215, 0] # Yellow
o = [0, 0, 0] # off
ua_flag = [
@bechynsky
bechynsky / web_app_lab_setup.ps1
Created May 1, 2023 07:03
This is script for students environment to play with Azure Web Apps. Every student will get AAD account and rights for one Web App as contributor. You need to share direct link to Web App resource.
# Azure Active Directory domain
$domain = ""
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$PasswordProfile.Password = ""
$PasswordProfile.ForceChangePasswordNextLogin = $false
$resourceUrlPrefix = "https://portal.azure.com/#" + $domain + "/resource/"
$location = "westeurope"