Skip to content

Instantly share code, notes, and snippets.

Avatar

ja.nz ja0nz

View GitHub Profile
@ja0nz
ja0nz / highlightDOM.ts
Last active May 22, 2022
dependency free performant DOM text highlighter | HTML markup -> DocumentFragment | HTML markup
View highlightDOM.ts
/*
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 Oct 14, 2020
Nix/NixOS Sizzy Dev Browser (https://sizzy.co/)
View sizzy_default.nix
/*
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 Mar 26, 2020 — forked from 4eek/nixos-encrypted-zfs.sh
How I installed Encrypted ZFS root on NixOS
View nixos-encrypted-zfs.sh
#!/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
uberspace; auto update bitwarden_rs
View bitwarden_update
#!/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'
View BarChart.js
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);