sigma.js
sigma.js is a free and open-source JavaScript library to draw graphs, using the HTML5 canvas element. It has been especially designed to share interactive network maps on a Web page or to explore dynamically a network database.
Repo.js
Repo.js is a light-weight jQuery Plugin that lets you easily embed a Github repo onto your site. As a plugin or library author this is a great way to showcase the contents of a repo on a project page.
JavaScript String: Single or Double Quote?
If you come from a strongly typed language like C++ to JavaScript you’ll definitely confused the way strings are represented in it.
In JavaScript you can use both single and double quotes to represent a string. Also you can use both single and double quotes in a single line too but the nesting order should be maintained ie if you start a double or single quote then you must finish it before using a different quote. For example
var strStudentName = "Tom" + ' Thomas'; //Correct var strStudentAddress = "12/56, ' + 'Arizona "; //Incorrect; due to the quote nesting issues
So the best part is the user can represent the string in JavaScript any way they want. But a question at this point is which method is the proper one?
There is no definite answer as both single and double quotes are interchangeable and you can use whatever you find convenient.
Still I feel that we should use single quotes in JavaScript to represent strings. One of the reason I found is this style is useful especially if you are dealing with HTML markup strings in JavaScript. In HTML the double quotes used for storing attributes. An example would be
var strHtml = '<div id="p0_content">This is a test</div>";
In the above code snippet we’ve used single quote for the string value and double quotes for enclosing the attribute value in the markup. It looks simple and elegant.
C++ Primer Plus and LearnCPP.com
Two weeks back I’ve started to check C++, after a gap of almost 71/2 years. During these 71/2 years I’ve worked in a variety of technologies. Majority of them were related to web applications and scriptting languages.
Though I have used languages like Java, C#, VB.net, etc from time to time either for accomplishing some of my tasks or for doing some personal experiments or projects.
But when I returned back to C++ it was a bit different experience. I prefer learning or brushup things based on books and have read some great books along with some really bad ones. I feel that some authors really make things difficult for reader by going in a very complex way while describing things. I personally feel that writing is an art and some authors really mastered the art of writing and Stephen Prata is one the of the best author I’ve experienced.
Recently I bought C++ Primer Plus by Stephen Prata. I bought this purely based on the reviews about this in Amazon.com and my decision to buy this book was one of the best that I’ve made recently.
I haven’t read this book completely but I can assure you that this covers all the details about C++ in a very detailed manner. The writing style is simple and strightforward unlike some other books. I’d suggest this book to anyone who wants to learn C++ as a newbie or for someone with lots of programming experience as both can gain a lot of information from this. This book would be an asset to any C++ programmer.
Another great online reference for budding C++ programmers is LearnCPP.com. This resource maintains its quality throughout its tutorials. The writing style was simple and uncomplicated. I often found that conveying the concepts can be very difficult. But LearnCPP.com handled this very efficiently. I highly recommend this site to anyone who wants to learn C++ or bushup their C++ skills.
climits Symbolic Constants
There can be situations from a code snippet needs to start from the first allowable value of variable of a particular type and goes until the final value that the type support. This kind of scenarios are frequent in embedded programming at least, which I am familiar with.
In C++ there are some symbolic constants available through which one can determine the minimum and max value of particular data type. These constants are a part of climits header files.
The following code snippet demonstrates this functionality
void showCLimitsSymbolicConstants(){ std::cout<<"CHAR_BIT: "<<CHAR_BIT<<"\n"; //Number of bits in a char std::cout<<"CHAR_MIN: "<<CHAR_MIN<<"\tCHAR_MAX: "<<CHAR_MAX<<"\n"; //Min and maximum char value std::cout<<"SCHAR_MAX: "<<SCHAR_MAX<<"\tSCHAR_MIN: "<<SCHAR_MIN<<"\n"; //Max and Min signed char value std::cout<<"UCHAR_MAX: "<<UCHAR_MAX<<"\n"; //Max unsigned char value std::cout<<"SHRT_MAX: "<<SHRT_MAX<<"\tSHRT_MIN: "<<SHRT_MIN<<"\n"; //Max & min short value std::cout<<"USHRT_MAX: "<<USHRT_MAX<<"\n"; //max unsigned short value std::cout<<"INT_MAX: "<<INT_MAX<<"\tINT_MIN: "<<INT_MIN<<"\n"; //max and min signed int value std::cout<<"UINT_MAX: "<<UINT_MAX<<"\n"; //max unsigned int value std::cout<<"LONG_MAX: "<<LONG_MAX<<"\tLONG_MIN: "<<LONG_MIN<<"\n"; //max and min long value std::cout<<"ULONG_MAX: "<<ULONG_MAX<<"\n";//max unsigned long value std::cout<<"LLONG_MAX: "<<LLONG_MAX<<"\tLLONG_MIN: "<<LLONG_MIN<<"\n";//max and min long long value std::cout<<"ULLONG_MAX: "<<ULLONG_MAX<<"\n";//max unsigned long long value std::cin.get(); }
Case Sensitivity in PHP function names
People from non PHP background will be confused a bit about PHP function’s case insensitivity while calling them from the PHP code. You can call the function name in any case (note that the name should be same) it will not trigger any error like we have in other languages like C++, JavaScript, etc
<?php function foo() { echo "in foo<br>"; } foo(); fOo(); FOO(); foO(); ?>
All the above function calls will invoke the function foo without any issues. But personally I’d prefer to use a function name that matches with the function definition in the code to avoid any confusions in the future.
Sprite Cow
As a Front-end developer I regularly work with CSS Sprites.
I often think about getting the exact background position values of the individual images that are present in a big sprite image from a developer perspective who does not have much proficiency in graphic tools like Adobe Photoshop/Gimp.
Sprite Cow helps you to get the background-position, width and height of individual images within a sprite image in a very simple manner. You can load your sprite image and then click on the individual image or select it based on your preference and the tool will do its magic.
DNS Benchmarkers
In my last article about DNS servers I have mentioned some DNS servers that you can use.
That article opens up a new question how can we determine the best possible DNS server for our network, PC, etc? DNS benchmarkers are for that purpose.
DNS benchmarker will check and tell you the best DNS server(s) for you.
Here are two free tools that you can try
DNSBench/DNS Benchmark
namebench
DNSBench is more faster among the two but both will show you the best possible DNS server resources that is suitable for your purpose.
DNS Server Recommendations
Which DNS server is the best for me? I think about this all the time. I have two Internet connections both comes with their own DNS servers but I am still looking for the best possible DNS server for me. Why is this?
The primary duty of a DNS server is to convert the domain names (eg: yahoo.com) to its IP address. So you need to use the best DNS server that you can use. So that the DNS lookup can be quick. This will definitely improve the browsing speed especially if you are dealing with hundreds of websites a day.
Two best DNS servers I normally recommend are:
The IP address of Google DNS servers are 8.8.8.8 and 8.8.4.4
The IP adress of OpenDNS DNS servers are 208.67.222.222 and 208.67.220.220
You can use Google and OpenDNS servers alternatively.
You may find some other resource too but these are the most consistent DNS server I’ve used until now
validate.js – A form validation library
Have you ever looked for a small library that exclusively used for validating form fields that comes with a very light footprint?
validate.js is a lightweight JavaScript form validation library inspired by CodeIgniter.
This library supports over a dozen of validation rules on the form fields with provision for customizable messages to the user, provision for setting custom validation rules, etc.
The size of the library comes around 1.3 KB (minified and gzipped) and also there is no noticeable dependency with any popular JavaScript frameworks.
Demo and Documentation of this library can be found here