Archive for the ‘code’ Category

Presenting with the Twitter backchannel

Friday, April 3rd, 2009

I went to Bath for openMIC this week (part conference, part barcamp – a brilliant and informative day on innovation in mobile).

The first half was made up of traditional conference-style presentations, and during one of these presentations, I noticed tweets with the #openMIC hashtag become particularly active: feedback that the presenter was missing.

I wondered about ways that the presenter could have got that feedback before finishing his talk…

thinking about fun ways presenters can get realtime audience feedback via twitter. PowerPoint VB script to embed hashtag search in slides?

This isn’t a new idea: I’ve heard of large US tech conferences where the backchannel is displayed on a second screen or projector next to the presenter’s slides. But I rarely get the chance to present where there is the facility for projecting to two screens at once.

So I got thinking about how a compromise could work: embedding a live twitter search somewhere within a presentation.

I had a bit of free time this afternoon to play with the idea a little more. As is sadly often my way, my first few ideas were needlessly overcomplicated: using macros, VBScript or something like that to try and get data from the web and embed it within my slides.

Fiddly. And prone to a number of fundamental issues, such as trying to avoid reloading the twitter search every time you change slide.

But then I had a flash of what, for want of a better word, I shall call ‘genius’. 😉

Instead of fighting to embed a website within a presentation, what about embedding a presentation within a webpage?

A little bit of playing around with code, and I managed to pull a quick proof-of-concept together.

(more…)

ScriptFu – scripting with Gimp

Wednesday, April 1st, 2009

I wrote on Sunday about my first attempt to use Gimp to script some image manipulation stuff I wanted to do – specifically, combining multiple images into a single, multi-layered image.

A few people have asked me for more info about how to do this, so I thought I’d share my script here. Gimp is an open-source image editor, but it also comes with a batch mode where you can run it’s functions from a script. The scripting language for Gimp is called ScriptFu, and is a Lisp-type language. I’ve not done anything in Lisp since learning Scheme at University… so it felt a little odd at first.

This was my first attempt at writing in ScriptFu, so it’s worth pointing that I’m not an expert, and what I’ve written might not be elegant or the “right” way to do it. But I did manage to get something working in a few hours of playing with it.

To start with, a few tips from how I got started:

The doc – The documentation on scripting at docs.gimp.org is fantastic, and got me off to a quick start. It includes enough snippets and samples that I could see the sort of thing I’d need to do.

Gimp’s PDB – If you launch Gimp, go to Help -> Procedure Browser. It starts up a very neat searchable API doc for all of the Gimp functions. Even when I didn’t know the name of functions I needed, typing a quick guess (e.g. “layer”) into here would show me a few sensibly-named options, and show me the full API info for them all.

Photobucket

(more…)

Creating multi-layered screenshots (a BarCamp London hack)

Sunday, March 29th, 2009

I’m on a slow (gah, engineering works!) train back from an awesome BarCampLondon. I’ve got a ton of notes from so many fascinating talks and sessions, but not quite sure how to share them… they would make for the world’s longest blog post!

But as I have a little time to kill, I thought I’d quickly share a little hack that I pulled together overnight. An old idea, but a fun one – and it’s amazing what beer and interesting people will do for your creativity. 🙂

The hack is a little Windows utility to capture more useful screenshots.

By way of background, when you press the “Print Screen” button, it copies an image of your desktop to the clipboard. Very useful. But it has limitations.

What if a window you want to see in the screenshot image is obscured by another window? Or minimised entirely? That information is lost.

Not with my hack! 🙂

My tool captures “interactive” multi-layered screenshots – a picture of each window is captured separately on it’s own layer. This creates a screenshot that (even after you’ve taken the screenshot) will let you move windows around, hide/restore windows, and change the z-order of windows.

It creates a sort of simulation-like snapshot of what your desktop was like at the time.

(more…)

How good is my mobile network operator?

Tuesday, March 17th, 2009

I’d like to think that I’m normally a fairly easy-going person, but we all have our pet peeves and for me one of mine is my mobile phone network operator. They drive me nuts – I never get a signal anywhere!

Or at least, so I thought.

Last night, I put together a quick test to keep track of how much time my phone doesn’t have a signal.

It is technically very simple to do, but I’ll describe how it works in a moment. First, the results. Today was a “typical” work day – I spent most of it at my desk which is by a window on a first floor. I don’t work in a lead-lined bunker, and I didn’t hide the phone in a microwave (does that even work?) or anything like that.

I started the test at home this morning, when I normally start checking my emails and twitter. And it’s been running all day. While in my office, the phone was on my desk. The rest of the time it’s been in my pocket.

It looks like I have a signal more often than I thought – for over seven hours it had a signal, with only a little over three hours with no signal. I was expecting a result with time without a signal being greater than time with a signal.

This is hardly a scientific test, but I wonder if my perception is worse than reality? Maybe all it takes is a few times for the phone to not have a signal when I need it for me to get the impression that it “never” has a signal.

(more…)

Beginner’s guide to writing a Firefox extension

Sunday, February 22nd, 2009

Last week, I shared my hack for syncing my browsing between my computer and mobile. It’s built around a Firefox extension, so I thought I’d share my notes on how I got it to work.

screenshotThis post is a complete sample for creating a Firefox extension to add a button to the browser toolbar. When you click on the button, it grabs the URL from the Firefox address bar and does something with it.

I’ve gone through each file you need, explaining what it’s for and giving a sample ready for copy-and-pasting.

In my browser sync hack it sent the URL to my phone, but for this walkthrough I’m going with something simpler: opening the webpage in Internet Explorer. You can replace that bit of script with something more useful 🙂

I’m not an expert at this stuff by any means, and I found a lot of useful code snippets on mozilla.org to get me going. But this seems to work, and as people that I’ve shown my extension to so far seemed surprised at how easy it was, I thought it might be useful to share.

Apart from the Internet Explorer bit itself (which is a little Windows-specific), the rest of this should all work wherever Firefox does.

(more…)

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…)