Zend Framework: View Helper to Render any HTML tag

Sometimes you might want to render a HTML tag with a lot of dynamic attributes in a view, of you need to create an HTML Element somewhere else were it is unlikely to use HTML with inline <?php tags.

I created a view helper that just takes an array of the attributes and returns the tag. The interesting part is thing is, that this functionality is already hidden in the Zend Framework within Zend_View_Helper_HtmlElement.

<?php

/*
 * This helper allows to render any HTML element with attribs from an array.
 * 
 * @author A. M.
 * @copyright Public Domain
 */
class Zend_View_Helper_AnyHtmlElement extends Zend_View_Helper_HtmlElement {

	/**
	 * @param tag The HTML tag, for example img 
	 * @param attribs HTML Attributes
	 * 
	 */
    public function anyHtmlElement($tag, $value = null, array $attribs = null)
    {
    	if ($value != null) throw new Zend_Exception('not implemented yet, we can make only <XXXXXX /> tags right now.');

    	$xhtml = '<' . $tag . ' ';
    	$xhtml .= $this->_htmlAttribs($attribs);
    	$xhtml .= $this->getClosingBracket();
        return $xhtml;
    }
}

Simulate slow connection with the Bandwith Module for Apache

For testing websites that are intended for use in the fields, I often wanted to make your http://localhost feel like on a modem connection. The easiest solution I found is the the Apache module mod_bw.

This is a short setup guide for Ubuntu Webdevelopers that care about their users or everybody who want’s to get an idea about how Internet in large parts of the world feels 🙂

Setup on Ubuntu

  1. Install the module using for example using aptitude install libapache2-mod-bw
  2. Activate the module: a2enmod bw
  3. Insert the following configuration to your virtual host:
    BandWidthModule On
    ForceBandWidthModule On
    BandWidth all 1024
  4. Restart Apache
  5. If not done already, you might should also install also the Webdeveloper plugin for
    Firefox and choose Web Developer -> Disable -> Disable Cache

Now browsing on http://localhost will be at 1kbyte per second.

Optimize your Website

  • Using mod_gzip to compress data
  • Minify CSS, Javascript and optimize Pictures

Additional tipps can be found in Yahoo’s Best Practices for Speeding Up Your Web Site.

GNOME Terminal Notification Patch – debs for Ubuntu Karmic (amd64)

I just compiled the patch for the GNOME Terminal to display notifications when a command is finished for Ubuntu Karmic, 64 bit Version.

A ZIP file with two Debian packages that can just be installed using

dkpg -i

can be downloaded here.

Great Ethiopian Run 2009

Heute war Great Ethiopian Run.

10 km – 1 Stunde, 27 Minuten, keine Glanzleistung, aber ich habe ja auch quasi nicht trainiert. Mein Schwiegervater mit seinen über 60 Jahren ist übrigens fast genau die gleiche Zeit gelaufen, Glückwunsch

Bilder vom Great Ethiopian Run

GNOME Terminal: Notification when command is finished

There is a patch to notify you as soon as a command in the gnome terminal finished working.

It workes by monitoring the changes:

  • start command (find, gcc, wget and so on)
  • switch to an other application (gnome terminal in to the background)
  • it detects after some seconds whether there was any new output and then decides whether to monitor for activity or for inactivity
  • if the command finished, the terminal window flashes

Some other users of GNOME and me had this idea a while ago. I also tried to develop a patch but did not have the time to finish it. The feature now was implemented by henux  who I found on rentacoder.

The patch and the .deb files (tested on Ubuntu 9.04, unfortunately the update manager sometimes replaces them):

GNOME Notification Patch with .debs Download

How to use it:

  1. Start GNOME Terminal
  2. Right Click:  Monitor for Inactivity/Activity

I recommend to have this always-on by changing the setting in Edit -> Profile Preferences

Have fun!

How to write Amharic (Ethiopic Characters) in Ubuntu

I attached an overview on how to reach the letters of the Ethiopian Geez using the phonetic input for Amharic. To activate that mode, for example in GNOME Editor, use right-click -> Input Methods -> Amharic).

Improvements are welcome.

How to write Amharic in Ubuntu (Download PDF)

USB-Missile Launcher for Panorama Photography Part 2

The micro switches were completely removed. To not destroy the device, the control software must be modified to take care of the mechanical limits. Additionally, we want to find a way, to control the device exactly.

The scale So, first of all, a scale is added to the base. I made it using Inkscape and used the star/polygon tool, „object to path“ and finally modified the mid markers in of the stroke’s style  to paint 36 equally distributed markers on a circle. This scale can be downloaded and printed on a simple paper InkJet-sticker to easily attach it to the future 360pano-platform.

After the turnable platform is marked at a fixed position using a black marker, we can easily read the current rotation angle in steps of 10° (and 5°), next the pymissile software is modified to turn the platform by a specified amount. This is done by simple trial and error.

I marked the critical area (caused by the mechnial barrier to avoid multiple full rotations and twist and destroy the cables) with red color. The finally usable range is 0-320° degrees.

Software extentsion

Screenshot of the control center As mentioned before, the pymissile control is used. In recent Ubuntu versions, the software can be installed using „aptitude install pymissile“ (it is always suprising what a vast variety of different software the Debian/Ubuntu repository contains. Next, instead of pymissile, we use the modified version pyusbpano.

When the software is started, the calibration mode is active. The left mouse button must be pressed and held until the platform returned to the zero position. By pressing C the calibration mode is left. Next, using the keys „h“ „j“ „k“ „l“ and „z“ „u“ „i“ „o“ the platform can be turned by 5, 10, 20 or 40 degrees. The software does not execute any action, when it belives that the critical area would be reached.

Betatest

Betatest 1 I also added a „script“ (can be started using the key „g“) to aim at 3 times 9 positions („looking“ down, straight, up and turing angles 0, 40, 80, … 320 degrees). For a first test, I attached my mobile phone that is able to shoot a picture each 10 seconds.

The former rocket launcher with attached mobile phone

Finally these 27 pictures are stiched together using autostich. The result is already quite amazing – but unfortuately due to some timing issues, some shoots were lost.Next, I want to try to mount a CANON camera and modify the FIRE-function of the former missile launcher toy to be used as an USB remote (CHDK Wiki).

Automatically shot panorama

 

USB-Missile Launcher for Panorama Photography Part 1

Since I went to Ethiopia the first time, I became interested in panoramic photography. Some samples can be found on AddisMap/Panorama. I took all these panoramas freehand. By chance I found the impressing website about KAP (Kite Aerial Photography) by James Gentles who recommended to use devices like the gigapan system for automatically shooting panoramas. I got the idea to modify my USB controlled missile launcher for taking panoramic pictures.

Hardware modification

Mechanical Barriers (at the case) and missing teeth

Unfortunately,  the missile launcher only turns 180°. To modify it for peaceful use, it has to be opened. We find two microswitches that are triggered as soon as the base reaches it’s limit and cause the electric motor to stop. Additionally there are two mechanical barriers.

A microswitch

At first, I removed one of these barriers and of the the trigger, fixed everything together and was hoping that it is now possible to do nearly 360° rotations. But, unfortunately some of the platform’s big gearwheel’s teeth are not fabricated. That is why we had to construct these additional teeth (thanks to my brother). As the stud for preventing > 360° turns accidentally was removed, this is fixed with some piece of plastics and superglue. Adding some additional teeth

The final gearwheel