WordPress Plugin Update and Install Functions

On the page where they explain how to create tables for your plugin, there’s a link to the register_activation_hook function, which is run when the plugin is activated. However, right in the first section, it says:

Note: Don’t use activation hooks (especially for multisite). Do this instead:

It’s far better to use an upgrade routine fired on admin_init, and handle that per-site, basing it on a stored option.

That links to another page, which repeats the information, but doesn’t tell you how to do this. Here’s one way. Continue reading WordPress Plugin Update and Install Functions

Yet Another Parallax Effect, but This One Wastes Fewer Pixels and Bytes.

Everyone loves the parallax effect, and I’ve been swiping snippets of code to do it for a long time, but never really thinking about it too much. You load it, set some parameters, and that’s it. I was having a little glitch with one, and was tweaking it, and I started to wonder why the effect didn’t just start at one end of my image, and end at the other end.

After all, if I don’t show all the pixels, I’ve “wasted” all those network bytes to load the data, and all the memory to hold the data.

This parallax effect is stingy with network bytes.
Continue reading Yet Another Parallax Effect, but This One Wastes Fewer Pixels and Bytes.

Responsive Design + Mobile First = Automated Layouts

I’m shocked at how many businesses still have websites that don’t work in mobile. For the average person, reading web pages on a smartphone is the primary way they read content on the web.

Though I’m not 100% on board with “mobile first”, it should soon be the norm. To CSS hackers, “mobile first” just means implementing the mobile layout first, then making the wider-screen layout the exception.
Continue reading Responsive Design + Mobile First = Automated Layouts

End the Chaos, Get with the Program: Python Logging to Syslog, and Filtering with RSyslog

This article describes how to use Python’s logging
library to send logs to syslog. Then, using rsyslog,
a fancier syslog, we produce a log of pre-filtered
output.
Continue reading End the Chaos, Get with the Program: Python Logging to Syslog, and Filtering with RSyslog

One Event Bus to Rule Them All! d3 Dispatch, the d3 Event System, Notes

Learning d3 events this afternoon. These are the notes I’m taking while I’m learning it. I hope it helps.

It’s called d3.dispatch. d3.dispatch(‘eventname1′,’eventname2’) returns an object that manages setting event handlers, and dispatching events. The event system isn’t global (unlike in most frameworks, where the event system appears to be globally available)- it’s contained entirely within the object.
Continue reading One Event Bus to Rule Them All! d3 Dispatch, the d3 Event System, Notes