January 28, 2016

Renderer - Main process communication in Electron

Electron (or) Atom Shell is used to build cross platform desktop apps with web technologies. With electron, you can do a lot more than just wrapping your webpage into an app. In browsers, web pages usually run in a sandboxed environment and are not allowed access to native resources. Electron have the power to use Node.js APIs in web pages allowing lower level operating system interactions. Well, how does this work? ... Read more

January 19, 2016

Resolving `module isn't defined` error in Electron

Well, I got a chance lately to build a desktop app for DoSelect and we came across this weird issue moment not defined We use moment.js for a couple of things. One of the answer from Stack Overflow suggested to turn node-integration : false but we needed node-integration for some other purposes. So, what/where is the problem? module is defined, even in the browser-side scripts. This causes moment.js to ignore the window object and use module, so the other scripts won’t find moment in global scope. ... Read more

January 16, 2016

Node.js clustering maintaining sticky session

NodeJS is single threaded. It is event-driven and single-threaded with background workers. Scaling up a node application is possible by splitting a single process into multiple processes or workers by using cluster module. The cluster module allows you to create child processes (workers), which share all the server ports with the main Node process (master). A simple example {% highlight javascript %} var cluster = require(‘cluster’) var http = require(‘http’) var numCPUs = require(‘os’). ... Read more

March 21, 2015

Block scoping in JavaScript and hoisting

Hoisting is the JavaScript interpreter’s action of moving all variable and function declarations to the top of the current scope. This means, the declarations (not the values) will be pushed to top of the current scope before the interpreter starts its job. For instance, Function declarations are hoisted but the function declarations that are assigned to a variable is not hoisted. {% highlight javascript %} foo(); // Function called before initializing ... Read more

Copyleft Jaipradeesh