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 / 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
@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:
@dsc
dsc / fb-spamvertiser-remover.js
Created December 28, 2018 04:19
Facebook Spam-vertiser Remover
/* Facebook Spam-vertiser Remover
It looks like fb advertisers can now upload a list of emails to spam with FB ads. I
wrote this script -- which blocks them from the ad preferences page -- mostly out of
spite and annoyance. It will not reduce the number of ads you see, or really make them
better, it will simply penalize the companies who uploaded a big-ass list of emails
they bought. For example, I see about 500 car dealerships in my list. I neither have
a car nor do I want one.
These steps require you to be comfortable with the browser's console. The steps below are for Chrome.
def uniqued(it, keyfunc=id):
keys = set()
for o in it:
k = keyfunc(o)
if k in keys: continue
keys.add(k)
yield o
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 2 columns, instead of 3 in line 1.
cp1041.eqiad.wmnet %20Sync/SyncClient1.1%20Profile/MIDP-2.0%20Configuration/CLDC-1.1 1
cp1041.eqiad.wmnet zero=250-99 192929
cp1041.eqiad.wmnet zero=297-01 643
cp1041.eqiad.wmnet zero=410-01 6822
cp1041.eqiad.wmnet zero=420-01 3262
cp1041.eqiad.wmnet zero=470-01 4
cp1041.eqiad.wmnet zero=502-13 20
cp1041.eqiad.wmnet zero=502-16 1687
cp1041.eqiad.wmnet zero=510-11 23
cp1041.eqiad.wmnet zero=520-18 1140
@dsc
dsc / xcs.pig
Last active December 15, 2015 07:29
SET default_parallel 2;
%default month 02
IMPORT 'hdfs:///libs/kraken/pig/include/load_webrequest.pig';
log_fields = LOAD_WEBREQUEST('hdfs:///wmf/raw/webrequest/webrequest-wikipedia-mobile/2013-02-*,hdfs:///wmf/raw/webrequest/webrequest-wikipedia-mobile/2013-03-*');
-- log_fields = LOAD_WEBREQUEST('hdfs:///wmf/raw/webrequest/webrequest-wikipedia-mobile/2013-$month-*');
xcs_cachehost = FOREACH log_fields GENERATE timestamp, hostname, x_cs PARALLEL 2;
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
dfs.ha.fencing.ssh.connect-timeout 30000 core-default.xml
file.blocksize 67108864 core-default.xml
file.bytes-per-checksum 512 core-default.xml
file.client-write-packet-size 65536 core-default.xml
file.replication 1 core-default.xml
file.stream-buffer-size 4096 core-default.xml
fs.AbstractFileSystem.