Archive

Archive for March, 2012

A command-line, interactive mini dictionary

March 29, 2012 Leave a comment

In Google, you can use the search term “define:word” to get the definition of a given word. Google can also pronounce the word.

I’ve made a simple script that gives similar functionalities from the command-line. Usage: just type in a word. The script is part of my jabbapylib library; available here.

Screenshot

------------------------------------------
Jabba's Interactive Mini Dictionary v0.1.0
q - quit | c - clear
------------------------------------------
>>> barkeeper
===Definition===
(noun)
A person who owns or operates a bar for the sale of alcoholic beverages.
===Examples===
(1) Aaron called the barkeeper over and asked for a beer.
(2) The barkeeper was the only human in the establishment; all of the patrons were stout, broad-faced halflings.
>>>

It’s not visible here, but the script pronounces the given word too.

The script uses the API of wordnik.com, so you’ll need to ask an API key (free). More info here.

Don’t use sudo with graphical applications

March 29, 2012 Leave a comment

This post is based on a comment of one of my readers called gourgi.

Problem
You want to launch a graphical application with administrator privileges. Shall I use “sudo”?

Solution
No. In the case of graphical applications, you should use “gksudo” instead. “You should never use normal sudo to start graphical applications as root. You should use gksudo (kdesudo on Kubuntu) to run such programs. gksudo sets HOME=~root, and copies .Xauthority to a tmp directory. This prevents files in your home directory becoming owned by root.” [1]

More info:

  1. https://help.ubuntu.com/community/RootSudo#Graphical_sudo
  2. http://www.psychocats.net/ubuntu/graphicalsudo

Download files with wget from sites that verify your user-agent

March 28, 2012 Leave a comment

Problem
You want to download a file from a given site with your favourite wget utility but you get a “403 Forbidden” error in your face. Of course, everything works from your browser. What to do?

Solution
If it works from the browser but it fails with wget, then the site must check your user-agent. If it sees “User-Agent: Wget/1.12 (linux-gnu)” (version may vary), then it simply blocks you.

But don’t fear for a second. Simply fake a different user agent with wget and continue downloading.

Solution 1:

wget --user-agent "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0" http://host/file.jpg

Solution 2:
If you don’t want to provide a user agent each time, put the following your ~/.wgetrc file:

# custom .wgetrc file
user_agent = Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0

Then:

wget http://host/file.jpg

Audio pronunciation of words from Google

March 27, 2012 Leave a comment

Amit Agarwal has a nice post entitled “Download the Audio Pronunciation of Words from Google“.

In short
Take the following template URL:

https://ssl.gstatic.com/dictionary/static/sounds/de/0/WORD.mp3

And replace WORD with the word you want to hear pronounced. With mplayer and vlc I couldn’t play them directly, first I had to download them with wget.

Examples:

Update
This is implemented in my jabbapylib library, see here.

Categories: google Tags: ,

RUIN – An animated short set in a post-apocalyptic universe

March 25, 2012 Leave a comment

RUIN – An animated short set in a post-apocalyptic universe.

 

Thanks Jeszy for the link.

Categories: Uncategorized Tags: , ,

mc problem: cannot chmod target file, operation not permitted

March 25, 2012 Leave a comment

Problem
With mc, you want to copy lots of small files to an NTFS partition. However, for every file it drops a warning: “cannot chmod target file”. Either you switch to root or you sit next to the keyboard and press Skip for every single file. WTF?

Solution
When you press F5, untick the option “Preserve attributes“. Done.

Minitube – a YouTube desktop application

March 22, 2012 Leave a comment

Minitube is a YouTube desktop application. With it you can watch YouTube videos in a new way: you type a keyword, Minitube gives you an endless video stream. Minitube is not about cloning the original YouTube web interface, it aims to create a new TV-like experience.

Installation

sudo apt-get install minitube
Categories: ubuntu Tags: , ,

Launch Software Sources from the command-line

March 22, 2012 2 comments

Problem

Canonical started to integrate everything in the Ubuntu Software Center. Software Sources is available from this, but how to launch it from the command-line?

Solution

gksudo software-properties-gtk

Updated according to the comment of gourki.

Categories: ubuntu Tags:

Create a shared folder in Virtualbox

March 22, 2012 Leave a comment

Problem
You have a guest operating system in Virtualbox and you want to exchange some data between the host and the guest. For this purpose you want to use a shared folder. The shared folder should be writeable in the guest too.

In my case I had two Ubuntu systems as host and guest.

Solution
There are several guides for setting up a shared folder (one, two). In short:

  • create a shared folder on the host (e.g. /opt/shared.folder.vbox)
  • create a shared folder on the guest (it can have the same path, e.g. /opt/shared.folder.vbox)
  • install guest additions under the guest (Devices -> Install Guest Additions…), then restart the guest
  • under the guest, go to Devices -> Shared Folders… Under Shared Folders, add the path of your shared folder (here /opt/shared.folder.vbox). You can tick Auto-mount and Make Permanent if you want. Note that in my case, although I selected these two options, the shared folder was not mounted automatically.

Make the shared folder writeable
On the guest, you can manually mount the shared folder with the following command:

sudo mount -t vboxsf shared.folder.vbox /opt/shared.folder.vbox

As I figured out, only root can mount a shared folder.

However, it mounts the folder in read-only mode! To make it writeable, I had to add the following line(s) to /etc/fstab under the guest:

# shared folder
shared.folder.vbox /opt/shared.folder.vbox vboxsf defaults,rw,auto,uid=1000,gid=1000 0 0

I use the system as a normal user called jabba, and 1000 is its user id and group id. It can be found in /etc/passwd (columns 3 and 4):

$ cat /etc/passwd | grep jabba
jabba:x:1000:1000:Jabba Laci,,,:/home/jabba:/bin/bash

After a reboot, this folder is still not auto-mounted :( You can mount it with:

sudo mount /opt/shared.folder.vbox

But now it should be writeable…

Auto-mount shared folder at each boot
Now let’s put the dot on the “i” :) If you want your shared folder auto-mounted at each boot, add this line to /etc/rc.local on the guest:

mount /opt/shared.folder.vbox

Make sure that it comes before the line “exit 0“.

BBC Science & Environment

March 21, 2012 Leave a comment
Categories: Uncategorized Tags: ,
Follow

Get every new post delivered to your Inbox.

Join 62 other followers