php

/Tag: php

OG cards for WordPress link posts.

Some of you may have noticed recently that alis.me has started displaying OpenGraph meta information at the head of link-type posts (e.g. this post).

I admit I stole this idea from Tumblr, or rather I stole it from updating my (unreleased) WordPress-to-Tumblr crossposter plugin to support Tumblr’s support (“support”) of OG cards.1 I figured the idea would be cool to implement locally as well, and when I couldn’t find an existing plugin that did exactly what I wanted, I decided to write my own.

(more…)

  1. I say “support” because Tumblr doesn’t auto-populate OG cards for link posts created by the API because… reasons, I guess. Also, I still can’t get it to accept the photos property, because… fuck you Tumblr, I guess.
2018-05-15T09:37:28+10:0015th May, 2018|Tags: php, wordpress, xp|

Recurring todos in HabitRPG via PHP.

So some of you may remember a while back I started “playing” (using?) HabitRPG. Habit is basically a cross between a task management app and an RPG game. Instead of things like “kill ten rats”, your quests are things you define from your own todo lists, like “go to the gym” or “write your goddamn book you lazy bastard”.

Habit has three types of tasks: habits are ad hoc things you want to either do (giving rewards), or avoid (bringing pain); dailies are things you want to do either every day, or every Tuesday, or every Sunday and Wednesday, or whatever; and to dos are “projects” you want to do at some point, then tick off.

One of the downsides of Habit is that it doesn’t support recurring tasks that aren’t liked to a particular day of the week. So, for example, I have a daily to take the bins out every Sunday (because that’s when garbage collection is, and it doesn’t make sense to do it on another day), and a habit for washing the dishes (I won’t cry if it’s not done every day… but I should do it). But what about, say, re-dying my hair, which is something I generally want to do on the first Friday of every second month, although if it waits a few weeks it doesn’t matter much (I’ll just suffer through a faded dye job)? Or what about my gym schedule, which is alternating weights and cardio, though, again, doesn’t really matter if I don’t go literally every single day?

Yeah. This can get complicated real quick.

Fortunately, Habit has an API, and I know some PHP scripting. So I whipped up something cute and dinky containing all my silly task auto-creation logic, and run it once a day with cron.

The foundation of the script is a very simple class to access the Habit API, which looks like: (more…)

2018-11-26T08:25:14+10:0016th August, 2014|Tags: php, programming, tech, xp|