Programming

Rock, Paper, Scissors, Prolog!

Simple, classic games like Rock, Paper, Scissors are good to code when learning a new language. The lovely thing about making this game in Prolog is you’re just encoding what it is, not how it is. It’s a subtle difference, but I’ll point it out during this explanation.

Getting JSON data from an API in SWI-Prolog

Some folks don’t make their data available through RDF formats, or nice SPARQL endpoints, instead they provide a (REST/RESTFUL) API and will return JSON data for your request. It can be a little tricky figuring out how to get this data into your SWI-Prolog program. So in this post I demonstrate with a simple example.

Setting Up Unit Testing In SWI-Prolog

Reading the docs for plunit, it can be quite tricky to figure out how to setup a nice unit testing environment and actually run those tests. In this post I demonstrate how I do it, keeping my tests separate from my code, and running them with a handy command.

All Hail The Mighty Vim

Vim is a cruel learning curve, it’s a long way from modern text editors, and yet it is still a popular choice for programmers. Why?! Because it’s worth it. There are many things Vim does well, many things that I could use to show it off. But for this post, I had to choose only one thing, which is evaluating commands.

Python Generators, yield and send

Another little known Python feature that deserves more love. This time we’re looking at the send function that lets you input values into your generator as it’s running. It works through yield and is awesome!

RDFLib Graph with RDBS

It’s tricky to find out how to set up RDFLib Graph to use a RDBS backend, but it can be done using SQLAlchemy and RDFLib-SQLAlchemy. This means it’ll support all the engines SQLAlchemy does, including MySQL and Postgres. I’ll highlight two gotchas to look out for when using RDFLib-SQLAlchemy and walk you through getting setup using a wrapper class to RDFLIB Graph.

Semantic Web for Google

Google makes extensive use of Semantic Web technologies, although they prefer the term Knowledge Graph. In this post I’ll show you how to add structured data to a Flask Blog app, with JSON-LD and Jinja2 templates to help Google understand your content, which in turn should improve SEO.

Semantic Web for Facebook

Facebook use the Semantic Web. They have an ontology called “Open Graph” that links your webpage into their social graph. This means when someone shares your webpage on Facebook, it’ll look how you’ve specified. In this post I’ll show you how to include this in a Flask blog application with a Jinja2 template.