Archive for the ‘code’ Category

Programmatically getting last visited page from Pocket Internet Explorer

Tuesday, February 17th, 2009

I wrote earlier about my hack for syncing my browsing between my computer and mobile.

One of the most fiddly bits of implementing this was how to get the last visited page from Pocket Internet Explorer on my phone. In case this is useful to anyone, here is a quick description of how I did it.

I wrote the code to get the last visited page in C++. I couldn’t find any way to access the browser, or the address bar, programmatically.

The closest I could find is a set of Windows Internet Services API calls which let you have direct access to the browser cache used by Pocket Internet Explorer.

I wrote the code for Pocket Internet Explorer on Windows Mobile, but to the best of my knowledge it should work on regular Internet Explorer. I’ve not tried it because, let’s be honest, who uses Internet Explorer? 😉

The approach was to use FindFirstUrlCacheEntryEx and FindNextUrlCacheEntryEx to enumerate through the INTERNET_CACHE_ENTRY_INFO entries in the Internet cache.

Each INTERNET_CACHE_ENTRY_INFO item stores (amongst other information) the URL it was downloaded from, and the time the cache item was last accessed.

So I find the last page the user has visited by enumerating through the cache, and store the URL for the cache item with the latest last-accessed time.

(more…)

Syncing browsing between mobile and computer

Tuesday, February 17th, 2009

Imagine the scene.

You are sat at your computer, reading a fascinating article online.

You’re about halfway through reading it when something comes up and you need to leave your desk.

Wouldn’t it be great if you could finish reading the page on your mobile? (Without needing to remember how you found the webpage, or what the URL is?)

With this Firefox extension, you can. 🙂

screenshot

(more…)

Responding to the state of the National Grid

Sunday, February 15th, 2009

Okay, I know I said I’d stop banging on about CurrentCost stuff… sorry. My next post will be about something different. Honest! 😉

But with talk about Home Camp 2009 starting to pick up, it seems like a good time to remember one of the interesting factoids I picked up at Home Camp last year.

As I wrote at the time:

…the frequency of the electricity you receive from the National Grid is proportional to the ratio of supply vs demand for electricity usage on a national level…

There was a lot of discussion about how this information could be used to make a difference.

This is discussed in more depth at dynamicdemand, but the sort of thing we talked about was how you could make a significant difference without reducing your total electricity usage at all, but by shifting your usage to times when national supply is greater than the demand, and so when the energy is cheaper and more efficient to produce.

As I wrote at the time, it might be interesting to see what this looks like plotted against your own personal electricity usage.

Demonstrating my lightning quick l33t development skills, only ten weeks later, I got round to trying it out. 🙂

(more…)

Getting data from the CurrentCost CC128

Saturday, February 7th, 2009

I really need to stop blogging about CurrentCost stuff, this is starting to look like an obsession 🙂

But before I do that, I thought I’d share my experiences in writing a new CurrentCost parser.

What is this all about?
On the off-chance that anyone following me hasn’t already heard about CurrentCost a million times already, CurrentCost meters are domestic electricity monitors that tell you how much electricity your household is using. And they have a connection underneath that lets you grab the data from them.

As well as getting your current electricity usage, you can also get historical usage totals out of the serial port, which I’ve used in a variety of ways, such as in my Python CurrentCost software.

CurrentCost have now brought out a new model of their monitor – the CC128. The data format is different to the current models, so I wanted to try and write a new parser that could handle both the existing model and the new CC128 data.

(more…)

Revisiting my Twitter Glossary

Sunday, January 11th, 2009

Have you ever read someone’s tweet and not known what they are on about?

At IBM HackDay 5, I played around with an idea for a Twitter hack – a Twitter Glossary that would let users define terms they regularly use in tweets. The idea was that followers would see the definitions appearing as tooltips over those words when they appear in tweets.

screenshot of the firefox extension

I described the idea in more detail here. It’s now available for anyone to try.

(more…)

Another CurrentCost app update

Sunday, January 4th, 2009

The tabbed interface in my CurrentCost app continues to serve me well. It means I can keep adding new pages to try out new things to display and compare, without spending any time rethinking the interface to make room for another graph.

I added another this morning. When you sync the app with the web, it downloads (anonymised) daily power usage values for every registered user, and plots them on a single scatter graph.

I wanted to do this for every stored daily power usage value, but it was unwieldy. I’ve settled for having the web service calculate average daily power usage for each user, and plotting them instead.

plotting everyone's CurrentCost readings on a single scatter graphEach cross on the graph for a day represents a different user, which is neat – a nice way of seeing trends. By plotting my own usage in a different colour, I can see where I am in the distribution.

If you’ve not tried my app yet, please do consider it. The more people I can get submitting data to the web service, the more interesting these graphs become!

Drawing pretty graphs with Open Flash Chart

Friday, December 19th, 2008

I’m keen for young people that Solent Youth Action works with to have access to information about how the charity runs. I’d like for us to be as transparent as possible, and as a geek, one of the ways that I am working on this is by putting more stuff on our website.

We put our Financial Statements online so that people could see where we get our money from, and how we spend it. But it’s a dry document – a twenty-two page PDF of numbers and accounting blurb.

While it is important for this information to be available, it’s not easily accessible to many like this. Tonight I had a play with presenting it as animated online graphs using the awesome Open Flash Chart.

The Open Flash Chart site has very clear tutorials and a ton of examples, so I wont waste time here by going into detail explaining how to use it.

But it’s worth highlighting just how simple it is – drop the swf file into a directory on your webserver, then point it at a JSON file with your data (either by URL, or by reference in your HTML). That’s pretty much it.

The most complicated bit was copying figures out of the Financial Statements document and pasting it into a JSON text file. Even this was fairly quick.

Flash graphs are not as accessible as something like Google Chart images because they require Flash to be installed. However, I hope the visual flair they add makes up for this, and will help grab the attention of our volunteers.

I created a couple of quick charts to show our income and expenditure, but there are many more examples of how to use it here and here.

CurrentCost – setting yourself a personal goal

Sunday, December 14th, 2008

One of the themes that came up at HomeCamp was that collecting data about personal energy usage was good, but putting it in a broader context helped make it more effective.

With that in mind, I thought I’d make a small improvement to my CurrentCost app to add a financial context to the data it displays.

I’ve added the ability to specify an annual electricity usage target – it asks the question “How much do you want to spend on electricity in a year?”

screenshotOnce you answer that, a target line is added to each graph. The target line shows how much electricity you should use in order to meet your goal.

For example, the graph showing daily electricity usage has a horizontal line showing how much electricity usage you can use a day in order to meet your target annual electricity spend. Bars in the graph that are taller than the horizontal line show you exceeding your goal, bars that stay under show you on track.

(more…)