Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

View vsajip's full-sized avatar

Vinay Sajip vsajip

I'm a developer experienced in desktop & Web development.I'm a Python committer - I implemented stdlib logging, venv and the Windows Python launcher.
View GitHub Profile
@vsajip
vsajip /datetime.lua
CreatedOctober 21, 2025 03:55— forked fromzwh8800/datetime.lua
lua ISO 8601 datetime parser -https://repl.it/IQuI/5
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
vsajip /readline_support.py
CreatedJune 13, 2025 23:09
Build a version of the SQLite3 Multi Cipher shell with readline support.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2025 Red Dove Consultants Limited. License: 3-Clause BSD.
#
importargparse
importlogging
importos
importsubprocess
importsys
@vsajip
vsajip /build-lazarus.bash
CreatedJune 13, 2025 06:02
Script to build Lazarus from source on Linux
#!/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)"
# ======================================================
@vsajip
vsajip /error.txt
CreatedMarch 19, 2025 20:31
Layout problem in Flutter
══╡ 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
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 github

Let's saycontributor has submitted a pull request to your (author) project (repo). They have made changes on theirbranchfeature and have proposed to merge this intoorigin/master, where

origin -> https://github.com/author/repo.git

Now say you would like to make commits to their PR and push those changes. First, add their fork as a remote called

@vsajip
vsajip /enh_rotating_handler.py
CreatedAugust 11, 2023 16:21
A rotating handler based on time and size
# 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
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).
<divid="my-unique-id"hx-history-preserve>
<p>Markup here wil be returned to it's original state on history restore.</p>
</div>
@vsajip
vsajip /htmx-metadata.js
CreatedJune 25, 2023 05:02— forked fromcroxton/htmx-metadata.js
Htmx swapping metadata
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'){
from __future__importannotations
importasyncio
importdatetime
importsys
importtime
fromtextual.appimportApp,ComposeResult
fromtextual.containersimportContainer,Horizontal,Vertical
fromtextual.widgetsimportDataTable,Footer,Label
@vsajip
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
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

[8]ページ先頭

©2009-2025 Movatter.jp