Ronnie http://blog.ronnieroller.com Most recent posts at Ronnie posterous.com Wed, 01 Dec 2010 19:36:00 -0800 Setting Application Pool Via Command Line in IIS 7 http://blog.ronnieroller.com/setting-application-pool-via-command-line-in http://blog.ronnieroller.com/setting-application-pool-via-command-line-in

I needed a way to set the default website's application pool in IIS 7 using the command line.  I discovered this:

%systemroot%\system32\inetsrv\APPCMD set site "Default Web Site" /[path='/'].applicationPool:"ASP.NET v4.0"

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/733435/rr.jpg http://posterous.com/users/5AkZ9Kfpmvrr Ronnie R. Ronnie Ronnie R.
Wed, 06 Oct 2010 19:56:00 -0700 ASP.NET MVC 2 ActionResults for XML, JSONP, and RSS http://blog.ronnieroller.com/aspnet-mvc-2-actionresults-for-xml-jsonp-and http://blog.ronnieroller.com/aspnet-mvc-2-actionresults-for-xml-jsonp-and

Needing a reusable way to return XML, JSONP, and RSS from action methods in my MVC 2 controllers, I created three types of action results to handle the work.

XML

public class XmlResult<T> : ActionResult
    {
        public T Obj { get; set; }

        public XmlResult(T obj)
        {
            this.Obj = obj;
        }

        public override void ExecuteResult(ControllerContext context)
        {
            var xs = new System.Xml.Serialization.XmlSerializer(this.Obj.GetType());

            context.HttpContext.Response.ContentType = "text/xml";
            xs.Serialize(context.HttpContext.Response.Output, this.Obj);
        }
    }

 

JSONP

public class JsonpResult<T>: ActionResult
    {
        public T Obj { get; set; }
        public string CallbackName { get; set; }

        public JsonpResult(T obj, string callback)
        {
            this.Obj = obj;
            this.CallbackName = callback;
        }

        public override void ExecuteResult(ControllerContext context)
        {
            var js = new System.Web.Script.Serialization.JavaScriptSerializer();
            var jsonp = this.CallbackName + "(" + js.Serialize(this.Obj) + ")";

            context.HttpContext.Response.ContentType = "application/json";
            context.HttpContext.Response.Write(jsonp);
        }
    }

 

RSS

public class RssResult : ActionResult
    {
        public SyndicationFeed Feed { get; set; }

        public override void ExecuteResult(ControllerContext context)
        {
            var rss = new Rss20FeedFormatter(Feed);

            context.HttpContext.Response.ContentType = "application/rss+xml";

            using (var writer = System.Xml.XmlWriter.Create(context.HttpContext.Response.Output))
            {
                rss.WriteTo(writer);
            }
        }
    }

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/733435/rr.jpg http://posterous.com/users/5AkZ9Kfpmvrr Ronnie R. Ronnie Ronnie R.
Mon, 04 Oct 2010 13:30:00 -0700 JSON Serialization on Windows Phone 7 http://blog.ronnieroller.com/json-serialization-on-windows-phone-7 http://blog.ronnieroller.com/json-serialization-on-windows-phone-7

I started toying around with creating a HackerNews app for Windows Phone 7 and quickly found out that System.Web.Script.Serialization.JavaScriptSerializer() isn't available on the platform.  Here's how I'm handling it -- make sure you add a reference to System.ServiceModel.Web.

using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;

namespace Serialization
{
    public static class Json
    {
        public static string Serialize(T obj)
        {
            using (var ms = new MemoryStream())
            {
                var serializer = new DataContractJsonSerializer(typeof(T));
                serializer.WriteObject(ms, obj);
                var json = ms.ToArray();

                return Encoding.UTF8.GetString(json, 0, json.Length);
            }
        }

        public static T Deserialize(string json)
        {
            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(json)))
            {
                var serializer = new DataContractJsonSerializer(typeof(T));
                return (T)serializer.ReadObject(ms);
            }
        }
    }
}

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/733435/rr.jpg http://posterous.com/users/5AkZ9Kfpmvrr Ronnie R. Ronnie Ronnie R.
Sat, 25 Sep 2010 22:35:00 -0700 Tech/Developer Podcasts I Enjoy http://blog.ronnieroller.com/techdeveloper-podcasts-i-enjoy http://blog.ronnieroller.com/techdeveloper-podcasts-i-enjoy

Podcasts killed the radio for me.  Here's the tech/developer related podcasts that I keep up with:

  • The Changelog - The Changelog is a weekly podcast that covers what's fresh and new in Open Source
  • The Conversation - A talk show featuring discussions with special guests, the latest tech and development news
  • Scott Hanselman's Hanselminutes - Scott gives practical how-to advice, discusses .NET, social media, and blogging
  • A Minute With Brendan - The latest JavaScript news in a minute hosted by Brendan Eich, the father of JS.
  • .NET Rocks - A long running podcast for Microsoft .NET developers
  • SitePoint Podcast - General news, talk, and opinion for web developers and designers
  • The Talk Show - General Technology, Apple talk by John Gruber

I also try to keep up with YUI theater and sometimes Google Tech Talks.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/733435/rr.jpg http://posterous.com/users/5AkZ9Kfpmvrr Ronnie R. Ronnie Ronnie R.
Fri, 10 Sep 2010 21:35:00 -0700 ViewText Now Works With YouTube http://blog.ronnieroller.com/viewtext-now-works-with-youtube http://blog.ronnieroller.com/viewtext-now-works-with-youtube

I just pushed out a small change that enables ViewText to work with YouTube.  Only the title, video, and description are left, everything else is removed.  The preview is resized for mobiles to fit in either portrait or landscape mode.  Have a look at an example.

I'm also thinking about including the Coleman-Liau index for pages, or a least a way to retrieve it, but the algorithm is somewhat in flux.  Odd for something defined in 1975 to be so uncertain today.  I've found several definitions of the algorithm, all slightly different, but similar enough that any can be used.  This discussion on Wikipedia gives some insight. 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/733435/rr.jpg http://posterous.com/users/5AkZ9Kfpmvrr Ronnie R. Ronnie Ronnie R.
Wed, 08 Sep 2010 18:38:00 -0700 Comment threads on iHackerNews http://blog.ronnieroller.com/comment-threads-on-ihackernews http://blog.ronnieroller.com/comment-threads-on-ihackernews

Comment threads, one of those small tucked away features, are now active on iHackerNews.com.  This mimics HN by showing a users most recent comments.  View a user's profile for the thread link.  Example, view Paul Graham's comments: http://ihackernews.com/threads/pg 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/733435/rr.jpg http://posterous.com/users/5AkZ9Kfpmvrr Ronnie R. Ronnie Ronnie R.
Mon, 06 Sep 2010 10:33:00 -0700 Small, but nice iHackerNews update http://blog.ronnieroller.com/small-but-nice-ihackernews-update http://blog.ronnieroller.com/small-but-nice-ihackernews-update

Over the weekend I was able to add theme support to iHackerNews.com.  The "Dark" and "Light (default)" themes are the only two available, for now.  I'll probably build in a way for others to create their own, but for now I wanted to get the dark theme out since it was requested sometime back.  I also added in functionality to post top level comments on news items.  Before, comments were only allowed as replies.  For logged in users, I’m still contemplating on a way to derive voted items that were voted on outside of iHackerNews without hitting news.ycombinator.com with every transaction.  Maybe keep a short term cache of voted items?

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/733435/rr.jpg http://posterous.com/users/5AkZ9Kfpmvrr Ronnie R. Ronnie Ronnie R.