All about programming in GNU/LINUX


Parallelism Is Not Concurrency

Existential Type

In an earlier post I mentioned that one goal of the new introductory curriculum at Carnegie Mellon is to teach parallelism as the general case of computing, rather than an esoteric, specialized subject for advanced students.  Many people are incredulous when I tell them this, because it immediately conjures in their mind the myriad complexities of concurrency: locks, monitors, deadlock, dining philosophers, ….  And if you look at the recent research literature, you will see countless papers of the form (a) parallelism is important, so (b) let’s talk about concurrency.  The situation has gotten so bad that I think that most computer scientists cannot distinguish the two concepts.  (Or maybe they willfully confuse the two so as to justify funding for work on concurrency by appealing to the importance of parallelism.)

Given this state of affairs, I cannot explain what we are doing at Carnegie Mellon (to anyone who doesn’t…

View original post 1,830 more words

Cracking the Source: UnderStanding NodeJs Source Code -1

………!!!!…………!!!!!!!!……..!!!!!! Its time for some extreme engineering 😛
Welcome to the series Cracking source ..
This is the first post in the series of posts to come about understanding the source code of Node.JS .  Its been enough time since i’ve been using Node as the webserver for all my projects and its time to understand the source and making an attempt to contribute to its repo ! This blog cannot be considered as a step by step tutorials on understand the source of NodeJs , this is the place where i share my learning , experience and views in the course of journey in understanding the source code of NodeJS.

I stumbled upon this pull request on my mobile screen while i was travelling back home few days ago . The request on the this file called tls.js  from the lib folder of the nodejs source tree . This is how the i started exploring tls.js from the source

The tls module uses OpenSSL (uses the underlying OpenSSL executable installed on your system) to provide Transport Layer Security and/or Secure Socket Layer: encrypted stream communication.

So this post is about tls.js and how it works .

Here is the documentation of the TLS api  . Lets get into details of the API tls.getCiphers()

Here is the code of the API tls.getCiphers() from its source

exports.getCiphers = function() {
  var names = process.binding('crypto').getSSLCiphers();
  // Drop all-caps names in favor of their lowercase aliases,
  var ctx = {};
  names.forEach(function(name) {
    if (/^[0-9A-Z\-]+$/.test(name))
        name = name.toLowerCase();
    ctx[name] = true;
  return Object.getOwnPropertyNames(ctx).sort();

process.binding() is a Javascript interface for the C++ core of Node . So process.binding(‘crypto’).getSSLCiphers will result in execution of corresponding function from the c++ core of Node , here is the link to source of getSSLCiphers() from the c++ core We shall get into the C++ core in the further posts to come .
The C++ core returns an array contains all Cipher names .
Later the array of names are iterated using forEach() method of node . Each names are tested against the Regular Expression /^[0-9A-Z\-] ,Any string that begins/ends and containing digits (0-9) and alphabets in caps (A-Z) and another character ‘-‘ are matched and set as keys in the ctx{} object . And at the end the keys of the object ctx containing the names of the Cipher are returned as an array in sorted order using the following line of code

return Object.getOwnPropertyNames(ctx).sort();

Lets use this API from the tls library , and here is the code

var tls = require('tls');
var cipher = tls.getCiphers();

Lets get into the C++ core in the posts to come in future , but thats it for now .Wait for more exciting posts to come in my journey through source of Node .
Till then happy Coding 😀

Intro to AngularJS and Client Server communication using nodeJS and AngularJS:Posting data to the Node-Express server using AngularJS

Hmmmm , its time for a new post !!! After the last post on Depth First Search in python , now you have a U-turn ahead and this post is on achieving client server communication using NodeJS server in the backend and AngularJS in the front end  !!!

If your curious on achieving client-server communication using backbone.JS and nodeJS , here is the link
In case you try the same using websockets and nodeJS , here is the link for the post .

And here is the github link for the codes posted in this blog !

Lets get started with how to achieve it using Angular and NodeJS as server .This might be a very simple task for a AngularJS developer ,but the blogs are not always meant for experts 😛  Since the blog is aimed at web developers who are starting to develop web applications by using NodeJs in the backend and AngularJS in the front end , ill try to keep the post as simple and easy as possible .

So , Lets get started ……….

Before we begin here are the basics of AngularJS ,

  • AngularJS provides a set of html attributes which starts with ng , example ng-app,ng-controller,ng-view,ng-click , these attributes are used to direct and communicate with angularJS .
  • ng-app attribute tells angularJS to bootstrap or start the application , usually this is associated with the html tag of the application , example 
<html ng-app>
         <script src=""></script>

 controllers in AngularJS

  • Using controllers you can tell AngularJS ,which of javascript variables or primitives forms the Models data which will be used the views
  • Angular by default passes this object called $scope for every Angular controller
  • By assigning the data to this $scope object you’ll
    be telling angular that the assigned data are those which are supposed to be the used by views to render HTML , this is the model data

To brief , the controllers in angularJS have three responsibilities
1.Initializing the model variables
2.Give views the access to the models data by assigning them to the $scope variable
3.It provides the code and logic to execute while users interact with the various parts of the controllers

$http is another directive passed onto a controller and can be made use of to interact with server (make GET,POST requests etc…) , we’ll be using same directive in this post to interact with the server

One of the amazing feature of Angular which makes application development really easy is the ability of Angular’s controller to bind the data of an HTML element (like a input box , text box or any widget) with the models data and it also provides event handlers/methods to propagate the changes to the model data automatically  

Here is an simple example of how controller binds the data and the views , a angular controller is binded to the application by using ng-controller attribute  within a html element , the controller will be incharge of the application within the scope of that html tag,the explanation is given after the code example  

<html ng-app>
    <script src=""></script>
      <div ng-controller="firstController">
      <!--firstController is the name of the controller function, its scope expands within this div element -->
        <input ng-model="modelData" >

         function firstController($scope){ //controller function
 /*This is the same variable which is used in html,now the value is variable is binded the input box data*/
             console.log("New: "+newVal);/*Watch the browser console*/
           /*$scope.$watch listens to the changes in the modelData variable ,
             The value in the modelData variable is changed when the value in the input box is changed ,
             these are automatically bound together  using <input ng-model="modelData" > */

ng-model=”modelData”, This is like a global declaration of the variable ‘modelData’ within the controllers scope(within div element in this case) without the need to declare it anywhere .This variable now can be accessed as model data inside the html to render by using it inside the double braces {{}}, this is how you can bind the data with the views . Now lets say you have some application logic to be performed using this data , so you need to be able to access the variable within the Javascript too , the variable `modelData` can be accessed only within the controller function (inside your javascript) which is incharge the current html scope , in this case the data is accessible through the firstController() , controller function (since this is the controller function for the input elements scope,that is, the input element inside the scope of the div with ng-controller=”firstController”).Now as i had already mentioned the model’s data can be accessed using the $scope object which is passed onto the controller,so this can be accessed using $scope.modelData inside the controller function of the Javscript
ng-model=”modelData suggests that the $scope.modelData is the controller variable with which this view is associated,and this is how angular easily brings in binding of the views and data with the help of the controller.
Now lets say you have used {{modelData}} at ten different places in your html to render the view , the change to the modelData is automatically propagated to all thee places in views so that the html with new data is rendered
Here is the screenshot on with the browsers console opened

Angular MVC

Angular MVC

Phew!!!!! 😯 Lets now start with the headline of the post …How to communicate to the server from angular ,and how to handle it using NodeJs-express server
Here is the code snippet ang2.html of where angular makes a POST request to the server when user clicks the submit ,

<html ng-app>
    <form ng-controller='appController' ng-submit="send()">
      <!--send() function from the controller is called on form submission -->
        <textarea ng-model='data.textdata'></textarea>
        <input type="submit" ngClick="Submit">

    <script src="">
        function appController($scope, $http) {
            /*$http directive is used to communicate ot the server */
            $ = {}
            $scope.response = {}

            $scope.send = function () {
                /*executed when submit is clicked*/
                console.log("inside click");

                var posting = $http({
                    method: 'POST',
                    /*posting to /post */
                    url: '/post',
                    data: $,

                    processData: false
                posting.success(function (response) {
                    /*executed when server responds back*/
                    $ = response;


Here is the server code app.js using node.js-express to handle the POST request from the AngularJS frontend script and respond back to it .

var express = require('express')
, http = require('http'), path = require('path');

var app = express();

app.use(express.static(path.join(__dirname, 'public')));
/*JS client side files has to be placed under a folder by name 'public' */
/*to access the posted data from client using request body*/'/post', function (req, res) {
    /* Handling the AngularJS post request*/
    res.setHeader('Content-Type', 'application/json');
    /*response has to be in the form of a JSON*/
    req.body.serverMessage = "NodeJS replying to angular"
        /*adding a new field to send it to the angular Client */
    /*Sending the respone back to the angular Client */

http.createServer(app).listen(3000, function () {
    console.log("Express server listening on port 3000");

Create a folder called public and place ang2.html inside it
, Here is the link for the codes published in this post

Here are the screenshots from server and client side ,

Angular posting data

Angular posting data

server handling client angularJS request

server handling client angularJS request

fianlly !!!!!!!!!!!!!!!!thats the end of this post , i hope you guys found this post to be helpful in understanding how to use AngularJS to communicate to the server , will catch up soon with further exciting posts , till then Happy coding 😀

Obtaining user logs! (Task 1)

Good post!

Karthik Srivatsa

Out of a lot of options that we had, we opted for OpenCart ( ) for our front end e-commerce solution. So the first step was to download and configure open cart over a locally running LAMP server. The steps for setting up the OpenCart site on your Apache server can be found here : ” ” .




Apache provides a mod_usertrack ( “ ” ) module for logging the user activity by using cookies and generates a ‘clickstream’ log. An enhanced version of the same module can be found here by the name mod_cookietrack : ” ” . This module requires apache-dev to be installed and perl. After that you install it using the command ‘sudo ./’.


NOTE : If you have errors saying that apxs file is not found in /usr/sbin/apxs try to look for it in the folder /usr/bin/apxs and…

View original post 465 more words

2013 in review of the blog

The stats helper monkeys prepared a 2013 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 11,000 times in 2013. If it were a concert at Sydney Opera House, it would take about 4 sold-out performances for that many people to see it.

Click here to see the complete report.

Simple CSS3 Transformations – transitions , translations and rotation

 W3C consortium was setup to standardize different browser interpreted languages , but different browser vendors wanted to provide support for experimental css3 features till they are standardized by W3C , such experimental and browser specific css3 features are to used with the prefix provided the vendor , -webkit-(chrome and safari),-o-(opera),-moz-(firefox),-ms-(IE), in the following code snippet i’ve just used -webkit- prefixes , so the code just works in Google chrome browser , to make it work in other browsers , just repeat the attributes with the vendor specific prefixes 


<!DOCTYPE html>
<title>First Transform </title>
h1 {
text-align : center ;
font-family : Futura ;

h1:hover {

-webkit-transition :6s all steps(6,end);
-webkit-transform : translateX(600px);
/* the header (h1 ) moves on X-axis (translates) 600px to the right , but the transition(webkit-transition) effect in place
makes sure that this transition takes place over a time of 6 seconds and 6 steps on mouse hover */
img.tilt:hover {
-webkit-transform : rotate(9.0deg); /*Rotates the image by 9 degrees on mouse hover and transition makes the effect take place smoothly over a period of 5 seconds */
-webkit-transition : 5s all;
<h1>CSS3 Testing</h1>
<p><img src = “deb.jpg” style= “width:300px;height:200px; margin: 0 2em 2em 0;”class=”tilt” >Hi , this is Debian , Debian is a free Operating system , the kernel used by debian is the kernel written Linux torwals .Debian is a free and universal operating system where everything , i repeat , everything in the operating system is free , the source for every binary in DEBIAN is available, All the softwares for debian comes packaged in .deb(.debian) files where these are hosted in their official repositories </p>


Writing A Simple WebServer using NODEJS

Well , we should consider ourselves lucky to be in this age of computing where a programmers job is made very easy with usage of modern languages . Writing a Web Server using C was and is a herculian task . With issues like limited buffer size , spawing threads or new processes to cater new clients and bulky system calls with complex structures to pass as parameters everthing has to be explicitly managed . One of the easiest way which i’ve found out to write webservers is by using NODEJS . Concurrency handling mechanisms are taken care of implicitly and programming becomes easy since Java Script is used .Here is a simple webserver written using NODEJS

var http=require('http'),
	url = require('url'),
	mime = require('mime'),//npm install mime
	fs = require('fs'),
http.createServer(function(req,res) { 
	 pathname = search_path + req.url;

	fs.stat(pathname , function(err,stats){
	  if(err) { 
		res.write('Bad Request , Request cannot be accepted');
	else if(stats.isFile()) {
		var type = mime.lookup(pathname);

		// 200 status - found , no errors 
		res.statusCode = 200;
		//create a readable stream and pipe to the http response 
		var file = fs.createReadStream(pathname);
		file.on("open",function() { 
		file.on("error",function(err) {
	else {
		res.write('Cannot Access Directory');
}).listen(8324);//listen to port 8324
console.log('Server running at 8324');