Archive
Listening to Pandora Radio
Problem
You wanna listen to Pandora Radio outside of the US.
Solution
Well, I already have a proxy explorer script that finds working US proxies. You can choose one and update the proxy info in the FoxyProxy Firefox add-on.
However, updating the proxy info manually is tiring. So I made another script that updates the config file of FoxyProxy (here is my foxyproxy.xml). In order to force FoxyProxy to see the new settings, you’ll have to restart the browser.
The script is available here: pandora.py.
Update (20121110)
If you want to listen to Pandora Radio, there is an easier method.
Ubuntu tweaking softwares
Dropbox: don’t sync certain directories; empty the cache
Problem
I have a laptop with a small HDD. I want to use Dropbox on it too but in this case I hardly have any free space left. Could I select certain directories that I don’t want to see on my laptop?
Solution
Yes, it’s possible. Here is a detailed description how to do that. In short: go to Dropbox -> Preferences…, select the Advanced tab and click on Selective Sync… Here untick the directories that you don’t need on your current machine. When you click on Update, these directories will be removed from your local Dropbox folder but they remain on the server, so there is no need to worry. They are simply not synced with the current machine.
However, you may notice that after Dropbox has removed these directories, you still don’t have more free space :( Well, the dropbox client put the deleted files in the cache… Here is how to empty the cache. In short: stop the client, delete the content of the cache folder (but leave the cache folder itself), restart the client.
Ubuntu 12.04 stops booting (b43 wifi problem)
I had problems installing Ubuntu 12.04 on my Dell Latitude D410 laptop. As it turned out it was because of the b43 wifi card. But let’s see the story step by step.
First, I couldn’t install the system from the normal install CD. The boot process simply stopped. So I downloaded the alternate CD. The installation went fine but when I rebooted the machine, it froze again… WTF? I got the following error message:
[ xx.xxxx] b43-phy0 ERROR: firmware file "b43/ucode5.fw" not found [ xx.xxxx] b43-phy0 ERROR: firmware file "b43-open/ucode5.fw" not found [ xx.xxxx] b43-phy0 ERROR: You must go to http://wireless.kernel.org [snip] read all the instructions on this website.
OK, so the firmware of the wifi card is missing. Let’s disable the wifi then. The following line should be added to /etc/modprobe.d/blacklist.conf:
blacklist b43
Here is how I did it: start the system with a 11.10 live CD (which doesn’t freeze), mount the root partition of the laptop, then modify the blacklist.conf file.
After reboot, the system didn’t freeze but, obviously, I had no wifi. Connecting a cable, I could install the following package:
sudo apt-get install firmware-b43-installer
Edit blacklist.conf again and enable b43 (put that line in comment). After restart I had wifi.
Calculating the average incrementally
This entry is based on Sándor Norbert’s post on Incremental average calculation.
Problem
I have a large list with very large numbers and I want to calculate their average. However, I’m afraid there would be an overflow while summing up the elements.
Solution
The traditional average computation first calculates the sum of the elements and then this sum is divided by the number of elements. However, the average can be calculated incrementally too, i.e. you take the 1st element and you calculate its average, then take the 2nd element and update the average, and so on. When you process the last element, you have the average of the whole list. Let’s see it mathematically.
Recall the traditional average:

Now let’s see the incremental formula:

Thus, the average up to i elements:

The algorithm in Python:
def inc_avg(li):
"""Calculate the average incrementally.
Input: a list.
Output: average of the list."""
left = 0
right = len(li)-1
avg = li[left]
left += 1
while left <= right:
curr = left + 1
avg += (li[left] - avg) / float(curr)
left += 1
return avg
Experimental results
TODO: compare the runtime of plain average with this incremental solution.
USB drive not mounted in Virtualbox guest
Problem
I have a Linux host with a Windows 7 guest in Virtualbox. I want to transfer some big files to the Windows guest via a USB stick but the Windows guest doesn’t see the attached USB stick. What to do?
Solution
I didn’t find a proper solution but I have a workaround. In Virtualbox, before booting up the guest system, you can specify a CD/DVD image under Settings -> Storage (see this figure). This image will be mounted and will be visible in the guest.
So, collect the stuff you want to transfer in a directory, convert the folder to ISO image format and mount this image file before booting up the Windows guest. Works for me :)
Another solution is to set up a shared folder but I haven’t figured out yet how to do that.
Create an ISO image from a directory
Problem
You have a directory that you want to convert to ISO image format.
Solution
Here I found several ways how to do that. I liked acetoniso and genisoimage.
acetoniso: install it with “sudo apt-get install acetoniso“. It has a graphical interface. Under Image Conversion, there is a menu point called Generate ISO from folder. It will pop up two file dialogs, don’t be surprised. First choose the folder to be converted. Then specify the name of the ISO output.
genisoimage: install it with “sudo apt-get install genisoimage“. It’s a console application. Use it the following way:
genisoimage -o my_image.iso my_directory


