Skip to content

Instantly share code, notes, and snippets.

View ulidtko's full-sized avatar
💬
Organically produced code, hand-written no AI, minimal carbon footprint.

Maxim Ivanov ulidtko

💬
Organically produced code, hand-written no AI, minimal carbon footprint.
View GitHub Profile
@mara004
mara004 / ghostscript_ffi.py
Last active April 14, 2025 01:06
PDF rendering with Ghostscript, revisited (ABI bindings, in-memory approach)
# Four lines intentionally left blank
# SPDX-FileCopyrightText: 2025 geisserml <[email protected]>
# SPDX-License-Identifier: MPL-2.0 OR GPL-3.0-or-later
# Note that Ghostscript is AGPL-licensed, so this code is altogether affected by copyleft
# Written with Ghostscript 9.56.1 on Fedora.
import dataclasses
import datetime
import re
import socket
import socketserver
import time
class config:
SOCKET_TIMEOUT = 10
@kohenkatz
kohenkatz / generate_ulid_text.sql
Created April 28, 2020 06:29
Postgres stuff for working with ULID
-- From https://github.com/geckoboard/pgulid/blob/d6187a00f66dca196cf5242588f87c3a7969df75/pgulid.sql
--
-- pgulid is based on OK Log's Go implementation of the ULID spec
--
-- https://github.com/oklog/ulid
-- https://github.com/ulid/spec
--
-- Copyright 2016 The Oklog Authors
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
@chrisdone
chrisdone / Intro.md
Last active May 20, 2024 12:44
Statically checked overloaded strings

Statically checked overloaded strings

This gist demonstrates a trick I came up with which is defining IsString for Q (TExp a), where a is lift-able. This allows you to write $$("...") and have the string parsed at compile-time.

On GHC 9, you are able to write $$"..." instead.

This offers a light-weight way to enforce compile-time constraints. It's basically OverloadedStrings with static checks. The inferred return type

@garbados
garbados / interview_with_a_human.md
Last active May 21, 2022 11:45
A short story about humans who might be robots with an accompanying shell script for reading the story aloud in robot voices.

"Interview with a Human" (2015) by Diana Thayer

Who are you?

The last human, as far as the market is concerned, though I wouldn't expect you to recognize it. I haven't worn flesh since we mined the sun.

Why not?

Flesh has a price, and I have no means to pay. I leased my consciousness to a corporation without a name. I sold the skin and organs my parents gave me to a recycling firm to pay the deposit.

@jennyknuth
jennyknuth / README.md
Last active March 5, 2025 18:51
Transform an SVG into a data URI—best practice

How to transform an SVG into a data URI

by Jenny Knuth, based on the work of Chris Coyier and Taylor Hunt

A data URI is a nice way to include a web resource without needing to make an HTTP request. Chris Coyier explains the technique nicely in Probably Don't Base64 SVG.

While a PNG might use Base64 encoding, for SVG, there is a better way.

Taylor Hunt's experiments led to this solution for optimizing SVGs in data URIs:

"So the best way of encoding SVG in a data URI is data:image/svg+xml,[actual data]. We don’t need the ;charset=utf-8 parameter (or the invalid ;utf8 parameter…), because URLs are always ASCII."

@pessom
pessom / gist:babaad22107a96cae9271cbc0bca983f
Created December 3, 2017 17:52 — forked from declaresub/gist:2cf0e6f4a08129e2a4e4
Python logging.config.dictConfig example
#! /usr/bin/python
from logging import getLogger
from logging.config import dictConfig
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters':
@technion
technion / Password References.md
Last active March 31, 2025 13:21
A set of references on modern password policies

References on modern password policies

Below links provide source, reference link and relevant quote

Standards

NIST

https://github.com/usnistgov/800-63-3/blob/nist-pages/sp800-63b/sec5_authenticators.md

Verifiers SHOULD NOT impose other composition rules (e.g., requiring mixtures of different character types or prohibiting consecutively repeated characters) for memorized secrets. Verifiers SHOULD NOT require memorized secrets to be changed arbitrarily (e.g., periodically).However, verifiers SHALL force a change if there is evidence of compromise of the authenticator.

Major organisations

@shatil
shatil / punnel.py
Created July 27, 2016 17:37
Python OpenSSL libraries' private key signing vs. OpenSSL's rsautl
#!/usr/bin/env python
from __future__ import print_function
import base64
import sys
PEM = ("""-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAgK1Q6Ydi8UUheJLvnTYJE65NOZtAtjDdDSxS+6b4x9EakjIylljSzs5uLEJn
@chpatrick
chpatrick / codec.hs
Last active October 25, 2024 11:37
Composable Applicative bidirectional serialization
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
-- actual imports :)
import Control.Category
import Prelude hiding (id, (.))
-- example imports
import Control.Monad.Reader
import Control.Monad.Writer