Archive for the ‘Computer-related’ Category

I am one of the [many] happy users of Dropbox. I use it to synchronize my files, primarily those related my work and my PhD thesis, between home and lab computers. So far, Dropbox has proved to be a quick, light and flawless tool.

There’s one thing that annoyed me every time I stumbled upon it — it’s the behavior of the “Open Dropbox Folder” menu item. I assume that a click on this item, or just on the Dropbox icon in the tray, should open the local Dropbox folder in the system-specific file manager. In reality it opens a web browser and there’s no obvious way to change this. Maybe this feature works correctly under Gnome, since the dropbox package contains Nautilus extensions. I don’t use Gnome and don’t have Nautilus installed to check this. Instead, I use Trinity desktop and I want my Dropbox folder opened in Konqueror. A bit of googling and observation revealed the solution.

First of all, I wanted to know how the dropbox daemon chooses a browser. It turned out that, when the daemon needs to open a browser, it looks at the system preference for “x-www-browser”. This means that dropbox opens a browser that /etc/alternatives/x-browser symlink points to. In my case it was Chromium. Changing the system preference by issuing
sudo update-alternatives --config x-www-browser
resulted in a desired browser being launched. Well, it’s better now, but still far from what I wanted.

When the daemon is launched from a terminal, a click on the “Open Dropbox Folder” sends a message back to the terminal:
Warning: unknown mime-type for "/home/vitalie/Dropbox" -- using "application/octet-stream"
Error: no "view" mailcap rules found for type "application/octet-stream"
No applications found for mimetype: inode/directory

Aha, so dropbox first looks for an application to handle directories and then, if nothing is found, resorts to browsers! Very well, now I have to figure out how to assign this inode/directory mimetype to Konqueror.

Mimetypes (what does it mean, by the way?) are assigned by issuing something like xdg-mime default application_name.desktop mimetype_name. In my case it was
xdg-mime default konqueror.desktop inode/directory
Now a click on “Open Dropbox Folder” opens my local Dropbox folder in Konqueror.

P.S.: I worked only after I copied the konqueror.desktop file from /opt/trinity/share/applink to ~/.local/share/applications.
P.P.S.: It would probably be easier to edit file associations in Trinity Control Center, aka Kcontrol.

Copying files between computers

Posted by Vitalie Ciubotaru

The main problem that arises when using several computers is how to keep files synchronized. There are dozens of solutions, and mine is probably not the optimal one. However, these tricks work out for me and I want to share. Besides, I just want to put down some of those long pipes I constructed, so that I don’t need to keep them in my mind. (more…)

Idea: anonymous community

Posted by Vitalie Ciubotaru

From time to time I read about anonymous boards, sorta open-entry communities, formed around some phenomenon. The first example of such board is, of course, 4chan (no, I never read it — the “of course” is solely due to the large number of references to that particular website). As far as I know, anyone can post there and no registration/authorization is required. Very impressive, but… (more…)

Searching for data is always frustrating. While updating (or rather extending it back into the past) my personal database on CPI inflation I had to make my way through the jungle of different formats, time-spans, frequencies etc. that come from different statistical bodies (by the way, of all statistical agencies I checked out these days, UK’s Office for National Statistics is the weirdest! Just my humble opinion, of course).

When there was just a couple of gaps left, I turned to They got a nice web-site and, more importantly, they got data I needed. Unfortunately, there was no easy way to export these data — one has to select part of the page, paste it somewhere and clean it of rubbish like text and percentage marks. It would take ages to rip all those sparse figures … but wait, I got a perfect toolkit for this kind of job. After five minutes of “googling” and fine-tuning the tools my one-line monster script was ready. Here’s how it looks:

for i in {2006..2011}; do curl -s${i}.aspx | grep "nbsp;%" | cut -d"<" -f2 | cut -d">" -f2 | cut -d"&" -f1 | awk 'NR % 2 == 0' | sed 's/$/+100/' | bc -l; done

This script crawls through all webpages that contain the data I need, searches for my figures, formats them into a human-readable form and displays them. Of course, it can be further improved, say, to add a date column, write data to a file etc., but it’s already done the job and I probably won’t need it any time soon. I just couldn’t resist bragging a bit about my script (and praising the unix-way, of course!).

.bit domains: rather dead than alive

Posted by Vitalie Ciubotaru


Several months ago (probably at the end of September 2011) I came across the Namecoin. This is what I want to talk about today.

What are namecoins?

Unlike Bitcoin, the Namecoin project is not all that much about money, although namecoins can be and are traded against bitcoins and real money. More than anything else, it’s about the new first-level internet domain, the “dot-bit”, they created. Having some namecoins (or should I say “namecoin” since the coins are almost perfectly divisible and due to this exactness are often uncountable) allows one to register and administer an address ending in “.bit”, like http://www.example.bit. One doesn’t need to apply to a registrar (although it’s possible) — it would suffice to run the namecoin software and issue a single command.

An idea

After I grasped the general concept of namecoins and *.bit domains, I wondered how easy is it to register a domain and to have it running. I also wanted to know how many domains were registered and how how many of them are active. For this purpose I decided to register a domain, to assign it to an IP, to set up a DNS-server, to count registered domains, to set up a search engine, and — finally — to index all .bit domains. My humble attempts of merged-mining did not yield enough namecoins to register a domain and it was only due to the Namecoin Faucet that I collected a sufficient amount for my experiments.

Registering a *.bit domain

The command to pre-order a domain is
namecoind name_new d/yourdomainname
where yourdomainname is the desired name without the “.bit” part. If everything is OK, a transaction identifier and a short ransom number are displayed. The domain name is registered by issuing
bitcoind name_firstupdate rand json
where rand is the random number from the previous step and json looks like can have many forms, but generally looks like ‘{“ip”: “”, “map”: {“”: “”, “www”: “”}}’. It will take some time for everyone namecoin server to update their .bit address database.

Counting the bucks

So I registered a domain and assigned it to a real IP address at a free hosting. Of course, I could not see my new website in the browser — my provider’s DNS server knew nothing about websites ending in .bit. So I need a DNS capable of resolving .bit addresses. But first I want to know how many domains ware there. For this I downloaded a small and simple utility from, compiled it and ran
./namecoin-hosts rpcuser rpcpassword > hosts.txt
where port, rpcuser and rpcpassword are taken from ~/.namecoin/bitcoin.conf. OK, now we have a file that contains all registered .bit domains. To find out how many addresses there are, we just count the lines:
wc -l hosts.txt
At this moment there are 13712 websites, which include duplicates with and without the trailing “www.”.

Setting up a dot-bit-compatible local DNS-server

There are dozens of solutions with similar functionality. I chose to use dnsmasq. Configuration is reduced to adding one line to /etc/dnsmasq:

to be continued

Understanding gnuplot

Posted by Vitalie Ciubotaru

When it comes to graphs, gretl has a very good interface. This is why sometimes I open gretl not for another regression, but simply to create another graph. On the other hand, the default settings for graphs in gretl are a sort of “one-size-fits-all”, so I often have to fine-tune the graphs before saving them as image. The need to to repeat many steps for every single graph can be annoying — e.g. I save the graph, close gretl and then discover that the title is mis-spelt.

In order to avoid these unnecessary repetitions I looked at gnuplot. gnuplot is a plotting software that can produce very expressive graphs. Actually, it’s gnuplot that produces graphs for gretl, but calling gnuplot directly, without relying at gretl, gives us much more control over the final result.

For the sake of exersice, I used data on Moldovan consumer prices, which I use in my research, to test-drive gnuplot. A bref look at the data:

$ cat cpi_monthly.csv

and so on up to December 2011.

OK, let’s plot the last eleven years.
$ gnuplot
set datafile separator ","
set xdata time
set timefmt "%YM%m"
set xrange ["2000M01":"2011M12"]
set format x "%Y"
set yr [-.05:.05]
set xzeroaxis lt 0 lw 1 linecolor rgb "black"
set style line 1 lt 1 lw 1 pt 3 linecolor rgb "blue"
set title 'CPI inflation (log monthly changes), 2000-2011'
plot "cpi_monthly.csv" using 1:2 notitle w line ls 1

Yes, if one creates graphs from time to time, then it will look like too much code. However, if one needs to produce many graphs with the same look-and-feel, one can reuse this code for multiple times, with only minor changes. Below is the result (click to enlarge).

CPI inflation (log monthly change), 2000-2011

CPI inflation (log monthly change), 2000-2011

Building a case for my mini-ITX board

Posted by Vitalie Ciubotaru

Previous posts on this topic:

* * *

There’s a dozen of questions that I have to answer before embarking for this adventure.

  1. What shall I do about hard disks? If I want to have a hard disk (or two) inside the box, then I’ll have to provide space for it and to think about some sort of mounting rack/case to fix the disk to. If all disks will be outside, the size of the box will be much smaller, but there will be extra cables to plug/unplug every time I want to connect a disk (this is especially unpleasant with SATA disks, which, to my surprise, seem to require extra power even when connected to USB). Inside is better.
  2. What shall I do about power supply? One way is to use the standard ATX power supply I own (and use right now). The other is to find a cheap DC-DC adapter board (like in car computers) and use a laptop-type PSU. Besides these obvious options, I could get a smaller PSU (like TFX, SFX, FlexATX) and toss it inside. Gotta find out what dimensions they have.
  3. What shall I do about cooling? The easiest (and coolest, to me at least, would be to leave two opposite sides uncovered and to drill several holes right above the CPU radiator. Additionally, I could mount a fan somewhere. This shouldn’t be difficult — although it’s a fanless board, it preserves connectors for a CPU fan and a system fan.

Then there is a series of less important questions:

  1. Shall I use the onboard USB connectors and have USB ports on the front panel?
  2. Shall I use the onboard Audio connectors and have extra Audio on the front panel?
  3. Shall I use the PCI slot? If yes, what shall I insert in it — a WiFi, an IDE riser card, another Ethernet card, a CF card reader, or…?
  4. Shall I add another 2Gb of RAM?
  5. What about NAND Flash memory?
  6. What to do with the front panel leds and buttons? Making a button myself is not exactly a trivial task, but tapping a screwdriver to the power switch headers on the board every time I need to turn it on is not a good solution either.

Anyway, I have already purchased a 300x450x3 mm sheet of black plastic (have no idea how that material is called). If With luck I think I can do with this amount of plastic.

UPDATE (Oct. 24) The set of two six-wire cables (power switch, HDD and power leds, no reset switch) that I bought on ebay arrived today. A two-way IDE-to-SATA and a 3.5IDE/2.5IDE/SATA-to-USB adapters are still somewhere on their way.

UPDATE #2 (Nov. 1) The 2-way SATA-IDE converter arrived today. It is a bit different compared to the picture on eBay — it has a couple of jumpers, which miss on the original picture. It took me a while to figure out the correct position of the jumpers and get it working. First, there is a legend to the jumpers, but it’s on the other side of the board. Second, to make it work one has to connect power to both the disk and the board, which is counter-intuitive. Anyway, after several tries I connected my 3.5” IDE disk and I can access my pictures again.

UPDATE #3 (Nov. 2) The everything-to-USB adapter is here. I did not test it yet, but it looks so simple that I can’t image what can go wrong.

UPDATE #4 (Jan 10, 2012) A trip to Akihabara resulted in a small (TFX?) power supply box.

* * *

Followup posts on this DIY project:

DYI computer based on an Atom miniITX board

Posted by Vitalie Ciubotaru

Usually, when I travel around Kansai, it’s sightseeing that I’m mostly interested in. Every time I try to visit a new place and in most cases I don’t visit the same place more than once. However, there’s one place I tend to visit again and again, although I don’t see any noticeable changes about it. The place is called Den-Den Town.
I don’t go there to buy something specific, just for sightseeing. Most of the time I can’t restrain myself from buying another [useless] piece of computer hardware. My last visit resulted into a new motherboard, RAM and a hard drive. Almost an entire computer :-)

The motherboard is an Atom-based mini-ITX fan-less board made by Foxconn. A small and quiet board is one of those things I’ve been pondering about for months, reading reviews, looking at Ebay price tags and swinging between utility and passion. Usually I focused my attention on VIA’s C3/Eden/C7 boards — they are cheaper, though less productive. The purchasing decision was pretty much spontaneous — I just came across several mini-ITX motherboards. This board happened to be cheaper than the VIA-based competitor, so the decision was made.

A quick look at the specifications revealed that it requires DDR2-800 (aka PC2-6400) type memory and SATA-type hard disks. I didn’t have either, so two other purchases followed: a 2 gigabyte memory module and a 40 gigabyte disk. To make a working computer I needed to add a power supply, a display, a keyboard and a mouse.

Until now all computers that I had to (dis-)assemble were based on Pentium III, so I was a bit surprised to find out that the power supply should have 24 pins instead of 20 pins, and that a new beast, called “P4 connector”, emerged from nowhere. Luckily, the power supply unit that I found in my computer case was the right type. Add my spare keyboard, a nobody’s display I found in my lab and my stylish black-and-yellow mouse that reminds me of Lamborghini Diablo and Need for Speed 3, and the DYI computer is ready. By the way, there’s a real lot of nobody’s hardware, mostly junk produced 10 to 15 years ago, probably abandoned by folks who’d been imprisoned here before myself.

It’s time to turn it on. However, in order to see it run (or fly!) we need an operating system. First, I connected the SATA disk that I bought and an external disk (originally internal, taken from a deceased IBM Inspiron laptop, but turned into an external USB device) and switched the newly assembled computer on. “Switched” doen’t mean “pushed a button”, because the computer didn’t, and still doesn’t, have an on-off button. Instead, I had to use a piece of metal to connect the power-on pins on the board. The motherboard is fanless and thus absolutely quiet, which is why I could judge whether it’s booting only by the sound of the system beep and the old hard disk (the new one is very quiet, too).

It happily beeped and started booting. I hit “Delete” to make sure that both drives were detected, to see if the memory was the promised type and size, and simple to wander a bit through the BIOS. When I tried to adjust system clock the system hung, maybe because I used the numpad, not just up and down keys. Whatever was the reason, it was the only case of unexpected behavior so far. From the second try I successfully changed the time, then changed the first booting device to USB and happily booted into my Kubuntu/Trinity 10.10.

While I was googling and figuring out how to install an OS on the SATA drive (I only had an install CD), another surprise popped up — Atom is a 64 bit, not 32 bit, processor! Well, this meant that I would have to install a 64 bit version of Kubuntu. After some hassle (QEMU refused to load a 64 bit CD image, the image got copied onto a flash drive without the bootloader and refused to boot, GRUB2 refused to boot CD ISO from the hard disk etc.) I installed an OS on the SATA disk and finally booted into the shining new 64-bit version of Kubuntu.

Well, that’s where I am now — I’m writing this post from my barebone computer in my lab. There are two issues left on my agenda. First, I need to get some sort of casing for my new beast, and second, I need to come up with an idea about how to use it. Difficult questions…

I have almost zero experience working with plastic or wood, almost zero tools for such a project, and zero, without the “almost”, experience making computer cases, but if I am to use all the advantages that this computer offers (small size, no noise, portability etc.), then I absolutely need a case for it. I already bought a IDE-to-SATA adapter for my 3.5” IDE disks (I think I have three such disks and one of them holds all my photos) and a set of front panel connectors (power and reset switches, and power and HDD leds — I’ll finally be able to switch the machine without a screwdriver). Now I am choosing between wood and acrylic glass, and thinking about the size and shape of the future case. Anyway, I have a fallback solution: I can always give up and simply put everything in the old large case, where the PSU comes from.

The second question is how to use this machine. Should I turn it into a home file server (on local hard drives and on Dropbox, Ubuntu One etc.) and let it just sit around gathering dust somewhere in a corner? Should I design it as a portable nettop-like computer and carry it with me back and forth? Can it serve as a standalone WiFi access point with a web server (e.g. hosting a MMORG for my lab colleagues :-))? Other ideas?

* * *

Followup posts on this DIY project:

Batch rename images

Posted by Vitalie Ciubotaru

A bash script to rename images to their creation date and time.

# batchrename
# Change file name(s) to timestamp, preserving
# file extension(s)
# by Vitalie Ciubotaru
# August 17, 2011

renameit() {
# get extension

# check if destination file exists
new_filename=`ls -l --time-style="+%Y.%m.%d.%H.%M.%S" "$file2rename" | cut -d' ' -f6`
if [ -e "$new_filename.$extension" ]
echo "destination file for ${file2rename} exists. Appending extra characters"

# Appending characters
export i=1
while [ "$i" -lt 10000 ]
case ${#i} in
1 ) extrachar="000"$i;;
2 ) extrachar="00"$i;;
3 ) extrachar="0"$i;;
4 ) extrachar=$i;;
# test if file exists
if [ -e "$new_filename$extrachar.$extension" ]
# if so then pick next extra character
let i=$i+1
#if not then rename and proceed to the next file
mv -v $file2rename $new_filename$extrachar'.'$extension

# just rename and move to the next file
mv -v "$file2rename" $new_filename'.'$extension

# check if the filename is given
if [ -z $1 ] || [ $1 == "-help" ] || [ $1 == "-?" ]
echo "Usage: `basename $0` file-to-rename"
exit 1

# set the counter of renamed files
export rename_counter=0

# resolve wildcards and get a list of files to rename
for file2rename in $*
# first, check if file exists
if [ -f "$file2rename" ]
let rename_counter=$rename_counter+1
echo "File" $file2rename "does not exist."

# reporting results
if [ "$rename_counter" -eq "0" ]
echo "no files to rename"
echo "total: $rename_counter file(s)"

Memo to self: Joining avi files

Posted by Vitalie Ciubotaru

sudo apt-get install mencoder mplayer
cat part1.avi part2.avi part3.avi > joined.avi
mencoder -forceidx -oac copy -ovc copy -o output.avi input1.avi input2.avi input3.avi