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 ~
get http://phantomjs.googlecode.com/files/phantomjs-1.7.0-linux-i686.tar.bz2
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 http://www.raspberrypi.org 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 <firstname.lastname@mail.com>",
  "keywords": ["my_keyword1", "my_keyword2"], 
  "repository": {
    "type": "git",
    "url": "https://github.com/myuser/my_package.git"
  },
  "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://github.com/joyent/node.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
Output:
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.

Features:
  • 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/prog.cc
Once the program is compiled for profiling, you must run it in order to generate the information that gprof needs.
./bin/prog
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.