Old Monk – here are some things you may not know about it (we know you love it anyway)

March 27, 2014 § Leave a comment

Old Monk – here are some things you may not know about it (we know you love it anyway)

 

Old Monk lovers drink nothing but Old Monk and it is India’s favourite drink. Old monk lovers do not care about expensive single malts or crazy wines – they just want the monk. Almost every Indian man has a story to tell related to his Old Monk experiences – and we’ll save it for another day as to why we are in love with it. Meanwhile, here are a few things that you might not know about this heavenly rum:

There is a beer by the name of Old Monk 10000 Super Beer.

(If you know where to buy this in India please let us know at @tadtop)SONY DSC

Image source

First old monk was produced by Mohan Meakin Ltd at Kasauli in the Himalayan Mountains.

2

Image source

It is now produced in Ghaziabad, Uttar Pradesh.

2

Image source

 

Old monk has never advertised.

3

Image source.

It is sold with different alcohol content in India and USA. 42.8% in India and 40% in USA. The Army issue alcohol content is 50%.

5

The first time it was tasted officially was 19 December 1854 – we declare it as OLD MONK DAY – can we celebrate it as a national wet day ?

6

Image Source

Old Monk lost its rank as the largest selling dark rum in the world to McDowell’s No.1 Celebration Rum. Huh, as if we’re in that Quality Vs Quantity game.

8

Image source

Old Monk is also the third largest selling Rum in the world. Comes in different shapes & sizes

7

Image Source

 

 ALWAYS REMEMBER THIS:

9 (pssst: Hardcore is old monk+water; neat old monk is level X)

Image source

And this: There are no old monk fans, just lovers

Date A Guy Who Smokes

March 26, 2014 § Leave a comment

Date A Guy Who Smokes

By GRAGORY NYAUCHI

Date a guy who smokes, you’ll find him standing under the trees in a garden, or stepping out of a club into the fresh air to have a puff, you’ll see him taking a walk as smoke trails from his nose, or lost in thought appreciating the simple beauty that nature offers every day. Talks to him, smokers are the friendliest people you will ever meet. Ask him for a cigarette and watch him reach into his packet or pocket and hand you one even if it’s the last one. If he can’t find one bask in the selflessness of him offering you the half that he is holding in his hands.

Date a guy who smokes because he can make friends in a minute, he will stop and talk to people from all walks of life. Paupers, popes, poets, and posers will stand around with him for at least the length of a cigarette. Here is a man who knows how to share the world with everyone that the earth has thrown out of its belly, here is a man who has come to understand that there is something of worth in a shared word.

Date a guy who smokes because nobody can live in the moment more than him. Watch him take a puff as he stands still and let the world pass him by. Watch him not need the chatter of conversation in order to feel comfortable in the world, watch as he looks at the world with wonder and amazement as happy to be in the Hilton as he is to be in a dingy leaky bar because as long as he has his cigarette everything is ok with the world.

Date a guy who smokes because he realises the world isn’t ending soon. He is a man who has met with triumph and disaster and managed to treat those two imposters just the same, welcoming them into his life with a cigarette in his mouth and a fire in his hands. Date him because he understands fire. Because he knows that passion held too long can scorch you but that passion not properly nurtured will leave you cold and needing to try again. A guy who smokes knows that a gust of wind is all the world needs to throw at you in order to put off your dreams for a season, so he holds his dreams close; he cups them in his hands because he wants to protect them from the world.

Date a guy who smokes because, even though he may not have a solution to every crisis he knows that time changes everything. Look at him when something horrible happens, maybe his face will crumple a little, maybe his shoulders will sag, there may be fear and panic in his eyes. This will pass too in no time at all watch as he stands up right as a rod, fumbles in his pocket for a fire and lights the cigarette that you didn’t even see him put in his mouth. Watch as every puff he takes in restores some of his balance. Look closely enough and you will see his mind churning or his soul making peace with the world.

Watch him smoke at night with the lights off. See the flame from the cigarette light him up for just a moment before this illumination turns to smoke. Realise that he has had many moments like these. He understands the value of illusion better than most, it gives a warm glow but in no time at all it turns to smoke and ash. Maybe this is why he doesn’t lie so much, he knows that all lies flit away in the night air disappearing and leaving nothing but a bad smell in the room.

Date him because he stands his ground every day. Date him because he more than anyone else hears about the hazards of smoking. He has heard arguments against it and he has read reports about it but he did the thing that men do, he stood his own. Even if the whole world was arrayed against him he would stand there between that and what he cares about.

It’s easy to date a guy who reads. For he will be faithful to you as he is to the countless of storybook heroes and heroines, villains and villainesses that passed his beady little eyes as the strolled down the pages of the books he read.

Date him because he finds pleasure every day in one small way. Date him because he can find joy in every waking moment. The joy of anticipation as he waits for his first cigarette, the child-like wonder and awe that is writ on his face when he finds a cigarette after giving up on ever doing so. Let these emotions into your life there are shabbier companions than joy and wonder.

Most of all date him because he understands love. He understands that sometimes love is wrong for you but love is worth being wrong. He knows that love hurts and he knows intimately that love kills but that doesn’t stop him from love. He is a man who has found something that he loves and is willing to let it kill him. He is a man with a capacity for great love, for depthless, for selfless love. He shows it every time he smokes.

So find a man who smokes and share a cigarette with him.

The Repository Pattern Example in C#

March 4, 2014 § Leave a comment

The Repository Pattern Example in C#

The Repository Pattern is a common construct to avoid duplication of data access logic throughout our application. This includes direct access to a database, ORM, WCF dataservices, xml files and so on. The sole purpose of the repository is to hide the nitty gritty details of accessing the data. We can easily query the repository for data objects, without having to know how to provide things like a connection string. The repository behaves like a freely available in-memory data collection to which we can add, delete and update objects.

The Repository pattern adds a separation layer between the data and domain layers of an application. It also makes the data access parts of an application better testable.

You can download or view the solution sources on GitHub:
LINQ to SQL version (the code from this example)
Entity Framework code first version (added at the end of this post)

The example below show an interface of a generic repository of type T, which is a LINQ to SQL entity. It provides a basic interface with operations like Insert, Delete, GetById and GetAll. The SearchFor operation takes a lambda expression predicate to query for a specific entity.

using System;
using System.Linq;
using System.Linq.Expressions;

namespace Remondo.Database.Repositories
{
    publicinterfaceIRepository<T>
    {
        void Insert(T entity);
        void Delete(T entity);
        IQueryable<T> SearchFor(Expression<Func<T, bool>> predicate);
        IQueryable<T> GetAll();
        T GetById(int id);
    }
}

The implementation of the IRepository interface is pretty straight forward. In the constructor we retrieve the repository entity by calling the datacontext GetTable(of type T) method. The resulting Table(of type T) is the entity table we work with in the rest of the class methods. e.g. SearchFor() simply calls the Where operator on the table with the predicate provided.

using System;
using System.Data.Linq;
using System.Linq;
using System.Linq.Expressions;

namespace Remondo.Database.Repositories
{
    publicclassRepository<T> : IRepository<T> where T : class, IEntity
    {
        protectedTable<T> DataTable;

        public Repository(DataContext dataContext)
        {
            DataTable = dataContext.GetTable<T>();
        }

        #region IRepository<T> Members

        publicvoid Insert(T entity)
        {
            DataTable.InsertOnSubmit(entity);
        }

        publicvoid Delete(T entity)
        {
            DataTable.DeleteOnSubmit(entity);
        }

        publicIQueryable<T> SearchFor(Expression<Func<T, bool>> predicate)
        {
            return DataTable.Where(predicate);
        }

        publicIQueryable<T> GetAll()
        {
            return DataTable;
        }

        public T GetById(int id)
        {
            // Sidenote: the == operator throws NotSupported Exception!
// 'The Mapping of Interface Member is not supported'
// Use .Equals() instead
return DataTable.Single(e => e.ID.Equals(id));
        }

        #endregion
    }
}

The generic GetById() method explicitly needs all our entities to implement the IEntity interface. This is because we need them to provide us with an Id property to make our generic search for a specific Id possible.

namespace Remondo.Database
{
    publicinterfaceIEntity
    {
        int ID { get; }
    }
}

Since we already have LINQ to SQL entities with an Id property, declaring the IEntity interface is sufficient. Since these are partial classes, they will not be overridden by LINQ to SQL code generation tools.

namespace Remondo.Database
{
    partialclassCity : IEntity
    {
    }

    partialclassHotel : IEntity
    {
    }
}

We are now ready to use the generic repository in an application.

using System;
using System.Collections.Generic;
using System.Linq;
using Remondo.Database;
using Remondo.Database.Repositories;

namespace LinqToSqlRepositoryConsole
{
    internalclassProgram
    {
        privatestaticvoid Main()
        {
            using (var dataContext = newHotelsDataContext())
            {
                var hotelRepository = newRepository<Hotel>(dataContext);
                var cityRepository = newRepository<City>(dataContext);

                City city = cityRepository
                    .SearchFor(c => c.Name.StartsWith("Ams"))
                    .Single();

                IEnumerable<Hotel> orderedHotels = hotelRepository
                    .GetAll()
                    .Where(c => c.City.Equals(city))
                    .OrderBy(h => h.Name);

                Console.WriteLine("* Hotels in {0} *", city.Name);

                foreach (Hotel orderedHotel in orderedHotels)
                {
                    Console.WriteLine(orderedHotel.Name);
                }

                Console.ReadKey();
            }
        }
    }
}

Repository Pattern Hotels Console

Once we get of the generic path into more entity specific operations we can create an implementation for that entity based on the generic version. In the example below we construct a HotelRepository with an entity specific GetHotelsByCity() method. You get the idea. 😉

using System.Data.Linq;
using System.Linq;

namespace Remondo.Database.Repositories
{
    publicclassHotelRepository : Repository<Hotel>, IHotelRepository
    {
        public HotelRepository(DataContext dataContext) 
            : base(dataContext)
        {
        }

        publicIQueryable<Hotel> FindHotelsByCity(City city)
        {
            return DataTable.Where(h => h.City.Equals(city));
        }
    }
}

[Update july 2012] Entity Framework version

The code below shows a nice and clean implementation of the generic repository pattern for the Entity Framework. There’s no need for the IEntity interface here since we use the convenient Find extension method of the DbSet class. Thanks to my co-worker Frank van der Geld for helping me out.

using System;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;

namespace Remondo.Database.Repositories
{
    publicclassRepository<T> : IRepository<T> where T : class
    {
        protectedDbSet<T> DbSet;

        public Repository(DbContext dataContext)
        {
            DbSet = dataContext.Set<T>();
        }

        #region IRepository<T> Members

        publicvoid Insert(T entity)
        {
            DbSet.Add(entity);
        }

        publicvoid Delete(T entity)
        {
            DbSet.Remove(entity);
        }

        publicIQueryable<T> SearchFor(Expression<Func<T, bool>> predicate)
        {
            return DbSet.Where(predicate);
        }

        publicIQueryable<T> GetAll()
        {
            return DbSet;
        }

        public T GetById(int id)
        {
            return DbSet.Find(id);
        }

        #endregion
    }
}

Where Am I?

You are currently viewing the archives for March, 2014 at Naik Vinay.