Skip to content

Instantly share code, notes, and snippets.

@ertaquo
ertaquo / psycopg_enum.py
Created April 12, 2022 12:21
Enum and enum arrays support for psycopg3.
import itertools
from enum import Enum
from typing import TypeVar, Optional, Generic, List, Union
import psycopg.adapt
from psycopg.adapt import Buffer
from psycopg.types import TypeInfo
E = TypeVar("E", bound=Enum)
@ertaquo
ertaquo / psd.ksy
Last active February 24, 2023 12:39
Photoshop format definition (incomplete) for Kaitai Struct
meta:
id: psd
file-extension: psd
endian: be
seq:
- id: file_header
type: file_header
- id: color_mode_data
type: color_mode_data
- id: image_resources
@ertaquo
ertaquo / pan.js
Created September 26, 2016 08:59
Utils to validate and format credit card numbers
var validatePAN = function(pan){
pan = pan.replace(/[^\d]+/g, '');
if (pan.length < 12)
return false;
var even = false;
var check = 0;
for (var i = pan.length - 1; i >= 0; i--) {
var n = pan[i]|0;
if (even) {