Wednesday, July 11, 2018

Aleatory stuffs

This time it’s not of my own but instead something I revisit more often these days (2nd3). However, the first itinerary is something, you might also like reading further in your leisure time.
  1. Midnight conversation of an old school friend with sister over Maggi: <LINK>
  2. One feature - One commit [By work colleague]: <LINK>
3. The story of a shepherd

Saturday, May 26, 2018

A perfect day

What if you had one day perfectly healthy, I asked? What would you do?
“Twenty-four hours?” Twenty-four hours.
“Let’s see ... I’d get up in the morning, do my exercises, have a lovely breakfast of sweet rolls and tea, go for a swim, then have my friends come over for a nice lunch. I’d have them come one or two at a time so we could talk about their families, their issues, talk about how much we mean to each other.
“Then I’d like to go for a walk, in a garden with some trees, watch their colors, watch the birds, take in the nature that I haven’t seen in so long now.
“In the evening, we’d all go together to a restaurant with some great pasta, maybe some duck—I love duck and then we’d dance the rest of the night. I’d dance with all the wonderful dance partners out there, until I was exhausted. And then I’d go home and have a deep, wonderful sleep.”
That’s it?
“That’s it.”

Go on break the rules, forgive quickly, love truly and never regret anything that made you smile ~ Morrie.

- Excerpt from "Tuesdays With Morrie" by Mitch Albom

Thursday, April 26, 2018

Education Cost in Germany

Before applying to any university for an abroad degree programme, generally one should consider the cost beforehand, at least once before you board that plane to leave everything behind and start a new life. I know few of my friends who got admission offers from ivy schools but could not join because of financial constraints. Before we proceed any further, let me clarify that this post specifically addresses the expenses of pursuing a master programme in a German public university and most specifically of Munich.

The first point of the costing as imaginable would be tuition fees. German public universities do not charge any tuition fee as of October 2017 [1]. However, those who want to study at a private university might have to pay up to 20,000€ per year, and if a student fails any subject, he/she would have to pay approx 2,000€ for reattempt per subject. A student of a public university only needs to pay a marginal semester fee (128€), which also allegedly helps the student with the living costs, e.g; it covers a part of transportation cost within the city (Munich subway is expensive - the minimum roundtrip ticket price is approx 3*2 = 6€; Pro: 5 minutes walk from about anywhere, faster than cars and rarely late), subsidies the meal at university cafes, sports (a very wide range of options are available on an FCFS basis and access to olympics grade state infrastructure - 10€ per semester) and student dorms fees. Again, the semester fee might vary depending on the university. So pretty awesome for 128€, isn't it? Besides if you make it to the merit list, the university awards you with the scholarship or well-paid research assistantship. Apart from these, if you are an average guy like me who knows a little bit of this and that, there are tons of research projects in the university, that could pay you well.

The second big part is living cost. Munich is without any doubt the most expensive city to live in Germany. It is usually around 30-40% costlier than the rest of Germany. Especially rents are so crazy here that even London and Paris look sane - a single room in a shared flat is already 500€ and up. However, for those universities that are located in a small town or university-town, 200-300€ could easily fetch you a single room with attached kitchen and stuff.

Now let's get back to the semester fee (128€) that a student pays at the beginning of every semester. A part of this fee goes to Munich Student Union and in exchange, Munich Student Union avails subsidized student accommodation (believe me, it is a nightmare to find one in Munich and surrounding areas -  took me one year). The rooms are equipped with centralized heating, running hot/cold water and unlimited internet (DW/UP speed: 20/40 Mbps), which is covered by the rent itself. The student union offers the students a total of almost 11,000 rooms and apartments at an average monthly rent of approx 300€. The average waiting time to get an accommodation from the student union varies from 6-12 months, depending on the halls of residence. In most cases, the kitchen and washrooms are shared with other students and everyone has a small single room. Applying early for a place at the residential home raises the chance to get one of the strongly demanded places such as Studentenstadt Freimann. Residential homes cost between 200-400€, a room in an apartment-sharing community costs between 300-500€. A single apartment can cost from 400€ upwards. So once a student secures admission to the university, they must immediately register themselves at Munich Student Union online portal. Additionally also consider applying for private student dorms, such as John-Mott-Haus.

Now, there are other things that are needed, starting with food, clothing, study materials and free-time activities (such as beer - beer is cheaper than bottled water) that form another part in costing. Regarding study materials, you mostly do not need to buy many books or print a lot of lecture materials - almost 99% of lectures are recorded and other resources such as books, IEEE publications, journals, safari are accessible through university e-media library and apps. The money needed for food depends on the individual; however, it is generally advised to shop in discount supermarkets such as Aldi, Edeka or Rewe which offers high-quality groceries at a cheap price. These stores don't spend their money on advertisements and expect customers to pay for that. German people usually don’t care much about things being gluten-free, organic or whatever (few does?), so the grocery prices just don’t heat up out of thin air. However, if you are a brand person then there are stores though that charge above the market, for example, Basic. In total, it is a good way to look at your own lifestyle and calculate with about 200€ more.

The below Fig. 1 (provided by the university office of academic affairs) illustrates the estimated monthly living cost for a student studying in Munich based on the 19th social survey of the Deutsche Studentenwerk [2]. In one of the emails before induction, the university programme advisor had suggested calculating the living expenditures based on the maximum cost (approx 800€ per month according to her).
Fig. 1. An estimated monthly cost of living for a student in a German university [2]
Well enough of estimation, I think it would be more beneficial for a future applicant to know the actual incurred cost for pursuing a master programme in a German public university. First of all, let me clarify few things: first I completed my programme in three years, second my daily lifestyle does not demand a lot of expenditures - I have mostly inexpensive tastes, so take the below Fig. 2 with a pinch of salt, and lastly third these expenditures include few loans that I had given to few friends and also few travelling costs which I didn't categorize while preparing this chart (Lazy I know already) and thus got added to Uncategorized section, so give or take, I think the total expenditures, for me, must have been around 30,000€ for three years.
Fig. 2. Expenses planet chart of total expenditures for three years

Apart from daily living expenses, you should consider including traveling on your list (You get only one life to see everything, remember!), which can be expensive depending on your choices. It is also quite normal if you keep calculating every price to your native country currency in your first few months but please grow out of it for your own sake. Get a part-time job once you are settled (you will be paying around 40-50% income tax - approx 1,000€ per month) and for heaven sake, please don't be cheap when it comes to tipping people who provide you with their generous services. Generally, 10-15% tip is acceptable if the services are great (otherwise less) and you will be greeted with a hearty Danke, more than this is usually seen as show-off by your peers - don't worry nobody will complain and you will still get your Danke. Respect local culture, please don't always keep talking about how awesome/different your native country is. I'm sure, yours is - though after a while it becomes mildly annoying, better use this opportunity to expand your horizon. Don't be a flamboyant, loud-mouthed prick, your language, manners, and way of speaking do matter, respect social-laws and do study well.

Few other expenditures you should be aware of:

  • TV/Radio license fee: 20€ per month (You will moan about it, everyone does!)
  • Health insurance: 85€ per month (if the registered number of semesters <= 12, otherwise 180€ per month)
  • Church Tax: If want to avoid, simply register yourself as an atheist
  • Mobile: 10€ per month (250 MB data plan)
  • IsarCard: 193€ per semester (allows 24 hours access to Munich subway)
  • Morning Coffee: 1€ per cup (only in student cafes, otherwise 2.5€)
  • Restaurants: around 20€ (per meal)
  • University Cafe: around 4€ (per meal)
  • Drink in a beer-garden / nightclub: around 5-7€ (per drink)
Good luck!

References:
[1]  Referendum to abolish tuition in German Public Universities.
[2]. The Economic and Social Conditions of Student Life in the Federal Republic of Germany.

Note: All the cost incurrences were collected in October 2017.

Thursday, April 12, 2018

Dasbidaniya over a cup of tea!

With a dear friend. During our last train journey, we were talking about the sacred geometry of our life chances, about growing old, about not becoming an old man full of regrets but growing as an old content man with full of white hairs - but not with regrets. What could be the hidden law of a probable outcome - we don't know, we will never know -  if we don't try it firsthand. What could be the easiest way to become that old man that we despise so much - Follow others for fear of what society would say otherwise, living in the fear of what people might think? Nothing matters, as if I don't do what I told you before, that regret will take over and will never leave. I am very glad to have this friend of mine, an honorable man, a man who doesn't believe playing solely for the money, status, or respect but for what he believes is right (don't get carried away too far - he is quintessentially a guy first just like many of us - his resolution to keep the room in an orderly way lasted for precisely ONE day :D ); natheless can't help but feel little doleful as well at our perfectly timely egress. Next time, we meet, I hope we will be on that path where memory or money for that matter doesn't dissolve our fervor. Until then Dasbidaniya!


Wednesday, April 4, 2018

Rum interviewees

I believe, we all have done few hilarious (read embarrassing) stuffs during interviews, for god knows why? I mean, we all have been there, once in a while, haven't we - Not in a horrible way but seriously don't even try to venture into these kinds of a blizzard. And if you do, yes you might have a funny story to share down the lane with your friends and family, but probably without that job in your profile. But Hey, what's the point in life, if you can't make few of your own stories. So if you, like me, have any interview regrets, these should make you feel better – you’re not alone. All these incidents are mind-fart incidents of either mine or my friends. However, for their privacy sake, I will address each of these incidents as a third person.  And, obviously, these stories are biased in favor of interviewee so don't read too much in between. However, on a serious note, do acknowledge that the firm for which you are being interviewed has every right to have whatever criteria they deem fit but at the same time you should know that they are not doing you any favor - They are looking for their best and you must be looking for your best. So don't sweat over if it doesn't work out - When one door closes, another opens, Always! Go out there, learn and enjoy the process - Be respectful but at the same time expect the same courtesy, otherwise just walk out - No further discussion!

1. But you are beyond.
Job description: Software Dev (A networking company - ABC)
Interviewer (I): How proficient are you in networking?
Candidate (C): I am okay but not really my expertise.
I: How are you going to survive in ABC, if you don't know these stuffs?
C: But in pre-talk, you had stated that ABC is beyond networking, didn't you!
2. Home guy.
Job description: Software Consultant
Interviewer (I): For 2 days in a week, you have to work from <City 100 KM away>.
Candidate (C): Okay, but I am a work from home kinda guy.
3. Half dressed.
Job description: Back-end SE
So for the online interviews, this guy feels relax with his top-half cloth and for the rest - well let's just say a minimally required element. One fine day, during an online interview, he needed a piece of paper to write his pseudo code, but understandably couldn't get up of his chair to fetch one :)
4. Smile creep.
Job Description: Master Admission
This incident is ancient, 2010. So this guy seriously said what is written in the below pic, in front of whole panel: First smile and then that filmy dialogue. The Profs stomach might be hurting from laughter once the guy was out of the panel.
They say a pic is worth a thousand words. What an idiotic answer, LOL!
To the profs, his smile must have looked like this :D
5. Impressed already?
Job Description: Application dev
Interviewer: Impress me!
Candidate: I'm exceptionally proficient in python and back-end, and I'm pretty expensive!
6. A late wizard? 
Job Description: Cloud tools
Interviewer arrives around 20 minutes late.
Interviewer: Hello, how are you doing?
Candidate: I'm sorry - I'm early!
7. A bird came to city.
Job Description: A truly awesome startup, back-end dev
Interviewer: Your work history shows that you have been mostly working with well-established firms. What is your motivation?
Candidate: I'm a bird (WTF did he smoke last night :D)

Sunday, February 11, 2018

Python’s philosophy Once again

Let's restate the Python's philosophy from the Python terminal itself:

>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

Now I realize, learning a programming language is not that difficult (Disclaimer: Not counting Brainfuck category of languages), however learning software engineering is what it's really hard. Writing code is the easiest part that you could ever do, what indeed matters is how you "engineer" your program. What I need now is to slowly let principles of PEP8 and Flake8 coding guidelines sink into the psyche. My most favorite guideline from PEP8 cookbook:

"Know when to be inconsistent -- sometimes style guide recommendations just aren't applicable. When in doubt, use your best judgment. Look at other examples and decide what looks best. And don't hesitate to ask!"

References:
[1]. https://www.python.org/dev/peps/pep-0008/#introduction
[2]. http://flake8.pycqa.org/en/latest/

Monday, January 22, 2018

defaultdict vs. dict in Python

Dictionary is easy to use data-structure for storing data for later retrieval hashed by unique keys. Obviously, the keys should be immutable objects such as string, set or numbers (list can't be key). In some cases, a new key might always have a default value such as an empty list or a numeric value (basically anything). While this is easy to do manually in a standard dictionary, the defaultdict type automates and simplifies these kinds of operations by automatically assigning default values to any new hashable key entry.

Definition of defaultdict:
---------------------------------------------------------------
class collections.defaultdict([default_factory[, ...]])

A defaultdict works exactly like a standard dictionary, but it is initialized with a function (“default_factory”) that takes no arguments and provides the default value for a nonexistent key.  A defaultdict will never raise a KeyError. Any key that does not exist gets the value returned by the default_factory. However do remember to pass the default_factory to default_dict otherwise if the default_factory attribute is None, this raises a KeyError exception with the key as the argument (It will then behave just like a standard dictionary).

Be sure to pass the function object to defaultdict(). Do not call the function, i.e. Use defaultdict(func), not defaultdict(func()).

In the following example, a defaultdict is used for counting the frequency of characters in an input string. The default_factory is int, which in turn has a default value of zero. (Note: “lambda: 0″ would also work in this situation). For each character in the string, the value is incremented by one where the key is the character. We do not need to make sure that a character is already a key – it will use the default value of zero.

Example 1:
---------------------------------------------------------------
from collections import defaultdict

def print_dict(user_dict):
    for key in user_dict:
        print key + ": " + str(user_dict[key])

def default_function(): return 0

input_str = "abccddddeeee"

# All these three methods produce same result.
char_freq_dict = defaultdict(default_function)
# char_freq_dict = defaultdict(int) 
# char_freq_dict = defaultdict(lambda: 0)

for ch in input_str:
    char_freq_dict[ch] += 1

print_dict(char_freq_dict)

Output:
---------------------------------------------------------------
a: 1
c: 2
b: 1
e: 4
d: 4

You could accomplish the same objective using the standard dictionary in following way:
def print_dict(user_dict):
    for key in user_dict:
        print key + ": " + str(user_dict[key])

input_str = "abccddddeeee"

char_freq_dict = dict()

for ch in input_str:
     if ch not in input_str:
         char_freq_dict[ch] = 0

     char_freq_dict[ch] += 1

print_dict(char_freq_dict)


In our next example, we use an empty list for any nonexistent key. The input provides a list of tuples consisting country and city. We want to build a dictionary where the keys are the countries and the values are lists of all cities for that country. To build this dictionary of lists, we use a defaultdict with a default_factory of the list. An empty list is created for each new (aka, nonexisting) key.

Example 2:
---------------------------------------------------------------
from collections import defaultdict

def default_function(): return []

def print_dict(user_dict):
    for key in user_dict:
        print key + ": " + str(user_dict[key])


input_list = [('germany', 'munich'), ('germany', 'berlin'), ('UK', 'london'), ('UK', 'bristol'), ('UK', 'liverpool'), ('sweden', 'stockholm')]

# All these three methods produce same result.
#country_city_dict = defaultdict(default_function)
#country_city_dict = defaultdict(lambda:[])
country_city_dict = defaultdict(list)

for entry in input_list:
    country = entry[0]
    city = entry[1]
    country_city_dict[country].append(city)

print_dict(country_city_dict)


Output:
---------------------------------------------------------------
sweden: ['stockholm']
germany: ['munich', 'berlin']
UK: ['london', 'bristol', 'liverpool']

In the last example, we distinctly demonstrate that a defaultdict never raises a KeyError. Any key that does not exist gets the default value returned by the default_factory.

Example 3:
---------------------------------------------------------------
from collections import defaultdict

def print_dict(user_dict):
    for key in user_dict:
        print key + ": " + str(user_dict[key])

num_dict = defaultdict(lambda: 'Magic, I am here')

for item in ['a', 'b', 'c']:
    if num_dict[item]: print item + " is already present"

    # Notice, here we are trying to access value for a key in the if condition, so      
    # default_dict comes into the picture. if we instead use 'if item in num_dict:'
    # , then we are not  really accessing this new_key in num_dict and thus
    # the default_dict will not be kicked off for this key item.

    else: print item + " is Missing"

print_dict(num_dict)

Output:
---------------------------------------------------------------
a is already present
b is already present
c is already present
a: Magic, I am here
c: Magic, I am here
b: Magic, I am here

References:
[1]. https://www.accelebrate.com/blog/using-defaultdict-python/
[2]. https://docs.python.org/2/library/collections.html#collections.defaultdict