Making my blog suck less – Retweet (via @Tweetmeme)

For those of your who haven’t come across Tweetmeme before, they are a Reading (UK) based startup aggregating all the links which are retweeted on twitter. Many say it is ‘digg for twitter’.

While my blog posts generally don’t get retweeted, I wanted to include a retweet button as an experiment to see if it will have any difference on the traffic, tweets of blog posts or my followers count.

To add the tweetmeme button onto my posts, I simply include the following javascript. Note, I’ve made some adjustments, firstly I have gone for the compact style, I have also manually set the url which the button relates to which is set by the blogger platform and finally set the retweet to come from me.

	
		tweetmeme_style = 'compact';
		tweetmeme_url = '';
		tweetmeme_source = 'ben_hall';
	
	

Making my blog suck less

While I’ve been blogging for a number of years, my theme and layout has never really had my full attention. This has resulted in a number of issues, poor experience and finding older content more difficult than it needed to be. As such, I’ve decided to give the site a face-lift. A lot of this has been inspired by Scott Hanselman and the tips he has given to improve his blog.

This post covers the initial changes I have made, why I’ve made them and some tips you could apply to your own site if you wished.

1) Added a notice bar

At the top of every page I have added a notice bar with links to various internal and external pages which I would like my readers to pay attention to and visit. These include various social sites such as GitHub and Twitter with the hope that by having them in the notice bar people will be able to more easily identify them. Of course, there still needs to be excellent content on those sites, but making it easier for readers to access should be a high priority.

2) Making my favourite personal posts easier to find

There are a number of posts which I’m proud of which new visitors might be interested in and as such I wanted to make it easier for people to find. The aim is to reduce the bounce rate of visits from search engines, but also ensure that this content can be accessible to anyone who might be interested in what I have written previously.

3) Clean HTML

One of my personal bug bears at the moment is having clean(ish) HTML and CSS. I used to let this slide, but over time I’ve come to realise just how important it is. Not only does it improve compatibility across different browsers, but it also improves the load-time as the HTML is more streamlined as well as allowing for a more consistent look across the blog. The added advantage being that the html is now in a maintainable state meaning I’m not scared of updating the template like before. The problem with this is that things might not look 100% correct – if you notice any problems with formatting, then please let me know.

If you visit my homepage, you hopefully will notice a number of other changes some of which I’ll cover in later posts. I’m hoping you will find some benefit in my new changes. If you think there is anything else I need to change, then please let me know.

Mono XSP == OSX ASP.net Web Server

Over the weekend I required a very simple web server on my MacBook to allow me to play around with some iPhone Web App development. It didn’t need to do much, simply accept requests and serve webpages. While I’ve created web servers before, after sending a tweet out I was reminded about Mono XSP. XSP is an ASP.net web server developed under the Mono project banner allowing you to serve web pages and asserts (javascript, css, images etc) to clients. Simply – it’s great!

After installing Mono, to launch a server simply navigate to the directory where your pages resides using a Terminal (command prompt), and type in XSP. This will start a full webserver on port 8080 serving pages from the directory. Now, within seconds, I can quickly make any directory on my laptop accessible over HTTP!

On OSX, the execution simply looks like this:

Pretty:Base Ben$ xsp
xsp2
Listening on address: 0.0.0.0
Root directory: /Users/Ben/SourceControl/iPhoneWebApp101/iWebKit/Base
Listening on port: 8080 (non-secure)
Hit Return to stop the server.

Great for prototyping and rapid development and while I haven’t tried it, it should work on Windows equally as well.

Capistrano – sudo: must be setuid root sudo: must be setuid root sudo: must be setuid root

I’m in the process of trying to automate the deployment of a rails application. For this I’m using a framework called Capistrano. However, when I tried to deploy onto the remote server I was given the following error:
pretty:railsapp Ben$ cap deploy:setup
* executing `deploy:setup'
* executing "sudo -p 'sudo password: ' mkdir "
servers: ["attendoo.com"]
[attendoo.com] executing command
** [out :: attendoo.com] sudo: must be setuid root
command finished

By default, Capistrano uses sudo by default, as such in the deploy.rb file you need to set it to not use sudo

set :use_sudo, false

After this, when you deploy it will not attempt to issue the commands as sudo, instead just as the user you are logged in as.

Internet is fast moving – introducing BenHall.Tumblr.com

In my previous post I spoke about Getting personal with Posterous. Well, after signing up I gave Tumblr a go, and I have to say I was impressed!


As such, I would like to introduce http://benhall.tumblr.com/. Two great services! However, I think Tumblr has the edge for allowing you to easily write different style of blog posts – such as text, images or videos. Overall, it also has a nicer feel and experience.

Getting personal with Posterous

While Twitter is great for sharing ideas, I’m getting a little frustrated at the 140 character limit. Sometimes it is great, other times you need a few more characters. I also want to keep this blog more ‘professional’ and technical related. As such, I’m going to use a service called Posterous to post some random thoughts and comments of a more personal nature about my life. Some of you might be interested, however I’m guessing most of you won’t be 🙂

One of the great things about Posterous is how easy it is to get started as you simply send an email to [email protected] This then creates a blog for you:

However, in order to get a real URL you need to claim your post by clicking the link.

Done! The blog has been created. The domain name is http://benhall.posterous.com/ – Feel free to follow what I’m saying.

If you want to start blogging, sharing ideas – either personal, or technical then posterous is a very quick way to get started.

iPhone useragent different when using Safari and home screen

Via Mac OSX Safari
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19

Via iPhone Safari
Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16

Via home screen:
Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341

xUnit Browser Attribute – Run Cross-Browser WatiN tests effortlessly

Recently I wanted to run a web UI test across multiple different browsers using WatiN. WatiN supports FireFox, IE and Chrome so that wasn’t a problem, however in order to test the application on difference browsers I would have to duplicate the logic multiple times. This harms readability and maintainability of your tests and is just pain wrong. As such, I created a very similar xUnit Browser Attribute, code can be found on my GitHub repository along with the binaries.

The concept is simple, have the instance of the browser created for you outside of your test and provided the instance as a argument during execution. By using attributes, you can define multiple different browsers, each one will generate a separate test. The advantage of having the tests in this fashion means that if a test one particular browser fails then you can quickly see the problem and the results form the other browsers. If they where just a single test, if one part of  test failed, you wouldn’t be able to see the results for the other part. This can make identify where the problems lies much more difficult. An example of the attribute and a test is below.

public class Example
{
    [Theory]
    [Browser("IE")]
    [Browser("FireFox")]
    [Browser("Chrome")]
    public void Should_Click_Search_On_Google_And_Return_Results_For_AspNet(Browser browser)
    {
        browser.GoTo("http://www.google.co.uk");
        browser.TextField(Find.ByName("q")).Value = "asp.net";
        browser.Button(Find.ByName("btnG")).Click();
        Assert.True(browser.ContainsText("The Official Microsoft ASP.NET Site"));
    }
}

This example is made possible by taking advantage of the xUnit Extensibility model and being able to create objects dynamically in C#. The attribute code is below, as WatiN has a clean namespace structure creating an object based off the string of the name is easy.

public class BrowserAttribute : DataAttribute
{
    public string Browser { get; set; }
    public BrowserAttribute(string browser)
    {
        Browser = browser;
    }
 
    public override IEnumerable GetData(MethodInfo methodUnderTest, Type[] parameterTypes)
    {
        Type type = Assembly.GetAssembly(typeof(Browser)).GetType("WatiN.Core." + Browser);
        return new[] { new[] {Activator.CreateInstance(type) }};
    }
}

With this attribute, you can now quickly and easily define the browsers you want the test to run against, without having to duplicate the test itself.