hur.st's bl.aagh

BSD, Ruby, Rust, Rambling

faccess

Basic cross-platform file accessibility checks for Rust

[rust]

faccess adds file accessbility checks for file paths to Rust:

pub trait PathExt {
    fn access(&self, mode: AccessMode) -> std::io::Result<()>;
    fn readable(&self) -> bool;
    fn writable(&self) -> bool;
    fn executable(&self) -> bool;
}

impl PathExt for std::path::Path;
Continue Reading

Elite Shield Tester

Find the best-possible Elite Dangerous Shields

[rust] [javascript] [elite] [gaming]

In the popular space simulation game, Elite Dangerous, one of the challenges is determining how best to outfit your ship — if you’re going into combat, choosing the right shield, with the right boosters and the right engineering can be the difference between life or death.

So why not sap the fun out of it by using a computer to work out the best configuration for us?

Continue Reading

Compactor

A friendly user interface to Windows 10 filesystem compression

[rust] [windows]

One of the more notable features that shipped with Windows 10 is a new filesystem compression system based on the Windows Overlay Filesystem architecture, originally developed for transparent handling of disk images.

It’s intended for use in applications, in particular the base OS (in a feature referred to as CompactOS), but sadly this is only exposed to users via a command line program — compact.exe — and most users fail to take advantage of it.

Compactor offers this as an alternative:

Pretend there's a nice GUI here. Continue Reading

cw

Count Words - a Rust wc implementation

[rust]

cw is a fast Rust reimplementation of the classic Unix wc command, featuring fast paths for most common modes of operation, including SIMD-accelerated line and UTF-8 codepoint counting via the bytecount crate (closing issue #41 there in the process).

It also supports multithreading, because of course it does.

Even in single-threaded mode it is almost always much faster than either FreeBSD or GNU wc implementations.

Continue Reading

monotime

Rust-style monotonic clocks in Ruby

[ruby] [rust]

Monotime offers an alternative to the typical method of monotonic timekeeping in Ruby:

# Bog standard Ruby
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
do_something
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start

# With monotime
require 'monotime'
include Monotime

start = Instant.now
do_something
elapsed = start.elapsed

# or
elapsed = Duration.measure { do_something }

It’s less fiddly, and uses proper types wrapping elapsed times in nanoseconds, which is about as close to the native representations as Ruby gets.

Continue Reading

Password Generation in Ruby and Rust

Writing the same small program in two different languages.

[ruby] [rust]

I’ve been doing a fair bit of Rust lately. Honestly, I haven’t been so smitten with a language since I started writing Ruby back in 1999.

Rust is many of the things Ruby isn’t—precompiled, screaming fast, meticulously efficient, static, explicit, type-safe. But it’s also expressive and, above all, fun. I think this rare mix makes it a good companion language for Ruby developers, particularly with things like Helix and rutie making it easy to bridge the two.

The best way of learning is by doing, so why not avoid that and just read about me doing something instead?

Continue Reading

rtss

Relative Timestamps for Stuff

[rust]

rtss annotates its output with relative durations between consecutive lines and since program start.

Inspired by Kevin Burke’s Golang tss, I thought it would be a fun exercise and a nice bit of Rust practice to implement something similar.

I’m fairly pleased with the result - it’s considerably faster, running at hundreds of MB per second in my tests - and somewhat more featureful, including pty support, allowing it to work similarly to expect’s unbuffer command.

Continue Reading

gcstool / ruby-gcs

Efficient set membership with Golomb Compressed Sets

[rust] [ruby]

Similar to Bloom Filters, Golomb Compressed sets allow for space-efficient probablistic storage of sets. In other words, you can ask a GCS if it’s seen an object, and retrieve either “absolutely not” or “probably not” in response.

gcstool was my first Rust project, developed primarily to play about with the haveibeenpwned.com pwned-passwords-2.0.txt database. It can store all half a billion items with a false-positive rate of 1-in-50 million in just 1.6GB, importing them in just a few minutes, though with fairly high memory requirements.

Continue Reading