Five Examples of Using List Comprehensions in Python

List Comprehensions in Python are awesome. A while back wrote a post on some examples of using List Comprehensions in Python. Here are more examples of List Comprehensions 1. Converting a list of integers to a list of strings Let us say we have a list of integers like and we can use List Comprehensions […]

Three Ways to Merge (or flatten) Lists in Python

Often you may have to flatten a list of lists or merge multiple lists into a single list in python. Obviously there are multiple ways to go about it. Here are three ways to flatten or merge lists in to a list. Merge with “+” Operator” If you have three separate lists like [1, 2, […]

Paste command examples in Linux/Mac OS

The Linux command paste is one of the powerful commands that can be used to “merge multiple files in to a single file” and also “collapse multiple lines in a single file to a new file”. Here are some basic examples of using the paste command. Paste command to merge multiple files into a single […]

How to join PDF files in Mac on Terminal?

In Mac, you can use Preview to join multiple pdf files into a single pdf file. A more convenient way is to join/merge multiple pdf files from command line on Terminal. More recent Mac OS X versions already have Python script to merge multiple pdf files into a single pdf file. Here is how to […]

10 Easy Bash Shell Aliases

Aliases are great way to simplify the terminal experience. Basically an alias is a command line shortcut that allows one personalize the way one interact with Linux commands. The basic idea is to come with a simple version of your favorite command and add it to .bashrc file so that you can reuse the simple […]

How to Fold a Long Single Line Text to Multiple Lines (in Python and Linux)?

You might want to convert a really long string in a single line into multiple lines with specified width. For example, if you have string like 12345678912345678912345678912345678912345678910 and want to split the long text to multi-line text, where each line is of length w, like w=9 123456789 123456789 123456789 123456789 123456789 10 In the above […]

11 awesome ways to use find command in Linux to search files/directory

The find command is Linux is one of the most useful commands  for searching files and directories. At first the find command syntax might look a bit daunting, but once we get a hang of it, the find command is a great asset. How to print all files and directories in current directory? find . […]

Bash tip: Search through history using the up and down arrows

Ctrl-R is one of the most useful commands on the terminal and it allows to browse through command history and re-use it again. On bash shell there is a much simpler way to search through your command history on terminal. Basically you can start typing the initial letter and then use up and down arrow […]

“with” statement in Python to Open a file

A common way to work with files in Python is to create file handler with “open” statement and work with the file. After finishing the work with the file, we need to close the file handler with close statement. For example, if we want to read all lines of a file using Python , we use […]

25 Tips to Move Around in Vim

h Move left j Move down k Move up l Move right w Move to next word W Move to next blank delimited word b Move to the beginning of the word B Move to the beginning of blank delimited word e Move to the end of the word E Move to the end of blank delimited […]