Skip to content

Instantly share code, notes, and snippets.

@hn3000
hn3000 / search-federation.md
Last active October 19, 2024 12:59
Search - Federated, personalised

Federate search

What I'd like

  • self-hosted search engine
  • meta search, checking several APIs, e.g. bing, google (are there others?)
  • search through an index of my own web browsing history (I may be looking for sth I read last week)
  • search using search API offered by sites, eg Wikipedia, github, archive.org, media.ccc.de, peertube, youtube even (do they even offer APIs? They totally should!)
@hn3000
hn3000 / wsl-as-root.txt
Last active August 11, 2023 11:12
launch wsl bash as root
# list installed distributions
wsl --list -v
# replace Ubuntu to use another distribution
wsl -d Ubuntu -u root
@hn3000
hn3000 / watchy-button-test-serial-README.md
Last active June 20, 2021 08:42
sqfmi Watchy button test printing over serial

A little Arduino program for the sqfmi Watchy (watchy.sqfmi.com) that makes it easy to test the buttons.

Thanks to the people on discord, especially @mayanki (who pointed me at things) and @aliceafterall who created a version of this that only uses the Watchy display (but is a bit slower because of that).

Create a new sketch in Arduino, select ESP32 Dev module as target, connect watchy, select the correct port and upload!

@hn3000
hn3000 / rust-coverage.sh
Created April 23, 2021 22:50
rust test coverage with grcov
METHOD=${1:-${METHOD:-"A"}}
if [ "$METHOD" == "A" ]
then
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"
unset LLVM_PROFILE_FILE
else
@hn3000
hn3000 / dockerfile
Created April 17, 2021 00:20
cargo tarpaulin in docker
## run with `docker run --security-opt seccomp=unconfined -it <image-name>`
## (-it in case your unit tests rely on the ability to read stdin)
FROM rust:1-slim-buster as builder
RUN apt update && apt install -y pkg-config libssl-dev && cargo install cargo-tarpaulin
WORKDIR /build
COPY . .
@hn3000
hn3000 / Cargo.toml
Last active March 13, 2021 12:54
Bug or feature?
[package]
name = "weird_async_write_behaviour"
version = "1.0.0"
authors = ["@hn3000", "@rkarp"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
async-std = "1.9.0"
@hn3000
hn3000 / qemu
Last active July 24, 2021 08:22
qemu network hook script
#!/bin/bash
# this file wants to be called /etc/libvirt/hooks/qemu
# see https://wiki.libvirt.org/page/Networking
#!/bin/bash
echo "$0: ($(dirname $0) $(pwd)) $*" >> /var/log/qemu-nohop.out
export XML="$(cat)"
nohup $(dirname $0)/update-forwards.sh "$@" >> /var/log/qemu-nohop.out &
@hn3000
hn3000 / npm-release.sh
Last active October 29, 2020 16:37
npm release oneliner
npm test && npm version patch && npm publish && git push --tags
@hn3000
hn3000 / convert-to-data-url.ts
Created April 7, 2020 11:24
Convert an image URL to a Data URL with this one simple trick ...
function createDataUrl(icon: string): Promise<string> {
const result = new Promise<string>((resolve, _reject) => {
let image = new Image();
image.addEventListener('load', () => {
let canvas = document.createElement('canvas');
canvas.width = image.naturalWidth;
canvas.height = image.naturalHeight;
canvas.getContext('2d').drawImage(image, 0, 0);
resolve (canvas.toDataURL('image/png'));
});
@hn3000
hn3000 / algolia.swagger2.json
Created March 26, 2019 11:42
Algolia API (partial) as swagger 2.0
{
"$schema": "http://json.schemastore.org/swagger-2.0",
"swagger": "2.0",
"info": {
"title": "Swaggerized Algolia API",
"version": "1"
},
"basePath": "/1",
"schemes": [ "https" ],
"host": "${APPLICATION_ID}-dsn.algolia.net",