Lessons Learned Going Offline with HTML5

I recently built a simple web-based CRM tool only to run into a problem: my users didn’t have internet access all the time, so couldn’t reach it when on the road. Primary use was going to be on phones and tablets, so I could have built a native app, but with both Android and iOS devices to support it would have meant learning two new coding environments or a framework which could publish to both.

Having played with some of the features in HTML5 I was aware it had the ability to work offline, storing data locally. So I did a bit of research and began knocking something together. I thought I’d outline some of the lessons I learned on the way.

Giving credit where it’s due, I leant heavily on Alex Gibson’s example, you can find his code on Github.

Making a web page available offline

To make a file available offline, you need to create a cache manifest. Some of the older tutorials I found name it with a .manifest file type (e.g. offline.manifest, cache.manifest) but this didn’t work for me, you need to name it with a .appcache file extension (e.g. offline.appcache).

In there you need to reference all the files and resources you want available offline, and you can also set which files should never be cached as well as what to do if someone tries to access a page which is not available.

To make it easier, I created a completely separate file (offline.html) to do everything I wanted when there was no internet access, using Ajax, in one page.

I did add support to my .htaccess for a cache-manifest content type, but it worked fine before I had done that. Continue reading…

How to Decide on a Processor

It used to be fairly easy to figure out how good a processor was in relation to another, the main manufacturers (Intel and AMD) had two lines apiece — one budget line (Celeron/Duron) and one performance line (Pentium/Athlon) — and the higher the clock rating (measured in Mhz/Ghz) the better it was. These days the raw clock speed is only one aspect of how fast a processor is and with the chip companies updating their ranges more often, using multiple cores and inventing their own benchmarks, it can be very hard to understand what exactly you’re buying. Now there is an argument to say we don’t need to worry about processors any more. Any chip offers at least enough power to do anything a user wants unless they plan to do lot of video rendering (and even then it’ll just be slower). While that may be true, I still recommend avoiding the budget end of the CPU spectrum when buying a new computer so you have a machine that’ll last as long as possible. The price difference is usually minimal and it’ll be more future-proof (I installed Windows 8 on a six-year-old machine recently, the only upgrade it had received in that time was some more RAM). So knowing what you’re buying is still useful, and it lets you compare apples with apples when it comes to prices.

The Current Market

Intel and AMD are still the big boys in the desktop and laptop markets, if you want to run Windows it’ll be on their chips. If you’re looking at a Mac, they’re powered by Intel chips. The current ranges broadly divide as follows:

Manufacturer Low-Power Budget Standard Performance
Intel Atom CeleronPentium i3/i5 i7
AMD C-SeriesE-Series SempronAthlon II A-Series FX

To be honest, I spent a lot of time looking at the various chip ranges and ended up more confused than when I started. The Intel i-series chips seem the easiest to follow, which AMD seems to be replicating with an equivalent A-series (the higher the number the more powerful the processor) but there are still some old chip families kicking around to confuse things. Personally, I’d recommend sticking with the newer i-series and A-series/FX chips from the relevant vendor. I get the feeling the others are likely to be phased out over time and they use different physical sockets which makes upgrading problematic. Each range seems to have an equivalent mobile version, so the same applies to laptops. As a rule, Intel chips are more powerful (at least at the upper end) but more expensive while AMD chips are usually usually offer better value for money. So if you want performance, stick with Intel, if you have a budget, look at AMD. Continue reading…

Booting Linux from a USB Stick using a Floppy

The trusty old Fujis that make up the bulk of the computers I deal with day-to-day tend to be pretty reliable, but I have noticed a few going down with (what I believe are) faulty disk drive controllers (to be fair, these machines are at least six years old). The system runs fine, all except seeing a hard drive.

I’d obviously heard of running a computer from a solid state disk of some sort, it’s not new. The Raspberry Pi runs off of an SD card and I’ve seen a few projects using Compact Flash. So rather than bin another machine, I thought I would experiment to see if I could get Linux to run from an old USB flash drive I have lying around (Windows was pushing it on size if nothing else).

At first I looked for a lightweight distro, something close enough to Windows in look that, should I put it in front of one of my users, it wouldn’t freak them out. Precise Puppy seemed to be the answer.

Once loaded it runs from RAM, which made it responsive, but the design was a bit hard on the eye and to save any changes permanently you had to remember to click a button to write to the USB stick, which was a slow and tedious process. It also seemed to asked me to confirm some settings every time it started, not great when a machine rebooted, I could already hear the support calls. The final straw was the difficulty in getting an RDP client working.

I went back to a distro I knew a bit better and which looked easier on the eye: Linux Mint.

Installing Linux

To be honest, once I’d decided on Mint, I didn’t do anything particularly special, just picked the USB drive as the installation drive after booting from a Live CD/DVD. It took a bit of time, but once it was installed it ran from there without needing to do anything else.

I decided on a 4GB drive as 2GB was a little tight should you want to install anything else (and Mint isn’t the slimmest by default, it isn’t designed to be).

You could also install it using something like UNetBootin I assume.

The only slight issue is on boot you get an error saying hd0 is out of space and you have to press a key to continue, whether it does or not has been a bit random, but a reboot usually sorts it out. Continue reading…

Second-Hand PCs Offer Great Savings

I’d normally buy computers brand new, but at work I’ve found a great source of cheap computers that do the job at knock-down prices: eBay. Businesses are always looking to save money, but most couldn’t cope without their computers. In our case they’re largely used as thin clients, along with running a web browser, perhaps an office suite and some have an email client. If you want to buy a new machine these days you’re looking at something with multi-gigahertz multi-core processors and truckloads of RAM that’ll set you back £250+. It’s overkill for what most people use their computers for.

I found a low-powered Atom processor more than up to the task for the majority of my use. Tablets and smartphones have much less processing power and significantly less RAM than a desktop, yet happily do everything from web surfing to games. Previously, I’ve asked whether Atom-powered computers were worth the money (and decided not). I can confirm that’s still the case because of what you can pick up second-hand.

My latest acquisitions on eBay were two Fujitsu-Siemens workstations with 2.4 GHz Pentium 4 processors and 1.5 GB of RAM. They came with copies of Windows XP Pro and are more than capable of doing what 99% of users need. Their specs weren’t cutting edge and these machines were about six years old. They’re not particularly power efficient, they had signs of wear and they use some non-standard parts, making replacing bits harder if they fail, but they only cost me £25 each (including delivery). That’s less than the cost of a Raspberry Pi!

Now, granted, that was just for a base unit (tower, whatever you call it), no keyboard, mouse or monitor. I could buy new ones of all of those for under £100, but I’m sure I could find them on eBay for much less (in fact I found whole systems — base unit, monitor, etc — for £99) and once you have them you don’t need them again, just upgrade your base unit as and when you need to.

If the specs on my machines don’t impress you, I found a dual-core 2.8 Ghz Pentium PC with 2 GB RAM and a 300 GB hard drive, with Windows 7 installed, for £100 (plus £10 postage). That’ll happily run Windows 8 and, if you’re capable of upgrading the RAM, will happily do almost any task you throw at it for years to come. Continue reading…

A Little Home Automation

I’ve mentioned elsewhere that I have a lamp timer and was finding it frustrating to have to manually change the on/off times throughout the year as the length of the day changes. One option I suggested using a computer to to give more flexibility and control.

Well I’ve been running with a setup that does use a computer for a few months now and it seems to be working well, so well that it’s controlling my Christmas lights too. In the end I didn’t wait for a Raspberry Pi (I already have a small Linux server that’s on 24/7, so just used that instead).

In my other article I posited using something like X10 to control it, but X10 plugs and controllers are fairly expensive. I had a set of three remote controlled plugs already and a bit of searching found that they could be controlled remotely. I got the set for free, but you can pick up similar ones in supermarkets and DIY places from as little as £5. Just be sure they adhere to one of the standards (such as Bye Bye Standby or Home Easy, which seem to be the most common in the UK). To send on and off signals I settled on a simple USB stick from a Swedish company to do just that.

The Transmitter

Telldus TellstickI opted for the Telldus TellStick, which isn’t cheap (though it’s the cheapest of their range), but it had good support on multiple platforms (including Linux) and saved me soldering or whatnot. It cost me £54.60 (inc VAT and postage) from Audon Electronics.

The unit is underwhelmingly small and looked a little disappointing when I opened the pack, but I plugged it in and followed the instructions to download and install the application and within minutes I was able to switch a socket on and off through the control centre software.

I was thinking of using the automation as an exercise to play about with Python, but I know PHP better and there seemed a fairly simple way to get that to work (plus I already had everything installed so could get a web front-end working no problem). Continue reading…