Using Bitbucket and Mercurial

Pre-requisites for this Tutorial
  • An Account in BitBucket.org
  • Install Mercurial from here

How to get the Code

Use the below command to get the source to your local.

$ hg clone https://USERID@bitbucket.org/REPOPATH/

How to make changes

Once you have the code on you local computer. You are free to make changes. And once in a while if you want to commit your changes then use the below command to commit to the local repository.

$ hg commit -m "comments" -u USERID

Remember: The above commit is local only. It will not be reflected in the bitbucket repository.
To publish you changes for everyone to see, use push command.

$ hg push

How to get changes from remote repo

To get changes made in Remote(bitbucket) to local repository.

$ hg pull
$ hg merge tip

For more detailed guide see here.

Have fun!

Gravatar - A Globally Recognized Avatar

A Globally Recognized Avatar

Gravatar is an image that follows you from site to site appearing beside your name when you do things like comment or post on a blog. Avatars help identify your posts on blogs and web forums, so why not on any site?

How it works

Url: http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?s=80

The URL always begins with http://www.gravatar.com/avatar/ and the next part is the hexadecimal MD5 hash of the requested user's lowercased email address with all whitespace trimmed. Hashing is done to prevent spambots from harvesting e-mail addresses.

Parameters:

  • Parameter "s" will fetch image of size 80x80 (example: s=80)
  • Parameter "g" will fetch image if it is rated G (example: r=g, r=pg)
  • Parameter "d" will fetch a default image if there is no gravatar associated with an email address (Example: d=wavatar, d=404)

Technology Details:

- Initially developed in Ruby on Rails now in PHP.
-
Uses nginx (fourth most popular) as Webserver
-
Photos are served from Amazon S3 Cloud

"The way that images were stored originally was: a complete image was made for all sizes between 1×1 and 80×80 pixels, a directory made for each rating, and a symlink placed from the rating to the appropriate image (either the users image or the default image in case the rating was too high.) So that's 80 images, 5 directories, and 240 symbolic links. The reason for this, I believe, was to attempt to serve the avatar content without any database interaction whatever. The files were then archived, uploaded to Amazon S3, and an entry added to Amazon SQS. Finally the SQS entry was retrieved by the serving server, the file downloaded, extracted, and placed on the filesystem. So this is why it took several minutes once you uploaded and cropped your image for you to be able to browse the rest of the site again. You can imagine how many files Gravatar was comprised of by the time we got a hold of it! We knew that this would simply NOT work for our new 512×512px avatar sizes. Lastly there were a couple of directories which had several hundred thousand entries (either files or other directories) which were nearly impossible to even get a listing inside of. So we had a list of things NOT to do. We just needed to figure out what TO do

So we decided that we would render all our avatars dynamically from the highest quality copy of the image we can manage… down. We would only store one version of the image, though we would store it in multiple places (a local file server for speed, and S3 for redundancy.) We would still rely heavily on caching. And we would asynchronize as much of the workload as was possible, so that you don't have to wait for things to happen after you finish cropping (to do this we employed various techniques and hacks best left for another day and another story.)

Gravatar now lives on about 20 servers: 2 Database servers, 1 File server, 2 Load balancers, 5 Caching servers, 9 Web servers, and 1 Development server. That combination of servers is handling an average of 7,214 of your requests every second of every day. That's a whopping 623,293,056 requests daily! 96% of all of those requests are served directly from cache. These days we get around 5,000 uploaded images every day."

Unique Avatar Icon Generators based on Email address

identicon wavatar monsterid


Gravatar Rocks.

"Unknown Source" in Stacktrace

When compiled java source with Ant any Exception thrown from these compiled classes doesnt show line numbers. This seems to be a default setting in Ant.
http://ant.apache.org/manual/CoreTasks/javac.html

BUILD FAILED
java.lang.NullPointerException
        at com.mycompany.myapp.MyClass.doSomething(Unknown Source)

To get back the line numbers in the Exception Stacktrace add the below options to the javac task.

debug="on"


Creating Web Applications from Scratch

Archy is a useful tool I came across which can be used to create blank web applications.

This tool becomes extremely handy as it includes all the necessary web.xml configuration and some sample code to start with.

And its very easy to use also. I recommend all starters to use this tool to create their application base.

Maven: See deprecated API usage warnings; commandline

Maven command line option to see the warnings for deprecated code usage.

mvn clean compile -Dmaven.compiler.showDeprecation=true

http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html