Claiming no credit for this, but oh man is it cool!
via @blacknight86 <- hero
October 26th, 2009 § 0
Claiming no credit for this, but oh man is it cool!
via @blacknight86 <- hero
October 20th, 2009 § 0
For work on my new project I need to validate UK mobile numbers using JQuery. I couldn’t find any existing scripts to do this, so I thought I’d just publish what I created in case anyone else finds it useful
This will only validate UK mobile phone numbers (including any spaces, +44 or 0044), not landlines (which is what I needed):
$(document).ready(function() {
//add new function to JQuery to validate uk mobile phone numbers
jQuery.fn.extend({
vMobile: function(){
pattern = /^((00|\+)44|0)7\d{9}$/;
this.val(this.val().replace(/\s/g,''));//Strip whitespace
return pattern.test(this.val());
}
});
//apply to text field
$('input.mobilenumber')
.keyup(function(){
if ($(this).vMobile()) $(this).addClass('valid').removeClass('invalid');
}).blur(function(){
if ($(this).vMobile()) $(this).addClass('valid').removeClass('invalid');
else $(this).addClass('invalid').removeClass('valid');
});
});
This’ll monitor the .mobilenumber text field for keypress and unfocus events, and apply either .valid or .invalid CSS class depending on the result.
P.s. I think wordpress has knack’d my tabbing, so sorry if it’s not so readable
Thanks to james.padolsey for the RegEx
October 18th, 2009 § 1
Over the weekend, my housemate and I decided to attempt the famed Centurion drinking game. The rules are simple:
Easy! Before I continue, I’d like to say that I won: my housemate made it to 46, was sick and dropped out. lame!
Anyway, we were finding it hard to keep track of both the time passing and the beer-shot count when my geek training kicked in. It would be so simple, but why not write a program that beeped to prompt you to take a drink? This sounded like an amazing idea during the drinking, anyways…
If anyone wants to use my Centurion script (it’s great fun!), you can download it here. If anyone wants to challenge the unbeaten centurion (me) let me know..
Be sure to chmod it to 755:
$ chmod 775 ./beer.sh
And here’s the code.. I wish I took a photo!
#!/bin/bash
for i in $(seq 1 100)
do
echo "beer yourself for the $i time"
beep
sleep 60
done
October 7th, 2009 § 0
Calmly delivered, incredibly punchy and right on the money. Take that, clergy!
October 5th, 2009 § 0
OK I’ve written a few of these in the past and never had any problems, but my application for my latest hair-brained idea got turned down. Apparently I didn’t provide enough detail, or describe what API methods I’d use… they must be clamping down these days.
Anyway, I sat down and wrote out what I thought might be accepted, and in the process I’ve described my new service: http://LestIforget.it (coming soon
(I’m posting this in case anyone wants to copy it for their use.. *shrug*)
Application to Twitter:
API Methods:
inbox monitoring:
- direct_messages
- direct_messages/new
user management:
- notifications/follow
- notifications/leave
OAuth:
- oauth/request_token
- oauth/authorize
- oauth/authenticate
- oauth/access_tokenI’m creating a public SMS-driven (direct messages to LestIForget) note-taking service: it’s a simple project to just practise my coding skills but might be useful to others.
I will use the twitter REST API to allow my service to poll my direct message inbox about once a minute or (ideally) more frequently, and these will be posted onto a website that users log into via OAuth. The intention is to be able to send direct message SMS via mobile phone and the service will save the note for later on a website that users can log into using OAuth.
I need to monitor who’s following my account in order to advise users that they need to follow lestiforget in order to direct message it.
Initially I don’t see requests going above 1000/hour (maximum!).
Thanks,