pluton's blog

blog about me

Blog’s migration

Hello there!

The blog has been moved here: http://www.egeek.me/!

Sandisk Sansa Clip+ + podcasts + gPodder

Hello everybody!

I’ve been using a Sandisk Sansa Clip+ 4GB player for a few months now. It’s an excellent player for podcasts. It is definitely a bang for the buck. A big advantage is that it saves the position of each podcast when you switch to another one.

The player has a menu item called Podcasts, where it places all recognized podcasts from the internal memory. When I first uploaded podcasts to the device, I wasn’t very happy because podcasts’ tags are filled differently. The player builds the list based on the Artist field, and the second level is the Title tag. I wanted to use the menu correctly, so I had to create a script to fix the tags.

Git repository with the script is available here: https://github.com/pluton8/fixtags. You can clone it or just download the script by pressing the Download button on that page. So, you’ve downloaded and unpacked it. Let’s assume you’ve placed it to your ~/bin/ directory. How to run it?

You need to install Python 3 and a package called stagger (http://code.google.com/p/stagger/) first.

Luckily, gPodder supports running a custom script after downloading a podcast. We’ll use the feature. Actually, the script can’t be run outside of gPodder. In gPodder go to Preferences, then push the “Edit config” button. There is a field named “cmd_download_complete”, which specifies a command being run after downloading a file. Insert the path and filename of the script to that field. Here is a screenshot:
cmd_download_complete option

In my case, the script is sitting in the directory bin/fixtags/ in my home directory. Save the config. Now the script should work.

NB! The script processes the podcasts it knows only! That is, the ones I added support for. If you listen to other podcasts, you will have to update the script.

That’s all. Feel free to ask any specializing questions.

Bash: how to fix “;5D” issue

Hi again.
After a recent update of my Arch Linux, I faced an issue in bash. Ctrl+Left/Right didn’t work. Instead, bash just showed “;5D;5C;5A;5B;5D;5C”, etc.
Hopefully, I use git to keep track of my /etc directory, thus I was able to see the diff of the update. The cause of the issue is a change in /etc/profile, specifically, removing the line:
INPUTRC="/etc/inputrc"

As we may see from man bash, “If that variable [INPUTRC] is unset, the default is ~/.inputrc.” Yes, I didn’t set the variable in my .bashrc, and I didn’t have the .inputrc file. So, the solution is pretty obvious: create your own .inputrc file. Mine is below:

$include /etc/inputrc

# faster completion
set show-all-if-ambiguous on

"\e[A": history-search-backward
"\e[B": history-search-forward

Ctrl+Left/Right works great now! For more information on how to configure bash, go to https://wiki.archlinux.org/index.php/Bash.

Podcasts!

Hello again. Today’s topic is podcasts! I do like podcasts. In a nutshell, a podcast is like a recording of a radio show, but a podcast can be recorded and uploaded to the internet by anyone. They can be of diverse topics, styles, and genres.
I’d love to share a list of the podcasts I listen to. I like listening to podcasts while I’m going somewhere in order not to spend time for nothing. So, let’s start.
I’m subscribed to… as it turns out, 136 podcasts, English and Russian. About a half is suspended for some reason. Here is a screenshot of gPodder, a podcast aggregator:
gPodder

Firstly, I’ll have a brief look at English podcasts.

  • No Agenda (http://noagenda.mevio.com/) – a very interesting podcast about the current situation (mainly in the USA). The two hosts, Adam Curry and John C. Dvorak, have a very critical view on the American government. The podcast has an innovative approach to podcasts monetization, it’s a user-donated show. The average length is two hours, thus it can be hard for non-native English speakers to listen to, although they speak clearly and understandably.
  • ESLPod (http://www.eslpod.com/website/index_new.html) – a very good and easy podcast for ESL students (as me). There is a great deal of free podcasts now, so you can listen to them for over a year.
  • FLOSS Weekly (http://twit.tv/FLOSS) – a podcast about “Free Libre Open Source Software”. Every week the host, Randal Schwartz, and co-hosts interview people developing open-source projects. Judging by his plans, we’ll hear a lot of interesting people.
  • A Way with Words (http://www.waywordradio.org/) – a podcast where the hosts explain English idioms, words origin, expressions and everything about English. It’s worth listening to for those who want to know more details about English.
  • Grammar Girl’s Quick and Dirty Tips (http://grammar.quickanddirtytips.com/) – another podcast about English, but more concentrated on writing. It’s quite short, five minutes on average, and each one explains one topic.
  • Freakonomics Radio (http://freakonomicsradio.com/) – a podcast that explains “the hidden side of everything”. And, as it turns out, this “everything” is related to economics. Worth listening to.
  • EconTalk (http://econtalk.org/) – another podcast on economics. The host talks with his guest about various economics-related things.
  • This American Life (http://www.thisamericanlife.org/) – a podcast that is usually consisted of four or five stories on a certain theme. They can be pretty amazing.

Well, in order not to make this post too big, I’ll stop now. The rest of podcasts will be given in next part.
Stay tuned!

Update of the GnuCash encryption script

Hi everybody. Some time ago, I published my script to work with encrypted GnuCash files. Here it is: https://pluton8.wordpress.com/2010/11/13/encryption-of-a-gnucash-file/
I’ve made a small security improvement since then, so a new version is available here: http://pastebin.com/DG7ygqtw
The thing is that in earlier versions password was given to openssl via the command-line, therefore any user could run ‘ps aux‘ and see it. Now the password is transmitted via stdin, which is more secure. Some more information: http://www.perlmonks.org/?node_id=308211.
So long.

A tiny userjs (for Yandex’s search page)

Hi again!

Updated on 2011-06-11!

My primary search engine is Yandex, but I often click to the “Google” link at the bottom of a Yandex’s search page. Google’s interface is English, but when I click the link, it enables Russian one. It happens due to “hl=ru” parameter of that link.
It’s a bit inconvenient, so I made it to write a little userjs for the Opera browser. Here is the source:

// ==Userscript==
// @name YandexToGoogle
// @description Removes the 'hl=ru' parameter in Yandex's links to Google at the bottom of a search page
// @version 1.1 (2011-06-11)
// @author pluton <pluton.od at gmail.com>
// @include http://yandex.ua/yandsearch*
// @include http://yandex.ru/yandsearch*
// ==/Userscript==

(function() {
    window.opera.addEventListener('BeforeEvent.DOMContentLoaded', function(ev) {
        // find our Google link
        var elem = document.getElementsByClassName('b-summary__item')[1];
        // and remove the parameter
        elem.search = elem.search.replace("hl=ru&", "sourceid=opera&");
    }, true);
})();

Now, how to install it. Go to “opera:about” address, and find the folder name opposite the “User JavaScript folder” label (in my case, it is “/home/user/.opera/userjs”). Then just save the script’s code to “yandex_to_google.js” file. Works in Opera 10.63+.
That’s all for today. Leave your comments.

Encryption of a GnuCash file

Hello, today I’d like to write about a small thing I use to keep my GnuCash’s file secure (on a GNU/Linux platform). But, at first, for those who don’t know, GnuCash is a program for accounting personal finances. A little annoyance with it is that the application can’t protect its files with password, therefore anyone may open your file and count the money.
The solution I selected is to encrypt the file with the help of external tools. I searched after how to do that, and found one and another posts (in Russian) that recommend using openssl. I made use of the information and created a bash-script to simplify the encoding/decoding process:
Updated on Dec 16
A newer version is available here: https://pluton8.wordpress.com/2011/01/31/update-of-the-gnucash-encryption-script/

#!/bin/bash
# This is a script to work with an encrypted gnucash file. It asks for the
# password, decrypts the file, runs gnucash, and encrypts it back. Logs and
# backups are shredded at the end.
# Author: pluton 
# Version: 0.8 (Thu Dec 16 2010)
# License: GNU GPL 3

CP=/bin/cp
KDIALOG=/usr/bin/kdialog
OPENSSL=/usr/bin/openssl
GNUCASH=/usr/bin/gnucash
SHRED=/bin/shred
BASENAME=/usr/bin/basename

FILE=~/your_encrypted_file
FILETMP="${FILE}.tmp"
TIMEOUT=2   # seconds
TITLE=$($BASENAME $0)

notify() {
    [ -n "$1" ] && text="$1" || text="?"
    $KDIALOG --passivepopup "$text" --title "$TITLE" $TIMEOUT
}

[ -e "$FILE" ] || { notify "File '$FILE' was not found"; exit 1; }

pass=$($KDIALOG --password "Enter the password /GC/")
[ "$pass" == "" ] && { notify "The password is empty"; exit 2; }

$OPENSSL enc -d -aes-256-cbc -k "$pass" -in "$FILE" -out "$FILETMP" || \
    { notify "The password seems to be wrong"; exit 3; }
$CP -f "$FILE" "${FILE}.bkp"
$GNUCASH "$FILETMP"
$OPENSSL enc -e -aes-256-cbc -k "$pass" -in "$FILETMP" -out "$FILE" || \
    { notify "An error occured while encoding (code #$?)"; exit 4; }
unset pass
$SHRED -zun 2 "${FILETMP}"*
notify "Done"

Save the script, then “chmod +x” it. Also, you should prepare the encrypted file in the following way. Run openssl enc -e -aes-256-cbc -in your_file -out your_encrypted_file in the terminal (substitute your_file and your_encrypted_file with your filenames), input password that you’ll use to get access to the file, and delete the original file.
Basically, what the script does is it asks for the password, decrypts the $FILE file and backups it, runs gnucash, and then encrypts it again with the same password. The last command shreds all temporary GnuCash’s files.
I use KDE4, that’s why the script launches kdialog to ask for the password.
IMHO, it’s a good approach to start with, although there is an issue that when the gnucash is running, the decrypted file is available for any program. There should be a solution for this.
Thanks for reading. If you have any questions, leave a comment.

Anki

Recently I’ve stumbled upon a program called Anki (website: http://ichi2.net/anki/). It is a program for helping a person to memorize, as they called, “facts”. Of course, its obvious usage is to remember words of a foreign language. Facts are recorded in “cards”, which are by-turn combined into “decks”.
IMHO, the main advantage of the program is that you can tell it how easy you remembered the card. Based on this information, Anki will show you the card sooner or later.

My screenshot:
Free Image Hosting at FunkyIMG.com
If you know Russian, there’s a good video introduction to the program here: http://www.youtube.com/watch?v=UHGWre0Nq4g

By the way, if you learn English and know Russian, as I do, you can download and use my deck called ‘Kwizme_en’. It’s compiled from the words from http://twitter.com/kwizme_en.

I strongly recommend the program if you need to learn some foreign words.

Fahrenheit 451

I am reading an interesting book now, ‘Fahrenheit 451’ by Ray Bradbury. Its genre is antiutopia. The number ‘451’ refers to the temperature “at which book-paper catches fire and burns.”

The book describes future world where books are burnt out, and people are always “happy” because they only go to work, see the TV, and sleep. The book makes one think.

More info is on wiki.