Posts

Showing posts from March, 2017

Learn BASH with me in 5 mins

Image
I just started learning Linux bash from today. From my first impression of the language, I infer that it is a language with all the basic capabilities as of an infant high level language. May be I am right or wrong.Time will tell . We will keep going and keep discovering gradually. Let's start with the usual protocol of learning a language.

The HELLO WORLD program.
How to print things in shell. This is the first thing everyone wants to know while learning any language.

Anything that is not a variable is printable . And we print/echo it using the famous ECHO keyword

$ echo hello world hello world
Printing a number.
$ echo 1 1 Printing a string with double quotes$ echo"my name is arindam" my name is arindam Printing a string with single quotes$ echo'my name is Arindam' my name is Arindam Printing a number with quotes$ echo'1' 1
Creating  Variables and recalling them.
So how can we store things. How to recall that stored value. How to change that value.

X=9…

An early morning trek to Ghangad Fort

Image
Ghangad is a short but exciting trek offering the thrill of trekking over difficult patches in portions and some heart trembling moments when you cling on to a thin wire of hope for support.
It great for training beginners. And the view is just splendid.

Duration : 30 mins - 40 mins

Why to choose this trek:

1) Great for only morning treks like Sinhagarh. It offers a mind view of two sides of the mountain .
2) Easy to reach. The route to Ghangad offers amazing landscapes from Tamini Ghat. So it's a bonus.
3) Don't need to plan ahead. Don't need to carry much stuff if you planning to return same day.
4) In rainy season, the waterfalls in the valley area are amazing. We plan to do it this rainy season.
5) Barely any crowd. We encountered no one. Absolute silence and just the wind blowing , animal sounds from the forest . It was just a trekker's dream come true.

Our Plan :

We started at 3:30 .
Climbed and reach back home by 12 AM .
It's an hour long journey . We went via…

Python List sorting with key argument explored

Everybody uses lists as an array to store values. List provide a lot of in-build features.SortingMembershipIndexingIterationreversingAdding/RemovingPoppingCount
Lots of reasons to use lists. I think, one of the most used features is sorting. Internally , python uses Merge sort technique to sort the array items. But the sort method can be used in many other ways to have more control.

The python help says:


>>> help(list.sort) Help on method_descriptor: sort(...) L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) ->-1, 0, 1

Things to note: The sort method doesn't return anything. It saves the changes in the list permanently. Thats why it is faster than the method sorted

SIMPLE SORT


>>> l = ['c', 'b', 'd', 'a'] >>> l.sort() >>> l ['a', 'b', 'c', 'd']
If elements are strings, they gets sorted by alphabetical order.

SORT IN REVERSE ORDER


>>> l =…