My Bare Metal RPi journey

I bought a Raspberry Pi 3 B+ a few years ago about the time I started learning Rust which was also about when I took OS dev. I wanted to learn OS development and I’d heard about CS140e so I thought it would be relatively easy. And it has been relatively easy when compared to interchanging the OS on my laptop which is the alternative I was considering. The Raspberry Pi has a lot of tutorials and examples, it’s hard to brick, it can netboot, it has user and kernel mode, and it has GPIO that would be fun to play with.

Continue

The Most Cursed JavaScript

There was an old trick used by Angular and a few other libraries of using a function's source code (which you can get using .toString()) to get its argument names. Promisify-node used this technique to find arguments called callback or cb. Angular uses it for dependency injection, though there are other better ways of doing that.

Continue

How to parse HTML with Regular Expressions

Sample of what we'll be building

I’ll be using JavaScript here. With it we can write this in <100 lines of code.

Harness

We’ll start by laying out our code. I’ll be using closures, but you could — and my first version did — use a class instead. We’ll need a parse_html function, inside we’ll put a helper function called pull and a parse_content function which we’ll fill in later.

If you’d like to follow along, the finished code is here: regex-html

Continue

How to Instantiate HTML Template Elements

I'm excited about template elements. There's no specified way of instantiating them, so let's talk about where they come from, why we use them, and how to instantiate them.

Continue

Built-In and Custom Traits in JavaScript

The Problem

Polymorphism is important in any language and while it is very easy to write polymorphic code in JavaScript, it is relatively hard to manage that code. Without explicit types you must either assume the structure of an object, or explicitly test its structure before using any functionality. Explicitly testing slows down your code, while making unsound assumptions usually results in bugs. This might sound like a trade off, but it’s just another problem for which fast and safe solutions exist.

Continue

From a lot of Rust and WASM

I’ve been working in Rust on Web Assembly projects a lot lately. First was working through the Raytracing in a Weekend series except I’m using Rust and drawing to an HTML Canvas. Right now I’m working on a template for peer to peer websites that wouldn’t require hosting a WebRTC signaling server. My previous version was all JavaScript including a binary serialization and deserialization setup which I’ve replaced with the Postcard crate. In my projects, I’ve gone from manually instantiating the wasm module to using wasm-pack, and then to using wasm-bindgen without wasm-pack. These are a few little things I’ve picked up during these experiences. 

Continue