Categories
Uncategorized

Book Review: Instant Sublime Text Starter

Disclaimer: I received a copy of the book for review purposes.


The book Instant Sublime Text Starter is another nice title from Packtpub. The book gets an user started with the Sublime Text editor with very simple instructions. The book starts with installation and covers all major platforms. Having used the various operating systems over the year, I’ve found the instructions more than adequate for Windows, Linux and Mac OSX users.

The book highlights the common features of Sublime Text and provides a decent walk through. It also provides guidelines on where to go next to master the text editor. The book, as a starter is a very good one. If you’re into building software, Sublime Text could be a useful tool. And this book would certainly help you start instantly.

Categories
Uncategorized

Tagging in Git: Why? How?

Why use Git tag?

Git tags are like milestones, markers or a specific point in the repo’s history marked as significant. Tags are usually used to mark stable releases or achievement of very important milestones.

Tags can help the users of the repo to easily navigate to the important parts of the code history like release points. For example, on Github, you can easily grab archive of “tags” in the current repo.

Dealing with Tags

List tags:

Search in tags:

That will display tags starting with “v1.” – use regex and your common sense to do complex queries. This can help you narrow down your query in case you have plenty of tags in the repo.

View a tag:

Note: The command doesn’t have “tag” in it. 🙂

Adding tags:

The “-a” denotes an annotated tag – means it’s stored as a full object in the git database where as a non annotated tag is just a pointer to a specific commit. Just drop the “-a” to create normal tags. The “-m” option is of course obvious, it allows you to add a message to the annotated tag.

Adding Tags later:

This will add the “v1.2” tag to the commit marked by “9fceb02”. “git log” will help you get the checksum of the commit.

Pushing Tags to remote branch:

PS: Git tags are not pushed automatically with generic “git push” command. You must push the tags separately.

Deleting a tag:

That will delete the tag v1.0.0.

These are the very common uses of Git tags. Look at the git manual for more complex stuff you can do with tagging 🙂

Categories
Uncategorized

Doing magic with C# Method Extension

Say, we have a class defined in one of the assemblies shipped with a third party solution. It would be a great help if you could add a helper method to one of the objects. Unfortunately, we do not have the source code. 🙁 What do we do?

In such scenarios, .NET hasn’t left us alone in the desert 😀 The method extension technique will allow us to add our own methods to classes of our choice. Want to see an example? Take the List generics, every list of a generic type has some handy methods. Now we want to add one of ours. Printing each of the element in a list requires us to setup a foreach() loop every time. Why don’t we add an extension method named “Print()” which would print all the elements in a list – one by one? Let’s get our hands dirty!

Facts to remember:
— To extend a class and add method, we must declare a public static class with some name. The name doesn’t matter at all.
— We should define a method with our desired name in that class.
— The first parameter to the method will be “this < Object_we_want_to_extend > parameterName”. Do not forget the “this” keyword. It is the magic wand that does the magic.
— We can pass additional parameters.
— When calling the extended method from the original object, the first parameter is not required to pass. You can ignore it as if it were never there.
— For safety and security the extended method can not access private areas (fields, properties or methods).

So what do all these mean? Show me some codes! Okay, here you go:

The output shall be:

Cool, no? 😀 The code is commented as much as I thought necessary. Feel free to ask a question or submit any feedback you might come up with 🙂

Have fun implementing some extended methods on your own 🙂