Skip to content

Instantly share code, notes, and snippets.

View aleph-naught2tog's full-sized avatar

Max Cerrina aleph-naught2tog

View GitHub Profile
@aleph-naught2tog
aleph-naught2tog / extract_css_variables.js
Last active February 19, 2025 15:37
Set color variables in CSS from Tailwind
// source: https://gist.github.com/Merott/d2a19b32db07565e94f10d13d11a8574
// this exposes all our colors as CSS variables
// this goes in as the last step in your plugins
function ({ addBase, theme }) {
function extractColorVars(colorObj, colorGroup = '') {
return Object.keys(colorObj).reduce((vars, colorKey) => {
const value = colorObj[colorKey];
const newVars =
typeof value === 'string'
@aleph-naught2tog
aleph-naught2tog / deepPrettyDebug.ts
Created September 23, 2024 13:06
A module for a debug call that will log out what you want, with a message, to a customatizable depth. Wrapper around util.inspect.
import util from 'util';
// NOTE: THIS IS NODE ONLY, BECAUSE OF THE RELIANCE ON NODE THE 'UTIL' MODULE.
/**
* Creates a deep, pretty-formatted, colorful, human-readable string of any
* object suitable for logging and debugging.
*`InspectOptions` is a pretty rich interface, but some reasonable defaults have
* been set, such as sorting keys alphabetically for ease of reading, color
export const cartesianProduct = (...colls: unknown[][]) =>
colls.reduce<unknown[][]>(
(products, coll) =>
products.flatMap((product) => coll.map((value) => [...product, value])),
[[]]
);
@aleph-naught2tog
aleph-naught2tog / README.md
Last active December 15, 2021 01:51
Useful styles for Twitter (alt text, hiding individual images)

useful twitter styles

Intro

These are meant to be injected via Stylus, an extension that allows customization and styling of various websites. (It's likely these styles would work in other tools allowing for customization or adding CSS, but I haven't checked any other tools personally. This uses pure vanilla CSS.)

This tool is currently designed to:

  1. highlight images with no alt-text in red
  2. show you the alt-text for images that have it when you hover over the image
  3. [requires extra configuration] hides images from your timeline (note: this won't hide them if you actually click the link)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
>
<title>Document</title>
@aleph-naught2tog
aleph-naught2tog / filter_splice_sort.js
Last active February 6, 2020 02:28
A buggy impl of Array.prototype.filterSpliceSort
Array.prototype.filterSpliceSort = function(callbackFn) {
const returnArray = [];
for (let index = 0; index < this.length; index += 1) {
const value = this[index];
const result = callbackFn(value, index, this);
// -- Return true to keep the element
if (true === result) {
// nothing to see here, move along
continue;
@aleph-naught2tog
aleph-naught2tog / extensions.txt
Last active January 25, 2020 17:21
Current VSC Setup
betterthantomorrow.calva
bierner.github-markdown-preview
bierner.markdown-checkbox
bierner.markdown-emoji
bierner.markdown-preview-github-styles
bierner.markdown-yaml-preamble
borkdude.clj-kondo
bradgashler.htmltagwrap
BriteSnow.vscode-toggle-quotes
buenon.scratchpads
@aleph-naught2tog
aleph-naught2tog / get-type-package-names.rb
Last active January 18, 2020 01:06
Generate a list of the probably @types packages for missing type files
`tsc | grep 'TS7016'`.split("\n").map(&:strip).map { |str| /('|"").+?(?=\1)/.match(str) }.map { |reg| reg[0].gsub(/'|"/, '') }.uniq.map { |str| "yarn add @types/#{str};" }.join("\n")
@aleph-naught2tog
aleph-naught2tog / rename-oneliner.rb
Created January 17, 2020 19:06
Rename JS(X) files containing types to their TS(X)
`tsc | grep -e 'TS8010'`.split("\n").map(&:strip).map { |err| err.split('(').first }.uniq.map { |source| File.rename(source, source.gsub(/\.j(?=sx?$)/, '.t')) }
@aleph-naught2tog
aleph-naught2tog / delete_non_video_stuff.js
Last active December 20, 2019 01:04
Delete non video stuff from CNN page
const selectorsToRemove = [
'._7eda40eb._34e5cb16._4564d500',
'footer',
'.ls-event-tray._8926d01d',
'._56b5b25c',
'._4b262fa5',
'._3be0fd6a',
'.Box-sc-1fet97o-0.outbrain__Container-oos1px-0.cnBIwK',
'.courageous_pushdown_element',
'[class^="template-basestyles__AdSlot"]' // big top ad video in FF