Skip to content

Instantly share code, notes, and snippets.

View joakim's full-sized avatar
🌿

joakim

🌿
View GitHub Profile

On leap seconds

The problem with leap seconds is not leap seconds, but using UTC for precision purposes.

🤖 TAI ⬌ UTC 🧑

If we instead used [TAI][tai] for computers and derived [UTC][utc] for humans, there would be no need to abandon leap seconds and decouple the world's calendars from the rotation of the Earth. With TAI, leap seconds have no effect. They would only appear when displayed to humans in UTC, the problem of leap seconds reduced to a UI issue.

Unfortunately, rather than move towards adopting TAI for computers, there's been a strong push by tech companies to remove leap seconds from UTC for all.[^1] It would practically make TAI the new time scale for all humans on Earth.

@joakim
joakim / instant-to-jd.js
Last active November 2, 2025 13:10
Converts a Temporal.Instant to a Julian Date. Formatted for readability.
const hoursInDay = 24
const minutesInDay = 1440
const secondsInDay = 86400
const millisecondsInDay = 86400000
const microsecondsInDay = 86400000000
const nanosecondsInDay = 86400000000000
/**
* Converts a Temporal.Instant to a Julian Date (decimal number).
**/
@joakim
joakim / tauri_traffic_light_positioner_plugin.rs
Created October 12, 2024 21:41 — forked from charrondev/tauri_traffic_light_positioner_plugin.rs
This code describes a mechanism to adjust traffic light positioning on MacOS with Tauri 2.x
use objc::{msg_send, sel, sel_impl};
use rand::{distributions::Alphanumeric, Rng};
use tauri::{
plugin::{Builder, TauriPlugin},
Manager, Runtime, Window,
}; // 0.8
const WINDOW_CONTROL_PAD_X: f64 = 15.0;
const WINDOW_CONTROL_PAD_Y: f64 = 23.0;
@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) ->