Archive | January 2008

Optimize Amarok collection indexing using MySQL

By default, Amarok use SQLite to store collection informations. If you’ve a running MySQL or Postgre server on your machine, you can optimize Amarok collection indexing reducing retrieval time.
Amarok MySQL configuration

  1. Open a root shell (sudo bash) and run mysql
    mysql> create database amarok;
    Query OK, 1 row affected (0.00 sec)
    mysql> grant all privileges on amarok.* to 'amarok'@'localhost'\ 
    identified by 'type_here_your_password';
    Query OK, 0 rows affected (0.00 sec)
  2. Open Amarok and go to Settings > Amarok configuration > Collection and fill the database fields (watch screenshow)
  3. If you got an error don’t worry, simply force collection re-scan (Tools)

Now your music collection run on an efficient MySQL database.

Use lightbox for all inline elements


You simply enable lightbox v2 on image nodes (admin/settings/lightbox2) but your lightbox show a small imagecache thumbnail?

  • Disable lightbox on image nodes (admin/settings/lightbox2)
  • Enable “Display image with a link to the image file” (admin/settings/inline)
  • Apply this Inline lightbox patch

This patch simply add a rel=”lightbox” to each inline image link, natively pointing to full-size image.

Make JCarousel and Contemplate work together

Drupal modules needed:

* = tested on latest official release
Howto subject: How to use JCarousel within a Contemplate modified node body

JCarousel is a nice JQuery plugin to render a vertical or horizontal bar containing some custom HTML code elements. Every element is within a list item of an unordered list. On page load a JQuery event trigger the simple unordered list to show as a bar.

Let’s start

To use Contemplate more smoothly (and without cut/paste from your preferred code editor, i.e. Quanta), you can create a file-based contemplate instead a database based.

  1. Create a sites/all/contemplates folder (or sites/mysitename/contemplates)
  2. According to Contemplate help (admin/help/contemplate), put there your node-mynodetype-body.tpl.php file, where “mynodetype” is the machine name of the type you want to modify (that one that appears like node/add/mynodetype when you create a new node of that type).
  3. Visit admin/content/templates to update the contemplate list. Now, if you go to admin/content/templates/mynodetype you can read:

    This template is being read fromsites/all/contemplates/node-mynodetype-body.tpl.php
    Please make changes to this file or remove it to continue editing here.

This is your contemplate file for this how-to. You’ve only to modify it, upload it and watch your mynodetype body growing up with JCarousel.

Call JCarousel

On the top of your content template, write:

$js = “// <![CDATA[
#function to add a Bouncing Effect on your JCarousel: you can add another custom effect function
// Credits: Robert Penners easing equations (
jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
if ((t/=d) < (1/2.75)) {
return c*(7.5625*t*t) + b;
} else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;

# Call JCarousel when page is ready for the element mycarousel
# Read
jQuery(document).ready(function() {
vertical: false,
animation: 3000,
easing: ‘BounceEaseOut’,
visible: 5,
scroll: 4
// ]]>”;

#add to HTML page HEAD this JavaScript code
drupal_add_js($js, ‘inline’, ‘header’);


Using latest official release of JCarousel, tango theme skin.css file returns a buggy appearance. You can switch to the original tango skin.css file on Simply copy that file to your module skin folder.
In order to make your JCarousel works better, you have to write some additional CSS lines on your theme CSS file:

/* JCarousel custom CSS for horizontal bars */
/* DO NOT USE margin or padding for item elements
(auto-adjusted with visible/scroll JCarousel options) */
width: 100px;
/* Bar total width for 5 elements
(100×5)px + 10px horizontal padding */
width: 550px;

/* center jcarousel within a block element */
margin: auto;

/* item height = bar height */
.char .jcarousel-item-horizontal,
.char .jcarousel-clip-horizontal{
height: 150px;

Contemplate JCarousel

A simple but useful way to test JCarousel is to display attached image files on your mynodetype. Assuming that all attached files are image files, that you want tango theme and you want to render an imagecache picture with preset named “my_thumbnail_preset”, add to your contemplate file these lines:

$attached_files_carousel = TRUE;

if($attached_files_carousel): ?>
<ul id=”mycarousel” class=”jcarousel-skin-tango”>
$preview_imagecache_preset = ‘character_picture’;
foreach($node->files as $uploaded_file){
/* if imagecache is present, build the thumbnail */
$uploaded_file_preview = theme(‘imagecache’,$preview_imagecache_preset,$uploaded_file->filepath);
$uploaded_file_preview = l($uploaded_file->filename,$uploaded_file->filepath);
/* Print the List Item */
print “<li>” . ‘<a title=”‘.$uploaded_file->filename.’” rel=”lightbox” href=”‘. base_path() . $uploaded_file->filepath . ‘”>’. $uploaded_file_preview . ‘</a>’ . “</li>”;
endif; ?>

Fantastic Attachments

This method simply write the UL#mycarousel via PHP (static JCarousel method). Using rel=”lightbox” enable image file zoom via JavaScript, if lightbox v2 module is enabled. If you want to implement complex AJAX loading or to experiment more JCarousel effects, options and customizations, see also:

Another example, using some CSS and photoframe module:

Create nice pdf with ps2pdf and any word processing utility

Apply on: any GNU/Linux distrubution

Applications like OpenOffice allow to export document in the PDF format. However, sometimes the result is not very much professional. To obtain the best from your document in printing, you can follow a two-step conversion using any word processing utility.

  1. Use the option “Print to file” to convert your document to PostScript format. (i.e.
  2. Convert the generated PostScript file in PDF using ps2pdf

Conversion tips:

To generate a document to print (more heavy), with embedded fonts, best image rendering etc. you can use:

ps2pdf -dPDFsettings=/prepress

The “prepress” distiller parameter automatically choose the best settings for print, but you can override it.

See also:
How to use ps2pdf advanced options


Get every new post delivered to your Inbox.

Join 26 other followers

%d bloggers like this: