Skip to content

Instantly share code, notes, and snippets.

View rauschma's full-sized avatar

Axel Rauschmayer rauschma

View GitHub Profile
const primaryColumn = document.querySelector('div[data-testid="primaryColumn"]');
document.body.innerHTML = '';
document.body.append(primaryColumn);
// Per-tweet controls
for (const ele of document.querySelectorAll('div[role="group"]')) {
ele.remove();
}
// Reply widget

Work in a post-growth world

Source: “Le travail dans un monde post-croissance (Dominique Méda)” (56-minute video)

  • Currently, the economy and commercialized work dominates our society.
  • Many societies are not based on “commercialized work” and don’t have a word for it.
  • Adam Smith: work enables us to create wealth. We are interested in the latter (not in work itself).
  • During the 18th century, our values changed significantly: from valuing moderation (a traditional christian value) to valuing wealth.
    • The goal became to produce as much as possible – more than we need to fulfill out immediate needs.
  • Work becomes something meaningful: To assert ourselves in the world, we have to work.
// Batch-delete videos from YouTube’s “Watch later” playlist
// Paste the following code into a browser console while the playlist is open
// Code based on: https://gist.github.com/astamicu/eb351ce10451f1a51b71a1287d36880f?permalink_comment_id=4087416#gistcomment-4087416
//
// (Suggestions for improvement welcome. My approach for waiting for the .click() to finish, feels hacky.)
const pause = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function remove() {
for (let i=0; i < 100; i++) {
document.querySelector('#primary button[aria-label="Action menu"]').click();

I find it easiest to make sense of this as follows:

  • It’s an implicit parameter of functions (other than arrow functions).
  • It’s always provided when we invoke such functions – how depends on how we invoke them.

Demo:

import assert from 'node:assert/strict';

//========== this is an implicit parameter of getThis() ==========

#!/usr/bin/env node
// Use curl to download a URL to a file whose name is URL-decoded
// Related: https://github.com/curl/curl/issues/2573
import {execSync} from 'node:child_process';
// Documentation for node:child_process – https://exploringjs.com/nodejs-shell-scripting/ch_nodejs-child-process.html
export const WEB_PATH_SEP = '/';
export function getWebBasename(webPath) {

Instructions

This bookmarklet shows a profile or a post on another Mastodon server in your server’s web app.

Installation

  • Change the value of HOST to the domain of your Mastodon server.
  • Create a bookmark and paste the lines in show-in-mastodon-web-app.js into its address (browsers are OK with pasting multiple lines).

Usage

import assert from 'node:assert/strict';
// Extended RegExp mode (flag /x) [1] via a template tag
//
// Quote: “While the x-mode flag can be used in a RegularExpressionLiteral,
// it does not permit the use of LineTerminator in RegularExpressonLiteral.
// For multi-line regular expressions you would need to use the RegExp
// constructor.”
//
// The plan is to include this functionality in re-template-tag [2]. Then
// The actual API is documented at the end of this file
/**
* @see https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
*/
const ansiConstants = {
//----- Attributes -----
Normal: 0,
// This code has moved here: https://2ality.com/2022/10/javascript-decorators.html#example-friend-visibility