Skip to content

Instantly share code, notes, and snippets.

View linusg's full-sized avatar

Linus Groh linusg

View GitHub Profile
@linusg
linusg / yarn_get_latest_minor_upgrades.py
Last active July 11, 2019 11:07
Generate `yarn upgrade` commands for all packages with upgradable minor and patch versions
import ast
import shlex
import subprocess
import sys
import semver
PROJECT_DIRECTORY = "." if len(sys.argv) < 2 else sys.argv[1]
@linusg
linusg / generate_macos_model_identifiers_dict.py
Last active July 29, 2023 06:38
Generate macOS model identifier / device name mapping from Apple support pages
import json
import re
import requests
DEVICE_NAME_MODEL_IDENTIFIER_REGEX = r"<strong>(.*)\s*(?:<br>\s*</strong>|</strong>\s*<br>)\s*.*\s*Model (?:Label|Identifier):\s*(.*)\s*<br>"
SUPPORT_URLS = [
# iMac
"https://support.apple.com/en-gb/HT201634",
import re
import subprocess
import sys
from pathlib import Path
FUTURE_ANNOTATIONS_IMPORT_REGEX = (
r"^from __future__ import (?:.*, )?annotations(?:, .*)?"
)
sudo lshw
[sudo] password for linus:
linus-desktop
description: Desktop Computer
product: MS-7A34 (To be filled by O.E.M.)
vendor: Micro-Star International Co., Ltd
version: 2.0
serial: To be filled by O.E.M.
width: 64 bits
capabilities: smbios-3.0.0 dmi-3.0.0 smp vsyscall32
// 13.29 ApplyUnsignedRoundingMode ( x, r1, r2, unsignedRoundingMode ), https://tc39.es/proposal-temporal/#sec-temporal-applyunsignedroundingmode
Crypto::SignedBigInteger apply_unsigned_rounding_mode(Crypto::SignedBigInteger const& x, Crypto::SignedBigInteger r1, Crypto::SignedBigInteger r2, Optional<UnsignedRoundingMode> const& unsigned_rounding_mode)
{
// 1. If x is equal to r1, return r1.
if (x == r1)
return r1;
// 2. Assert: r1 < x < r2.
VERIFY(r1 < x && x < r2);
@linusg
linusg / diff.diff
Created May 24, 2022 19:20
bigint nonsense
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
index c5da1b12ac..aca68bdbd7 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
@@ -1093,6 +1093,69 @@ double apply_unsigned_rounding_mode(double x, double r1, double r2, Optional<Uns
return r2;
}
+// 13.29 ApplyUnsignedRoundingMode ( x, r1, r2, unsignedRoundingMode ), https://tc39.es/proposal-temporal/#sec-temporal-applyunsignedroundingmode
+Crypto::SignedBigInteger apply_unsigned_rounding_mode(Crypto::SignedDivisionResult const& x, Crypto::SignedBigInteger r1, Crypto::SignedBigInteger r2, Optional<UnsignedRoundingMode> const& unsigned_rounding_mode)
@linusg
linusg / a.patch
Created October 19, 2022 08:37
SerenityOS Browser support in WPT
diff --git a/tools/wpt/browser.py b/tools/wpt/browser.py
index 66796a8968..6a581b0675 100644
--- a/tools/wpt/browser.py
+++ b/tools/wpt/browser.py
@@ -2046,3 +2046,27 @@ class Epiphany(Browser):
# Tech Preview output looks like "Web 3.31.3-88-g97db4f40f"
return output.split()[1]
return None
+
+class SerenityOSBrowser(Browser):
@linusg
linusg / notes.md
Created April 12, 2023 13:21
Real-world NixOS dotfile repos
@linusg
linusg / shell.nix
Created August 3, 2023 14:37
[WIP] ladybird-gtk4 nix shell
let
gtk4Overlay = final: prev: {
gtk4 = prev.gtk4.overrideAttrs (old: rec {
version = "4.11.4";
src = prev.fetchurl {
url = "mirror://gnome/sources/gtk/${prev.lib.versions.majorMinor version}/gtk-${version}.tar.xz";
sha256 = "sha256-jSdisWecXhkQpcBCqlZx+cG5432o+kGn3+RNEksZyeg=";
};
});
};
@linusg
linusg / prune_blank_profile_followers.py
Last active August 6, 2023 13:34
Prune blank profile followers from a Mastodon account
from mastodon import Mastodon
CLIENT_SECRET = "..."
ACCESS_TOKEN = "..."
API_BASE_URL = "https://chaos.social"
mastodon = Mastodon(
client_secret=CLIENT_SECRET,
access_token=ACCESS_TOKEN,