Web Development
Postcode CSV and SQL
by Mike on Nov.01, 2011, under General, Web Development
I’ve recently been part of a project that built a large database of the UK’s address data, including postcodes and place names.
I have placed this data online to sell. The full set of data is over 100MB, and includes latitude and longitude coordinates of postcodes and some place names.
This data has a ton of uses, including integration with Google Maps for various things. I use it to create a ‘find my nearest…’ search, or to plot items onto a map.
You can get the data at a very, very, very small fee over on Postcode CSV website.
Strip HTML from a string in JavaScript
by admin on May.20, 2011, under Web Development
Nice handy way of removing all HTML from a string using on JavaScript:
variable.replace(/<.*?>/g, '');
There are other ways of doing this, but they rely on the presence of a web browser. This should work in most modern JS engines.
How to Print Part of a Page in JavaScript
by Mike on Dec.21, 2010, under General, Web Development
Recently I was working on a project that needed a ‘print’ button. Usually I work with database-driven content, so creatign a ‘prinkt’ page is fairly simple – I just use a blank page template and load in the content. In thsi project though, there was quite an advanced templating system, which turned out to be not quite so advanced as I couldn’t pull the data from the template view into a blank template…
So anyway. I wanted to use JavaScript to pull in page of the page rather than having to recreate a lot of the templating system. Below is what I made, hopefully you’ll find it useful.
function printDiv()
{
var divToPrint=document.getElementById('page-content');
newWin= window.open("");
newWin.document.write(divToPrint.innerHTML);
newWin.print();
newWin.close();
}
Basically you have a div on your page called ‘page-content’ (or whatever you want). You can then call the function on a button press or whatever ().
The script basically creates a new window, puts the contents of the selected div into it, prints that new page, and then close that new page. The user may see a flicker while that happens, unfortunately unavoidable.
Hope it helps.
Electronic Cigarette Blogs
by Mike on Sep.27, 2010, under Findings, General, Projects, Web Development
I’ve just started up an electronic cigarette blog and a Squidoo electronic cigarette ‘lens’.
I haven’t used Tumblr before, but I’m impressed from the off. It works out the box, looks great and is pretty idiot-proof. I think they only thing it’s missing is better networking – I have yet to find any other similar blogs without resorting to Google.
Squidoo I have used before, but only briefly. It works well and does what it says on the tin. I also like the revenue sharing through Google AdSense, although I’m not sure quite how well it works as I’m convinced I must have had at least one click after having thousands of visits.
Check them both out.
Cycle Routes
by Mike on Jul.02, 2010, under General, Projects, Web Development
A while ago I wrote how I was setting up a cycle routes website with my Dad. Well, it’s been up for a while now, and has one of the largest collection of cycle routes of any website in the UK.
Because of the website’s uniqueness, it has been spotted by a lot of the nation’s councils. We now feature on nearly every of the UK’s council’s websites, and generate a lot of interest in cycling from all ages.
We are often receiving requests for new routes in people’s areas, and we’re thinking of streamlining the site a little so that cycle enthusiasts and upload their own cycle routes, as was the original intention.
Check out the cycle routes website, have a look around, and get out on your bike.
CodeIgniter – The best framework for the job?
by Mike on Jun.18, 2010, under Findings, General, Web Development
Most web developers have their own code base that they refer back to on a regular basis. Many have even developed their own simple platforms that do a lot of the leg work for them, that they know inside out and can easily deploy on a new project.
More recently though, at least in the last 4-5 years, frameworks have been popping up left right and centre. From CakePHP, which is generally considered to be a little unstable, to the super-reliable ZendFramework, built by Zend – the PHP company.
Zend and Cake are not he only frameworks though. After trying a lot, I find my personal favourite to be CodeIgniter, which is built by EllisLabs.
CodeIgniter comes with libraries and helpers that can be activated at any point within the framework. These helpers try and simplify many tedious tasks involved with making web applications. Things like form validation is a breeze, and the functions used are much more powerful than something that can be drummed up quickly in any normal PHP app. Image manipulation is made easy, and emailing through PHP can be done well without needing to load in the bloated PEAR, which the documentation recommends.
CodeIgniter uses standard MVC (Model > View > Controller) to create it’s systems. Although at first glance this can seem a little silly and over-thought, but it makes life a lot easier for everyone involved. The MVC structure is standardised, reliable and fast, and every developer should follow suit with it very easily.
CodeIgniter also makes debugging applications very easy. The built-in profiler shows all of the POST, and GET data, aswell as all database queries. I used a customised version of the profiler that I tweaked to also show SESSION data.
When working with lots of small, simple queries CodeIgniter also makes life easy with active records, their database library. It allows queries to be written with a fraction of the amount of code. Let’s say we want to pull off everything from a table, simple: db->get(’table’) – no need to write a full query to do it. Active records do support large queries with unlimited amounts of JOINs, but my personal preference is to compile these myself and throw them into a normal query using the DB library’s db->query() method – probably because I’m used to the structure of the queries and the syntax so I can spot errors more easily. If you’re not hot on SQL though, you’ll probably benefit massively.
My personal framework recommendation is definitely CodeIgniter, but make sure you check out all of the others available too. CodeIgniter has a massive community that helps solve any problem you may have, the community includes forums and live chat rooms, which the EllisLabs developers often frequent.
Football Forum
by Mike on May.10, 2010, under General, Projects, Web Development
Well, as you probably know, I like making things to do with football. Notably Football Badges and Football Feeds, both of which are doing extremely well.
My new venture is something a little bit more large-scale. The football badges application gets around 250,000 new unique visits (at time of writing) per month, my goal is to syphon some of these over to the new project, the football forum. At time of writing the number one slot on Google for ‘Football Forum’ only has 25,000 members. This may seem a lot, but when you consider it’s only a tenth of my average monthly traffic on the football badges application, you’ll see that it’s entirely possible that it could be beaten.
Within 3 weeks of launching the forums already have approaching 200 active users. This may not seem like a lot, but consider that this sort of website is viral, and the rate of growth will only increase over time.
If you’re interested in football and want to speak to some like-minded individuals, then head over.
Football Forum
Pub Directory
by Mike on May.10, 2010, under General, Projects, Web Development
It’s been a while since I last posted, I’ve been ridiculously busy of late with a huge amount of projects coming underway, but there will be more news of that in the next few posts.
A project I started some time ago, which was started fairly randomly is the pub directory. It’s a website with (nearly) every pub in the UK listed. Although the search function isn’t great at the moment, there is the ability to search for a city and pub name – but everything does share the same search box, so searching something like ‘Winchester’ might bring up a few unwanted results.
Other than that the site is doing well. The pubs are all categorised by region, so it’s quite easy to find pubs around you. There are also several nice features, including the ability to add a review to the pub. The pub reviews don’t require any sign-ups, and are protected from spam by a reCaptcha form, which works excellently.
Have a look and see if you can find your pub: Pub Directory
British Kings and Queens
by Mike on Mar.09, 2010, under General, Projects, Web Development
So, another AdSense site is up and running. British Kings and Queens was built in PHP using CodeIgniter. There are a lot of pages, mostly generated from the database.
I wrote all of the content myself, which took around 4-5 hours. I’m hoping this unique content will pay off, but I’m currently not seeing much traffic.
Check the site out, I actually learnt quite a lot about British History and past Kings and Queens of Britiain whilst writing it.
British Kings and Queens
All Phobias
by Mike on Feb.24, 2010, under Findings, Projects, Web Development
A couple of nights ago I decided to do a little experiment. I was going to create a generic website with a few hundred pages of content, SEO the hell out of it, and see if I can earn anything from AdSense.
The website is All Phobias, and it lists every ‘known’ phobia out there. It’s written in PHP ontop of CodeIgniter. I created a small C app to scrape all of the data off a few different websites and generate some SQL for me. All in all the whole thing took about 4 hours to make. The design is some crappy free one I downloaded, as I’m not really interested in how it looks.
I’ve made sure every page has everything it should like unique titles, h1 tags and all the meta tags to go with it. I have also made a couple of blogs on external websites and made 5-10 posts on each, some linking to the site, and some not. I’ve submitted to some free submission sites, as well as linking from all of my major sites with a decent page rank.
I’ve submitted a hefty sitemap (I think there were 750 pages) to Google, but the domain is still in the incubation period, so I guess I’ll need to wait a couple of months to see any real progress.
Since the site went live 2 nights ago it’s earnt me a whopping £2. Which, to be honest, isn’t bad at all. If I can earn £1 a night from 2 nights work then I’ll be a happy man. Do the math on that, 15 sites per month, for 6 months, that would be ~£90 per day, or £2.7k a month. Not bad. My hope is that in 6-8 months time it will be top of Google for a lot of keywords ‘all phobias’, along with many of the actual phobia names and short descriptions (’fear of spiders’, for example), at which point the £1 a day would easily jump up to £5-10 per day, with a bit of luck.