Browsing posts in: developer

Finally an android emulator as fast as the iOS simulator

Android development is fairly simple, but a good simulator that comes close to the iOS simulator experience was missing until now, but with GenyMotion the wait is over.  Installation is easy, and you can set up a lot of different emulation environments.  The advantage of genymotion is that it creates a real virtual android device, so whatever you are developing with (android studio, eclipse) sees the GenyMotion emulator as a “real” connected device.

Screen Shot 2014-10-18 at 17.58.40

Continue Reading

Laravel 4 – composer and packagist

Just released: the new Laravel version 4. The most important change is that laravel now embraces composer, the php package installer. This is good news if you want to use one of the many packagist packages available through composer, but this makes life a bit more complicatied as well. The old bundle system was a bit restricted but had one large advantage: ease of use.

What you need to keep in mind is that not all packages are structured in the way that laravel understands. For instance, you can install the original twitter bootstrap package but that leaves you with a directory structure like

But for laravel you need all img/js/css in a public directory like:

So how do we cope with this? Of course you can use the special laravel bootstrapper package, but that comes with pre-compiled bootstrap.
What we want is to configure bootstrap and then use Basset (the laravel asset compiler) to lesscompile/minimize all bootstrap resources and put the result in our laravel /public dir. But we don’t want to change anything to the bootstrap package because we want to be able to update to newer versions in the future.

Please leave a comment if you’ve found a beautiful solution to this.



Generating microsoft office documents (word, excel) on your webserver using php

Actually, this is much easier than you might think. The trick is to use the capability of excel and word to read html files

So just generate normal html, but use a content-type header line to force the browser to see this as a word or excel file: (using php)

header (“Content-type: application/msword”); or
header (“Content-type: application/”);
for word and
header (“Content-type: application/msexcel”); or
header (“Content-type: application/”);

I have never seen any difference between msword and, so if anybody knows the difference, please respond.

Then you might want to define the local filename. This can be done using the content-disposition header:

header(“Content-Disposition: filename=\”invoice_$invoicenr.xls\””);

For excel, just start generating a html table. The full table is used as excel sheet with its rows and columns.
For word, just start generating html code. It is interpreted by word. Make sure to use a FULL url path if you want to include images.

Here is an example to generate a word document:

Click here to test it.

Flash memory reliability

During my trip to China a few weeks ago I met Ernst Fuld again. Ernst is CEO of the NGN, the dutch IT-professional platform. He told me that he has tried to test some usb-sticks and see if they could be written and erased so many times that they break. As you probably know, flash memory can only be written a limited number of times. Each time you erase (rewrite) the memory cell, there is a slight chance that it breaks. Normally, the memory is guaranteed to last for 100000 rewrites, but has anybody tested this on a regular usb stick?

There is a problem however. The sticks are known to use a technique called “wear levelling”. The data you write to the stick is remapped to memory area’s where the number of rewrites is the lowest. This means that you cannot test 1 cell by re-writing a small file over and over. You have to fill the WHOLE stick in order to rewrite all cells. And even if you manage to break a cell, there is also error-correction logic and bad-block remapping that will correct the error without notice. So the flash memories seem to be unbreakable.. or not!?

That’s why I wrote this simple app: Flashkiller. It’s a free download so you can test the reliability of your memory stick yourself. If you broke a usb-stick or memory card with it, please respond to this post!

May 2 update: the kingston 512mb is now @19000 rewrites and still without an error..

june 13 update: The kingston is DEAD. After 65000 writes it becomes a read-only stick. Nothing can be written any more, and when i try to write it gives an error!!!!

Acceptgiro’s printen

Even een item in het nederlands. Wat is het toch lastig om informatie te vinden over het printen van acceptgiro’s, en dan met name het berekenen van de controle getallen.

Uiteindelijk bij interpay de goede informatie gevonden: … -34971.pdf

Maar hoe werkt het nou? Vrij simpel. Alle controles worden met de bekende 11-proef (modulus-11 algoritme) uitgevoerd. Dat wil zeggen dat je elk cijfer met een weging optelt en het resultaat deelt door 11. De rest die je overhoudt trek je van 11 af en dit geeft het controle getal.

voorbeeld: (16 cijferig betalingskenmerk)
c000 0567 8901 2345 (c=het controlegetal dat we gaan berekenen)

de wegingen zijn 2 4 8 5 10 9 7 3 6 1 en die moet je vanaf rechts toepassen, en als je klaar bent begin je weer van voor af aan. Dus:

215/11 = 19 rest 6
11-6 = 5 dus controle getal (c) is 5
Indien C = 10 wordt 1 aangenomen
Indien C = 11 wordt 0 aangenomen

dus het betalingskenmerk is dan

5000 0567 8901 2345

Mserv client for windows

Already for a few years, i’m running MSERV, a great opensource mp3 jukebox which is completely client-server and has a good rating- and genre system which allows it to play random music that corresponds to the current mood, current lister etc.

You can rate numbers as superb, good, normal, bad, awful etc. and it takes this into account to play numbers more or less often, depending on your rating. Everybody can rate, so this is a good jukebox to use with a group of people.

There are a few clients available, and I’ve taken MservClient as a base to further develop the windows client. MservClient is written by Marco Schulze and Marc Klinger, and can be found here. Because I’ve changed the whole concept of MservClient, I adopted a new name: Mserv4win. Also, there is not much left from the original code of mservclient. Mserv4win takes the look and feel from winamp and puts it on top of mserv.

Continue Reading

Simple Tabs for your webpage with php

I’ve just finished a new version of the icelandic-horses website. Because it’s a fairly large site, I decided to use tabs on top of the page, to make navigation simple and intuitive.

Just looking for what is available on the net, i found lots an lots of nice implementations, however, they all were very complex, used a lot of javascript or everything was done with images/tables. I wanted a PHP/CSS solution without images, and in fact, it turned out very simple, and looks like this:

(no javascript and only 1 image used: a transparant dot (a gif file of 1×1 pixel, transparant)

Here is the class code:

And here is the CSS. Acutally the whole “tab” look is done with borders in CSS:

And here is a sample how to use this class:

You could use separate php files for each tab-page, or use one “big” php file with all pages. With additem, you just supply the url of the page itself.
If you use separate php files, be sure to include the code above in every file (with an include)
The $curmenu var indicates which tab to highlight. Be sure to set it right, otherwise all tabls are grey

mysql from a remote machine

Assuming you can connect locally to mysql, you’d expect to be able to connect remote…not! This is not as easy as it seems.

First make sure you CAN access the mysql server from a remote machine. By default, the my.cnf file contains a statement:
that is in your way. This only allows connections from the localhost. Put a # in front of it.

After this, still no luck, because the mysql privilege system is not your default user/password pair, but mysql for some reason also needs to know where you’re calling from. This is due to the unusual non-standard structure of their user table: it contains host/user/password.

So add your remote host to the table by issuing:

grant all on *.* to user@remotehost identified by ‘password’

or, if you want to allow access from all hosts, use a % like:
grant all on *.* to ‘user’@’%’ identified by ‘password’

note: put quotes around username and host if neccesary. Beware not to quote the complete thing (like ‘user@host’) because mysql thinks you mean user “user@host” on the local machine.

Because mysql caches privileges, you need to flush them so enter:
flush privileges

after this you should be able to login

to see if its ok, do

use mysql
select * from user;

That’s it. Sounds easy, but as the mysql documentation index/search sucks bigtime it can take you hours to find this out. (for instance, searching on the 1130 error number puts you on the wrong trail by giving information about blocked-hosts that has nothing to do with the real problem)