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 / 1itg_line.py
Last active January 2, 2021 12:14
Example how displays work 1itg_line.py
from sense_hat import SenseHat
sense = SenseHat()
r = (255, 0, 0) # red
g = (0, 255, 0) # green
b = (0, 0, 255) # blue
w = (255,255,255) # white
e = (0,0,0) # empty, no light - black
# 8x8 matrix RGB display
@bechynsky
bechynsky / 1itg_smile.py
Last active January 2, 2021 12:13
Example how displays work 1itg_smile.py
from sense_hat import SenseHat
sense = SenseHat()
r = (255, 0, 0) # red
g = (0, 255, 0) # green
b = (0, 0, 255) # blue
w = (255,255,255) # white
e = (0,0,0) # empty, no light - black
# 8x8 matrix RGB display
@bechynsky
bechynsky / 1itg_greeting.py
Last active January 2, 2021 12:27
Example how displays work 1itg_greeting.py
from sense_hat import SenseHat
sense = SenseHat()
sense.show_message("1. IT Gymnazium", text_colour = (0, 255, 0))
@bechynsky
bechynsky / Program.cs
Created January 2, 2021 12:17
Example how to call Cognitive Services Vison REST API
using System;
using System.Net;
using System.Text;
namespace VisionDemo
{
class Program
{
private const string LOCATION = "";
private const string KEY = "";
@bechynsky
bechynsky / ad.scala
Last active January 19, 2021 08:52
DP-200 Module 3 Lab 3 Exercise 3 Task 4
//From Storage Account
// Azure Storage Account name <storage-account-name>
var storage_account_name = ""
// <file-system-name>
var file_system_name = "logs"
// From AD
// Application (client) ID <application-id>
var application_id = ""
// Key <authentication-key> for application
@bechynsky
bechynsky / 1itg_thumbnail.bat
Created January 2, 2021 12:40
Using curl util to call Cognitive Services Vision REST API for Generate Thumbnail
curl -H "Ocp-Apim-Subscription-Key: {KEY}" -H "Content-Type: application/json" "https://{LOCATION}.api.cognitive.microsoft.com/vision/v3.1/generateThumbnail?width=100&height=100&smartCropping=true" -d "{\"url\":\"https://upload.wikimedia.org/wikipedia/commons/thumb/5/56/Shorkie_Poo_Puppy.jpg/1280px-Shorkie_Poo_Puppy.jpg\"}" -o small_dog.jpg
@bechynsky
bechynsky / create_cosmosdb.sh
Last active January 12, 2021 09:53
Creates Cosmos DB resource, database and collection. Designed for Cloud Shell
export RESOURCE_GROUP=""
export RESOURCE_NAME=""
export LOCATION=""
export DB_NAME=""
export COLLECTION=""
export PARTITION_KEY=""
az group create --name $RESOURCE_GROUP --location $LOCATION
az cosmosdb create --name $RESOURCE_NAME --kind GlobalDocumentDB --resource-group $RESOURCE_GROUP
az cosmosdb sql database create --name $DB_NAME --account-name $RESOURCE_NAME --resource-group $RESOURCE_GROUP
@bechynsky
bechynsky / rpi_camera_to_blob_storage.py
Created January 5, 2021 14:32
Get picture from Raspberry Pi Camera and uplouad to Azure Storage Container
from picamera import PiCamera
from azure.storage.blob import BlobServiceClient, BlobClient, BlobSasPermissions, generate_blob_sas
from datetime import datetime, timedelta
# You need to create container first
container_name = ''
account_name = ''
key = ''
connection_string = 'DefaultEndpointsProtocol=https;AccountName=' + account_name + ';AccountKey=' + key + ';EndpointSuffix=core.windows.net'
@bechynsky
bechynsky / vision_101.py
Created January 5, 2021 14:36
Simple demo Azure Cognitive Services Vision REST API
import requests
from pprint import pprint
subscription_key = ''
endpoint = ''
api_url = endpoint + 'vision/v3.1/analyze'
image_url = ''
headers = {'Ocp-Apim-Subscription-Key': subscription_key,
'Content-Type': 'application/json'}
@bechynsky
bechynsky / azurestoragesample.cs
Last active January 11, 2021 15:13
Sample for Azure Storage account, AZ-204, DP-200
/*
You neeed to create App.config file with this content
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="storage" value="YOUR CONNECTION SRING TO AZURE STORAGE ACCOUNT" />
</appSettings>
</configuration>