Posts

Precaching Moodle Theme CSS

I've run into a few issues recently with my Moodle site (moopi.uk) due to the amount of time it takes for Moodle to compile the CSS cache for the new default theme, Boost.

For most this is may be a one off issue that will go away once the CSS is compiled for the first time. This however really affects me as my site runs on a Raspberry Pi and so is lacking the raw grunt most servers will have to take this initial hit. On moopi.uk it takes over 10 mins to run this CSS compilation and as such does not finish within my PHP max_execution time. I could just raise my timeouts above this, but this still would mean my first visitor will probably never see a page load.

While this may actually be a bug it's still very much a general problem for me running on such minimal resources. My solution is to run a CLI script to precache the Moodle CSS after an upgrade and before I leave maintenance mode. Now any downtime is graceful and CSS compilation and caching occurs without being affected by…

Moodle on Centos or Red Hat 7 (with SELinux!)

Why the need for another 'Installing Moodle' guide? Two reasons, Systemd and SELinux.
The steps are presented as a Bash script, which may be run on a virgin system, installing a complete working Moodle stack in one go, including enforcing SELinux.

In addition to the absolute basics it also includes adding ClamAV virus for file uploads and Memcached for sessions and 'MUC'.

It does not cover any extras you will need to get your site up to production, e.g. securing your database or updating your virus definitions automatically. Neither does it do any extra PHP configuration (upload limits, execution time etc.) or any extra complexities that might be desirable. For all of this you should goto docs.moodle.org.

Moodle on a Raspberry Pi 2 - moopi.mrverrall.co.uk

I've occasionally wondered if it was at all practical to run a small functional Moodle site using just a Raspberry Pi and whenever I've been half tempted to try I've came to the swift conclusion that the answer was most likely 'No'; and I think this is still probably the case today.
We are now however in the brave new era of the Raspberry Pi 2 where we have more cpus and RAM to play with, and after my friend Moodle Fairy asked if it was at all possible or indeed worthwhile to do such a thing I decided it was time to give it a real shot and put to task my experience in optimising Moodle at work hosting a Moodle site on the decidedly lightweight Pi 2.
So what is the answer? Can you run a useful Moodle on a raspberry Pi 2? Well, yes you can! And not only that I have been rather impressed with the sites overall performance which has exceed all reasonable expectations. Your average page load time is well under a second.
Rather than go into more details here, I'll s…

Raspberry Pi A2DP Bluetooth Audio Receiver

I wanted to use a Raspberry Pi to act as a Bluetooth audio receiver or my Hi-Fi so that I could connect a phone/tablet easily to some proper speakers wirelessly. Rather than reinventing the wheel 'kmonkey' has already achieved most of what I set out to do over here; check this out first.

The only issue now is the manual intervention needed to connect up a new Bluetooth source to the output sink. I initially created a simple bash script to poll pulseaudio (every 5 seconds) and run the necessary commands as and when a new device is connected. You can see the script here and all the pertinent commands are explained over in kmonkey's blog. This is all good, but will need to be run manually using something like,

# nohup ./bt_audio_attach &

This is a bit rubbish and you'll be pleased to know there is a better way to get this done, UDEV!

Over at the Raspbery Pi forums  there's some discussion on using UDEV scripts to automate this process entirely. Initially I had…

Blocking Adverts from the Roku Menu

UPDATE: 18 May 2013 - A new firmware (v5) has changed the way ads are handled on the Roku such that this guide is no longer relevant. 

Roku are are a pretty neat little media streaming box but one thing that I think lets them down are the trashy and mostly irrelevant adverts on the home page. Wouldn't it be great if you could get rid of these?

The ads are served by the third party ad platform, ZEDO. You can block the ads from displaying by simply blocking this domain entirely or by being more targeted and blocking the specific sub-domain serving the Roku ads. A TCPDUMP of my Roku shows that the ad images currently come from 'd7.zedo.com' (although this may change).

I block them by adding a custom DNS record for this sub-domain to my home router pointing to the loopback address (127.0.0.1). There are or course many other ways you could do this, but the best way will largely depend on your own set-up and resources.

An Exercise in Form Validation using JavaScript Prototyping

Form validation is an important part of most websites and more specifically client side validation is an important contribution to the the user experience.

In the brave new world of "Web 2.0" we have access to tools like JQuery to help developers to do this sort of jazz with AJAX and the like. This however (regardless of how straight forward it actually is) is still scary and complicated for anyone not already familiar with JavaScript.

The code I want to talk about here is of my own creation. I'll be the first to admit that "I am not a developer", and so the code itself may not be technically perfect, for this I make little apologies.

What I set out to do is create a reusable code class; a class which can be reused to validate any form without modification or an excess of additional javascript. I also took the opportunity to tinker with 'prototyping' to take a true object orientated approach to the code; this makes it fast and hopefully easy to follow…

If you were an animal what would you be and why?

Recently I was asked to be involved in the recruitment process at my place of work and had to, with the help of two of my team members, spend half an hour interviewing prospective job candidates. Now I've had a few interviews in my time and seem mostly to do quite well in that kind of situation, but this would be my first experience on the other side of the table.

I remember having read interview guides before now that had warned me to be prepared for silly questions like 'If you were an animal what would you be and why?'. So with the simple intention of using this very question as an icebreaker (and partly becaused I'd enjoy using such a cliché) we decided I could kick off with it.

We weren't hoping to get anything useful out of it at all, but in hindsight the animal question proved way more valuable than I could have ever expected, not because of any in depth analysis into the answers, such as lions as leaders or any crap like that, but purely on how the intervi…