Skip to content

Instantly share code, notes, and snippets.

View rido-min's full-sized avatar
💭
coding

Rido rido-min

💭
coding
View GitHub Profile
@rido-min
rido-min / SslStreamCustomCA.cs
Created October 24, 2023 15:29
SslStreamCustomCA
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
string host = "test.mosquitto.org";
int port = 8883;
using Socket socket = new(SocketType.Stream, ProtocolType.Tcp);
socket.Connect(host, port);
using NetworkStream stream = new(socket);
@rido-min
rido-min / LICENSE
Created June 4, 2023 18:57 — forked from chrislawlor/LICENSE
Multicast delegates in Python. Uses operator overloading for subscription, C# style.
Copyright 2020 Christopher Lawlor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
@rido-min
rido-min / Command.cs
Created February 10, 2023 01:48
IoTHubCommands
using Microsoft.Azure.Devices;
using System.Text.Json;
namespace SampleDtdlCmd
{
public class Command<TReq, TResp>
{
string _cs;
string _did;
string _name;
@rido-min
rido-min / admin-user.yaml
Last active June 16, 2022 21:52
k8-dashboard
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@rido-min
rido-min / ComputeDeviceKey.cs
Last active June 3, 2022 02:51
ComputeDeviceKey
internal static string ComputeDeviceKey(string masterKey, string deviceId) =>
Convert.ToBase64String(new System.Security.Cryptography.HMACSHA256(Convert.FromBase64String(masterKey)).ComputeHash(System.Text.Encoding.UTF8.GetBytes(deviceId)));
@rido-min
rido-min / ModelsRepositoryClientExtensions.cs
Created April 8, 2022 16:53
ModelsRepositoryClientExtensions
namespace DTDL_scratch
{
using Azure.IoT.ModelsRepository;
using Microsoft.Azure.DigitalTwins.Parser;
internal static class ModelsRepositoryClientExtensions
{
public static async Task<IEnumerable<string>> ParserDtmiResolverAsync(this ModelsRepositoryClient client, IReadOnlyCollection<Dtmi> dtmis)
{
IEnumerable<string> dtmiStrings = dtmis.Select(s => s.AbsoluteUri);
@rido-min
rido-min / Program.cs
Created April 7, 2022 22:30
ValidatePayload
using Microsoft.Azure.DigitalTwins.Parser;
using Microsoft.Azure.DigitalTwins.Parser.Models;
using System.Text.Json;
string basePath = Path.Join(System.Reflection.Assembly.GetExecutingAssembly().Location + @"./../../../");
string ReadFile(string path) => File.ReadAllText(Path.Join(basePath, path));
string ToJs(object obj) => JsonSerializer.Serialize(obj);
var objectModel = new ModelParser().Parse(new string[] { ReadFile("geotypes-1.json") });
@rido-min
rido-min / DTDLParserExtensions.cs
Last active April 8, 2022 17:50
DTDLParserExtensions.cs
namespace dtdl_dotnet
{
using Microsoft.Azure.DigitalTwins.Parser;
using Microsoft.Azure.DigitalTwins.Parser.Models;
public static class DtmiExtensions
{
public static string ToPath(this Dtmi dtmi) => $"{dtmi.ToString().ToLowerInvariant().Replace(":", "/").Replace(";", "-")}.json";
}
public static class ModelParserExtensions
Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.Empty.ToString("N")))
@rido-min
rido-min / X.Y.Z.Sources.csproj
Created October 12, 2021 06:37 — forked from attilah/X.Y.Z.Sources.csproj
X.Y.Z.Sources nuget package
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<IsPackable>true</IsPackable>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>contentFiles</ContentTargetFolders>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>