Blog

Debugging NodeJS application in Windows

This will be the first post in the category Black book, which will stand for common errors that I make and do not want to repeat. This idea came from the great book on IT management Making Things Happen.

So, debugging the Node application – usually after the NodeJS is setup, developers start working on theirs NodeJS projects using the standard console output. For example, I want to control what number I get after the function call

function getTheNumber(inputNumber) {
  return (inputNumber * 5);
}
console.log('Result: ' + getTheNumber(10));

The output will look like this

C:\Users\alexshumilov\blog\test>node test.js
50
C:\Users\alexshumilov\blog\test>

But what if you need to debug some complex logic, with all pros and cons of the JavaScript? What if you need the debugger like in desktop application developement IDE’s, with breakpoints, scope variables view etc.? The node-inspector will help you out in this one.

First we need to install it using the NPM package manager

npm install -g node-inspector

Then we open separate console window and execute

C:\Users\alexshumilov>node-inspector &
Node Inspector v0.12.3
Visit http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858 to start debugging.

Then in another console window we actually launch our code in debugging mode

C:\Users\alexshumilov\blog\test>node --debug-brk test.js
Debugger listening on port 5858

Visit the provided link and you will get

node-inspector window with the test script

XPath to XML with PHP

Sometimes the development of applications that deal with the XML comes to the point when the developer has to build XML document using only XPath location of elements and theirs values. For such cases the XPath to XML processor was written, so I hope it will help somebody in converting the XPath sets into documents. It is very light and performs basic document construction without any validations (we assume that no XML Schema is available).

You can checkout the XPath to XML processor at https://github.com/sashuk/xpathtoxml. Below the example of input array (in JSON format, so you can just do the json_decode(INPUTSTRING, true); over it) and the resulting output (in XML) are listed.

Read more

JavaScript Genetic Algorithm example

Genetic algorithm – In the computer science field of artificial intelligence, a genetic algorithm (GA) is a search heuristic that mimics the process of natural evolution. This heuristic (also sometimes called a metaheuristic) is routinely used to generate useful solutions to optimization and search problems.

Genetic algorithms belong to the larger class of evolutionary algorithms (EA), which generate solutions to optimization problems using techniques inspired by natural evolution, such as inheritance, mutation, selection, and crossover.

There is a simple demonstration of this algorithm below

Read more

Deploying Windows Server 2008 R2 on VMware with Openstack

I would like to share my experience of deploying virtual machines (from now on – VM’s) based on Windows Server 2008 R2 x64 in Openstack environment.

First I would like to describe the situation why I had to use Openstack for deployment of Windows-based VM’s. Currently the project for distributed calculations using OGC WPS standard is being developed in

ISDCT SB RAS, Irkutsk, so there is a need for a web-application, which will allow users to create VPS in one click – then they install required WPS service on they freshly created VPS and join our project. Users enter the name of the VM and choose the operation system. Currently we offer Ubuntu 14.04 LTS and Windows Server 2008 R2. When user creates his own VPS, he receives public IP and root credentials of the VM.

 So, what do we have – host with VMware ESXi controlled by vCenter, two VM’s for Openstack compute and controller nodes. In this guide we will cover full procedure how to create Windows VM in vCenter, then we will convert it to the Openstack image in Glance and launch it as ready-to-use VM in one click. Probably, this guide can be applied to any of the Windows system, not only for Windows 7-based systems.

Read more

Operation system not found Error VMware Openstack

If you keep getting the “Operation system not found” error while deploying images in Openstack on ESX/ESXi host, it is probably because of you did not specify the the “vmware_ostype” parameter while creating/importing image – otherwise, it is not going to be properly recognized by VMware.

Example:

glance image-create –name=cirros –disk-format=vmdk –property vmware_adaptertype=”ide” –property vmware_disktype=”sparse” –is-public=True –property vmware_ostype=”otherLinux64Guest” –container-format=bare < cirros-0.3.2-x86_64-disk.vmdk

Complete list of possible values you can find at https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html