Skip to content

Instantly share code, notes, and snippets.

@dsc
dsc / chunks.py
Last active August 11, 2020 15:53
Random Python tools (py2 bc lazy)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Chunking utilities -- Functions to group an iterable into pieces or "chunks".
"""
### String Chunking Utils
def chunks(it, sep, fileAsBytes=True, asFile=None):
"Divides a stream into iterable groups based on either a size or a delimiter."
@dsc
dsc / stack.py
Created August 11, 2020 15:57
A debugging tool for the lazy: pay a ridiculous performance penalty so you don't have to actually have to pay attention to what's calling what.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" A debugging tool for the lazy: pay a ridiculous performance penalty so
you don't have to actually have to pay attention to what's calling what.
"""
# import logging
# log = logging.getLogger('lessly')
import inspect, weakref
@dsc
dsc / teenychat.user.js
Created March 20, 2021 16:56
Greasemonkey Script to regularly truncate the chat (and improve site perf)
// ==UserScript==
// @name Teenychat TinyChat Chat Teenifier
// @description Truncates chat regularly to eliminate slowdown.
// @author David Schoonover <[email protected]>
// @namespace http://less.ly/tinychat/teenychat
// @version 0.1
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js
// @require https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.js
// @run-at document-end
// @grant none
[alias]
### REMEMBER ###
# When using a function-wrapper, like !"f () { echo foo; }; f" ...
#
# 1) You *MUST* use DOUBLE QUOTES around the value.
#
# 2) You *MUST* to double-escape any regex-escape (eg. \.\1\w) that is NOT a normal escape.
# So '\t\n' is ok, but '\1' needs to become '\\1'. (I think lines are fed to sh, which