When you load JavaScript as a module , you get access to import.meta.url , which contains the URL of the module script itself. I first encountered this feature through the Web Worker incantation supported by modern bundlers: new Worker ( new URL ( ' ./worker ' , import . meta . url ), { type : " module " }, ); We'll come back to this. The interesting thing I realized was that I could add params to…
I recently added a spare SSD so I could play with desktop Linux again, and I again quickly grew tired of trying to catch the GRUB boot selection screen. A bit of searching turned up this project log for a Simplified hardware boot switch . The basic idea came together smoothly enough, but I have a few minor additions I thought worth mentioning. In the guide, you detect the presence of the "switch…
Julia Evans on Examples of floating point problems and Examples of problems with integers It's good to get have some additional concrete examples of what often feel like abstract concerns. Future of Memory Safety: Challenges and Recommendations Consumer Reports wades into the programming language safety debate? The source and timing are both mildly hilarious, but it's a good high level overview.…
Be sure to read Building Canrun: A statically typed logic programming library for Rust to put this article in context. Also see my update post with more recent API/implementation notes . In basic μKanren , values interact through unification Sidenote 1 1 As always, anything I say about *Kanren or... really anything I say should be taken with a grain of salt. As I've rambled at a few formerly close…
Deploying a website is harder than it might first appear. Even a simple html page with a single Javascript or CSS file is a distributed system prone to race conditions. A "modern" Single Page Application with code splitting is worse. Consider our simple HTML page. We have v1 deployed to our live site. It depends on a couple of .js and .css files. A visitor requesting our page will get v1 , which…
TLDR: I made a toy logic programming library in Rust called Canrun ( original announcement ). I just published a new version with fixes for several serious design flaws: canrun v0.4.0 on docs.rs . One design challenge in building out the early versions of Canrun was how to store a mix of arbitrary types. I eventually settled on an approach where you had to explicitly define your "domain" up front…
tl;dr I made a service that lets you replay old podcast feeds as if they're just starting: PodReplay.com . Continue reading if you're curious to read a smattering of design notes and half remembered anecdotes. The long version I have a bad habit. Well, maybe more than one, but I'll try to suppress the one about trying to talk about too many ideas at once and focus on the one about trying to…
I wanted to share a few functions between a Rust server and web app client, so I decided to finally try out WebAssembly (WASM) . After a few tweaks to get data marshalled between the Javascript/WASM worlds , it actually worked really well... except the final .wasm file size was about 720K for a ~100 line function (plus dependencies, of course). Working through the code size guide eventually made…
Adding an <itunes:block>Yes</itunes:block> tag to a feed will instruct complying podcast directories (such as Overcast or iTunes ) to not list that feed publicly. I also found mentions of a <googleplay:block> tag, but even Google's own docs only seem to mention the iTunes tag. I haven't found an equivalent for JSON Feed , but I'm still not sure how widespread support actually is, especially among…
Update 2 Jan, 2023: Many aspects of this library have been redesigned, especially relating to the domain stuff: Simplifying a toy logic programming library Canrun is a new logic programming library for Rust with static types and constraints. In my initial post I mentioned going through a few fundamental revisions before settling on the current approach. Here I'll try to do a quick recap for two…
Update 2 Jan, 2023: Many aspects of this library have been redesigned, especially relating to the domain stuff: Simplifying a toy logic programming library I keep bumping into logic programming, especially in the form of the *Kanren family. In keeping with tradition, this is my attempt to implement it in Rust, my current hobby language of choice. After a few false starts, I got a not completely…
My favorite pytest feature is its support for "funcarg" fixtures, a lightweight approach to wiring up data flow. Years ago, I even wrote a small library targeted at more generic usage. It was a fun experience, but most of the Python I've written lately is in the form of small scripts. In that context, it's often convenient to avoid extra dependencies. To that end, I've been using a minimal…
In no particular order. Don't Let the Internet Dupe You, Event Sourcing is Hard I'm grateful that I never had a chance to actually implement event sourcing in a non-trivial setting. I was a bit infatuated with the idea for a while, but I've come to realize that there are more tradeoffs and complications than might be obvious at first glance. Still a cool technique for the right problem, but not a…
I got a bit tangled up while experimenting with threads and channels in Rust. The compiler prevented any undefined behavior or memory corruption, but it can only do so much. My problems came from a shaky understanding of the language's fundamentals and the inherent complexity of parallel programming. Or, in my case, attempted parallel programming. The following code is the result of stripping away…
I've begun to seriously dig into the Rust programming language. The learning curve is real, but I already appreciate the work they've put into ergonomics. I'm writing a simple photo thumbnail endpoint using the Rocket web framework (v0.4) and Image library (v0.20.1). My first pass used a lot of unwrapping to ignore potential errors. A lot can go wrong, even in this "simple" case. Note: This post…
Update: Elm's list range syntax has been removed as of version 0.18. The replacement is List.range 1 2, which is if nothing else more searchable. I recently stumbled around for more than a few moments searching for a canonical way to generate a range of numbers in Elm. I finally found a working example by searching for "haskell range syntax". > [1..2] [1,2] : List number Elm doesn't appear to…
In React, the most often cited method of binding form elements to data is to pass the value along with an update function. update(e.target.value)} /> This code is straightforward and explicit, but the update functions can easily become coupled to method of persisting the data change. This is especially tricky when the form element is nested a few layers deep. Facebook's LinkedStateMixin is one…
I recently learned two new things about Javascript. The first discovery makes me feel silly. Somehow I missed that there is a multiline form as well as the short, single line form. const short = (n) => n + 1; const long = (n) => { return n + 1; }; This isn't a huge paradigm shift, but it does mean that there are far fewer cases in which the old function(){} syntax makes sense beyond familiarity.…
One of the stranger rough edges that comes with using ES6 (via Babel/Webpack) revolves around the way Babel transpiles the new module syntax. When you use a named import, Babel's transpiled output seems almost designed to cause a bit of confusion, as it assigns the imported value to a local variable with a rather munged name. // Original code import { foo } from "bar"; console.log(foo); //…
For tiny projects, template strings can make simple things really easy, even without using libraries. const template = (title, items) => ` ${title} ${subtitle ? ` ${subtitle} ` : ''} ${items.map(item => ` ${item} `).join('')} `; Some aspects of this may seem familiar if you've been using React. Replacing traditional template language loop constructs with .map takes getting used to, but the…
Did you know that you can dynamically change the transitionName of a React animation on the fly? This is more of a "hey look it works" thing then an actual revelation. First, a quick primer/review taken from the React animation docs. The CSSTransitionGroup automatically adds classes to its children when they are added and removed. {items} In this case, a new item will be rendered with the…
React components have a surprisingly simple property which sets them apart from the equivalents in other frameworks. Rather then being specified by name in a string based template, they're referenced as a value in Javascript. import Hello from "./Hello"; World ; Since the name of the tag is actually just the name of a local variable, component references can be dynamically calculated, passed into…
I like systems. I'm always fascinated by wonderfully designed systems which are as useful as they are beautiful. In my own work, I often feel a strong pull to "invent" an elegant and general "solution". The result, more often then not, exhibits neither trait. “The real trouble with this world of ours is not that it is an unreasonable world, nor even that it is a reasonable one. The commonest kind…
I've been using Vagrant to manage local development environments for a while, but there are subtle differences between the base Ubuntu Vagrant box and the Ubuntu Cloud Images I typically use in production. Since the base set of packages don't match exactly, builds would occasionally fail on AWS after working fine locally. While I always caught these issues before they went live, the mismatch was…
Fetch is a lovely little api for making ajax requests. I've been using the github/fetch polyfill in lieu of full browser support, but with a recent chrome update all requests were being sent without cookies. At first it seemed to be a strangely obvious glitch in Chrome's implementation, but the behavior turns out to be according to the spec. I think it's an odd default, but I'm sure they had their…
I've wasted a lot of time trying to sort out my javascript workflow, and Webpack has brought me very close to the smooth and drama free experience I'm been looking for. The documentation is a bit rough, so I posted a step by step Webpack tutorial based on what I've learned so far. One of the big factors holding back the advancement of the front end Javascript ecosystem has been the lack of a…