Instantly share code, notes, and snippets.
I'm a developer experienced in desktop & Web development.I'm a Python committer - I implemented stdlib logging, venv and the Windows Python launcher.
- United Kingdom
- https://www.red-dove.com/
- https://ko-fi.com/vsajip
vsajip /datetime.lua
CreatedOctober 21, 2025 03:55 — forked fromzwh8800/datetime.lua
lua ISO 8601 datetime parser -https://repl.it/IQuI/5 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| functionparse_json_date(json_date) | |
| localpattern="(%d+)%-(%d+)%-(%d+)%a(%d+)%:(%d+)%:([%d%.]+)([Z%+%-])(%d?%d?)%:?(%d?%d?)" | |
| localyear,month,day,hour,minute, | |
| seconds,offsetsign,offsethour,offsetmin=json_date:match(pattern) | |
| localtimestamp=os.time{year=year,month=month, | |
| day=day,hour=hour,min=minute,sec=seconds} | |
| localoffset=0 | |
| ifoffsetsign~='Z'then | |
| offset=tonumber(offsethour)*60+tonumber(offsetmin) | |
| ifxoffset=="-"thenoffset=offset*-1end |
vsajip /readline_support.py
CreatedJune 13, 2025 23:09
Build a version of the SQLite3 Multi Cipher shell with readline support. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| # | |
| # Copyright (C) 2025 Red Dove Consultants Limited. License: 3-Clause BSD. | |
| # | |
| importargparse | |
| importlogging | |
| importos | |
| importsubprocess | |
| importsys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # ====================================================== | |
| # by rvk (v.2.1, 2024-12-06) | |
| # ====================================================== | |
| echo"" | |
| echo"==============================================================" | |
| echo"Running on:$(sed's/\x0/ /' /sys/firmware/devicetree/base/model2>/dev/null|| cat /sys/devices/virtual/dmi/id/product_name2>/dev/null||echo Unknown)" | |
| # ====================================================== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞══════════════════════ | |
| The following assertion was thrown during performLayout(): | |
| RenderCustomMultiChildLayoutBox object was given an infinite size | |
| during layout. | |
| This probably means that it is a render object that tries to be | |
| as big as possible, but it was put inside another render object | |
| that allows its children to pick their own size. | |
| The nearest ancestor providing an unbounded height constraint is: RenderFlex#0fb98 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE: | |
| parentData: offset=Offset(0.0, 0.0) (can use size) | |
| constraints: BoxConstraints(0.0<=w<=749.0, 0.0<=h<=614.0) |
vsajip /push-to-someone-elses-pr.md
CreatedMarch 13, 2024 14:48 — forked fromwtbarnes/push-to-someone-elses-pr.md
Brief instructions for how to modify and push to someone else's PR on githubvsajip /enh_rotating_handler.py
CreatedAugust 11, 2023 16:21
A rotating handler based on time and size This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| # From https://stackoverflow.com/questions/6167587 | |
| classEnhancedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler): | |
| def__init__(self,filename,when='h',interval=1,backupCount=0,encoding=None,delay=0,utc=0,maxBytes=0): | |
| """ This is just a combination of TimedRotatingFileHandler and RotatingFileHandler (adds maxBytes to TimedRotatingFileHandler) """ | |
| logging.handlers.TimedRotatingFileHandler.__init__(self,filename,when,interval,backupCount,encoding,delay,utc) | |
| self.maxBytes=maxBytes | |
| defshouldRollover(self,record): | |
| """ | |
| Determineifrollovershouldoccur. |
vsajip /example.html
CreatedJune 30, 2023 10:52 — forked fromcroxton/example.html
Adds a `hx-history-preserve` attribute to preserve the initial dom state of an element's children for history (before it has been manipulated by JS). This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| <divid="my-unique-id"hx-history-preserve> | |
| <p>Markup here wil be returned to it's original state on history restore.</p> | |
| </div> |
vsajip /htmx-metadata.js
CreatedJune 25, 2023 05:02 — forked fromcroxton/htmx-metadata.js
Htmx swapping metadata This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| htmx.on('htmx:beforeSwap',(htmxEvent)=>{ | |
| letincomingDOM=newDOMParser().parseFromString(htmxEvent.detail.xhr.response,"text/html"); | |
| // Transpose <meta> data, page-specific <link> tags and JSON-LD structured data | |
| // Note that hx-boost automatically swaps the <title> tag | |
| letselector="head > meta:not([data-revision]), head *[rel=\"canonical\"], head *[rel=\"alternate\"], body script[type=\"application/ld+json\"]"; | |
| document.querySelectorAll(selector).forEach((e)=>{ | |
| e.parentNode.removeChild(e); | |
| }); | |
| incomingDOM.querySelectorAll(selector).forEach((e)=>{ | |
| if(e.tagName==='SCRIPT'){ |
vsajip /slow_op.py
CreatedDecember 18, 2022 12:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| from __future__importannotations | |
| importasyncio | |
| importdatetime | |
| importsys | |
| importtime | |
| fromtextual.appimportApp,ComposeResult | |
| fromtextual.containersimportContainer,Horizontal,Vertical | |
| fromtextual.widgetsimportDataTable,Footer,Label |
vsajip /debounce.py
CreatedDecember 16, 2022 21:26 — forked fromwalkermatt/debounce.py
A debounce function decorator in Python similar to the one in underscore.js, tested with 2.7 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| fromthreadingimportTimer | |
| defdebounce(wait): | |
| """ Decorator that will postpone a functions | |
| execution until after wait seconds | |
| have elapsed since the last time it was invoked. """ | |
| defdecorator(fn): | |
| defdebounced(*args,**kwargs): | |
| defcall_it(): |
NewerOlder