Posts Tagged Documentation

Posted on Programming

Logic parsing & cat breeds

Logipar – an open source logic parsing library

Logipar, pronounced Lojipur (and soon you’ll see why), has a history.

It always starts out like this: I’m working on a project and it has some form of filter box – where you can type, and the results shown will be limited to those relevant to what you’ve typed. So you can type “cat” and it’ll show you all cats.

That’s easy enough. But then I want to be able to match multiple things simultaneously – to see all the cats as well as all the dogs.

Still easy, I normally split on commas – “cat, dog” would show all cats and all dogs.

And here is where things get troublesome. Sure, I can list all the cats and all the dogs, but what if i want to list only results that are both cats and dogs.

Okay this example is starting to break down. Where I’m going with this is logic parsing. Splitting on commas, I have to decide whether to join them with a logical OR (show all the cats as well as all the dogs) or with a logical AND (show only results that are BOTH a cat and a dog).

And sure, I can pick one or the other, but what if I want the option to use either?

So I made Logipar. An open source library for parsing logic strings. With Logipar I can type “cat OR dog“, or I can type “cat AND dog“. And it’ll parse that logic for me.

Logipar works in multiple languages, which is convenient because I work in multiple languages. Now to go back and add it to all the various tools I’ve ever written. JK, I probably won’t do that.

But all future projects.. That’s a different story!

You can use it too, if you want, I mean. No pressure.

 


Cat breed data

Having built Logipar, I wanted to create a demo for it. To identify any obvious bugs, sure, but more to better convey what Logipar does and is capable of.

For that, I needed some data. And the first thing that came to mind was cats.

When I went looking for a cat breed dataset, I found nothing. Sure, there were some websites with breed data – but they weren’t great. Fields would randomly be missing, or displayed in completely different ways.

I spent an entire day compiling the data from five different sites (wikipedia, cattime, petfinder, purina, and royalcanin), conjoining it, and then cleaning it up.

Now I have a cat breed dataset.

So if you want to see what Logipar can do and learn about cats, boy, do I have a tool for you: https://altef.github.io/logipar – conveniently iframed below:

It shows more or fewer fields based on the width of its container.



Posted on Programming

Magically managing menus

Hey, so, I’m going to detail my method for making menus. I’ll try as well to explain the reasons behind the choices I make. If you have any questions, let me know and I’ll try to fabricate a plausible answer.

Two popular menu types are drop down menus, and your basic expanding lists. But good news, the HTML we use for both is the same! Why? Because they’re both menus! They may look different, but in essence they’re nothing but a nested list of links. And in my opinion, we should do our best to use HTML to describe the data we’re presenting.

One big bonus is that if we take out the CSS, the website still usable. We can also easily provide alternate stylesheets for things like mobile phones, and pages are easy to navigate from text-based browsers. Most importantly, the HTML is short, clear, and easily readable.

Which is why I’m going to use nested lists. The styling will be done with CSS, and some event handling with Javascript (I’ll use JQuery because it’s nice, but don’t feel tied to it).

I’ve prepared a page complete with code quotes and comments:

I was too lazy to style it. Also, the magic was a trick. There was no magic. I’m sorry.

Your friend,
Brad