Skip to content

Instantly share code, notes, and snippets.

View krzysztofjeziorny's full-sized avatar

Krzysztof Jeziorny krzysztofjeziorny

View GitHub Profile
@simonw
simonw / geocode.py
Created January 26, 2025 16:49
Geocode using the API bulit into macOS CoreLocation
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "pyobjc-core",
# "pyobjc-framework-CoreLocation",
# "click"
# ]
# ///
"""Basic geocoding using CoreLocation on macOS."""
#!/usr/bin/env ruby
# Archive linkding bookmarks to Markdown files
# Can use [Gather](https://brettterpstra.com/projects/gather-cli/)
# for conversion (if installed), or use Marky
# the Markdownifier (web-based).
#
# See options below for configuration
#
# This script is designed to run once initially, and then
# be set to run in the background at intervals using cron
@rixx
rixx / form-rendering-thoughts.md
Last active October 26, 2024 18:07
Thoughts on Django’s form rendering

Django's template-based form rendering: thoughts and pains

Short (well, I tried) collection of thoughts and impressions after moving to Django-native template-based form rendering with pretalx, my ~medium-sized(?) Django project.

When Carlton threatened to read my code (shock, horror), I decided to just write up my impressions, and a gist/pastebin/etc seemed the right format, cuz this isn’t polished enough for a blog post, and also way not constructive enough.

@thesamesam
thesamesam / xz-backdoor.md
Last active April 29, 2025 14:00
xz-utils backdoor situation (CVE-2024-3094)

FAQ on the xz-utils backdoor (CVE-2024-3094)

This is a living document. Everything in this document is made in good faith of being accurate, but like I just said; we don't yet know everything about what's going on.

Update: I've disabled comments as of 2025-01-26 to avoid everyone having notifications for something a year on if someone wants to suggest a correction. Folks are free to email to suggest corrections still, of course.

Background

@danjac
danjac / form.html
Last active March 12, 2024 15:52
Django form using AlpineJS to render rating field
{#
class ReviewForm(forms.ModelForm):
class Meta:
model = Review
fields = (
"comment",
"score",
)
help_texts: ClassVar = {
@cnk
cnk / models.py
Last active October 30, 2023 09:18
Add custom attributes to a Wagtail page - but only when creating.
class CourseIndexPage(Page):
# ..... fields ......
base_form_class=CourseIndexPageForm
class CourseIndexPageForm(WagtailAdminPageForm):
def __init__(self, *args, **kwargs):
"""
Sets up the Course selector to treat selecting null for the Edition as setting it to "current".
@danjac
danjac / htmx_fragments.py
Created June 30, 2023 09:33
Django helper function to render one or more template blocks with HTMX
from django.http import HttpRequest, HttpResponse
from django.template.response import TemplateResponse
from render_block import render_block_to_string
def render_template_fragments(
request: HttpRequest,
template_name: str,
context: dict | None = None,
*,
@marcus-at-localhost
marcus-at-localhost / addhash.js
Last active March 23, 2023 13:48
[Save Bootstrap 5 Tab State in URL for Deep Linking] #bootstrap #js <https://codepen.io/localhorst/pen/dyqbboY>
//@see https://codepen.io/localhorst/pen/dyqbboY
(function () {
'use strict'
if(location.hash){
const triggerEl = document.querySelector(location.hash)
bootstrap.Tab.getOrCreateInstance(triggerEl).show() // Select tab by name
}
const selectableTabList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tab"]'))
selectableTabList.forEach((selectableTab) => {
@TobeTek
TobeTek / models.py
Last active January 29, 2024 15:41
Querying Django's JSON Field
from django.db import models
from django.utils.translation import gettext_lazy as _
class Person(models.Model):
"""
Store data about people in a school
"""
name = models.CharField(max_length=100)
@RobertAKARobin
RobertAKARobin / safari.md
Last active December 5, 2024 01:38
Safari's date-picker is the cause of 1/3 of our customer support issues

Safari's date-picker is the cause of 1/3 of our customer support issues

...and obviously we're building a workaround. But I'm absolutely flabbergasted that a standard <input type="date"> HTML field, in a standard browser, from a company that bases its reputation good design, could be so dreadful.

The context

I'm the developer for a startup that sells a genetic test to recommend medications for high blood pressure. For medical reasons we need to know our customers' birth date. Most of our customers are in their 60s or older. We've found that many of them use iPads or iPhones. And they're the ones who complain to our customer support that our site is unusable.

The problem