RSSAmplifier

Blog

Plingdollar

Plingdollar is the various projects and musings of me, Will Speak. I am a computer science graduate and software developer. I have dabbled in a variety of programming languages. When it comes to user interfaces I’d rather have a command line. I have an interest in photography and a weakness for all things mac.

willspeak.meRSS feed ↗38 posts

Latest posts

Scrubbing Up

One of the key features that makes Scheme such a powerful language is the support for powerful macro transformations. A Scheme program goes through a stage of syntax expansion before the program is bound. Many syntax constructs in Scheme programs are in fact macros. So far in Feersum our macro support has been lacking a core concept however: hygiene. In this post I aim to outline the shape of the…

On the Same Page

At the end of 2021 GitHub pages deployments moved to using GitHub actions . When a site is deployed you can see the jobs running to generate your site, package it up ready to be deployed, and push it to the GitHub Pages service. Lets try using these actions in a custom GitHub Actions workflow to build and deploy a site without using Jekyll. There are two main steps in the deployment of a site to…

Into the Dark

I’ve finally dragged this blog into the 21st century with the addition of Dark Mode . In this post I’ll walk through some of the main tasks, and dig into the approach I took. The first step was to get rid of colours hard-coded into the CSS. The old style-sheet was full of #FFF s and #222 s along with more esoteric tints, tones, and shades. I worked colour by colour to pull them into a single block…

Red Green Syntax Trees - an Overview

It’s no secret that I’m a big fan of a good parser. One of the key parsing techniques that I have tried to focus on in the past is “infallible parsing”. The idea that for any input the parser should always generate some output. This is important to try and give as accurate a set of errors as possible when malformed or partial code is being analysed. An idea that builds on this is lossless syntax…

Granola Slices

A quick and easy recipe for the flapjack I miss from the office. Ingredients Porridge oats: 250 grams Strawberry Granola: 10 grams Cake Fruit: 30 grams Pumpkin Seeds: 10 grams Butter (melted): 150 grams Sugar: 150 grams Golden Syrup: 2 tbsp Method Pre-heat the oven to 180C (fan). Line a baking tray with greaseproof paper. Combine the dry ingredients in a large bowl and set aside. Place the butter…

Error Recovery in FParsec

An interesting discussion on error recovery with the nom parser combinator in Rust has been sitting on my “To Read” list for a few months. After re-reading it a few times I have been inspired to try out the approach in that article using the FParsec library . Just as in that example we will attempt to parse the language defined by the following Parser Expression Grammar (PEG): expr ← sum sum ←…

A Captivating Resolution

Compilers are generally split into three stages: syntax, semantic, and emit. The translation from syntax tree, produced by the first stage, to semantic tree, consumed by the latter stages, is called binding . Binding involves walking the syntactic representation, resolving variable references, and producing a tree based on the semantic structure of the program. For a single scope variable lookup…

LISP in Two Days with Rust

As a sidetrack from the development of my programming language I’ve spent some time developing a LISP . The plan is to use the language as a testing ground for experimentation with transforming an AST in Rust. The syntax of LISP is simple and was developed to be easy to parse. I figured it would make a good starting point for an experimental compiler. The language I’ll be developing here is…

Optional Extras

A neat feature of the Option<T> type in Rust is that it implements the From<T> trait. This allows for ergonomic optional parameters: fn print_int < T : Into < Option < u32 >>> ( stuff : T ) { match stuff .into () { Some ( value ) => println! ( "{}" , value ), None => println! ( "no value!" ), } } This function can be called with a standard Option value like print_int(Some(100)) or print_int(None)…

Racing Onwards

I’m a long term Emacs user. When I first started writing rust I concocted an Emacs configuration using racer-mode and rust-mode directly which got the job done. Since then the state of Rust editor support has come a long way. I’ve finally taken the plunge and moved to RLS for a richer language completion experience. RLS is the Rust Language Server. It implements the standardised “language server…

Once More with Handlers

I previously wrote about creating a custom authentication middleware in ASP .NET Core . With the move to ASP .NET Core 2.0 this approach at creating custom authentication providers no longer works. It’s time drag custom authentication into the Year of the Fruit Bat with an ASP .NET Core 2.0 AuthenticationHandler . Where previously we registered a custom middleware when configuring our app we…

Upon Reflection

I’ve been spending most of my time recently performance profiling and optimising one of our main services. Part of its job involves exposing data objects through a generic interface. The abstraction allows public properties on each object to be read using an untyped indexer. To do this we look up all the properties of each data object via reflection and cache them so later reads and writes are…

Make it work Switch

During some performance testing of an application a colleague and I had trouble processing more than 150 requests per second per instance. After much hair-pulling the bottleneck was identified as the ServicePointManager.RequestLimit . This global variable controls the number of parallel HTTP requests that a .NET app will make to a given domain. By default it is set to 2, throttling the load that…

Authentication Middleware in ASP.NET Core

There are two sides to the auth story in ASP .NET Core: authentication and authorisation. Authorisation is usually controlled in an MVC app with the [Authorize] attribute. The simplest, no-argument [Authorize] checks that the user has a single identity which is authenticated. Authentication is responsible for inspecting the request and adding known identity information about the user. In many…

Rusting up Some Iron

Rust is one of my favourite languages. One of it’s great strengths is its ecosystem of crates , another is the FFI system which enables writing native extensions when performance or safety is required. Over the last week I’ve been pulling these two together in IronRure , a .NET Standard wrapper around the Rust regex crate. I started this with zero knowledge of FFI in C#. I was pleasantly surprised…

The Pragmatic PasswordBox

In WPF the PasswordBox control does not expose the password it contains through data binding. It is a security feature designed to protect the sensitive data the box contains. It is however quite a faff and has sparked much debate . Recently I’ve been experimenting with ReactiveUI . ReactiveUI brings together the elegance and power of Reactive Extensions (RX) and MVVM to provide a clean, simple,…

The Dark Side

At work I’m paid to write C#. At home I’m a dedicated Mac user. When I initially learnt C# for the job interview years back I had to use Mono to run it on my Mac. A lot has changed in the .NET world since then, most notably the arrival of .NET Core . So I finally decided to give it a try. The installation on OS X was really simple. So far I’m really enjoying compiling stuff from the command line…

The Lies

At the weekend I was listening to Stereophonics ~ Performance and Cocktails . The song Half the Lies you Tell Ain’t True reminded me of a certain public figure. I have no idea why. But when you rely on a lie that’s true, And no one believes in the things you do ‘Cause half the lies you tell ain’t true It’s been stuck in my head ever since. My brain can’t quite remember the verse, so it’s…

The Missing Link

LLVM is great for hacking about with languages. It takes a lot of the complexity out of code generation. It allows you to turn your SyntaxTree or whatever you’ve got into real live object code. Code you can directly execute. Well, almost. The last crevasse that LLVM plonks us down next to is linking . Taking a collection of object files, adding the C runtime library and producing an executable…

Low Down - Part 2 - Initialisation

In my previous post I left out something quite important: initialising the components of LLVM we wanted to use. Luckily there’s a quick and easy way to get that sorted, and we get to learn about a neat part of the Rust standard library. LLVM itself is composed of many modular libraries. This is great for library consumers as you can pick just the bits you want to use in whatever application you’re…

The Low Down - Using LLVM From Rust

LLVM is a collection of libraries and programs for creating compilers. It is built around a powerful intermediate representation, LLVM IR. It has tools for compiling LLVM IR to native instructions, performing optimisations and even performing JIT compilation. The libraries that power this have an extensive C API allowing you to harness this power yourself, so that’s what we’re going to do! I’ll…

Top-down Operator Precedence Parsing in Rust

Following on from from creating a tokeniser the next step is writing a parser. The simplest way to create a hand-rolled parser is using recursive decent . In this parsing method each non-terminal in the grammar is converted into a function which encodes it’s parsing logic. This is great for parsing things like function definitions, variable declarations and other parts of a language which can be…

Doing Nothing

When hacking on a problem it’s easy to get carried away with the how. How are you going to divide up the implementation. How are you going to ensure it’s testable. Usually these hows are quite narrow. I used to head to and from work on the bus, however i’ve recently switched to cycling in. It’s quite nice to be able to take a break from the how and do nothing. Taking some time out often means you…

768 is the Magic Number

When reconstrucing a binary MSMQ message from a backup I was first tempted to just set the Body property on the message directly. This doesn’t quite work however as the Body property is serialised with whatever formatter you’re using when the message is sent. var mq = new MessageQueue ( @".\Private%\test" ); var messageBody = File . ReadAllBytes ( "..." ); var message = new Message (); message .…

Hacktoberfest

One of my favourite new languages right now is Rust . It’s an interesting combination of strong typing, low level control and memory safety. Rust is a rapidly growing and changing language, and now is a great time to get involved as part of Hacktoberfest. Hacktoberfest is GitHub & Digital Ocean’s yearly celebration of open source code. Submit 4 pull requests to open source projects on GitHub and…

A Rusty Guide to Tokenising by Hand

I recently wrote about creating a tokeniser in C++ using Ragel . In that post I created a lexer which recognised a set of three tokens. In this post I’ll discuss creating a lexer by hand in Rust to recognise the same language. The job of a tokeniser is to break down a piece of text into a set of tokens, or lexemes. A token consists of two parts: an identifier which defines which regular expression…

Microcrates: Little Flecks of Rust

Gists are really just git repos with no directory structure. This is something that some Rubyists have taken advantage of in the past to create “Microgems” . Would it be possible to do the same thing in Rust? I was in the process of messing around with some Rust code. I had created a new crate with cargo and hacked around a bit. Not wanting to lose my changes I’d created a git repository too. We…

Tokenising in C++ with Ragel

Ragel is an alternative to Lex/Flex for creating lectures from a set of regular expressions. It is far more powerful however. Where Lex allows you to chain together a set of regular expressions and run some actions written in C or C++ in response to a match Ragel allows you to generate an arbitrary state machine by combining regular expressions and then run actions at any point in the matching of…

Joining the Disqusion

I have finally got around to adding commenting to this blog. In the end it turned out to be quite simple. I chose to use Disqus as it was such an easy option to embed, and has support for many different blogging platforms. To embed it in Jekyll was as simple as copying the sample HTML from the Disqus website. There are some subtleties to getting this all working properly with Jekyll though. If…

Sneakernet Push

I’ve been living without internet recently. That hasn’t stopped me writing code though. If anything it has accelerated the process. I’m mainly using Git these days. It’s more than at home working without a connection to my repos on GitHub. Every now and again I like to back things up though. That’s where the “ Sneakernet Push ” comes in. Start by creating a new empty git repository somewhere on…

Testing Times

It’s been a hectic few months. I’ve just moved from the blistering sunshine of the south of England to the chilly embrace of the north. That means I’ve not been able to spend that much time writing code outside of work. Now things have calmed down a bit I decided to integrate google test into a C++ application I am developing. This is the story of just how easy that was. There is a lot of code in…

The First Solution and The Best Solution

There is a saying. I’m not sure where it comes from. I’m not even sure if I made it up entirely. But I find it entirely appropriate when developing software. The first solution is usually not the best solution. But it’s better than no solution at all. Programming is all about solving problems. It’s about breaking difficult things into smaller things you already know how to do. Most of the time…

Loosing Focus

The air is warm. Too warm perhaps. There is almost no wind at all. What breeze there is does nothing to cool. Lights twinkle on the skyline in intricate patterns. I slide them out of focus. Snap.

Help, I'm Learning (and It's Fun)

It all started one fateful day, as these things have a habit of doing. A friend was playing a game on his laptop where he launched rockets into space. He informed me that it was called “ Kerbal Space Program ”. I thought nothing of it until I came across the game again in the Seam store. Now I’m hooked. The game is still in beta, but there are still hours of fun to be had. The mechanics of the…

A Splash of Colour

I began my text editing journey, as many do I am sure, with Notepad.exe . When I made the transition to OS X I began searching for an editor to replace it. The then-free Smultron was that editor initially. Since then I have used many editors, from the wonderful TextMate to the cheap-and-cheerful GNU nano . I even tried vim and, of course, Emacs . In the endless search for the text editor I enjoy…

Secure for the Common Case

“I’ll have to type in that thing again” my dad moaned. “They gave me a new laptop and I haven’t used it on the wireless yet.” he explained. The “thing” he was referring to of course was the wireless key. A completely incomprehensible string of numbers and letters that took up three lines on the back of the junk-mail envelope in his hand. I began wondering exactly how secure the house wireless…

How to Recognise a Tortoise

Computer vision is an area which I had a distant interest in for quite some time. I appreciate that the task of vision is a complex one and always imagined that there must be some great algorithms behind the task. The process of computer vision, like many areas of artificial intelligence, is one where it is so easy to view the actions of a computer as those of a person. It was this lingering…

Testing Testing Testing

Scripting languages are all the rage these days. I am a fan of Python, although you may prefer Ruby, Node.js or whatever it is the cool kids are using these days. The exact language that takes your fancy however doesn’t really matter. They almost all have one thing in common: Unit tests. This is not a startling realisation, nor is it restricted to the realms of modern scripting languages. I hear…