Shared Know How

Howto: fix, find, use, make & do it guide

NEW: .htaccess redirect to maintenance – under construction page

author Posted by: Tim on date Jan 17th, 2011 | filed Filed under: Other stuff

For simple redirect while doing maintenance on websites like upgrades or emergency fixes I put a site in maintenance by adding the next few lines to my .htacces

RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteCond %{REQUEST_URI} !(\.(gif|jpg|css)$|^/maintenance\.html$)
RewriteRule ^(.*)$ /maintenance.html [R=302,L]

Ofcourse change the 123\.123\.123\.123 to your ip address and create a maintenance.html. This .htaccess will still serve images and css normally so you can use them in your maintenance page.

If you want to add more ip adresses just duplicate the line: RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123 and change the ip.

Share printer with Airprint under Linux/Ubuntu 10.04

author Posted by: Tim on date Nov 22nd, 2010 | filed Filed under: Other stuff

Getting Airprint printer sharing to work under linux is fairly simple.

First off all you need to get your printer working under linux using Cups and make sure you have pdf support (apt-get install cupsd cups-pdf). I won't get into detail howto configure cups. This will be different from printer to printer and pretty well described on the internet.

  • Download the script to  the script to generate an Avahi daemon config file provided by tjfontaine:

git clone (apt-get install git - if you don't have git yet)

  • To run this script you need python and python-cups:

apt-get install python python-cups

  • run the script:

cd airport-generate/

  • copy the created files to your avahi services config directory:

cp *.service /etc/avahi/services/

After this you should be ready to go. I still did get one error in my cups error log:
Request from "fe80::7ec5:37ff:fe09:62df%eth0" using invalid Host: field "office.local"

To get this working I still needed to add one line in /etc/cupsd.conf  :
ServerAlias *


Optimize your PHP website performance

author Posted by: Tim on date Apr 16th, 2010 | filed Filed under: Other stuff, php, programming, webserver

Optimize your PHP website by making sure you use the following tricks

The list

Optimize front-end

  • Combine CSS files as much as possible
  • Combine Javascript files as much as possible
  • Always place a favicon.ico (saves needless 404 request and file searches)
  • If you use a lot of small images for your website make use of CSS Sprites
  • Use GZIP compression

Optimize PHP

  • Install APC (Alternative PHP Cache). This will speed your php up a lot
  • if you don't use .htaccess or have control over the server remove .htaccess ability and set any options in your apache virtual host file.
  • don't use current directory (".") in your include path but instead link directly to files in your code: include("./example.php")
  • Watch how many include paths you have. It will search in every folder for to find include file.
  • use persistent mysql connection (mysql_pconnect)

This list is based on the presentation of Rasmus Ledorf at Campus Party 2010 - Out of this e've compiled a small checklist of things to do when you create a php website. This will make sure you will use all the simple tricks to make your website and PHP code to run fast. Further information on how to benchmark this look at the presentation of Rasmus.

Solved Dojo> Dijit.Dialog in ZendFrameWork doesn’t parse

author Posted by: Tim on date Jun 8th, 2009 | filed Filed under: php, programming

When trying to make a Dojo dialog work with another controller which is loaded trough the href attribute of the dialog. The content will not render as dijit elements.

This is because ZendFramework places all the properties in the Javascript array zendDijits and then add them to the elements after loading. However this will not work for the loaded Dialog because the ZendDijits are set in the view of the controller opening the dialog.

The simple solution to this is to use the declaritive formin the Zend_Dojo_View_Helper_Dojo by placing the following line in your code:

  2. Zend_Dojo_View_Helper_Dojo::setUseDeclarative();

I placed this in my bootstrap.php right after the line where the Zend_Dojo_View_Helper is loaded.

Making de view helper declarative will place the dojo properties directly into the html of the elements.
Side-effect: the script will not be correctly verified as valid (x)html but it will solve the problem!

Evolution importing old mail in Ubuntu Intrepid 8.10 hangs

author Posted by: Tim on date Oct 31st, 2008 | filed Filed under: linux

Ofcourse yesterday when the new Ubuntu 8.10 came out I couldn't wait to install the new version. I came across a big problem though that evolution was hanging on importing/migrating my old mail. I tried to copy my old .evolution folder and even importing a backup I made.

Evolution segfaulted with the following line in messages

[   56.897763] evolution[6320]: segfault at 0 ip b6a45d07 sp bff95824 error 4 in[b69e9000+b5000]

It turns out that importing fails on the ev-summary files in ~/.evolution/

The solution is deleting those ev-summary files. They will be regenerated by evolution. Because I have dozens of folders in my evolution I used the following line:

find ~/.evolution -name *ev-summary -print0 | xargs -0 rm

after that  evolution works just fine.

Linux PPTP VPN server install for use with Iphone

author Posted by: Tim on date Sep 28th, 2008 | filed Filed under: iphone, linux

I was looking into getting an vpn connection from my iphone to my server because I wouldn't want to send my email passwords and webpasswords clear over any public WIFI. Setting up an open source vpn connection from the Iphone is fairly simple but there is not much choiche of software. To my knowledge OpenVPN and Openswan are not supported so my choiche came down to: Poptop which is probably not the most secure solution because it's uses the Microsoft protocol which has a few flaws but I figured it would be much safer then nothing and if there is an evil WIFI I would guess they will just go for the easy targets.

My install is a CentOS 5.2 installation but it should work under any fairly recent Linux distribution

Setting Poptop VPN for Iphone is done in just four steps:

Read more »

AF9015 – equinux tubestick under Ubuntu

author Posted by: Tim on date Sep 5th, 2008 | filed Filed under: linux

Installing drivers for the af9015 sold as the Equinux tubestick and numerous other brands for Linux is pretty easy to find & install. Go to and download the latest drivers.

We need to build these drivers so make sure you installed the following packages


Read more »

Flex 3 Combobox error #1502

author Posted by: Tim on date Sep 4th, 2008 | filed Filed under: flash, flex

We where dealing with finding the bug in the following error:

Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds. at mx.core::UIComponent/get owner() at mx.core::UIComponent/owns()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\] at mx.managers::PopUpManagerImpl$/nonmodalMouseDownOutsideHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\] at PopUpData/mouseDownOutsideHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\]

It turns out that it has to do with a certain id in one of our elements which had the id "owner" apparently this is used internally in flex as well. Simple to fix but pretty hard to find

Fixed AS3 Flash TextArea – CSS incompatibility

author Posted by: wytze on date Jul 8th, 2008 | filed Filed under: flash

When working with flash components we often run into disadvantages. As with the TextArea class (fl.controls.TextArea) we encountered that it is not possible to use a CSS on its 'textField' property. Once again we thought to have the fast way to an end with components, but nothing of the sort.:'(

Since the 'styleSheet' property returns a standard TextField instance it struck us as weird that setting its 'styleSheet' property didn't work. The TextArea class was trying to set textFormat which fails after setting the stylesheet of the textfield.

Error message:

Error: Error #2009: This method cannot be used on a text field with a style sheet.
at flash.text::TextField/setTextFormat()
at fl.controls::TextArea/drawTextFormat()
at fl.controls::TextArea/draw()
at fl.core::UIComponent/callLaterDispatcher()

This pointed us to the 'drawTextFormat()' function in the TextArea class. After taking a look we figured out what to do.

The problem turned out to be that every time you add text to your textarea the class tries to add a designated, or default flash-textFormat to the textfield. Adding Flash TextFormat objects to textfields conflicts with stylesheets. Our solutions was relatively simple: a small class extends of the textArea class.

Click continue for the fixing source
Read more »

Hiding TextArea border in AS3

author Posted by: thijs on date Jul 8th, 2008 | filed Filed under: flash

TextArea shows a border by default


Using a TextArea in actionscript 3 could come in handy as the Flash component adds in a ScrollBar by default. But it also provides some things you might not want there..

One of those things is the border, that is placed there by default.

Inspired by the solution posted here I found that you can override the skin that is used by default in the component ("upSkin") by using:


by overriding it with a Sprite, which is empty by default, all the visual aspects are cleared... including the border!