Programming and writing about it.

echo $RANDOM

Moved to GitHub pages

Hi all, my domain name now points to my GitHub pages site. If you are a subscriber to my blog, please consider updating your feeds.

Atom feed:

In more exciting news, my new book “Doing Math with Python” is out!

Doing Math with Python: Chapters 5 and 6 in early access

I am excited to share that the fifth and sixth chapters are available as part of the early access of my book Doing Math with Python.


Chapter 5: Sets and Probability

This chapter starts off with how to create a set and demonstrating the common set operations. Utility of the different set operations are demonstrated via simple applications. For example, Cartesian product is used to write a program to simulate an experiment to calculate the time period of a simple pendulum of different lengths and at places with varying gravity. Union and intersection operations are applied to finding the probability of events.

The chapter then moves onto discussing how to generate uniform and non uniform random numbers, and using them to simulate scenarios such as a die roll and a fictional ATM which dispenses dollar bills of different denominations with varying probability.

One of the challenges at the end discusses drawing venn diagrams.

Chapter 6: Drawing shapes and Fractals

This chapter is logically divided into two parts. The first part introduces the reader to matplotlib patches which allows drawing geometric shapes (circles and polygons), followed by matplotlib’s animation API which allows drawing animated figures. The trajectory of a projectile motion discussed elsewhere in various contexts is animated combining both these things.

The second part of the book introduces the concept of geometric transformation. Combining that with the knowledge of generating random numbers learned earlier in Chapter 5, the reader will learn how to draw fractals such as the Barnsley Fern.

The challenges at the end gives the opportunity for the reader to explore the Sierpinski triangle and Henon’s function.

Trying out the programs

Using the Anaconda distribution (Python 3) should be the easiest way to try out all the programs in the book. You will need matplotlib, sympy 0.7.6 and matplotlib_venn to try out the programs. An installation guide will be available online soon.

Stay updated

I am working on the last chapter for the book. You can stay updated on the book via various channels:

Blog posts:

Facebook page:

G+ Community:


If you are interested in taking a look at a sample copy, I can try to get a sample for you to look at the current pre-released version of the book. Please feel free to get in touch.

Doing Math with Python: Stay Updated

I am reaching the final stages of my new book. Here are few ways to stay updated about the book:


Blog posts:

Facebook page:

G+ Community:


If you are an educator/teacher, I can also try to get a sample for you to look at the current pre-released version of the book.

Fedora 22 Scientific Alpha

Just tested the Fedora 22 Scientific Alpha RC3 image today with the test scripts/programs. Some screen shots follow:

IPython notebook


IPython notebook/SymPy/matplotlib plotting




A complete list of all the software included is in the guide.

Contribute to Fedora Scientific

  • Use it!
  • You can  help complete the guide. One notable piece of software missing from that list is “pandas”.
  • You can add examples/scripts/IPython notebooks to the repository here

Doing Math with Python: Two more chapters in Early Access

I am excited to share that the third and fourth chapters are available as part of the early access of my book Doing Math with Python.


Chapter 3: Describing Data with Statistics

As the title suggests, this chapter is all about the statistical measures one would first learn in high school – mean, median, mode, frequency table, range, variance, standard deviation and linear correlation are discussed.

Chapter 4: Algebra and Symbolic Math with SymPy

The first three chapters are all about number crunching. The fourth chapter introduces the reader to the basics of manipulating symbolic expressions using SymPy. Factorizing algebraic expressions, solving equations, plotting from symbolic expressions are some of the topics discussed in this chapter.

Trying out the programs

Using the Anaconda distribution (Python 3) should be the easiest way to try out all the programs in the book.

LCA 2015 talk: Beaker’s Hardware Inventory system

The video is up on YouTube:


Since I could not make it to LCA, Nick Coghlan presented the talk on my behalf. Thanks Nick!

A docker based workflow for working on beaker

While working with beaker‘s code base, I often feel the need to run my tests for a patch/feature and continue to work on with different things while they run, including running other tests testing something different. Currently this is not possible since we start off with a clean database on every test run and simultaneous runs would obviously make one run step on another’s feet.

I finally have an initial docker based prototype for making this possible.

Announcing early access for “Doing Math with Python”

Early Access promotion:

No Starch Press is running a promotion tomorrow (29/01/2015 – PST)  that will offer 40% off all Early Access titles on, including Doing Math with Python. The discount code is BRIGHTANDEARLY. Currently two chapters are available and more should be up in the coming days!

I am excited to write that my new book “Doing Math with Python” to be published by No Starch Press is now available via their “Early Access” program – which means if you now buy the book, you will get the chapters as and when they are available and also, the chapters may need more polishing.


The book uses Python 3 exclusively and the Appendix A covers setup and installation instructions for Python 3 and the libraries used in the book. However, that is not yet available. Hence, at this stage, the easiest way would be to use a distribution such as Anaconda on Windows, Linux or Mac OSX (untested, I don’t have access to the OS).

Book Review: Linux System Programming

I received a review copy of the book as part of the blogger review program.

I review for the O'Reilly Blogger Review Program

Title:  “Linux System Programming (2nd Edition) ” by Robert Love; O’Reilly Media.


This book consists of 11 chapters. The first chapter introduces you nicely to the the core topics and lays the foundation for the rest of the book. Files (including some hints on the role of the virtual file system and how they are represented in the Kernel), Input/Output (User buffered I/O, I/O scheduling, Scatter-Gather I/O), Processes (including their creation mechanisms and management), Threads (and how Linux implements them along with a treatment of the POSIX threads library), Memory (Process address space, dynamic memory allocation strategies, and how they work, memory locking) form the core of the book. The second last chapter discusses signal handling. The last chapter of the book is on time (the different types of time, how you can get/set time, measure time elapsed and timers) and is sort of a “standalone” topic for the book. The first appendix discusses the GCC extensions to the C language and can be handy when you read the Kernel source code.


In this book, the author discusses some of the most important topics that one would want to learn about when venturing into the area of “system programming” on Linux. He introduces the topics in a friendly manner adding some fun anecdotes from time to time (what does the “c” in calloc() stand for?).At various places, the reader is given a peek under the hood (for example, pause() is one of the simplest system calls implemented) which can only make the curious reader happy and itchy to download the kernel source code and start grepping. The book includes code examples throughout and hence if you are learning a topic for the first time, these are very useful starting points.


System programming on Linux is an area encompassing number of related topics most of which can fill up whole books on their own. I also could not help comparing this book with “The Linux Programming Interface” by Michael Kerrisk (a book which I own already). Should you buy this book if you already own the latter? Yes, you should. While not being “encyclopedic” and not covering topics such as socket programming at all, Robert Love’s “Linux System Programming” has the right level of treatment and detail for the reader interested in system programming.

Product page:

Fedora 20 Scientific Released

Fedora 20 is now released, which also means the newest release of Fedora Scientific along with other spins are also available.


You can download the spin images from here.

What’s new in Fedora Scientific

The notable additions in this release are:

  • Sage, along with Sage notebook.
  • SymPy, the Python library for Symbolic mathematics
  • The Python 3 versions for scipy, numpy, matplotlib libraries and IPython (including IPython notebook)
  • Commons math, a Java library for numerical computing

The Fedora 20 release notes are here.

Fedora Scientific Documentation

I started work on some documentation for Fedora Scientific about a month or so back. It is far from what I want it to be, but you can see the current version here. The first goal that I have in mind is to document all the major scientific tools and libraries that are shipped with Fedora Scientific. By document, I imply links to the official project resources and guides. The second goal is to actually add original content and make it a guide book for Fedora Scientific which may be used as an entry point for Open Source Scientific Computing. Once the guide has taken some shape, an RPM package can be created and distributed with Fedora Scientific so that the entire documentation is available for offline perusal.


The Fedora Scientific documentation is an excellent starting point if you are looking to make a contribution to Fedora Scientific. You can view the project here.

If you have some toy/throwaway scripts that makes use of one of the libraries/tools, you may want to contribute it to the
“tests” here. They will help sanity check these libraries and tools during the development of upcoming Fedora Scientific releases.

Discussions and support

Please join the Fedora scitech mailing list.

Suggetions and ideas? Please leave a comment.