Skip to content

Instantly share code, notes, and snippets.

[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
@dsc
dsc / gist:3855240
Created October 8, 2012 21:52
Python argparse Cheatsheet
Arg Name or Optional Flags:
positional : str = "foo"
options : str = "-f", "--foo"
Standard:
action : str = [store], append, store_true, store_false, store_const, append_const, version
default : * = [None]
type : callable = [str], argparse.FileType(mode='wb', bufsize=0)
Exotic:
@dsc
dsc / jconsole-proxy.sh
Created August 7, 2012 01:15
jconsole via ssh proxy
#!/bin/bash
#/ jc -- jconsole via ssh proxy
#/
#/ Usage: jc [options] HOST JMX_PORT [PROXY_PORT=JMX_PORT] [JMX_HOST=HOST]
#/
#/ Starts a SOCKS proxy via ssh to connect to a
#/ JVM running on a remote and protected machine.
#/
#/ Arguments:
@dsc
dsc / shadyurl.sh
Created March 11, 2010 15:01
shadyurl.sh -- Don't just shorten your URLs via the command line, also make them suspicious and frightening.
#!/bin/bash
# @author dsc@less.ly
if test "$1"; then
LONG_URL="$1"
else
read LONG_URL
fi
SHADY="http://www.shadyurl.com/create.php?myUrl="
@dsc
dsc / README.md
Created June 22, 2012 05:16
Performance of JS Hash Implementations
@dsc
dsc / git-fat-pack.sh
Created June 13, 2012 17:53
Permanently remove crap from a git repo.
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
@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 <dsc@less.ly>
// @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
@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 / 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 / shopkeeper.md
Last active January 24, 2020 22:04
StS: The Shopkeeper Boss Fight

The Shopkeeper (Boss Fight)

  • The first time you defeat the Shopkeeper, you gain the relic Comfy Rug (Reduce
  • Big Attack animation is his hand coming down from the top of the screen to smoosh you.
  • All his actions get his sfx and banter.
  • Innate Relic Buffs:
    • Starts combat with the buffs from every relic that was for sale in the shop you just entered. (Relics that do things with cards are mapped onto comparable effects for an enemy.)
    • Starts with the buffs from every shop relic you haven't already seen in a shop (or purchased).
      • Normal Effects: Clockwork Souvenir, Hand Drill, Sling of Courage, Lee's Waffle
      • Chem X -- Increase the Shopkeeper's gain of Toolbox stacks by +2 whenever any would be gained (both from the starting Toolbox and the Transmute action).
  • Toolbox -- Starts with 3 stacks of Toolbox, which triggers a random effect each turn when it ticks down: