All posts in Code

The ultimate landing page infographic

If you’ve launched a product, needed highly optimized landing pages or just used landing pages for something to bring in more traffic, then you’ll be familiar with things such as A/B Split testing and the likes. But, perhaps you could save some time with your testing by launching a great landing page from the beginning.

Here’s a fantastic landing page infographic:

Click to enlarge

Click to enlarge

Thomas Suarez, 12 year old Steve Jobs?

Thomas Suarez is a 12 year old application developer who’s clearly plugged into levels of maturity he shouldn’t be plugged into! This is truly quite amazing:

Tinycon – Favicon alert script

Hah, from time to time I come across awesome little things and that’s what has happened this evening, introducing Tinycon.

The concept is simple, Tinycon is a piece of JavaScript that you add to your website, which shows a counter on the visitor’s favicon. So when you visit a website that has the script installed, the website you’re visiting’s favicon gets a little counter on top of it and you can keep track of how long it’s been since you’ve been to that tab. Ok, perhaps it’s not the easiest thing to explain, here’s a picture:

The project is by @tommoor and he’s added the code to github for us to download, tweak and push, so you’re welcome to download a copy and do what you wish with it!

Oh, how I love developers

Relate to this? ;)

Click to enlarge

Click to enlarge

PHP check a website’s Twitter mentions

I started experimenting with social signals as ranking factors in Search Engines; by social signals I mean the count of mentions a website has on a social network such as Facebook, Twitter, LinkedIn, StumbleUpon, Google+ and so forth. I correlated a lot of metrics using a spreadsheet, which was time consuming so I decided to write a script to do it for me. I am 80% complete with the entire script so I’m not going to publish it all, but rather just a taste of what I’m doing.

The code below, when executed on Apache, will crawl Topsy and return the number of times a chosen website has been mentioned on Twitter. This code needs to be run in conjunction with a form that passes a text field with the domain name, so you may have to code that up quickly or later the code to bypass the domain inclusion.

Here’s the code:


$domain_name = $_POST['domain'];
$domain_name = strtolower(trim($domain_name));

echo "Results for " . $domain_name . ":

";

// build search queries
$topsy_twitter = 'http://topsy.com/s?q='.$domain_name;

// cURL contents of queries
$topsy_twitter_contents = grab_contents($topsy_twitter);

// Find match on Topsy for Twitter
if(preg_match('/Search results 1<\/strong>-10<\/strong> out of (.*?) tweets/sim', $topsy_twitter_contents, $regs)){
$indexed_pages = substr($regs[1], 0, stripos($regs[1], " "));
$indexed_pages = strip_tags(str_replace(",","",$indexed_pages));
echo "Twitter Mentions: " . $indexed_pages;
}else{
echo "Twitter Mentions: 0";
}

function grab_contents($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}

?>

As I mentioned, I’ve adapted this to cover an assortment of social networks and am deciding whether I should compile it into an advanced WordPress Social Metrics Plugin.. watch this space.

Search Engine alerts plugin for WordPress

I wrote some code the other day that I felt was rather useful for people who are either launching a website or testing changes on a website in terms of getting ranked. What I mean by this is that when you launch a new website, you might want to know when Google is going to index your website, or if you’re testing out new things on your website and want to know when Google’s been past to test the changes.

The code is really straight forward, but I wanted to share it anyway in case there’s someone out there who could make use of it or further its development:


$to = ""; // insert receiving email address
$from = ""; // insert sending email address
$body = "";
$bots = array('Googlebot', 'Yahoo', 'MSN'); //add the bots you want

foreach ($bots as $bot)
{
if (eregi($bot, $_SERVER['HTTP_USER_AGENT']))
{
$subject = "BOT DETECTED: " . $_SERVER['HTTP_USER_AGENT'];
if (mail($to, $subject, $body, $from))
{
// nudda
}
}
}
?>

I then took the code and compiled it into a WordPress plugin with a couple options for those people who prefer not to delve around in code. You can download the pluggin by clicking here, simply extract it, upload it to /wp-content/plugins/, activate it and look for the options panel in WordPress to configure your settings.

I used it when launching a website a few weeks ago; the client wanted to know when his website was indexed, so I installed the plugin on the website and had full control over when Google was crawling his site. Needless to say, I was able to alert him almost immediately when his site was indexed – happy client.

There’s a more detailed writeup on the code here, if you’re interested.

Drop me a comment if you use it please!

CSS Ribbon Menu’s

I reckon towards the beginning of 2011 Ribbon Menu’s became really popular and since then I’ve stumbled across hundreds of websites that make use of them. It isn’t always the menu per say, and often used to represent the ul li structures of sidebars, but nevertheless, ribbon’s are popular and this post will assist you.

The combination of CSS3 transitions and CSS2 pseudo-elements will allow you to create an awesome ribbon menu, but please note that IE8 and IE9 don’t support CSS3 transitions so the hover states won’t be animated.

Right, let’s get to it:

First things first, the HTML:


The next thing we need to do is write some CSS to style the forked ends:

.ribbon:after, .ribbon:before {
margin-top:0.5em;
content: "";
float:left;
border:1.5em solid #fff;
}
 
.ribbon:after {
border-right-color:transparent;
}
 
.ribbon:before {
border-left-color:transparent;
}

Let’s setup the actual link styling:

.ribbon a:link, .ribbon a:visited {
color:#000;
text-decoration:none;
float:left;
height:3.5em;
overflow:hidden;
}

And now the animated folds:

.ribbon span {
background:#fff;
display:inline-block;
line-height:3em;
padding:0 1em;
margin-top:0.5em;
position:relative;
 
-webkit-transition: background, margin 0.2s; /* Saf3.2+, Chrome */
-moz-transition: background, margin 0.2s; /* FF4+ */
-ms-transition: background, margin 0.2s; /* IE10 */
-o-transition: background-color, margin-top 0.2s; /* Opera 10.5+ */
transition: background, margin 0.2s;
}
 
.ribbon a:hover span {
background:#FFD204;
margin-top:0;
}
 
.ribbon span:before {
content: "";
position:absolute;
top:3em;
left:0;
border-right:0.5em solid #9B8651;
border-bottom:0.5em solid #fff;
}
 
.ribbon span:after {
content: "";
position:absolute;
top:3em;
right:0;
border-left:0.5em solid #9B8651;
border-bottom:0.5em solid #fff;
}

And there we have it, an awesome ribbon menu with transition animation!

This tutorial was created by Jack Moore.

New Developer Tools for Mozilla Firefox

For those of you who are developers, and still use Firefox, you’ll be happy to know that Mozilla announced yesterday that they’ve rolled out a new developer too. Mozilla put together a video for all of us to have a look at it:

Some of the features are:

1. More built in tools for real-time editing.
2. Page Inspector allows you to look into a page’s structure.
3. Style Inspector allows for quick and easy style editing.
4. Scratchpad uses Eclipse Orion to give you syntax highlighting
5. A full-screen API for full screen web experiences.

Those aren’t shabby additions and some of them are definitely going to give Chrome’s developer tools a run for their money.

The tools come bundled with Firefox, so you’ll need to update to get them.

Over to you Chrome, let’s see how you come back!

Ajax simply explained!

Just brilliant, click to enlarge!

Speed up your web design with CSS Refresh

If you’ve ever built a website before you’ll more than likely know something about CSS, well at least I hope you do otherwise you might have been using tables ;) Naturally, when you make a change to the CSS files on your website, you need to refresh the browser to see the changes, right? Well, I’ve stumbled across something pretty cool, read on..

CSS Refresh is a really small and unobtrusive JavaScript file that monitors your CSS files, when you make a change, the JavaScript file automatically implements the changes and you need not refresh your browser – think of how much time that could save you! If I had a dollar for every time I’d pressed F5, I’d be writing this from my villa in France!

Getting started is really easy, you just need to follow 3 really easy steps which you find here: http://cssrefresh.frebsite.nl/#how

It’s a really useful little tool, give it a go!