<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Matt&#x27;s Blog</title>
    <subtitle>Matthew Esposito&#x27;s blog. Check out my [about page](&#x2F;about) :)</subtitle>
    <link href="//matthew.science/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="//matthew.science/"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-01-01T00:00:00+00:00</updated>
    <id>//matthew.science/atom.xml</id>
    <entry xml:lang="en">
        <title>Projects</title>
        <published>2026-01-01T00:00:00+00:00</published>
        <updated>2026-01-01T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="//matthew.science/projects/" type="text/html"/>
        <id>//matthew.science/projects/</id>
        
        <content type="html">&lt;h2 id=&quot;redlib&quot;&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;redlib-org&#x2F;redlib&quot;&gt;Redlib&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;Rust, Docker, CI&#x2F;CD, Reverse Engineering&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;m the maintainer of Redlib, a private and lightweight alternative frontend for Reddit. It&#x27;s grown quite a bit since I started, serving over 1.7 million container pulls a month and helping people in censorship-heavy regions access content.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;occumetrics-sep-2023&quot;&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;matthew.science&#x2F;posts&#x2F;occupancy&#x2F;&quot;&gt;OccuMetrics&lt;&#x2F;a&gt; (Sep 2023)&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;Rust, C++, IoT, ESP32, Grafana, SQLite, ML&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;OccuMetrics was an experiment in using BLE beacon counting to predict campus occupancy. I used a fleet of ESP32s and some time-series machine learning to forecast trends with over 90% accuracy. The project got some unexpected love - it was featured on &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;hackaday.com&#x2F;2023&#x2F;12&#x2F;13&#x2F;bluetooth-as-proxy-for-occupancy&#x2F;&quot;&gt;Hackaday&lt;&#x2F;a&gt; and is even cited in &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;efi.mit.edu&#x2F;spring24&#x2F;ex01&#x2F;research&quot;&gt;MIT engineering course materials&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;focusguardian-april-2024&quot;&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;focusguardian.org&quot;&gt;FocusGuardian&lt;&#x2F;a&gt; (April 2024)&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;Rust, Vue, C++, PocketBase, Tailwind&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Built this in a 24-hour solo hackathon where it won &amp;quot;Best Hardware Hack.&amp;quot; FocusGuardian is a tool that manages focus by handling DNS-over-HTTPS requests on a schedule you set. I even put together a hardware prototype using C++ and LVGL. You can read more about the sleep-deprived experience in my &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;matthew.science&#x2F;posts&#x2F;focusguardian&#x2F;&quot;&gt;blog post&lt;&#x2F;a&gt;. (I replaced my personal usage of it with the Foqos app on iOS, and I was the first and only user, so I stopped maintaining it)&lt;&#x2F;p&gt;
&lt;h2 id=&quot;alpr-analysis-dec-2025&quot;&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;alpranalysis.com&#x2F;&quot;&gt;ALPR Analysis&lt;&#x2F;a&gt; (Dec 2025)&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;Rust, GIS, OSINT&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This project focuses on mapping surveillance infrastructure. I built a tool that crunches massive OpenStreetMap datasets (over 60GB!) to find and classify ALPR (Automatic License Plate Reader) cameras. It&#x27;s written in Rust to keep things fast and memory-efficient. I also built a &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;alpranalysis.com&#x2F;&quot;&gt;Vue.js dashboard&lt;&#x2F;a&gt; to visualize the data, turning raw OSINT into something anyone can explore.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Basics of the RISC-V ISA</title>
        <published>2024-07-01T00:00:00+00:00</published>
        <updated>2024-07-01T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="//matthew.science/posts/riscv/" type="text/html"/>
        <id>//matthew.science/posts/riscv/</id>
        
        <content type="html">&lt;p&gt;I&#x27;m having a great time in &lt;a href=&quot;&#x2F;now&quot;&gt;Boston&lt;&#x2F;a&gt; this summer, but one thing I&#x27;ve really been fixated on is &lt;code&gt;RISC-V&lt;&#x2F;code&gt;. It&#x27;s an ISA that aims to be flexible and modular to meet the needs of any level of computing, from the smallest microcontroller to the largest supercomputer, while learning from the mistakes of previous ISA&#x27;s like &lt;code&gt;x86&lt;&#x2F;code&gt;, &lt;code&gt;ARM&lt;&#x2F;code&gt;, &lt;code&gt;MIPS&lt;&#x2F;code&gt;, etc. &lt;&#x2F;p&gt;
&lt;p&gt;The &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www2.eecs.berkeley.edu&#x2F;Pubs&#x2F;TechRpts&#x2F;2014&#x2F;EECS-2014-146.pdf&quot;&gt;original draft&lt;&#x2F;a&gt; for &lt;code&gt;RISC-V&lt;&#x2F;code&gt; was created in just one summer by Krste Asanović, professor emeritus in the EECS department at UC Berkeley, and grad students Andrew Waterman and Yunsup Lee.&lt;&#x2F;p&gt;
&lt;p&gt;There&#x27;s a number of changes that &lt;code&gt;RISC-V&lt;&#x2F;code&gt; makes to simplify the instruction set, and to make it flexible enough to reach its goals. I will try to give a high level overview, mainly summarized from the essential text, &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;dl.acm.org&#x2F;doi&#x2F;book&#x2F;10.5555&#x2F;3202479&quot;&gt;The RISC-V Reader: An Open Architecture Atlas&lt;&#x2F;a&gt; (coauthored by none other than Andrew Waterman). Included at the end is a downloadable flash card set in case you want to commit the information herein to long-term memory.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;typical-cisc-isa-design&quot;&gt;Typical CISC ISA design&lt;&#x2F;h2&gt;
&lt;p&gt;There&#x27;s many choices that must be made when designing an ISA. Targeting a specific niche means accepting trade-offs on things like cost, flexibility, and developer experience. For example, embedded &lt;code&gt;ARM&lt;&#x2F;code&gt; devices accept difficulty in programming&#x2F;compiling and poor performance in exchange for lower cost and higher simplicity. &lt;code&gt;X86&lt;&#x2F;code&gt; devices accept higher cost, complexity, and worse tech debt, in exchange for higher performance.&lt;&#x2F;p&gt;
&lt;p&gt;In general, these ISAs accept the trade-offs for specific use cases, and computing is fragmented across these. They accept these because they are &lt;strong&gt;incremental&lt;&#x2F;strong&gt; ISA&#x27;s - new processors must implement all previous extensions, because they prioritize backwards binary-compatibility. &lt;&#x2F;p&gt;
&lt;p&gt;With X86, this incremental nature grows to be quite tedious indeed - the &lt;code&gt;CISC&lt;&#x2F;code&gt; instruction set has its roots in the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Intel_8086&quot;&gt;8086&lt;&#x2F;a&gt;, introduced in 1978, itself a 16-bit extension of the 8-bit &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Intel_8080&quot;&gt;8080&lt;&#x2F;a&gt; from 1974, itself an extended variant of the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Intel_8008&quot;&gt;8008&lt;&#x2F;a&gt; (though starting with the 8080, binary compatibility was broken). &lt;&#x2F;p&gt;
&lt;p&gt;That means the set of instructions that must be implemented by every new &lt;code&gt;X86&lt;&#x2F;code&gt; chip date back to 1974, at a rate of three new instructions per month. This also means every old, outdated, useless instruction over the course of &lt;strong&gt;fifty years&lt;&#x2F;strong&gt; must be added by every new chip, resulting in &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.usdebtclock.org&#x2F;&quot;&gt;USA levels&lt;&#x2F;a&gt; of tech debt. At some level, just like government debt, tech debt isn&#x27;t always bad - breaking compatibility every few years would be terrible for an ISA, literally the bottom layer of computing. Sure, you JS devs can switch to a new framework every 6 months - but your CPU&#x27;s ISA sets the maximum standard for backwards compatibility. So a sense of caution and safety is reasonable!&lt;&#x2F;p&gt;
&lt;p&gt;That being said, starting fresh with fifty years of ISA design history to learn from provides a number of improvements. Let&#x27;s get into how &lt;code&gt;RISC-V&lt;&#x2F;code&gt; diverges from traditional &lt;code&gt;CISC&lt;&#x2F;code&gt;&#x27;s.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;risc-v-design-philosophy&quot;&gt;RISC-V design philosophy&lt;&#x2F;h2&gt;
&lt;p&gt;As opposed to the &lt;strong&gt;incremental&lt;&#x2F;strong&gt; ISA&#x27;s of yore, which act as an ever-growing pile of cruft, &lt;code&gt;RISC-V&lt;&#x2F;code&gt; is designed to be a &lt;strong&gt;modular&lt;&#x2F;strong&gt; ISA. There&#x27;s one core ISA, called &lt;code&gt;RV32I&lt;&#x2F;code&gt;. This is the bare basics of a CPU, implemented by every &lt;code&gt;RISC-V&lt;&#x2F;code&gt; processor. Upon it, every other ISA can be emulated*. This means that &lt;strong&gt;any&lt;&#x2F;strong&gt; &lt;code&gt;RISC-V&lt;&#x2F;code&gt; processor can run &lt;strong&gt;any&lt;&#x2F;strong&gt; &lt;code&gt;RISC-V&lt;&#x2F;code&gt; code, by simply removing the target features to enable emulation.&lt;&#x2F;p&gt;
&lt;p&gt;* - &lt;code&gt;RV32A&lt;&#x2F;code&gt;, the atomic instruction set, is the only exception, since its atomicity features requires hardware support&lt;&#x2F;p&gt;
&lt;p&gt;The idea behind the additional modules is to maximize the flexibility for everyone from programmers, chip designers, compiler writers, etc. Hardware manufacturers can implement exactly the additional ISA&#x27;s needed to perform their tasks, or implement most&#x2F;all of them for a general computing device. But for those with specific low-end needs, they can choose to implement only a subset. In addition, these modular extensions are discussed heavily by a wide array of experts, and even if accepted, they still remain optional.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;base-isa-rv32i-integer&quot;&gt;Base ISA: &lt;code&gt;RV32I&lt;&#x2F;code&gt; - Integer&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;code&gt;RV32I&lt;&#x2F;code&gt; is the base integer ISA that serves as the foundation for the rest of the extensions. With it, everything else can be implemented (though hardware manufacturers will likely want to make it more performant by designing hardware implementations).&lt;&#x2F;p&gt;
&lt;p&gt;There are six base instruction formats in &lt;code&gt;RV32I&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;R&lt;&#x2F;code&gt;: Register-register ops&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;I&lt;&#x2F;code&gt;: Short immediates and loads&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;S&lt;&#x2F;code&gt;: Stores&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;B&lt;&#x2F;code&gt;: Conditional branches&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;U&lt;&#x2F;code&gt;: Long immediates&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;J&lt;&#x2F;code&gt;: Unconditional jumps&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;One mnemonic you can use to remember each of these formats is:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;quot;&lt;strong&gt;R&lt;&#x2F;strong&gt;andom &lt;strong&gt;I&lt;&#x2F;strong&gt;nstructions &lt;strong&gt;S&lt;&#x2F;strong&gt;ometimes &lt;strong&gt;B&lt;&#x2F;strong&gt;oggle &lt;strong&gt;U&lt;&#x2F;strong&gt;seless &lt;strong&gt;J&lt;&#x2F;strong&gt;unk&amp;quot;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;One special behavior of &lt;code&gt;RV32I&lt;&#x2F;code&gt; is that two special bit patterns are illegal: all zeroes and all ones. This is to help debug erroneous jumps or memory sections. If encountered, the CPU will immediately trap. More on trapping in &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;osblog.stephenmarz.com&#x2F;ch4.html&quot;&gt;this article about interrupts and traps&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;All &lt;code&gt;RV32I&lt;&#x2F;code&gt; instructions are 32 bits, and there are 32 registers available. &lt;&#x2F;p&gt;
&lt;p&gt;One special register exists, &lt;code&gt;x0&lt;&#x2F;code&gt;, which always contains zero. This enables many optimizations, as a large number of &lt;code&gt;CISC&lt;&#x2F;code&gt; instructions are dedicated to regular operations, except with a zero as an implicit operand - instead of an instruction dedicated to the zero case, the generic instruction can be used with the zero register, still allowing for efficient performance (since this register&#x27;s use is equivalent to the implicit knowledge of a zero argument).&lt;&#x2F;p&gt;
&lt;p&gt;However, &lt;code&gt;RV32I&lt;&#x2F;code&gt; is not designed to contain every instruction - one notable missing feature is multiplication and division of integers. This can of course be emulated with the other instructions, but many lower level use cases don&#x27;t have a need for dedicated M&#x2F;D instructions.&lt;&#x2F;p&gt;
&lt;p&gt;In addition, &lt;code&gt;RV32I&lt;&#x2F;code&gt; lacks dedicated overflow&#x2F;underflow detection instructions. Manually implementing this is trivial in only a few instructions.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rv32m-multiply-divide&quot;&gt;&lt;code&gt;RV32M&lt;&#x2F;code&gt; - Multiply&#x2F;Divide&lt;&#x2F;h2&gt;
&lt;p&gt;The RV32M extension adds integer multiply and divide instructions. There&#x27;s four major instructions: &lt;code&gt;div&lt;&#x2F;code&gt;&#x2F;&lt;code&gt;mul&lt;&#x2F;code&gt;, and the unsigned versions, &lt;code&gt;divu&lt;&#x2F;code&gt;&#x2F;&lt;code&gt;mulu&lt;&#x2F;code&gt;. &lt;&#x2F;p&gt;
&lt;p&gt;One difference between traditional CISC and RV32M is that by default, the multiplication instructions will only calculate half of the result (the lower half, unless you add the &lt;code&gt;h&lt;&#x2F;code&gt; modifier, a la &lt;code&gt;mulhu&lt;&#x2F;code&gt;). Two 32-bit numbers multiplied together results in a 64-bit number. &lt;code&gt;CISC&lt;&#x2F;code&gt; ISA&#x27;s will typically calculate both halves and place each half in a pair of registers (&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.felixcloutier.com&#x2F;x86&#x2F;mul&quot;&gt;&lt;code&gt;X86&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20190222083348&#x2F;http:&#x2F;&#x2F;logos.cs.uic.edu&#x2F;366&#x2F;notes&#x2F;mips%20quick%20tutorial.htm&quot;&gt;&lt;code&gt;MIPS32&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;). Many use-cases of the multiplication instructions only use one or the other, and the additional &lt;code&gt;mov&lt;&#x2F;code&gt; incurred by writing to both registers, despite throwing out half of it, adds up. Calculating both halves takes only one extra instruction.&lt;&#x2F;p&gt;
&lt;p&gt;As you can imagine, &lt;code&gt;RV32M&lt;&#x2F;code&gt; is considered crucial for general-purpose computing, meaning it is grouped in with the &lt;code&gt;G&lt;&#x2F;code&gt; extension - more on that below.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rv32a-atomic-instructions&quot;&gt;&lt;code&gt;RV32A&lt;&#x2F;code&gt; - Atomic Instructions&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;code&gt;RV32A&lt;&#x2F;code&gt; provides two kinds of atomic instructions: Atomic memory operations (AMO), and Load reserved&#x2F;store conditionals (LRSC), also known as load-linked&#x2F;store-conditional (LLSC). It&#x27;s also the only extension that cannot be emulated by software on &lt;code&gt;RV32I&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The combination of these two categories pack a powerful punch for atomic primitives. LRSC instructions allow for compare-and-swap to be implemented quite easily, which serves as the universal synchronization primitive. Any other single-word synchronization operation can be created by building off of CAS operations. The addition of AMO operations allows for efficient IO operations across buses, improving performance.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;atomic-memory-operations-amo&quot;&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;RISC-V#Atomic_memory_operations&quot;&gt;Atomic memory operations (AMO)&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;AMO&#x27;s allow you to perform basic operations on memory without interruptions between the read and the write. AMO instructions allow for seven different operations: &lt;code&gt;add&lt;&#x2F;code&gt;, &lt;code&gt;and&lt;&#x2F;code&gt;, &lt;code&gt;or&lt;&#x2F;code&gt;, &lt;code&gt;swap&lt;&#x2F;code&gt;, &lt;code&gt;xor&lt;&#x2F;code&gt;, &lt;code&gt;max&lt;&#x2F;code&gt;, and &lt;code&gt;min&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Neither interrupts nor other processors can modify the memory between these instructions.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;load-reserved-store-conditional-lrsc&quot;&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Load-link&#x2F;store-conditional&quot;&gt;Load reserved&#x2F;store conditional (LRSC)&lt;&#x2F;a&gt;&lt;&#x2F;h4&gt;
&lt;p&gt;LRSC instructions are more flexible than AMO&#x27;s. They comprise of just two instructions (naturally &lt;code&gt;lr&lt;&#x2F;code&gt; and &lt;code&gt;sc&lt;&#x2F;code&gt;). &lt;code&gt;lr&lt;&#x2F;code&gt; loads memory from an address, marking it as &lt;strong&gt;reserved&lt;&#x2F;strong&gt;. Then, you perform arbitrary computation with it. &lt;code&gt;sc&lt;&#x2F;code&gt; then only saves the operand to the reserved memory address &lt;em&gt;&lt;strong&gt;iff&lt;&#x2F;strong&gt;&lt;&#x2F;em&gt;  the reserved memory hasn&#x27;t been modified in the meantime. If it has, an error is raised. The LRSC operations allow for lock-free, atomic operations that prevent race conditions.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rv32fd-floating-point&quot;&gt;&lt;code&gt;RV32FD&lt;&#x2F;code&gt; - Floating Point&lt;&#x2F;h2&gt;
&lt;p&gt;Two extensions exist under this group: &lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;RV32F&lt;&#x2F;code&gt;: Single precision floating point&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RV32D&lt;&#x2F;code&gt;: Double precision floating point&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;These extensions provide 32 separate registers only for floating-point! &lt;code&gt;f0&lt;&#x2F;code&gt; does &lt;strong&gt;not&lt;&#x2F;strong&gt; however have the same &lt;code&gt;x0&lt;&#x2F;code&gt; always-zero behavior.&lt;&#x2F;p&gt;
&lt;p&gt;Some differences between &lt;code&gt;RV32FD&lt;&#x2F;code&gt; and traditional &lt;code&gt;CISC&lt;&#x2F;code&gt;-based floating point is the introduction of a rounding mode called &amp;quot;static rounding&amp;quot;. This means the rounding mode is set per-instruction, instead of dynamic rounding, where it is set across all instructions. This improves performance if you need a different rounding mode for a single instruction, or quickly need to switch between rounding modes.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;RV32FD&lt;&#x2F;code&gt;&#x27;s multiplication instructions, notably, do not have upper and lower halves during multiplication (product is same size), and have no direct remainder instructions.&lt;&#x2F;p&gt;
&lt;p&gt;In addition, &lt;code&gt;RV32FD&lt;&#x2F;code&gt; provides the standard &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Multiply%E2%80%93accumulate_operation#Fused_multiply%E2%80%93add&quot;&gt;Fused multiply-add&lt;&#x2F;a&gt; instructions as well, which are more accurate for common algorithms like matrix multiplication, dot product, signal processing, gradient descent, and more.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;RV32FD&lt;&#x2F;code&gt; also has a number of miscellaneous instructions, including:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Sign injection instructions (speeds up sign-based calculations like negation, absolute value, etc)&lt;&#x2F;li&gt;
&lt;li&gt;Classification instructions (tests a FP number for a list of properties, returning a bitmask classifying it as +&#x2F;- infinity&#x2F;normal&#x2F;subnormal&#x2F;zero&#x2F;quiet&#x2F;signaling. useful to math libraries)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;rvzicsr-control-status-registers&quot;&gt;&lt;code&gt;RVZicsr&lt;&#x2F;code&gt; - &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Control&#x2F;Status_Register&quot;&gt;Control Status Registers&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;The &lt;code&gt;Zicsr&lt;&#x2F;code&gt; extension defines control and status registers (CSRs) and instructions, primarily used by the privileged architectures. All CSR instructions atomically read-modify-write a single CSR.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;five-embeddev.com&#x2F;riscv-user-isa-manual&#x2F;Priv-v1.12&#x2F;csr.html&quot;&gt;Reference to RVZicsr&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rvzifencei-fence-instructions&quot;&gt;&lt;code&gt;RVZifencei&lt;&#x2F;code&gt; - &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Memory_barrier&quot;&gt;Fence instructions&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;The &lt;code&gt;Zifencei&lt;&#x2F;code&gt; extension defines one instruction - &lt;code&gt;FENCE.I&lt;&#x2F;code&gt; - that allows enforcement of an ordering constraint on memory - ie, once you store and fence memory, &lt;strong&gt;any&lt;&#x2F;strong&gt; subsequent fetches are guaranteed to read after that memory (on the same hardware thread). &lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;five-embeddev.com&#x2F;riscv-user-isa-manual&#x2F;Priv-v1.12&#x2F;zifencei.html&quot;&gt;Reference to RVZifencei&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rv32-64g&quot;&gt;&lt;code&gt;RV32&#x2F;64G&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;code&gt;RVxxG&lt;&#x2F;code&gt; is not an extension in itself, but rather shorthand for the previous extensions, useful for general computing. It contains:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;A base ISA (&lt;code&gt;RV32I&lt;&#x2F;code&gt; or &lt;code&gt;RV64I&lt;&#x2F;code&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Standard extensions 
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;RVxxM&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RVxxA&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RVxxF&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RVxxD&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RVxxZicsr&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RVxxZifencei&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;AKA, it implements all common integer&#x2F;floating operations, as well as atomic&#x2F;synchronization primitives.&lt;&#x2F;p&gt;
&lt;p&gt;This is a useful benchmark for finding a general computing device - it should have all of these extensions at minimum to be a useful computer.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rv32c-compressed-isa&quot;&gt;&lt;code&gt;RV32C&lt;&#x2F;code&gt; - Compressed ISA&lt;&#x2F;h2&gt;
&lt;p&gt;Many other ISAs provide smaller versions of their instruction set, like ARM Thumb and Micro MIPS. However, these largely diverged from their larger cousins, bringing the larger burden of different compressed instructions that may not map directly to standard instructions. &lt;code&gt;RISC-V&lt;&#x2F;code&gt;&#x27;s &lt;code&gt;RV32C&lt;&#x2F;code&gt;, on the other hand, contains &lt;em&gt;only&lt;&#x2F;em&gt; instructions that correspond to one standard instruction, meaning it&#x27;s purely a subset of standard &lt;code&gt;RISC-V&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Thanks to the direct mapping, only the assembler and linker must be aware of the use of &lt;code&gt;RV32C&lt;&#x2F;code&gt; - its use is completely transparent to compiler authors and assembly writers.&lt;&#x2F;p&gt;
&lt;p&gt;There are three observations &lt;code&gt;RV32C&lt;&#x2F;code&gt; uses as key to its high compression:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Ten registers are accessed more often&lt;&#x2F;li&gt;
&lt;li&gt;Many instructions overwrite one of their operands&lt;&#x2F;li&gt;
&lt;li&gt;Immediate operands tend to be small, and some instructions favor certain immediates&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;rv32v-vector-instructions-data-level-parallelism&quot;&gt;&lt;code&gt;RV32V&lt;&#x2F;code&gt; - Vector instructions (&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Data_parallelism&quot;&gt;data-level parallelism&lt;&#x2F;a&gt;)&lt;&#x2F;h2&gt;
&lt;p&gt;ISAs have long utilized parallelism-based instructions to make certain algorithms more efficient, like signal processing, machine learning, simulations, and cryptography, but even &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;simdjson.org&#x2F;&quot;&gt;JSON parsing&lt;&#x2F;a&gt; and &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rusticstuff&#x2F;simdutf8&quot;&gt;UTF-8 validation&lt;&#x2F;a&gt;. Essentially, it defines instructions that allow for performing the same operation on many pieces of data. &lt;&#x2F;p&gt;
&lt;p&gt;One existing implementation of this is SIMD - introduced in the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;ILLIAC_IV&quot;&gt;ILLIAC IV&lt;&#x2F;a&gt; parallel computer in 1974 (also the first large computer to use solid-state memory!). SIMD defines the data width and operation &lt;em&gt;within&lt;&#x2F;em&gt; the instruction. This means every additional operation or data width used grows the complexity of the ISA extremely quickly. Here&#x27;s a non-complete list of X86-based SIMD extensions introduced:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;MMX_(instruction_set)&quot;&gt;MMX&lt;&#x2F;a&gt; (&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.oracle.com&#x2F;cd&#x2F;E18752_01&#x2F;html&#x2F;817-5477&#x2F;eojdc.html&quot;&gt;46 instructions&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Streaming_SIMD_Extensions&quot;&gt;SSE&lt;&#x2F;a&gt; (&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;cdrdv2.intel.com&#x2F;v1&#x2F;dl&#x2F;getContent&#x2F;671200&quot;&gt;70 instructions&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SSE2&quot;&gt;SSE2&lt;&#x2F;a&gt; (&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.intel.com&#x2F;content&#x2F;www&#x2F;us&#x2F;en&#x2F;support&#x2F;articles&#x2F;000005779&#x2F;processors.html&quot;&gt;144 instructions&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SSE3&quot;&gt;SSE3&lt;&#x2F;a&gt; (&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.intel.com&#x2F;content&#x2F;www&#x2F;us&#x2F;en&#x2F;support&#x2F;articles&#x2F;000005779&#x2F;processors.html&quot;&gt;a spry 13 instructions&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;SSSE3&quot;&gt;SSSE3&lt;&#x2F;a&gt; (&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.intel.com&#x2F;content&#x2F;dam&#x2F;www&#x2F;public&#x2F;us&#x2F;en&#x2F;documents&#x2F;manuals&#x2F;64-ia-32-architectures-optimization-manual.pdf#G3.1106470&quot;&gt;32 instructions&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Advanced_Vector_Extensions&quot;&gt;AVX&lt;&#x2F;a&gt; (&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;40876094&quot;&gt;86 instructions&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Advanced_Vector_Extensions#Advanced_Vector_Extensions_2&quot;&gt;AVX2&lt;&#x2F;a&gt; (&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;a&#x2F;40876094&quot;&gt;137 instructions&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;AVX-512&quot;&gt;AVX-512&lt;&#x2F;a&gt;, itself a modular ISA extension containing sets of extensions comprised of F, CD, ER, PF, VL, DQ, BW, IFMA, VBMI, 4VNNIW, 4FMAPS, VPOPCNTDQ, VNNI, VBMI2, BITALG, VP2INTERSECT, GFNI, VPCLMULQDQ, and VAES, though no CPU implements all of these.&lt;&#x2F;li&gt;
&lt;li&gt;AVX-VNNI, AVX-IFMA, AVX10, APX...&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The list goes on. I&#x27;ll give you a sneak peek into just &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.felixcloutier.com&#x2F;x86&#x2F;gf2p8affineinvqb&quot;&gt;one&lt;&#x2F;a&gt; AVX-512 instruction, but they all look like this:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;VGF2P8AFFINEINVQB zmm1{k1}{z}, zmm2, zmm3&#x2F;m512&#x2F;m64bcst, imm8&lt;&#x2F;code&gt;: Computes inverse affine transformation in the finite field GF(2^8). Galois Field New instructions can be used to create Rijndael S-boxes&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Imagine one of these instructions for every power of two between 64 and 512. (Okay, only four, but the point still stands.)&lt;&#x2F;p&gt;
&lt;p&gt;While AVX and other SIMD implementations do remain optional (similar to the modular nature of RISC-V), as you can see above, it&#x27;s still extremely complex. Perhaps this sufficiently demonstrates the motivation behind the simpler design philosophy that &lt;code&gt;RV32V&lt;&#x2F;code&gt; took on.&lt;&#x2F;p&gt;
&lt;p&gt;Okay, enough about SIMD - let&#x27;s get into &lt;code&gt;RV32V&lt;&#x2F;code&gt; and how it works.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;RV32V&lt;&#x2F;code&gt; is similar enough to existing data-level parallelism (DLP) instructions like SIMD - providing ways to operate on many pieces of data simultaneously. &lt;&#x2F;p&gt;
&lt;p&gt;However, rather than hard-coding the sizes and operations in the operation, these are arguments to the instruction - meaning you don&#x27;t need 10 different variants for every operation, 4 different variants for every size, etc. This drastically reduces the number of instructions needed to perform a wide variety of DLP functions.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Separating the vector length and maximum operations per clock cycle from the instruction encoding is the crux of the vector architecture&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;The assembler places information like the vector length, operation, and data type in the vector registers, where the instruction reads it. This dynamic form of typing gives two crucial new features:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Reduced instruction count (since vector type information is dynamic)&lt;&#x2F;li&gt;
&lt;li&gt;Improved efficiency and faster interrupts by disabling unused registers (since vector length information is known)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;In addition, &lt;code&gt;RV32V&lt;&#x2F;code&gt; defines vector bitmasks which allow choosing whether or not to perform the operation on each vector element. These are stored in the vector predicate registers (&lt;code&gt;vpi&lt;&#x2F;code&gt;) and allow for simple conditional vector computation without branching. There are also four vector predicate instructions that perform logical operations on multiple bitmasks, to simplify nested conditional operations.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;general-trivia&quot;&gt;General trivia&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;code&gt;RISC-V&lt;&#x2F;code&gt; contains three main privilege levels:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Machine mode (runs most trusted code)
&lt;ul&gt;
&lt;li&gt;Provides full access to memory, IO, and system features&lt;&#x2F;li&gt;
&lt;li&gt;Ability to intercept exceptions&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;Supervisor mode (support for operating systems)
&lt;ul&gt;
&lt;li&gt;Page-based virtual memory&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;User mode (application code)
&lt;ul&gt;
&lt;li&gt;Cannot access privileged resources, CSRs, or other&#x27;s memory (via Physical Memory Protection, where M-mode defines memory access rules for U-mode)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;These privilege levels are required for implementations of standard operating systems. However, all processors must implement machine-mode as the bare minimum.&lt;&#x2F;p&gt;
&lt;p&gt;There are two kinds of errors:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Exceptions
&lt;ul&gt;
&lt;li&gt;Synchronous, at run-time, associated with an instruction&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;Interrupts
&lt;ul&gt;
&lt;li&gt;Asynchronous, triggered externally, and not associated with an instruction&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Traps exist to control these errors. A trap that moves to a higher privilege level is a &lt;strong&gt;vertical trap&lt;&#x2F;strong&gt; - one that does not is a &lt;strong&gt;horizontal trap&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;A mechanism called &lt;strong&gt;exception delegation&lt;&#x2F;strong&gt; exists to allow interrupts to be delegated to S-mode code without being rerouted through M-mode (to improve performance).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;additional-extensions&quot;&gt;Additional extensions&lt;&#x2F;h2&gt;
&lt;p&gt;The extensions mentioned previously serve as a solid basis for many use cases across computing. However, here is a list of ratified extensions for RISC-V.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;RVxxQ&lt;&#x2F;code&gt;: &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;riscv.org&#x2F;wp-content&#x2F;uploads&#x2F;2019&#x2F;12&#x2F;riscv-spec-20191213.pdf&quot;&gt;quad-precision floating point&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RVxxB&lt;&#x2F;code&gt;: &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;riscv&#x2F;riscv-bitmanip&#x2F;releases&#x2F;download&#x2F;1.0.0&#x2F;bitmanip-1.0.0-38-g865e7a7.pdf&quot;&gt;bit manipulation&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RVxxZk&lt;&#x2F;code&gt;: &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;riscv&#x2F;riscv-crypto&#x2F;releases&#x2F;download&#x2F;v1.0.1-scalar&#x2F;riscv-crypto-spec-scalar-v1.0.1.pdf&quot;&gt;scalar cryptography&lt;&#x2F;a&gt;
&lt;ul&gt;
&lt;li&gt;This one is a must-read for cryptography nerds out there.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RVxxH&lt;&#x2F;code&gt;: &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;five-embeddev.com&#x2F;riscv-priv-isa-manual&#x2F;Priv-v1.12&#x2F;hypervisor.html&quot;&gt;hypervisor extension&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;...and many more found &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;wiki.riscv.org&#x2F;display&#x2F;HOME&#x2F;Ratified+Extensions&quot;&gt;here&lt;&#x2F;a&gt; or &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;RISC-V#ISA_base_and_extensions&quot;&gt;here&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;code&gt;RISC-V&lt;&#x2F;code&gt; also standardizes profiles, which are sets of extensions standardized to meet certain needs. Here&#x27;s information about &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;riscv&#x2F;riscv-profiles&#x2F;blob&#x2F;main&#x2F;src&#x2F;profiles.adoc#rva22-profiles&quot;&gt;&lt;code&gt;RVA22&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, the profile you likely want to choose if you&#x27;re interested in general computing on &lt;code&gt;RISC-V&lt;&#x2F;code&gt; today (&lt;code&gt;RVA23&lt;&#x2F;code&gt; is still being finalized).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;hardware&quot;&gt;Hardware&lt;&#x2F;h2&gt;
&lt;p&gt;Here&#x27;s a list of hardware available today that you can use to tinker with. Note that I don&#x27;t own any of these (yet...). None of these links are sponsored. In addition, many of these devices are in an alpha state, being very unstable for regular use, until drivers are written in a better state. Don&#x27;t expect 4k YouTube streaming yet.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;sbc&quot;&gt;SBC&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.banana-pi.org&#x2F;en&#x2F;BPI-F3&#x2F;BananaPi_BPI-F3&quot;&gt;Banana Pi BPI-F3&lt;&#x2F;a&gt; - SpacemiT K1 CPU&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;milkv.io&#x2F;mars&quot;&gt;Milk-V Mars&lt;&#x2F;a&gt; - StarFive JH7110 CPU&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.riscfive.com&#x2F;product&#x2F;visionfive-2&#x2F;&quot;&gt;VisionFive 2&lt;&#x2F;a&gt; - StarFive JH7110 CPU&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;laptops&quot;&gt;Laptops&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;arace.tech&#x2F;products&#x2F;muse-book-risc-v-laptop?variant=43275737268404&quot;&gt;MuseBook&lt;&#x2F;a&gt; - SpacemiT M1 CPU&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;store.deepcomputing.io&#x2F;products&#x2F;dc-roma-risc-v-laptop&quot;&gt;DC-ROMA Laptop&lt;&#x2F;a&gt; - Alibaba T-Head TH1520 CPU&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;store.deepcomputing.io&#x2F;products&#x2F;dc-roma-riscv-laptop-ii-with-octa-core-cpu&quot;&gt;DC-ROMA Laptop II&lt;&#x2F;a&gt; - SpacemiT K1 CPU&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;wiki.sipeed.com&#x2F;hardware&#x2F;en&#x2F;lichee&#x2F;th1520&#x2F;lcon4a&#x2F;lcon4a.html&quot;&gt;Sipeed Lichee Console 4A (mini netbook)&lt;&#x2F;a&gt; - TH1520 SOM&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;frame.work&#x2F;blog&#x2F;introducing-a-new-risc-v-mainboard-from-deepcomputing&quot;&gt;Upcoming Frame.work RISC-V mainboard&lt;&#x2F;a&gt; - StarFive JH7110 CPU&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;workstations&quot;&gt;Workstations&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;store.deepcomputing.io&#x2F;products&#x2F;dc-roma-workstation&quot;&gt;DC StationV D300&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;milkv.io&#x2F;pioneer&quot;&gt;Milk-V Pioneer&lt;&#x2F;a&gt; - SOPHON SG2042 CPU&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;flash-cards&quot;&gt;Flash cards&lt;&#x2F;h2&gt;
&lt;p&gt;I hope you came away from this article more interested in &lt;code&gt;RISC-V&lt;&#x2F;code&gt;! In just this short article, I (hope I) gave you working knowledge of some of the design choices and structure of the instruction set.&lt;&#x2F;p&gt;
&lt;p&gt;If you want to commit this information to memory, whether you&#x27;re interested in a career in it or because you simply find an open-licensed, modern ISA to be fascinating, you can find a flashcard set below.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;app.mochi.cards&#x2F;decks&#x2F;62c649cd-0fff-4670-947d-4675f77b0ffa&#x2F;VjA7dOHC&#x2F;RISCV&quot;&gt;Mochi.cards shared deck&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;&#x2F;static&#x2F;RISC-V.mochi&quot;&gt;Mochi.cards .mochi file&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;&#x2F;static&#x2F;RISC-V.zip&quot;&gt;Markdown style cards&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Why? Well, some of my favorite articles from around the web have tickled just the right neurons, so much so that I created flash cards for all of the content within, and study it (among the rest of my decks) every day. Not so much out of relevancy (though one day I&#x27;ll get my dream of a working-OOTB RISC-V laptop!), but out of the joy of learning.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;sources&quot;&gt;Sources&lt;&#x2F;h2&gt;
&lt;p&gt;I consulted a number of sources while writing this article. Of course including the foundational text &amp;quot;The RISC-V Reader: An Open Architecture Atlas&amp;quot;, but also:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;riscv.org&#x2F;wp-content&#x2F;uploads&#x2F;2019&#x2F;12&#x2F;riscv-spec-20191213.pdf&quot;&gt;The RISC-V Instruction Set Manual&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;osblog.stephenmarz.com&#x2F;index.html&quot;&gt;Stephen Marz&#x27;s awesome blog: The Adventures of OS: Making a RISC-V Operating System using Rust&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.felixcloutier.com&#x2F;x86&#x2F;&quot;&gt;Félix Cloutier&#x27;s x86 and amd64 instruction reference&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20190222083348&#x2F;http:&#x2F;&#x2F;logos.cs.uic.edu&#x2F;366&#x2F;notes&#x2F;mips%20quick%20tutorial.htm&quot;&gt;MIPS Architecture and Assembly Language Overview&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;link.springer.com&#x2F;book&#x2F;10.1007&#x2F;978-3-662-10345-6&quot;&gt;The Illiac IV: The First Supercomputer&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;danielmangum.com&#x2F;risc-v-tips&#x2F;&quot;&gt;Various RISC-V tips from Daniel Mangum&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>I built a SaaS in 24 hours</title>
        <published>2024-04-23T00:00:00+00:00</published>
        <updated>2024-04-23T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="//matthew.science/posts/focusguardian/" type="text/html"/>
        <id>//matthew.science/posts/focusguardian/</id>
        
        <content type="html">&lt;p&gt;This weekend, I participated in &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;tribehacks.com&#x2F;&quot;&gt;TribeHacks IX&lt;&#x2F;a&gt; at my university, William &amp;amp; Mary.&lt;&#x2F;p&gt;
&lt;p&gt;My submission, FocusGuardian, is a service that allows you to define rules that will block any service you choose. Are you a chronic late night scroller? Block Instagram and TikTok after 10PM. Are you guilty of checking Hacker News constantly during your classes or at work? Block it M-F, 9-5.&lt;&#x2F;p&gt;
&lt;p&gt;Since it&#x27;s DNS based, it can be blocked at any time, on all of your devices, and will truly act as a network block. The reason why I built this instead of using existing solutions like Apple&#x27;s Screen Time or Opal, or browser extensions, are as follows:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;I need something that works across all of my devices, as I am just as likely to consume on my laptop as I am my phone&lt;&#x2F;li&gt;
&lt;li&gt;I need something that can&#x27;t be easily bypassed. At this point, I have been trained to bypass Apple&#x27;s Screen Time prompts by clicking &amp;quot;ignore&amp;quot; every day, it&#x27;s almost muscle memory. So I want something that won&#x27;t stop me from opening the app but rather break its functionality, so I&#x27;m more aware of the block.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The possibility of scheduling the blocks also serves to put myself in a routine - if I know I will have an hour of social media at the end of the day, I won&#x27;t constantly check it throughout the day. In my experience that&#x27;s better than just limiting it to one hour for the whole day, because I could quickly burn through it, and there&#x27;s no schedule I&#x27;m forcing myself into.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;inspiration&quot;&gt;Inspiration&lt;&#x2F;h2&gt;
&lt;p&gt;I thought to myself, what if I just program a DNS server to do this? That sounds like it&#x27;d work - just return a &lt;code&gt;0.0.0.0&lt;&#x2F;code&gt; response if it needs to be blocked. I could parse some rules to decide live whether a DNS request should be permitted or blocked, then just pass it up to a recursive DNS resolver if it&#x27;s allowed.&lt;&#x2F;p&gt;
&lt;p&gt;I would need to make it DNS over HTTPS, though - I could NOT buy an IPV4 address for every user, so DNS over UDP and TLS were out of the question. DoH, however, allows you to set whatever path you want for the query, meaning you could make the endpoint &lt;code&gt;https:&#x2F;&#x2F;dns.focusguardian.org&#x2F;USER_ID&#x2F;dns-query&lt;&#x2F;code&gt;, and it would be specific to one user&#x27;s rules and schedules.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;selling-points&quot;&gt;Selling Points&lt;&#x2F;h2&gt;
&lt;p&gt;My idea distinguishes itself from existing solutions by addressing some limitations and offering unique features:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cross-Device Compatibility:&lt;&#x2F;strong&gt; Unlike some existing solutions such as Apple&#x27;s Screen Time or browser extensions, FocusGuardian operates seamlessly across all devices, including laptops, smartphones, and tablets. This ensures consistent distraction-blocking functionality regardless of the device being used.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Enhanced Blocking Mechanism:&lt;&#x2F;strong&gt; Traditional solutions often rely on prompts or restrictions that users can easily bypass. In contrast, FocusGuardian employs a DNS-based blocking mechanism that effectively prevents access to specified services.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Flexible Scheduling:&lt;&#x2F;strong&gt; By allowing users to schedule distraction-blocking rules based on specific times and days, FocusGuardian promotes the establishment of healthy digital habits. This flexibility enables users to tailor their usage restrictions to their individual routines and preferences, ultimately fostering more productive and balanced lifestyles.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I&#x27;m not sure how differentiated I am in reality from the existing market (such as Opal), but hey, I spent my 24 hours coding, not doing market analysis. :)&lt;&#x2F;p&gt;
&lt;h2 id=&quot;frontend&quot;&gt;Frontend&lt;&#x2F;h2&gt;
&lt;p&gt;So, I got started! I whipped up a Vue&#x2F;Vite&#x2F;TailWind frontend in a few hours, with tabs for information on how this can be beneficial to parents, students, etc. I&#x27;m NOT a frontend developer (last year, my hackathon submission was hand-written HTML fragments being returned by a Rust backend and it looked... subpar). But, in the past year, I&#x27;ve been building Vue frontends for side projects, and I&#x27;d like to say I&#x27;m passable by now.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;fg-frontend.png&quot; alt=&quot;Screenshot of the frontend&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I wanted a landing page to be done first, since that&#x27;s what gets looked at for the hackathon. For my own sake I spent the vast majority of my time on working on the actual functionality but making it look pretty is really what gets you points.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;backend&quot;&gt;Backend&lt;&#x2F;h2&gt;
&lt;p&gt;Next - the backend. I started writing writing some sample code that parsed DNS over HTTPS requests in Rust. I was nose-deep in the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.rfc-editor.org&#x2F;rfc&#x2F;rfc8484&quot;&gt;RFC&lt;&#x2F;a&gt; and implementing the two possible methods that could be used. At first, I simply proxied to Quad9&#x27;s DoH endpoint, but that quickly proved too slow - it adds the entire latency of another HTTPS request. I switched to a local resolver issued over UDP.&lt;&#x2F;p&gt;
&lt;p&gt;I tried adding the DoH configuration to Firefox to test, and success! I could see the requests being proxied and Firefox worked as expected. &lt;&#x2F;p&gt;
&lt;h4 id=&quot;apple-cannot-adhere-to-spec-ever&quot;&gt;Apple cannot adhere to spec, ever.&lt;&#x2F;h4&gt;
&lt;p&gt;I used &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;dns.notjakob.com&#x2F;&quot;&gt;this site&lt;&#x2F;a&gt; to generate a DoH profile for my phone. But alas, even when my DNS resolver follows spec, Apple does not work. You need to add support for POST&#x2F;GET requests, where GET requests could have a &lt;code&gt;dns&lt;&#x2F;code&gt; parameter or a &lt;code&gt;name&lt;&#x2F;code&gt; and &lt;code&gt;type&lt;&#x2F;code&gt; parameter - where &lt;code&gt;dns&lt;&#x2F;code&gt; is a base64-encoded DNS packet, or &lt;code&gt;name&lt;&#x2F;code&gt; is a domain and &lt;code&gt;type&lt;&#x2F;code&gt; is a DNS packet type. This involves manually constructing a DNS packet if they decided to send it as the latter case.&lt;&#x2F;p&gt;
&lt;p&gt;Maybe I was just sleep deprived at the time but this implies Apple doesn&#x27;t adhere to the DoH spec. That&#x27;s okay, I handled that case and Apple was working perfectly!&lt;&#x2F;p&gt;
&lt;p&gt;Now to write some of the actual rule&#x2F;scheduling&#x2F;user code.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;user-database&quot;&gt;User database&lt;&#x2F;h2&gt;
&lt;p&gt;I have used &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;pocketbase.io&#x2F;&quot;&gt;Pocketbase&lt;&#x2F;a&gt; in the past - it&#x27;s an absolutely magical self-hosted FOSS Firebase alternative. It handles user authentication, OAuth (sign in with all the services), tables with auth rules, etc. I was able to very quickly get started with it, by using two tables - manual vs scheduled rules - each one associated with a user and list of services.&lt;&#x2F;p&gt;
&lt;p&gt;I modified the Rust backend to grab from the database periodically, then parse the list of schedules&#x2F;services into a database. The backend then would first check on any DNS requests if the user has an active rule for that service. If so, it would modify the returned IP to be 0.0.0.0 (this is generally the agreed-upon way - &lt;code&gt;NXDOMAIN&lt;&#x2F;code&gt; responses could have the OS use a backup DNS server which would be bad).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;service-list&quot;&gt;Service list&lt;&#x2F;h3&gt;
&lt;p&gt;I didn&#x27;t want to manually collect a long list of services and their associated list of domains, but I had remembered that the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;AdguardTeam&#x2F;AdGuardHome&#x2F;&quot;&gt;AdGuard Home&lt;&#x2F;a&gt; server I run does have the option of blocking services, so they must have a list of these services and domain names associated with each one. And indeed, they do! Buried in the source code is a list - so I had my code parse that and build a list of services supported for my website. (I manually added Hacker News since it wasn&#x27;t there and that&#x27;s my worst procrastination tool)&lt;&#x2F;p&gt;
&lt;h2 id=&quot;frontend-pt-2&quot;&gt;Frontend pt 2&lt;&#x2F;h2&gt;
&lt;p&gt;Now, to write code that will allow me to add rules on the fly. &lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;fg-rule.png&quot; alt=&quot;Screenshot of the UI that allows adding a rule by name, service, and time&#x2F;day&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After a lot of searching about Vue forms, I finally have a component to add rules! After integrating with PocketBase, it&#x27;s as easy as:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;js&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-js &quot;&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;await &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;pb&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;collection&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;scheduled_rules&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;).&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;create&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;bodyParams&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I wrote some code to handle the case where the rule isn&#x27;t scheduled but rather manual, and we were off to the races.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;mobile-app&quot;&gt;Mobile App&lt;&#x2F;h2&gt;
&lt;p&gt;Upon making the desktop site, I realized: I was definitely not good at making responsive Vue sites. The create rule component notably was extremely poor when viewed on mobile. I researched some solutions for creating mobile apps in a cross-platform manner and found the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;ionicframework.com&#x2F;&quot;&gt;Ionic Framework&lt;&#x2F;a&gt; which served me very well. I got a simple proof of concept working quickly, and it looked decent.&lt;&#x2F;p&gt;
&lt;img src=&quot;&#x2F;imgs&#x2F;mobile.png&quot; alt=&quot;Demo of the mobile app, with a similar UI to the desktop app, but with a menu along the bottom&quot; width=&quot;300&quot;&#x2F;&gt;
&lt;p&gt;At this point, I had a working website, a demo mobile app written in Ionic, and instructions on how to add FocusGuardian for every common platform (Windows, Mac OS, Linux, Firefox, Chrome, iOS, iPad OS, etc). But, this wasn&#x27;t cool enough. For those manual rules, is it really the best decision to have to open your computer to visit the site to enable it? I wanted a hardware solution that would allow me to enable&#x2F;disable my rules without using a browser.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;hardware-prototype&quot;&gt;Hardware prototype&lt;&#x2F;h2&gt;
&lt;p&gt;I had so many old pieces of hardware laying around, from ESP32s and RPi Zeros. None of those would be enough for a consumer-facing prototype, but I had one secret weapon - a LilyGo T-QT.&lt;&#x2F;p&gt;
&lt;img src=&quot;&#x2F;imgs&#x2F;t-qt.png&quot; alt=&quot;Image of the T-QT, a very small ESP32 device with a screen and two buttons&quot; width=&quot;350&quot;&#x2F;&gt;
&lt;p&gt;This bad boy is incredibly small, yet has buttons and a screen! That&#x27;s all you need, really. Can we go back to the blackberry&#x27;s now?&lt;&#x2F;p&gt;
&lt;p&gt;So, I got to coding - Surely I could learn LVGL in the 12 hours left.&lt;&#x2F;p&gt;
&lt;p&gt;I began by simply modifying the sample program, a duck waddling gif, and added &amp;quot;text&amp;quot;. That worked okay.&lt;&#x2F;p&gt;
&lt;p&gt;Now, to mock rendering the rules. We will write code to actually parse from the database, but below, I will fake it.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;c++&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-c++ &quot;&gt;&lt;code class=&quot;language-c++&quot; data-lang=&quot;c++&quot;&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;static char*&lt;&#x2F;span&gt;&lt;span&gt; rules[] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;instagram&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;hn&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;};
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;static bool*&lt;&#x2F;span&gt;&lt;span&gt; enabled[] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;false&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;true&lt;&#x2F;span&gt;&lt;span&gt;};
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;static int&lt;&#x2F;span&gt;&lt;span&gt; current_rule &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;static int&lt;&#x2F;span&gt;&lt;span&gt; max_rule &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a0a1a7;&quot;&gt;&#x2F;&#x2F; In refresh_debug
&lt;&#x2F;span&gt;&lt;span&gt;lv_obj_t &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;*&lt;&#x2F;span&gt;&lt;span&gt;debug_label &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;lv_label_create&lt;&#x2F;span&gt;&lt;span&gt;(src);
&lt;&#x2F;span&gt;&lt;span&gt;String text;
&lt;&#x2F;span&gt;&lt;span&gt;text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;Rules&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0997b3;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;for &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;int&lt;&#x2F;span&gt;&lt;span&gt; i &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;; i &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt; max_rule; i&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;++&lt;&#x2F;span&gt;&lt;span&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(i &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;==&lt;&#x2F;span&gt;&lt;span&gt; current_rule) {
&lt;&#x2F;span&gt;&lt;span&gt;    text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;&amp;gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;  } &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;else &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;    text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;   &amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;  text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;#39;[&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(enabled[i]) {
&lt;&#x2F;span&gt;&lt;span&gt;    text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;X&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;  } &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;else &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;    text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;   &amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a0a1a7;&quot;&gt;&#x2F;&#x2F; no monospace fonts, sorry!
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;  text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;] &amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;  text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+=&lt;&#x2F;span&gt;&lt;span&gt; rules[i];
&lt;&#x2F;span&gt;&lt;span&gt;  text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0997b3;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;lv_label_set_text&lt;&#x2F;span&gt;&lt;span&gt;(debug_label, text.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;c_str&lt;&#x2F;span&gt;&lt;span&gt;());
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;lv_obj_align&lt;&#x2F;span&gt;&lt;span&gt;(debug_label, LV_ALIGN_TOP_LEFT, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;);
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a0a1a7;&quot;&gt;&#x2F;&#x2F; If the toggle button is pressed
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(enabled[current_rule]) {
&lt;&#x2F;span&gt;&lt;span&gt;  enabled[current_rule] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;true&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;} &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;else &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;  enabled[current_rule] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;false&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;refresh_debug&lt;&#x2F;span&gt;&lt;span&gt;();
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a0a1a7;&quot;&gt;&#x2F;&#x2F; If the scroll button is pressed
&lt;&#x2F;span&gt;&lt;span&gt;current_rule &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;(current_rule &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;%&lt;&#x2F;span&gt;&lt;span&gt; max_rule;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This was pretty good! I could simulate &amp;quot;scrolling through&amp;quot; the rules (updating where the &lt;code&gt;&amp;gt;&lt;&#x2F;code&gt; character was) with the right button, and use the left button to toggle the currently selected rule. Now for actually integrating with the database.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;https-on-the-esp32&quot;&gt;HTTPS on the ESP32&lt;&#x2F;h3&gt;
&lt;p&gt;Getting HTTPS working on the ESP32 was really the most difficult part of this project. I ended up simply disabling TLS certificate validation. It&#x27;s still encrypted, but anyone who can control the connection could MITM by presenting any TLS certificate. Unfortunate, and obviously not ideal, but this will be just fine for my one-day-long hackathon. I&#x27;m well aware of the security implications, and will be iterating on this to find the best solution if I bring this to fruition.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;parsing&quot;&gt;Parsing&lt;&#x2F;h3&gt;
&lt;p&gt;JSON parsing was pretty easy - I mostly just used the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;arduinojson.org&#x2F;&quot;&gt;ArduinoJson&lt;&#x2F;a&gt; library. It became pretty easy to parse responses into the global rules array (once I switched to using Strings!).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;demoing-the-hardware&quot;&gt;Demoing the hardware&lt;&#x2F;h3&gt;
&lt;p&gt;Approximately 10 minutes before the deadline, I filmed my demo for the project, including the hardware.&lt;&#x2F;p&gt;
&lt;video width=&quot;320&quot; height=&quot;240&quot; controls alt=&quot;Video demo of the hardware&quot;&gt;
  &lt;source src=&quot;&#x2F;imgs&#x2F;hwdemo.mp4&quot; type=&quot;video&#x2F;mp4&quot;&gt;
&lt;&#x2F;video&gt;
&lt;h2 id=&quot;summary-of-my-tech-stack&quot;&gt;Summary of my tech stack&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Rust-based DNS backend (handles processing DNS requests, keeping up-to-date with newly created rules, and generating Apple MobileConfigs)&lt;&#x2F;li&gt;
&lt;li&gt;Vue-based frontend&lt;&#x2F;li&gt;
&lt;li&gt;Ionic-based mobile app demo (still being worked on)&lt;&#x2F;li&gt;
&lt;li&gt;Go-based user database (PocketBase + custom Go)&lt;&#x2F;li&gt;
&lt;li&gt;C++-based software on the embedded hardware&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Juggling it all had me accidentally writing Rusty &lt;code&gt;let x&lt;&#x2F;code&gt; in JavaScript, C++&#x27;y &lt;code&gt;const *&lt;&#x2F;code&gt; in Go, etc. I don&#x27;t think this stack is too much; it fulfills my needs at exactly the right complexity, and none of it seems over- or under-engineered for my needs. But just having 24 hours of switching between all of them to become proficient enough to get out a fully-working prototype hurt my head a &lt;strong&gt;lot&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;reviews-of-my-tech-stack&quot;&gt;Reviews of my tech stack&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Rust: &lt;b&gt;10&#x2F;10&lt;&#x2F;b&gt;. I&#x27;m very experienced in Rust, so I&#x27;m biased and well over the learning curve for a simple project like this. Rust&#x27;s performance-strong characteristics reassure me I didn&#x27;t leave any performance on the table by not choosing another language.&lt;&#x2F;li&gt;
&lt;li&gt;Vue: &lt;b&gt;9&#x2F;10&lt;&#x2F;b&gt;. Really good dev experience, plenty of libraries for most of the things I wanted to do.&lt;&#x2F;li&gt;
&lt;li&gt;Ionic: &lt;b&gt;7.8&#x2F;10&lt;&#x2F;b&gt;. Pretty good, though I didn&#x27;t get this working in time, I could easily freshen it up in a weekend.&lt;&#x2F;li&gt;
&lt;li&gt;PocketBase&#x2F;Go: &lt;b&gt;10&#x2F;10&lt;&#x2F;b&gt;. PocketBase makes it incredibly easy to turn a proof of concept web app into a SaaS while saving me from all of the pain of user authentication, OAuth, databases, etc.
&lt;ul&gt;
&lt;li&gt;MailPace for transactional emails: &lt;b&gt;10&#x2F;10&lt;&#x2F;b&gt;, awesome and dead-simple to integrate with Pocketbase for all of the sign-up&#x2F;reset emails (and I wrote the Rust library for it, so if I need to email from the backend, I can do so easily!).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;C++: &lt;b&gt;5&#x2F;10&lt;&#x2F;b&gt;. I have experience working with ESP32 as a platform but it was my first time learning LVGL. Definitely harder to pick up and start hacking with, but I also was down to a few hours. Maybe I disliked it more because I was closer to the deadline when I started working on it?&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;results&quot;&gt;Results&lt;&#x2F;h2&gt;
&lt;p&gt;The results of this hackathon were three-fold.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;&#x2F;&gt;
I was very happy to find I could bang out a functional, ready-for-launch SaaS in 24 hours, that could expand into B2C hardware (irrespective of how good the idea is - truthfully I am unsure about demand, so this was more of a technical challenge)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;&#x2F;&gt;
I was doubly happy to get the hardware working - I want to work on a proper first iteration, on a larger device, and get all of the kinks out.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;&#x2F;&gt;
I won best hardware hack!&lt;&#x2F;li&gt;
&lt;li&gt;&lt;input disabled=&quot;&quot; type=&quot;checkbox&quot; checked=&quot;&quot;&#x2F;&gt;
I did this all solo, without any external help!&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;All in all, a very fun experience!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;what-s-next-for-focusguardian&quot;&gt;What&#x27;s next for FocusGuardian&lt;&#x2F;h1&gt;
&lt;p&gt;I am launching &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;focusguardian.org&quot;&gt;FocusGuardian&lt;&#x2F;a&gt; as a fully featured SaaS today, in a pilot program. &lt;&#x2F;p&gt;
&lt;p&gt;Until June&#x2F;July, &lt;strong&gt;I won&#x27;t add any code that checks for premium status&lt;&#x2F;strong&gt; - so if you want to try out how premium feels, you may sign up and utilize those unlimited rules and ad-blocking without paying. &lt;&#x2F;p&gt;
&lt;p&gt;But if you want to help me recoup some of the costs of the server, domain, hardware, the Celsius&#x27;s consumed while being built, etc, and feel like you get enough value from it, feel free to click upgrade on the pricing page.&lt;&#x2F;p&gt;
&lt;p&gt;Free plan allows for two scheduled rules, and two manual rules. As well as unlimited DNS requests&#x2F;devices&#x2F;etc.&lt;&#x2F;p&gt;
&lt;p&gt;Paid plan allows unlimited rules, ad blocking, requesting additional services for blocking, and first access to a hardware client, should I turn that into a full project (provided interest is there).&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;m starting out the paid plan at $5&#x2F;mo, $55&#x2F;yr (with a discount to $2.50&#x2F;mo, $27.50&#x2F;yr - see &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;focusguardian.org&#x2F;pricing&quot;&gt;pricing page&lt;&#x2F;a&gt;).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;feedback&quot;&gt;Feedback&lt;&#x2F;h2&gt;
&lt;p&gt;If you have feedback about absolutely anything, send me an email at admin @ the domain (either one). Do you think you&#x27;d be interested in paying for a product like this eventually? Or would you use the hardware solution? I would greatly appreciate if you signed up today and started using it, and providing feedback!&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;mailto:feedback@focusguardian.org&quot;&gt;Send me a letter!&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;focusguardian.org&quot;&gt;You can visit FocusGuardian here!&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Analyzing 106,090 YikYak posts from my university</title>
        <published>2024-04-22T00:00:00+00:00</published>
        <updated>2024-04-22T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="//matthew.science/posts/yikyak/" type="text/html"/>
        <id>//matthew.science/posts/yikyak/</id>
        
        <content type="html">&lt;p&gt;First, some background!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;background&quot;&gt;Background&lt;&#x2F;h3&gt;
&lt;p&gt;YikYak is an anonymous social media app common on college campuses. Even on my own campus, it&#x27;s done some &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.npr.org&#x2F;sections&#x2F;alltechconsidered&#x2F;2015&#x2F;07&#x2F;13&#x2F;422620195&#x2F;on-college-campuses-suicide-intervention-via-anonymous-app&quot;&gt;good&lt;&#x2F;a&gt;. It was very popular between 2013 and 2015, finally shutting down in 2017, mostly due to higher education administrations cracking down on the app - but the rights were sold to Square and resold to another company in 2021. They relaunched in the same year, growing moderate popularity again. &lt;&#x2F;p&gt;
&lt;p&gt;In 2022, a student &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;theresponsetimes.com&#x2F;yikyak-is-exposing-user-locations&#x2F;&quot;&gt;identified a flaw in the API that returned precise location data for every post&lt;&#x2F;a&gt; (Note: Location &lt;em&gt;was&lt;&#x2F;em&gt; a key part of the app as communities were by geolocation. But the precise coordinates to 15 ft was an issue.)&lt;&#x2F;p&gt;
&lt;p&gt;Finally, in 2023, YikYak was sold to Sidechat (a similar app). They essentially threw away most of the codebase, reskinned Sidechat to look like YikYak, and now dual-list them.&lt;&#x2F;p&gt;
&lt;p&gt;The culture of YikYak is pretty interesting - it&#x27;s a fully anonymous app on a university campus, so it&#x27;s conducive to posting about stress, exams, classes, photographs of nature&#x2F;animals on campus, personal relationship problems, information about events, gossip on the campus&#x27;s student assembly elections, etc. Generally, unfiltered thoughts by anyone on campus.&lt;&#x2F;p&gt;
&lt;p&gt;Now that you have some context, let me get into how I scraped all 106,090 posts.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;javascript&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-javascript &quot;&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;var &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;cursor &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;while &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;true&lt;&#x2F;span&gt;&lt;span&gt;) {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;let &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;posts &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= await &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;getPosts&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;group&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;cursor&lt;&#x2F;span&gt;&lt;span&gt;);
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;posts&lt;&#x2F;span&gt;&lt;span&gt;.length &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;=== &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;break&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;addPosts&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;posts&lt;&#x2F;span&gt;&lt;span&gt;);
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Yes, it really was that simple. Huge shoutout to Micah Lindley, who developed the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;micahlt&#x2F;sidechat.js&quot;&gt;sidechat.js&lt;&#x2F;a&gt; library I forked to get this to work.&lt;&#x2F;p&gt;
&lt;p&gt;Now that we have all of the posts, let&#x27;s analyze them. I used the &lt;code&gt;nltk.sentiment.vader&lt;&#x2F;code&gt; library for sentiment analysis, but otherwise, all columns already exist, and I simply shuffled them around (converting UTC to ET, binning to certain time intervals, etc).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;time-of-day-vs-frequency&quot;&gt;Time of day vs frequency&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;yikyak&#x2F;timefreq.png&quot; alt=&quot;Time frequency chart showing low frequency between 2 AM and 9 AM, then consistent evenly spread frequency the rest of the day&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Interesting how late the posts taper down. According to this frequency chart, there&#x27;s more people posting at 2 AM than 8 AM. Though I suspect there&#x27;s less people awake at 2 AM, they&#x27;re just perhaps more likely to post at 2 AM than 8 AM as they would likely be in class.&lt;&#x2F;p&gt;
&lt;p&gt;I also found the bump from 9 PM to 11 PM intriguing. More late-posting, I suppose. &lt;&#x2F;p&gt;
&lt;h2 id=&quot;day-vs-sentiment&quot;&gt;Day vs sentiment&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;yikyak&#x2F;sentiment_daily.png&quot; alt=&quot;Day vs sentiment chart - Friday, Saturday, and Sunday are high, Monday and Tuesday are medium, and Wednesday and Thursday are low&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This one is really cool - it shows how Friday, Saturday, and Sunday on average have a high sentiment score. This makes sense - college students love weekends, and Fridays are close enough to qualify.&lt;&#x2F;p&gt;
&lt;p&gt;The drop as the week comes around to Monday and Tuesday makes sense, as well. Though the drop on Wednesday and Thursday is more interesting. Perhaps as the week starts, people are feeling refreshed from the weekend, but by Wednesday and Thursday, they&#x27;re feeling more tired and stressed.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;time-of-day-vs-sentiment&quot;&gt;Time of day vs sentiment&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;yikyak&#x2F;sentiment_hourly.png&quot; alt=&quot;Time of day vs sentiment chart&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This one is one of my favorites. It charts average sentiment against the time of day it was posted, along with the volume of each interval (to show the variance). The sentiment around midnight is relatively low - almost the lowest of intervals - even with a pretty high sample size. Around 2 AM, the sentiment is relatively high, but the low sample size (as well as the next two intervals) means this data is les reliable.&lt;&#x2F;p&gt;
&lt;p&gt;Interestingly enough, the worst-sentimentality interval is 8 AM. This makes sense to me - university students don&#x27;t generally like early morning classes and might complain about it on YikYak. As the day continues on, sentiment improves. By 4 PM, there is a higher sentiment score - where many students may be leaving classes. It slightly declines until 8 PM, but the 10 PM interval is the highest interval there is. Perhaps students are happiest at night when they may be doing activities with friends.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;frequency-of-stress-related-words-vs-exam-periods&quot;&gt;Frequency of stress-related words vs exam periods&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;yikyak&#x2F;stress.png&quot; alt=&quot;Frequency of stress-related words vs exam periods chart&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This one is my favorite. It shows how words like &amp;quot;exam&amp;quot;, &amp;quot;study&amp;quot;, &amp;quot;stress&amp;quot;, etc peak during exam periods, as do &amp;quot;midterm&amp;quot; and &amp;quot;final&amp;quot; in their respective periods. Then, immediately following final periods, discussions about &amp;quot;grades&amp;quot; shoot upwards.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h2&gt;
&lt;p&gt;I really like doing this kind of analysis, from reverse engineering the API&#x27;s authentication mechanism, to charting and analyzing the data with Pandas + Jupyter Notebook. It&#x27;s normal to think, oh, I bet generally people are happier on weekends, but to actually quantify it on a graph is just awesome.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Now</title>
        <published>2024-03-03T00:00:00+00:00</published>
        <updated>2024-03-03T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="//matthew.science/now/" type="text/html"/>
        <id>//matthew.science/now/</id>
        
        <content type="html">&lt;h3 id=&quot;2024-11-01&quot;&gt;2024-11-01&lt;&#x2F;h3&gt;
&lt;p&gt;Currently I&#x27;m back in full swing in my fall semester at William &amp;amp; Mary! It&#x27;s going pretty well. &lt;&#x2F;p&gt;
&lt;h3 id=&quot;2024-06-29&quot;&gt;2024-06-29&lt;&#x2F;h3&gt;
&lt;p&gt;Right about now, I&#x27;m in the middle of an awesome internship at &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;memfault.com&quot;&gt;Memfault&lt;&#x2F;a&gt; in Boston! &lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s what you can find me doing most days!&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Watching the Red Sox&lt;&#x2F;li&gt;
&lt;li&gt;Visiting nearby art museums&lt;&#x2F;li&gt;
&lt;li&gt;Strolling the Longwood area, chasing geese to take pictures&lt;&#x2F;li&gt;
&lt;li&gt;Reading various books (currently into &lt;strong&gt;Hard-Boiled Wonderland and the End of the World&lt;&#x2F;strong&gt; and &lt;strong&gt;The RISC-V Reader: An Open Architecture Atlas&lt;&#x2F;strong&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Maintaining &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;redlib-org&#x2F;redlib&quot;&gt;Redlib&lt;&#x2F;a&gt; from various coffee shops&lt;&#x2F;li&gt;
&lt;li&gt;Telling myself I should really get a flip phone to stop the doomscrolling&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;!-- ![Fenway Park](&#x2F;imgs&#x2F;sox.webp =100x20) --&gt;
&lt;img src=&quot;&#x2F;imgs&#x2F;sox.webp&quot; alt=&quot;Fenway Park&quot; width=&quot;600&quot; style=&quot;width: 600px; height: 550px; object-fit: cover; object-position: center bottom;&quot;&gt;
&lt;img src=&quot;&#x2F;imgs&#x2F;museum.webp&quot; alt=&quot;Isabella Stewart Gardner Museum&quot; width=&quot;600&quot;&gt;
&lt;img src=&quot;&#x2F;imgs&#x2F;geese.jpg&quot; alt=&quot;Geese&quot; width=&quot;600&quot;&gt;
&lt;h3 id=&quot;2024-03-03&quot;&gt;2024-03-03&lt;&#x2F;h3&gt;
&lt;p&gt;Here&#x27;s what you can find me doing most days!&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Working at my lab developing &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;scholarworks.wm.edu&#x2F;honorstheses&#x2F;1651&#x2F;&quot;&gt;SCOPE&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;OSS contributions (mostly maintaining &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;redlib-org&#x2F;redlib&quot;&gt;Redlib&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Working on my side projects (save me side projects.. side projects...)&lt;&#x2F;li&gt;
&lt;li&gt;Laying on &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Sunken_Garden_(Virginia)&quot;&gt;Sunken Garden&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Taking photographs of absolutely anything and everything (gallery site to come, but for now, check these two out!)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;sunken.jpg&quot; alt=&quot;Sunken Garden&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;zable.jpg&quot; alt=&quot;Zable Stadium&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Exploring corners of campus&lt;&#x2F;li&gt;
&lt;li&gt;Maintaining servers in the sky&lt;&#x2F;li&gt;
&lt;li&gt;Biking around &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Colonial_Williamsburg&quot;&gt;Colonial Williamsburg&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Reviewing lectures for my computer science classes&lt;&#x2F;li&gt;
&lt;li&gt;Playing around with &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.rust-lang.org&#x2F;&quot;&gt;Rust&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Fixing Libreddit - now Redlib</title>
        <published>2024-01-17T00:00:00+00:00</published>
        <updated>2024-01-17T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="//matthew.science/posts/fixinglibreddit/" type="text/html"/>
        <id>//matthew.science/posts/fixinglibreddit/</id>
        
        <content type="html">&lt;p&gt;Have you heard of &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;libreddit&#x2F;libreddit&quot;&gt;Libreddit&lt;&#x2F;a&gt;? It&#x27;s an awesome front-end for Reddit that is lightweight and respects your privacy by proxying all requests through the backend. I am (was?) a maintainer for it for most of last year.&lt;&#x2F;p&gt;
&lt;p&gt;If you have heard of it, maybe you know it&#x27;s been subpar lately. All instances have been subject to an oppressive rate limit, meaning many instances (especially the most popular ones) regularly returned an error unless you were very lucky. This is a consequence of the tightening down that Reddit has done - they want to ban Reddit clients, scrapers, etc. Especially given the advent of enormous LLM training datasets that probably source from Reddit-based content... Reddit wants their money from these users. &lt;&#x2F;p&gt;
&lt;p&gt;But, if you know me, I wouldn&#x27;t let that slide. No one gets between the privacy-preserving front-ends and their content!&lt;&#x2F;p&gt;
&lt;p&gt;See, that&#x27;s funny, because I did unfortunately let it slide. For six months Libreddit largely didn&#x27;t work. I made a &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;libreddit&#x2F;libreddit&#x2F;pull&#x2F;819&quot;&gt;PR&lt;&#x2F;a&gt; fixing this, which keeps track of OAuth tokens and spoofs the most common clients from iOS and Android, respectively. I used the information from &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36086240&quot;&gt;this HN comment&lt;&#x2F;a&gt; and &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;gist.github.com&#x2F;hogseedy&#x2F;b149c5f1ad1b628ba00556c7d4a898f8&quot;&gt;this Gist&lt;&#x2F;a&gt; to create my first proof of concept. I sat on the PR for a while due to a number of factors, including possible legal objections to spoofing a mobile client, and the fact that Libreddit had a possible legal threat hanging over our heads due to the (looking back now, immediately obvious) trademark issue with the name. (Reddit only allows you to use their name if you use &amp;quot;XYZ For Reddit&amp;quot;). Not to mention, my semester was in full swing and my workload didn&#x27;t ever let up enough for me to have a full day to go through all of the changes necessary.&lt;&#x2F;p&gt;
&lt;p&gt;But it&#x27;s winter break! I&#x27;m relaxing at home with gads of free time, fingers twitching looking for a project to work on. So I patched up Libreddit, merged &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;redlib-org&#x2F;redlib&#x2F;issues&#x2F;2&quot;&gt;all of the outstanding PRs&lt;&#x2F;a&gt;, merged my OAuth credential spoofing, and replaced every &amp;quot;Libreddit&amp;quot; with &amp;quot;Redlib&amp;quot;. Here&#x27;s what I did, and some of the interesting things I ran into.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;I used &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;mitmproxy.org&#x2F;&quot;&gt;mitmproxy&lt;&#x2F;a&gt; on iOS and Android to intercept the token grabbing. The sample code was a great starting point, but I really wanted to match behavior best as possible. I had to sign into my Reddit account, though, as the Reddit app doesn&#x27;t currently allow account-less browsing. It only offers &amp;quot;anonymous&amp;quot; browsing if you have an account. 
&lt;ul&gt;
&lt;li&gt;The good news is, this anonymous browsing mode really is anonymous (or at least, the endpoint doesn&#x27;t require an account login to create a token).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;I wrote a bash script that scrapes the most recent iOS and Android app versions, to send along in the header.&lt;&#x2F;li&gt;
&lt;li&gt;I then tossed the iOS one, since much to my chagrin, telling Reddit you&#x27;re an anonymous iOS user will mean they block all content not deemed appropriate. Sticking to spoofing the Android client for now.&lt;&#x2F;li&gt;
&lt;li&gt;I wrote code to refresh the auth token after the 24 hours it lasts, just as the Android app does.&lt;&#x2F;li&gt;
&lt;li&gt;I sent along as many of the official app&#x27;s headers along for the ride, too, so there will be less of a chance of Reddit cracking down on Redlib&#x27;s requests.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Thanks to these changes, Redlib now works as an alternative to Libreddit, and hopefully a viable alternative to visiting Reddit itself. Report any bugs you find, please!&lt;&#x2F;p&gt;
&lt;p&gt;There won&#x27;t be an official instance, as I can&#x27;t guarantee uptime, but you can access a list of instances &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;redlib-org&#x2F;redlib-instances&#x2F;blob&#x2F;main&#x2F;instances.md&quot;&gt;here&lt;&#x2F;a&gt; (and contribute your own if you&#x27;re interested in supporting the project!).&lt;&#x2F;p&gt;
&lt;p&gt;Anyway, here&#x27;s the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;redlib-org&#x2F;redlib&quot;&gt;link to the repo&lt;&#x2F;a&gt;! &lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Building an occupancy sensor with a $5 ESP32 and a serverless DB</title>
        <published>2023-10-20T00:00:00+00:00</published>
        <updated>2023-10-20T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="//matthew.science/posts/occupancy/" type="text/html"/>
        <id>//matthew.science/posts/occupancy/</id>
        
        <content type="html">&lt;p&gt;Have you ever wanted to design a full end-to-end software solution to collect occupancy data across a college campus?&lt;&#x2F;p&gt;
&lt;p&gt;I didn&#x27;t think I would either, but here we are.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-inspiration&quot;&gt;The inspiration&lt;&#x2F;h2&gt;
&lt;p&gt;During my first year in college, we had Sodexo as our dining provider. They had a contract with &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.bluefox.io&#x2F;products&#x2F;count&quot;&gt;Bluefox&lt;&#x2F;a&gt;, who provides occupancy sensors to report the number of people within a dining hall. I&#x27;d like to think they used this data to improve dining hall operations. I couldn&#x27;t tell you what they &lt;em&gt;actually&lt;&#x2F;em&gt; used it for. I can say that after some FOIA requests a friend made that returned PDF&#x27;s with awful kerning, these devices work by counting smartphone MAC addresses from Bluetooth advertising packets. This was a pretty cool way for me to avoid crowds in the dining hall - toss the API call into Grafana, and you have a live chart of how busy the dining halls are.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-downfall&quot;&gt;The downfall&lt;&#x2F;h2&gt;
&lt;p&gt;Unfortunately, the university switched dining hall providers to Aramark. Aramark does not contract Bluefox to provide the same occupancy counts, which meant no more occupancy data, which meant no more skipping busy hours.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-climb-back&quot;&gt;The climb back&lt;&#x2F;h2&gt;
&lt;p&gt;The idea of tracking occupancy metrics with a bluetooth beacon was stuck in my head. What design decisions and considerations would you need to make?&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;How accurate is BLE beacon count, as a proxy for occupancy?
&lt;ul&gt;
&lt;li&gt;Some people carry around headphones, smartwatches, etc - but some don&#x27;t carry any devices at all (or keep Bluetooth off on their phone).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;How accurate is BLE beacon availability time, as a proxy for dwell time?
&lt;ul&gt;
&lt;li&gt;Can we use unique MAC addresses&#x27; churn to detect this?&lt;&#x2F;li&gt;
&lt;li&gt;Is the built-in MAC address randomization that is common across &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;source.android.com&#x2F;docs&#x2F;core&#x2F;connect&#x2F;wifi-mac-randomization-behavior&quot;&gt;many&lt;&#x2F;a&gt; different &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;support.apple.com&#x2F;guide&#x2F;security&#x2F;bluetooth-security-sec82597d97e&#x2F;web#sec18ee64d9d&quot;&gt;manufacturers&lt;&#x2F;a&gt; going to impact this? (Even though this privacy feature has &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;ieeexplore.ieee.org&#x2F;document&#x2F;9369628&quot;&gt;flaws&lt;&#x2F;a&gt;)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;How can we communicate the results back to a central server?
&lt;ul&gt;
&lt;li&gt;WiFi seems the obvious choice for me. Not every location will have easy-to-access WiFi, though.&lt;&#x2F;li&gt;
&lt;li&gt;LoRa could be an option, depending on the distribution of beacons. Here&#x27;s some &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;medium.com&#x2F;home-wireless&#x2F;what-is-the-range-of-a-lora-radio-411261e35f46&quot;&gt;range testing numbers&lt;&#x2F;a&gt;, though this is affected by the antenna&#x27;s gain and locations (here&#x27;s &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;yosensi.io&#x2F;posts&#x2F;what_is_the_real_range_of_lora&#x2F;&quot;&gt;another test&lt;&#x2F;a&gt; with a far higher range).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;How can we collect the data?
&lt;ul&gt;
&lt;li&gt;Should we use a time series database?&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;How can we analyze the data?
&lt;ul&gt;
&lt;li&gt;Can we predict trends in the longer time spans, excluding special events like homecoming weekend, finals week, etc?&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I found these questions tumbling around in my head, so I began with some preliminary testing - writing some simple code to count the number of devices detected on my laptop&#x27;s Bluetooth adapter. Success - it was surprisingly easy to write code to scan for &lt;code&gt;x&lt;&#x2F;code&gt; seconds every &lt;code&gt;y&lt;&#x2F;code&gt; seconds and save it to a SQLite database at regular intervals. So, I carried my laptop to dining halls, Chick-Fil-A, Starbucks, etc and waited.
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
And waited.
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
And waited.
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
I spent a lot of time collecting data while sipping on coffees and milkshakes. You know, for data collection purposes. This is all very academic, of course.
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
​No other reason.
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
​Anyway, accuracy - In smaller areas (like a single-room Starbucks), I found the count to be pretty accurate. At the very least it reflected trends in occupancy very quickly. When more people arrived, the charts quickly climbed. &lt;&#x2F;p&gt;
&lt;p&gt;In larger areas like dining halls, the counts seemed accurate by my guesstimate. There&#x27;s no way for me to count everyone in a dining hall, with complicated layouts and different seating areas, especially when I&#x27;m not certain of my bluetooth adapter&#x27;s range (is it picking up people on the terrace through the walls? etc). But it most definitely matched the trends around class changes - when classes got out, people went to eat, which rapidly increased the number of people I saw, and the number of beacons my laptop detected.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;long-term-deployment&quot;&gt;Long term deployment&lt;&#x2F;h2&gt;
&lt;p&gt;Okay, sounds great, it looks like we have some kind of method validation. But I don&#x27;t plan on cloning myself in every dining hall and sitting 24&#x2F;7, so what can we do to create a small device to collect the same data?&lt;&#x2F;p&gt;
&lt;h2 id=&quot;raspberry-pi-maybe&quot;&gt;Raspberry Pi - Maybe?&lt;&#x2F;h2&gt;
&lt;p&gt;My first thought was - Raspberry Pi Zero W. It&#x27;s small and cheap, has Wi-Fi and Bluetooth, and definitely is in stock somewhere on Earth. &lt;&#x2F;p&gt;
&lt;p&gt;I rewrote my simple code (in Rust, no less!) to handle everything gracefully (reboots, no network, adapter loss, etc). Linux Bluetooth is incredibly painful to handle in a headless way. Binding to DBus requires cross-compiler magic and not even Cross was getting me out of it. After struggling enough through a million different compiler flags, a power outage that caused me to lose my progress on the Makefile (also, yes I use Make with Rust), and at last setting up a QEMU bridge, I was able to get my binary to run on my Pi. I even wrote all of the patching magic to make it connect to Wi-Fi (try doing THAT headlessly, when there&#x27;s a portal you have to sign into!), install the necessary libraries on start-up, make a service to run my executable, and automagically update when I push a new update. Okay, that&#x27;s a lot of moving parts. Let&#x27;s boot it up and hope it works...&lt;&#x2F;p&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;br &#x2F;&gt;
&lt;p&gt;&lt;strong&gt;Nothing.&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;That&#x27;s right, absolutely nothing worked. Not even the automagic wifi connection via Mac address fiddling hacks. &lt;&#x2F;p&gt;
&lt;h2 id=&quot;moving-on&quot;&gt;Moving on&lt;&#x2F;h2&gt;
&lt;p&gt;If you&#x27;re smarter than me, you may have realized that&#x27;s &lt;del&gt;a bit&lt;&#x2F;del&gt; WAY too much complexity. We really do not need a whole Linux kernel at all. We need two things - reliable Wi-Fi, and reliable Bluetooth. Okay, so shelve the Pi Zero W and Orange Pi Zero W I bought. What&#x27;s this nonsense about a device that can do these two things at an even cheaper price and smaller footprint?...&lt;&#x2F;p&gt;
&lt;h2 id=&quot;esp32&quot;&gt;&lt;strong&gt;ESP32&lt;&#x2F;strong&gt;?&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;occupancy&#x2F;esp32c3.png&quot; alt=&quot;ESP32C3&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;On paper, it looks great - Wi-Fi, Bluetooth, extremely low power usage (🌱🌍♻️🌿🌞💚), very cheap, and very tiny.&lt;&#x2F;p&gt;
&lt;p&gt;I purchased one off of Amazon since I didn&#x27;t want to wait for overseas shipping (not losing momentum in a nerd snipe like this is &lt;strong&gt;CRITICAL&lt;&#x2F;strong&gt;). I bought a random &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.amazon.com&#x2F;dp&#x2F;B072HBW53G&quot;&gt;ESP32-WROOM-32 with an OLED display&lt;&#x2F;a&gt;, since I thought it would be cool to display the data on the screen live. I rewrote my data collection code in C++ form (away from Rust!) since the Rust ecosystem for ESP32 is not all the way there yet.&lt;&#x2F;p&gt;
&lt;p&gt;After fidgeting with the display code enough to get it working (&lt;code&gt;SSD1306Wire display(0x3c, 5, 4);&lt;&#x2F;code&gt; if you&#x27;re wondering), it worked great. I asked campus IT to whitelist the MAC address, wrote up some Cloudflare functions into a D1 database as my data ingest, and set out to work.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;deployment&quot;&gt;Deployment&lt;&#x2F;h2&gt;
&lt;p&gt;I &lt;del&gt;hid&lt;&#x2F;del&gt; placed my data collection device in my campus library on a crisp fall morning, sat myself down at my laptop, saw the data rolling in, and did a silent celebration. Off to my Principles class to learn about scope rules then...&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&#x2F;imgs&#x2F;occupancy&#x2F;chartfall.png&quot; alt=&quot;A picture showing my chart rapidly falling as it peaks&quot;&#x2F;&gt;
  &lt;figcaption&gt;Why did everyone leave Swem library and never come back???&lt;&#x2F;figcaption&gt;
&lt;&#x2F;figure&gt;
&lt;h3 id=&quot;obstacles&quot;&gt;Obstacles&lt;&#x2F;h3&gt;
&lt;p&gt;One major problem that I ran into was the poor specs of the random ESP32 device I had. &lt;&#x2F;p&gt;
&lt;p&gt;The above issue shows the device crashing at about 250 devices. At first, I was worried this was a bug with the result count being stored in a 1-byte number, like a u8 (thus capping at ~255 devices). A quick &lt;code&gt;Serial.print&lt;&#x2F;code&gt; made me realize it would crash also at about 249, 265, etc - randomly around this area. So, not a bit-overflow issue (at least, not in the integer part!).&lt;&#x2F;p&gt;
&lt;p&gt;Our library fills up quickly with studious twamps - it wouldn&#x27;t last a minute in finals season if it couldn&#x27;t handle any more than that. &lt;&#x2F;p&gt;
&lt;h3 id=&quot;the-problem-identified&quot;&gt;The problem - identified&lt;&#x2F;h3&gt;
&lt;p&gt;By saving the results during a scan into a data structure until the end of the scan, it piled up data about the device&#x27;s scan strength, advertised services, manufacturer ID, etc. While this seems like great data to collect, I had one thing in mind - the number of unique devices (for now). &lt;&#x2F;p&gt;
&lt;p&gt;By debugging the heap size constantly, I realized that the scan results was filling up the small amount of RAM it had. This was bad news - at first, I didn&#x27;t see a way to still collect the data while not actually collecting the data.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;resolution&quot;&gt;Resolution&lt;&#x2F;h3&gt;
&lt;p&gt;I decided to brush up on my C++ data structures programming and write a small hashset. After all, the data structure for the scan results was very bloated - if I could override that, I would be able to control the heap size more closely, right?&lt;&#x2F;p&gt;
&lt;p&gt;On every callback, then, we&#x27;d insert the MAC address into a hashset, then clear the built-in result structure to allow for more memory.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;occupancy&#x2F;code.png&quot; alt=&quot;Code&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Unfortunately, this is not ideal - &lt;strong&gt;if and only if&lt;&#x2F;strong&gt; there&#x27;s some results to check for duplicates, the callback is only called on new devices. When we clear this every time, we give it amnesia, thus every single BLE advertisement packet causes a callback. We &lt;em&gt;do&lt;&#x2F;em&gt; check for duplicates in &lt;code&gt;addToSet&lt;&#x2F;code&gt; (it is a hashset!), but this will definitely cause hundreds of duplicate callbacks to our hashset, &lt;em&gt;and&lt;&#x2F;em&gt; heap thrashing since we&#x27;re allocating and deallocating the result structure every single callback. That&#x27;s okay (for now), it&#x27;s better to repeatedly check a hashmap with no more than 1000 entries (a very quick procedure) very often, than have our capacity limited to 250 people. &lt;&#x2F;p&gt;
&lt;h3 id=&quot;more-obstacles&quot;&gt;More obstacles&lt;&#x2F;h3&gt;
&lt;p&gt;Okay, we now have a perfect way to scan for devices for long periods of time. Oh would you look at the calendar - it&#x27;s fall break! I&#x27;ll leave it in the library and have it report back so I can see how packed it is over break (yes, there will be studying done on campus over break - we are a nerdy college). Perfect, even some long-term testing over the 5 day weekend! Surely nothing bad will happ-&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&#x2F;imgs&#x2F;occupancy&#x2F;fallbreak.png&quot; alt=&quot;A picture showing my chart rapidly falling again&quot;&#x2F;&gt;
  &lt;figcaption&gt;That&#x27;s about 400 devices before the crash - on a fall break day in a college. As mentioned - nerdy.&lt;&#x2F;figcaption&gt;
&lt;&#x2F;figure&gt;
&lt;p&gt;Okay, awesome. Another issue, one that manifests itself after 3 hours of use with zero indication of issues. After fighting with the debugger for long enough, and even tossing in periodic reboots (it boots very quick so this adds almost no time at all), I chalked this up to a bad board&#x2F;BT adapter - it seemed to run, but it instantly returned zero devices on every scan. That&#x27;s okay - while I was messing with this Amazon one, I bought quite a few others, along with the rest I&#x27;ve bought over the course of the whole project.&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&#x2F;imgs&#x2F;occupancy&#x2F;devices.jpeg&quot; alt=&quot;A picture showing several devices I&#x27;ve purchased over the course of this project&quot;&#x2F;&gt;
  &lt;figcaption&gt;Seeed Studio XIAO ESP32S3&#x2F;C3, WaveShare ESP32S3 Zero, Unbranded ESP32-WROOM with OLED, Orange Pi Zero W (untouched), Raspberry Pi Zero W (L-&gt;R, T-&gt;D)&lt;&#x2F;figcaption&gt;
&lt;&#x2F;figure&gt;
&lt;p&gt;After testing all of these, the only one reliable to work for long periods of time (one month currently) was the XIAO ESP32C3&#x2F;S3. Both work acceptably, but I decided to go with the C3, since it&#x27;s RISC-V, which is awesome (for my ideals), and since it&#x27;s cheaper, which is also awesome (for my wallet).&lt;&#x2F;p&gt;
&lt;p&gt;Another benefit of switching to a better manufacturer is more SRAM - I was able to switch away from my hand-written hashmap implementation, since the RAM was able to hold the results data structure much better without crashing. I&#x27;ve seen as high as 1000 devices detected with no sign of slowing down. This probably reduces CPU usage as well - no more heap and callback churn!&lt;&#x2F;p&gt;
&lt;p&gt;After I found a device that worked far better, I moved my deployment location to my dorm room window so I would have an easier deployment cycle - here it is with numerous academic buildings in the background.&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&#x2F;imgs&#x2F;occupancy&#x2F;esp32c3-deployed.jpeg&quot; alt=&quot;A picture showing a XIAO ESP32C3 turned on and scanning&quot;&#x2F;&gt;
  &lt;figcaption&gt;My RISC-V based ESP32C3, scanning from my dorm room window in front of Washington Hall, during homecoming weekend.&lt;&#x2F;figcaption&gt;
&lt;&#x2F;figure&gt;
&lt;h2 id=&quot;final-data-collection&quot;&gt;Final data collection&lt;&#x2F;h2&gt;
&lt;p&gt;Now that I&#x27;ve gotten my data collection working successfully, let&#x27;s look at the data for one day.&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&#x2F;imgs&#x2F;occupancy&#x2F;chart.png&quot; alt=&quot;A screenshot of a chart showing occupancy stats - it shows peaks at times where you&#x27;d expect there to be&quot;&#x2F;&gt;
  &lt;figcaption&gt;Data collection for one day. Notice the peaks? That&#x27;s right about the time that classes switch.&lt;&#x2F;figcaption&gt;
&lt;&#x2F;figure&gt;
&lt;p&gt;There&#x27;s something to note about this. The device might be in my dorm, but it largely is not limited to the dorm&#x27;s own inhabitants. Otherwise, it would be at its max in the early morning and drop as the day went on. If I wanted it to measure exclusively dorm inhabitants, I would probably place it more centrally (instead of out a window), but it still would not be great at this, since dorms are the &lt;em&gt;worst&lt;&#x2F;em&gt; at permeating bluetooth signals through many walls.&lt;&#x2F;p&gt;
&lt;p&gt;That&#x27;s okay, I&#x27;ll just keep that in mind as I analyze the data - it&#x27;s mostly picking up students as they go into the two nearest academic buildings, not the dorm inhabitants. &lt;&#x2F;p&gt;
&lt;p&gt;The peaks start up around 7:50, right before the 8 am classes start in Ewell and Washington halls. I suspect this is detecting the students initially leaving dorms, shuffling along to their classes, and the drop is as students enter the buildings. Then, the peak at 8:50 is probably as students leave their 8 AMs and go to their 9 AMs, entering the range of the device only to immediately leave it as the numbers drop at 9 AM. Same for 9:50&#x2F;10 AM, and 10:50&#x2F;11 AM. These are all class switch times.&lt;&#x2F;p&gt;
&lt;p&gt;These all point to method validation - it seems like this device really is good at tracking trends in the movement of students around it. The antenna is also seemingly very high range - I didn&#x27;t expect it to reach the ~160ft into Washington Hall, and the ~100ft into Ewell. The altitude of being on the 3rd floor probably helps with it, though.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;time-series-forecasting&quot;&gt;Time series forecasting?&lt;&#x2F;h2&gt;
&lt;p&gt;This seems like the perfect target for time series forecasting, like with &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;neuralprophet.com&#x2F;&quot;&gt;NeuralProphet&lt;&#x2F;a&gt;. The data is chock-full of hourly, daily, and weekly trends. I added the functionality to predict these trends and so far, it&#x27;s very good at predicting daily trends; the longer (week, month, and season-long) trends will likely converge after enough data is collected.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;further-thoughts&quot;&gt;Further thoughts&lt;&#x2F;h2&gt;
&lt;p&gt;Of course, this is not a solved project. I&#x27;ve written the code to parse this into a Cloudflare DB, into Grafana, and some forecasting, but there&#x27;s more to be done. &lt;&#x2F;p&gt;
&lt;p&gt;I performed an enormous amount of literature review over the course of this project - reading dozens of research papers on the topic, finding out what works and what didn&#x27;t, what I would try and what I would avoid. Many questions are raised in these papers, that I still want to answer.&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&#x2F;imgs&#x2F;occupancy&#x2F;papers.jpeg&quot; alt=&quot;A photograph of a stack of research papers, annotated with sticky notes&quot;&#x2F;&gt;
  &lt;figcaption&gt;Hours of doc review&lt;&#x2F;figcaption&gt;
&lt;&#x2F;figure&gt;
&lt;p&gt;For example, how well of a proxy is a BLE beacon count for actual population count? &lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Does this depend on the demographics? How do we find a correction factor (like for &lt;code&gt;x&lt;&#x2F;code&gt; beacons, there&#x27;s roughly &lt;code&gt;0.7x&lt;&#x2F;code&gt; people, given the multiple devices people carry around)? &lt;&#x2F;li&gt;
&lt;li&gt;For example, in the computer science building, is the linear rate to population higher, since we carry so many gadgets around? Or is it lower, because we know to turn off Bluetooth when not using it (BT firmware zero days, you see)? &lt;&#x2F;li&gt;
&lt;li&gt;Or in the staff building, is it lower compared to students, since they are less likely to carry around a bunch of tech?&lt;&#x2F;li&gt;
&lt;li&gt;Maybe the rate is lower in a dining hall, since not many people are using multiple devices like they would in a lecture hall (laptop, iPad, etc for notes)?&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Other questions came to mind, like:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Can we improve the accuracy by setting an RSSI minimum, for which devices weaker than it do not count, to ensure only those who are really nearby get counted?&lt;&#x2F;li&gt;
&lt;li&gt;Can we improve the accuracy by filtering by manufacturer ID, so it&#x27;s only Apple + common Android manufacturers? Would this help, since Apple Watches, AirPods, MacBooks, etc would all still add to the count?&lt;&#x2F;li&gt;
&lt;li&gt;What kinds of privacy accomodations do I need to keep in mind? I already only track pure beacon numbers. I don&#x27;t track actual MAC addresses like Bluefox did, but do I need to add noise to the data? Is the existing data noisy enough to avoid deanonymization? Is it realistic to identify a single person in the data without anything but the number of devices?&lt;&#x2F;li&gt;
&lt;li&gt;What&#x27;s the best scan duration? Too quick, and it won&#x27;t find all of the hundreds of devices that exist. Too long, and we risk inaccuracy (counting devices that have since left, data showing large drifts within short periods of time, etc). 
&lt;ul&gt;
&lt;li&gt;Is a dynamic scan length best? (Think about cooking a bag of popcorn - when a period of time passes without any change, you&#x27;re done)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Lots of questions to answer. I plan on validating my data with real-world population data collected in a place where it&#x27;s easy to get the &amp;quot;ground truth&amp;quot;. Maybe I will reach out to a place on campus who either already tracks occupancy (the gym with swipe in&#x2F;out), or will investigate more thoroughly in a place where it is trivial to do so myself (limited entry&#x2F;exit, like a dining hall, or a Starbucks).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;further-work&quot;&gt;Further work&lt;&#x2F;h2&gt;
&lt;p&gt;I am not sure whether I will be taking this further - I&#x27;m currently talking to some professors about the use cases for some university committees, or perhaps further academic (and hopefully publish-worthy) research. I am also considering selling it to brick-and-mortar businesses that want to measure occupancy trends. It&#x27;s a pretty packaged up solution - everything from the front-end to the back-end is built already. This is vaguely what the setup looks like for any given deployment:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Set up Wi-Fi in config (either have network whitelist the MAC if it&#x27;s a portal, or connect to open&#x2F;password protected Wi-Fi on boot)&lt;&#x2F;li&gt;
&lt;li&gt;Change machine and site IDs in config&lt;&#x2F;li&gt;
&lt;li&gt;Plug device&#x2F;devices into outlet in central&#x2F;convenient locations&lt;&#x2F;li&gt;
&lt;li&gt;Set up Grafana dashboard to read each device from backend&lt;&#x2F;li&gt;
&lt;li&gt;Set up Grafana dashboard to read predicted trends as well, in separate charts&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;If you&#x27;re interested in any of this, please let me know! I&#x27;d love to hear from you.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h2&gt;
&lt;p&gt;I hope you enjoyed reading my blog post about analyzing occupancy trends and embedded development. If you have any suggestions, comments, questions, or angry fists, you can email me at &lt;a href=&quot;mailto:maesposito@wm.edu&quot;&gt;maesposito@wm.edu&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;br &#x2F;&gt;
&lt;!-- &gt; Think this was cool? Hiring software engineering interns for Summer 2024? [Check out my resume here](https:&#x2F;&#x2F;docs.google.com&#x2F;document&#x2F;d&#x2F;1EN2k5ZUOLTvMs_NZtUq8tKVKawif5Idb&#x2F;). I&#x27;m very passionate about software development (I did all of this without the promise of _any results_ - all in my spare time because I loved doing it!), and I&#x27;m always ready to embark on new coding adventures. --&gt;
&lt;h2 id=&quot;bibliography&quot;&gt;Bibliography&lt;&#x2F;h2&gt;
&lt;!DOCTYPE html PUBLIC &quot;-&#x2F;&#x2F;W3C&#x2F;&#x2F;DTD XHTML 1.1&#x2F;&#x2F;EN&quot; &quot;http:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;xhtml11&#x2F;DTD&#x2F;xhtml11.dtd&quot;&gt;
&lt;html xmlns=&quot;http:&#x2F;&#x2F;www.w3.org&#x2F;1999&#x2F;xhtml&quot; xml:lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text&#x2F;html; charset=utf-8&quot;&#x2F;&gt;
&lt;title&gt;Bibliography&lt;&#x2F;title&gt;
&lt;&#x2F;head&gt;
&lt;body&gt;
&lt;div class=&quot;csl-bib-body&quot; style=&quot;line-height: 2; margin-left: 2em; text-indent:-2em;&quot;&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Ahmad, J., Larijani, H., Emmanuel, R., Mannion, M., &amp;amp; Javed, A. (2020). Occupancy detection in non-residential buildings – A survey and novel privacy preserved occupancy monitoring solution. &lt;i&gt;Applied Computing and Informatics&lt;&#x2F;i&gt;, &lt;i&gt;17&lt;&#x2F;i&gt;(2), 279–295. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.aci.2018.12.001&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.aci.2018.12.001&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1016%2Fj.aci.2018.12.001&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Occupancy%20detection%20in%20non-residential%20buildings%20%E2%80%93%20A%20survey%20and%20novel%20privacy%20preserved%20occupancy%20monitoring%20solution&amp;amp;rft.jtitle=Applied%20Computing%20and%20Informatics&amp;amp;rft.volume=17&amp;amp;rft.issue=2&amp;amp;rft.aufirst=J.&amp;amp;rft.aulast=Ahmad&amp;amp;rft.au=J.%20Ahmad&amp;amp;rft.au=H.%20Larijani&amp;amp;rft.au=R.%20Emmanuel&amp;amp;rft.au=M.%20Mannion&amp;amp;rft.au=A.%20Javed&amp;amp;rft.date=2020-01-01&amp;amp;rft.pages=279-295&amp;amp;rft.spage=279&amp;amp;rft.epage=295&amp;amp;rft.issn=2210-8327&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Apolónia, F., Ferreira, P. M., &amp;amp; Cecílio, J. (2021). Buildings Occupancy Estimation: Preliminary Results Using Bluetooth Signals and Artificial Neural Networks. In M. Kamp, I. Koprinska, A. Bibal, T. Bouadi, B. Frénay, L. Galárraga, J. Oramas, L. Adilova, Y. Krishnamurthy, B. Kang, C. Largeron, J. Lijffijt, T. Viard, P. Welke, M. Ruocco, E. Aune, C. Gallicchio, G. Schiele, F. Pernkopf, … G. Graça (Eds.), &lt;i&gt;Machine Learning and Principles and Practice of Knowledge Discovery in Databases&lt;&#x2F;i&gt; (pp. 567–579). Springer International Publishing. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1007&#x2F;978-3-030-93733-1_42&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1007&#x2F;978-3-030-93733-1_42&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1007%2F978-3-030-93733-1_42&amp;amp;rft_id=urn%3Aisbn%3A978-3-030-93733-1&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=Buildings%20Occupancy%20Estimation%3A%20Preliminary%20Results%20Using%20Bluetooth%20Signals%20and%20Artificial%20Neural%20Networks&amp;amp;rft.btitle=Machine%20Learning%20and%20Principles%20and%20Practice%20of%20Knowledge%20Discovery%20in%20Databases&amp;amp;rft.place=Cham&amp;amp;rft.publisher=Springer%20International%20Publishing&amp;amp;rft.series=Communications%20in%20Computer%20and%20Information%20Science&amp;amp;rft.aufirst=Frederico&amp;amp;rft.aulast=Apol%C3%B3nia&amp;amp;rft.au=Frederico%20Apol%C3%B3nia&amp;amp;rft.au=Pedro%20M.%20Ferreira&amp;amp;rft.au=Jos%C3%A9%20Cec%C3%ADlio&amp;amp;rft.au=Michael%20Kamp&amp;amp;rft.au=Irena%20Koprinska&amp;amp;rft.au=Adrien%20Bibal&amp;amp;rft.au=Tassadit%20Bouadi&amp;amp;rft.au=Beno%C3%AEt%20Fr%C3%A9nay&amp;amp;rft.au=Luis%20Gal%C3%A1rraga&amp;amp;rft.au=Jos%C3%A9%20Oramas&amp;amp;rft.au=Linara%20Adilova&amp;amp;rft.au=Yamuna%20Krishnamurthy&amp;amp;rft.au=Bo%20Kang&amp;amp;rft.au=Christine%20Largeron&amp;amp;rft.au=Jefrey%20Lijffijt&amp;amp;rft.au=Tiphaine%20Viard&amp;amp;rft.au=Pascal%20Welke&amp;amp;rft.au=Massimiliano%20Ruocco&amp;amp;rft.au=Erlend%20Aune&amp;amp;rft.au=Claudio%20Gallicchio&amp;amp;rft.au=Gregor%20Schiele&amp;amp;rft.au=Franz%20Pernkopf&amp;amp;rft.au=Michaela%20Blott&amp;amp;rft.au=Holger%20Fr%C3%B6ning&amp;amp;rft.au=G%C3%BCnther%20Schindler&amp;amp;rft.au=Riccardo%20Guidotti&amp;amp;rft.au=Anna%20Monreale&amp;amp;rft.au=Salvatore%20Rinzivillo&amp;amp;rft.au=Przemyslaw%20Biecek&amp;amp;rft.au=Eirini%20Ntoutsi&amp;amp;rft.au=Mykola%20Pechenizkiy&amp;amp;rft.au=Bodo%20Rosenhahn&amp;amp;rft.au=Christopher%20Buckley&amp;amp;rft.au=Daniela%20Cialfi&amp;amp;rft.au=Pablo%20Lanillos&amp;amp;rft.au=Maxwell%20Ramstead&amp;amp;rft.au=Tim%20Verbelen&amp;amp;rft.au=Pedro%20M.%20Ferreira&amp;amp;rft.au=Giuseppina%20Andresini&amp;amp;rft.au=Donato%20Malerba&amp;amp;rft.au=Ib%C3%A9ria%20Medeiros&amp;amp;rft.au=Philippe%20Fournier-Viger&amp;amp;rft.au=M.%20Saqib%20Nawaz&amp;amp;rft.au=Sebastian%20Ventura&amp;amp;rft.au=Meng%20Sun&amp;amp;rft.au=Min%20Zhou&amp;amp;rft.au=Valerio%20Bitetta&amp;amp;rft.au=Ilaria%20Bordino&amp;amp;rft.au=Andrea%20Ferretti&amp;amp;rft.au=Francesco%20Gullo&amp;amp;rft.au=Giovanni%20Ponti&amp;amp;rft.au=Lorenzo%20Severini&amp;amp;rft.au=Rita%20Ribeiro&amp;amp;rft.au=Jo%C3%A3o%20Gama&amp;amp;rft.au=Ricard%20Gavald%C3%A0&amp;amp;rft.au=Lee%20Cooper&amp;amp;rft.au=Naghmeh%20Ghazaleh&amp;amp;rft.au=Jonas%20Richiardi&amp;amp;rft.au=Damian%20Roqueiro&amp;amp;rft.au=Diego%20Saldana%20Miranda&amp;amp;rft.au=Konstantinos%20Sechidis&amp;amp;rft.au=Guilherme%20Gra%C3%A7a&amp;amp;rft.date=2021&amp;amp;rft.pages=567-579&amp;amp;rft.spage=567&amp;amp;rft.epage=579&amp;amp;rft.isbn=978-3-030-93733-1&amp;amp;rft.language=en&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Baronti, P., Barsocchi, P., Chessa, S., Mavilia, F., &amp;amp; Palumbo, F. (2018). Indoor Bluetooth Low Energy Dataset for Localization, Tracking, Occupancy, and Social Interaction. &lt;i&gt;Sensors&lt;&#x2F;i&gt;, &lt;i&gt;18&lt;&#x2F;i&gt;(12), Article 12. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.3390&#x2F;s18124462&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.3390&#x2F;s18124462&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.3390%2Fs18124462&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Indoor%20Bluetooth%20Low%20Energy%20Dataset%20for%20Localization%2C%20Tracking%2C%20Occupancy%2C%20and%20Social%20Interaction&amp;amp;rft.jtitle=Sensors&amp;amp;rft.volume=18&amp;amp;rft.issue=12&amp;amp;rft.aufirst=Paolo&amp;amp;rft.aulast=Baronti&amp;amp;rft.au=Paolo%20Baronti&amp;amp;rft.au=Paolo%20Barsocchi&amp;amp;rft.au=Stefano%20Chessa&amp;amp;rft.au=Fabio%20Mavilia&amp;amp;rft.au=Filippo%20Palumbo&amp;amp;rft.date=2018-12&amp;amp;rft.pages=4462&amp;amp;rft.issn=1424-8220&amp;amp;rft.language=en&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Barsocchi, P., Crivello, A., Girolami, M., Mavilia, F., &amp;amp; Palumbo, F. (2017). Occupancy detection by multi-power bluetooth low energy beaconing. &lt;i&gt;2017 International Conference on Indoor Positioning and Indoor Navigation (IPIN)&lt;&#x2F;i&gt;, 1–6. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;IPIN.2017.8115946&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;IPIN.2017.8115946&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FIPIN.2017.8115946&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=Occupancy%20detection%20by%20multi-power%20bluetooth%20low%20energy%20beaconing&amp;amp;rft.btitle=2017%20International%20Conference%20on%20Indoor%20Positioning%20and%20Indoor%20Navigation%20(IPIN)&amp;amp;rft.aufirst=Paolo&amp;amp;rft.aulast=Barsocchi&amp;amp;rft.au=Paolo%20Barsocchi&amp;amp;rft.au=Antonino%20Crivello&amp;amp;rft.au=Michele%20Girolami&amp;amp;rft.au=Fabio%20Mavilia&amp;amp;rft.au=Filippo%20Palumbo&amp;amp;rft.date=2017-09&amp;amp;rft.pages=1-6&amp;amp;rft.spage=1&amp;amp;rft.epage=6&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Billah, M. F. R. M., &amp;amp; Campbell, B. (2019). Unobtrusive Occupancy Detection with FastGRNN on Resource-Constrained BLE Devices. &lt;i&gt;Proceedings of the 1st ACM International Workshop on Device-Free Human Sensing&lt;&#x2F;i&gt;, 1–5. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1145&#x2F;3360773.3360874&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1145&#x2F;3360773.3360874&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1145%2F3360773.3360874&amp;amp;rft_id=urn%3Aisbn%3A978-1-4503-7007-3&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=Unobtrusive%20Occupancy%20Detection%20with%20FastGRNN%20on%20Resource-Constrained%20BLE%20Devices&amp;amp;rft.btitle=Proceedings%20of%20the%201st%20ACM%20International%20Workshop%20on%20Device-Free%20Human%20Sensing&amp;amp;rft.place=New%20York%2C%20NY%2C%20USA&amp;amp;rft.publisher=Association%20for%20Computing%20Machinery&amp;amp;rft.series=DFHS&#x27;19&amp;amp;rft.aufirst=Md%20Fazlay%20Rabbi%20Masum&amp;amp;rft.aulast=Billah&amp;amp;rft.au=Md%20Fazlay%20Rabbi%20Masum%20Billah&amp;amp;rft.au=Bradford%20Campbell&amp;amp;rft.date=2019-11-10&amp;amp;rft.pages=1%E2%80%935&amp;amp;rft.spage=1&amp;amp;rft.epage=5&amp;amp;rft.isbn=978-1-4503-7007-3&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Chen, Z., Jiang, C., &amp;amp; Xie, L. (2018). Building occupancy estimation and detection: A review. &lt;i&gt;Energy and Buildings&lt;&#x2F;i&gt;, &lt;i&gt;169&lt;&#x2F;i&gt;, 260–270. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.enbuild.2018.03.084&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.enbuild.2018.03.084&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1016%2Fj.enbuild.2018.03.084&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Building%20occupancy%20estimation%20and%20detection%3A%20A%20review&amp;amp;rft.jtitle=Energy%20and%20Buildings&amp;amp;rft.stitle=Energy%20and%20Buildings&amp;amp;rft.volume=169&amp;amp;rft.aufirst=Zhenghua&amp;amp;rft.aulast=Chen&amp;amp;rft.au=Zhenghua%20Chen&amp;amp;rft.au=Chaoyang%20Jiang&amp;amp;rft.au=Lihua%20Xie&amp;amp;rft.date=2018-06-15&amp;amp;rft.pages=260-270&amp;amp;rft.spage=260&amp;amp;rft.epage=270&amp;amp;rft.issn=0378-7788&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Demrozi, F., Turetta, C., Chiarani, F., Kindt, P. H., &amp;amp; Pravadelli, G. (2021). Estimating Indoor Occupancy Through Low-Cost BLE Devices. &lt;i&gt;IEEE Sensors Journal&lt;&#x2F;i&gt;, &lt;i&gt;21&lt;&#x2F;i&gt;(15), 17053–17063. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;JSEN.2021.3080632&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;JSEN.2021.3080632&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FJSEN.2021.3080632&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Estimating%20Indoor%20Occupancy%20Through%20Low-Cost%20BLE%20Devices&amp;amp;rft.jtitle=IEEE%20Sensors%20Journal&amp;amp;rft.volume=21&amp;amp;rft.issue=15&amp;amp;rft.aufirst=Florenc&amp;amp;rft.aulast=Demrozi&amp;amp;rft.au=Florenc%20Demrozi&amp;amp;rft.au=Cristian%20Turetta&amp;amp;rft.au=Fabio%20Chiarani&amp;amp;rft.au=Philipp%20H.%20Kindt&amp;amp;rft.au=Graziano%20Pravadelli&amp;amp;rft.date=2021-08&amp;amp;rft.pages=17053-17063&amp;amp;rft.spage=17053&amp;amp;rft.epage=17063&amp;amp;rft.issn=1558-1748&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Ding, Y., Han, S., Tian, Z., Yao, J., Chen, W., &amp;amp; Zhang, Q. (2022). Review on occupancy detection and prediction in building simulation. &lt;i&gt;Building Simulation&lt;&#x2F;i&gt;, &lt;i&gt;15&lt;&#x2F;i&gt;(3), 333–356. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1007&#x2F;s12273-021-0813-8&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1007&#x2F;s12273-021-0813-8&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1007%2Fs12273-021-0813-8&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Review%20on%20occupancy%20detection%20and%20prediction%20in%20building%20simulation&amp;amp;rft.jtitle=Building%20Simulation&amp;amp;rft.stitle=Build.%20Simul.&amp;amp;rft.volume=15&amp;amp;rft.issue=3&amp;amp;rft.aufirst=Yan&amp;amp;rft.aulast=Ding&amp;amp;rft.au=Yan%20Ding&amp;amp;rft.au=Shuxue%20Han&amp;amp;rft.au=Zhe%20Tian&amp;amp;rft.au=Jian%20Yao&amp;amp;rft.au=Wanyue%20Chen&amp;amp;rft.au=Qiang%20Zhang&amp;amp;rft.date=2022-03-01&amp;amp;rft.pages=333-356&amp;amp;rft.spage=333&amp;amp;rft.epage=356&amp;amp;rft.issn=1996-8744&amp;amp;rft.language=en&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Dodier, R. H., Henze, G. P., Tiller, D. K., &amp;amp; Guo, X. (2006). Building occupancy detection through sensor belief networks. &lt;i&gt;Energy and Buildings&lt;&#x2F;i&gt;, &lt;i&gt;38&lt;&#x2F;i&gt;(9), 1033–1043. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.enbuild.2005.12.001&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.enbuild.2005.12.001&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1016%2Fj.enbuild.2005.12.001&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Building%20occupancy%20detection%20through%20sensor%20belief%20networks&amp;amp;rft.jtitle=Energy%20and%20Buildings&amp;amp;rft.stitle=Energy%20and%20Buildings&amp;amp;rft.volume=38&amp;amp;rft.issue=9&amp;amp;rft.aufirst=Robert%20H.&amp;amp;rft.aulast=Dodier&amp;amp;rft.au=Robert%20H.%20Dodier&amp;amp;rft.au=Gregor%20P.%20Henze&amp;amp;rft.au=Dale%20K.%20Tiller&amp;amp;rft.au=Xin%20Guo&amp;amp;rft.date=2006-09-01&amp;amp;rft.pages=1033-1043&amp;amp;rft.spage=1033&amp;amp;rft.epage=1043&amp;amp;rft.issn=0378-7788&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Feng, C., Mehmani, A., &amp;amp; Zhang, J. (2020). Deep Learning-Based Real-Time Building Occupancy Detection Using AMI Data. &lt;i&gt;IEEE Transactions on Smart Grid&lt;&#x2F;i&gt;, &lt;i&gt;11&lt;&#x2F;i&gt;(5), 4490–4501. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;TSG.2020.2982351&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;TSG.2020.2982351&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FTSG.2020.2982351&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Deep%20Learning-Based%20Real-Time%20Building%20Occupancy%20Detection%20Using%20AMI%20Data&amp;amp;rft.jtitle=IEEE%20Transactions%20on%20Smart%20Grid&amp;amp;rft.volume=11&amp;amp;rft.issue=5&amp;amp;rft.aufirst=Cong&amp;amp;rft.aulast=Feng&amp;amp;rft.au=Cong%20Feng&amp;amp;rft.au=Ali%20Mehmani&amp;amp;rft.au=Jie%20Zhang&amp;amp;rft.date=2020-09&amp;amp;rft.pages=4490-4501&amp;amp;rft.spage=4490&amp;amp;rft.epage=4501&amp;amp;rft.issn=1949-3061&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Filippoupolitis, A., Oliff, W., &amp;amp; Loukas, G. (2016). Occupancy Detection for Building Emergency Management Using BLE Beacons. In T. Czachórski, E. Gelenbe, K. Grochla, &amp;amp; R. Lent (Eds.), &lt;i&gt;Computer and Information Sciences&lt;&#x2F;i&gt; (pp. 233–240). Springer International Publishing. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1007&#x2F;978-3-319-47217-1_25&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1007&#x2F;978-3-319-47217-1_25&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1007%2F978-3-319-47217-1_25&amp;amp;rft_id=urn%3Aisbn%3A978-3-319-47217-1&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=Occupancy%20Detection%20for%20Building%20Emergency%20Management%20Using%20BLE%20Beacons&amp;amp;rft.btitle=Computer%20and%20Information%20Sciences&amp;amp;rft.place=Cham&amp;amp;rft.publisher=Springer%20International%20Publishing&amp;amp;rft.series=Communications%20in%20Computer%20and%20Information%20Science&amp;amp;rft.aufirst=Avgoustinos&amp;amp;rft.aulast=Filippoupolitis&amp;amp;rft.au=Avgoustinos%20Filippoupolitis&amp;amp;rft.au=William%20Oliff&amp;amp;rft.au=George%20Loukas&amp;amp;rft.au=Tadeusz%20Czach%C3%B3rski&amp;amp;rft.au=Erol%20Gelenbe&amp;amp;rft.au=Krzysztof%20Grochla&amp;amp;rft.au=Ricardo%20Lent&amp;amp;rft.date=2016&amp;amp;rft.pages=233-240&amp;amp;rft.spage=233&amp;amp;rft.epage=240&amp;amp;rft.isbn=978-3-319-47217-1&amp;amp;rft.language=en&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Mashuk, M. S., Pinchin, J., Siebers, P.-O., &amp;amp; Moore, T. (2018). A smart phone based multi-floor indoor positioning system for occupancy detection. &lt;i&gt;2018 IEEE&#x2F;ION Position, Location and Navigation Symposium (PLANS)&lt;&#x2F;i&gt;, 216–227. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;PLANS.2018.8373384&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;PLANS.2018.8373384&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FPLANS.2018.8373384&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=A%20smart%20phone%20based%20multi-floor%20indoor%20positioning%20system%20for%20occupancy%20detection&amp;amp;rft.btitle=2018%20IEEE%2FION%20Position%2C%20Location%20and%20Navigation%20Symposium%20(PLANS)&amp;amp;rft.aufirst=Md%20Shadab&amp;amp;rft.aulast=Mashuk&amp;amp;rft.au=Md%20Shadab%20Mashuk&amp;amp;rft.au=James%20Pinchin&amp;amp;rft.au=Peer-Olaf%20Siebers&amp;amp;rft.au=Terry%20Moore&amp;amp;rft.date=2018-04&amp;amp;rft.pages=216-227&amp;amp;rft.spage=216&amp;amp;rft.epage=227&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Meyn, S., Surana, A., Lin, Y., Oggianu, S. M., Narayanan, S., &amp;amp; Frewen, T. A. (2009). A sensor-utility-network method for estimation of occupancy in buildings. &lt;i&gt;Proceedings of the 48h IEEE Conference on Decision and Control (CDC) Held Jointly with 2009 28th Chinese Control Conference&lt;&#x2F;i&gt;, 1494–1500. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;CDC.2009.5400442&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;CDC.2009.5400442&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FCDC.2009.5400442&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=A%20sensor-utility-network%20method%20for%20estimation%20of%20occupancy%20in%20buildings&amp;amp;rft.btitle=Proceedings%20of%20the%2048h%20IEEE%20Conference%20on%20Decision%20and%20Control%20(CDC)%20held%20jointly%20with%202009%2028th%20Chinese%20Control%20Conference&amp;amp;rft.aufirst=Sean&amp;amp;rft.aulast=Meyn&amp;amp;rft.au=Sean%20Meyn&amp;amp;rft.au=Amit%20Surana&amp;amp;rft.au=Yiqing%20Lin&amp;amp;rft.au=Stella%20M.%20Oggianu&amp;amp;rft.au=Satish%20Narayanan&amp;amp;rft.au=Thomas%20A.%20Frewen&amp;amp;rft.date=2009-12&amp;amp;rft.pages=1494-1500&amp;amp;rft.spage=1494&amp;amp;rft.epage=1500&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Oliff, W., Filippoupolitis, A., &amp;amp; Loukas, G. (2017). Evaluating the impact of malicious spoofing attacks on Bluetooth low energy based occupancy detection systems. &lt;i&gt;2017 IEEE 15th International Conference on Software Engineering Research, Management and Applications (SERA)&lt;&#x2F;i&gt;, 379–385. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;SERA.2017.7965755&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;SERA.2017.7965755&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FSERA.2017.7965755&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=Evaluating%20the%20impact%20of%20malicious%20spoofing%20attacks%20on%20Bluetooth%20low%20energy%20based%20occupancy%20detection%20systems&amp;amp;rft.btitle=2017%20IEEE%2015th%20International%20Conference%20on%20Software%20Engineering%20Research%2C%20Management%20and%20Applications%20(SERA)&amp;amp;rft.aufirst=William&amp;amp;rft.aulast=Oliff&amp;amp;rft.au=William%20Oliff&amp;amp;rft.au=Avgoustinos%20Filippoupolitis&amp;amp;rft.au=George%20Loukas&amp;amp;rft.date=2017-06&amp;amp;rft.pages=379-385&amp;amp;rft.spage=379&amp;amp;rft.epage=385&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Pratama, A. R., Widyawan, W., Lazovik, A., &amp;amp; Aiello, M. (2018). Multi-User Low Intrusive Occupancy Detection. &lt;i&gt;Sensors&lt;&#x2F;i&gt;, &lt;i&gt;18&lt;&#x2F;i&gt;(3), Article 3. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.3390&#x2F;s18030796&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.3390&#x2F;s18030796&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.3390%2Fs18030796&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Multi-User%20Low%20Intrusive%20Occupancy%20Detection&amp;amp;rft.jtitle=Sensors&amp;amp;rft.volume=18&amp;amp;rft.issue=3&amp;amp;rft.aufirst=Azkario%20Rizky&amp;amp;rft.aulast=Pratama&amp;amp;rft.au=Azkario%20Rizky%20Pratama&amp;amp;rft.au=Widyawan%20Widyawan&amp;amp;rft.au=Alexander%20Lazovik&amp;amp;rft.au=Marco%20Aiello&amp;amp;rft.date=2018-03&amp;amp;rft.pages=796&amp;amp;rft.issn=1424-8220&amp;amp;rft.language=en&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Rahaman, M. S., Pare, H., Liono, J., Salim, F. D., Ren, Y., Chan, J., Kudo, S., Rawling, T., &amp;amp; Sinickas, A. (2019). OccuSpace: Towards a Robust Occupancy Prediction System for Activity Based Workplace. &lt;i&gt;2019 IEEE International Conference on Pervasive Computing and Communications Workshops (PerCom Workshops)&lt;&#x2F;i&gt;, 415–418. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;PERCOMW.2019.8730762&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;PERCOMW.2019.8730762&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FPERCOMW.2019.8730762&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=OccuSpace%3A%20Towards%20a%20Robust%20Occupancy%20Prediction%20System%20for%20Activity%20Based%20Workplace&amp;amp;rft.btitle=2019%20IEEE%20International%20Conference%20on%20Pervasive%20Computing%20and%20Communications%20Workshops%20(PerCom%20Workshops)&amp;amp;rft.aufirst=Mohammad%20Saiedur&amp;amp;rft.aulast=Rahaman&amp;amp;rft.au=Mohammad%20Saiedur%20Rahaman&amp;amp;rft.au=Harsh%20Pare&amp;amp;rft.au=Jonathan%20Liono&amp;amp;rft.au=Flora%20D.%20Salim&amp;amp;rft.au=Yongli%20Ren&amp;amp;rft.au=Jeffrey%20Chan&amp;amp;rft.au=Shaw%20Kudo&amp;amp;rft.au=Tim%20Rawling&amp;amp;rft.au=Alex%20Sinickas&amp;amp;rft.date=2019-03&amp;amp;rft.pages=415-418&amp;amp;rft.spage=415&amp;amp;rft.epage=418&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Rueda, L., Agbossou, K., Cardenas, A., Henao, N., &amp;amp; Kelouwani, S. (2020). A comprehensive review of approaches to building occupancy detection. &lt;i&gt;Building and Environment&lt;&#x2F;i&gt;, &lt;i&gt;180&lt;&#x2F;i&gt;, 106966. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.buildenv.2020.106966&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.buildenv.2020.106966&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1016%2Fj.buildenv.2020.106966&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=A%20comprehensive%20review%20of%20approaches%20to%20building%20occupancy%20detection&amp;amp;rft.jtitle=Building%20and%20Environment&amp;amp;rft.stitle=Building%20and%20Environment&amp;amp;rft.volume=180&amp;amp;rft.aufirst=Luis&amp;amp;rft.aulast=Rueda&amp;amp;rft.au=Luis%20Rueda&amp;amp;rft.au=Kodjo%20Agbossou&amp;amp;rft.au=Alben%20Cardenas&amp;amp;rft.au=Nilson%20Henao&amp;amp;rft.au=Sousso%20Kelouwani&amp;amp;rft.date=2020-08-01&amp;amp;rft.pages=106966&amp;amp;rft.issn=0360-1323&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Sayed, A. N., Himeur, Y., &amp;amp; Bensaali, F. (2022). Deep and transfer learning for building occupancy detection: A review and comparative analysis. &lt;i&gt;Engineering Applications of Artificial Intelligence&lt;&#x2F;i&gt;, &lt;i&gt;115&lt;&#x2F;i&gt;, 105254. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.engappai.2022.105254&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.engappai.2022.105254&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1016%2Fj.engappai.2022.105254&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Deep%20and%20transfer%20learning%20for%20building%20occupancy%20detection%3A%20A%20review%20and%20comparative%20analysis&amp;amp;rft.jtitle=Engineering%20Applications%20of%20Artificial%20Intelligence&amp;amp;rft.stitle=Engineering%20Applications%20of%20Artificial%20Intelligence&amp;amp;rft.volume=115&amp;amp;rft.aufirst=Aya%20Nabil&amp;amp;rft.aulast=Sayed&amp;amp;rft.au=Aya%20Nabil%20Sayed&amp;amp;rft.au=Yassine%20Himeur&amp;amp;rft.au=Faycal%20Bensaali&amp;amp;rft.date=2022-10-01&amp;amp;rft.pages=105254&amp;amp;rft.issn=0952-1976&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Shen, W., &amp;amp; Newsham, G. (2016). Smart phone based occupancy detection in office buildings. &lt;i&gt;2016 IEEE 20th International Conference on Computer Supported Cooperative Work in Design (CSCWD)&lt;&#x2F;i&gt;, 632–636. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;CSCWD.2016.7566063&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;CSCWD.2016.7566063&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FCSCWD.2016.7566063&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=Smart%20phone%20based%20occupancy%20detection%20in%20office%20buildings&amp;amp;rft.btitle=2016%20IEEE%2020th%20International%20Conference%20on%20Computer%20Supported%20Cooperative%20Work%20in%20Design%20(CSCWD)&amp;amp;rft.aufirst=Weiming&amp;amp;rft.aulast=Shen&amp;amp;rft.au=Weiming%20Shen&amp;amp;rft.au=Guy%20Newsham&amp;amp;rft.date=2016-05&amp;amp;rft.pages=632-636&amp;amp;rft.spage=632&amp;amp;rft.epage=636&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Sikeridis, D., Papapanagiotou, I., &amp;amp; Devetsikiotis, M. (2019). &lt;i&gt;BLEBeacon: A Real-Subject Trial Dataset from Mobile Bluetooth Low Energy Beacons&lt;&#x2F;i&gt; (arXiv:1802.08782). arXiv. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.48550&#x2F;arXiv.1802.08782&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.48550&#x2F;arXiv.1802.08782&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.48550%2FarXiv.1802.08782&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;amp;rft.type=preprint&amp;amp;rft.title=BLEBeacon%3A%20A%20Real-Subject%20Trial%20Dataset%20from%20Mobile%20Bluetooth%20Low%20Energy%20Beacons&amp;amp;rft.description=The%20BLEBeacon%20dataset%20is%20a%20collection%20of%20Bluetooth%20Low%20Energy%20(BLE)%20advertisement%20packets%2Ftraces%20generated%20from%20BLE%20beacons%20carried%20by%20people%20following%20their%20daily%20routine%20inside%20a%20university%20building.%20A%20network%20of%20Raspberry%20Pi%203%20(RPi)-based%20edge%20devices%20were%20deployed%20inside%20a%20multi-floor%20facility%20continuously%20gathering%20BLE%20advertisement%20packets%20and%20storing%20them%20in%20a%20cloud-based%20environment.%20The%20data%20were%20collected%20during%20an%20IRB%20(Institutional%20Review%20Board%20forhe%20Protection%20of%20Human%20Subjects%20in%20Research)%20approved%20one-month%20trial.%20Each%20facility%20occupant%2Fparticipant%20was%20handed%20a%20BLE%20beacon%20to%20carry%20with%20him%20at%20all%20times.%20The%20focus%20is%20on%20presenting%20a%20real-life%20realization%20of%20a%20location-aware%20sensing%20infrastructure%2C%20that%20can%20provide%20insights%20for%20smart%20sensing%20platforms%2C%20crowd-based%20applications%2C%20building%20management%2C%20and%20user-localization%20frameworks.%20This%20work%20describes%20and%20documents%20the%20published%20BLEBeacon%20dataset.&amp;amp;rft.identifier=urn%3Adoi%3A10.48550%2FarXiv.1802.08782&amp;amp;rft.aufirst=Dimitrios&amp;amp;rft.aulast=Sikeridis&amp;amp;rft.au=Dimitrios%20Sikeridis&amp;amp;rft.au=Ioannis%20Papapanagiotou&amp;amp;rft.au=Michael%20Devetsikiotis&amp;amp;rft.date=2019-05-09&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Tekler, Z. D., Low, R., &amp;amp; Blessing, L. (2019). An alternative approach to monitor occupancy using bluetooth low energy technology in an office environment. &lt;i&gt;Journal of Physics: Conference Series&lt;&#x2F;i&gt;, &lt;i&gt;1343&lt;&#x2F;i&gt;(1), 012116. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1088&#x2F;1742-6596&#x2F;1343&#x2F;1&#x2F;012116&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1088&#x2F;1742-6596&#x2F;1343&#x2F;1&#x2F;012116&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1088%2F1742-6596%2F1343%2F1%2F012116&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=An%20alternative%20approach%20to%20monitor%20occupancy%20using%20bluetooth%20low%20energy%20technology%20in%20an%20office%20environment&amp;amp;rft.jtitle=Journal%20of%20Physics%3A%20Conference%20Series&amp;amp;rft.stitle=J.%20Phys.%3A%20Conf.%20Ser.&amp;amp;rft.volume=1343&amp;amp;rft.issue=1&amp;amp;rft.aufirst=Zeynep%20Duygu&amp;amp;rft.aulast=Tekler&amp;amp;rft.au=Zeynep%20Duygu%20Tekler&amp;amp;rft.au=Raymond%20Low&amp;amp;rft.au=Lucienne%20Blessing&amp;amp;rft.date=2019-11&amp;amp;rft.pages=012116&amp;amp;rft.issn=1742-6596&amp;amp;rft.language=en&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;V., M. P. J., de Souza, B. J. O., Lamenza, T. de S., &amp;amp; Endler, M. (2022). &lt;i&gt;Practical Challenges And Pitfalls Of Bluetooth Mesh Data Collection Experiments With Esp-32 Microcontrollers&lt;&#x2F;i&gt; (arXiv:2211.10696). arXiv. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.48550&#x2F;arXiv.2211.10696&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.48550&#x2F;arXiv.2211.10696&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.48550%2FarXiv.2211.10696&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;amp;rft.type=preprint&amp;amp;rft.title=Practical%20Challenges%20And%20Pitfalls%20Of%20Bluetooth%20Mesh%20Data%20Collection%20Experiments%20With%20Esp-32%20Microcontrollers&amp;amp;rft.description=Testing%20network%20algorithms%20in%20physical%20environments%20using%20real%20hardware%20is%20an%20important%20step%20to%20reduce%20the%20gap%20between%20theory%20and%20practice%20in%20the%20field%2C%20and%20an%20interesting%20way%20to%20explore%20technologies%20such%20as%20Bluetooth%20Mesh.%20We%20implemented%20a%20Bluetooth%20Mesh%20data%20collection%20strategy%20and%20deployed%20it%20in%20indoor%20and%20outdoor%20settings%2C%20using%20ESP-32%20microcontrollers.%20This%20data%20collection%20strategy%20also%20covers%20an%20alternative%20packet%20routing%20strategy%20based%20on%20Bluetooth%20Mesh%20-%20MAM%20-%20already%20discussed%20and%20simulated%20in%20previous%20work%20using%20the%20OMNET%2B%2B%20simulator.%20We%20compared%20the%20real-world%20ESP-32%20experiments%20with%20the%20past%20simulations%2C%20and%20the%20results%20differed%20significantly%3A%20the%20simulations%20predicted%20a%20%2B459%5C%25%20unique%20message%20collection%20compared%20to%20the%20results%20we%20obtained%20with%20the%20ESP-32.%20Based%20on%20those%20results%2C%20we%20also%20identified%20vast%20room%20for%20improvement%20in%20our%20ESP-32%20implementation%20for%20future%20work%2C%20including%20solving%20an%20unexpected%20packet%20duplication%20in%20the%20MAM%20algorithm%20implementation.%20Even%20so%2C%20MAM%20performed%20better%20than%20Bluetooth%20Mesh&#x27;s%20default%20relay%20strategy%2C%20with%20up%20to%20%2B4.06%5C%25%20more%20(unique)%20data%20messages%20collected.%20We%20also%20discuss%20some%20challenges%20we%20experienced%20when%20implementing%2C%20deploying%2C%20and%20running%20benchmarks%20using%20Bluetooth%20Mesh%20and%20the%20ESP-32%20platform.&amp;amp;rft.identifier=urn%3Adoi%3A10.48550%2FarXiv.2211.10696&amp;amp;rft.aufirst=Marcelo%20Paulon%20J.&amp;amp;rft.aulast=V.&amp;amp;rft.au=Marcelo%20Paulon%20J.%20V.&amp;amp;rft.au=Bruno%20Jos%C3%A9%20Olivieri%20de%20Souza&amp;amp;rft.au=Thiago%20de%20Souza%20Lamenza&amp;amp;rft.au=Markus%20Endler&amp;amp;rft.date=2022-11-19&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Valks, B., Arkesteijn, M. H., Koutamanis, A., &amp;amp; den Heijer, A. C. (2021). Towards a smart campus: Supporting campus decisions with Internet of Things applications. &lt;i&gt;Building Research &amp;amp; Information&lt;&#x2F;i&gt;, &lt;i&gt;49&lt;&#x2F;i&gt;(1), 1–20. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1080&#x2F;09613218.2020.1784702&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1080&#x2F;09613218.2020.1784702&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1080%2F09613218.2020.1784702&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Towards%20a%20smart%20campus%3A%20supporting%20campus%20decisions%20with%20Internet%20of%20Things%20applications&amp;amp;rft.jtitle=Building%20Research%20%26%20Information&amp;amp;rft.volume=49&amp;amp;rft.issue=1&amp;amp;rft.aufirst=Bart&amp;amp;rft.aulast=Valks&amp;amp;rft.au=Bart%20Valks&amp;amp;rft.au=Monique%20H.%20Arkesteijn&amp;amp;rft.au=Alexander%20Koutamanis&amp;amp;rft.au=Alexandra%20C.%20den%20Heijer&amp;amp;rft.date=2021-01-02&amp;amp;rft.pages=1-20&amp;amp;rft.spage=1&amp;amp;rft.epage=20&amp;amp;rft.issn=0961-3218&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Yoshimura, Y., Krebs, A., &amp;amp; Ratti, C. (2017). Noninvasive Bluetooth Monitoring of Visitors’ Length of Stay at the Louvre. &lt;i&gt;IEEE Pervasive Computing&lt;&#x2F;i&gt;, &lt;i&gt;16&lt;&#x2F;i&gt;(2), 26–34. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;MPRV.2017.33&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;MPRV.2017.33&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FMPRV.2017.33&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.genre=article&amp;amp;rft.atitle=Noninvasive%20Bluetooth%20Monitoring%20of%20Visitors&#x27;%20Length%20of%20Stay%20at%20the%20Louvre&amp;amp;rft.jtitle=IEEE%20Pervasive%20Computing&amp;amp;rft.volume=16&amp;amp;rft.issue=2&amp;amp;rft.aufirst=Yuji&amp;amp;rft.aulast=Yoshimura&amp;amp;rft.au=Yuji%20Yoshimura&amp;amp;rft.au=Anne%20Krebs&amp;amp;rft.au=Carlo%20Ratti&amp;amp;rft.date=2017-04&amp;amp;rft.pages=26-34&amp;amp;rft.spage=26&amp;amp;rft.epage=34&amp;amp;rft.issn=1558-2590&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Zim, M. Z. H. (2021). &lt;i&gt;TinyML: Analysis of Xtensa LX6 microprocessor for Neural Network Applications by ESP32 SoC&lt;&#x2F;i&gt;. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.13140&#x2F;RG.2.2.28602.11204&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.13140&#x2F;RG.2.2.28602.11204&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.13140%2FRG.2.2.28602.11204&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;amp;rft.type=preprint&amp;amp;rft.title=TinyML%3A%20Analysis%20of%20Xtensa%20LX6%20microprocessor%20for%20Neural%20Network%20Applications%20by%20ESP32%20SoC&amp;amp;rft.description=In%20recent%20decades%2C%20Machine%20Learning%20(ML)%20has%20become%20extremely%20important%20for%20many%20computing%20applications.%20The%20pervasiveness%20of%20ultra-low-power%20embedded%20devices%20such%20as%20ESP32%20or%20ESP32%20Cam%20with%20tiny%20Machine%20Learning%20(tinyML)%20applications%20will%20enable%20the%20mass%20proliferation%20of%20Artificial%20Intelligent%20powered%20Embedded%20IoT%20Devices.%20In%20the%20last%20few%20years%2C%20the%20microcontroller%20device%20(Espressif%20ESP32)%20became%20powerful%20enough%20to%20be%20used%20for%20small%2Ftiny%20machine%20learning%20(tinyML)%20tasks.%20The%20ease%20of%20use%20of%20platforms%20like%20Arduino%20IDE%2C%20MicroPython%20and%20TensorFlow%20Lite%20(TF)%20with%20tinyML%20application%20make%20it%20an%20indispensable%20topic%20of%20research%20for%20mobile%20robotics%2C%20modern%20computer%20science%20and%20electrical%20engineering.%20The%20goal%20of%20this%20paper%20is%20to%20analyze%20the%20speed%20of%20the%20Xtensa%20dual%20core%2032-bit%20LX6%20microprocessor%20by%20running%20a%20neural%20network%20application.%20The%20different%20number%20of%20inputs%20(9%2C%2036%2C%20144%20and%20576)%20inputted%20through%20the%20different%20number%20of%20neurons%20in%20neural%20networks%20with%20one%20and%20two%20hidden%20layers.%20Xtensa%20LX6%20microprocessor%20has%20been%20analyzed%20because%20it%20comes%20inside%20with%20Espressif%20ESP32%20and%20ESP32%20Cam%20which%20are%20very%20easy%20to%20use%2C%20plug%20and%20play%20IoT%20device.%20In%20this%20paper%20speed%20of%20the%20Xtensa%20LX6%20microprocessor%20in%20feed-forward%20mode%20has%20been%20analyzed.&amp;amp;rft.identifier=urn%3Adoi%3A10.13140%2FRG.2.2.28602.11204&amp;amp;rft.aufirst=Md%20Ziaul%20Haque&amp;amp;rft.aulast=Zim&amp;amp;rft.au=Md%20Ziaul%20Haque%20Zim&amp;amp;rft.date=2021-06-20&quot;&gt;&lt;&#x2F;span&gt;
  &lt;div class=&quot;csl-entry&quot;&gt;Zoto, J., La, R. J., Hamedi, M., &amp;amp; Haghani, A. (2012). Estimation of Average Vehicle Speeds Traveling on Heterogeneous Lanes Using Bluetooth Sensors. &lt;i&gt;2012 IEEE Vehicular Technology Conference (VTC Fall)&lt;&#x2F;i&gt;, 1–5. &lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;VTCFall.2012.6399146&quot;&gt;https:&#x2F;&#x2F;doi.org&#x2F;10.1109&#x2F;VTCFall.2012.6399146&lt;&#x2F;a&gt;&lt;&#x2F;div&gt;
  &lt;span class=&quot;Z3988&quot; title=&quot;url_ver=Z39.88-2004&amp;amp;ctx_ver=Z39.88-2004&amp;amp;rfr_id=info%3Asid%2Fzotero.org%3A2&amp;amp;rft_id=info%3Adoi%2F10.1109%2FVTCFall.2012.6399146&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;amp;rft.genre=proceeding&amp;amp;rft.atitle=Estimation%20of%20Average%20Vehicle%20Speeds%20Traveling%20on%20Heterogeneous%20Lanes%20Using%20Bluetooth%20Sensors&amp;amp;rft.btitle=2012%20IEEE%20Vehicular%20Technology%20Conference%20(VTC%20Fall)&amp;amp;rft.aufirst=Jorgos&amp;amp;rft.aulast=Zoto&amp;amp;rft.au=Jorgos%20Zoto&amp;amp;rft.au=Richard%20J.%20La&amp;amp;rft.au=Masoud%20Hamedi&amp;amp;rft.au=Ali%20Haghani&amp;amp;rft.date=2012-09&amp;amp;rft.pages=1-5&amp;amp;rft.spage=1&amp;amp;rft.epage=5&quot;&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;body&gt;
&lt;&#x2F;html&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Finding three bugs in the markdown crate with cargo-fuzz</title>
        <published>2022-01-08T00:00:00+00:00</published>
        <updated>2022-01-08T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="//matthew.science/posts/fuzzing/" type="text/html"/>
        <id>//matthew.science/posts/fuzzing/</id>
        
        <content type="html">&lt;p&gt;Fuzzing is the act of testing software with a “fuzzer” which generates random or possibly invalid input, in order to find bugs like OOM conditions, crashes, or other errors where the input is expected to fit a specific format. &lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s best used with parsers; one example is the &lt;code&gt;markdown&lt;&#x2F;code&gt; crate which I&#x27;ve found &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;johannhof&#x2F;markdown.rs&#x2F;issues&#x2F;43&quot;&gt;two&lt;&#x2F;a&gt; different &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;johannhof&#x2F;markdown.rs&#x2F;issues&#x2F;45&quot;&gt;bugs&lt;&#x2F;a&gt; within (though they are similar). Both of these bugs cause panicking of the thread, which is a pretty big problem. I&#x27;ve submitted issues for both of these fuzzing errors, and I&#x27;ll go over them here, then I&#x27;ll show how I found them. &lt;&#x2F;p&gt;
&lt;h2 id=&quot;first-markdown-parsing-bug&quot;&gt;First &lt;code&gt;markdown&lt;&#x2F;code&gt; parsing bug&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;main&lt;&#x2F;span&gt;&lt;span&gt;() {
&lt;&#x2F;span&gt;&lt;span&gt;    markdown::to_html(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;- &amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;);
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This code looks pretty straight-forward. A simple beginning bullet point and nothing else. Let&#x27;s look at the error.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#fafafa;color:#383a42;&quot;&gt;&lt;code&gt;&lt;span&gt;matt@matt ~&#x2F;r&#x2F;m&#x2F;src (main) [101]&amp;gt; RUST_BACKTRACE=full mold -run cargo r
&lt;&#x2F;span&gt;&lt;span&gt;    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
&lt;&#x2F;span&gt;&lt;span&gt;     Running `&#x2F;home&#x2F;matt&#x2F;rust&#x2F;markdown-crash&#x2F;target&#x2F;debug&#x2F;markdown-crash`
&lt;&#x2F;span&gt;&lt;span&gt;thread &amp;#39;main&amp;#39; panicked at &amp;#39;index out of bounds: the len is 0 but the index is 0&amp;#39;, &#x2F;home&#x2F;matt&#x2F;.cargo&#x2F;registry&#x2F;src&#x2F;github.com-1ecc6299db9ec823&#x2F;markdown-0.3.0&#x2F;src&#x2F;parser&#x2F;block&#x2F;unordered_list.rs:84:44
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If you want to read the full backtrace (&lt;code&gt;RUST_BACKTRACE=full&lt;&#x2F;code&gt;), generally for each item in the list you want to find the code that&#x27;s in the project directory, or in &lt;code&gt;.cargo&#x2F;registry&lt;&#x2F;code&gt; if it&#x27;s a library crashing. Above I just included the first line (backtrace=full not needed). Let&#x27;s take a look at the offending code.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;let mut&lt;&#x2F;span&gt;&lt;span&gt; list_contents &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;vec![];
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; c &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;in&lt;&#x2F;span&gt;&lt;span&gt; contents {
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; is_paragraph &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;||&lt;&#x2F;span&gt;&lt;span&gt; c.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;len&lt;&#x2F;span&gt;&lt;span&gt;() &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1 &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;            list_contents.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;push&lt;&#x2F;span&gt;&lt;span&gt;(ListItem::Paragraph(c));
&lt;&#x2F;span&gt;&lt;span&gt;        } &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;else if let&lt;&#x2F;span&gt;&lt;span&gt; Paragraph(content) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; c[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;].&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;clone&lt;&#x2F;span&gt;&lt;span&gt;() {       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a0a1a7;&quot;&gt;&#x2F;&#x2F;LINE 84
&lt;&#x2F;span&gt;&lt;span&gt;            list_contents.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;push&lt;&#x2F;span&gt;&lt;span&gt;(ListItem::Simple(content));
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;contents is a Vec&amp;lt;Vec&lt;Block&gt;&amp;gt;, or a list of list of blocks. So, for each &lt;strong&gt;list of blocks c&lt;&#x2F;strong&gt; within the list of lists, &lt;strong&gt;if the&lt;&#x2F;strong&gt; &lt;strong&gt;&lt;code&gt;is_paragraph&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt; &lt;strong&gt;bool has been flipped&lt;&#x2F;strong&gt; or &lt;strong&gt;if&lt;&#x2F;strong&gt; &lt;strong&gt;&lt;code&gt;c&lt;&#x2F;code&gt;&#x27;s length is greater than 1&lt;&#x2F;strong&gt;, push it as a paragraph. Then to the problem line: if the first item of &lt;code&gt;c&lt;&#x2F;code&gt; (which would be a single block within the list of blocks) is a paragraph, push a list item containing the content. &lt;&#x2F;p&gt;
&lt;p&gt;Again, the iterator here iterates over a Vec&amp;lt;Vec&lt;Block&gt;&amp;gt;, meaning each time it runs, c is a list. When this code is ran with the erroneous input, the iterator runs once, because a list was started yet never finished. So the loop runs once with an empty Vec&lt;Block&gt; as its input. This means when line 84 asks for &lt;code&gt;c[0]&lt;&#x2F;code&gt;, there&#x27;s nothing to give; there is no first item in the list. The solution is to limit that iterator to lists that aren&#x27;t empty. This is a standard out-of-bounds error though it&#x27;s very common when parsing untrusted input. A parser like this should never panic, though: it should always throw an error or simply return erroneous input. Let&#x27;s move onto the…&lt;&#x2F;p&gt;
&lt;h2 id=&quot;second-markdown-parsing-bug&quot;&gt;Second &lt;code&gt;markdown&lt;&#x2F;code&gt; parsing bug&lt;&#x2F;h2&gt;
&lt;p&gt;Oddly enough, when returning to this bug for this post, I was unable to reproduce this specific bug. However, I did find a different one!&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;main&lt;&#x2F;span&gt;&lt;span&gt;() {
&lt;&#x2F;span&gt;&lt;span&gt;    markdown::to_html(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;0 &amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;);
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Okay, so at first glance, this looks similar. Let&#x27;s look at the crash message, except this time, excluding the &lt;code&gt;RUST_BACKTRACE=full&lt;&#x2F;code&gt; environment variable.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;thread &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;main&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt; panicked at &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;#39;index&lt;&#x2F;span&gt;&lt;span&gt; out of bounds: the len is &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt; but the index is &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;home&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;matt&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;.cargo&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;registry&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;src&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;github.com&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;1ecc6299db9ec823&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;markdown&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0.3&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;src&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;parser&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;block&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;ordered_list.rs:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;88&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;44
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Hmm, another out of bounds in a different place (see the &lt;code&gt;ordered_list.rs&lt;&#x2F;code&gt; which was previously in &lt;code&gt;unordered_list.rs&lt;&#x2F;code&gt;) I suspect this error is the same: an iterator over a list of lists, of which there is one list, of which is empty. Let&#x27;s look at the code.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; c &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;in&lt;&#x2F;span&gt;&lt;span&gt; contents {
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; is_paragraph &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;||&lt;&#x2F;span&gt;&lt;span&gt; c.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;len&lt;&#x2F;span&gt;&lt;span&gt;() &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1 &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;            list_contents.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;push&lt;&#x2F;span&gt;&lt;span&gt;(ListItem::Paragraph(c));
&lt;&#x2F;span&gt;&lt;span&gt;        } &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;else if let&lt;&#x2F;span&gt;&lt;span&gt; Paragraph(content) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; c[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;].&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;clone&lt;&#x2F;span&gt;&lt;span&gt;() {
&lt;&#x2F;span&gt;&lt;span&gt;            list_contents.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;push&lt;&#x2F;span&gt;&lt;span&gt;(ListItem::Simple(content));
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Yep; it&#x27;s the same code except in a different module. Let&#x27;s try a quick fix:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; c &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;in&lt;&#x2F;span&gt;&lt;span&gt; contents.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;into_iter&lt;&#x2F;span&gt;&lt;span&gt;().&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;filter&lt;&#x2F;span&gt;&lt;span&gt;(|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#e45649;&quot;&gt;x&lt;&#x2F;span&gt;&lt;span&gt;| &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;!&lt;&#x2F;span&gt;&lt;span&gt;x.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;is_empty&lt;&#x2F;span&gt;&lt;span&gt;()) {
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; is_paragraph &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;||&lt;&#x2F;span&gt;&lt;span&gt; c.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;len&lt;&#x2F;span&gt;&lt;span&gt;() &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1 &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;            list_contents.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;push&lt;&#x2F;span&gt;&lt;span&gt;(ListItem::Paragraph(c));
&lt;&#x2F;span&gt;&lt;span&gt;        } &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;else if let&lt;&#x2F;span&gt;&lt;span&gt; Paragraph(content) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; c[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;].&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;clone&lt;&#x2F;span&gt;&lt;span&gt;() {
&lt;&#x2F;span&gt;&lt;span&gt;            list_contents.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;push&lt;&#x2F;span&gt;&lt;span&gt;(ListItem::Simple(content));
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This converts &lt;code&gt;contents&lt;&#x2F;code&gt; into an iterator. Notice the usage of &lt;code&gt;into_iter()&lt;&#x2F;code&gt;, which &lt;em&gt;converts&lt;&#x2F;em&gt; &lt;code&gt;contents&lt;&#x2F;code&gt; rather than returning an iter over the slice (which would make &lt;code&gt;c&lt;&#x2F;code&gt; a &lt;code&gt;&amp;amp;Vec&amp;lt;Block&amp;gt;&lt;&#x2F;code&gt;); we want to consume &lt;code&gt;contents&lt;&#x2F;code&gt; so the values are not borrowed. Then, it filters the list of lists to only iterate over lists that are not empty. Let&#x27;s test: &lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;matt&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;@&lt;&#x2F;span&gt;&lt;span&gt;matt &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;~&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;markdown&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;crash (main) [&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;101&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt; mold &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;run cargo r
&lt;&#x2F;span&gt;&lt;span&gt;   Compiling markdown v0.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;3.0 &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;home&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;matt&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;markdown.rs)
&lt;&#x2F;span&gt;&lt;span&gt;   Compiling markdown&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;crash v0.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1.0 &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;home&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;matt&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;rust&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;markdown&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;crash)
&lt;&#x2F;span&gt;&lt;span&gt;    Finished dev [unoptimized &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; debuginfo] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;target&lt;&#x2F;span&gt;&lt;span&gt;(s) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;in &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1.50&lt;&#x2F;span&gt;&lt;span&gt;s
&lt;&#x2F;span&gt;&lt;span&gt;     Running `target&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;debug&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;markdown&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;crash`
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;ol&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;ol&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Hooray! The bug is fixed. This filter also fixes the previous bug.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how-i-found-these-bugs&quot;&gt;How I found these bugs&lt;&#x2F;h2&gt;
&lt;ol&gt;
&lt;li&gt;Follow the instructions given here: &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;rust-fuzz.github.io&#x2F;book&#x2F;cargo-fuzz&#x2F;tutorial.html&quot;&gt;https:&#x2F;&#x2F;rust-fuzz.github.io&#x2F;book&#x2F;cargo-fuzz&#x2F;tutorial.html.&lt;&#x2F;a&gt; The book tutorial can explain it far better than I can.&lt;&#x2F;li&gt;
&lt;li&gt;Then, begin fuzzing. Run &lt;code&gt;cargo fuzz run fuzz_target_1&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;My setup: I&#x27;ve got three windows open. On the left is VSCodium open in the source directory. On the right, I&#x27;ve got one window on the top running &lt;code&gt;cargo fuzz&lt;&#x2F;code&gt; and on the bottom inside of a test project that simply takes the crashing input and runs it (so I can get a full error with offending line of code and all). &lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;fuzzing&#x2F;1_image.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Whenever a crash is found, I try to minimize it with &lt;code&gt;cargo fuzz tmin fuzz_target_1 fuzz&#x2F;artifacts&#x2F;fuzz_target_1&#x2F;(file)&lt;&#x2F;code&gt;. This tries messing with the input to find the smallest input that still crashes; this often reduces it from some gibberish to something that probably is easier to understand. &lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;fuzzing&#x2F;2_image.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s one input that crashes; after minimizing it, it turns into &lt;code&gt;[;]:&lt;&#x2F;code&gt;. &lt;&#x2F;p&gt;
&lt;p&gt;Then, I enter the input into the project on the bottom right and running it so Rust can give me a more accurate error when it crashes (libFuzzer doesn&#x27;t show me line where it crashed).&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;main&lt;&#x2F;span&gt;&lt;span&gt;() {
&lt;&#x2F;span&gt;&lt;span&gt;    markdown::to_html(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#50a14f;&quot;&gt;&amp;quot;[;]:&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;);
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#fafafa;color:#383a42;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;   Compiling markdown&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;crash v0.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1.0 &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;home&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;matt&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;rust&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;markdown&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;crash)
&lt;&#x2F;span&gt;&lt;span&gt;    Finished dev [unoptimized &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; debuginfo] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#0184bc;&quot;&gt;target&lt;&#x2F;span&gt;&lt;span&gt;(s) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;in &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;0.28&lt;&#x2F;span&gt;&lt;span&gt;s
&lt;&#x2F;span&gt;&lt;span&gt;     Running `target&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;debug&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;markdown&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;crash`
&lt;&#x2F;span&gt;&lt;span&gt;thread &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;main&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt; panicked at &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;#39;index&lt;&#x2F;span&gt;&lt;span&gt; out of bounds: the len is &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt; but the index is &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;home&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;matt&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;markdown.rs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;src&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;parser&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;block&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a626a4;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;link_reference.rs:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;27&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c18401;&quot;&gt;92
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here, I can see where the code crashed. Let&#x27;s look at the code.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;fuzzing&#x2F;image.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This looks like another standard out-of-bounds; let&#x27;s try adding a simple &lt;code&gt;if lines.len() &amp;lt; 2 { return None }&lt;&#x2F;code&gt; before the offending line. Of course, there&#x27;s better ways to fix it, but simply to identify that this is the crash for now.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;imgs&#x2F;fuzzing&#x2F;3_image.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Yep, that fixes it. &lt;&#x2F;p&gt;
&lt;p&gt;Next, I&#x27;ll try running cargo-fuzz on a PR I got that refactors a lot of parsing logic, and uploading a video of me fuzzing and fixing the bugs until the fuzzer runs for a few minutes unperturbed. Until next time!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>About me</title>
        <published>2004-01-01T00:00:00+00:00</published>
        <updated>2004-01-01T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="//matthew.science/about/" type="text/html"/>
        <id>//matthew.science/about/</id>
        
        <content type="html">&lt;h2 id=&quot;my-blog&quot;&gt;My Blog&lt;&#x2F;h2&gt;
&lt;p&gt;This is the blog of Matthew Esposito! I am a computer science&#x2F;philosophy student at the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;wm.edu&#x2F;&quot;&gt;College of William &amp;amp; Mary&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;resume&quot;&gt;Resume&lt;&#x2F;h3&gt;
&lt;p&gt;Check it out &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;sigaloid&#x2F;resume&#x2F;raw&#x2F;refs&#x2F;heads&#x2F;main&#x2F;main.pdf&quot;&gt;here&lt;&#x2F;a&gt;!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;about-me-fun&quot;&gt;About me (fun)&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;toby.party&#x2F;&quot;&gt;I love my dogs very much&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;I occasionally climb trees&lt;&#x2F;li&gt;
&lt;li&gt;I&#x27;ve listened to 47,203 minutes of music this year. 55% of that was &amp;quot;danceable&amp;quot; music!&lt;&#x2F;li&gt;
&lt;li&gt;I still use my Sony Walkman, 12 years after I got it (thank you 7 year old me, for not breaking it!). Now running Rockbox!&lt;&#x2F;li&gt;
&lt;li&gt;My 7th grade science project was running &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.kali.org&#x2F;tools&#x2F;sslstrip&#x2F;&quot;&gt;&lt;code&gt;sslstrip&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; on our home wifi and tricking my dad into giving up his Amazon password. It was rejected from my science fair for being &amp;quot;too complicated&amp;quot; and various other &amp;quot;ethical issues&amp;quot;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;about-me-other&quot;&gt;About me (other)&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;I am the team lead of the GeoDev team at the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;geolab.wm.edu&#x2F;&quot;&gt;Geospatial Evaluation and Observation Lab&lt;&#x2F;a&gt; at William &amp;amp; Mary, where we work with machine learning and democratize access to datasets. Some of the awesome things we are doing as a lab:
&lt;ul&gt;
&lt;li&gt;Sharing openly-licensed (CC BY 4.0) geographic boundaries &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.geoboundaries.org&#x2F;&quot;&gt;for every country in the world&lt;&#x2F;a&gt;!&lt;&#x2F;li&gt;
&lt;li&gt;Providing boundaries to the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.gatesfoundation.org&#x2F;&quot;&gt;Bill and Melinda Gates Foundation&lt;&#x2F;a&gt; for vaccine distribution&lt;&#x2F;li&gt;
&lt;li&gt;Working with the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.thegef.org&#x2F;who-we-are&quot;&gt;Global Environment Facility&lt;&#x2F;a&gt; to better distribute &lt;em&gt;billions of dollars&lt;&#x2F;em&gt; in environmental grants by computationally analyzing project reports&lt;&#x2F;li&gt;
&lt;li&gt;Working alongside the UN&#x27;s &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;salb.un.org&#x2F;en&quot;&gt;Second Administrative Level Boundaries program&lt;&#x2F;a&gt; and &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.unocha.org&#x2F;&quot;&gt;Office for the Coordination of Humanitarian Affairs&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;I assisted with an &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;scholarworks.wm.edu&#x2F;honorstheses&#x2F;1987&#x2F;&quot;&gt;honors thesis research paper&lt;&#x2F;a&gt; into worldwide governments&#x27; use of internet shutdowns to suppress dissent and control information flow, shedding light on the impact of these tactics on freedom of expression and the right to access information&lt;&#x2F;li&gt;
&lt;li&gt;I am a founding member and DevOps lead of the &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;tribelink.wm.edu&#x2F;organization&#x2F;linux&quot;&gt;Linux&#x2F;FLOSS club&lt;&#x2F;a&gt; at William &amp;amp; Mary&lt;&#x2F;li&gt;
&lt;li&gt;I have &lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pulls?q=is%3Amerged+author%3Asigaloid&quot;&gt;contributed to the Rust programming language&lt;&#x2F;a&gt;!&lt;&#x2F;li&gt;
&lt;li&gt;I gave a &lt;a href=&quot;&#x2F;rust-talk-matthew-esposito.pdf&quot;&gt;talk introducing Rust&lt;&#x2F;a&gt; at William &amp;amp; Mary&#x27;s 8th Annual Hackathon, Cypher @ W&amp;amp;M!&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;contact&quot;&gt;Contact&lt;&#x2F;h3&gt;
&lt;p&gt;You can almost always find me biking speedily around the William &amp;amp; Mary campus. Please say hi!&lt;&#x2F;p&gt;
&lt;p&gt;More practically, there is a mail button below :)&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
