informative

What is Firefox doing now?

I had some time to kill, so I pulled up my system monitor and had a look. One thing bugged me: Firefox was doing something while I was not doing something with Firefox. So I dove into the settings and documentation and this long post deals with all the things I could find.

mod_rewrite rule to strip SSL: https to http

One problem with https is that it is not possible to do mass virtual hosting, because the certificate is connected to the hostname, but the hostname is determined by the request. Chicken and egg problem there. In the end you can make a snake-oil certificate for one domain, but it won't work with other domains. If you decide to strip https support for those people who find a way to get there, here is a .httaccess file that will do that:

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule ^.* http://%{HTTP_HOST}%{REQUEST_URI} [redirect=permanent]

cclive: Download flash videos from the Linux command-line

You may already know youtube-dl, a popular Python script which allows you to easily download a youtube video. Well, there is another program which mimics this behavior, but works for more then just youtube, and it's called cclive.

CClive started out as a perl program under the name of clive, but the C++ rewrite is simpler and has a smaller memory footprint. Cclive has the same usage as youtube-dl:

cclive <URL>

you can't get it simpler then that.

I wanted to use this, so I decided to package it for Ubuntu, there was no package available yet, so this blog entry is to tell you about my new PPA entry for cclive. Debian unstable has a package for it already, so for debian you can find it here.

The 0.5.5 release supported sites are

Programming safely with Python

People often say that Python is an easy language, but like other easy languages it is often harder to make sure you are working in a safe manner. I'm not talking about security, but bug-free.

A) Assert allot:

assert something == True #This must be true because...
assert isinstance(variable, int) #This algorithm only makes sense with intergers

Giving cgit a go on Ubuntu, a quick tryout tutorial

After being annoyed by the snapshot filenames of gitweb, I started looking around. A patch to fix the problem has already been submitted to the gitweb developers and if they see the need it will be part of a future release. Bored of waiting, I tried cgit.

cgit is currently at version 0.8.3 and still needs some testing and security checks before it gets to version 1.0 (according to their own README), but that is no reason not to try it out locally.

At the time of writing there are were no packages available, so I decided to create one and post in to my PPA. If you have apache set up and running and know a bit of what you are doing, get that package and let's take it for a spin.

gnome-power-cmd is dead, long live dbus-send?

The new Karmic is missing something that I used to use: gnome-power-cmd (formally gnome-power-cmd.sh). To fill this void, I had to dive into the internet to find what could replace it.

The idea behind gnome-power-cmd is that you could make suspend, hibernate and reboot calls from the commandline if you where logged in as normal user, not needing the root privileges. It was a userspace variant of the pm-utils (pm-suspend, etc.) which all need you to be root. The death of the command (which was simply a shell script) probably came with the HAL to DeviceKit transition. So, on Karmic it seems that neither HAL dbus messages, nor gnome-power-command calls will work. This is the closest thing I could find:

dbus-send --print-reply \
            --system \
            --dest=org.freedesktop.DeviceKit.Power \
            /org/freedesktop/DeviceKit/Power \
            org.freedesktop.DeviceKit.Power.Suspend

That should suspend your computer. You can substitute the Suspend with Hibernate if you want, although I haven't tried the latter as it doesn't work with my computer (on boot, it just ignores it and nothing is restored). A local replacement for gnome-power-cmd shown and downloadable below

A nice Python typo to have

I had this typo in my code, and it gives you the weirdest errors ever:

translation = range(20)
translation = [[i, str('Number %i' % i)] for i in range(20)]
print 'Translations set: ',[i[1] for i in translation]

#Split the list, so we only take the upper part
firstN = 5
print 'First %i translations' % firstN, [i[1] or i in translation[:firstN]]

If you have not seen the typo yet, what would you expect the output to be? The output is...

Python default arguments for C++ developers

Jumping into a new language can be allot of fun, but your pervious experiences may hurt you more then they help. A good example of that is jumping into Python with C++ experience and trying to use default arguments. Simply enough you say, after doing some of

def fun(a = 0):
  print a
  a = 10
  print a

fun()
fun()

You can sit back and think you have seen that all before. However, today I discovered there is actually a twist here. What do you think the following code will produce?
def fun(a={}):
  print a
  a['hello'] = 'good'

fun()
fun()

Will the hello ever appear on the standard out?

Open up DAAP for the local networks using ufw

To open up your ufw firewall for DAAP on the local network (ipv4 rfc 1918), you can issue the following:

sudo ufw allow proto tcp from 10.0.0.0/8 to 10.0.0.0/8 port 3689
sudo ufw allow proto tcp from 172.16.0.0/12 to 172.16.0.0/12 port 3689
sudo ufw allow proto tcp from 192.168.0.0/16 to 192.168.0.0/16 port 3689

To delete them again, use the same but with "delete" just before "allow".

logfish the definition

Why logfish.net? Well, I ran through the freedict dictionary and brute-forced my way to a new dictionary word with not too many letters. Also it has "log" in it, so I thought that was cool.

For historical reasons, I decided to just copy the dict.org defenition and make sure it is kept here for all to see.

Syndicate content