gaskell.org » MVC http://gaskell.org picking up where teh rest leave off Tue, 07 Jun 2011 16:38:59 +0000 en hourly 1 http://wordpress.org/?v=3.3.2 Rails helper distance_of_time_in_words ported to C# http://gaskell.org/rails-helper-distance_of_time_in_words-ported-to-c/ http://gaskell.org/rails-helper-distance_of_time_in_words-ported-to-c/#comments Mon, 29 Sep 2008 06:31:10 +0000 andy gaskell http://gaskell.org/?p=85 kabouter can scale.While learning rails I came across a very cool helper method called distance_of_time_in_words. You’ve probably seen this method in action if you’ve used Twitter – no guessing about time zones and as a user I think it’s a nice touch. So on to the port itself…

The Good
C# is automatically faster because everyone knows Ruby is slow and that rails can’t scale.
Seriously though, the port to C# uses resource files so internationalization is handled by simply adding a translated resource file to your project.

The Bad
C# doesn’t have the concept of static extension methods. To me DateTime.DistanceOfTimeInWords would be much nicer than DateHelper.DistanceOfTimeInWords.
Range support in the language is hokey at best. No ranges in switch statements. bleh.

The Ugly
The code! If you compare the C# version to the Ruby version it’s a little ahhhhhhhhhhh… inelegant? The Ruby version weighs in at 28 lines of readable code. The C# version is a b-e-a-s-t with 55 lines of code including 2 helper methods. I’m open to any suggestions in making the C# code shorter or more readable.

The Rest
The method time_ago_in_words has also been ported. Altogether the helper code is 74 lines – also included is over 250 lines of test code. All examples listed on the Rails page were also included in the test.

You can grab the code here or at the subversion repository http://svn.gaskell.org/helpers

]]>
http://gaskell.org/rails-helper-distance_of_time_in_words-ported-to-c/feed/ 4
Bulletproof Ajax with ASP.NET MVC (this time with jQuery) http://gaskell.org/bulletproof-ajax-with-aspnet-mvc-this-time-with-jquery/ http://gaskell.org/bulletproof-ajax-with-aspnet-mvc-this-time-with-jquery/#comments Sun, 10 Aug 2008 22:11:11 +0000 andy gaskell http://gaskell.org/?p=81 As a follow up a recent post about using unobtrusive javascript and Ajax in your ASP.NET MVC applications, I ported the Bulletproof Ajax bookstore application to use jQuery instead of Hijax. This led to more terse code – lines of javascript were reduced from 178 to 41. If you’ve spent at least few hours jQuery then you should find that the new code is also more readable. No server side code changes were necessary.

jQuery is also really easy to extend – I wrote a couple of extensions that would be usable throughout an application. Here’s the extension I wrote to produce the ubiquitous yellow fade effect:

(function($) {
   $.fn.yellowFade = function() {
    return this.css({backgroundColor: "#ffffcc"})
    .animate({backgroundColor: "#ffffff"}, 1500, "linear");
   }
 })(jQuery);

Calling this method flows with the rest of jQuery style chaining of methods:

function(data) { $("div#basket").html(data).yellowFade(); });

This one liner is a callback from our http post to the /Cart/AddProduct. The data parameter contains the response from the server. $("div#basket") is getting the container div from our shopping cart. Then we replace the html within the shopping cart div with the response from the server and follow it up with a yellow fade to provide user feedback.

Code is downloadable here. The demo.

]]>
http://gaskell.org/bulletproof-ajax-with-aspnet-mvc-this-time-with-jquery/feed/ 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 Buy Generic Methotrexate No Prescription Viagra Walmart Best Online Pharmacy For Cialis Generic Buying Femara Canadian Pharmacy No Prescription Needed Alesse Purchase No Prescription Mircette Cheapest Levitra From India Buy Tablets Actonel Online No Prescription Antibiotics Online Ordina Viagra Tricor No Prescription Acheter Diabecon Viagra Ou Equivalentes Amoxil Buy Online Cheap Cafergot Order Buy Best Generic Baclofen Tablets Without a Prescription Seroquel Order Online No Perscription Purchase Lexapro Online Without Prescription Buy Viagra Online Tabs Cheap Generic Substitute Viagra Purchase Lexapro Purchase Viagra In Australia Buy Viagra In Canada Fast Canadian Pharmacy Toronto Zithromax Order Bupropion Next Day Delivery Canadianlab Viagra Tablets Buy VentolinZovirax And Cost Levitra 20mg Tablets Generic Viagra Free Pills Viagra Professional Buy