Skip to content

Instantly share code, notes, and snippets.

@tclancy
tclancy / MockElement.ts
Created Jul 13, 2021 — forked from fredyfx/MockElement.ts
Mock DOM Document and Element in TypeScript for Unit testing in Headless environment.
View MockElement.ts
/*
This can be used in unit tests to simulate a DOM document.
I have implemented the bare minimum. Feel free to add more, or to change my implementation.
Sample Usage:
import 'jasmine';
import { MockElement } from './support/mock-element';
@tclancy
tclancy / TableVerticalSplitHack.js
Created Apr 26, 2017 — forked from vstefanoxx/TableVerticalSplitHack.js
Script to automatically split wide HTML tables that doesn't fit the width of the PDF page generated by WkHtmlToPdf (or equivalent). From an idea of Florin Stancu <niflostancu@gmail.com> and his script wkhtmltopdf.tablesplit.js, this implementation is quite different because the splitting is done vertically on a excessive wide table, while the or…
View TableVerticalSplitHack.js
/**
* WkHtmlToPdf table vertically-splitting hack
* Script to automatically split wide HTML tables that doesn't fit the width of the PDF page generated
* by WkHtmlToPdf (or equivalent)
*
* The general idea come from Florin Stancu <niflostancu@gmail.com> and his script wkhtmltopdf.tablesplit.js
* The implementation is quite different because the splitting is done vertically on a excessive
* wide table, while the original script was meant to split horizontally an excessive long table
*
* To use, you must adjust pdfPage object's contents to reflect your PDF's
@tclancy
tclancy / middleware.py
Last active Jan 8, 2016 — forked from acdha/middleware.py
Django middleware for Pympler
View middleware.py
# encoding: utf-8
# Derived from Piotr Maliński's example with a few modifications to use logging and :
# http://www.rkblog.rk.edu.pl/w/p/profiling-django-object-size-and-memory-usage-pympler/
from pympler import muppy
from pympler.muppy import summary
from pympler.asizeof import asizeof
from django.conf import settings
import logging
@tclancy
tclancy / expire_all_sessions.py
Last active May 9, 2022 — forked from playpauseandstop/gist:1818351
Django management command to expire all sessions
View expire_all_sessions.py
import datetime
from django.conf import settings
from django.contrib.auth import logout
from django.contrib.auth.models import User
from django.contrib.sessions.models import Session
from django.core.management.base import NoArgsCommand
from django.http import HttpRequest
from django.utils.importlib import import_module