Archive for June, 2009


More Shameless Self Promotion

Daniel and I are on .Net Rocks talking Twitter development and TweetSharp today. It was an interesting and fun experience. Thanks to Carl and Richard for the opportunity.

Direct download via
Via the iTunes store

Posted by Jason under General  •  No Comments

Yours Truly talking TweetSharp on dnrTV

Daniel Crenna and I recently recorded a screencast/interview for dnrTV on the subject of TweetSharp. It was posted today and is available for viewing here.

I haven’t watched it, yet. Nobody likes the sound of their own recorded voice and I’ll beat myself up too much if I made any incorrect statements due to nerves or something. :) I’m sure I will watch it eventually, then the wailing and gnashing of teeth will begin.

Posted by Jason under General  •  1 Comment

Auto-Filter your tweets with Tweet# and LINQ

Every so often on twitter a topic becomes so popular as to become annoying. If you follow a lot of people this happens pretty much on a daily basis.

This also gives rise to another twitter phenomenon – people announcing that they’re filtering out #trendyTopic because of the noise it generates, thus contributing further to the noise.

This gave me an idea in passing that I immediately posted to twitter. “What if my client could be set to auto-filter out trending topics.” I initially thought it was a silly idea, but then as I let it roll around in my noggin a bit I decided it could actually have some promise, if implemented properly.

So…if you’re developing a twitter client (admit it, you are, everyone’s doing it) and you’re using TweetSharp to do it, here’s some code to get you started. It’s easy!

First, we need the code to get the current trends.

/// <summary>
/// Gets current trends as a string enumeration
/// </summary>
/// <returns></returns>
public static IEnumerable<string> GetTrendingTopics()
    var search = FluentTwitter.CreateRequest()
    var response = search.Request();
    var trends = response.AsTrends();
    foreach ( var trend in trends.Trends )
        yield return trend.Name;

This code will get us today’s trending topics.

Next, we’ll get our friends’ timeline

public static IEnumerable<TwitterStatus> GetFriendsTimeline()
    var twitter = FluentTwitter.CreateRequest()
        .AuthenticateAs( UserName, Password )

    var response = twitter.Request();
    return response.AsStatuses();

Now that you have trends, and tweets, it’s just a matter of writing a bit of LINQ code to filter out any tweets that have the trending string in the text.

public static IEnumerable<TwitterStatus> FilterTweets( IEnumerable<TwitterStatus>tweets, IEnumerable<string> filterTexts )
    var filteredTweets = from t in tweets
                             from f in filterTexts
                             where t.Text.Contains(f)
                             select t;
    return filteredTweets;

For the purposes of this example we’ll just dump the tweets out to the console.

public static void WriteFilteredTweets( )
    var tweets = GetFriendsTimeline();
    var trends = GetTrendingTopics();
    var filtered = FilterTweets(tweets, trends); 
    foreach ( var status in filtered )
        Console.WriteLine("{0} - {1}", status.User.ScreenName, status.Text);

This is obviously a fairly trivial example, and represents the nuclear option of tweet filtering. If I were to implement this fully I would probably want to show the user a list of trending topics and have a one-click filter option (i.e. one button or check box per trend) that automatically expired when the trending topic dropped off the list of current trends.

Other ways this could be better

  • Apply it except when you are @replied to in the tweet
  • Rather than simply hiding the tweets, move them to a less prominent area of your client
  • Adapt the code and use it to highlight trending tweets instead of hiding them

Posted by Jason under General  •  No Comments