<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Robert Knight</title>
    <link>https://robertknight.me.uk/</link>
    <description>Recent content on Robert Knight</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 31 Dec 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://robertknight.me.uk/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>RTen in 2025</title>
      <link>https://robertknight.me.uk/posts/rten-2025/</link>
      <pubDate>Wed, 31 Dec 2025 00:00:00 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/rten-2025/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/robertknight/rten&#34;&gt;RTen&lt;/a&gt; is a machine learning runtime for&#xA;Rust that was first released in December 2023. It enables you to take models&#xA;that have been trained in Python (eg. using PyTorch) and run them in Rust. It&#xA;supports models in ONNX format, which you can find many of on &lt;a href=&#34;https://huggingface.co/models?library=onnx&amp;amp;sort=trending&#34;&gt;Hugging&#xA;Face&lt;/a&gt; or export from&#xA;frameworks such as &lt;a href=&#34;https://docs.pytorch.org/docs/stable/onnx.html&#34;&gt;PyTorch&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The project started out as a runtime for&#xA;&lt;a href=&#34;https://github.com/robertknight/ocrs&#34;&gt;Ocrs&lt;/a&gt;, an OCR library and CLI tool. It&#xA;has since evolved into a general purpose ONNX runtime which can run a wide&#xA;variety of popular models across many domains (vision, audio, text, etc.). The&#xA;current version only supports CPU inference, though I plan to change this next&#xA;year.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The RTen machine learning runtime - a 2024 retrospective</title>
      <link>https://robertknight.me.uk/posts/rten-2024/</link>
      <pubDate>Mon, 30 Dec 2024 00:00:00 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/rten-2024/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/robertknight/rten&#34;&gt;RTen&lt;/a&gt; is a machine learning runtime for&#xA;Rust that I have been working on since mid 2022. It allows you to take models&#xA;that have been trained in Python, using a framework such as PyTorch or Keras and&#xA;run them in a Rust project.&lt;/p&gt;&#xA;&lt;p&gt;This includes many pre-trained models that are&#xA;available on places such as &lt;a href=&#34;https://huggingface.co&#34;&gt;Hugging Face&lt;/a&gt;. Models are&#xA;first exported to &lt;a href=&#34;https://onnx.ai&#34;&gt;ONNX&lt;/a&gt; which is a portable exchange format&#xA;for models, then converted to a &lt;a href=&#34;https://flatbuffers.dev&#34;&gt;FlatBuffers&lt;/a&gt;-based&#xA;format (&lt;code&gt;.rten&lt;/code&gt;) which can be loaded more efficiently at runtime.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Shallow rendering revisited: Better unit tests for React/Preact components</title>
      <link>https://robertknight.me.uk/posts/shallow-rendering-revisited/</link>
      <pubDate>Mon, 10 Feb 2020 00:00:00 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/shallow-rendering-revisited/</guid>
      <description>&lt;p&gt;In this post I will discuss the benefits of isolating tests for React/Preact&#xA;UI components from the details of child components, and the various approaches&#xA;that we looked at for our frontend projects at&#xA;&lt;a href=&#34;https://github.com/hypothesis/client&#34;&gt;Hypothesis&lt;/a&gt;. I will explain why we settled&#xA;on the approach that we did and provide links if you would like to use the same&#xA;tools and techniques in your projects.&lt;/p&gt;&#xA;&lt;h2 id=&#34;why-mock-child-components&#34;&gt;Why mock child components?&lt;/h2&gt;&#xA;&lt;p&gt;When writing unit tests for a module in an application, it is generally a good&#xA;idea to isolate that module from its dependencies, or at least those which&#xA;have significant complexity or cost in terms of runtime performance.&#xA;Isolating such dependencies has several benefits:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Mocking ES6 and CommonJS modules with Babel</title>
      <link>https://robertknight.me.uk/posts/mocking-es-imports-with-babel/</link>
      <pubDate>Sat, 29 Jun 2019 00:00:00 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/mocking-es-imports-with-babel/</guid>
      <description>&lt;p&gt;A common need when writing unit tests is to limit the scope of the code being&#xA;tested and force certain code paths to be executed by &lt;em&gt;mocking&lt;/em&gt; imported&#xA;functions / classes etc. and controlling their outputs.&lt;/p&gt;&#xA;&lt;p&gt;In an &lt;a href=&#34;https://robertknight.me.uk/posts/browserify-dependency-mocking/&#34;&gt;earlier post&lt;/a&gt; I wrote about how&#xA;existing tools for mocking JavaScript modules work when using the Browserify&#xA;bundler, and problems with it. In this blog post, I present the approach that we&#xA;are currently using to mock modules in JavaScript code&#xA;&lt;a href=&#34;https://github.com/hypothesis&#34;&gt;at Hypothesis&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Keeping reviewers happy when developing larger changes</title>
      <link>https://robertknight.me.uk/posts/code-review-and-large-changes/</link>
      <pubDate>Fri, 05 Apr 2019 00:00:00 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/code-review-and-large-changes/</guid>
      <description>&lt;h2 id=&#34;the-challenge&#34;&gt;The challenge&lt;/h2&gt;&#xA;&lt;p&gt;When developing a large change to a project, in a team that uses code review and&#xA;frequent deployments, there is a conflict that often comes up:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;There is uncertainty at the outset about what exactly will need to change and&#xA;the best approach to take. This tends to demand being highly iterative while&#xA;working on the code. You&amp;rsquo;ll find unforeseen complexities part-way through.&#xA;You&amp;rsquo;ll figure out a better solution once you&amp;rsquo;ve got something working. You&amp;rsquo;ll&#xA;make a mistake or a typo and need to make &amp;ldquo;fixup&amp;rdquo; commits to correct it.&lt;/li&gt;&#xA;&lt;li&gt;At the end you want to present a result at the end which is easy to review,&#xA;minimizes deployment risks, and provides a clear record of the rationale for&#xA;past decisions for your future self and other team members. This demands&#xA;delivering changes in small, clearly organized increments, as if you knew&#xA;exactly what you needed to do beforehand and never made mistakes.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2 id=&#34;a-development-strategy&#34;&gt;A development strategy&lt;/h2&gt;&#xA;&lt;p&gt;In this post I&amp;rsquo;m going to describe the workflow that I use to try and meet both&#xA;these needs. The strategy is to optimize for being able to make changes quickly&#xA;and easily at the start and get feedback that might result in significant&#xA;changes early, yet makes the review and deployment steps easy later.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Browserify and dependency mocking</title>
      <link>https://robertknight.me.uk/posts/browserify-dependency-mocking/</link>
      <pubDate>Thu, 28 Feb 2019 00:00:00 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/browserify-dependency-mocking/</guid>
      <description>&lt;p&gt;&lt;em&gt;Update (2019-04-11) - After exploring various alternatives, I wrote a new&#xA;&lt;a href=&#34;https://github.com/robertknight/babel-plugin-mockable-imports&#34;&gt;Babel plugin&lt;/a&gt; to&#xA;solve the problems outlined in this blog post.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://browserify.org&#34;&gt;Browserify&lt;/a&gt; is a tool that enables a collection of&#xA;Node.js-style modules (aka. CommonJS) to be bundled together into a script file&#xA;that can be loaded in the browser.&lt;/p&gt;&#xA;&lt;p&gt;This post explores the structure of the JavaScript bundles that Browserify&#xA;generates and how the proxyquireify package modifies the bundle to support&#xA;mocking of &lt;code&gt;require&lt;/code&gt; calls in tests. It assumes that you are familiar with&#xA;creating modules in Node. Towards the end I explain some of the caveats with&#xA;Proxyquireify&amp;rsquo;s approach and briefly explore alternatives.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Encrypting secrets in a Git repository using git-crypt</title>
      <link>https://robertknight.me.uk/posts/git-crypt-intro/</link>
      <pubDate>Thu, 08 Feb 2018 12:43:34 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/git-crypt-intro/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/AGWA/git-crypt&#34;&gt;git-crypt&lt;/a&gt; provides a way to encrypt a&#xA;subset of files in a Git repository such that only specific collaborators can&#xA;decrypt them, while making it possible for everyone else to access the&#xA;unencrypted files and perform standard Git operations on the repository. At&#xA;&lt;a href=&#34;https://github.com/hypothesis&#34;&gt;Hypothesis&lt;/a&gt; we use this to store various secrets&#xA;(API keys, passwords) in a &amp;ldquo;playbook&amp;rdquo; repository for use by developers involved&#xA;in the operation of the web service, while making it possible for a wider&#xA;audience of staff at the organisation to access and update other resources in&#xA;the same repository.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Web request and database transaction integration with Pyramid and SQLAlchemy</title>
      <link>https://robertknight.me.uk/posts/pyramid-db-transactions/</link>
      <pubDate>Mon, 29 Jan 2018 16:45:17 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/pyramid-db-transactions/</guid>
      <description>&lt;p&gt;I recently had to debug a &lt;a href=&#34;https://github.com/hypothesis/h/issues/4704&#34;&gt;thorny issue&lt;/a&gt; in&#xA;&lt;a href=&#34;https://hypothes.is&#34;&gt;Hypothesis&lt;/a&gt; with the integration between our web framework&#xA;&lt;a href=&#34;https://docs.pylonsproject.org/projects/pyramid&#34;&gt;Pyramid&lt;/a&gt; and database ORM&#xA;&lt;a href=&#34;http://www.sqlalchemy.org&#34;&gt;SQLAlchemy&lt;/a&gt;. This integration is responsible for&#xA;ensuring that changes to business objects (annotations, users, groups) made when&#xA;processing API requests or form submissions actually get persisted to the&#xA;database. Understanding how this works from the existing documentation was not&#xA;straightfoward. These are my notes on how the various pieces fit together.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://www.sqlalchemy.org&#34;&gt;SQLAlchemy&lt;/a&gt; is a Python database ORM which uses the&#xA;&lt;a href=&#34;https://martinfowler.com/eaaCatalog/unitOfWork.html&#34;&gt;Unit of Work&lt;/a&gt; design&#xA;pattern. In UoW, changes made to database rows via manipulations of ORM objects&#xA;are grouped into transactions, which are then either committed or rolled-back as&#xA;an atomic unit. The application makes commands to the database via a&#xA;&lt;a href=&#34;http://docs.sqlalchemy.org/en/latest/orm/session.html&#34;&gt;&amp;ldquo;Session&amp;rdquo;&lt;/a&gt; object.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Notes on React Europe 2016</title>
      <link>https://robertknight.me.uk/posts/react-europe-2016/</link>
      <pubDate>Sat, 04 Jun 2016 00:00:00 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/react-europe-2016/</guid>
      <description>&lt;p&gt;The second &lt;a href=&#34;https://www.react-europe.org/&#34;&gt;React Europe&lt;/a&gt; conference has just&#xA;finished and this is a jotting-down of some thoughts on the conference and my&#xA;favorite talks whilst the Parisian red wine and almond croissants clear out of&#xA;my system.&lt;/p&gt;&#xA;&lt;p&gt;The organizers are kindly&#xA;&lt;strong&gt;&lt;a href=&#34;https://www.youtube.com/channel/UCorlLn2oZfgOJ-FUcF2eZ1A&#34;&gt;putting up videos on YouTube&lt;/a&gt;&lt;/strong&gt;&#xA;as I write this.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-conference&#34;&gt;The Conference&lt;/h2&gt;&#xA;&lt;p&gt;This was a two-day conference preceded by a hackathon kindly hosted by Mozilla&#xA;and a welcome event hosted by &lt;a href=&#34;https://twitter.com/redbadgerteam&#34;&gt;Red Badger&lt;/a&gt;.&#xA;It was well organized and ran smoothly, the main part consisted purely of 30&#xA;minute talks with a few lightning-talk spots. There was plenty of time&#xA;in-between for discussions.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Optimizing Webpack build times and improving caching with DLL bundles</title>
      <link>https://robertknight.me.uk/posts/webpack-dll-plugins/</link>
      <pubDate>Sat, 06 Feb 2016 00:00:00 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/webpack-dll-plugins/</guid>
      <description>&lt;p&gt;Webpack&amp;rsquo;s &lt;code&gt;Dll&lt;/code&gt; and &lt;code&gt;DllReference&lt;/code&gt; plugins are a way to split a large JavaScript&#xA;project into multiple bundles which can be compiled independently. They can be&#xA;used to optimize build times (both full and incremental) and improve caching for&#xA;users by putting code which changes infrequently into separate &amp;ldquo;library&amp;rdquo;&#xA;bundles. The term &amp;lsquo;Dll&amp;rsquo; is short for &lt;em&gt;Dynamically Linked Library&lt;/em&gt; which is a&#xA;feature for native Windows applications that solves the same problem.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Understanding the QWidget layout flow</title>
      <link>https://robertknight.me.uk/posts/qt-widget-layout/</link>
      <pubDate>Thu, 21 Nov 2013 00:00:00 +0000</pubDate>
      <guid>https://robertknight.me.uk/posts/qt-widget-layout/</guid>
      <description>&lt;p&gt;When layouts in a UI are not behaving as expected or performance is poor, it can&#xA;be helpful to have a mental model of the layout process in order to know where&#xA;to start debugging. For web browsers there are some good resources which provide&#xA;a description of the process at different levels. The layout documentation for&#xA;&lt;a href=&#34;https://www.qt.io&#34;&gt;Qt&lt;/a&gt; describes the various layout facilities that are&#xA;available but I haven&amp;rsquo;t found a detailed description of the flow, so this is my&#xA;attempt to explain what happens when a layout is triggered that ultimately ends&#xA;up with the widgets being resized and repositioned appropriately.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
