Skip to content

Instantly share code, notes, and snippets.

View pavel-a's full-sized avatar

Pavel A. pavel-a

View GitHub Profile
@pavel-a
pavel-a / edid_dump.cs
Created March 25, 2019 22:52
A little program to dump display EDIDs in hex. Gets extension blocks.
// Read EDIDs from all displays via WMI ...
// https://docs.microsoft.com/en-us/windows/desktop/wmicoreprov/wmimonitorraweedidv1block
using System;
using System.Management;
namespace edid_dump {
class edid_dump
{
static void Main(string[] args)
// Phys monitor control via DDC/CI or VESA commands
// (David Lowndes)
// From https://social.msdn.microsoft.com/Forums/en-US/5437ddb8-af86-4cf0-8061-798e6601e08e/how-to-control-system-brightness-using-windows-api-?forum=windowsgeneraldevelopmentissues#554b7b7f-0aab-429d-9c36-fd39608979b0
#include <Windows.h>
#include <physicalmonitorenumerationapi.h>
#include <highlevelmonitorconfigurationapi.h>
#pragma comment( lib, "Dxva2.lib" )
void
@pavel-a
pavel-a / tcp_echoclient.py
Last active December 23, 2019 20:12
Simple TCP, UDP Echo clients in Python. Generate random messages of random length. To test some bare metal embedded thingy.
#!/usr/bin/python3
"""
Echo client / TCP
Parameters: set below: server IP address, port=7, timeouts
Message random generated, binary; length and data random : see make_random_msg()
NOTE: First message takes very long time, don't set REPLY_TIMEOUT too short!
pa01 23-dec-2019
"""
import socket
@pavel-a
pavel-a / bin2hexp.py
Last active September 16, 2025 23:32
Binary file converter to Intel hex (python script)
#!/usr/bin/python3
'''
Converts a binary file into an intel hex file
Usage: Bin2Hex.py [-A base_address] [-n] [-F yes|no] -b <binary_file> -o <hex_to_be_created>
pavel_a@fastmail.fm 05-aug-2022
Original: https://community.silabs.com/s/article/converting-binary-firmware-image-files-to-intel-hex-files-bin-to-hex-x
'''
@pavel-a
pavel-a / USBWriteProtect1.js
Created April 28, 2023 21:42
Windows; toggle write protection on inserted USB drives (wsh)
//-----------------------------------------------------------------------------
// Toggle write protection on USB drives
//
// See http://support.microsoft.com/kb/555443
// [ HKLM\System\CurrentControlSet\Control\StorageDevicePolicies\WriteProtect: reg_dw: 1 ]
//
// NOTES:
// - This registry hack (KB555443) works only starting from XP SP2; I don't check for the SP.
// - If a drive is already attached, write enable seems to come in effect immediately;
// Write disable becomes effective only after the drive is re-attached.