Christian Heilmann

You are currently browsing the archives for the General category.

Archive for the ‘General’ Category

Useful tweets widget using Yahoo Pipes and some JavaScript

Sunday, September 28th, 2008

If you look on the right side of this blog (and you can see) and you have JavaScript enabled you’ll spy a little “Useful tweets” widget (list). This is done with Yahoo Pipes and some JavaScript. As people asked me how it is done, here goes:

The idea

I use twitter a lot. Some of what I write is very relevant to the blog here, some is not fit for publication and some is just personal. So publishing all the tweets here would have been disruptive, hence I tried to find a way to filter things down.

What I do is that I end every tweet that I want to show up here with a § symbol, thus giving me a handle to filter out the good ones.

Playing nice with twitter and not summoning the fail whale

As twitter is probably the most hit API out there I didn’t want to go through the API and all the authentication malarkey. Instead I am using the ATOM feed and pipes to get the information and to filter it down.

Yahoo pipes is still full of win when it comes to filtering, mashing and converting data, and the pipe in question that I am using is available here: Useful tweets pipe

It takes the atom feed of a twitter user of a certain ID, removes all tweets but the ones ending in a § and removes the user name of the output.

Using the pipe and displaying the content

In order to display the pipe all you need is a small JavaScript and the right HTML in your page (or in my case WordPress template):




The link means the thing still makes sense when JavaScript is not available and the script does the rest. One thing you need to do to show your useful tweets instead of mine is to change the class on the DIV! You get the number from your twitter page:

  • Go to your twitter page, f.e.: http://twitter.com/codepo8
  • Click the RSS link at the bottom
  • Check the URL of the feed, your ID is the number in between the slash and ‘.rss’, f.e.: http://twitter.com/statuses/user_timeline/13567.rss

The JavaScript for display of the badge is no rocket science whatsoever:


var tweets = function(){
var x = document.getElementById('mytweet');
if(x){
var twitterUserId = x.className.replace('user-','');
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'http://pipes.yahoo.com/pipes/pipe.run?' +
'_id=f7229d01b79e508d543fb84e8a0abb0d&_render=json' +
'&id=' + twitterUserId + '&_callback=tweets.tweet';
document.getElementsByTagName('head')[0].appendChild(s);
};
function tweet(data){
if(data && data.value && data.value.items){
if(typeof data.value.items.length !== 'undefined'){
var ul = document.createElement('ul');
var all = data.value.items.length;
var end = all > 5 ? 5 : all;
for(var i=0;i < end;i++){
var now = data.value.items[i];
var li = document.createElement('li');
var a = document.createElement('a');
a.href = now.link;
a.appendChild(document.createTextNode(now.title));
li.appendChild(a);
ul.appendChild(li);
}
x.appendChild(ul);
}
}
};
return{
tweet:tweet
}
}();
  • We check if the element with the ID mytweet exists
  • We then extract the user ID from the class name and create a new JavaScript pointing to the JSON output of the pipe. This, once loaded, will call tweets.tweet() and send the data as JSON
  • The tweet() method checks if data was retrieved, creates a list of links and appends it to the DIV.

Hope this is useful to someone else, too.

Reading blinds – a bookmarklet to help me read easier

Wednesday, September 24th, 2008

I am now a proud user of a 24 inch monitor at work and I realized that when I read large texts, the amount of white on the screen starts to hurt my eyes. Therefore I’ve written a small bookmarklet to black out part of the screen on demand and have a link top left to show and hide the blinds that cover the rest of the content. The blinds are fixed position so that I can scroll the content behind them. I also add padding to the bottom of the document to have enough scrolling space.

Here’s a blog without reading blinds:

A blog without reading blinds

The same blog with reading blinds on:

A blog with reading blinds

The bookmarklet is hosted on my server, to install it simply drag the following link to your links toolbar: Reading Blinds

Scripting Maintainability – my presentation at Fronteers Conference, Amsterdam

Saturday, September 13th, 2008

I just came back from the Fronteers conference in Amsterdam. I was part of a panel on JavaScript and gave this talk about using JavaScript in large and distributed teams. There’ll be a video available soon, and I will also do a more in-depth report. For now, here are the talk slides:

[slideshare id=596899&doc=fronteersmaintainability-1221333679665493-9&w=425]

Interview about Scripting Enabled with BBC Backstage

Tuesday, September 9th, 2008

At dconstruct this year, Ian Forrester and Rain Ashford of the BBC backstage interviewed several unsuspecting victims about all kind of things buzzing in the internet scene these days. By a stroke of luck, Bill Thompson was out and about to interview me about my upcoming conference on the 19th and 20th of September in London, England: Scripting Enabled

Here’s the video:

I thank everyone involved for the chance to tell people about the event and I am looking forward to seeing you there!

UK government browser guidance in dire need of upgrading

Monday, September 8th, 2008

One thing web developers who do not work in large corporations or with the public sector or education often forget is that there’s a lot of red-tape and checkbox ticking to be done before you even start a line of code. This get worse once there has been a decision made or a guideline in place, as replacing or upgrading those slips far down the list of need-to-do’s.

The web is a large and confusing place and the fact that you just cannot control or demand the setup your visitors use to come to your site and consume what is there can be frustrating. To me, it is what the web is about and I love the challenge of the unknown. Official sites, however, do not revel in unknowns and challenges and try to help webmasters to release quickly by cutting down on things to support.

Last friday, the UK government’s Central Office of Information (COI) published a public consultation on browser standards for public sector websites which misses the mark of good advice by quite a bit.

Bruce Lawson checked the guidelines in detail and responded to them on the WaSP blog

I agree with all that is said there, and humbly point the COI to the graded browser support my employer applies to steer the wild web into easier supportable channels.

There’s a comment form on the bottom of the page on the guidance site that gives you a chance to react to this. It might not mean much, but let’s not forget that if we can have an impact on the public service, it’ll mean a lot more web sites out there that do the right thing. These are the areas we should concentrate on – if your blog doesn’t render properly that is much less of an issue than you not being able to pay a parking ticket or sign up your kids for school.