Educating yourself does not mean that you were stupid in the first place; it means that you are intelligent enough to know that there is plenty left to 'learn'. -Melanie Joy

Monday, 24 November 2014

Change the screen brightness using bash script - xrandr

November 24, 2014 Posted by Dinesh , , ,
In my Ubuntu 14.0 (Dell Inspiron), brightness controls were not working at all. So I started searching for other alternatives to sets the brightness. finally I found this xrandr. it is great tool to set the brightness and even to rotate the screen. --brightness flag can be used to set the brightness (best values: 0 - 1) --brightness flag cab be used to rotate the screen (possible options : normal,...

Saturday, 13 September 2014

Undestanding Generators in Python

September 13, 2014 Posted by Dinesh ,
Before we understand generator we must know Iterator. Iterator: Iterator is any object which understands the concept of a for-loop. Basically this means that it has a next method, when it is called it returns the next item in the sequence. Everything you can use in "for" is an iterable: lists, strings, files...etc >>> [x*x for x in range(3)] [0, 1, 4] >>> mylist = [x*x for...

Sunday, 27 July 2014

Encrypt files using Vim

July 27, 2014 Posted by Dinesh , , , , , No comments
Vim comes with default encryption mechanism refereed as VimCrypt in the documentation. It is capable of writing files encrypted and read them back. Creating new encrypted file: vim -x <file> This will create new file if it is not exist or open an existing file and prompt for password. This password is used as key to encrypt and decrypt the file. Encrypt the current working file: :X You...

Saturday, 26 July 2014

Automate your Vim - The power of autocmd

July 26, 2014 Posted by Dinesh , , , No comments
1. Vim templates I often used to write sample C++ codes to test the functionality. But it is pain to add default code for every test code that I write. Vim has a brilliant solution for it. that is templates. Create some template files in any of the directory you wish, here I created ~/.vim/templates/skeleton.cpp that contains default c++ code i.e #include, using namespace std, main,..etc. Then...

Saturday, 4 January 2014

Python - Thread synchronization - using Thread Events

January 04, 2014 Posted by Dinesh No comments
We may often need to signal the thread to do some special task. Simple solution is to create events. Definition from python docs: threading.Event()     A factory function that returns a new event object. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until...

Friday, 3 January 2014

Python - Signal handling and identifying stack frame

January 03, 2014 Posted by Dinesh No comments
Signals are identified by integers and are defined in the operating system C headers. Python exposes the signals appropriate for the platform as symbols in the 'signal' module.  the signal module in python is used to install your own signal handlers.  When the interpreter sees a signal, the signal handler associated with that signal is executed as soon as possible. signal handler...