Category: Technology

Programming, gadgets (reviews thereof) and computers

Kindle-ing

kindleAnother in an occasional series of gadget reviews, and more general thoughts on books. This time I look at the Amazon Kindle, my latest gadgety purchase – I have the WiFi only version with added leather carry case. The Kindle is an electronic device onto which books can be downloaded from a range of sources. In a sense the device is a side issue, Kindle software is available for smartphones (I have it on my HTC Desire), and computers. The main action for the Kindle is in the ecosystem: it makes it very easy to spend money on Amazon!

There are quite a few books available in the Kindle Store on Amazon, both free and paid. The paid offerings are a little cheaper than their paper equivalents but not hugely so. In addition PDF files can be read using the device, it will also play MP3 audio files. The Kindle Store also has links out to places where free content can be downloaded. For example, Project Gutenberg holds a wide variety of out of copyright material in a variety of e-book formats.

As long as you’re prepared to compromise a little you’ll not run short of things to read –  I’d like to read the Patrick O’Brian Aubrey-Maturin series but they are not yet available for download. Only three of the top ten Amazon bestsellers are available in Kindle format at the moment. So far I’ve bought “Trilobite!” by Richard Fortey and “22 days in May” by David Laws. I also have “Sustainable Energy – without the hot air” by David Mackay which I got as a free download, and converted to an appropriate format using Calibre e-book Management, this is available as a community conversion of the original HTML files. Books can be transferred to the Kindle by WiFi, or direct cable connection. Buying books is magically easy – press button, wait a minute and you’re done!

Compared to an HTC Desire the Kindle interface feels rather clunky, I kept wanting to change pages by touch! Having said this moving from page to page is ergonomically easy: there are a couple of handy page forward / page backward buttons suited to either handedness. Page changes feel ever so slightly ponderous with a bit of a flash as the page changes. The battery life is very good, the display is e-ink based and so static display takes no power, only switching pages requires power. The display size is about right and it is very nice to read from, when I first opened the device I assumed the picture on the screen was a piece of paper for display purposes. There are a range of options for adjusting text size, spacing and so forth, although I found some glitches with text size control.

The Kindle is ideal for plain text, however for text with diagrams it is a bit hit-and-miss, although the quality of the display is good enough to show quite detailed greyscale images in the case of the Fortey book these have simply not been included by the publisher. The Mackay book includes figures but the placement of the figures in the text has largely been done automatically and is a bit wobbly. I’d really like to try a book with illustrations which have been done properly – any recommendations then please comment.

The benefit of the Kindle with non-fiction is that searching, bookmarking, and highlighting are all relatively straightforward. I have religious objections against making marks in paper books – I think as a result of using the library as a child. It’s also possible to add notes to a book and to see the “favourite” notes of others.

The problem is the Kindle misses the display aspects of book owning and reading; my house is full of books collected over 20 years. They are my extended phenotype; they tell you something about me. If you visit my house you can see my books – you might want to borrow one. The Kindle cuts this away, you can’t see what is on my Kindle, and if even if you could, you couldn’t borrow it. I’ve tried to replicate the bookshelf aspect in my Shelfari account, where you can see what I am reading and what I have read. I’m also missing the pile of books beside my bed. I’m an old-fashioned animal that misses physical objects.

Overall: not at all bad, reading raw text is comfortable, the whole buying new text is frighteningly easy, and a range of formats can be read. I’m looking forward to using the Kindle to avoid my mortal holiday fear – that I might run out of things to read!

Sunlight

IMG_6875 Some time ago we installed “solar thermal” on our roof, as described in: “The Dorothy Hopkinson Memorial Solar Panel”. This heats water, it’s significantly reduced our gas usage over the summer when the central heating is not on but during the winter when most of our gas is consumed the effect is minimal.

Next step on the renewable energy list is solar photovoltaic (PV) – this converts light to electricity directly. Solar PV systems are rather more expensive than solar thermal systems, until recently the economics of this were a bit questionable – £10,000 is a lot to spend to reduce your electricity consumption by half. However, the feed-in tariff scheme was introduced in the UK in April 2010. This scheme pays a generous tariff based on the total amount of renewable electricity generated by an installation in an effort to increase the uptake of such systems. A similar scheme has been in place in Germany since 2000, where it has been pretty successful in reaching this goal.

We have a medium-sized 3 bed semi-detached house with East-West facing roof elements which are relatively small. Two of us live in the house, our annual electricity consumption is typically 6.5 kWh  per day or 2400kWh per year (*see below for a comment on units). When we first moved into the house our consumption was around 11kWh per day (4000kWh per year). We reduced this by replacing all our light bulbs with low energy versions; switching off a second fridge/freezer; almost entirely stopping using a tumble drier and on replacing fridges and washing machines we bought the lowest energy versions we could find. So these measure achieved roughly 40% reduction. I know all this because I’ve been recording our electricity and gas consumption once a week for the last 3 years!

A colleague at work has recently installed both solar thermal and solar PV, and he gave a talk describing his experiences. After some delay we arranged for a survey by The Green Electrician, who were the installers recommended locally by Segen. The surveyor did a few measurements of our roof and then went through sample power generation calculations and costings based on those measurements. The calculation is described in “The Government’s Standard Assessment Procedure for Energy Rating of Dwellings” (SAP 2005 page 69). Beforehand I was under the impression that this wasn’t going to be worthwhile since only our East-facing roof is available for installation and this is always described as ‘non-ideal’. However, the calculations show that the penalty for an East-facing roof compared to a south-facing one is only about 15%. Unlike solar thermal, direct sunlight is not required – useful energy is still generated on a cloudy day or when the panel is in shadow.

Slight diversion: we were original quoted for an 8 panel system, however once on the roof the installers found they could fit two more panels. I’ve redone the calculations to allow for this – they may be a little bit inaccurate but not much.

The system recommended was a 1.85kWp Suntech system (ten 1580 x 808mm panels = 12.64m2) limited by the size of our roof. The calculated output of this system is 1393kWh per year i.e. about 60% of our annual usage. The price quoted for this system is ~£8,600 (excluding cost of scaffolding which was just over £400). The feed-in tariff is £575 per year based on 1393kwH per year production at a price of 41.3p per kWh. The savings on our electricity bill should be £98 per year (based on 50% of generated electricity being used by us at 14p per Kwh) and £21 based on selling the other 50% back to the grid at 3p per kWh. The feed-in tariff is inflation linked, and it’s reasonable to assume that the buy and sell prices of electricity will go up in the future. As you can see the feed-in tariff is what makes this financially sensible. In theory we will be getting £694 back on the system every year, so it will pay for itself in 13 years or less, mainly due to the feed-in tariff. The tariff is paid for 25 years so at the end of 25 years we will have been “re-paid” at least £8350 more than we spent. This is an embarrassingly high “middle-class benefit”. There are companies who will install renewable systems, paying the upfront costs, providing significantly cheaper electricity and taking the tariff (see Guardian article here): in summary this could work for you but the companies aren’t doing you a favour.

Installation is pretty straightforward: we needed substantial scaffolding across the front of the house to provide roof access; there’s some electrical gear to go in the loft (this is a panel about 1m2) and there’s a cable run from there down to our consumer unit under the stairs where there is a further small meter the size of a central heating controller. In our house this is fairly straightforward: the cable runs up to the loft via ducting up the stairwell – we’ll bury this in the wall when we next decorate. Three chaps were working for a substantial fraction of two days but they also cleaned out my gutter and re-pointed the ridge-tiles. At this point I’d like to commend Ian, Danny and John: the installers, who did a fine job and were most polite.  

There’s still some paperwork for us to do, but essentially the power companies are obliged to pay the feed-in tariff and accept energy back from us onto the grid.

At the moment I’m going up and down the loft stairs to look at my power generation at 30 minute intervals! Overall I’m very pleased with the system: survey to installation was a day under 3 weeks and on a not particularly sunny day I’ve been generating 1000W since 10:30am and peaked at around 1500W. As of 3pm I’ve generated 4.4Kwh which is nearly 70% of our average daily usage. We expect to get less electricity from the system as we head into the shorter days of winter with a sun lower in the sky, but it’s not a bad start.

As an additional bonus we can now electrocute unsuspecting electricians in a sustainable fashion – unlike a normal house you need to switch off supply from the grid and from the solar panel before sticking your screwdriver anywhere electrical. There are big signs to this effect next to the consumer unit.

*Note on units: Power is the rate at which something consumes energy, and the units for this are Watts (W), 1000 Watts is known as 1kiloWatt (kW) – a kettle uses about 2kW when it is running, the PC I’m using about 300W and the electric shower about 9kW. Ultimately what you buy from the electricity company is an amount of energy. For domestic electricity consumption we talk about “kWh” or “kilowatt-hours” this is a power multiplied by a time which in physical terms is “energy” which physicists would normally quote in units of “Joules” however, we’re not in physics at the moment. The quoted output of our system is in “kWp” or “Kilowatt-hours (peak)” – this is the maximum power we could possibly obtain from the system.


Some pictures of the system, including a graph of gas and electricity consumption over the last three years.

Bamboo Pen and Touch

This is a tiny technology review. I recently bought a Wacom Bamboo Pen and Touch tablet, I say recently – I picked it up from the post office a little over 2 hours ago!

I used a Wacom tablet extensively as a mouse replacement at work some years back, and rather liked it. I only gave up because I moved into industry from academia and they are a bit more fussy about what I attach to the PC with which I am provided. At home the pen interface didn’t work quite so well because at the time I was quite keen on computer games, first-person shooters in particular, and controlling the little man in such a game using a pen is exceedingly challenging, to say the least.

The big benefit of a pen interface to my mind is that I can hold the pen whilst typing, then when I need to do some “mousing” I don’t have to scrabble around for the mouse. The whole process is just much smoother.

Unlike my original Wacom tablet this model will accept both pen and touch (with your fingers) input – I must admit I’m not really anticipating using the touch input. It appears to support the range of multi-touch gestures that a smartphone will accept. The active area of the tablet is roughly journalists notepad size which makes it small for an artist type tablet.

In terms of software, the installation attempts to guide you into some spoken tutorials which treat you like a moron – praising fulsomely your every successful pen-stroke. None of this is actually necessary since using a pen is largely intuitive and all you really need to learn is what the right-click simulation is (it’s the button on the body of the pen) and what the configurable buttons on the tablet do.

I have the tablet installed on a Windows 7 system, which is “ink” aware – it understands interacting via a pen: A little palette will pop out wherein the miracle of the “handwriting recognition” is performed – being able to read my scrawl is impressive but it’s a bit like a talking dog: it’s very clever but ultimately pointless on a computer with a keyboard. Office 2007 is also ink aware, you can open up a document and scribble on a separate layer – obviously the first thing I did was draw a big circle around something and wrote “bollocks” next to it.

The tablet also comes with some little mini-apps in which you can doodle and play games, you can also download more mini-apps. They don’t look fantastically useful.

All in all I think we’re going to be happy together – holding the pen feels just like old times!

A set of blog posts on SQL

This is a roundup post for a rather specialist set of posts I wrote on SQL (Structured Query Language), a computer language for creating and querying databases. Basically the posts are my notes on the language which I’m learning because a couple of programming projects I have in mind will need it. The main source for these notes is the Head First SQL book. I’ve used a another book in this series (Head First Design Patterns) – I quite like the presentational style. The code in the posts is formatted for display using this SQL to HTML formatter.

Topics covered:
Some notes on SQL: 1 – Creation
Some notes on SQL: 2 – Basic SELECT
Some notes on SQL: 3 – Changing a table
Some notes on SQL: 4 – Advanced SELECT
Some notes on SQL: 5 – Database design
Some notes on SQL: 6 – Multi-table operations
Some notes on SQL: 7 – Subqueries and views

Of course you can find SQL cheatsheets elsewhere.

The Head First SQL book also has material on transactions and security, if I get a renewed bout of enthusiasm I will add a post on these items.

I used MySQL via its command line client to do the exercises, because it’s about as straightforward as you can get. Notepad++ recognises SQL as a language and will do syntax highlighting, so I type my commands into it and copy them into the MySQL command line client. MySQL is pretty straightforward to install. I also installed Microsoft SQL Server Express 2008, which turned out to be a bit more of a struggle but on the plus side integration the C# .NET, which is what I normally program in, looks better than for MySQL.

I’ve been using with the SQL Server via SQL Management Studio (a graphical interface to databases) on the general election data compiled by The Guardian. First contact with actual data, as opposed to learning exercises has proved interesting! A lot of things that are fiddly to do in a spreadsheet are straightforward using  SQL.

SQL was designed in the early 1970’s, with commercial implementations appearing towards the end of the decade. It’s influence visible is visible in more modern languages, such as the LINQ extensions to C# (this influence is pretty explicitly stated). Some of the ideas of database design (normalisation) seem relevant to object-oriented programming.

It’s been an interesting learning experience, my scientific background in programming has me stuffing pretty much any sort of data into an array in the first instance. SQL and a database look like a much better solution for many situations.

Some notes on SQL: 7 – Subqueries, combining selections and views

This is the seventh, and final, in a series of blog posts on SQL, the first covered creating a database, the second selecting information from a database, the third commands to modify the structure and contents of an existing database, the fourth, advanced selection. The fifth post covered database design. The sixth post covered multi-table database operations. This post covers subqueries and views. No claim of authority is made for these posts, they are mainly intended as my notes on the topic.
This is largely a wrapping up blog post to cover a couple of items.As an alternative to the joins described in a previous post, “subqueries” can often be used. A subquery is essentially an entire query embedded in another query. Subqueries can be used with UPDATE, INSERT and DELETE statements, whilst joins cannot. However, joins can be used to bring columns from multiple tables. There are no special keywords involved in creating a subquery. There is some discussion on the pros and cons of subqueries and joins here on Stackoverflow.

In an uncorrelated subquery the so-called inner query can be evaluated with no knowledge of the contents of the outer query. This expression contains an uncorrelated subquery:

UPDATE raw_candidate_data
SET    gender = ‘f’
WHERE  firstname IN (SELECT firstname
FROM   firstname_gender_lookup
WHERE  gender = ‘f’); 

The inner query is the clause in brackets, in this instance it is a shorthand way of building a list for an “IN” comparison. Often an inner query returns a single value, i.e. for an average or maximum in a list.

This expression contains a correlated subquery:

UPDATE raw_candidate_data
SET    party_id = (SELECT party_id
FROM   parties
WHERE  raw_candidate_data.party = parties.party_name); 

The inner query requires information from the outer query to work, this expression acts as a look up.

Complex queries can be given aliases using the VIEW keyword, for example:

CREATE VIEW web_designer AS SELECT mc.first_name, mc.last_name, mc.phone,
mc.email FROM my_contacts mc NATURAL JOIN job_desired jd WHERE jd.title=‘Web Designer’; 

Can subsequently be used by:

SELECT * FROM   web_designers; 

The view web_designers can be treated just as any other table.

The results of multiple select commands can be combined using the keywords: UNION, UNION ALL, INTERSECT and EXCEPT. UNION returns the distinct union of the results of all the selects, i.e. with no repeats, UNION ALL includes the repeats. INTERSECT returns items that are common to both SELECTs and EXCEPT returns those items that are returned by the first SELECT but not the second. The general form for these combination operations is as follows:

SELECT title FROM   job_current
UNION
SELECT title FROM   job_desired
UNION
SELECT title FROM   job_listings
ORDER  BY title; 

Each SELECT statement must return the same number of columns and each column must be coercible to the same datatype. Only a single ORDER BY statement for the set of SELECTs can be used.

Keywords: UNION, UNION ALL, INTERSECT, EXCEPT, VIEW