Skip to content

Instantly share code, notes, and snippets.

View joakim's full-sized avatar
🌿

joakim

🌿
View GitHub Profile
@joakim
joakim / evil-spreadsheet.js
Created December 12, 2023 12:05
Evil Spreadsheet
// Inspired by this Python code: https://ralsina.me/weblog/posts/BB585.html
// Really really limited, but it works. "Look ma, no DAG!"
function evil(formula, sheet) {
with (sheet.functions) {
with (sheet.cells) {
return eval(formula);
}
}
}
@joakim
joakim / collection.js
Last active December 28, 2021 19:48
Collection – a tiny, immutable data structure for JavaScript/TypeScript
Collection = (spec) => {
if (typeof spec !== 'object') throw new TypeError('Collection specification must be an object')
return Object.freeze(Object.create(Collection.prototype, Object.getOwnPropertyDescriptors(spec)))
}
Collection.prototype = Object.create(null, {
[Symbol.isConcatSpreadable]: { value: true },
[Symbol.iterator]: { value: function* () { for (let key in this) { yield this[key] } } },
[Symbol.toPrimitive]: { value: (hint) => hint === 'number' ? NaN : '[object Collection]' },
[Symbol.toStringTag]: { value: 'Collection' },
})
@joakim
joakim / evil-all.csv
Created December 9, 2021 19:47
Containerise the evil companies Alphabet (Google), Amazon and Meta (Facebook)
@^https?://(.+\.)?google\.com/ Evil Alphabet
@^https?://(.+\.)?google\.org/ Evil Alphabet
@^https?://(.+\.)?googleapis\.com/ Evil Alphabet
@^https?://(.+\.)?g\.co/ Evil Alphabet
@^https?://(.+\.)?ggpht\.com/ Evil Alphabet
@^https?://(.+\.)?google/ Evil Alphabet
@^https?://(.+\.)?goog/ Evil Alphabet
@^https?://(.+\.)?gle/ Evil Alphabet
@^https?://(.+\.)?blogger\.com/ Evil Alphabet
@^https?://(.+\.)?googleblog\.com/ Evil Alphabet
@joakim
joakim / evil-meta.csv
Last active December 9, 2021 19:41
Containerise Meta (Facebook), that evil company
@^https?://(.+\.)?facebook\.com/ Evil Meta
@^https?://(.+\.)?facebook\.net/ Evil Meta
@^https?://(.+\.)?fb\.com/ Evil Meta
@^https?://(.+\.)?fbcdn\.net/ Evil Meta
@^https?://(.+\.)?fbcdn\.com/ Evil Meta
@^https?://(.+\.)?fbsbx\.com/ Evil Meta
@^https?://(.+\.)?tfbnw\.net/ Evil Meta
@^https?://(.+\.)?facebook-web-clients\.appspot\.com/ Evil Meta
@^https?://(.+\.)?fbcdn-profile-a\.akamaihd\.net/ Evil Meta
@^https?://(.+\.)?fbsbx\.com\.online-metrix\.net/ Evil Meta
@joakim
joakim / evil-amazon.csv
Last active December 9, 2021 19:40
Containerise Amazon, that evil company
@^https?://(.+\.)?amazon\.cn/ Evil Amazon
@^https?://(.+\.)?amazon\.in/ Evil Amazon
@^https?://(.+\.)?amazon\.co\.jp/ Evil Amazon
@^https?://(.+\.)?amazon\.com\.sg/ Evil Amazon
@^https?://(.+\.)?amazon\.com\.tr/ Evil Amazon
@^https?://(.+\.)?amazon\.fr/ Evil Amazon
@^https?://(.+\.)?amazon\.de/ Evil Amazon
@^https?://(.+\.)?amazon\.it/ Evil Amazon
@^https?://(.+\.)?amazon\.nl/ Evil Amazon
@^https?://(.+\.)?amazon\.es/ Evil Amazon
@joakim
joakim / evil-alphabet.csv
Last active December 29, 2021 23:57
Containerise Alphabet (Google), that evil company
@^https?://(.+\.)?google\.com/ Evil Alphabet
@^https?://(.+\.)?google\.org/ Evil Alphabet
@^https?://(.+\.)?googleapis\.com/ Evil Alphabet
@^https?://(.+\.)?g\.co/ Evil Alphabet
@^https?://(.+\.)?ggpht\.com/ Evil Alphabet
@^https?://(.+\.)?google/ Evil Alphabet
@^https?://(.+\.)?goog/ Evil Alphabet
@^https?://(.+\.)?gle/ Evil Alphabet
@^https?://(.+\.)?blogger\.com/ Evil Alphabet
@^https?://(.+\.)?googleblog\.com/ Evil Alphabet
@joakim
joakim / lagrange-inline-formatting.ks.lua
Last active November 26, 2022 19:40
kesh version of Lagrange MIME hook for formatting of inline emphasis
import [ read-lines ]: 'https://deno.land/std/io/buffer.ts'
import [ copy ]: 'https://deno.land/std/streams/conversion.ts'
#type: (search: #RegExp, replace: #text)
-- Pass-through the header
print "20 { Deno.args.join(';') }\r"
-- Check for type=inline parameter
inline: Deno.args.find (arg) ->
@joakim
joakim / lagrange-inline-formatting.ts
Last active December 6, 2021 20:32
Lagrange MIME hook for formatting of inline Markdown style emphasis in Gemini's GemText
import { readLines } from 'https://deno.land/std/io/buffer.ts'
import { copy } from 'https://deno.land/std/streams/conversion.ts'
const print = console.log
type type = [search: RegExp, replace: string]
// Pass-through the header
print(`20 ${ Deno.args.join(';') }\r`)
// Check for type=inline parameter
@joakim
joakim / tuple.js
Last active October 7, 2021 14:06
A versatile immutable data structure for JavaScript. It's like the strict yet lenient parent that Array and Object never had. Related to aunt Lua's tables.
nothing = new Proxy(Object.freeze(Object.create(null)), Object.create(null, {
get: {
value(target, property) {
return property === Symbol.toPrimitive ? () => undefined : nothing
}
}
}))
Tuple = (...elements) => {
if (elements.length === 0) return nothing
@joakim
joakim / nothing.js
Last active January 25, 2024 22:01
The concept of nothing in JavaScript (Crockford's idea of a better undefined)
nothing = new Proxy(Object.freeze(Object.create(null)), {
get(target, property) {
if (property === Symbol.toPrimitive) return () => undefined
return nothing
},
set() {
return nothing
}
})