Skip to content

Instantly share code, notes, and snippets.

View ja0nz's full-sized avatar

ja.nz ja0nz

View GitHub Profile
@ja0nz
ja0nz / highlightDOM.ts
Last active May 22, 2022 12:34
dependency free performant DOM text highlighter | HTML markup -> DocumentFragment | HTML markup
/*
Needed a highlighter working on raw HTML markup text. Got deep into DOM manipulation
This module exports two members:
* highlightDOMFragment: string -> DocumentFragment (f.e. for diffing nodes, el.replaceChildren, el.replaceWith)
* highlightDOMString: string -> string (f.e. for el.innerHTML)
Usage example:
highlightDOMString(
"<div>Highlight this</div>", // HTML markup string (f.e. obtained from el.innerHTML)
"this", // query string (match to highlight in HTML)
@ja0nz
ja0nz / sizzy_default.nix
Last active October 14, 2020 09:50
Nix/NixOS ♥ Sizzy Dev Browser (https://sizzy.co/)
/*
Unfortunately, the Sizzy AppImage is somewhat closed source and has no permalink.
Therefore it can't be added to any package manager.
To install it with the Nix package manager follow the steps:
- mkdir sizzy && touch sizzy/default.nix
- cp Sizzy-<version>.AppImage sizzy
- echo <content of this file> > sizzy/default.nix
- nix-env -if sizzy/default.nix
@ja0nz
ja0nz / nixos-encrypted-zfs.sh
Created March 26, 2020 16:43
How I installed Encrypted ZFS root on NixOS
#!/bin/sh
# FIRST STOP THE zfs-zed SERVICE
systemctl stop zfs-zed
# FORCE UNLOAD ZFS KERNEL MODULES
lsmod | grep zfs | cut -d' ' -f1 | xargs rmmod -f
# NOW ADD THE FOLLOWING TO /etc/nixos/configuration.nix
#
@ja0nz
ja0nz / bitwarden_update
Last active May 11, 2021 21:22
uberspace; auto update bitwarden_rs
#!/usr/bin/env bash
# Settings: DIR to your bitwarden clone
DIR=~/git/bitwarden_rs
# Settings end
# Just some terminal coloring
NC='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
@ja0nz
ja0nz / BarChart.js
Created June 22, 2017 18:01
Mike Bostocks BarChart in React - https://bl.ocks.org/mbostock/3885304
import React, { Component } from 'react';
import { tsv } from 'd3-request';
import { scaleBand, scaleLinear } from 'd3-scale';
import { max } from 'd3-array';
import { select, } from 'd3-selection';
import { axisBottom, axisLeft } from 'd3-axis';
import { futurize } from 'futurize';
import { Future } from 'ramda-fantasy';
import './BarChart.css';
const read = futurize(Future)(tsv);