Archive

Archive for April, 2012

Listening to Pandora Radio

April 30, 2012 Leave a comment

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.

Categories: firefox, python Tags: , ,

The Batman Equation

April 30, 2012 Leave a comment

Click on the image for more info. Thanks Jeszy for the link.

Categories: math Tags: ,

Ubuntu tweaking softwares

April 28, 2012 Leave a comment
Categories: ubuntu Tags:

Dropbox: don’t sync certain directories; empty the cache

April 28, 2012 Leave a comment

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)

April 28, 2012 2 comments

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.

Tips from here: 1, 2.

Ubuntu 12.04 — Precise Pangolin

April 27, 2012 Leave a comment

Precise Pangolin has arrived. I updated my home machine yesterday, no problems at all. I also updated another machine, went like a charm. Some of the tips below are from here.

Some minor issues
Last time I installed xscreensaver and removed gnome-screensaver. However, this time locking the screen didn’t work. So I put back gnome-screensaver: “sudo apt-get install gnome-screensaver“. Note that when you press CTRL+ALT+L, the following file will be called: /usr/bin/gnome-screensaver-command.

On ubuntu.com, it’s still the 32-bit version that is recommended :( Here is a discussion about it.

When I wanted to upgrade, the installer complained about the skype and acroread packages, so I removed them. After the upgrade I couldn’t put them back on one of my machines. I have a 64 bit system and these packages are 32 bit, so they require some 32 bit libraries. However, one of them had a conflict with its 64 bit equivalent. I hope this issue will be resolved.

I also had problems on one of my laptops (a Dell Latitude D410). The live CD stopped booting. It turned out it was because of the b43 wifi card. Read more about it here.

I’ve found another great tweaking tool called unsettings. Read more about it here. In 12.04 the Launcher is always visible on the left side. With unsettings you can easily change that. Also, you can disable the global menu and overlay scrollbars with a click. You can also change the activation trigger of the Launcher from the left edge to the top left corner.

You can add a weather indicator too to the top panel: “sudo apt-get install indicator-weather“. Launch indicator-weather and add it to your startup applications.

Some autostart items don’t show up in the Startup Applications dialog. To get all of them to show up, use the following command (tip from here):

sudo sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop

Update (20120915)
If you hate the Global Menu (File, Edit, etc.) appearing on the top bar instead of the application bar, you can remove it like this:

sudo apt-get remove appmenu-gtk3 appmenu-gtk appmenu-qt

Then log out and log back in. This tip is from here.

Calculating the average incrementally

April 25, 2012 Leave a comment

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:


That is:


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.

Categories: math, python Tags: ,

Firefox error message

April 24, 2012 Leave a comment

Err, OK, I guess :)

Categories: firefox, fun

USB drive not mounted in Virtualbox guest

April 24, 2012 1 comment

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

April 24, 2012 Leave a comment

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
Follow

Get every new post delivered to your Inbox.

Join 61 other followers