Skip to content

Instantly share code, notes, and snippets.

View jimkring's full-sized avatar
💭
CI/CD

Jim Kring jimkring

💭
CI/CD
View GitHub Profile
@jimkring
jimkring / REAMDE.md
Created May 23, 2026 23:36
script for installing/updating lmstudio on ubuntu

update_lmstudio.sh

Updates LM Studio to the latest Linux release and keeps its launcher icon working.

What it does

  • Checks the version before downloading. It reads the real package version from just the first 2 MiB of the .deb (an HTTP range request) and compares it to the installed dpkg version. The full ~650 MB download and sudo dpkg -i only happen when a newer version actually exists.
  • Fixes the missing app icon. LM Studio's .deb installs its icon into an invalid hicolor/0x0/ directory that the desktop ignores, so the app ships with no icon. After installing, the script copies the package's 1024×1024 icon into ~/.local/share/icons/hicolor/512x512/apps/ — per-user, so it survives future upgrades (the packaging bug is not fixed by upgrading).

Usage

@jimkring
jimkring / nuikta_fastapi_workaround.py
Last active September 4, 2024 18:14
Working around an issue with Nuitka-commercial's handling of embedded file and it's incompatibility with anyio/asyncio async file IO, which is used by Starlette's FileResponse class.
import os
import stat
from fastapi.responses import FileResponse
from starlette.types import Receive, Scope, Send
class FileResponseSynchronous(FileResponse):
"""
This works around an issue building with `Nuitka-commercial` and embedding files
@jimkring
jimkring / json_schema_to_pydantic_model.py
Last active April 19, 2026 17:34
Create a Pydantic model from JSON Schema dynamically at runtime
import tempfile
import json
from pathlib import Path
from typing import Any, Dict, Type
import datamodel_code_generator
from pydantic import BaseModel
def json_schema_to_pydantic_model(json_schema: Dict[str, Any]) -> Type[BaseModel]:
@jimkring
jimkring / modify_nipkg_to_show_in_add_or_remove_programs.ps1
Last active June 1, 2024 06:39
PowerShell script to modify a File nipkg to show in Add or Remove Programs
# Copyright (c) 2024 JKI. All rights reserved.
# Licensed under the MIT License.
### About ###
# This a powershell script to modify a .nipkg file such that the packaged LabVIEW executable application shows in the Windows Add or Remove Programs list
# See NIPM docs on this feature here:
# https://www.ni.com/docs/en-US/bundle/package-manager/page/instructions-xml-file-packages.html#GUID-4607C6C4-C7F0-4544-93CD-F098A4271D43__GUID-18C9D8AE-B61B-41B2-8D54-4B604F34D18D
### How this Script Works ###
@jimkring
jimkring / fastui_breadcrumb_component.py
Last active May 20, 2024 03:38
build a breadcrumb component for fastui
from fastui import components as c
from fastui.events import GoToEvent
def build_breadcrumb(links: list[tuple[str, str]]) -> c.Div:
"""
Returns a fastui `Div` component that behaves as a bootstrap `breadcrumb`.
`links` input is a list of tuples like [(display_text, url_string), ...].
Each link becomes a sub `Div` marked with the bootstrap `breadcrumb-item` class.
@jimkring
jimkring / image.py
Last active May 2, 2024 00:16
fastui raw html component example
import io
import base64
from typing import Union
from PIL import Image # requires `pillow` package
from fastui.components import Iframe
def iframe_from_html_raw(
raw_html: str,
@jimkring
jimkring / configparser_labview.py
Created December 16, 2023 22:23
A python ConfigParser that works better when reading INI files created with LabVIEW.
import configparser
class ConfigParserLabVIEW(configparser.ConfigParser):
"""
A ConfigParser that handles LabVIEW-generated config files with fewer errors than the default configparser:
- disables the interpolation feature
- disables the strict validation feature
- removes double-quotes from around values
"""
JKI CONTRIBUTION LICENSE AGREEMENT
Thank you for your contribution to JKI software project(s). In order to clarify the intellectual property rights in the project(s), and to grant licenses to the project(s) to others, James Kring, Inc. (“JKI”) requires that you accept this Contributor License Agreement (“Agreement”). This license is for your protection as a Contributor as well as the protection of JKI, its users, and its licensees; you may still license your own Contributions under other terms.
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to JKI. Except for the license granted herein to JKI and recipients of software distributed by JKI, You reserve all right, title, and interest in and to Your Contributions and retain the right to license and distribute them separately under the terms of your choice.
1. Definitions. “You” (or “Your”) shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreemen