free hit counter Nauman Leghari's Blog

The best way to learn something is to develop an application with it. So when it comes to Rails, I decided [*] to develop a clone of TinyUrl.

Here is the screen shot of the website. The source code is hosted at google project hosting and you can find the summary of the development here.

[*] The suggestion to develop this as a starting point came via Adnan Masood who is running LinkCutter.

 

 

Once in a while; when I try to remember something that I read in some book some time ago, I don't usually succeed in that and then I have to start from scratch which is like DRY. So, I'm trying to do something new here by posting anything interested and useful that I read in a book. This is like a customized index to the book.

Practical Rails Projects

The following notes are from a book titled "Practical Rails Projects". In my quest to learn as much languages as I can, I found it refreshing to learn about rails and ruby.  There are a number of things from Rails that I'd like to see tightly integrated with ASP.NET.  With more dynamic features in C#, ASP.NET MVC, MonoRail  and SubSonic, I'm sure it will be fun again to develop with .NET :).

A little summary of the book. Pratical Rails Projects covers a niche area of learning. While you get to learn about the basics of Ruby and Rails in "Agile Web Development with Rails" and get in depth with "The Rails Way", you still need to learn how to effectively apply the technology on a real-life project. While many of the projects built in the book are not real-life examples but they all have the potential.  Anyway, you get the idea, right? So here are the notes:

  • Chapter 1: About installing Rails, Setting up a project so skipping it. 
  • Chapter 2:
  • Chapter 3,4,5: MonkeyTasks: A Todo list application
    • User authentication and management: acts_as_authenticated plugin
    • before_filter, after_filter - AOP like methods on controllers
    • Create model with --skip-migration to bypass the creation of migration file
    • Chronic gem( gem install chronic) : natural language parser for date (Yesterday, this Monday etc)
    • Calendar plugin:  http://topfunky.net/svn/plugins/calendar_helper/
    • Design tip: Skinny controllers, Fat models
  • Chapter 6,7,8: Exercisr : REST based application
    • Mapping resources for REST
    • scaffold_resource
    • Authentication: restful_authentication
    • Graphs:
  • Chapter 9: Blog application
  • Chapter 10: Simple Blog: Web Services, MetaBlog API, Blogger API
  • Chapter 12, 13, 14: Comic: Caching
  • Chapter 15, 16, 17: Church Community
    • Users, Profiles, Blog, Home Page, Comments, Photo Gallery, Rich edit control
    • Batch image uploading with SWFUpload, activeupload
    • Image cropping: http://kropper.captchr.com/ works with attachment_fu
  • Chapter 18: Gaming Trends: Rewrite of an old PHP project
    • ExtJS layouts, grids
    • Applying Rails database migrations for an existing database
    • Building a custom generator
    • In Place Edit
    • Versioning: acts_as_versioned
    • Acts_as_paranoid, delete_at check in database instead of actually deleting the record.
  • Chapter 24: Highrise
    • Mashup with Highrise API, Yahoo Maps, ExtJS
    • Rails 2.0 features

How Apple Got Everything Right by Doing Everything Wrong
http://www.wired.com/techbiz/it/magazine/16-04/bz_apple?currentPage=all

Google Visualisation API ( out of Gapminder )
http://google-code-updates.blogspot.com/2008/03/introducing-google-visualization-api.html

ASP.NET Controls for amCharts
http://www.amcharts.com/aspnet

Django running on IronPython
http://unbracketed.org/2008/mar/16/pycon-2008-django-now-plays-dark-side/

 

Design Patterns in Dynamic Programming
http://www.norvig.com/design-patterns/ppframe.htm

Introducing the Erlang AMQP Client
http://hopper.squarespace.com/blog/2008/1/12/introducing-the-erlang-amqp-client.html

.NET/C# AMQP client library and WCP binding
http://www.rabbitmq.com/dotnet.html

Improving Agility in Visual Studio
http://pragmatic-code.blogspot.com/2008/01/improving-agility-in-visual-studio.html
( NAntAddin and NUnitAddin )

Using AOP in the Enterprise (Video)
http://www.infoq.com/presentations/colyer-enterprise-aop

Topics in High-Performance Messaging
http://www.29west.com/docs/THPM/thpm.html

Microsoft buying Yahoo?
- Google could be the beneficiary here as this could start a mass exodus of talented developers if the deal go through.


Summary:
A simple example using OTP.NET to connect a .NET node to an erlang node. I have decided to write this after reading the article on "Integrating Java and Erlang" on ServerSide.com so I highly recommend that you read that article before continuing here as there are many things which are already described there which I'm not going to repeat.

 

OTP.NET is a port to the Jinterface that the author used in the serverside article.  Here, I'll use the same process to integrate erlang code with a C# application.

 

[I found OTP.NET while browsing through the Jungerl code repository. Jungerl contains miscellanous utilities for erlang programmers]

 

The source code for the erlang mathserver application is also listed here. I've changed it to do multiplcation instead of addition and made it simpler by removing the send/receive code.

 

File: Mathserver.erl


-module(mathserver).

-compile(export_all).

 

multiply(First, Second) ->

First * Second.

 

Now, you can try this code in an erlang shell to see if it is working

 

(1) >> werl.exe -sname servernode -setcookie cookie

(2) (servernode@apollo)3> c(mathserver).

{ok,mathserver}

(3) (servernode@apollo)7> mathserver:multiply(10, 3).

30

 

(1) starts an erlang shell in a window using servernode as the short node name. The cookie is also required for security and you can see how we will use it in the client.

(2) & (3) we then compile our application and call the exposed method to get the result back.

 

Before starting to write a C# Sharp application, we can quickly start another erlang shell to see if we can connect to our server node from a new node.

>> werl.exe -sname clientnode -setcookie cookie

>> (clientnode@apollo)3> rpc:call(servernode@apollo, mathserver, multiply, [10, 2]).

20

 

Once we are confident that the erlang application is working, we can close the client node shell and start devenv.exe and a new project .

 

The first thing we need to do is to include the reference to the OTP.dll file. You can either compile it yourself by downloading the source code from jungerl[sourceforge] or just download the sample application(sample download link). Please note that I've only included the dll in the sample and not the full source code.

 

Now you can add the following code to the main method.

using System;
using System.Collections.Generic;
using System.Text;
using Otp;

namespace ErsharpClient 
{
    class Program
    {
        static void Main(string[] a)
        {
            OtpSelf cNode = new OtpSelf("clientnode", "cookie");
            OtpPeer sNode = new OtpPeer("servernode@apollo");
            OtpConnection connection = cNode.connect(sNode);

            Otp.Erlang.Object[] args = new Otp.Erlang.Object[] { 
                new Otp.Erlang.Long(1), new Otp.Erlang.Long(4)
            }; 
            connection.sendRPC("mathserver", "multiply", args);

            Otp.Erlang.Long sum = (Otp.Erlang.Long)connection.receiveRPC();
            Console.WriteLine("Return Value:" + sum.ToString());
        }
    }
}

This is exactly similar to the code described in the article therefore I'm not going to duplicate that information.

 

Download Sample Application 

 

Other Links:

[ServerSide Article] http://www.theserverside.com/tt/articles/article.tss?l=IntegratingJavaandErlang

[JInterface] http://www.erlang.org/doc/apps/jinterface/index.html

[OTP.NET Announcement] http://www.erlang.org/pipermail/erlang-questions/2004-May/012313.html

[Jungerl] http://jungerl.sourceforge.net/

[OTP.NET] http://jungerl.cvs.sourceforge.net/jungerl/jungerl/lib/otp.net/

 

So, Java comes to rescue .NET again and OTP.NET makes inter node communication between erlang and .NET possible :)

I have just uploaded v1.0 of my Erlang cheat sheet. There are too many things which are still left out so please provide comments and suggestion on what you would like to see in the next version.

Download Erlang Cheat Sheet 1.0 (PDF)

Erlang Cheat Sheet

Is it just me or the following logo of just released Volta looks familiar?

Some of the sessions from Google scalability conference are now available on Google Video.

YouTube Scalability
http://video.google.com/videoplay?docid=-6304964351441328559

Building a Scalable Resource Management
http://video.google.com/videoplay?docid=-3937025764791991714

Abstractions for Handling Large Datasets
http://video.google.com/videoplay?docid=-2727172597104463277

Lessons In Building Scalable Systems
http://video.google.com/videoplay?docid=6202268628085731280

MapReduce Used on Large Data Sets
http://video.google.com/videoplay?docid=741403180270990805

Scaling Google for Every User
http://video.google.com/videoplay?docid=-7039469220993285507

SCTPs Reliability and Fault Tolerance
http://video.google.com/videoplay?docid=210885113635893162

What:
A simple NAnt custom task to send SMS messages using the BT SDK.

Why:
Maybe you want to ping your manager every time the build fails :).

How:
1. Setup the SDK on your PC using my tutorial here. Please note that you need to register your own certificate and generate a wse3policyCache.config file which will be used in the next step.

2. Copy the SMS.Tasks.dll, btsdk.dll, btsdkcomponents.dll, wse3policyCache.config in your Nant/bin directory.

3. Change the Nant.exe.config to include the following entries so that it can pick up WSE config file. I suggest making a backup of that file before doing any changes.

--a)  This goes in <configSections> tag.

<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

 

--b)  And this can be anywhere inside <configuration> tag.

 

<microsoft.web.services3>

    <security>

      <x509 storeLocation="CurrentUser" />

    </security>

    <policy fileName="wse3policyCache.config" />

    <diagnostics>

      <trace enabled="false"/>

    </diagnostics>

</microsoft.web.services3>

 

I have provided a sample Nant file in case you need to refer to it. Please do not just replace your existing file with this as it will overwrite any existing configuration.

 

4. Sample usage:

 

<target name="smstask">

  <echo message="Before executing task" />

  <sms to="phone.number" message="Build Failure" />

  <echo message="After executing task" />

</target>

 

Where:

Download here

You know you are in excellent team when your colleagues create something like this.

Google Video

The video is based on the presentation "Mashing up the Mobile" by Paul Downey and Uros Rapajic.

 

More Posts Next page »