Smokes your problems, coughs fresh air.

Category: Technology (Page 39 of 47)

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.

Drupal 5 image management

Today, I have to face the task of finding reliable Drupal 6 modules for image uploading and WYSIWYG editing, so I dug into my drafts bin and found an old unfinished post dated March 24, 2008 about a similar quest for Drupal 5:

I’ve founded this new website, www.worldwide-wilderness.com. (Don’t mention the name; I know it’s sheer genius.) Drupal is going to power the site. At least I hope it will. First, I have to somehow convince Drupal’s media management not to suck, so far to little avail. πŸ™ This post is my attempt at getting my thoughts straight. (It’s the logging in blogging that is of great help to me when, later, I can quickly pick up a problem where I left it. Also, sometimes, a better solution is thrown at me.)

So, Drupal: Drupal is great! The installation is a snap. The organization of the management interface is very intuitive and I love how interdependent modules are handled (i.e.: the fact that they’re handled). I ended up with Drupal in my search for a system which can power a weblog and a wiki at the same time. Drupal is a CMS framework which I had often come across but for some reason had never taken a closer look at. Much to my detriment, was my first thought during the configuration/exploration phase after installation.

Before I continue about Drupal, I should tell you something about what I want to do with www.worldwide-wilderness.com. Naturally, the topic will be wilderness. The site’s purpose is to popularize the wild, uncontrolled aspect of nature. I’m doing this because I’d like to see wilderness everywhere, but especially in your eyes. The site will mostly be a blog, with illustrated stories, podcasts and even video’s. But, we want to have the ability to add a knowledge base (with wiki power). And everything has to be integrated, much more deeply than in my Point Omega project where I simply installed MediaWiki and WordPress, each on their own subdomain.

Now, I need to make a selection from the many media management modules which are available for Drupal. Initially there will be some posts with many photographs on www.world-wide-wilderness.com. Uploading and annotating these one-by-one will take all the fun out of it, so I want this to be made easy. The modules which I choose will have to facilitate this.

  • EXIF extraction is an absolute must. IPTC extraction is optional, as long as the IPTC information is not stripped from the original images. If changes to the extracted data would be changed back in the original images, this would be especially nice.
  • Batch uploading is another requirement. I don’t care much whether this is through WebDAV, a Gallery2 API or even using a compressed archive, but I don’t want to upload images one by one.
  • A final wish is the mass editing of captions and/or other meta-data. I like very much how Google’s Picasaweb does this. If this works well, it could somewhat mitigate the need for EXIF/IPTC meta-data extraction.

Up till now I’ve tried the following:

  • The first thing to decide was whether to use the regular Image module or not. I chose yes because there are so many other modules which depend on this module. It comes with a few contributed add-on modules already. The included gallery module is quite to my taste, so that’s good.

  • When using the Image module, there are many options for inserting images. So far, I like the GUI of Image Assist for uploading and inserting single images. I do think that the button messes up the layout of the content creation page though. Also, a module like this is completely useless when you want to upload more than a few files, which I do. πŸ˜•

    Drupal content creation screen with the img_assist module enabled
    The content creation screen was so beautifully sober without the intrusive Image Assistant icons!

    There’s another module, Upload Image, which might be even better for uploading single images. I like that it integrates with the attachment functionality which keeps my screen clean and comes from a core module. What this module does extra is that it turns each attached image into an actual image node, opening up many advantages such as adding the attached images to albums and everything. If I keep using the Image module, this module will also remain part of my toolkit for sure!

    The Upload Image module is supposed to display thumbnails instead of filenames in the attachment list. It doesn’t for me. But there’s another module, Upload Preview, which does just this and only this. Too bad that this module doesn’t work. It seems easy enough to fix, so I might patch this if I decide to go this route.

    I haven’t tried Node Images. It doesn’t have a proper release yet, and I’m not sure what it’d add over the other attachment features.

    But, of course, there’s competition for the core upload module: File Field uses the Content Construction Kit to do the same.

  • The Exif module can only display Exif data at this time, while I want to extract at least a caption. Support for extraction is planned. David Lesieur, the author of the module is not actively developing the module at this point.
  • Independently from the Image module, I’ve tried the Asset module. This module doesn’t seem to like safe_mode very much and I think that its file picker/upload dialog is inferior to img_assistant’s.

Something I haven’t tried: I like the ideas of the Media Manager module, but it’s hardly feature-complete or even stable at this point.

Maybe in the end I’ll have to settle for using a service such as Flickr or Picasaweb with some integration module. That would be quite a bummer, actually.

Because I was in a time-squeeze at that time, having the images hosted elsewhere was actually the last-minute solution that I chose for anything more involving than a few loose images.

Then, there’s still audio and video, but I think I really have to save that for a later time, although if this makes me choose for a the Asset module, for example, I might be totally screwed if I’ve already come to depend on another (incompatible) set of modules for image management.

Also, there’s an annoying bug in Image Uploading module.

This post applies to Drupal 5, while both that website and the website I’m working on now run on Drupal 6.

As a sidenote, the upgrade from Drupal 5 to Drupal 6 at the time was a total disaster, probably due to all the messing with modules and ended up with me painstakingly reconstructing all content from an SQL backup. πŸ™

Styling XML SVN logs with CSS

My friend, Wiebe, keeps his website in Subversion. (Always keep your project files in version management or you’ll be sorry.) He used to manually track the date with the last significant change in each file (because who cares about typos, right?). But, of course, he kept forgetting to update this when he actually made such changes. So, he decided that he wanted to publish the full SVN log for each page.

The raw SVN logs are a bit raw, reason enough to try to turn it in something prettier. Luckily, there’s no need to parse the log files, because svn log has a command-line option, --xml. This option causes the log file to be printed in a simple XML format:

<?xml version="1.0"?>
<log>
<logentry revision="345">
<author>halfgaar</author>
<date>2009-05-25T10:50:07.560914Z</date>
<msg>Added very useful note to index about an awkward sentence.
</msg>
</logentry>
<!-- Snipped the rest of the logentry elements -->
</log>

Now we can use any number of ready-to-use XML tools to process this log, but I figured that, maybe, a very simple solution could work: CSS. Cascasing Stylesheets can be used for more than just styling HTML. One of the few differences is that with non-HTML XML, there are no defaults for the CSS properties (and aren’t we always trying to discover and override the various browser-specific CSS defaults anyway?)

First, we want to add a <?xml-stylesheet?> processing instruction to the log file:

svn log --xml example_file.xhtml | sed -e '/<\?xml / a<?xml-stylesheet type="text/css" media="screen" href="/css/svn-log.css"?>'

The XML file now references the CSS file that we’re going to make:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" media="screen" href="svn-log.css"?>
<!-- snip -->

svn-log.css:

log {
 :;
 :('http://svn.collab.net/repos/svn/trunk/notes/logo/256-colour/subversion_logo-200x173.png');
 :;
 :;
 :;
 :;
 : 2em 204px 2em 5ex;
}
 
logentry {
 :;
 :;
 : 1em;
 :;
 :;
 : #999;
}
 
author {
 :;
}
 
date {
 :;
 : 10ex;
  /* If Firefox would support font families even when you force a font,
     I could use 'overflow: hidden' to hide everything except the date part of <date>. */
 :;
 :; 
 :;
 :;
 : 110%;
 : #7488a7;
}
 
msg {
 :;
 : pre-wrap;
 :;
}

We now have a nicely formatted log file. Other things you could do:

  • Add styles for printing (in a separate stylesheet or by using @media blocks).
  • Display the revision author instead of hiding it.

Of course, you could do all this and much more with XSLT, but that’s just all too obvious. πŸ™‚

If you want to see the stylesheet in action, take a look at Wiebe’s website and look for a View revision log of this page link in the footer of any of his pages.

XML SVN log styled with CSS

XML SVN log styled with CSS

Some new (upcoming) PostgreSQL features

These are some random new PostgreSQL features that I’m interested in:

  • The EXECUTE USING feature in PostgreSQL 8.4 will allow the use of more secure dynamic SQL in PL/PgSQL.

  • User defined exceptions in PostgreSQL 8.4 are a very exciting feature to me. In our unit tests we often check if an exception is properly raised. However, for exception that we raise ourselves, we’ve never been able to check which exception is raised.

    Another exciting possibility is that this will allow us to come up with a very clean validation scheme that produces exceptions that we’ll be able to use in the client web GUI.

  • WITH queries in PostgreSQL 8.4 will allow some very cool things, the coolest of which is something that I’ve wished for on more than one occasion: recursion.

  • The introduction of proper support for the SQL standard XML Type makes me wish that my favorite web hosting provider would support a real database besides their standard MySQL offering.

  • Enumerated Types will make some of my table definitions slightly clearer.

    -- This isn't too shabby (thanks to the CHECK constraint):
    CREATE TABLE persons (
    the_gender CHAR(1) CHECK (gender = 'm' OR gender = 'f')
    );
     
    -- But, I like this much better:
    CREATE TYPE gender AS ENUM ('male', 'female');
    CREATE TABLE persons (
    the_gender gender
    );

Extra kudos to the PostgreSQL development team for their accelerating pace! πŸ˜€

Writing a MediaWiki Gravatars template

This is a tutorial for MediaWiki users who want to learn how to create and use templates.

One day, I was looking for a MediaWiki extension to include a Gravatar (globally recognized avatar) in my user page on one of my MediaWiki installations. I did find an extension, but I thought it to be no better than writing a template myself.

A MediaWiki template

In a MediaWiki installation, if you find yourself repeating yourself in a lot of pages, you can turn the repetitive content into a template. This template can then be included in any page where you’d otherwise duplicate the content. In fact, you can include any page, but most templates will live in a separate namespace: Template.

To include a template, put the template name inside double curly braces, like this: {{My template}}. For templates inside the Template namespace (most templates), you can omit the namespace part. This means that if your template page name is Template:My template, you will call your template as in the previous example ({{My template}}).

Template parameters

Parameterization is a fancy word for what programmers do when they don’t want a function to return the same value on each invocation. They add parameters to the function. MediaWiki templates support parameters.

If you have a template called Template:My template which contains “I say this very often, but not {{{1}}}.“, you can invoke it with “{{My template|quite often enough}}“, you’ll get the text “I say this very often but not quite often enough“.

Template parameters are preceded by a pipe symbol (“|”). If you add more parameters, each in turn has to be preceded by the same symbol. Whitespace (even newlines) may be used before or after the pipe to increase readability.

To indicate where in the template you want the parameter value to appear, triple curly braces are used with the number of the parameter inside.

Named parameters

When your template accepts a lot of parameters, you might find it convenient to name the parameters instead of numbering them. Named and numbered parameters can be mixed (but the numbered parameters must come first):

{{Fruit|apple|color=red}}

Referencing the named parameter in the template is as easy as referencing a numbered parameter:

When I need vitamins, I can eat an {{{1}}}. This fruit is {{{color}}}.

Default parameter values

Parameters can be made optional, by adding a default value:

When I need vitamins, I can eat an {{{1|orange}}}. This fruit is {{{color|orange}}}.

Now, you can call the Fruit template with no arguments if you just want an orange.

Gravatar API

Gravatars are retreived by using a very simple URL API. The URL is constructed using the MD5-sum of your email address:

-n $EMAIL|md5sum
77eca8beb1df91ca21e6c781e62630f8

http://www.gravatar.com/avatar/77eca8beb1df91ca21e6c781e62630f8

Optional parameters can be given in the URL. For now, I’m only interested in s (for size). This defaults to 80 pixels, but I want a bigger image:

http://www.gravatar.com/avatar/77eca8beb1df91ca21e6c781e62630f8?s=200

A working Gravatar template

On my Hardwood Investments Wiki, I have made a template that is meant to be used on a user page (such as my own) to display a Gravatar similarly to how captioned images are normally formatted:

<noinclude>
This template shows a Gravatar for the given e-mail address belonging to a given MD5 sum.

== Example ==

<pre>
{{User Gravatar|41165a7e7126d616a0ae0762e00718e2}}
</pre>

</noinclude><includeonly><div style="margin: 0 0 1em 1em; float: right; border: 1px solid #ccc; background-color: #f9f9f9; padding: 3px;">
<div style="border: 1px solid #ccc;">
http://www.gravatar.com/avatar/{{{1}}}?s=200.jpg
</div>{{PAGENAME}}
</div></includeonly>

This template introduces a two new concepts: the <noinclude> section is only used when viewing the template page and the <includeonly> section is used only when viewing the page that includes the template; {{PAGENAME}} is a magic word that is used to display the username as the image caption.

Now that I’ve demonstrated a practical application of MediaWiki templates, I can finally publish this draft. πŸ™‚

Finding a decent GeSHi plugin for WordPress

I like GeSHi (enough even to have written a language file for it). For ages now, I’ve used a WordPress plugin by Dan Peverill. But for as long as I’ve been using the plugin, I’ve been looking to get rid of it.

Dan Peverill’s GeSHI plugin sucks for two reasons:

  1. It’s no longer being maintained. It doesn’t even seem to justify a page on Dan’s website anymore (for which reason I’m not going to give him any link-juice).
  2. It breaks HTML. With the plugin enabled I can no longer use the <code> tag to mark in-line elements as being code. Frankly, this is annoying and I find myself typing <tt> often when I mean <code>.

A search for WordPress plugins tagged GeSHi reveals a number of results: Sniplets, CodeColorer, Developer Formatter, and WP-SynHighlight. WP-Syntax is a plugin that is missing from the tag search.

Sniplets seems much too generic to my taste. I just want a GeSHi highlighter, period.

CodeColorer says it does what I want, but if I ever want to use the TinyMCE editor again, I won’t be able to with this plugin. Shouldn’t be too much of a problem, but still…

Developer Formatter is very thoroughly written and even sports a TinyMCE plug-in for copying/pasting the code. It is pretty big, though, and, as a rule, I tend to avoid plug-ins that complicate the database schema. I also don’t really see how these extra tables are an advantage feature-wise.

WP-SynHighlight uses a custom BBCode-style tag, [codesyntax] I like this (if you’re going to use pointy brackets, at least keep out of the HTML namespace), though I don’t like the attempt at a generic name; what’s wrong with calling the tag [geshi]? Seriously… I’m sure I’m going to forget this name billions of times if I’ll use this plug-in.

WP-Syntax uses the <pre> tag with a few custom attributes. This at least is better than the officially inline <code> tag that my current plugin uses, because most of the time that I’d use a <pre> tag I really do want syntax highlighting. Just wondering: will it also allow my to use it normally for that other rare occasion? Sadly, the plugin will doubtlessly wreak havoc with the visual (TinyMCE) editor.

So, which plugin will I choose? I am somehow inclined to want a plugin that can play nice with the visual editor because I keep telling myself how much nicer it would be to switch to the visual editor for all my posting. (That this will be difficult because I disabled WP’s ‘wpautop‘ filter to rid myself of its eagerness is a story for some later time.) This requirement rules out CodeColorer and WP-Syntax.

That leaves Developer Formatter and WP-SynHighlight. Both seem to fit my purpose. Developer Formatter sports a nice TinyMCE plugin for inserting code, but I don’t think that switching to TinyMCE will suddenly and unexpectedly make me afraid of typing. Besides, I really don’t want the extra tables in my database without a very good reason, so, for now, I will try WP-SynHighlight.

wmsystray, a notification area DockApp for WindowMaker

Many X apps these days require a system tray. GNOME and KDE have system tray applets enabled in their panels by default. WindowMaker doesn’t have a panel. It supports DockApps, which are, of course, much cooler. πŸ˜›

wmsystray

wmsystray 0.2.0 with 2 icons wmsystray 0.2.0 with 3 icons

wmsystray (homepage) is a DockApp that supplies a notification area for Window Maker. The version that is in Portage (0.1.1) was maintained by Matthew Reppert. Was; I installed it almost a year ago and it crashed as soon as I started the first app which used the system tray. I went looking for a newer version than the one in Portage. I found it in a comment on its dockapps.org page by Vlad Dinulescu. He had fixed a few bugs and released a new version (0.2.0).

Unfortunately, version 0.2.0 suffers some problems of its own: it crashes when I quit Skype and it sometimes “loses” the uTorrent icon (usually when I have to restart the DockApp after quiting Skype).

Why isn’t this built into Window Maker?

I would much prefer it if Window Maker natively supported a notification area, preferably with the icons appearing within or replacing the App Icons. I’m not the first to have this wish. There exists a patch already, but the WM devs don’t like the idea.

An alternative to wmsystray

Something that I completely overlooked until I started writing this post is this, which looks like a decent alternative to wmsystray. I’ll have to try if that one works better than wmsystray. Some time…

Increasing (encrypted) disk image size with dd

When you have a raw disk image file, you may need to increase its size at some point. With dd, you can do this:

dd conv=notrunc oflag=append if=/dev/zero of=backups bs=1M count=1024

This will add 1GB of zero data to the image file ‘backups’. You can then use resize2fs on it to increase the file system size (that is, if you use ext2/3/4):

e2fsck (-f) backups
resize2fs backups

However, if the disk image is a volume encrypted with cryptsetup + luks, first open it:

losetup /dev/loop/0 backups
cryptsetup luksOpen /dev/loop/0 encrypted-backups

Then resize the encrypted volume:

cryptsetup resize encrypted-backups
e2fsck (-f) /dev/mapper/encrypted-backups
resize2fs /dev/mapper/encrypted-backups

And I know, I still have to add LVMs to my set of skills…

Encoding a motion jpg video produced by a canon A430 to xvid

I sometimes need to encode video recorded with my Canon A430 digital camera to a format that works, so I want to convert it to xvid. The sound stream included is so weird (PCM at 11024 Hz, no, not 11025 Hz) that encoding with sound always results in async video/audio. Therefore I don’t encode sound. I use this:

mencoder video.avi -o video.xvid.avi -ffourcc XVID -ovc lavc -lavcopts vcodec=libxvid:mbd=2:v4mv:vqscale=4:aspect=4/3 -nosound

The vqscale can be made 3 for slightly higher quality, but with the crap quality it starts with, there is not much use.

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑