Skip to content

arch linux - kernel 3.6.10-1-ARCH zfsonlinux available

Time is ticking, arch linux has updated its kernel to 3.6.10-1 and zfsonlinx in the aur can handle that. Sounding like a broken record, download spl-utils, spl, zfs-utils, zfs and build it.

Use "sudo depmod -a" to generate your modules.dep and map files with the lates versions. Use " sudo systemctl enable zfs.service" if you want to add zfs as systemd service.

Translate to de es fr it pt ja

howto - zend framework 2 - form multilingual error messages and labels

Since the first time working with the new zend framework 2 form elements, i like it. Everybody who had the pleasure to deal with the form class from zend framework 1 will agree on that. But after a little bit of playing around with it, i had to build a form that works with multiple languages and has a lot of mandatory fields. Since you are injecting a filterclass with validators into the form, you have to create the error message inside the filter class and like:

//part of a form filter constructor $this->add( array( 'name' => 'name', 'filters' => array( array( 'name' => 'StringTrim' ) ), 'validators' => array( array( 'name' => 'NotEmpty', 'options' => array( 'messages' => array( \Zend\Validator\NotEmpty::IS_EMPTY => 'I am the error message that should be multilingual.' ) ) ) ) ) );
So my first idea was to inject a translator. Since you are using a "MyMagicFormFactory" to create the form, you can easily inject the translator (or the servliceLocator if you want to). But after a few thoughts, i figured out that the error message itself is totally wrong on that place, for my point of view. I thing a form as well as a filter is not responsible for a human readable error message. Thats why i moved/reset the definition of the error message and handle it in the template. Of course, i am also using the translator but now only in the view layer. By the way, i will deal the same way with the labels for each form element.

So the simple question is how to deal with it?

To keep it simple, i will not use the translator inside the following example. Assuming you a form with a input field for an email address. You can deal with it the following way.

<?php echo $this->form()->openTag($this->form); ?> <dl> <dt> <!-- we don't use the method ->getOption('lable') since we want to deal the multiple languages inside the template --> Your mail address </dt> <dd> <?php echo $this->formEmail($this->form->get('email)); $messages = $this->form->get('from')->getMessages(); //take a look inside the $messages since it is an array with keys like 'isEmpty' // if you want to create error messages by key, thats the way you can handle this. if (!empty($messages)) { echo '<label for="from" class="error">Please insert a valid email address.</lable>'; } ?> </dd> </dl>

Enjoy working with zend framework 2 :-).

Translate to de es fr it pt ja

web - Zend Framework 2 ServiceManager

english I found a great summary about available service manager features.

Invokables An invokable is simply a fully qualified class name, provided to the SM as a string. When requested, it will simply be instantiated with new $invokableClass();. [...] Factories A factory is either a PHP callable, an object, or the fully qualified class name of a class implementing Zend\ServiceManager\FactoryInterface. Factories are used to perform any setup or dependency injection required for the object being requested. [...] Aliases An alias simply points one service name to another and they can be recursive. This may seem pointless at first, but aliases actually play a very important role in a modular environment. [...] Initializers An initializer is either a closure, an object, or the fully qualified class name of a class implementing Zend\ServiceManager\InitilizerInterface. Any object pulled from a service manager is ran through the registered initializers which can perform additional initialization tasks. [...] Configuration Classes A configuration class that implements Zend\ServiceManager\ConfigInterface. Config classes simply know how to configure an instance of the SM, potentially setting several factories, invokables, initializers, etc. [...] Shared Services Anything placed in the SM can be either shared or not shared. If shared, the SM will create an instance of the requested service object the first time it is requested, and on subsequent requests, return that same exact instance. If shared is set to false for a service, the service manager will create a new service. By default, all services are set to shared. [...] Abstract Factories If a SM is asked for a service which it cannot locate, it will then query the registered abstract factories to see if any of them are able to create the requested object. An abstract factory is either a fully qualified class name as a string or instance of an object that implements Zend\ServiceManager\AbstractFactoryInterface. [...] Peering Service Managers The service manger introduces a concept of peering. Each service manager can have “peers”, or rather, a stack of one or more other service managers which can also be used when a service is pulled from the SM. [...]
source Quick start service managers in your application Great survey, isn't it?


Auf der Suche nach einer Erklärung über das Wort "invokable" fand ich einen Eintrag, der eine Übersicht über vorhandene Service Manager Funktionen gab. Um das Wissen auch in meiner Muttersprache weiter zugeben, folgt anschließend die Übersetzung der weitern oben zitierten, englischen Zeilen.

Invokables Ein "invokable" ist ein vollqualifizierter Klassenname, welcher dem ServiceManager als Zeichenkette zur Verfügung bereitgestellt wird. Falls verlangt, wird eine neue Instanz dieser Klasse mit Hilfe von "new $invokableClass();" erzeugt. [...] Factories Eine "factory" (Fabrik) kann eine PHP abrufbare, ein Object, oder ein vollqualifizierter Klassenname einer Klasse sein, welche die Schnittstelle "Zend\ServiceManager\FactoryInterface" implementiert. Fabriken werden genutzt um jegliche Einrichtung (Setup) oder Abhängigkeitsinjektion (dependency injection) für die Instanziierung einer Klasse zu realisieren und zentralisieren. [...] Aliases Eine "alias" (alternative Bezeichnung) zeigt einfach auf einen anderen Dienst und kann rekursiv sein. Wirken Aliases am Anfang als unnütz, können sie bei einer modularen Umgebung eine große Rolle spielen. [...] Initializers Ein "initializer" (Initialisierungsprogramm) ist entweder ein Closure, ein Object oder ein vollqualifizierter Klassenname einer Klasse, welche die Schnitstelle "Zend\ServiceManager\InitilizerInterface" implementiert. Ein Objekt, welches vom ServiceManager kommt, durchläuft die registrierten Initialisierungsprogramme, welche weitere Initialisierungsaufgaben vornehmen können. [...] Configuration Classes Eine "configuration class" (Einstellungsklasse) implementiert die Schnittstelle "Zend\ServiceManager\ConfigInterface". Einstellungsklassen wissen, wie sie den ServiceManager konfigurieren, setzen etwaig Fabriken, "invokables", Initialisierungsprogramme usw. [...] Shared Services Alles, was in den ServiceManager vorhanden ist, kann geteilt werden. Wenn ein Dienst geteilt ist, wir der ServiceManager eine Instanz des gewünschten Objects erstellen und zurückgeben. Wurde bereits eine Instanz erstellt, gibt der ServiceManager diese Instanz bei einer enreuten Anfrage wiederrum zurück. Falls ein Dienst nicht geteilt werden darf, erstellt der ServiceManager bei jeder Nachfrage eine neue Instanz der Klasse. Von Haus aus sind Dienste geteilt. [...] Abstract Factories Falls ein ServiceManager nach einem Dienst gefragt wird, den er nicht finden kann, wird er alle vorhandenen, abstrakten Fabriken anfragen um das gewünschte Objekt zu erstellen. Eine abstrakte Fabrik ist entweder ein vollqualifizierter Klassenname oder eine Instanz eines Objekts, welches die Schnittstelle "Zend\ServiceManager\AbstractFactoryInterface" implementiert. [...] Peering Service Managers Der ServiceManager hat das Konzept des "peering" (Späherei/Umherschauens/Gleichrangigkeit) eingeführt. Jeder ServiceManager kann einen, oder eine Sammlung von, "Gleichgestellten"/"Spähern" ServiceManagern besitzen, welche ebenfalls genutzt werden können, wenn ein Dienst vom ServiceManager angefordert wird. [...]

Quelle Schnellstart Service Managers in deiner Anwendung

Übersetzungsfehler korrigiere ich gern.

Translate to de es fr it pt ja

howto - speed up mysql constantantly with increasing tablesize

The startingpoint is the following. You have a table with increasing content. Due to this fact, somebody added a timestamp or a created_at column. Now a requirement pops up telling you "we have to get a quick overview of entries per day and we want to paginate over the results".

First idea is add a index on the created_at column. But your table is growing and another index means also more workload for the db to write an entry. To implement the pagination, you implement the usage of a limit. But the limit doesn't really speeds up your pagination when you try to get results for the last pages. The problem for the limit is, that mysql needs also to go over the results you want to leave of (because of the offset you have to provide).

So what to do? Assuming you have an unique key that is an autoincrement value, you can use this to reach your goals (and don't need another createdat column and write intensive index). But for the per day pagination you also need a little helper. One idea is to create a table that holds the start unique id for per day or you create a table per day or month. Since the second idea has too much drawbacks for me, i will explain the first one a bit more in detail. The idea is to create a table with columns id, date, first_id_for_the_day. Now you can easily deal with the question "what id's are entered per day". Now you just have to add to you query a "BETWEEN idofsearchdate AND (idofsearchnextdate - 1)". Of course, you still need the limit but the database now is using a smaller scope (limited by the between clause), so it shouldn't be that big deal for it :-).

Translate to de es fr it pt ja