Javascript Debugging with Console

Yes, we all know its basics:
console.log(‘Hello World!’); //log a message or an object to console‘Something happened…’); //same as console log
console.warn(‘Something strange happened…’); //same as console log but outputs a warning
console.error(‘Something horrible happened…’); //same as console log but outputs an error

So hopefully now, I can give you some tips which you didn’t know before, and which will make you a PRO debugger.

Tip #1 console.trace()

If you want to know where the log is being prompted from use console.trace() to get the stack trace with the logged data.

Tip #2 console.time() && console.timeEnd()

If you are trying to find a sneaky performance issue, start counting time with console.time() and print with console.timeEnd().

Tip #3 console.memory

If your performance issue is even trickier, and you are looking for a sneaky memory leak, you might like to try and utilize console.memory (property, not a function) to check out your heap size status.

Tip #4 console.profile(‘profileName’) & console.profileEnd(‘profileName’)

This is not standard, but is widely supported. You can start and end a browser performance tool – performance profile from the code using console.profile(‘profileName’) and then console.profileEnd(‘profileName’). This will help you profile EXACTLY what you want, and prevents you from having to be mouse-click, timing dependent.

Tip #5 console.count(“STUFF I COUNT”)

In a case of recurring function or code, you can use console.count(‘?’) to keep count of how many times your code is read.

Tip #6 console.assert(false, “Log me!”)

Yes, conditional logging without wrapping your logs with if-else 🙂
You can use console.assert(condition, msg) to log something when the condition is falsy.
*disclaimer — in Node.js this will throw Assertion Error!

Tip #7‘group’) & console.groupEnd(‘group’)

After writing so many logs, you might want to organize them. A small and useful tool for that is the & console.groupEnd(). Using console group, your console logs are grouped together, while each grouping creates another level in the hierarchy. Calling groupEnd reduces one.

Tip #8 String substitutions

When logging, you can incorporate variables using string substitutions. These references should be types (%s = string, %i = integer, %o = object, %f = float).

Tip #9 console.clear()

Well, having written so many logs, it’s now time to clear your console a little.

Tip #10 console.table()

Saving the best for last, this is a true gem in my opinion! You can actually print a very nice table with the objects you log using the console.table()

I really hope these tips make your debugging a bit more productive, and even a little fun!


console.dir(myObject, {colors: true, depth: null})

In Node, this prints the entire object (depth: null) with syntax highlight (colors: true). You can control the depth to be printed by passing a number to depth.


Another fun one is adding CSS to console.log statements:

console.log(‘%c Oh my heavens! ‘, ‘background: #222; color: #bada55’);



Functional Programming in JavaScript

What is Functional Programming in JavaScript?

Functional programming (often abbreviated FP) is the process of building software by composing pure functions, avoiding shared state, mutable data, and side-effects. Functional programming is declarative rather than imperative, and application state flows through pure functions. Contrast with object oriented programming, where application state is usually shared and colocated with methods in objects.

Functional programming is a programming paradigm, meaning that it is a way of thinking about software construction based on some fundamental, defining principles (listed above). Other examples of programming paradigms include object oriented programming and procedural programming.

What Kind of programmings we have in JavaScript prior to Functional Programming?



Wikidata Sparql Query Tutorial

What is SPARQL?

SPARQL, pronounced ‘sparkle’, is the standard query language and protocol for Linked Open Data on the web or in a semantic graph database (also called RDF triplestore). Eg: Wikipedia is a linked open data

SPARQL, short for “SPARQL Protocol and RDF Query Language”, enables users to query information from databases or any data source that can be mapped to RDF.

Basics – Understanding Prefixes

Wikidata Query Service (WDQS) is a software package and public service designed to provide a SPARQL endpoint which allows you to query against the Wikidata data set.

WDQS understands many shortcut abbreviations, known as prefixes.

Some are internal to Wikidata

wd, wdt, p, ps, bd, etc.

and many others are commonly used external prefixes, like

rdf, skos, owl, schema, etc.

?s is a prefix for a statement, or triple, or you could even think of it as the subject in an spo triple.

In the following query, we are asking for items where there is a statement of “P279 = Q7725634” or in fuller terms, selecting subjects that have a predicate of “subclass of” with an object of = “literary work”.

PREFIX wd: <>
PREFIX wds: <>
PREFIX wdv: <>
PREFIX wdt: <>
PREFIX wikibase: <>
PREFIX p: <>
PREFIX ps: <>
PREFIX pq: <>
PREFIX rdfs: <>
PREFIX bd: <>

# The below SELECT query does the following:
# Selects all the items(?s subjects) and their descriptions(?desc)
# that have(WHERE) the statement(?s subject) has a direct property(wdt:) = P279 <subclasses of>
# with a value of entity(wd:) = Q7725634 <Literary Work>
# and Optionally return the label and description using the Wikidata label service

SELECT ?s ?desc WHERE {
  ?s wdt:P279 wd:Q7725634 .
     ?s rdfs:label ?desc filter (lang(?desc) = "en").



Label service

You can fetch the label, alias, or description of entities you query, with language fallback, using the specialized service with the URI <>. The service is very helpful when you want to retrieve labels, as it reduces the complexity of SPARQL queries that you would otherwise need to achieve the same effect.

The service can be used in one of the two modes: manual and automatic.

In automatic mode, you only need to specify the service template, e.g.:

 PREFIX wikibase: <>
 SERVICE wikibase:label {
     bd:serviceParam wikibase:language "en" .


Install Redis and start working with it

Download redis

Unzip the folder and goto redis folder..

1. redis > `make` hit enter

2. cd src

3.  `./redis-server` hit enter

4. Open new tab in cmd prompt/terminal -> `./redis-cli` and hit enter. make sure you are in src folder.


you can use set and get commands in key value pairs format. Eg: `set “name” “Sathya”`. later `get name` will print sathya.

Similarly Publish and Subscribe also very easy to use in redis..

Publish: Take a new tab from src folder and enter `./redis-cli` and hit enter. Then do the following..

Subscribe: Take a new tab from src folder and enter `./redis-cli` and hit enter. Then do the following..

In simple words, like in twitter..when you subscribe to a channel, when ever user post(publish in redis point of view) a message, all channel subscribers will get that update.