Mood Lighting

The lighting in my bedroom uses Philips Hue bulbs — specifically, the coloured ones. Last night, I decided it would be nice to set the three lights in my bedroom to cycle slowly through a set of warm colours using a script.

I didn't want harsh transitions from one colour to the next, but for the lighting to fade from one colour to the next in a smooth gradient. Also, I didn't want the three bulbs to all be the exact same colour, but wanted each bulb to be at different stage in the cycle, like they're "chasing" each other through the colours.

So I whipped up a quick script. It requires the command-line tool hueadm to be installed and set up before we start. You can run hueadm lights to get a list of available lights, and in particular, their ID numbers.

Thank You, Coveralls.io

For letting me know my test coverage has increased by 0.00006%.

Coveralls.io screenshot

(Seriously it's a pretty cool service though.)

Finding Squares in Matrices

I don't usually take part in the Perl Weekly Challenge but one of this week's challenges caught my eye. I thought it could be a fun thing to attempt and decided to use Zydeco to help solve it.

The problem is that you're given a matrix of 0s and 1s:

You need to find any squares (equal length sides) where all four corners are 1s:

Applying Operators to Coderefs

In algebra, there's this pretty funky concept:

(f+g)(x) = f(x) + g(x)

And I was thinking if $f and $g were coderefs, what could $f + $g be?

Zydeco::Lite

Today I released Zydeco::Lite, a re-implementation of Zydeco but just using standard Perl syntax. So for example, class { ... } becomes class(sub { ...});.

This has the advantage of much faster compile time, similar run time speed, fewer dependencies, and compatibility with older versions of Perl before the keyword API was introduced. Of course, in some circumstances these aren't important concerns, so the nicer syntax of the full Zydeco will be preferred.

Zydeco and Zydeco::Lite are both based on MooX::Press which itself is based on Moo, Type::Tiny, and other modules. I've taken the synopsis example from the Zydeco documentation and rewritten it using the different layers of abstraction.

About Toby Inkster

user-pic I'm tobyink on CPAN, IRC and PerlMonks.