Saturday, December 15, 2012

Installing PhantomJS on Ubuntu

PhantomJS is a headless WebKit with JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

I have a virtual machine in which Ubuntu 12.04 (32-bit) version is installed. After a few attempts, I found the way how to install PhantomJS 1.7 to my virtual machine.

Steps are bellow:
cd ~
sudo tar xvf phantomjs-1.7.0-linux-i686.tar.bz2
sudo mv phantomjs-1.7.0-linux-i686 /usr/local/share/phantomjs
phantomjs --version

Saturday, December 8, 2012

Create your Own Git Server on Azure Cloud

I wrote a blog post 'Create your Own Git Server on Azure Cloud'. This blog post can be found here.

Saturday, October 20, 2012

Meet the Raspberry Pi

A few weeks ago I got my Raspberry Pi from element14. It's time to wipe away the dust from it:

If you don't know what Raspberry Pi is,  visit website.

I wanted to install raspberry by myself. I took an empty SD card and loaded to it Raspbian installer. Raspbian is OS dedicated to Raspberry Pi. You can find a manual how to install Raspbian here.

After long waiting and thew crashes I understood that installation failed.

I decided to choose different approach. I downloaded Raspbian image from here and  used Win32DiskImager tool to write this image to SD card.

Finally, Raspbian started.

Sunday, August 26, 2012

Create a npm package

npm is package manager for nodejs.

If you want to create and publish npm package you must complete theses steps:

1. Create a profile

Go to npm website and create a profile.

2. Create package.json file

Create a folder for your package and change the current directory to it:
mkdir my_package
cd my_package
Create package.json file:
  "name" : "my_package",
  "description": "package description goes here",
  "version": "1.0.0",
  "author": "Firstname Lastname <>",
  "keywords": ["my_keyword1", "my_keyword2"], 
  "repository": {
    "type": "git",
    "url": ""
  "main" : "./lib/my_package.js",
  "engines": {
    "node": ">=0.8.8"
3. Link with npm

Link your package with npm:
npm link
4. Publish the package

Add a user:
npm adduser
Publish a package:
npm publish
If you want to override published package you can user --force parameter:
npm publish --force

Monday, August 13, 2012

Say 'Hello world' using Node.js

Install node.js on Ubuntu

Install the dependencies:
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
Download source code of version 0.8.8 from github:
git clone -b v0.8.8-release git://
Build and install node.js:
cd node
sudo ./configure
sudo make
sudo make install
To get node.js version type:
node --version
Create Hello world application

Create my-script.js file:
console.log("Hello world!!!")
Run the code:
node my-script.js
Hello world!!!

Wednesday, July 18, 2012

MarkDown files viewer

MDPad is a free MarkDown files viewer and editor for Windows. It can be donwloaded from here.

  • Edit markdown file
  • Preview markdown file
  • Expor it as HTML file
  • Print it
  • Open it directly from explorer

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML). To read more go here.

Tuesday, June 26, 2012

Profiling C++ application

Profiling allows you to learn where your program spent its time and which functions called which other functions while it was executing.

To profile C++ application I use GNU profiler.

To compile a source file for profiling, specify the -pg option when you run the compiler. 
g++ -pg -o bin/prog src/
Once the program is compiled for profiling, you must run it in order to generate the information that gprof needs.
After you have a profile data file gmon.out, you can run gprof to interpret the information in it.
gprof -b ./bin/prog
You will get such result:
 Flat profile:
 Each sample counts as 0.01 seconds.
  no time accumulated
   %   cumulative   self              self     total           
  time   seconds   seconds    calls  Ts/call  Ts/call  name    
   0.00      0.00     0.00        1     0.00     0.00  method1()
   0.00      0.00     0.00        1     0.00     0.00  method2()
   0.00      0.00     0.00        1     0.00     0.00  method3()
    Call graph
 granularity: each sample hit covers 4 byte(s) no time propagated
 index % time    self  children    called     name
                 0.00    0.00       1/1           main [4]
 [5]      0.0    0.00    0.00       1         method1() [5]
                 0.00    0.00       1/1           method2() [6]
                 0.00    0.00       1/1           method1() [5]
 [6]      0.0    0.00    0.00       1         method2() [6]
                 0.00    0.00       1/1           method3() [7]
                 0.00    0.00       1/1           method2() [6]
 [7]      0.0    0.00    0.00       1         method3() [7]
 Index by function name
   [5] method1()               [6] method2()               [7] method3()
To read more about the GNU profiler go here.

HTTP: The Definitive Guide

A few days go I finished reading book HTTP: The Definitive Guide.

Web technology has become the foundation for all sorts of critical networked applications and far-reaching methods of data exchange, and beneath it all is a fundamental protocol: HyperText Transfer Protocol, or HTTP.

This book is about how web applications work, how the core Internet protocols and architectural building blocks interact, and how to correctly implement Internet clients and servers.

Monday, May 28, 2012

Enterprise Application Architecture

A few years a go I read two books about how to create architecture for enterprise applications. Now these books are on my work table. One of them is  Microsoft .NET: Architecting Applications for the Enterprise by Dino Esposito and Andrea Saltarello. Another book is Pattern of Enterprise Application Architecture by Martin Fowler.


Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. It runs on most available operating systems, including Windows and is licensed under the GNU GPL.

Squid website:

Friday, May 25, 2012

Defining a function pointer

I wrote some simple examples how to define function pointers. Defines and initializes a function that has no arguments and no return value:
void function1() {
  std::cout << "'function1' was invoked." << std::endl;

int main() {
  void (*func1)() = &function1;

  return 0;
Defines and initializes a function that has argument and return value:
int function2(int value) {
  std::cout << "'function2' was invoked." << std::endl;
  return value;

int main() {
  int (*func2)(int) = &function2;
  int value = func2(10);

  return 0;
Here is example how to pass a function pointer as argument:
Defines an array of functions:
void (*func_array1[3])() = { func1, func1, func1 };
for (int i = 0; i < 3; i++) {
Defines and initializes a function that refers to class member:
class MyClass {
    void myFunction(int value) { 
      std::cout << "MyClass function was invoked: " << value << std::endl;

int main() {
  MyClass mc;
  void (MyClass::*member_func)(int) = &MyClass::myFunction;

  return 0;
Rather than declaring function pointer using the full prototype each time, it is helpful to use a typedef:
  typedef void (MyClass::*FunctionPointer)(int);
  FunctionPointer funcPtr = &MyClass::myFunction;

Thursday, May 24, 2012

Professional ASP.NET MVC 3

One of the last books I read is Professional ASP.NET MVC 3. This book improved my knowledge about ASP.NET MVC3. This in-depth book shows you step by step how to use MVC 3.

Book covers new and updated features such as the new View engine, Razor, NuGet, and much more. The book's practical tutorials reinforce concepts and allow you create real-world applications. Topics include controllers and actions, forms and HTML helpers, Ajax, unit testing, and much more.

Saturday, April 28, 2012

How to increase the hard disk size of the virtual machine

Open a terminal and navigate to the folder with the VirtualBox disk image, then use the following command:
VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB 
replacing YOUR_HARD_DISK and SIZE_IN_MB with your image name and desired size.

My guest OS is Ubuntu. To manage it's partitions I used GParted Live CD.

Wednesday, April 25, 2012


Today my college told me about Arduino. I think it would be interesting to try it when I have some free time. Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. To read more go here.

Thursday, April 19, 2012

The linux sockets

I spend a few evenings reading about linux sockets. I created client and server's applications which use sockets with TCP/IP protocol. Client sends a request to the server and gets a response. I also found an interesting article about linux sockets and networking programming. The article can be found here.

Here is a simple diagram which shows how sockets work:

Here is a header file Channel.h of the channel class which encapsulates socket:

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

namespace lab {
 class Channel {
   int socket_id;
   sockaddr_in socket_address;
   void CreateSocket(const char* ip, int port);
   void Write(int connection_id, const char* message);
   void Read(int connection_id);
   Channel(const char* ip, int port);
   void Listen();
   void Send(const char *message);
   void Close();

Here is a source file Channel.cpp of the Channel class:
#include "Channel.h"
#include <iostream>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

lab::Channel::Channel(const char* ip, int port) {
 this->CreateSocket(ip, port); 

lab::Channel::~Channel() {

void lab::Channel::CreateSocket(const char* ip, int port) {
 // socket() creates an endpoint for communication and returns a descriptor.
 // AF_INET - IPv4 Internet protocols.
 // SOCK_STREAM - Provides sequenced, reliable, two-way, connection-based byte 
 // streams.
 socket_id = socket(AF_INET, SOCK_STREAM, 0);
 if (socket_id == -1) {
  std::cout << "Failed to create socket." << std::endl;
 } else {
  std::cout << "Socket was created successfully." << std::endl;

 socket_address.sin_family = AF_INET;
 socket_address.sin_port = htons(port);
 socket_address.sin_addr.s_addr = inet_addr(ip);
 memset(&(socket_address.sin_zero), 0, 8);
 // bind - bind a name to a socket.
 if (bind(socket_id, (struct sockaddr *)&socket_address, sizeof(struct sockaddr)) != -1) {
  std::cout << "Name was binded successfully to the socket." << std::endl;
 } else {
  std::cout << "Failed to bind a name to the socket." << std::endl;

void lab::Channel::Write(int connection_id, const char* message) {
 if (write(connection_id, message, strlen(message)) != -1) {
  std::cout << "Message was send: " << message << std::endl;
 } else {
  std::cout << "Failed to send a message." << std::endl;

void lab::Channel::Read(int connection_id) {
 char buffer[32];
 memset(buffer, 0, 32);
 if (read(connection_id, buffer, 32) != -1) {
  std::cout << "Message was read: " << buffer << std::endl;
 } else {
  std::cout << "Failed to read a message." << std::endl;

void lab::Channel::Listen() {
 // listen - listen for connections on a socket.
 // The backlog argument defines the maximum length to which the queue of 
 // pending connections for sockfd may grow.
 if (listen(socket_id, 4) != -1) {
  std::cout << "Listening the socket." << std::endl;
 } else {
  std::cout << "Failed to listen the socket." << std::endl;

 // accept - accept a connection on a socket.
 sockaddr_in remote_address;
 int connection_id;
 int remote_address_size = sizeof(remote_address);
 connection_id = accept(socket_id, (sockaddr*)&remote_address, (socklen_t*)&remote_address_size);
 if (connection_id != -1) {
  std::cout << "Connection was accepted." << std::endl;
 } else {
  std::cout << "Failed to accept connection." << std::endl;

 this->Write(connection_id, "Reply");


void lab::Channel::Send(const char *message) {
 // connect - initiate a connection on a socket.
 if (connect(socket_id, (sockaddr*)&socket_address, sizeof(sockaddr)) != -1) {
  std::cout << "Connection was estableshed successfully." << std::endl;
 } else {
  std::cout << "Failed to connect." << std::endl;
 this->Write(socket_id, message);

void lab::Channel::Close() {
Here is a file Client.cpp of the client application:
#include <iostream>
#include "Channel.h"

int main() {
 std::cout << "Client started..." << std::endl;

 lab::Channel *channel = new lab::Channel("", 2590);
 delete channel;

 return 0;
Here is a file Server.cpp of the client application:
#include <iostream>
#include "Channel.h"

int main() {
 std::cout << "Service started..." << std::endl;

 lab::Channel *channel = new lab::Channel("", 2590);
 delete channel;

 return 0;
Also I added makefile which allows to compile source code:
CPP = g++
CFLAGS = -Wall -lrt
CHANNEL_FILES = src/Channel.cpp
SERVICE_FILES = src/Service.cpp
CLIENT_FILES = src/Client.cpp

all: service client

service: channel $(SERVICE_FILES)
 $(CPP) $(CFLAGS) -o bin/service obj/channel.o $(SERVICE_FILES)

client: channel $(CLIENT_FILES)
 $(CPP) $(CFLAGS) -o bin/client obj/channel.o $(CLIENT_FILES)

channel: $(CHANNEL_FILES)
 $(CPP) $(CFlAGS) -o obj/channel.o -c $(CHANNEL_FILES)

 rm -f ./obj/*.o
 rm -f ./bin/service
 rm -f ./bin/client



Wednesday, April 18, 2012

Forking vs Threading

I found interesting article about forking and threading in Linux. In this article you can discover advantages and disadvantages of forking and threading. This article you can find here.

Sunday, April 15, 2012

Applications = Code + Markup: A Guide to the Microsoft Windows Presentation Foundation

When .NET 3.0 was released I decided to learn WPF and XAML. I read the book Applications = Code + Markup: A Guide to the Microsoft Windows Presentation Foundation by Charles Petzold. Later this book was useful when I was learning Silverlight wich is similar to WPF.

In this book I discovered:
  • Create and enhance controls including menus, toolbars, tree views, and list views
  • Use dynamic layout to automate the positioning of controls and graphics
  • Work with dependency properties and routed input events
  • Use XAML resources, styles, and templates to alter the appearance of your UI
  • Use data binding techniques in XAML to help simplify and streamline your applications
  • Develop visually-stunning UIs with interactive graphics, media, and animation

Tuesday, April 10, 2012

JavaScript Patterns

One of the last books I read is JavaScript Patterns written by Stoyan Stefanov. This book improved my knowledge about Javascript.

This book is dedicated to experienced developer which are looking how to solve problems related to objects, functions and inheritance.

  • Explore useful habits for writing high-quality JavaScript code, such as avoiding globals, using single var declarations, and more
  • Learn why literal notation patterns are simpler alternatives to constructor functions
  • Discover different ways to define a function in JavaScript
  • Create objects that go beyond the basic patterns of using object literals and constructor functions
  • Learn the options available for code reuse and inheritance in JavaScript
  • Study sample JavaScript approaches to common design patterns such as Singleton, Factory, Decorator, and more
  • Examine patterns that apply specifically to the client-side browser environment

Tuesday, April 3, 2012

C++ first program

A few days ago I thought it would be good to renew my knowledge about C++. I decided to create simple application and compile it on Linux and Windows. Here is application source code:
#include <iostream>

int main() {
 std::cout << "My first program..." << std::endl;
 return 0;


I created makefile which allows to compile and run application. To read more about how to create makefile you can read here.

CPP = g++
CFLAGS = -Wall -lrt

all: program
 $(CPP) $(CFLAGS) -o bin/program obj/program.o

 $(CPP) $(CFLAGS) -o obj/program.o -c src/program.cpp

 rm -f ./obj/*.o
 rm -f ./bin/program

To compile application just type make:
If you want to run application, type such command:
make run

To compile application on Linux I used GNU C++ compiler (g++). The -Wall command line option enables all warnings. If you want to get more information about compiler read here.


I created .mak file which allows to compile and run application. To read more about how to create .mak file and use NMAKE utility you can read here.

CPP = cl
CFLAGS = /EHsc /W4

all: program
 $(CPP) $(CFLAGS) /Febin/program.exe  obj/program.obj

 $(CPP) $(CFLAGS) /c src/program.cpp /Foobj/

 del bin\*.exe obj\*.obj

To compile application on Windows I used Microsoft C/C++ compiler (cl). The /EHsc command line option instructs the compiler to enable C++ exception handling. The /c command line option instructs the compiler to compile without linking. The /W command line option sets warning level. If you want to get more information about compiler read here.
To compile application, type such command:
nmake -f build.mak
To run application, type such command:
nmake -f build.mak run

Wednesday, March 28, 2012

Kanban boards

I found useful document in which Mattias Skari visualized a set of kanban boards from operations, development and sales to trigger ideas. It helped to create our own board which is used in my team for scrumming.

Those boards you can find here.

Tuesday, March 27, 2012

Let's Scrum

At work me and my colleague have started using Scrum. If this methodology is useful we will find out later.

Book Scrum and XP from the Trenches helped as to start Scumming. This book includes practical tips and tricks for most Scrum and XP practices. It can be downloaded for free from InfoQ website.


I have started to use VsVim Visual Studio 2010 extension. It's vim emulation layer for Visual Studio 2010. VsVim is free and can be downloaded from here.