Posts Tagged PHP

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.

But The Family Wishlist had a problem, one that I hoped – as all problems do – would go away if I ignored it long enough. Much to my surprise, it got worse. Worse and worse.

Or, if not worse, than at least less forgiveable.

The Family Wishlist, you see, wasn’t mobile friendly. Like, at all. But come on guys, it was 2008. Did smart phones even exist then?
It’s impossible to say. But what I can tell you is they exist now; moreover, people use them. Constantly and for everything.

So, after putting it off for ten years – through the power of procrastination – I finally did it. Or, redid it, as it were. I’ve rewritten it entirely, using my API framework (lull7) for the back-end, and react for the front-.

Also, no more ads. Who wants to see those, right? Especially on a phone, where space is minimal.

So if you and your family need to coordinate gifts this season (or any season), give it a try! I don’t know, maybe you’re running a Secret Santa or some such. It does that too. Also, family isn’t mandatory – orphans are welcome.

As with, I’m sure, many people, Mandrill’s recent changes found me looking to jump ship. Oh well, it was great while it lasted. Since we already use a number of AWS services, it made a sort of eggs-all-in-one-basket sense to switch to SES as our replacement.(more…)

Switching away from Mandrill, I found Amazon SES was sending two emails from my PHP test script. This only happened when hit from the web, running the same script through the PHP-CLI sent one email, as expected.

Looking at Chromes network tab, turns out it was loading the script as well as favicon.ico. Alas, there was no favicon.ico, and in the sites-enabled config for that location the FallbackResource was set to /index.php. Turns out it was loading index.php twice, resulting in two emails.

I used Bradicon! to create a quick favicon, uploaded it, and bam!, just one email from then on.

You shut the door behind you, hang your keys on the wall, and expertly slip out of your shoes. You’re home, the birthday party is over, and what else is there to do but check the status of your servers.

Oh, no, disaster has struck.

df -m reports your disk usage is at 100%. You feel the wave break over you as panic settles in.