Skip to content

Instantly share code, notes, and snippets.

View KeesCBakker's full-sized avatar
😎
Out huntin' bugz!

Kees C. Bakker KeesCBakker

😎
Out huntin' bugz!
View GitHub Profile
@KeesCBakker
KeesCBakker / Settings for MQTT.cs
Last active February 15, 2024 12:10
Settings to connect to MQTT using M2Mqtt (can be used with CloudMqtt)
using System.ComponentModel.DataAnnotations;
using uPLibrary.Networking.M2Mqtt;
using uPLibrary.Networking.M2Mqtt.Messages;
var settings = AppSettingsProvider.Create<MqttSettings>();
var port = Convert.ToInt32(settings.Port);
MqttClient client = null;
if (settings.UseSecureConnection)
{
@KeesCBakker
KeesCBakker / api.ts
Last active January 23, 2023 07:45
Hubot Grafana Slug Support
import fetch, { Headers } from "node-fetch"
import * as p from "path"
const { HUBOT_GRAFANA_HOST, HUBOT_GRAFANA_API_KEY } = process.env
async function fetchFromGrafanaApi(path: string) {
let url = p.join(HUBOT_GRAFANA_HOST!, path)
let response = await fetch(url, {
method: "GET",
headers: new Headers({
Authorization: `Bearer ${HUBOT_GRAFANA_API_KEY}`,
@KeesCBakker
KeesCBakker / roboflow-main-without-jquery-and-lodash.js
Created October 3, 2022 05:14
Let's remove the jQuery and lodash dependencies from the Roboflow main.js.
/*jshint esversion:6*/
window.addEventListener("load", (event) => {
const video = document.querySelector("video");
var model;
var cameraMode = "environment"; // or "user"
const startVideoStreamPromise = navigator.mediaDevices
.getUserMedia({
@KeesCBakker
KeesCBakker / custom-event-polyfill.js
Last active December 2, 2021 03:51
Custom Event Polyfill From MDN
// custom event polyfill for IE9 - IE11
(function () {
if (typeof window.CustomEvent !== 'function') {
function CustomEvent(event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
services.AddScopedByHiddenCookie<IMessageService, HiddenMessageService, DefaultMessageService>();
public static class HiddenCookieExtensions
{
public static IServiceCollection AddScopedByHiddenCookie<TService, THiddenImplementation, TDefaultImplementation>(this IServiceCollection services)
where TService: class
where THiddenImplementation: TService
where TDefaultImplementation: TService
{
services.AddScoped<TService>(provider =>
{
var context = provider.GetRequiredService<IHttpContextAccessor>();
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddHttpContextAccessor();
services.AddTransient<DefaultMessageService>();
services.AddTransient<ISecretKey, SecretKey>();
services.AddTransient<HiddenMessageService>();
public class DefaultMessageService : IMessageService
{
public string GetMessage() => "Hello world!";
}
public class HiddenMessageService : IMessageService
{
private readonly ISecretKey _key;
public HiddenMessageService(ISecretKey key)
public interface IMessageService
{
string GetMessage();
}
[ApiController]
[Route("")]
public class MyController : ControllerBase
{
private readonly IMessageService _messageService;
df_delta = (spark.read
.format("delta")
.load("/mnt/{prefix}-{topic}-delta/delta-table"))