31 December 2017

"Learning Python by Mark Lutz" - Reading Journal 2 [Chapter 2 and Chapter 3]

Learning Python by Mark Lutz Fifth Edition
Learning Python by Mark Lutz
Like me, if you are new to Python and want to ramp-up to become no non-sense developer in Python, you might want to read these posts (and if you are prepared to take up the tough path of mastering the language). The post like this is my experience - the journey that is little longer but interesting, thought-provoking and rewarding. 

For next few months, I would be posting my experiences with Python more specifically the learning I am going through from the book - "Learning Python by Mark Lutz". You can find all of my reading journal of this book and accompanying code in GitHub

The rest of this post covers what I learned in Chapter 2 and Chapter 3.

Chapter 2: How Python Runs Programs
This chapter introduces you a needed theoretical overview of Python runtime (interpreter) and Python bytecode. The execution of the program is explained in two viewpoints - programmer's view and Python's view. The programmers' view is what code to be written following the language constructs generating source code and Python's view is how to execute the program converting source code to actual functionality (the output of programmer view is input to Python's view). The chapter offers execution model variations (different runtime models - CPython, Jython, Stackless, PyPy) and optimization tools (Psyco JIT, Shed Skin, Cthyon). This chapter is wonderfully written and there will be some learning to everyone. I thoroughly enjoyed the content :-). Kudos to the author for covering a variety of insights.

Chapter 3: How You Run Programs
I need to start with a warning. This chapter has so much information and ways to run your code like "from the command line", "interactive", "IDLE" and "IDE". I personally suggest that we should try all the methods at least once and choose one of the methods. I find IDE convenient. Yes, I do use PyCharm community edition. On the good side, the chapter introduces modules, importing, namespaces, module reloads which is quite interesting. Good round up of exercises at the end. I do not want to bog you down with a lot of details. One little advice I have for you is to take breaks while reading this chapter and be prepared for a long haul. Without the break, I feel this chapter is little tough to complete and might appear daunting (and might be demotivating to complete). The good thing about such details are completeness

BTW, with this, we complete the first part of the book and we have eight more parts.

Looking forward to the Part 2

All posts related to "Learning Python by Mark Lutz"
Source Code@GitHub (exercises of this book)

Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)

30 December 2017

"Learning Python by Mark Lutz" - Reading Journal 1 [Intro and Chapter 1]

Like me, if you are new to Python and want to ramp-up to become no non-sense developer in Python, you might want to read these posts. The post like this is my experience - the journey that is little longer but interesting, thought-provoking and rewarding.

For next several months, I would be posting my experiences with Python more specifically the learning I am going to have from the book - "Learning Python by Mark Lutz". My first impression after reading the table of contents is very promising. It looks to me that it is one of the books that provide complete coverage of Python and exhaustive too. I am eager and yet at the same time little afraid because I never learned any programming language reading a book completely. Since it is massive in size containing 1500+ pages, I feel it is going to test my consistency. And that is one of the reasons why I want to write my reading journal.

The rest of the post contains what I learned from the chapter 1 (Initially I thought I would write journal of first three chapters. But I could not do it due to merits and the amount of content in this chapter)

Chapter 1: A Python Q & A Session
The book starts with a bang providing enough material and motivation as to why someone should invest time learning Python and reading/working-out this book. This chapter provides an introduction to Python in the form of question and answer. These are kind of questions that were eating my mind and wanting an answer because the websites or courses talk only on the language but this book seems to address the gap as to "why". I also feel that the author has set up an important tone - question everything when you learn. You will find answers to the following questions
  1. Why people use Python?
  2. Is Python scripting language?
  3. Is there any downside of Python?
  4. Who uses Python?
  5. What can I do with Python
  6. How is Python developed and supported?
  7. What are its technical strengths?
  8. How Python stacks up to other languages?
This chapter gives deeper insights with solid reasonings and you will understand what you will get by learning Python and what is the amount of knowledge that you will get by reading this book - "Learning Python by Mark Lutz"

Needless to say, I am all excited to continue to learn Python :-)

29 December 2017

Simple ProcMon - Putting all things together

I have written few posts on process management in Python - fork, exec, wait, and exit. These are exactly same Python APIs around system APIs provided by Linux/Unix/POSIX. In this post, I am going to talk about putting things together and create a simple process monitor.

Read how to fork, exec, wait and exit before proceeding with this post.

Functionality of Simple Process Monitor
  1. Have the list of processes that need to be monitored in the INI file. Let us call this configuration
  2. Load the configuration file
  3. Start the process
  4. Exec the new program
  5. Loop #3 and #4 until all the processes are loaded
  6. Monitor the process (wait). A simple call to "wait" would listen for a child to exit.
  7. When a child dies, handle it either by restarting the process again or do nothing (depending on how it is configured).
  8. Go back to #6 and continue the monitoring
It is going to tough to post all the code here. Refer my GITHub for the code. Feel free to extend or write tests

Experience: It is another personal experience on higher productivity claim of Python. I wrote the code in a couple of hours and spent around 2 hours on refactoring. Given my (lack of) experience in Python, Python seems to fulfill its promise.

28 December 2017

Blogger, Feedburner Email Subscription Popup Widget

After a very long time, I got a chance to write some Javascript, jQuery, and some HTML stuff. I thought of updating my blog with a new subscription pop-up. The goal is to show a pop-up enabling the user to subscribe to my blog through email. While I have them already in a couple of places, I felt a pop-up at the center of the screen would help - to get some attention and action. Let us see how it goes.

I am sharing the code here. Feel free to use it if you are searching for something like this (but give the credits by not removing Widget by Lakshmi N).

Now coming to the widget. The following are the functionalities
  1. Display a pop-up with an option to subscribe or close the widget
  2. Integrate the pop-up with my feed provider (which is Google's Feedburner) so that I do not need to manage the subscriptions. It comes with a lot of security and  I can move to a different provider if there is a need.
  3. Make it less annoying. Use cookies and do not display the pop-up for another N days (by setting the expiry for cookie).
While I foresee some changes on the look and feel - but the core features are almost there. I have also committed the changes to GitHub.  There are few customizations that you might need depending on your requirements and taste. Here is how I have implemented
  1. HTML/CSS: If you turn on developer tools in your browser, you should see that the entire pop-up is written using HTML, CSS, and Javascript. I have used absolute positioning of the widget so that it shows up in the middle of the browser window. 
  2. Images: There are two images that I have used - one for the background for the pop-up and the close button. You can customize these too for your requirements in case if you need better images
  3. Display Timeout: Configure timeout duration after which you want the pop-up to be displayed. The display of the pop-up will be delayed for such duration after document.ready(). This should be lesser duration.
  4. Cookie Expiry Timeout: This is the duration after which the popup will again appear. This can be any precision (it can be from milliseconds to year). In order for this logic to kick-in, the user should have clicked "close". Ideally, this should be longer duration.
  5. JQuery: I have used JQuery, so ensure that you load jQuery in section and add/update document.ready(). I have used one already on my blog from Google CDN.
  6. Other Platforms: I have tested this on my blog (blogger) and not tested on other blogging platforms. But I believe it should work. Give it a try :-)
  7. Questions: If you have any questions or the stuff is not working, use the comments section to reach out to me. I try my best to support.
Here is my gist (If you remove the credits, it is mere copying and if you give credits it will be termed as normal usage. Be happy that I do not ask for money or bitcoins :-)).

27 December 2017

Want to GIT?

The entire programming world is moving towards using GIT as it is becoming a de-facto. If you have few hours during the holidays and want to learn how to work with GIT (or how GIT works), do not miss this course from Udacity. The course instructor has done a good job of putting together a nice course with a lot of materials and exercises (you can complete the course in two days budgeting some breaks for reflection)

Udacity Course Link - Version Control with Git

Points to be noted:
Note 1: You will learn only git (not GIT Hub or something that uses git to host your code). Nevertheless, this should be the first step before embarking further. GIT Hub (or something similar) should be logical next step
Note 2: Highly recommend for students who are still in college (writing code is good thing, writing tests for the code is better thing, managing your code is the best thing)
Note 3: Very highly recommend for professionals who have not explored GIT yet (learn now or will be made to learn it in 2018).
Note 4: Many text editors (like Atom) and IDEs (like PyCharm) support GIT/GIT Hub (super easy)
Note 5 (good that you have read thus far): Refer https://git-scm.com and learn why you should be learning GIT if you are a developer

26 December 2017

Paradox of Choices

Less is more and more is less


I often undergo this once in a year when I try to change my phone. For past few years, I have been using smartphones (Android) but buying them is a strenuous exercise. It heavily taxes me. In fact, i take approximately about a month to decide whether to buy a phone and another month thinking what phone/brand to buy. Given the rate at which that I change the phone for past few years, it makes sense to shortlist two or three phones and pick the right one. It is especially more tedious when you want to buy things online (because the website throws options at you that you can compare)

Aren't choices good? The answer is "yes" and "no". The choices are good as long as we are able to decide and they are bad when we hit the decision paralysis (making choices).

Certainly, the choices beyond certain point overwhelm us. Our brain thinks that it is analyzing the choices but fails to understand that the choices deceive us. The brain gets tired and as a result, we end up making not so good choices (bad) or do not take decisions at all (worse).

If you are from India and had taken your wife to get a saree, you would have experienced this. The female is known to make wise decisions when it comes to life but often indecisive to select a saree (so the number of choices is the culprit)

So, it is true if someone says "less is more" (when the choice is less, you act on those choices very quickly).

Tidbits - https://en.wikipedia.org/wiki/The_Paradox_of_Choice

25 December 2017

Process Management in Python - os._exit()

This is a continuation of series of posts on Process management in Python. Read thisthis and this before continuing further. In this post, we are going to see how os._exit works and how it is related to "wait".

os._exit when invoked, the process that is calling it terminates immediately without doing any clean-ups (however system.exit() can be handled by the Python program, a much safer/clean way). The parent process receives the exit status when the parent process calls "wait" or "waitpid. os._exit calls _exit of OS

The following code demonstrates it. Beware, os._exit exits the process abruptly.

For more information on exit and _exit refer - https://en.wikipedia.org/wiki/Exit_(system_call)

Refer the Code in GIT Hub

Here is the code in Python (being Python, it is self-explanatory :-))

24 December 2017

Process Management in Python - os.wait()

This is a continuation of series of posts on Process management in Python. Read this and this before continuing further. In this post, we are going to see
  1. How the parent process can get the status of its child after the child has exited using "os.wait"
  2. What happens to the child processes after they exit but the parent is still alive and did not get the status (defunct - meaning that userspace is cleared but a small about of information in kernel space is retained so as to give the information when the parent requests the status which may potentially lead to inability to create new processes)
Getting the status of the child processes is simple. Just call os.wait() to get status of any child processes or waitpid to get status of a specific process. Note, this is blocking call meaning that the parent (thread) waits here until the child is exited/terminated.

For more information on wait/waitpid, refer - https://en.wikipedia.org/wiki/Wait_(system_call)

Refer the Code in GIT Hub

Here is the code in Python (being Python, it is self-explanatory :-))

23 December 2017

Process Management in Python - os.exec

This is continuation of the previous post - Process Management in Python - os.fork()

In Linux, running a command from the shell is a two-step process. The shell first creates a process using fork (posted earlier) and overlays a new program using "exec". For example, when you want to run the command "ls" from the shell - the shell forks a copy of its own and immediately loads the binary of "ls" and starts the execution again.

Beware, you cannot find a function exec() but rather it is a family of functions with names such as - execl, execle, execlp, execv. The functions are almost same and they differ only in parameters that are being passed. I have used one such functions in the following code. When you run this code, you should see a directory listing - the current process upon the successful calling of exec, loads "ls" and executes it. Once "ls" is executed, it exits (like it normally used to do)

As an experiment, you can do fork to create a child process and in the child process execution flow, you can overlay a new program.

Refer the Code in GIT Hub

Try running this script from Linux shell and see the output. Do not forget to share, like, comment if you like this post :-)

22 December 2017

Process Management in Python - os.fork()

Inspired by https://pymotw.com/3/signal/index.html, I thought of exploring os package in Python. The next few posts would be on process management and how to do it in Python. I would be showing you the code that is tiny. The goal is to provide basic code and I leave the improvision to you.

There are four important system calls - fork, exec, wait and exit that are related to process management. Interestingly Python provides equivalent APIs as a part of os package so that you can do a lot of system programming (and use it in a cool way). In this post, let us see some code that uses "os.fork" to create a new process.

os.fork() - creates a new process (often called as parent-child processes). The following code has enough comments and some explanation embedded as comments. Suggest you read the code and run it in Linux box.

Refer the Code in GIT Hub

If you want to know more about fork, refer - https://en.wikipedia.org/wiki/Fork_(system_call)

Share, comment and contribute if you like this post :-)

21 December 2017

Alarm and Signal in Python

Continuation to my previous post in Signals in Python. Again the credits go to Python Module of the week. The following code shows how easier it is to work with Python. This simple script registers for an alarm using SIGALRM which is configured to fire after "n" seconds. After "n" seconds, the handler function gets called.

In this code, I set alarm once as a part of main control flow and register again in the alarm handler. This program does not exit unless one kills the process or stops the execution of the program. (Python code seems to be more beautiful)

20 December 2017

Signal Handling in Python

If you are system programmer, you would have heard about signals and probably would have done lots of coding using signal. It might also be a second nature to you. But when you started to get your hands dirty with signals especially in C, it might have been quite involved. Now moving to signal handling in Python

Recently (last week), there was a post from Python Module of the week on signals and I thought I would try it. Here is the code that does some signal handling. You might want to check the full post (BTW, it is very interesting one). I feel that it easy to write code (and beautiful too) and I was able to do C-equivalent code in less than 30 minutes (which means that Python makes us productive). Here is the script that I wrote. You can find in GIT Hub and feel free to play around.

17 December 2017

"Python Crash Course by Eric Matthes" - Final Post and Review

If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.

This is going to be the final post on this book

Review Comments: I accidentally stumbled on this book when I was looking for the books on Python. As the name suggests, it met the purpose of offering the crash course in Python. I could see the chapters are shorter as that one can complete a chapter (or two) in a single sitting. and logically arranged. The code snippets (examples) and "try it yourself" offered a great insight into the programming language. If you are in a hurry to get yourself exposed to Python, grab a copy of this book and you should be making a lot of good progress in booting up in Python. I should also alarm you that this book does not cover the language and its features in great detail. If you are looking for a deeper coverage of each feature, there are other books.

I have solved all the exercises in GitHub. I do not intend to solve the projects now.

Ratings: I would rate this book a 4.5 Stars.

Recommendation: Apt for beginners of Python (If someone is new to programming, they might feel left behind in later chapters as the book covers quite a lot of ground in every chapter or might need to spend more time referring the materials online). If you are new to programming, maybe a MOOC course on Python would be an excellent start.

You can find all posts related to this book - here

Next Goal:
It is time to learn Python little deeper using "Learning Python" by Mark Lurtz

Want to challenge yourself?
Do you want to take part in the challenge of completing "Learning Python" in two months? Add comments below.

13 December 2017

"Python Crash Course by Eric Matthes" - Code Journal 2

If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.

Today's update:
Today (13-Dec-17, coded from 6am to 7.45am), I committed the coding solutions for Chapter 8. While solving the exercises, I realized that how easy and lovely is Python. When people say that Python is highly expressive, I did not relate to it. Now, I can :-). The amount of features that you can build with the amount of code is no way related. You will end up writing lesser code (less code means less time to develop means high productivity. Less code means fewer bugs which leads to high quality). If you want to experience it, try reading Chapter 8 and try solving examples. Lists, dictionaries along with various ways of using functions, passing arguments, passing parameters dynamically, passing a variable number of arguments are cool features of Python. Functions in Python is very powerful and yet flexible (I urge you to experience it by yourself)

Do not underestimate Python and this book (because it is a crash course). Solving some of the exercises can be very involved and serves the purpose. I would give 5/5 for the exercises in this chapter. Great selection of exercises. Kudos to the author

Solutions to Chapter 8 can be found in GIT Hub Repository. View it and Share it

Want to contribute/collaborate?
If you want to contribute, you can clone the repository, create a branch and give me a pull request. If you want to know how to collaborate, email/call me. Together, we can make things better.

If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-). 

12 December 2017

"Python Crash Course by Eric Matthes" - Code Journal 1

If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.

I am archiving all the code that I have written so far in GIT. Just in case if you want to see it live, check this out - https://github.com/grabyourfreedom/pythoncrashcourse. I have committed all the code that I have written till chapter 5. I will keep working on it - fix bugs, add comments, refactor and add solutions to more exercises. For next few days, I will work on the code until chapter 11 and start reading the other chapters from Saturday (for more posts and code). The code journal posts are likely to be short as I am planning to post only updates here and commit the code to GIT hub.

It is very exciting to ramp in a language - reading, coding, and sharing.

Want to contribute/collaborate?
If you want to contribute, you can clone the repository, create a branch and give me a pull request.

If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-). 

11 December 2017

"Python Crash Course by Eric Matthes" - Reading Journal 4

If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.

This post gives an overview of what I learned in Chapters 10 and 11.

Chapter 10: Files and Exceptions
It looks to me that the last few chapters are really informative. This chapter didn't disappoint me. The first part talks about file operations - reading a file, writing to a file, appending to a file with few variations. The second part talks about handling/managing errors using exceptions (try, except and else). As a bonus, the chapter covers storing data using JSON module and at the end talks about code refactoring. Overall it is written well and does the job.

Chapter 11: Testing Your Code 
This chapter seems to be very easy and yet at the same time very informative. It is great to see a book that boots up someone in a language (programming) talks about "testing the code". I feel that it makes a lot of difference in developer's life (others too) when we test our own code using automated unit tests. This chapter talks about testing your functions and classes using Python's unittest module with cool examples. And the side effect, it kindles the interest to explore further on creating automated tests too. Great job by the author

The next set of posts from me would be code journal. I will try to write a couple of posts sharing the coding exercises. With this, I concluded the basics of Python and I am excited to start the projects :-)

If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-). 

10 December 2017

"Python Crash Course by Eric Matthes" - Reading Journal 3

If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.

This post gives an overview of Chapters 7, 8 and 9

Chapter 7: User Inputs and while Loops
This chapter covers how to get input from the user, how to convert it to numerical values if you need it. It covers while loop, how to exit from the loop using flag, break, continue and how to avoid infinite loops. It gives a couple of examples of when and how to use while loops with lists and dictionaries. This chapter is extremely light for a developer and might be interesting to someone who is new to programming. You should complete this in less than 30 minutes including the exercises.

Chapter 8: Functions
The chapter covers quite a lot of ground with functions, modules and a bit on PEP8 styling guidelines with respect to functions. You will see how to define a function, without and with parameters, returning value, keyword argument, optional values, default values for parameters, passing a variable number of arguments, passing a variable number of arguments with keywords, importing a module, importing a function from a module, importing all the functions from a modules and aliases for module/functions with sufficient examples. The chapter closes with the styling guidelines from PEP8. An awesome chapter and I really liked this chapter. This chapter might take a little longer including exercises and reflection. It is best to pause here for some time to reflect to ensure you got everything. After completing this chapter, you will really feel that Python is powerful. Kudos to the author for giving us a wonderful chapter.

Chapter 9: Classes
Like the previous chapter, this chapter too covers very interesting paradigm of Object Orientation using classes and objects. If someone is new to programming, I recommend for a slow reading solving all the exercises and trying out all the examples. It is worth the effort. Ensure that you understand the essence of the chapter (classes, objects in OO paradigm) before moving further. If you already know another OO language like C++ or Java, it should be a cakewalk for you. This chapter talks about creating classes, __init__ method, self, creating objects, accessing attributes, calling methods of the objects, subclassing/inheritance, overriding, importing classes and styling of classes. Another wonderful chapter with real-world examples.

If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-). Together, let us transform ourselves.

09 December 2017

"Python Crash Course by Eric Matthes" - Reading Journal 2

Like me, if you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.

This post gives an overview of what I learned in Chapters 4, 5 and 6

Chapter 4 - Working with Lists
In this chapter, you will work with Lists in a much better way and you will see how much easier is working with Lists. You will learn the operations such as iterating the list using for loop, working with numerical lists using range, slicing a list, copying the lists, difference between copying and assigning lists. You also get to know various errors (runtime and logical error) that are likely to happen when you do not indent properly. At the end, you have a very nice section on how to Style the code. Refer PEP8 from here. This chapter is engaging and you can complete this chapter in 30 to 45 minutes including solving exercises.

Chapter 5 - if Statements
This is another easy chapter that covers conditions/tests, condition evaluation to boolean, test equality, test inequality, comparisons, multiple conditions using "and" and "or", check for existence of a value in a list and non-existence of a value in list, test to check whether the list is empty, simple if, if..else and if...elif...else. Like the other chapters, this chapter is also engaging and one can complete this within an hour

Chapter 6 - Dictionaries
This chapter covers the basics of another important feature of Python - Dictionary. This chapter teaches what is dictionary (you will understand the difference between list and dictionary when you work through examples),  adding new key-value pairs, modifying key-value pairs, removing a key-value pair, various ways of looping (items, keys, values) and various types of nesting (dictionary inside dictionary, list inside dictionary and dictionary inside list).

If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-). Together, let us transform ourselves.

08 December 2017

Switch by Chip and Dan Heath - Notes

This page contains my notes, my reflections and various other references that would aid my readers. Finally my recommendation on the book.

Book: Switch - Switch - How to change things when change is hard
Authors: Chip and Dan Heath

These posts are not a replacement for the book. The book is million times impressive and insightful. After reading these posts you might get an urge to buy the book but after reading the book you would like to change something. I would rate this book a five star (*****) and encourage all my readers to buy one. These posts should shed some light on your investment on this book and potential huge return on investment.

  1. Book Review after first reading
  2. Switch (Part 1) - Three Surprises
  3. Switch (Part 2) - Direct the Rider, Find the Bright Spots
  4. Switch (Part 3) - Direct the Rider
  5. Switch (Part 4) - Motivate The Elephant
  6. Switch (Part 5) - Shape The Path
  7. Switch (Part 6) - How to keep the Switch going?
  8. Found an excellent video review of the book in Youtube
  9. Other Resources to aid in learning

!!! Happy Switching !!!

07 December 2017

Interviewer Essentials

A great part of my weekend goes to interviewing and a considerable amount of my time during my weekdays is devoted to hiring and activities related to hiring - profile screening, talking to the candidates, interviewing - technical and softer aspects.

What I learned are (over a period of time)

To Interviewers and to their managers (the source of problem but who think that the fault is on everyone but them)
  1. In the part of the world that I live in especially - be ready to read more (do not get bored or scared of seeing the projects and skills that one acquired 10 years back that never eroded)
  2. Shortlist quickly and ask HR to schedule interview
  3. Be available on time. If you have some work and you would join late, send someone who can do interviews (not just filling the space/time)
  4. Interviews are a business transaction. The interviewer has to sell the company and the future employee is likely to undergo. Not a fancy future that would never materialize. Be pragmatic on what you say
  5. You cannot get super-man when you pay peanuts. Reset your expectations
  6. Expect that someone can become super-man after she joins. Look for track record
  7. People want career, money, satisfaction, appreciation, feedback and a great culture (only the order differs from people to people). Do not oversell anything (as people might feel they won't get other stuff)
  8. You may be leading machine critical things but do not expect the folks to burn might night oil. Do not boast either
  9. Interview for the position (do not interview like you are hiring a CEO when you are hiring a developer). It is big sin to hire a developer without coding. Satisfied with pseudo code or "I can tell the logic" is the biggest sin. If you are hiring for senior position, start with design and drill down to coding (or start with code and move to design - bottom-up or top-down either way is fine, but do it)
  10. Often neglected piece is asking them to write unit tests for their own code. They might even write just two test cases, but it is fine. The question is whether they "think". If someone is allergic to writing unit tests - never look back
  11. Giving clues is not a sin. When you give hints, you really know more about the candidate (whether he picks up quickly and able to connect the dots). When you give clues, ask them to enhance.
  12. Do not ask funny or fancy questions on DS and Algo (which you were not able to solve for three hours but once you solved you want others to solve in 10 minutes) when your daily work is something else
  13. The world is moving more towards OpenSource, please see whether the candidate has allergy towards the word - OpenSource (and self-learning/training/exploring on their own)
  14. Give them the runway - Not all will be able to crack everything first and not always. Warm them up
  15. Listen properly and be attentive. Ask questions and answer questions properly
  16. Most often you will learn things from others, interviewing is no exception
  17. Decide as soon as the interview is over. Overthinking is killer
  18. Help HR. Maybe they have so many candidates to take care. Pick your resume, invite the candidates and take care of interviews. Keep HR informed on outcomes
  19. If the candidate asks feedback, spend some time with them in giving feedback (especially if they are very junior to you and looking to improve themselves). You never know when you will work for a nerd
  20. No frustration (even if your day is tiring)
  21. After hiring, connect with the candidate. Try to see whether you can be of any use to them.
  22. Wait for them to join
  23. Most importantly - remember that you are hiring a human, not a machine. Behave appropriately
Of course, this is not the bible to do interviews and there are zillions other things to do.

Your comments?

06 December 2017

"Python Crash Course by Eric Matthes" - Reading Journal 1

Like me, if you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.

The best book to start (even if you are already exposed to some level of programming) is "Python Crash Course by Eric MatthesThe book consists of two parts. Part one is basics with 11 chapters and Part two consists of nine chapters with three projects. The main intention of this book is to get us up to speed in Python quickly (as you might have guessed it from the title).

The rest of the post gives an overview of what I learned in Chapters 1, 2 and 3 and what was interesting/boring. I ensure to keep it crisp so that you spend more time on learning rather than reading my stories.

Chapter 1: Getting Started
While many of us fumble when it comes to doing things for the first time, this chapter takes the installation of Python and running the first program to the extreme. All the folks who have exposure to programming to a decent degree will find it very boring (detailed steps in Windows, Mac, and Linux deserve their space in the appendix but not first chapter). What I would expect is some history of Python, principles of Python, Why Python is so popular, Where Python is used and what is the future of Python. My view is that you should download and install Python on your own and probably try run your first program (it is fine if you spend additional 15 mins to muck around and figure it on your own - believe me, it is easy). This chapter is a dull start.

Chapter 2: Variables and Simple Data Types
This chapter covers quite a lot of ground if you not exposed to programming at all. If you are experienced programmer, you will skim this chapter through but yet feel accomplished if you do all the exercises. This chapter talks about Variables, naming variables, data types - string, integers and float with some important operations on those datatypes in Python. The concluding sections of this chapter deal with importance of writing comments and The Zen of Python which in my view placed right at chapter 2. This chapter should take 30 minutes to an hour depending on whether you are a programmer or aren't. Python seems to be exciting

Chapter 3: Introducing Lists
This chapter covers an important aspect of Python - that is Lists. After reading this chapter and working out the examples/exercises one should get a fair handle on lists. Like me, if you are from C world you will find it to have some similarity with arrays but then it differs in varieties of ways. You will start feeling the uniqueness and flexibility of Python when you try out examples. This chapter should take around one hour to read and workout examples (since you are no longer new to Python). By now, you can expect yourself to start becoming comfortable with Python. This chapter was a treat for a newbie. Enjoyed it.

If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-). Together, let us transform ourselves.

04 December 2017

Learn Python with "Python Crash Course by Eric Matthes" - Getting Started

I found an excellent link that has recommendations for Python books. Looks like the most of the books are well rated on Amazon and I thought that I would start learning Python with little more focus and discipline.

First I would like to get started with the book "Python Crash Course" by Eric Matthes. The book promises that it would be a crash course with a hands-on approach with three projects after learning the basics of Python. I feel that it would be easier for me to boot-up in Python using this book by doing some projects. I expect to complete this book in 3-4 weeks time (depends on how much time that I am going to devote and most likely I will utilize my weekends).

As usual, I prefer reading this book twice and do things as I read the book the first time. The second reading is to fill the gaps and to ensure that I do not miss anything and probably refactor the code I have written. After I complete the book, I will write a full review of the book with pointers to the source code of the projects in a public repository like GIT and give my feedback on whether this book satisfied my expectations (I am also planning to write short summaries of chapters - what I learned, what I felt interesting and what is boring)

My expectations - Learn Python, interesting to read, interesting projects to do, some advice to programmers new to Python, Fast track my Python boot-up and guidance to go to next level in Python

Let me see whether this book satisfies me.

If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-). Together, let us transform ourselves.

16 August 2017

Wired to be Weird?

Journey of you and me

    Image result for mind
  1. Human mind is fresh when born
  2. Few days after you are born, the folks around you condition you (smile is an outcome of happiness, boy doesn't cry, so do not cry, a girl should not do this)
  3. Because of extreme conditioning, you build your faith
  4. You associate yourself with others of similar faith (things are fine till this)
  5. You tend to believe that the person who you associated with is "good" because of what you experience with him (which is ok, but things start to go bad). Instead of you liking a quality or a task, you tend to like that person
  6. Assume that the person exhibit some unusual behavior
  7. Since you like that person, you are actually discounting the unusual behavior (which is not good) and if you like that person to extreme, you actually justify his behavior
And therefore
  1. We are weird and as the result, we regress
  2. We regress and feel bad, understand our hardware (brain - how it is wired) and try to change our software (thinking/awareness). We grow (a nice possibility)

11 August 2017

Logic without Logic

Image result for ignorance
I came across an wonderful quote in a book on Discrete Mathematics. It applies to several things in life and our attitude in life. Here it goes 

Symbolic logic has been disowned by many logicians on the plea that its interest is mathematical and by many mathematicians on the plea that its interest is logical. - A N Whitefield

Inference: And as a result it is disowned by both.

Apply to Life: I have been in this is situation several times. For instance, when you study mathematics (or any complex subject that needs hard work to master) in school we hear teachers saying that you will understand it much deeper when you go to college. And after a couple of years when you are in college, your lecturer will say "you would learnt it in school" and just skim through it. 

We often get caught in the tiny window of ignorance due to negligence (when people treat you under qualified when you are young and over qualified when you are old and as a result you never get qualified). Break the window

06 June 2017

Internship for Students

Image result for internship
Writing this after a while. 

I was thinking of doing something like this for a very long time (many years probably) but took while. Dr. Sankaran's post is one of the reasons [Thank you Sir]

Hope you guys still remember OpenGyan. I am planning to do something similar but for folks who are really want to take programming to next level. The thinking is to come up with real world problems and TRY solving it and on the way you will learn some cool things. It will be like internship (of course with no stipend).

Program Structure:
  1. Identify folks who are interested to do this. Ideally someone with good (this is purely relative) programming skills and willing to put efforts to learn something new. Should be doing graduate or post-graduate course in a college (and interested in computers)
  2. Willingness to put 4-5 hours of efforts per week. I think this will be a big differentiation. 
  3. Willingness to work in latest technologies - cloud/containers/tools/http/REST (some of these are highly talked about in industry)
  4. Has Google hangout or similar tool for interaction
  5. Talking to geeks and learning from them (expands your learning)
  6. Planning to do for two teams each containing not more than two people. The members of team are co-located (either from same college or live near by each other or connected by Google hangout in the order of preference)
  7. Finally a demo of your work (a write-up on what you have done and learnt) and move on to next problem (if you are still interested)

What you will probably get (no guarantee):
  1. Problems that the world is trying to solve (tough part)
  2. How some of the problems are solved (easy part once tough part is found)
  3. Get hooked to problems (disciple)
  4. Apply what you learnt. If you have not learnt anything, learnt it first and apply it (consistency)
  5. Learn tools that professional use to debug/solve problems (smart work)
What you pay:
  • Your fee is through your commitment and valuing the folks' bandwidth
  • No exchange of money or favour to be involved

If you are interested - write to me GRABYOURFREEDOM AT GMAIL DOT COM
If you feel it will help someone that you know (or don't know) - Just Share.

05 March 2017

Programming Language Pragmatics [Chapter 1, Section 1.5] Check Your Understanding

This post has my answers for "Check Your Understanding" questions in section 1.5, Chapter 1 of the book Programming Language Pragmatics by Michael L. Scott.

Chapter 1, Section 1.5 - Check Your Understanding

Question # 11. Explain the distinction between interpretation and compilation. What are the comparative advantages and disadvantages of the two approaches?
Compiler produces machine code from high-level language. After the compilation, the machine code can be directly run on the target system which is locus during runtime. The machine code produced on one architecture cannot be run on a machine with different architecture. The compiled program is faster than its interpreter counterpart.

The interpreter is usually the locus when the program is running. The program written in high-level language is directly run on the target machine through interpreter. In a sense, the high-level code is machine instruction for interpreter. Most of the interpreter are slower in execution as most of the decisions during the course of the program are deferred until the control reaches to the particular statement. However the debugging is much more easier to do in interpreter as interpreter has control throughout the execution of the program. Moreover the interpreter can do useful features like on-the-fly compilation so that the program can generate code during execution which is again consumed/executed by interpreter.

Question #12. Is Java compiled or interpreted (or both)? How do you know?
Java is both compiled and interpreted. Java compiler transforms Java source code to bytecode. Java Virtual Machine (interpreter) executes bytecode.

Question #13. What is the difference between a compiler and a pre-processor?
Pre-processor is needed step before compilation. Compilation transforms the code substantially but pro-processing is usually is light-weight such as removing comments, replacing macros etc.

Question #14. What was the intermediate form employed by the original AT&T C++ compiler?
The intermediate form produced by AT & T C++ compiler is "C".

Questions #15. What is P-code?
P-code is intermediate code that are produced by Pascal compiler. P-code is run by Pascal interpreter during runtime.

Question #16. What is bootstrapping?
Typically the programming language compiler is written by itself meaning that a C compiler is usually written using C. However at first there will not be any compiler to compile the code written in C. Usually a tiny interpreter is written in a different language to produce machine instruction (tiny compiler). Later the tiny compiler produced by interpreter is used to compile the compiler. This is called bootstrapping. In similar fashion more features are added incrementally to produce high quality compiler.

Question #17. What is a just-in-time compiler?
Just-in-time compiler is a feature of interpretor that converts byte-codes to machine instruction while the program is under execution. This is done mainly to increase performance (speed of execution)

Question #18. Name two languages in which a program can write new pieces of itself "on the fly"
List and Prolog (Python, Perl, TCL also have similar features)

Question #19. Briefly describe three "unconventional" compilers - compilers whose purpose is not to prepare a high-level program for execution on a microprocessor
  1. SQL - Translates statements to operations on database
  2. Compilers to translate logic-level circuit specification into photographic masks for computer chips
  3. TEX that translates document to commands for printers

Question #20. List six kinds of tools that commonly support the work of a compiler within a larger programming environment
  1. Debuggers
  2. Editors
  3. Pretty-Printers
  4. Style Checkers
  5. Configuration Management
  6. Profilers
Question #21. Explain how IDEs differs from a collection of command-line tools
All the tools are integrated in an environment often collaborates amongst themselves where as the command line tools are used merely in isolation. For example when a program crashes, IDE points which line of the code is causing the issue and pops up the code in the editor. The developer can make the change and save the file. IDE automatically builds it.

26 February 2017

Programming Language Pragmatics [Chapter 1, Section 1.3] Check Your Understanding

This post has my answers for "Check Your Understanding" questions in section 1.3, Chapter 1 of the book Programming Language Pragmatics by Michael L. Scott.

Chapter 1, Section 1.3 - Check Your Understanding

Question #1: What is the difference between machine language and assembly language?
Machine language is written using the instructions set of the processor directly. Each operation supported by the processor is given a code using which the operation is carried out. The code written in Machine language will be in hexadecimal. But in the case of assembly language the program is written using mnemonic (often represented as operations such as MOV, STORE, ADD, SUB etc) which later translated to machine instructions by software called assembler. The assembly language also has provisions for macro definition which expanded by assembler before producing machine code.

Question #2: In what way(s) are high level languages an improvement on assembly language? In what circumstances does it still make sense to program in assembler?
While assembly language is faster to execute, high-level languages can be easily learnt by programmers, ported to varied architecture without requiring to rewrite entire logic on many architectures and saves programmers time since high-level languages are not one-to-one mapping of machine instructions. High level languages often use functions (in the context of mathematical functions) to produce highly expressive code. However assembler will be default choice for system specific performance reasons.

Question #3: Why are there so many programming languages?
There are several programming languages because of the following reasons - evolution, special purpose, personal choice, 

Question #4: What makes a programming language successful?
The programming languages are successful because of one or several of the following reasons - expressive power, Ease of use, ease of implementation, standardization, open source, excellent compilers, economic, patroage and internia.

Question #5: Name three languages in each of the following categories: von Neumann, functional, object-oriented. Name two logic languages. Name two widely used concurrent languages
von Neumann - C, Ada, Fortran
Functional: Haskell, ML, Scheme
Object-oriented: Java, C++, Smalltalk
Logic Languages: Prolog, spreadsheets
Concurrent Languages: C++, Java 

Question #6: What distinguishes declarative languages from imperative languages?
Imperative languages solves a problem by sequence of steps with each steps produces some side effects. The imperative language focuses on how a problem should be solved rather than what to do. The declarative languages on the other hand focuses on what needs to done.

Question #7: What organizations spearheaded the development of Ada?
US Department of Defence

Question #8: What is generally considered the first high-level programming language?

Question #9: What was the first functional language?
Lisp, Scheme?

Question #10: Why aren't concurrent languages listed as category in Figure 1.1?
Concurrency support is available in many of languages such as Java, C++ and C. Several concurrency packages are available as language extensions