Javascript class for tracking mouse idle time {January 04, 4:14 PM}

This is just a simple class I wrote for something that won't be used now, so thought I'd share it instead. It's using jQuery for events but that can easily be swapped out.

function Idle(config){
idler = this;
idler.mouseTimeout = 0;
idler.state = 1;
this.Start = function(){
$(document).bind('mousemove',idler.Move);
idler.Move();
};
this.Stop = function(){
$(document).unbind('mousemove',idler.Move);
window.clearTimeout(idler.mouseTimeout);
};
this.Move = function(){
if(idler.state==0)
config.onactive();
idle.state = 1;
window.clearTimeout(idler.mouseTimeout);
idler.mouseTimeout = setTimeout(idler.Idled,config.timeout);
};
this.Idled = function(){
idler.state = 0;
config.onidle();
}
}

Here's some example usage.

var idle = new Idle({
onidle:function(){
// hide stuff
},
onactive:function(){
// show stuff
},
timeout:1000
});
idle.Start();

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Currently rated 1.0 by 538 people

  • Currently 1.026023/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Paver Smith takes on three new starters {November 16, 11:56 AM}

Good to see Liverppol PR pals doing well. Paver Smith are expanding again.

Alex McDonald and Ruth Cobban have joined the agency’s PR team as a graduate trainee and account executive respectively while Danielle Thompson has joined its creative team as a junior account executive.

Cobban is a former journalist with the Worcester Standard newspaper in the Midlands while McDonald has recently graduated from Liverpool John Moores University.

Thompson is working for the agency on a one-year industrial placement while studying for an advertising and design degree at the University of Huddersfield.

Other news included:

Paver Smith wins Greater Manchester public health campaign

Paver Smith launches localism division

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Currently rated 2.7 by 6 people

  • Currently 2.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

ASP.Net and PostScript fonts {November 04, 1:51 PM}

If you're reading this then you've probably just discovered that your beautiful and expensive font is completely useless to you in .NET when using the GDI+ library. This is the case with all PostScript fonts including OpenType fonts using PostScript outlines (there are OpenType fonts that use TrueType outlines which work fine). Fortunately there is a way out, the older GDI library can render these fonts, it can be used from .NET with a bit of P/Invoking. Below is a class that takes some text and font info, and gives you a transparent image file that you can draw onto something else or output as a PNG. It gets around the transparency limitation by rendering the font much larger, making the background transparent and then shrinking it down again.

Usage is simple, colour is a hex string (no hash):

Bitmap RenderText(string text, string fontName, int size, string colour)

Here is the class:

using System;
using System.Runtime.InteropServices;
using System.Drawing;
namespace Cuyahoga.Web.UI
{
public class TextRender
{
[DllImport("gdi32.dll", EntryPoint = "ExtTextOutW")]
static extern bool ExtTextOut(IntPtr hdc, int X, int Y, uint fuOptions,
[In] ref RECT lprc, [MarshalAs(UnmanagedType.LPWStr)] string lpString,
uint cbCount, [In] int[] lpDx);
[DllImport("gdi32.dll")]
static extern bool TextOut(IntPtr hdc, int nXStart, int nYStart,
string lpString, int cbString);
[DllImport("gdi32.dll")]
static extern bool GetTextExtentPoint(IntPtr hdc, string lpString,
int cbString, ref Size lpSize);
[DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
[DllImport("GDI32.dll")]
public static extern bool DeleteObject(IntPtr objectHandle);
[DllImport("gdi32.dll")]
static extern IntPtr CreateFont(int nHeight, int nWidth, int nEscapement,
int nOrientation, int fnWeight, uint fdwItalic, uint fdwUnderline, uint
fdwStrikeOut, uint fdwCharSet, uint fdwOutputPrecision, uint
fdwClipPrecision, uint fdwQuality, uint fdwPitchAndFamily, string lpszFace);
[DllImport("gdi32.dll")]
static extern int SetTextColor(IntPtr hdc, int crColor);
[DllImport("gdi32.dll")]
static extern int SetBkColor(IntPtr hdc, int crColor);
public static Bitmap RenderText(string text, string fontName, int size, string colour)
{
// text size is multiplied by 10
IntPtr font = CreateFont(size * 10, 0, 0, 0, 0, 0, 0, 0, 1, 3, 1, 1, 1, fontName);
// set an obscure colour to be made transparent, any text using this won't work
// it would be good to choose this colour programatically as an opposite to input text colour
Color backcolor = ColorTranslator.FromHtml("#FF1CEC");
// create a temp graphics object to measure text
Bitmap bmp = new Bitmap(1, 1);
Graphics grpTemp = Graphics.FromImage(bmp);
Size MeasureSize = new Size(0, 0);
IntPtr tempDc = grpTemp.GetHdc();
IntPtr last_font = SelectObject(tempDc, font);
GetTextExtentPoint(tempDc, text, text.Length, ref MeasureSize);
bmp = new Bitmap(MeasureSize.Width, MeasureSize.Height);
bmp.MakeTransparent();
Graphics grp = Graphics.FromImage(bmp);
IntPtr dc = grp.GetHdc();
SetTextColor(dc, ColorTranslator.ToWin32(ColorTranslator.FromHtml("#" + colour)));
SetBkColor(dc, ColorTranslator.ToWin32(backcolor));
IntPtr last_font2 = SelectObject(dc, font);
TextOut(dc, 0, 0, text, text.Length);
DeleteObject(SelectObject(tempDc, last_font));
DeleteObject(SelectObject(dc, last_font2));
grpTemp.ReleaseHdc(tempDc);
grp.ReleaseHdc(dc);
bmp.MakeTransparent(backcolor);
// transparent oversized text is now drawn at a tenth its size to get smooth anti-aliased edges
Bitmap finalbmp = new Bitmap(MeasureSize.Width / 10, MeasureSize.Height / 10);
finalbmp.MakeTransparent();
Graphics final = Graphics.FromImage(finalbmp);
final.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
final.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
final.DrawImage(bmp, 0, 0, MeasureSize.Width / 10, MeasureSize.Height / 10);
return finalbmp;
}
}
}

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Currently rated 2.9 by 27 people

  • Currently 2.851852/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Howduino 2 {September 21, 5:21 PM}

The second Howduino event is coming up fast, almost too fast! I'm going to be on holiday the week before but it shouldn't matter, if the last one is anything to go by it'll be great. The best thing about it is when you get a room full of people that enthusiastic it all takes on a life of it's own. If you've not got a ticket already you better hurry, they're going fast! Howduino will be at the KUBE in Poole, Dorset, Oct 10th - 11th.

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Currently rated 2.6 by 19 people

  • Currently 2.63158/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Paul Groom Photography {July 09, 5:13 PM}

A friend of mine, Paul Groom, happens to be a brilliant photographer in Bristol. He's covered Live8 and taken photos of royalty and hollywood celebs. Anyway he's just launched a new website and I'd like to draw some attention to his work. If you're looking for a Bristol photographer please go and check it out!

bristol photographer

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Currently rated 3.1 by 18 people

  • Currently 3.055556/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Getting attention in the inbox {April 29, 1:01 PM}

One of the easiest ways to get your email to stand out in your customers inbox is to use some personalisation. People quickly spot their own name when scanning down a list and it gives your email an instant credibility as the user knows they must have given you their name before, even if they don't remember your brand immediately.

We decided to take this idea a little further with one of our clients, Alliance Fund Managers. Each email contains a dynamically generated custom image. For their News email the newspaper has the recipients name scribbled on it, and the date of the mailout across the top of the paper. On the events emails there is handwritten invite made out to the subscriber and on their regular investment deals update, there is a cheque dated and made out for £1million to the lucky recipient. Click the images below for a closer look. If you want to know more, get in touch with us.

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Currently rated 3.1 by 16 people

  • Currently 3.0625/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Howduino Liverpool {March 10, 11:43 AM}

We've just announced our hardware hacking event, Howduino. It'll be on May 23rd at FACT Liverpool. Check out the website for more info. http://www.howduino.com/

Permalink | Comments (1) | Post RSSRSS comment feed |

Categories:

Tags: ,

Currently rated 2.8 by 9 people

  • Currently 2.777778/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Glenn Brown Viral {February 16, 6:22 PM}

We've just launched this viral game for the Tate Liverpool, to promote an upcoming exhibition of Glenn Brown. He was shortlisted for The Turner Prize in 2000.

Screenshot

So please do go and have a play at http://glennbrown.atthetate.com/

The 3D effects are done with Papervision3D, it's the first app I've built using this library and it was suprisingly easy to use. You may be able to spot some little quirks with polygons peaking through surfaces they shouldn't, it does struggle with a number of objects close together at slightly different depths, but considering it's a 3D engine built entirely in flash it's quite amazing!

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags: , ,

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

iPhone Tracking with POP {February 15, 7:36 PM}

When the iPhone 3G was announced with built in GPS, native applications and of course the same always online tarif, a lot of geogeeks got a little bit excited. We hoped it would be a great platform for tracking your location in realtime using services like mapme.at. Unfortunately it's just not possible in the way we wanted. Apple, in their infinite wisdom, decided to lock down the phone as much as possible and remove all the those places where third party developers could degrade the experience. One of the features to go was the ability to run an application in the background. Now you could keep an application running and still lock your phone, but as soon as you want to use your phone for something else you have to close it, then remember to open it again.

I didn't want to jailbreak my phone, so I started thinking of other ways I could locate it. One thing that occurred is that if you could pick up what IP address the device is getting online with you could use that to find a location. Geocoding IPs is notoriously flaky, but if it's just a limited set of known locations, such as home, office or your regular coffee shop, you could tie them to the locations and it would still be quite useful.

So how to get the phone to constanty report it's IP address? Well there is one background process that is allowed to run on the phone, and that's the mail checking. So all I needed to do was write something that appeared to be a mail server but simply tracked the IP address. After a little chat with John we decided the integrate this into mapme.at.

Config

If you want to try it out, just set up an account on mapme.at, under the sources tab you should see an email address with a code followed by @email.mapme.at. Then on your iPhone set up a new POP account, the pop server is pop.mapme.at, and the username is the full email address from the mapme site. The rest of the details can be anything you want.

To start linking IP addresses to locations add new favourites on mapme, then click the "Insert IP tag" to link the network you're currently on to that tag. If you want to add other addresses you can type in the tags manually.

I think the next stage is to integrate (or even built) a shared database of geocoded IPs for public hotspots.

Permalink | Comments (2) | Post RSSRSS comment feed |

Categories:

Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

BarCamp Liverpool {December 08, 1:44 PM}

So Liverpool has just had it's first BarCamp, it didn't quite make the 200 attendees we were hoping for but it went great, I think 200 would have been too big anyway, it's much better when it's smaller and cosier. Maybe I'm biased since it's my home city, and it was great being able to go home to my own bed but everyone seemed to have had a great weekend.

It was good to have a chance to chat to Adrian about Ardunio since I'm going to get one for Chistmas :) Looking forward to having a play with it now. John was there representing OSM again, if you're into geodata or care about information that should be free then have a look at the OSM project.

As with every BarCamp, no matter what sessions I go to and enjoy there always seem to be more that I miss, Phils talk on how to give talks seemed to go down well and I probably could have done with seeing it and on Sunday there was a talk on Sex that seemed quite popular!

The Saturday night party kicked of with the Bitchin' Pitches sessions, which Adrian won with his power usage logging, then it ended with everone dancing around to D&B thanks to the endless flowing beer from Microsoft, we didn't even manage to drink it all! Thanks Steve :)

Waking up with a hangover on Sunday morning I suddenly remembered I had a multitouch screen I'd built stashed in the back of the wardrobe. So I set that up on Sunday afternoon and had a little crowd around it, I was surprised how well it worked!

After the talks someone suggested a big game of werewolf, as soon as we got going it was clear we were going to be there for some time, me and Phil had to leave during the game. I can't believe he was a werewolf! He was sat right next to me and I didn't have a clue! He is now a werewolf convert though, as is Chris, so about a Liverpool werewolf group?

Thanks to Katie and the organisers for all their hard work, and the sponsors for making it possible, and all the speakers that made it a conference worth going to!

Permalink | Comments (1) | Post RSSRSS comment feed |

Categories:

Tags: , ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Photosynth {August 23, 6:33 PM}

I was really impressed with photosynth when they first released the previews nearly 2 years ago, it's taken them a while to get around to opening it up to the public but they've finally done it. Here's a quick go at synthing my living room, only took 94 photos.

Screenshot

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Currently rated 4.0 by 4 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

New Moo {July 23, 8:09 PM}

Moo sent me a free sample of their new business cards. They're on the same stock as the original Moo card. Nice and heavy, good quality finish and they come with a really nice business card holder.

Moo Cards

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5