C Language Constructors and Destructors with GCC

Constructors and Destructors are special functions. These are one of the features provided by an Object Oriented Programming language. Constructors and Destructors are defined inside an object class. When an object is instantiated, ie. defined of or dynamically allocated of that class type, the Constructor function of that class is executed automatically. There might be many constructors of which the correct implementation is automatically selected by the compiler. When this object is destroyed or deallocated, the Destructor function is automatically executed. For example when the scope of the object has finished or the object was dynamically allocated and now being freed. The Constructors and the Destructors are generally contains initialization and cleanup codes respectively required by an object to operate correctly. Because these functions are automatically invoked by the compiler therefore the programmer freed from the headache of calling them manually.

Continue reading

Posted in C Language, Computer Science | Tagged , , | 5 Comments

WordPress.com Stats API

gimp_logoWordPress.com has a very nice stat plugin showing the overall post views data and also post by post, but it would be always great if there was more. A lot of people talk about introducing Google Analytics. A lot of people save the data offline by copying the summary tables into files to save the site data. I had an idea to process the data of my site a bit differently and find trends in the data. I thought except copy-pasting the site summary data, there should be a cleaner manner to store the data. First I made a brief Google search, then made a wordpress.com forums thread. Then i had a short chat with Mark in wordpress.com freenode IRC and was redirected to wp.com email support. The first result came from email support telling that there is no data export feature. But another email followed to correct the previous one which told about the wordpress.com stats API with which you can get your wordpress.com site’s stats data in CSV or XML format.
Continue reading

Posted in GNU+Linux+FOSS, Tutorials | Tagged , , | 12 Comments

Bash Script: Counting lines, words, characters

Objective

The objective is to write a shell script to mimic the functions of the wc command. This shell script would be made with bash built-ins and standard coreutils commands, and is made as accurate as possible to mimic wc.
Continue reading

Posted in Computer Science, Linux / Unix Shell | Tagged , , | 5 Comments

Cricket World Cup 2011

Cricket World Cup 2011 Logo I was keeping myself updated and was watching portions of the matches casually but I started watching the matches seriously from the semi-finals. The Ind v Pak match was a fine one (although the next day was one final examination). India-Pakistan matches have always been high-voltage matches. After defeating Pakistan I was feeling like it was the 2003 world cup, India again in the finals. 2003 final match was a painful memory, India was loosing from the very first moment. But in 2011 things have changed Australia is eliminated, and India is the one to do this cleaning job.

Continue reading

Posted in Writings | 4 Comments

Bash Script : Bitwise Not Operation in bash

This is a post to present one method to inverse the bit pattern of an input number, the bitwise not operation on a bit pattern. I am presenting one method which i figured out.
Continue reading

Posted in Computer Science, Linux / Unix Shell | Tagged , , | Leave a comment

Simpson’s 1/3rd Rule

A brief introduction to the Simpson’s 1/3rd rule and a uniform interval Composite Simpson’s 1/3rd Rule implementation.
Continue reading

Posted in Coding Discussions, Computer Science | Tagged , , | 1 Comment

Bash Script: Generating Primes within Range

Objective

Generating prime numbers within a range using bash script. The technique used in this implementation to generate the prime numbers is still the good old divide and check method, but with some tweaks attempting to make the execution a bit better.

Approach

The core method is, we check if an integer p is prime by:

  1. Dividing with integers which are not multiples of 2′s and 3′s
  2. Dividing with integers upto floor ( sqrt ( p ) )

The integer p itself is needed to be not divisible by 2 or 3 or both.
Read more to get the bash script

Posted in Computer Science, Linux / Unix Shell | Tagged , , | Leave a comment