Skip to content

Instantly share code, notes, and snippets.

eirnym /
Created February 3, 2024 11:12 — forked from HaleTom/
Print a 256-colour test pattern in the terminal
# Tom Hale, 2016. MIT Licence.
# Print out 256 colours, with each number printed in its corresponding colour
# See
set -eu # Fail on errors or undeclared variables
eirnym / GitHub Flavored Asciidoc (GFA).adoc
Created March 14, 2021 16:49 — forked from dcode/GitHub Flavored Asciidoc (GFA).adoc
Demo of some useful tips for using Asciidoc on GitHub

GitHub Flavored Asciidoc (GFA)

eirnym / AsciidocCheatsheet.adoc
Created March 14, 2021 11:51 — forked from powerman/AsciidocCheatsheet.adoc
Asciidoc cheatsheet for GitHub

Asciidoc cheatsheet for GitHub

eirnym / RandomDateGenerator.m
Created April 26, 2016 13:38
Random Date generator for Objective C.
Generate a random date sometime between now and n days before day.
Also, generate a random time to go with the day while we are at it.
@param days date range between today and minimum date to generate
@return random date
eirnym /
Last active December 21, 2023 17:22
SQLAlchemy 'if exists' patch
import re
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.schema import CreateTable, DropTable, \
CreateSequence, DropSequence, CreateIndex, DropIndex
from sqlalchemy.dialects.postgresql import DropEnumType
patches = (
(CreateTable, 'visit_create_table', "^\s*CREATE TABLE", "CREATE TABLE IF NOT EXISTS"),
(CreateIndex, 'visit_create_index', "^\s*CREATE INDEX", "CREATE INDEX IF NOT EXISTS"),
eirnym /
Created April 11, 2015 17:38
SQLAlchemy dump SQL and metadata create_all and drop_all usage example. This is highly usable with aiopg and similar library where synchronised version of engine is not applicable.
from sqlalchemy_dump import dump_sql
def create_all_sql(metadata):
return dump_sql(metadata.create_all, bind=True)()
def drop_all_sql(metadata):
return dumpsql(metadata.drop_all, bind=True)()
eirnym /
Last active August 29, 2015 14:18 — forked from exhuma/
this representable base adds generatable __str__ and __repr__
# based on:
class RepresentableBase(object):
""" Add automatic __repr__ and __str__ to SQLAlchemy ORM models
def _repr_worker(self, attribute):
mapper = object_mapper(self)
items = [(p.key, getattr(self, p.key))
for p in (