sigma.js

August 7, 2012 Leave a comment

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.

sigma.js Examples

Categories: Canvas, HTML5, JavaScript

Repo.js

August 7, 2012 Leave a comment

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.

Repo.js github page

Categories: JavaScript, Tools

JavaScript String: Single or Double Quote?

August 7, 2012 1 comment

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.

Categories: JavaScript

C++ Primer Plus and LearnCPP.com

July 26, 2012 Leave a comment

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.

Categories: Books, C++

climits Symbolic Constants

July 26, 2012 Leave a comment

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();
}
Categories: C++ Tags: ,

Case Sensitivity in PHP function names

July 19, 2012 1 comment

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.

Categories: PHP

Sprite Cow

June 5, 2012 1 comment

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.

Categories: CSS, Tools
Follow

Get every new post delivered to your Inbox.