Skip to content

Instantly share code, notes, and snippets.

11 fuzz.online
9 www.1sttheworld.com
8 www.justfab.co.uk
8 www.justfab.com
6 www.simplycarbonfiber.com
6 www.shoedazzle.com
6 www.fabletics.ca
6 topcoat.store
6 sugarandcotton.com
6 savethebeesproject.com
@gpittarelli
gpittarelli / gist:5689979e69eec0f3d76d202c835f3bd0
Created June 20, 2019 23:08
Simple browser xpath helpers
function* xpathLazy(q) {
const x = document.evaluate(
q,
document,
null,
XPathResult.UNORDERED_NODE_ITERATOR_TYPE,
null
);
let n = x.iterateNext();
while (n) {
@gpittarelli
gpittarelli / run-batch-job.sh
Created March 7, 2019 18:23
GNU Parallel autoscaling workload example
#!/usr/bin/env bash
(
while ((1)); do
gcloud --format=json compute instances list --filter="name~'nlp-workers-.*'" | \
jq -rc '.[]|select(.status=="RUNNING").name' > workers.hosts.txt
sleep 30s
done
) & # (or, just run this watcher in a separate script)
describe("Level 1", () => {
before(() => console.log("before 1"));
beforeEach(() => console.log("beforeEach 1"));
before(() => console.log("before 2"));
beforeEach(() => console.log("beforeEach 2"));
after(() => console.log("after 1"));
afterEach(() => console.log("afterEach 1"));
after(() => console.log("after 2"));
afterEach(() => console.log("afterEach 2"));
@gpittarelli
gpittarelli / node_prune.sh
Last active March 3, 2022 17:04
Prunes very-likely-uneeded files from node_modules directories
#!/usr/bin/env bash
# Port of https://github.com/tj/node-prune to bash
# Also,
# - fixed "*.ts" being overzealous and killing .d.ts files
# - added some more file types from https://github.com/npm/npm/issues/5264#issuecomment-259800486
#
# See also:
# - https://github.com/timoxley/cruft
# - https://yarnpkg.com/en/docs/cli/autoclean
# - https://github.com/ModClean/modclean
@gpittarelli
gpittarelli / xkcd-1806-scrolling-in-emacs.el
Last active March 3, 2017 08:45
Scroll through time, not space! like xkcd 2806, in emacs
(defun mwheel-scroll (event)
(interactive (list last-input-event))
(let ((button (mwheel-event-button event)))
(cond ((eq button mouse-wheel-down-event)
(undo-tree-undo))
((eq button mouse-wheel-up-event)
(undo-tree-redo)))))
;; ^ global override for all scrollwheel events
;; to do it only for shift+scroll, try:
@gpittarelli
gpittarelli / gist:4700650
Created February 3, 2013 05:33
Super simple c function to print a binary string without worrying about messing up the terminal
/* Print a binary string `str` of `len` bytes safely by printing
* non-printable characters as red hex codes. */
void safe_print(unsigned char *str, size_t len) {
unsigned char *it = str;
while (len--) {
if (isprint(*it)) {
putchar(*it);
} else {
printf("\33[31m%02X\33[0m", *it);