Skip to content

Instantly share code, notes, and snippets.

@jdhenckel
jdhenckel / PL2303_USB_Arduino_Demo.cpp
Created July 23, 2023 21:05
Sample code for reading POSTAGE scale with Arduino and USB Host Shield
#include <Arduino.h>
#include <usbhub.h>
#include <cdcprolific.h>
#include <SPI.h>
void print(String a, uint8_t b)
{
Serial.print(a);
Serial.print(' ');
@jdhenckel
jdhenckel / DICOM_Parser.cs
Created November 2, 2022 21:36
Small utility to convert EvilDicomObject into a heirarchy of simple types (dict, list, string, int, double) and eventually serialized to JSON
using EvilDICOM.Core;
using EvilDICOM.Core.Dictionaries;
using System.Text.Json;
using System.Linq;
namespace DotnetDicom
{
internal class Program
{
/// <summary>
@jdhenckel
jdhenckel / madras.js
Created August 29, 2022 18:45
A convenience class for Javascript to read documents from CosmosDB
//=====================
// Service functions for accessing the CosmosDB from the Madras-WDC
//==================
"use strict";
import { CosmosClient } from "@azure/cosmos";
function parseConnectionString(connection_string) {
let result = {};
for (let m of connection_string.matchAll(/(\w+)=(.*?);/g))
@jdhenckel
jdhenckel / WIndowSetup.cs
Last active February 20, 2024 14:11
This is a simple DotNet console application to save/restore desktop window positions and sizes
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Threading;
@jdhenckel
jdhenckel / MouseMinder.cs
Last active January 25, 2024 00:50
You can run this in the background and it will move your mouse to a nice location if you leave it idle for long enough time.
using System.Runtime.InteropServices;
using System;
using System.Numerics;
using System.Threading;
namespace MouseMinder
{
/***************
* John Henckel, jdhenckel@gmail.com 1 OCT 2020
*
@jdhenckel
jdhenckel / SQL-DrawIO-README.md
Last active June 21, 2019 15:00
A C# command line program to convert SQL DDL into nice DrawIO diagrams

SQL-DRAWIO

John Henckel, June 2019

This parses the SQL DDL for a database and generates a XML file that is suitable to IMPORT into the https://draw.io

Sql-DrawIO

/*
This can be used in unit tests to simulate a DOM document.
For example, in your jasmine spec file, in the beforeEach, you can do
global.document = new MockElement();
This is not complete. I only implemented the stuff that I needed for my own unit tests.
You should aggressively modify it for your purposes.
*/
@jdhenckel
jdhenckel / MockElement.ts
Last active July 16, 2020 23:06
Mock DOM Document and Element in TypeScript for Unit testing in Headless environment.
/*
This can be used in unit tests to simulate a DOM document.
I have implemented the bare minimum. Feel free to add more, or to change my implementation.
Sample Usage:
import 'jasmine';
import { MockElement } from './support/mock-element';
@jdhenckel
jdhenckel / ParserForCSV.java
Last active October 29, 2018 14:12
CSV Parser (comma delimited values) written in Java and works with EXCEL exported files
//-------------------------------------------------------------------------------
// This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
// The person who associated a work with this deed has dedicated the work to the public domain by
// waiving all of his or her rights to the work worldwide under copyright law, including all related
// and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform
// the work, even for commercial purposes, all without asking permission.
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;