Skip to content

Instantly share code, notes, and snippets.

@ridomin
ridomin / FixedSizeDictonary.cs
Created November 18, 2021 15:45
FixedSizeDictonary
public class FixedSizeDictonary<TKey, TValue> : Dictionary<TKey, TValue> where TKey : notnull
{
int size;
Queue<TKey> orderedKeys = new Queue<TKey>();
public FixedSizeDictonary(int maxSize) => size = maxSize;
public new void Add(TKey key, TValue value)
{
orderedKeys.Enqueue(key);
if (size != 0 && Count >= size) Remove(orderedKeys.Dequeue());
base.Add(key, value);
@ridomin
ridomin / watch.sh
Created October 3, 2021 07:53
dotnet watch
dotnet watch test --logger:"console;verbosity=detailed"
@ridomin
ridomin / getLinesFromTextArea.js
Created February 10, 2021 07:45
geLlinesFromTextArea.js
/**
* @param {string} id - element id
* @returns {HTMLElement}
*/
const gbid = (id) => {
const el = document.getElementById(id)
if (el === null) {
throw new Error('element not found: ' + id)
}
return el
@ridomin
ridomin / sleep.js
Created November 14, 2020 00:36
sleep,js
const sleep = (delay) => new Promise(resolve => setTimeout(resolve, delay))
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace TemperatureController2
{
class Program
{
@ridomin
ridomin / client.js
Created May 31, 2020 20:25
WebSocketsDemo
var wsUri = "ws://127.0.0.1:8999";
ws = new WebSocket(wsUri);
ws.onopen = (e) => console.log(e)
ws.onmessage = (e) => console.log(e)
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "SecurityLayer" -value 0
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -value 0
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "fAllowSecProtocolNegotiation" -value 0
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -Value 0
@ridomin
ridomin / create-aziothub-device.js
Created April 21, 2020 06:15
create-aziothub-device.js
'use strict';
const iothub = require('azure-iothub')
const registry = iothub.Registry.fromConnectionString(process.env.IOTHUB_CONNECTION_STRING)
const device = {deviceId: 'ppr-bb-' + new Date().getTime(), status: 'enabled'}
registry.create(device, (err) => {
if (err) throw(err)
console.log(`Device ${device.deviceId} created`)
import * as msRest from '@azure/ms-rest-js'
import {IoTHubTokenCredentials} from './iothub_token_credentials'
export type DigitalTwinGetResponse = {
body: any;
_response: msRest.HttpResponse & {
bodyAsText: string;
parsedBody: any;
};
};
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"globals" :
{
"alwaysShowTabs" : true,
"copyOnSelect" : false,
"defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :