Skip to content

Instantly share code, notes, and snippets.

@Arnavion
Arnavion / mrhlpr
Created March 23, 2024 17:46
mrhlpr wrapper that works directly on the user branch
#!/bin/bash
set -euo pipefail
shopt -s inherit_errexit
mkdir -p ~/.cache/mrhlpr
case "${1:-}" in
'fixmsg')
if [ -n "$(git status --porcelain)" ]; then
@Arnavion
Arnavion / 01_build.sh
Created February 3, 2023 05:08
steam in podman container
# ~/src/non-oss-container/build.sh
#!/bin/bash
set -euo pipefail
mkdir -p ~/non-oss-root/
podman image rm --force localhost/non-oss || :
@Arnavion
Arnavion / ip-flash.awk
Created November 18, 2019 19:34
Flash Raspberry Pi's IP address using its LED
#!/usr/bin/awk -f
BEGIN {
while (1) {
split(exec_line_match("ip addr show dev eth0", " inet "), ip_a_parts, " ")
split(ip_a_parts[2], ip_value_parts, "/")
split(ip_value_parts[1], ip_parts, ".")
reset();
@Arnavion
Arnavion / background.js
Created September 1, 2022 17:51
HN Blocklist Extension
browser.runtime.onMessage.addListener(async message => {
const { param } = message;
switch (param) {
case "get":
return getRecords();
case "set":
return setRecords(message.records);
@Arnavion
Arnavion / gps-nmea
Created August 12, 2022 19:44
Pinephone pmoS GPS
# /etc/init.d/gps-nmea
#!/sbin/openrc-run
command=/usr/local/bin/gps-nmea.py
command_args=
command_background=true
pidfile="/run/${RC_SVCNAME}.pid"
// If lines 72 and 73 are uncommented and 74 is commented out, the assert on line 77 succeeds (as expected).
// If lines 72 and 73 are commented out and 74 is uncommented, the assert on line 77 fails.
//
// $ zig run -O Debug ./main.zig
//
// Linux x86_64, 0.9.0-dev.2010+e8b39960b
const std = @import("std");
const Scanner = struct {
@Arnavion
Arnavion / Cargo.toml
Last active May 30, 2021 08:40
transducers-rs
[package]
name = "transducers"
version = "0.1.0"
authors = ["Arnavion <me@arnavion.dev>"]
edition = "2018"
[dependencies]
num-traits = { version = "0.2", default-features = false }
[dev-dependencies]
@Arnavion
Arnavion / async-await.ts
Last active May 30, 2021 06:25
Promise.any - async/await vs then()
async function any<T>(promises: Promise<T>[]): Promise<T> {
const rejections: any[] = [];
for (const promise of promises) {
try {
return await promise;
}
catch (reason) {
rejections.push(reason);
}
@Arnavion
Arnavion / async-await.ts
Last active May 30, 2021 06:24
Promise.first
async function first<T>(promises: Promise<T>[]): Promise<T> {
const rejections: any[] = [];
for (const promise of promises) {
try {
return await promise;
}
catch (reason) {
rejections.push(reason);
}
@Arnavion
Arnavion / lib.rs
Created December 3, 2019 00:36
launder-rs
#![deny(rust_2018_idioms, warnings)]
#![deny(clippy::all, clippy::pedantic)]
//! This crate defines a `launder` macro that can be used to create a borrow that is scoped to the block where this macro is invoked,
//! even if the expression to create the borrow returns a `'static` borrow.
/// This macro can be used to create a borrow that is scoped to the block where this macro is invoked,
/// even if the expression to create the borrow returns a `'static` borrow.
///
/// For example, dereferencing a raw pointer with `&*` creates a borrow with an arbitrary lifetime which can be `'static`.