What’s my name, bitch?

August 30th, 2006

Being ever so slightly bored at work, what with an Internet that doesn’t do anything half the time and a list of boring jobs as long as my arm, I decided to search for my name on T’Internet. Google to be precise.

Previously, the number one result would be my company website. Pretty weird since I’m not entirely sure that I ever mentioned my name on there, but relevant nonetheless. If anyone searched for me, they’d find me, and all would be good.

Recently, however, I’ve seemingly dropped off the face of the Interent. Old nicknames and email addresses are still to be found if you know where to look, but my actual, real, picked-on-at-school name is nowhere to be found – at least none of them are me.

So I figure I’ll write up a quick []D [] []\/[] []D [] []\[] ” page and bang that on a subdomain of my name, and maybe that’ll get me back on at number one. It was only a few minutes work and it may get me in touch with people who don’t bother with Friends Reunited.

I put a counter on there as well, to see if anyone’s actually trying it out. I could keep a record of what position I appear in as well, but that’s just a little but sad. OTT as well, but mainly sad.

Calculating Postcodes within a given Radius

August 27th, 2006

So, I was mooching about on t’Internet with ZiKeS this morning, and I remembered that I had wanted to create some kind of Postocode Range Finder using the UK Postcode Database I’d snagged from jibble.org a long, long time ago.

The basic idea was to take a postcode, add a range, and return every postcode within that radius. Initially I was having nightmares about SIN() and COS() functions, but it turns out O-Level maths had some use after all, in the form of Pythagoras’ Triangle Thigummybob, the one that goes ‘The square of the side opposide the right-angle is equal to the sum of squares of the other two sides’. Something like that – we’re reaching into parts of my brain that have gone unused for quite some time here.

I figured I’d let the server do all the work, and the final SQL I came up with was:

    SELECT POSTCODE,GRIDREFX,GRIDREFY FROM ukpostcodes
    WHERE SQRT(
    POW(ABS($xpos-GRIDREFX),2) +
    POW(ABS($ypos-GRIDREFY),2)
    ) < $dist

$dist being the range required in metres and $xpos and $xpos being the Grid Ref X and Y thingies respectively from my ‘root’ postcode. The script seems to work, and returns the other postcodes within my specified range, though in no particular order. I guess ‘nearest first’ would be cool.

My next problem is to actually apply this to something, since I don’t actually have a project in mind for it. Initially I thought of something like Dating or maybe Car/House sales, or even an entire community thing which would let you see exactly what was available in your area. Stay tuned, folks – anything could happen in the next half hour few months.

Bye Bye Internet Explorer – Hello Firefox!

August 20th, 2006

I’ve finally made the move away from Internet Explorer after a recent update of the Malisious Software Removal Tool left my installation extremely unstable. I would browse two or three pages and the thing would quit, prompting me to sent a report to MS, then reboot, rinse and repeat.

All this time I’ve been using IE and I’ve never had a problem with Spyware, Malware, BHO’s, call ‘em what you will. In the end I’m persuaded to switch by a program that’s meant to protect against all this crap. Now that’s Ironic.

So I’m off. For want of a better choice I switched to Firefox. A secondary consideration was that I already use Firefox on my work’s Mac. I’ve got so used to opening stuff in Tabs that it’s now second nature.

Update:
Oh well looky here! Seems the crashing is caused by a b*lloxed patch and my machine is now vulnerable to exploits. How the hell did that get past the testing stage? Thanks, Microsoft! (w*nkers)

MySpace is the new SlashDot

August 16th, 2006

Well maybe not quite but it’s certainly getting there.

You may recall I mentioned someone creating a Fake MySpace Login using d04.net the otherday, and that I pulled it just as soon as I spotted the phishing attempt.

Well it turns out I wasn’t quite quick enough, and on the 9th August I had 65,000 hits on that domain alone. I wondered why I’d experienced a bump in AdSense earnings, and it turns out 358 people had clicked on ads that were displayed as part of d04’s function. I don’t know whether I should be pleased about that or not.

A quick shufty through the server logs revealed the spike, and Google AdSense registered 105,000 page impressions over three days. Thankfully this is the new server and it didn’t even flinch – I’m not sure how the old one would have coped.

Stretching a Backgound Image using JavaScript and CSS

August 14th, 2006

UPDATE:
Thanks to viveka for pointing out that this code didn’t actually work – I’ve fixed the two stupid buglets and tested it and it does now. Apologies all round!

Anyway, previously

——–

I put a rather nice website design together a week or so back for a prospective client which used something I had never attempted before – a background image that is scaled to cover the whole page, no matter what dimensions the browser window is resized to. All well and good, but it turns out we got the job and I had to actually implement the bloody thing.

First up, we don’t actually use the BODY to display our background image, but a DIV (ID=bg, below) with WIDTH and HEIGHT set to 100% so it always covers our entire document display. To prevent scrollbars appearing on these elements we hide the overflow on them, so our main document looks like this:

    <BODY STYLE="overflow:hidden;" onResize="imgResize();" onLoad="imgResize();">
    <DIV ID="bg" STYLE="position:absolute; overflow:hidden; top:0px; left:0px; width;100%; height:100%;">
    <IMG SRC="test.jpg" WIDTH="800" HEIGHT="600" BORDER="0" ID="bgImage">
    </DIV>
    <DIV ID="fg" STYLE="position:absolute; top:0px; left:0px; width:100%; height:100%; overflow:auto;">
    Content in Here!
    </DIV>
    </BODY>

The content actually sits in another DIV (ID=fg,above) with it’s overflow forced to ‘auto’ so that we always see the space for a scrollbar, even if there’s nothing to do with it, and it resembles a regular browser window as closely as possible.

This setup allows us to access the image using getElementById and control it’s width and height according to our requirements. Naturally this requires some JavaScript:

    <SCRIPT language="JavaScript" TYPE="TEXT/JAVASCRIPT">
     var winWidth=0;
     var winHeight=0;
     var imgWidth=800
     var imgHeight=600
     var newWidth=0;
     var newHeight=0;
     function imgResize() {
      var bgImage=document.getElementById('bgImage');
      if(window.innerWidth) {
       winWidth =window.innerWidth;
       winHeight=window.innerHeight;
      } else {
       winWidth=document.body.offsetWidth;
       winHeight=document.body.offsetHeight;
      }
      if(winHeight>imgHeight) {
       newHeight=winHeight;
       newWidth=winHeight*(imgWidth/imgHeight);
      }
      if(newWidth<winWidth) {
       newWidth=winWidth;
       newHeight=newWidth*(imgHeight/imgWidth);
      }
      bgImage.style.width =newWidth;
      bgImage.style.height=newHeight;
     }
    </SCRIPT>

There’s some aspect-ratio related checks in the JavaScript to ensure your background image doesn’t get stretched out of shape as well. With some experimentation I’ve found that a background image of 800×600 gives great results at pretty much all sizes and isn’t too big – a nice balance between image quality and file size.

Latest Phishing Scam – Fake MySpace Login

August 11th, 2006

The Internet is full of very sad people. As if it wasn’t bad enough with phishing attempts to get bank account, PayPal or eBay details these people now have a new target – MySpace.

Over the last couple of days, pedwa2305@yahoo.com has tried to create fake MySpace login pages and used a Free Subdomain to try and fool users into giving up their details.

The login page itself is amateurish and unconvincing and has an advertising banner across the top of the page, but at least one person has emailed me (despite the domain being blocked, so all they see are d04-branded pages) asking to cancel her MySpace account.

Why MySpace? Is this a feeble attempt to hack a certain someone’s account or is it part of a much wider phishing attempt? I don’t care – the subdomains have been blocked and the account disabled. If anyone else creates one, the same will occur.

New Phone – Sony Ericsson k610i.

August 7th, 2006

I’ve finally got round to getting a new phone after waiting god known how long for the Nokia N92 to put in an appearance. The TV-sporting beastie doesn’t appear to be arriving on UK shores any time soon so I’ve plumped for a Sony Ericsson k610i instead.

Initial feelings are mixed. It’s thinner and lighter than my k750i and only 5mm longer – all good stuff for a 3G phone. In fact it feels positively svelte.

The menus have been reorganised, however, and that prevents me from simple picking up and using the k610i without reading the manual. The good – great thing about Nokias is that they all follow the same kind of menu layout (at least until you get to the Smartphones) and you can adapt to a new handset with ease.

The other thing about the phone is that MobileShop have sent me a white one. White. it looks like an iPod which, while it isn’t ideal, is slowly growing on me nonetheless. It’s smooth plastic as well which is… interesting.

That’s all the review you get for now, however, since Three still haven’t connected me despite me receiving the handset on Friday. I’ve been on to MobileShop and they’re chasing Three but at the time of writing, I can’t actually use the phone. Bah.

Net Neutrality – WE are the Internet!

August 4th, 2006

I’ve had the chorus from this bloody song going round my head ever since I was stupid enough to click a link in the B3ta newsletter. It’s a protest site on the subject of Net Neutrality with the most awesome video ever. It features the Gem Sweater Woman, Tron Guy, Peter Pan, Subservient Chicken and the Chinese Back Street Boys as well as the Spong Monkeys and Rocking Kittens.

Click here for awesome campaign goodness!
(Click on ‘The Video’ once it’s loaded).

Now with Value Added Lyrics!

    (Leslie Hall)
    Wake up everybody, stop sleeping.
    They wanna charge more, big companies are creeping,
    Into our Internet…
    The Internet’s in distress let’s answer the S.O.S.

    (Chorus)
    I’m the Internet, you’re the Internet,
    We’re the Internet, now that’s the Internet,
    I like the Internet, we love the Internet, and I can prove it.

    (Peter Pan)
    Some net fairy dust made me who I am,
    Living in an online Neverland.
    The web’s my playground, no suits allowed.
    Internet celebrities, let’s sing it proud.

    [Chorus x 2]

    (Tron Man)
    It’s not my tights that cut off circulation,
    Big business wants to control the net nation.
    What you can see, how much you should pay.
    Tell me, is this the democratic way?

    [Chorus x 2]

    (Leslie Hall)
    Wake up everybody, stop sleeping
    They wanna charge more, big companies are creeping,
    into our internet…
    Internet’s in distress let’s answer the SOS.

    Keep it free and keep it open
    speak up or our world wide web will be broken

    [Chorus - Tron Man]
    [Chorus - All, repeat to fade.]

And who the hell taught Leslie Hall to dance? That girl can move.

internetstills

Dude goes to Scotland. Again.

August 1st, 2006

Yes indeedy, it transpires that my mate K isn’t going over to Amsterdam as previously planned, so for a laugh I said he could always go camping up in Scotland with me. He says yes, I say ‘OK then!’ and we’re now off on a trip up to Glen Nevis (again!) at the end of the month – hurrah!

If the weather holds we’ll have a go at getting up that mountain again, but I’m still a fat bastard so it may not happen. There’s a Bank Holiday on the Monday so if I can take the Friday off we’ll make a long weekend of it.

PHP’s number_format(); breaks my form. Oy!

August 1st, 2006

Interesting PHP buglet of the month. I had a call from a client saying that the new prices he’d entered into his website’s admin area were coming back as £1 and £2 instead of the thousands that they should have been. I asked a few questions but it suddenly occurred to me that if you entered a comma in a number value, that would screw things up.

The client, of course, insisted that they were not entering commas into anything, but it transpires that when you pull a value from the DB and run it through number_format() (to get the value to two decimal places and present it as a currency) it actually seperates the groups of three digits with a comma. So:

    $price=number_format(123450/100,2);

returns “1,234.50″ rather than the “1234.50″ I was expecting.

This is all well and good until you actually save it in a form, whereby the comma ends up sending two seperate values for the same variable. Since only the first is used, the PHP on the receiving end sees ‘1′ instead of ‘1234.50′ and all hell breaks loose.

Well not really – the problem was spotted after only four items had gone wonky and before they actually had any customers, so nothing was lost on this little voyage of discovery. I wonder if our contract contains a clause absolving us of responsibility for stuff like this?