lunes, 25 de abril de 2016

Updating all pip/pip3 installed packages

Motivation

I've been looking for several options to upgrade my local python packages installed via pip. I've read some posts at stackoverflow and some github.com issues addressing different ways to upgrade them, but I was not very satisfied. I tried to make things on my own and here's how I did it.


Updating pip/pip3 packages

I knew that the command list of pip/pip3 consoles return the list of locally installed python packages. Just needed to take that output, process it and use it to feed pip/pip3 itself in order to get the packages updated.



I hope you find this useful!

sábado, 9 de abril de 2016

Script for automated text translation in Linux*

* I'm working with GNU/Linux Debian, but it should work ;)

Motivation

Some times you are reading stuff on books, documents, or simply the web. I know it sucks to keep opening new tabs on your browser in order to get translations for some words you don't understand. A Friend of mine told me about some script that can be bound to a keystroke combination, popping out the meaning of the highlighted text.

There are several of such scripts on the web, so making one by myself wouldn't be smart righ? Wrong!. I've tried some of them and all of them lack of features like checking that the clipboard is not empty or setting some limit for the size of the text to be translated or something like checking the languages involved in the translation(It could be useful every now and then). Besides it proved to be a good bash excercise for me.


How it works?

The operation steps are:

  • Check the contents of the primary clipboard. This clipboard always stores the text selected with thw mouse pointer at X sessions.
  • Queries a translation of the contents to google translator api
  • Formats result and makes a call to notify-send to deal with notifications daemon who shows the translation

Take a look at the script here

Making things work

Download the script and place it somewhere like /usr/local/bin give it execution permissions and bind the executable to some key combination that you will press each time you need to translate a selection of text :D