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 / 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 / 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`.
@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 / doc.md
Created September 8, 2017 03:09
tiny-async-await

A tiny crate that provides async and await macros to create futures::Futures and futures::Streams.

Code that uses these macros requires #![feature(conservative_impl_trait, generators)]

  • Returning a futures::Future

     #![feature(conservative_impl_trait, generators)]
    
     #[macro_use]
@Arnavion
Arnavion / make_deserializable.rs
Last active October 3, 2016 16:27
Macro for deserializing structs from JSON for Rust stable
//! Exports a single macro named make_deserializable that can be used in place of #[derive(serde::Deserialize)] on structs.
//! Supports regular structs and tuple structs of u64.
//! Only works with JSON deserialization.
//!
//! Eg: make_deserializable!(struct Foo { bar: String, baz: i32, });
//! Eg: make_deserializable!(struct Bar(u64));
macro_rules! impl_deserialize_struct {
(struct $struct_name:ident {
$($field_name:ident: $field_type:ty,)*