Skip to main content

Posts

Showing posts from 2015

Generate email filters in Gmail from list of emails

I have a lot of students from different classes who email me regularly. It is helpful to tell who belongs to which class. So I created a filter in Gmail which will sort the student's email according to their email ID. This scenario is also applicable to industry where we want to sort emails using filters. Most of the time people are able to do it by hand. However, for me it was challenging to do it by hand since I had 400 students. Therefore I fell back to Bash tools to automate the task. The first thing is to extract all the email IDs from a CSV file and save it as a list. cat file.csv | cut -d"," -f10 The 10th column had the email IDs in the CSV file. The fields are separated by commas in CSV files. Therefore, I have used -d"," as the delimiter in the cut command. "rwrwfa" "ebbra" "rksda" "ru57a" But they have the " which I need to get rid off. Easy use tr. cat file.csv | cut -d"," -f12 | s

Google script to generate expense spreadsheet in Google Sheets

Google has started scripting support for all its products. So Google docs now support scripting which will allow end users to automate routine tasks. Google Scripts is a Javascript cloud scripting language (as opposed to Javascript being client-side only) which can make life easier for most of us (Or at least the tech-savvy ones). But if you are not a programmer, don't despair -- this tutorial does not assume coding experience but the ability to copy and paste in the right places. Now all Google products support scripting and this includes Google Maps. So for example, if you want to write a script which will import the restaurant data from Google Maps, then make it into a list in Google Sheets, and then sort the list by distance from home and email that list to colleagues, it is now possible to achieve all of this due to the support of Google Scripts. This means that now many things can be automated and the end result is an increased level of productivity. Let's say, we ha

Convert a batch of scans into a djvu file

To convert a batch of image files (scans) into a single djvu document we first need to convert those files into pbm format first. Then convert each pbm file into a djvu document and then finally merge those multiple djvu into a single djvu document. But for those conversions we need Imagemagick (for convert ) sudo apt-get install imagemagick --fix-missing And we would need the djvulibre toolbox also sudo apt-get install djvulibre* After these softwares are installed we are ready to run the following script. This script will convert all jpg images into pbm and then to djvu and finally merge them into one single djvu file. I have assumed that the scans are in jpeg format. For tiff files replace  the TYPE with tif. Or you can call the script with the command line option of the file type. Just replace "jpg" by $1 in the script below. #!/bin/bash TYPE = "jpg" for x in *. $TYPE do y = ` basename $x . $TYPE ` convert $y . $TYPE $y .pbm cjb2 -

Small Nifty Dictionary in Python

We all have to look up words in a dictionary at some point or other. Whatever the reason it might be --  maybe because their jobs are text intensive, maybe because they a non-native speaker looking for the right pronunciation dictionaries are indispensible. There used to be some really good dictionary apps 6 years back. Now with google acting as the dictionary, a stand-alone dictionary app is kind of redundant. However these quick visits to google.com can slowly eat into our productive time. So I thought it will behelpful if a small little app sits in the corner of my screen not using any space which can act as a dictionary. So I wrote this app. The full app can fetch word meanings, IPA pronunciation guide and the actual pronunciation audio. The following code snippet implements the pronunciation part only. I have written this to work exclusively in Linux -- the Python code calls a Bash script to grab the pronunciation files from the internet. The choice of bash script is to perform