Core Data Property-Level Model Validation in Swift 4

IN SWIFT

I ran into an issue while writing property validation methods for a Core Data stack where the methods simply weren’t being called. After a bit of head scratching I realised it was because the methods needed to be annotated with @objc. This wasn’t needed in Swift 3 because @objc was inferred on all methods of subclasses of NSObject; however, the behaviour of @objc inference changed in Swift 4. Now, subclasses of NSObject must explicitly mark methods that need to be accessible from Objective-C. This took longer to realise than it should have since the Core Data documentation’s sample code for property-level validation hasn’t been updated for Swift 4.

Read More…

Strongly Typed Notifications in Swift

IN SWIFT

While working on rewriting Spotijack in Swift, I started to feel dissatisfied with Foundation’s notification API. It’s a stringly typed API that makes heavy use of Any and as someone who loves their types this makes me sad. To cheer myself up, I set about writing a more strongly typed notification system.

The end result is a small library1TypedNotification—that provides a set of protocols defining a more descriptive type system for notifications. Check out the GitHub project if you’re interested. There’s a Playground in it demoing the protocols. The rest of this blog post will cover them in a bit more detail.

Read More…

Fixing MATLAB on Fedora

IN MATLAB LINUX

The other week I had to set up a new installation of MATLAB r2016a on a (somewhat) fresh Fedora installation. After running the installer, I ran into a bunch of library errors when trying to run external C++ programs1 from MATLAB or when trying to plot something. When running an external C++ program, MATLAB would complain about missing versions of CXXABI and GLIBCXX in libstdc++2. When plotting something, MATLAB would complain about libmwosgserver.so.

Read More…

Integrating Receipts with ledger-mode

IN EMACS LEDGER

I’ve written a couple of functions for Emacs’ ledger-mode that make working with receipts a bit easier. With the cursor on a transaction, calling alex/ledger-attach-receipt will prompt for a file. This function copies the file to a receipts directory, renaming it to its hash and sorting it in subdirectories according to the transaction’s year and month1. Finally, the function adds a comment to the transaction with the hash of the file. The function alex/ledger-open-attached-receipt reads this comment and opens the associated file in Emacs. The receipts folder can be customised through the variable alex/ledger-receipt-folder.

Read More…

Using Ledger With an Encrypted Journal

IN LEDGER

I’m a pretty big fan of Ledger, a command line accounting system based on the double entry bookkeeping system. One of its strengths lies in the fact that the journal file that contains your transactions is a plain text file. This makes it super easy to sync the journal using your favourite file syncing service. Of course, before putting the journal file on a remote server, you’ll probably want to encrypt it. Ledger program doesn’t support encrypted journal files but, using GPG and a shell alias, you can get the vast majority of Ledger’s functionality to work with an encrypted journal.

Read More…