Posted by Mike Fleming | Posted in Twitter | Posted on 31-03-2009
0
When you have a few spare minutes, check out this blog post from Dallas Mavericks owner Mark Cuban. He raises a very interesting question, and it generated a bunch of different views in the comments section. His short question was simple: Are Your Tweets Copyrighted? Is it legal for someone to quote one of your Tweet’s in an article, on the news, or some other avenue?
Posted by Mike Fleming | Posted in Facebook, Flash, Flex | Posted on 31-03-2009
0
Big news was announced yesterday by Adobe and Facebook. They have jointly released an ActionScript 3.0 library for the Facebook API. This bundles the entire API into a prebuilt library ready to use on the Adobe Flash Platform. This is great news for the Flash/Flex developers out there, as previously it was up to you to write the code to hit the Facebook API. I believe this is also great news for the future at Adobe as well. In releasing this library they obvously see the importance of social media applications and how important these will be the in future. Hopefully this will lead to more integration into some of the other Adobe products. How about a cffacebook tag for ColdFusion?
Posted by Mike Fleming | Posted in .NET | Posted on 30-03-2009
0
If you saw the post last week on using the tweetsharp Twitter library for .NET, you saw a sample of the output for our quick little test. If you revist the output of the code, you will notice that the Twitter API will return plain text only, meaning the links contained in a tweet are just text. Thus they have no HTML code in them to make them a functional link. To solve this problem you can use a regular expression to find our link text and place it within a HTML link tag. After running a quick Google search, I came across a very good blog post at mikesdotnetting.com that covers some advanced regular expressions for C#. One of these samples includes an expression that will search for http, ftp and mailto text and converts it into functioning HTML. I used his code as is, with one exception. I preferred to have the links in my text open in a new window, so I added in the target tag to accomplish this.
| 01 | using System; |
| 02 | using System.Collections.Generic; |
| 03 | using System.Linq; |
| 04 | using System.Web; |
| 05 | using System.Text.RegularExpressions; |
| 06 | |
| 07 | /// <summary></summary><summary></summary> |
| 08 | /// Summary description for Global |
| 09 | /// <summary></summary><summary></summary> |
| 10 | public class Global |
| 11 | { |
| 12 | public static string ReplaceLinks(string arg) |
| 13 | //Replaces web and email addresses in text with hyperlinks |
| 14 | { |
| 15 | Regex urlregex = new Regex(@"(^|[\n ])((www|ftp)\.[^ ,""\s<]*)"); |
| 16 | arg = urlregex.Replace(arg, |
| 17 | m => String.Format(" <a href="\">{1}</a> ", |
| 18 | m.Groups[2].Value, |
| 19 | m.Groups[2].Value.Length > 27 ? m.Groups[2].Value.Substring(0, 27) + "..." : m.Groups[2].Value)); |
| 20 | |
| 21 | Regex httpurlregex = new Regex(@"(^|[\n ])((http://www\.|http://|https://)[^ ,""\s<]*)"); |
| 22 | arg = httpurlregex.Replace(arg, |
| 23 | m => String.Format(" <a href="\" target="\"_blank\"">{1}</a> ", |
| 24 | m.Groups[2].Value, |
| 25 | m.Groups[2].Value.Length > 27 ? m.Groups[2].Value.Substring(0, 27) + "..." : m.Groups[2].Value)); |
| 26 | |
| 27 | Regex emailregex = new Regex(@"([\w_.-]+\@[\w_.-]+\.\w+\s)"); |
| 28 | arg = emailregex.Replace(arg, |
| 29 | m => String.Format(" <a href="\">{1}</a> ", |
| 30 | m.Groups[1].Value, |
| 31 | m.Groups[1].Value.Length > 27 ? m.Groups[1].Value.Substring(0, 27) + "..." : m.Groups[1].Value)); |
| 32 | |
| 33 | return arg; |
| 34 | } |
| 35 | } |
| 36 | |
One quick note about that code above. To promote some code resuse I have created a class file called Global , where I created the function that houses our regular expression code. This class file goes into the App_Code folder, which then allows it to be called anywhere throughout our application. We can keep adding functions to this file as we build out our application. Calling the code is simple:
| 1 | string x = Convert.ToString(yourvariablename); |
| 2 | x = Global.ReplaceLinks(x); |
Posted by Mike Fleming | Posted in Games | Posted on 29-03-2009
1
Just saw this article on CNET about a new study that says playing action video games could help to improve your eyesight. The study found that playing action games can increase contrast sensitivity, help amblyopia (lazy eye), helping you see better at night and improve spatial resolution. So all that time playing Call of Duty was beneficial!
Posted by Mike Fleming | Posted in General | Posted on 27-03-2009
0
This is an old trick, but some of you may find it handy. I forgot about this myself until I read this Lifehacker post this morning. You can easily tell Outlook to use Google Reader when you click the RSS Feeds area. Just right click on the RSS Feeds item from your folder view and select properties. On the Home Page tab copy and paste the full URL to Google Reader. Click apply and you are all done. When you clicked the RSS Feeds link now it will fire up Google Reader in the reading pane.
Posted by Mike Fleming | Posted in .NET, Twitter | Posted on 25-03-2009
3
I’ve been diving into the world of .NET development a little more these days and decided to further my leaning some by playing around with the Twitter API. In looking around the net I came across a cool Twitter library for .NET named tweetsharp. It appears to be a fairly new project, so the documentation is a bit lackluster at the moment. I put together a quick page that calls one of the tweetsharp methods to return a list of tweets from my friend’s timeline.
For those of you new to .NET, once you download the library and uncompress the files you will see two .DLL files. Copy these over to your Bin directory of your website. This will allow you to import this library and use it throughout your website or application. One file contains the base tweetsharp library and the other is a helper library for JSON. The data that is returned from the tweetsharp library can be returned in many formats, so if you plan on using the JSON data you will need to include the helper library.
Below is the code for the code behind page, which contains the guts of the logic. Notice the import calls to the tweetsharp files in the top half of the code. The rest of the code is fairly short. I call the tweetsharp library and set up my return data variables. I then bind the data to a ListView control.
| 01 | using System; |
| 02 | using System.Collections.Generic; |
| 03 | using System.Linq; |
| 04 | using System.Web; |
| 05 | using System.Web.UI; |
| 06 | using System.Web.UI.WebControls; |
| 07 | using System.Threading; |
| 08 | using Dimebrain.TweetSharp.Fluent; |
| 09 | using System.Xml; |
| 10 | using System.Xml.Linq; |
| 11 | using Dimebrain.TweetSharp.Model; |
| 12 | using Dimebrain.TweetSharp.Extensions; |
| 13 | |
| 14 | public partial class test : System.Web.UI.Page |
| 15 | { |
| 16 | protected void Page_Load(object sender, EventArgs e) |
| 17 | { |
| 18 | var twitter = FluentTwitter.CreateRequest() |
| 19 | .AuthenticateAs("YOURUSERNAME", "YOURPASSWORD") |
| 20 | .Statuses().OnFriendsTimeline().AsXml(); |
| 21 | |
| 22 | var response = twitter.Request(); |
| 23 | |
| 24 | var statuses = response.AsStatuses(); |
| 25 | |
| 26 | ListView1.DataSource = statuses; |
| 27 | ListView1.DataBind(); |
| 28 | |
| 29 | Context.Trace.Write("OP", response.ToString()); |
| 30 | } |
| 31 | } |
The next part of the code is main ASPX file, and contains my ListView control that I have bound the data to. I set up my item template and then output my data.
| 01 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" Trace="true" %> |
| 02 | |
| 03 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 04 | |
| 05 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 06 | <head runat="server"> |
| 07 | <title></title> |
| 08 | </head> |
| 09 | <body> |
| 10 | <form id="form1" runat="server"> |
| 11 | <div> |
| 12 | |
| 13 | <asp:ListView ID="ListView1" runat="server"> |
| 14 | <LayoutTemplate> |
| 15 | <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> |
| 16 | </LayoutTemplate> |
| 17 | |
| 18 | <ItemTemplate> |
| 19 | <img src="<%#Eval("User.profileimageurl")%>" /> |
| 20 | <%#Eval("User.ScreenName")%><br /> |
| 21 | <%#Eval("Text")%><br /> |
| 22 | <%#Eval("CreatedDate")%><br /> |
| 23 | <br /><br /> |
| 24 | </ItemTemplate> |
| 25 | </asp:ListView> |
| 26 | |
| 27 | </div> |
| 28 | </form> |
| 29 | </body> |
| 30 | </html> |
This code produces the output below. Yes, it’s very vanilla output, but we can clean up our display later.

Using the tweetsharp library makes this code super simple, as all the underlying API calls are taken care of by the library. I plan on updating this some more and I’ll provide some more examples.
Posted by Mike Fleming | Posted in General, Windows | Posted on 24-03-2009
0
I stumbled across a nice little tutorial this morning by Chris Peterson of Alagad. It explains how to create a Windows based instance on Amazon EC2. It appears as though Chris will be authoring more posts that explain storage, backups and the pros/cons of running in the cloud. If you are curious on how how to set up instances in the cloud, give this a quick read.
Posted by Mike Fleming | Posted in General | Posted on 22-03-2009
0
Good morning everyone. I just wanted to let everyone know that I have a new name and URL for what was named the Magnetion Blog. This also gave me the opportunity to move the blog from Typepad over to Wordpress. The new name of the blog is The Dev Shack and the new URL is http://www.thedevshack.com. I plan on completing the switch later today or very early tomorrow morning.
Those of you who subscribe via RSS will also need to update your feed URL to http://www.thedevshack.com/feed/
I plan on keeping the old feed URL active and redirecting for 30 days or so.
Posted by Mike Fleming | Posted in ColdFusion | Posted on 19-03-2009
2
I saw this new technote yesterday from Adobe, showing how you can have ColdFusion render HTML pages. I would imagine most folks know how to do this and also that you can have any file extension set up to be rendered through ColdFusion. They also mention that this is a safe practice for hiding the underlying server technology from potential hackers. I have never really given much thought to making something like this a permanent step of the development process before. It could prevent a novice hacker from doing something ,malicious, but it's not going to stop a pro. How many of you are using this technique as part of your normal development practice?
Posted by Mike Fleming | Posted in Blackberry | Posted on 18-03-2009
0
Pandora announced the release of their Blackberry client today. After downloading it to my Curve and playing around with it a little, my first impressions are positive. The streaming quality was really nice, as I did not experience a single stop in the streaming. The app also picked up all my normal stations that I had created via their website. If you have a Blackberry I would recommend giving this a try. Just visit www.pandora.com from your device and you can download the app OTA.