Git

History

So, it’s always nice to know a bit of history. What happened was that the Linux Kernel was being maintained using bitkeeper free of charge. However, later Bitkeeper free of charge license terminated. So, Linus Torvalds decided to create Git to maintain the Linux Kernel Development.

Differences with other VCSs

Git is a Version Control System. There are many other VCSs but what’s good with it is that it was initially designed to maintain the Linux Source code which is huge. By that, you can understand that it’s going to consider lots of aspects such as size, bandwidth optimization and many others into consideration.

There are several differences between Git and other VCSs is that Git stores whole snapshots of the project rather than only deltas. Also, files are checksumed using SHA-1 Hash before they are stored and referenced using the checksum.

Now, a file in Git can be three states:

  1. Modified
  2. Staged
  3. Committed

It’s very simple. Whenever, we create/modify a file, we need to explicitly tell Git (Staging Process) to include the file in the next version. Now, to create this “next version”, we simply commit.

Configuration Files

Git has 3 level of configuration:

  1. System Wide Configuration
  2. User Specific Configuration
  3. Project Specific Configurations

What’s more interesting is that the configuration are overridden. So, User Specific configuration overrides System Wide Configurations and Project Specific configurations overrides User Specific configurations.

To view configurations, you can simply use this command:
git config --[system|global|local] -l

1. System Wide Configurations
Global git configurations are stored in the /etc/gitconfig file. To add/modify to this file, simply pass —system as an argument
git config --system user.name "Noorani Bakerally"

2. User Specific Configuration
All user specific configurations are stored in a .gitconfig file. This file is found in the home folder of users. So, to display it, simply run cat ~/.gitconfig.To add/modify to this file, simply pass – -global as an argument
git config --global user.name "Noorani Bakerally"

3. Project Specific Configuration
So, project specific configurations overrides all configurations. So, add/modify these project specific configurations, simply ensure that in the git repository of the project and do git config user.name "noorani Bakerally"

Git Objects

There are 4 types of object:

  1. blog: Consider it as a file in a git repository
  2. tree: A directory which can contain other trees or blobs
  3. commit: A specific point in time containing meta information and a pointer to the previous commit
  4. tag:A milestone in the life of the project. e.g. A new version

Also, all object have 3 attributes, a type(1 of the above 4), a size and its content.

Git basics

To create a git repository
mkdir new_git_repository
cd new_git_repository
git init new_git_repository

To clone an existing git repository
git clone <URL_Existing_git_repository>

To view status of files from the last commit
git status

File tracking
To manage your files, git track your file so that it can identify and changes to it. This is not automatic as you can avoid tracking some files but not adding adding or simple creating pattern in a gitignore file(we’ll see that later)

To explicitly tell git to track a file, do

git add <filename>

Creating/managing commit
git commit -a -m "the commit message", -a:all, -m:message
A commit is like a milestone in the life of a project. It’s like saving the project state in the project life time. A commit is represented in git as a 40 character SHA-1. Anything that is committed in git can be obtained again. At any point in time, you can return back to a specific commit using the reset.

git reset --hard <commit SHA1 Code>

The above command is dangerous. Suppose currently you have some modifications pending (not yet committed), if you run it, you lose all your modifications. Remember, anything committed can be regained. The negation is also true.

Suppose that you have created a commit and have forgotten to include some files. Therefore, just after the commit, perform the necessary modifications and add the files. Then do a

git commit --amend

To undo a commit,

git reset --[soft|hard] HEAD^
soft leaves all unchanges while hard removes all changes and returns back to the previous commit(HEAD^ refers to the previous commit).

Revert and Undo is different. Revert returns to a previous commit and commit this return. To undo a commit using revert,

git revert HEAD

To revert to a previous commit if you know the commit code:

git revert <SHA-1 Code of commit>

You can also revert by going back in history without entering the hashcode:
# move the branch pointer back to the previous HEAD
git reset --soft HEAD@{1}

Just by changing the number in the {}, you can revert back

Sometimes you need to know where you are:
To view the location of the current head,
cat .git/HEAD

this outputs the reference of the current head, ref: refs/heads/master

now to view the current head, simply perform a cat on the file:

cat .git/refs/heads/master

To get the difference between two branches:

git diff –name-status –color branch1..branch2

e.g. git diff –name-status –color master..development

To change the name of the branch you are currently are:

git branch -m newname

File Operations within a git repository
Like in any other folder, in a git repository, you can perform file operations like creating,removing,editing or moving file. For all file operations, you need to explicitly tell git about it. For the “create” operation, consider the file tracking above.

References:

  • http://www.codinginahurry.com/2011/02/05/three-levels-of-git-config/
  • http://linuxmanpages.net/manpages/fedora13/man1/git-config.1.html
  • http://git-scm.com/book
  • http://www.gitguys.com/topics/head-where-are-we-where-were-we/

How we should probably program on the web in 2012 and after?

Web development in 2000 and 2012 is surely not the same. Today, when we develop on the web, we need to consider many aspects which we wouldn’t do 12 years back. Modern Web Development techniques and technologies have had lots of implications.  Some of the aspects which are considered to be very important are:

1. Don’t forget Mobiles

Modern Web Development-US Mobile Devices Penetration

Image obtained here

I was googling and it happened that I landed on a very interesting article containing lots of statistics. In it, you’ll notice one very interesting prediction which I believe to be true. Mobile has currently a great share in the Modern Web Development World. This will intensify….

By 2014, mobile internet gonna take over desktop internet.

By that, if you are developer, you’ll surely understand the implications. So for every website/web application you are developing, ensure you have it’s mobile alternative. The big boss Google/Facebook….. are doing this, so don’t diverge from the best practice.

But how to develop a mobile browser version for each desktop browser version? The next one answers it :)

2. Develop an API

Strive to build a web service for your web application. By doing so, sky is the limit. Because, you can easily build a mobile version of your application in either native/web view easily just making your web application inter-operating with the web service.. Again, the big boss Google/Facebook, so …..

Read this and notice how developers are making their web application using web services to reflect Modern Web Development practices.

2. Be fair to all browsers’ users

Browser Statistics

Statistics obtained here

You cannot tell everyone to use Google Chrome just because it’s the best.  Just ensure that your web app is as beautiful and functional on all browsers as it is on Google Chrome :-)

3. Use a framework

Sometimes, it’s a bit difficult to use a different framework because that changes the way we program. But it’s important. The fact is that framework (be it a server-side for PHP, Ruby,Java…., client-side for JavaScript such as jQuery or for CSS such as BluePrint), regroups set of best practices that it is difficult to apply when writing raw codes. e.g. When writing raw SQL in PHP, you might create holes for SQL injection or when using raw JavaScript, you might write codes that may not be compatible for all browsers. So, check out a good framework and use it.

Now, what’s a good framework?
a. One which is “non-authoritative” will make it. That is, it doesn’t forces any convention on you, if you use it’s great and if you don’t, it doesn’t bother.

If you check Fat Free, I’ve never use it, but reading it’s documentation tell me one thing, you just include the base.php file and use whatever features you like. You can use its ORM, MVC structure or also implement your own application level conventions.

b. Secondly, choose a framework that utilizes open source tools so that tomorrow, if you want to use these tools in isolation in a different environment, you already have the expertise. e.g. Symfony 2 clearly lists in its documentation that it uses external software as its building block such as Twig as templating engine or Doctrine as ORM.

5. Don’t forget Social Networks

Modern Web Development-Social Sharing

Obtained here

If you forget social network, you are implicitly telling 2 billion users to forget you. Modern Web Development advises you to integrate your site with social networks just to make people aware that you exist. Then, if your content is of value to them, they’ll come like swarm of bees.

Here are some convincing articles I found concerning social networks:

  1. http://www.jeffbullas.com/2011/09/02/20-stunning-social-media-statistics/
  2. http://blog.hubspot.com/blog/tabid/6307/bid/5965/The-Ultimate-List-300-Social-Media-Statistics.aspx

6. Be SEO Friendly & Google Friendly at the same time

 

Modern Web Development-Google Spiders

You are doing a website and you want to have traffic on it. So, first, learn how to create traffic. Learn the best practices for making your websites SEO friendly. If you are using CMSs, make sure you use the proper plugins to increase traffic and adhere to SEO practices. Also, ensure you’re site is Google Friendly because currently Google is leading, so lead with him. Ensure to properly spoon-feed Google Spiders so that they choose to build their “web” on your site. My blog is very new & “premature”, still my statistics says this:
Top Search Engine

Bee Keeping-My First training

BeeKeeping

That’s me, Yaaaa :-) After completing my degree of Computer Science & Engineering, I did not start to work immediately. I didn’t had any idea when would I start or better, if I ever would or not. Everyday, I would wake up, do the necessary things, some programming then would find another interesting things to do. Finally, I and my friend Irfan decided to learn a bit of Bee Keeping. I googled a little and found some books and tutorials. However, finally, I understood that this is not computer science and reading a tutorial and trying it up will not make it. So, I phoned at AREU which redirected us towards the Mauritius Apicultural division. We went there and we met a Mr.Jamalkhan. He was a very nice guy with a good personality. He liked to share and we learnt many things from him. He had lots of experience(I think more than 30 years) in the field. He learnt from many countries including France and India. So, we went on a small training of how to remove bees from their wild environment and how to “domesticate” them. Below are some of the pics we took, it was really fun :-)

[slickr-flickr set="Learning Bee Keeping"]

My Childhood-”the female answer”

I’m still a child, but 15 years back, I was a child and childish at the same time. Till today, the best time of my life was childhood where I could afford to make crazy things without being viewed as a BAD ADULT which is the case today if ever I does them. Anyway, 15 years back, I wouldn’t miss any occasion to make something “GREAT” that would almost always force my parents to come to school and listen to the complains of teachers. There are indeed many such events but I don’t remember all.

Till Standard Four, I would make bad things but not that bad that would force teachers to sack me out of classes. But, as soon as I reached Standard Five, wonder from the energy to commit on mischievous acts came from.

What happens when someone doesn’t know the meaning of the word “female” when he is in standard 5 and his name is Noorani?

So, let me narrate to you something funny. So, I was in Standard Five and we completed the syllabus. Just not to remain idle, our teacher manage to get old Standard 6 English books from the school archive and distributed it to us. The scenario was that he would explain us the exercises and ask us questions. Since these books were used ones, some of them contained answers. He also told us not to trust the answers in the book. I was thinking myself to be greatly fortunate that I obtained a copy of the book containing answers. So, I turned back and thumbs up my friend thinking that today is my lucky day. From the back, one by one, all my friends were getting trouble answering questions because we were in the “weak” zone.

In fact, I was on the border of the “weak” zone. In a class of about 40 students, I would always come 25th with a standard deviation of at most 2. So, after all, my turn came and it was a mighty easy question for someone of Standard 5 but mighty difficult for someone like me. So, the question I obtained was “What is your gender?”. When I look at this question, I precipitately said “FEMALE” because the one who use the book before was a girl and she wrote “FEMALE”. The entire class began to laugh and looking at them I also began to laugh because I did not know what happened. Then, I, very silently, asked my friend who was sitting near me, “What happened?”, he replied, “What you really don’t know what happened?”, I replied “Yes, what happened, why are you laughing?”, hearing this, his laugh intensified. Its only during the recess that I came to know. That day, I did not get into trouble with the teacher, guess why?, his mood was OFF, I put it ON :)

 

 

RIA-Rich Internet Applications

We believe that RIA are modern Internet Application but I think RIA came into existence the moment JavaScipt took birth at Netscape. It’s really at that time that client-side web app started to become “rich”.

Why “Rich” ?
In typical websites, all interface are created on the server-side. The browser only renders the HTML. However, in RIA, server acts only as a model and supplies data. The interface and business logic is implemented in the client code. So, in typical websites, the client is a “thin client” in that it only renders HTML. However, in RIA, as mentioned above, the client is responsible to create the interface and also to implement a connection module to connect to the server.

Wikipedia definition for a RIA consist mainly the following parts:

  • has many of the characteristics of desktop application software
  • typically delivered by way of a site-specific browser, a browser plug-in, an independent sandbox, extensive use of JavaScript, or a virtual machine.”

However, I disagree with this clause “typically delivered by way of a site-specific browser, a browser plug-in”. Several frameworks make use of plugins to display Internet Applications.However, plugin is not a metric to determine whether a web application is an RIA or not. For me, RIAs only mimic desktop application software and try to inherit their traits. Personally, I see 2 main traits that RIAs try to mimic:

1. High Interactivity

In RIA, we don’t wait, they are very responsive and information is on demand(though it is not). In typical websites, users are more tolerant and they consider waiting as natural. However,RIA models desktop applications which tend to be very “fast”. Bandwidth can be a bottleneck leading to latency.Thus,latency need to be hidden/abstracted though it exists. I’ll try to answer the question “How to decrease latency?” below. Also, interaction is not only one way, from users to application but also from application to user. RIA interact with the user by making users to experience their richness through their fantastic designs and behaviors. The design is what I called the Data Presentation. The behaviors are the amazing effects that RIA exhibits such as fadeIn/fadeOut, transitions, drag and drop. In short, RIA need to be “young”, “gorgeous” and must “flirt” with the user in the smoothest way.

2.Data Presentation

On seeing RIAs, you’ll immediately notice that the widgets in the interface is different. Sometimes, you’ll see charts showing updated data on a real-time basis. There’ll be widgets are being updated by xmlHTTPResponses without even the user noticing it. The application structure of a RIA is somewhat different from a normal web application. Consider the following MVP pattern:

Application Structure

If we model an RIA using an MVP pattern then the client-side code is the View and the Presenter. The server only acts as a model for the RIA. All the codes for business logic and interface generation including a module to connect to server makes up the client. Initially all codes are obtained from the server. Thereafter, only data is obtained from the server through request made by the client communication module.

Now, I’m in a better position to answer the question, “How to decrease latency?”
1. Implement the MVP pattern described above to implement your RIA. By doing so, you’ll ensure that after the initial application load, all communication between the client and the server involves only and only bits of data.

2. Caching & Browser local storage
Implement your application such ensure caching on the level of the browser. Also, treat visibility properly so that if ever, you are using HTTP, intermediate proxies can cache your data. Then, for data that can be reused in the future, make use of the local storage.

3. Initial Application load
Normally, RIA are big in size compared to typical websites. So, at the initial application load, not all files are needed. I think it’s best not to load the entire application in one shot because several part might not be of use. Instead, insert junctures in your application that request the needed part from the server when needed. With JavaScript, it’s fairly easy to insert a script in DOM. Also, GWT does this well through a technique which they called Code Splitting

One very important aspect of Human Computer Interface is the enjoyment derived from using the software. So, at the same time, RIA must be at the same time useful and fun. I think that by optimizing bandwidth, ensuring a high level of interactivity and presenting data using rich widgets will allow to develop a good RIA which users will love.

Constaints

Though the technology exists for building RIAs, there are some constrains that cannot be avoided such as:

  • Heterogeneity
  • Search Engine Optimization
  • Browser Features
1.Heterogeneity

Browser Statistics

http://www.w3schools.com/browsers/browsers_stats.asp

Users on the other end make use of several browsers. We all know that browsers have incompatibilities. So, sometimes, we need to be good web developers and at the same time browser gurus to ensure consistency on all available browsers. Sometimes, when implementing some features of RIA, browser sniffing will be important. It’s boring because sometimes a particular feature must be implemented for several browsers if there is not a standard way to do it.

2.Search Engine Optimization

RIA will make use of asynchronous communication to request data from the server. The technology for achieving this is AJAX. There has always been a discussion whether not AJAX is SEO Friendly(Check this discussion here). However, Google has published a technique here to ensure that web crawlers can craw Ajaxified sites. They say it works and I’m sure it does but I’ve never used it.

3.Browser Features

RIA will always exist and so will normal websites do. Normal websites comply with browser features such as browser back/forward button, history, bookmarking. Normally, RIA are ajaxified internet application. Therefore, you’ll need to implement workarounds to ensure you don’t break those functionalities.

Development of RIA

There are several frameworks available for the development of RIAs. However, which one to choose? Personally, I’ve noticed that all RIA frameworks mitigate to maximize at least one of the three traits above. Some of the widely known frameworks are from Adobe technologies such as Flash or Flex, jQuery or Microsoft namely Microsoft Silverlight. (Here is a good list of RIA Frameworks) Check this to get an overview of RIA Statistics.

Future of RIA

I’m almost sure that the use of RIA will intensified in the coming years. Below is a study carried in 2006(obtained here):

Currently more and more companies are moving towards cloud computing(Saas) for their business solutions. Such as for accounting, some may be moving towards openERP or for CRM such as SalesForce. So, companies are now preferring Internet Application over Desktop applications. These Internet Application need to match those Desktop applications in terms of features and interactions. There comes RIAs to their rescue.