BigSmoke

Smokes your problems, coughs fresh air.

Page 41 of 52

Impossible to fix file collision when upgrading qt 4.3 to 4.5

I’m trying to upgrade my qt 4.3 to 4.5. Version 4.5 seems to be split up in several ebuils, one of which is qt-dbus. When trying to install qt-dbus, it says that the files conflict with qt-4.3. This is only normal, because in version 4.3, the files did belong to qt.

The thing is, some time ago, collision protection was disabled by default, which I thought made sense because when I tried enabling it, I’d get errors like these all the time. I disabled it for now (by putting “-collision-protect -protect-owned” in the FEATURES variable in make.conf), to be able to install Qt, but because it is enabled by default, I’d rather not keep it disabled.

(Text was copied from the post I made on the Gentoo forum about it.)

Really enabling portage compile cache

I always thought I had portage’s compile cache enabled, but upon recent inspection, it appears that I didn’t. What was missing, was the package dev-util/ccache. I also increased the cache size to 2 GB, as per the Gentoo documentation.

I noticed this because recently, portage started saying this:

!!! Directory does not exist: '/usr/lib/ccache/bin'
!!! Disabled FEATURES='ccache'

Correcting Spamassassins stale mirror configuration

My spamassassin updates daily by running sa-update. Recently, I’ve been getting failure notices that mirror spamassassin.kluge.net was no longer available. This was because of a known bug, apparantly. So, I deleted the MIRROR.BY file and ran sa-update again.

This caused problem number two: GPG key verification failed. This was also a known issue, so I had to do:

wget http://spamassassin.apache.org/updates/GPG.KEY
sa-update --import GPG.KEY

And then everything was OK again.

Adding locales in Ubuntu

I wanted the dates on my Kubuntu system to be shown as Dutch dates. Therefore, I needed to add a locale. The place to do it is in /var/lib/locales/supported.d/local. It now contains this:

en_US.UTF-8 UTF-8
nl_NL.UTF-8 UTF-8

Then run locale-gen to generate the locales.

Set the following environment vars (in profile or something) to let everything behave properly:

export LANG="nl_NL.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_COLLATE="C"

I don’t know anymore why I chose this specific configuration. I guess this means that everything, from thousand and decimal separators to dates is Dutch, and messages are English. I don’t know, however, why the collate is C. I vaguely remember something about it otherwise not including some characters in the sorting, causing weird sorting in words with dashes and such.

Gentoo update: WiFi drivers (iwl4965)

When I got the Wireless working on this laptop (a Lenovo T61), I was using Linux kernel 2.6.25. I remember that it was quite a pain, because the iwlwifi stuff had only just stabilized enough to replace the (now deprecated) ipw stuff. One of the things I didn’t get working at the time was Monitor mode.

Now, I’m upgrading to kernel 2.6.29, and there have been some changes to the kernel configuration for the iwl4965 driver. CONFIG_IWL4965 is now a suboption of CONFIG_IWLAGN. The wireless didn’t work on the first boot however. eth0 didn’t work either. But, when I changed the wired driver from “Intel PRO/1000 Gigabit Ethernet” (CONFIG_E1000) to the same for PCI-express (CONFIG_E1000E), it did work on the next boot and the wireless magically started working too. 😕

I was surprised because I don’t see what the wired and the wireless driver have got to do with each other. Also, before, I’ve always successfully used the non-PCI-express driver for my wired Ethernet interface and I’m so old fashioned that I can’t imagine either way that my hardware uses something so modern as PCI-express. 😛

Anyway, it works now. I’ve gone from kernel 2.6.25 to 2.6.29 and everything seems to be working. I still have to find out how to get Monitor mode working though.

One final thing I noticed is that upgrading net-wireless/iwl4965-ucode created an extra entry in my world profile: net-wireless/iwl4965-ucode:0. I wonder what that is for.

Customizing Google AdSense alternate ads

When AdSense runs out of inspiration (i.e.: no targeted ads are available), it displays public service ads by default. You can choose to replace this with a custom ad of your own choosing. To do this, you have to put a HTML page somewhere and change the alternate ads settings for the appropriate ad unit:

AdSense unit: alternate ads settings for HardhoutWiki leaderboard

Alternate ads settings for HardhoutWiki leaderboard AdSense unit

Instead of the public service ads, I wanted to serve a banner ad to promote our beautiful family vacation home. I created this image a few years ago for an AdWords campaign started by my uncle because he wanted to reach more potential vacation goers.

Schuilplaats banner ad

The 728x79 banner image

I put put up a page with the image at http://www.bigsmoke.us/schuilplaats-banner-ad/. The HTML is very simple:

<html>
  <head></head>
  <body>
    <a href="http://www.hugovandermolen.nl/schuilplaats/startpagina.php"><img src="schuilplaats-banner-ad.jpg" /></a>
  </body>
</html>

If anyone wants to promote our vacation home for free, all they have to do is to change Alternate ads or colors to Show non-Google ads from another URL and fill in http://www.bigsmoke.us/schuilplaats-banner-ad/.

Although I put the alternate ad up over a year ago, I was prompted to blog about it because two months ago, for the first time, I suddenly saw the ad actually being serviced on my Dutch HardwoodWiki:

The alternate ad in action

The alternate ad in action

Complete WordPress Atom feed: an XSLT transformation

Previously, I tried obtaining a full Atom feed without pagination from WordPress. I didn’t succeed, so I ended up writing an XSL transformation which merges all the pages of this Atom feed into one valid Atom XML stream.

The transformation: wordpress-full-atom-feed.xsl

<?xml version="1.0" encoding="UTF-8"?>
 
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:thr="http://purl.org/syndication/thread/1.0"
xmlns="http://www.w3.org/2005/Atom">
 
<xsl:param name="base_url" select="atom:feed/atom:link[@rel='self']/@href" />
 
 
<xsl:template match="/">
  <xsl:apply-templates select="node()" />
</xsl:template>
 
<xsl:template match="*">
  <xsl:element name="{name(.)}">
    <xsl:apply-templates select="node()" />
  </xsl:element>
</xsl:template>
 
<xsl:template match="@*|node()">
  <xsl:copy-of select="." />
</xsl:template>
 
<xsl:template match="atom:feed">
  <feed>
    <xsl:apply-templates select="@*|node()" />
 
    <xsl:call-template name="process_feed_page">
      <xsl:with-param name="page" select="number('2')" />
    </xsl:call-template>
  </feed>
</xsl:template>
 
<xsl:template name="process_feed_page">
  <xsl:param name="page" />
 
  <xsl:variable name="page_doc" select="document(concat($base_url, '?paged=', $page))" />
 
  <xsl:if test="$page_doc/atom:feed/atom:entry">
    <xsl:apply-templates select="$page_doc/atom:feed/atom:entry" />
  
    <xsl:call-template name="process_feed_page">
      <xsl:with-param name="page" select="$page + 1" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>
 
</xsl:transform>

The transformation works by processing the atom:feed element. Before closing that, the process_feed_page template is called. This template tries to open the next page and process all atom:entry elements in there. Then it tries to recurse to the next page.

The next page’s URL can be guessed because this is the normal feed URL with ?paged=[pagenum] appended to it. The feed URL can be found because WordPress adds it to the feed:

<link rel="self" type="application/atom+xml" href="http://blog.bigsmoke.us/author/halfgaar/feed/atom" />

For very old WordPress versions this doesn’t work, because the paged parameter isn’t supported there. Also, older versions might require you to supply the $base_url param to the XSLT processor, because the rel='self' link is incorrectly set to the URL of the default feed within all other feeds (such as the author feed or the tag feed).

Invocation

Invocation is simple. I use libxslt‘s xsltproc:

xsltproc wordpress-full-atom-feed.xsl http://blog.bigsmoke.us/author/halfgaar/feed/atom

That’s it. You end up with a full feed as if there never was any pagination to begin with; it almost looks as if WordPress does support the nopaging option for feeds.

Enforcing Drupal URL aliases

I hate modules, especially core modules. I prefer code to be tightly integrated. I want it to work together. Is that too much to ask? In Drupal, most functionality has been stuffed in modules. There’s a Locale module, a Content Translation module and a Path module. What’s missing is a Working Together module.

For me, clean, meaningful URLs are a number one, two and three requirement for any website that I do. Drupal considers /node/54673 to be a cool URL. I don’t. So, as a kind of afterthought, Drupal comes with the Path module. This module allows you to set URL aliases per node.

The problem is that there’s no concept of a canonical URL. The URL alias works, but so does the node/3242 URL. Neither redirects to the other. In many cases this is not much of a problem (because regular visitors will not notice this) but for our current project it is.

We have a lot of blocks with URL dependent visibility settings. For example, for a section about investing we have a menu that is displayed on all URLs starting with /investing, such as /investing/projects and so on.

After editing a page, Drupal helpfully redirects the user to node/[nodenumber]. For us, this means that the menu is no longer displayed and even the theme will be wrong. (We use the Sections module to select a subtheme based on which section you’re in.)

Global Redirect doesn’t work

The Global Redirect module promises to solve this by allowing you to redirect node/[nodenumber] URLs to their alias if available. It kinda does, in some circumstances.

Our Drupal website sports two languages: English (EN) and Dutch (NL). English is the default language (not the fallback language; we don’t use a fallback) and doesn’t use a prefix. Dutch uses the nl prefix. Two example URLs:

URL alias Generic URL
http://www.example.com/investing/projects http://www.example.com/node/288
http://www.example.com/nl/beleggen/projecten http://www.example.com/nl/node/110

When /node/288 is requested, the client is correctly redirected to /investing/projects, but when /node/110 is requested, no redirect takes place. It will take place when prefixing /nl, but this is completely useless since Drupal’s built-in actions such as edit don’t redirect using this prefix, and these actions were what we needed this module for in the first place.

A very simple hack that does work

We ended up tearing our hair out trying to fix Global Redirect until we decided that we could just delete the module and replace it with a RewriteRule and a simple PHP script.

Modify: .htaccess

# Put this after RewriteBase and before Drupal's default rewrite rules
RewriteRule ^(../)?node/([0-9]+)$ fixurl.php?nid=$2 [L]

Add: fixurl.php

<?php
 
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
 
$result = db_query("SELECT * FROM {url_alias} WHERE src = 'node/%d' LIMIT 1", $_GET['nid']);
if ( db_error() ) die("O agony!");
 
$url_alias_object = db_fetch_object($result);
$destination = $url_alias_object->dst;
 
$result = db_query("SELECT prefix FROM {languages} WHERE language = '%s'", $url_alias_object->language);
if ( db_error() ) die("O agony!");
 
$prefix = db_result($result);
 
if ( !empty($prefix) )
  $prefix .= '/';
 
header("Location: /$prefix$destination",TRUE,301);
 
?>

Shortcomings in our hack

The code assumes that every content page has an URL alias. For us, this is okay, because we need these pretty URLs to even have menus show up or to have the right page be displayed with the right theme.

Also, this code is specifically tailored to language code in the URL prefix. For subdomain based language selection, for example, you’d need to modify it.

Gentoo update: system

This Gentoo box needs upgrading badly. I started this in February, so perhaps it’s time to continue.

Trying to update the world profile causes a few too many problems, so I start with updating everything in the system profile:

# emerge --update --deep --newuse system

sys-apps/man-pages

The first blockage of the day is “sys-apps/man-pages-3” that is blocking “sys-apps/man-pages-posix-2003a“. The latter is pulled in by “sys-apps/man-pages-posix“, which in turn is required by “sys-apps/man-pages-3.20“.

Somehow, unmerging “sys-apps/man-pages” resolved this blockage:

# emerge --unmerge sys-apps/man-pages

I just had to ignore a few warnings about the package being part of my system profile and I could reissue the system update command. The unmerged package is neatly remerged.

# emerge --update --deep --newuse system

This command started merging 99 packages. The only interruption left in this process was caused by the savedconfig use flag which made the busybox ebuild fail.

With Vimperator it almost feels as if I can control Firefox

Wednesday, after returning to Groningen from Barcelona, I saw Ying using Vimperator. I was sold immediately.

I like to use the keyboard. Point and click is not really my cup of tea. It just doesn’t work without a touch screen. (A while ago I had the opportunity to see an expensive tilt-able touch screen in action and I was quite impressed by how suddenly a GUI became less of a disaster.) I’m an avid VIM user. Although I’ve tried training myself to Emacs, I’ve never made the switch. Even if I would have, this wouldn’t have changed the fact that I’m a shell person, not a desktop person.

Editing in an external editor

I do a lot of writing from my web browser (Firefox). This is not the most enjoyable activity imaginable using the typical <textarea>. It’s not that HTML textareas are so bad, it’s just that I don’t like typing anything extensive without using VIM.

The It’s All Text! Firefox add-on is one way to solve this problem. It adds a small “edit” button to the bottom right of all textareas. (It also adds a context submenu, but this can only be used to edit the whole page’s source (which I found to be a little bit disappointing as I’d rather seen that this acted on just the textarea when going there from a textarea).) The button executes an external editor of choiseGVIM.

Using Vimperator, when in insert mode (inside a textarea), I just have to press Ctrl-i to execute GVIM. The It’s All Text! add-on has thus been deprecated.

Better WindowMaker integration

Due to my reluctance to switch to a tiling window manager, I’m still using WindowMaker. Starting Firefox in WindowMaker is a bit of a nuisance because the main window opens too far out beyond the top left of my workspace. The only way to change this is to tell it to start maximized. However, the main window and the dialogs have the same WM_CLASS and I was somehow annoyed with getting all the popups maximized as well.

Vimperator starts these windows within the browser tabs, so there’s no longer a good reason not to start Firefox maximized. This saves me another keystroke whenever I begin a new browsing session.

Modes

Normal mode
In normal mode, I can perform all navigational tasks quickly an concisely. Especially identifying and following links is revolutionary. No more remembering access keys for every web app. I can just press f and type a number. The View Access Keys extension is no longer necessary.
Insert mode
I had never considered how much a seperate insert mode would have made me feel more in control of Firefox. The fact that I can escape it and scroll a bit or follow a link before continuing to type is priceless.
Pass-through mode
There are many modern web applications such as Gmail that have keystrokes conflicting with Vimperator. The great thing about Vimperator is that it wins. But, by pressing Ctrl-z, you can make the web page win until you escape the mode.

There are more modes, but I’m not here to write a tutorial. 🙂

Scrolling

I have many of the scrolling options that I’m used to in VIM. Most importantly, I can scroll half a page instead of a whole page! Before, I’ve spent a lot of time mucking around trying to find out how to make Firefox do this and the only extension that seemed to be able to deliver was Firemacs which I shied away because it did away with many of Firefox’s default key bindings, which is ironic because Vimperator seems much more extreme in this regard. 😛

Flash focus

On thing that I would really like Vimperator to do is to disable Flash content from stealing focus. That would remedy the last type of situation where I simply don’t feel in control of my web browser.

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑