Skip to content

Instantly share code, notes, and snippets.

View f-steff's full-sized avatar

Flemming Steffensen f-steff

View GitHub Profile
param (
[string]$BinaryFile,
[string]$SearchString,
$Offset = 0,
$ExtractInt = $null,
$CalcCRC = $null,
$WriteCRC_SE = $null,
$WriteCRC_BE = $null,
$MaxCount = $null,
[switch]$Help = $false,
@f-steff
f-steff / FindHexStringExtract.ps1
Last active August 21, 2024 11:52
Powershell script to search for a string inside an intel hex (iHex) formatted file, returning the address (with optional offset) to all found occurrences. Optionally return a 16 bit integer from an offset from the found address. Finally count of how many times the string was found.
param (
[string]$HexFile,
[string]$SearchString,
$Offset = 0,
$ExtractInt = $null,
$MaxCount = $null,
[switch]$Help
)
# To disable these debug outputs, comment the lines below.
@f-steff
f-steff / FindIHexString.ps1
Last active August 16, 2024 00:29
Powershell script to search for a string inside an intel hex (iHex) formatted file, returning the address (with optional offset) to all found occurrences, and a count of how many times the string was found.
param (
[string]$HexFile, # Path to the HEX file
[string]$SearchString, # The string to search for
$Offset = 0, # Optional address offset (default is 0)
[switch]$Help # Optional help switch
)
# Display help and exit if -help is provided
if ($Help) {
Write-Host "For lack of a better tool, FindIHexString is a quickly hacked together script that searches through"
@f-steff
f-steff / README.md
Created May 24, 2024 10:01
Forward a serial port from Linux to Windows

Forward a serial port from Linux to Windows.

Prerequisites:

  • com0com and com2tcp must be installed on the Windows machine (https://sourceforge.net/projects/com0com/)
  • socat must be installed on the linux box.
  • Optional, to log the communication (on windows) install hub4com (part of the com0com project).

Steps (tested on RPi):

@f-steff
f-steff / README.md
Last active May 7, 2024 13:01
Renesas RX MCU code flash programming - the example Renesas didn't provide.

Test project to try the four known modes of Code Flash self Programming of the RX family.

This code is tested on the RX651 Test board, with the R5F565NEDDFP MCU,

Compiled using CC-RX v3.06.00, and utilizing r_bsp 7.42 and r_flash_rx v5.11

It is expected that this code can be used on at least other RX MCU's from Renesas.

Not all of the tested features are expected to work on all of the various RX MCU's.

@f-steff
f-steff / GoogleSheetsEnableScandinavianKeyboardOnMac.user.js
Last active July 9, 2024 13:52
Tampermonkey userscript to enable missing keys in Scandinavian Keyboard mapping on Mac
// ==UserScript==
// @name Google Sheets Enable Scandinavian Keyboard On Mac
// @namespace https://gist.github.com/f-steff
// @version 1.1
// @description Fix shift+option+number keys in Google Sheets on Mac while using a Scandinavian keyboard layout, by interception of shift+option+number keys, and replace them with the correct char pasted in. Flaws: Does not enter edit mode when inserting into inactivated sheet cells.
// @author Flemming Steffensen
// @match https://docs.google.com/spreadsheets/*
// @grant none
// @homepageURL https://gist.github.com/f-steff/ace84434e1ee4e1107bcf0ba8d72ed2b
// @updateURL https://gist.githubusercontent.com/f-steff/ace84434e1ee4e1107bcf0ba8d72ed2b/raw/GoogleSheetsEnableScandinavianKeyboardOnMac.user.js
@f-steff
f-steff / List-Prioritized-DNS-Servers.ps1
Last active July 17, 2024 14:08
Search windows for DNS servers
$connectedInterfaces = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' }
$connectedInterfaces | ForEach-Object {
$interfaceAlias = $_.Name
$dnsServers = Get-DnsClientServerAddress -InterfaceIndex $_.InterfaceIndex -AddressFamily IPv4 | Select-Object -ExpandProperty ServerAddresses
$interfaceMetric = (Get-NetIPInterface -InterfaceIndex $_.InterfaceIndex).InterfaceMetric | Select-Object -First 1
for ($i = 0; $i -lt $dnsServers.Count; $i++) {
[PSCustomObject]@{
InterfaceAlias = $interfaceAlias
InterfaceMetric = [string]$interfaceMetric
@f-steff
f-steff / README.md
Last active August 6, 2023 19:13
var_dump for Python Jinja2 html template engine.

This code is a macro written in Jinja2, a powerful template engine for Python. This macro, named var_dump, works similarly to PHP's var_dump() function. It helps to print or display structured information about variables, especially useful for debugging.

The var_dump macro takes four parameters:

  • var: The variable you want to display.

  • var_name: The name of the variable (this is optional, and its default value is an empty string).

  • space: The indentation level (this is optional, and its default value is 0).

@f-steff
f-steff / install_packages.py
Created July 21, 2023 09:51
Install Python package at runtime
import pkg_resources
import subprocess
import sys
import importlib
import pprint
def install(package):
print(f'\n=======> Checking status of {package}:', flush=True)
try:
dist = pkg_resources.get_distribution(package)
@f-steff
f-steff / GoogleSheetsDisableF1.js
Created February 6, 2023 22:58
Userscript for Tampermonkey to intercept F1 on Google Sheets, so that the annoying Help popup can be suppressed.
// ==UserScript==
// @name F1 key interception on Google Sheets to suppress the Help
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Interception of F1 keypress on Google Sheets and replaces default behavior with nothing.
// @author Flemming Steffensen
// @match https://docs.google.com/spreadsheets/*
// @grant none
// ==/UserScript==