Skip to content

Instantly share code, notes, and snippets.

View zsteva's full-sized avatar

Zeljko Stevanovic zsteva

View GitHub Profile
// part 1
// example:
// input = [...document.getElementsByTagName('code')].map((e) => e.innerText)[5];
input = getInput();
rules = new Set(input.split("\n\n")[0].splitNL());
list1 = input.split("\n\n")[1].splitNL().splitCOL(",");
list1.filter((row) => {
return row.comb2().map(([a, b]) => rules.has(b + "|" + a) ? 1 : 0).sum() == 0;
}).map((row) => row[Math.floor(row.length / 2)]).nums().sum();
@zsteva
zsteva / aoc-2024-day2.js
Last active December 15, 2024 16:48
advent of code 2024 day 2 // javascript console
// part 1
function isSafe(row) {
if (row.isIncrease() || row.isDecrease()) {
return row.diff2().abs().filter((a) => (a > 3)).length == 0;
} else {
return false;
}
}
@zsteva
zsteva / aoc-2024-day1.js
Last active December 15, 2024 15:33
advent of code 2024 day 1 // javascript console
// part 1
list1 = getInput().splitNL().splitCOL().nums().column(0).toSortedNUM();
list2 = getInput().splitNL().splitCOL().nums().column(1).toSortedNUM();
zip(list1, list2).map(([a1, a2]) => Math.abs(a1-a2)).sum();
// result 1651298
// part 2
(() => {
var cells = [ ... document.getElementById("queens-grid").querySelectorAll(".queens-cell") ];
var size = Math.sqrt(cells.length);
var map = cells.map(e => e.className.match(/cell-color-(\d+)/)[1]);
var queens = Array(map.length).fill(0);
(() => { var s = [ ... document.getElementById("queens-grid").querySelectorAll(".queens-cell") ].map(e => e.className.match(/cell-color-(\d+)/)[1]).map(n => Number.parseInt(n).toString(32)).join(''); return s.match(new RegExp('.{1,' + Math.sqrt(s.length) + '}', 'g')).join('@'); })();
const symbol_set = Symbol("set");
export class ArraySet {
constructor() {
this[symbol_set] = new Set();
}
get size() {
import hid
vendor_id = 1386
product_id = 161
d = hid.device()
d.open(vendor_id, product_id)
while True:
buf = d.read(7)
@zsteva
zsteva / stu500tablet.py
Created May 5, 2024 18:40
stu-500 converter u tablet
# [email protected]
# 2024-05-05
from evdev import UInput, AbsInfo, ecodes as e
import hid
tablet_vendor_id = 1386
tablet_product_id = 161
#!/bin/bash
# wordfence appimage builder
# by [email protected]
APPTOOL_URL="https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage"
PY_URL="https://github.com/niess/python-appimage/releases/download/python3.12/python3.12.3-cp312-cp312-manylinux_2_28_x86_64.AppImage"
APPTOOL_NAME="$(basename "$APPTOOL_URL")"
PY_NAME="$(basename "$PY_URL")"
@zsteva
zsteva / extract-help.sh
Last active October 29, 2023 14:12
DSM-11 %HELP extractor
#!/bin/bash
#
# depending: bash 4+, socat
#
#
# Copyright (C) 2023 Zeljko Stevanovic <[email protected]>
#
# This program is free software; you can redistribute it and/or modify