May 112012

First, I should point out that the title of this post is a bit of an intentional misnomer. There’s really no such thing as “module-specific” anything in ZF2, so what we’re really talking about is the topmost namespace of the controller being dispatched. So in the case of MyModule\Controller\SomeController, the topmost namespace would be MyModule. In most cases, this will be the name of a given module.

Here’s how you can easily switch the layout (or perform any other arbitrary logic) for a specific module in Zend Framework 2.0 (as of d0b1dbc92):

<?php
namespace MyModule;
 
class Module
{
    public function init(Manager $moduleManager)
    {
        $sharedEvents = $moduleManager->events()->getSharedManager();
        $sharedEvents->attach(__NAMESPACE__, 'dispatch', function($e) {
            // This event will only be fired when an ActionController under the MyModule namespace is dispatched.
            $controller = $e->getTarget();
            $controller->layout('layout/alternativelayout');
        }, 100);
    }
}

This event listener will only be triggered if an ActionController under the MyModule namespace is dispatched, so you do not need to perform any additional logic to check which “module” or namespace the controller being dispatched is under.

Keep in mind, as of writing this, ZF2 is still in beta. There are plans to add a convenience layer to the framework before the GA release which will likely make common tasks like this much simpler.

See also: Rob Allen’s post on module specific bootstrapping in ZF2

With the new modular infrastructure in Zend Framework 2, one of the most common questions will indoubitably be how to share a database connection across modules. Here’s a quick explanation of how to share your database connection across multiple modules in a way that can even allow you to use a single connection between Zend\Db, Doctrine2, and possibly even other database libraries / ORMs.

Continue reading »

This is pretty obscure, and chances are, you probably don’t need to do this even if you think you do. I’m merely posting this for my own future reference and potentially for that one person who has a bizarre use-case for this like I did so they might stumble across this post.

So here it is: if you ever find yourself in a situation where you’d like to be able to update the commit that a submodule points to in your super-project, but you also don’t want to clone the entire submodule project down to do so (assuming you have not already initialized/updated the submodule(s) or you didn’t clone with –recursive), you can actually accomplish this with the following:

[user@workstation myproject (master)]$ git update-index --cacheinfo 160000 88e6a302c42840440f9faac73f27efc6a3e0c1a6 pathto/mysubmodule

In the above, pathto/mysubmodule would be the path to your submodule, and 88e6a302c42840440f9faac73f27efc6a3e0c1a6 is the commit hash you wish to update the submodule to point to. Note that you must specify the full commit hash, not an abbreviated hash. The number 160000 is a magic number that Git uses internally to identify that the file type is a submodule, so leave that as-is. After running the above command, git status and git diff should show the change. You can now commit the updated submodule.

BE CAREFUL, as this will not actually check that you have provided a valid commit hash.

Thanks to Mikachu in the #git channel on Freenode for helping me figure this one out.

Today, a friend of mine told me about a nifty little launcher program for Gnome3 written by Simon Schneegans called Gnome-Pie.

Gnome-Pie isn’t yet in any of the yum repositories I use or trust, so I thought I’d write on how to install it. I’m not the first person to write this, however I might be the first person to write it in English. Also M@riscal seemed to be missing a dependency or two.

Step 0: Install dependencies:

[user@workstation ~]$ sudo yum install vala-devel bamf bamf-devel libxml2-devel gtk2-devel cairo-devel cmake unique-devel libXtst-devel gnome-menus-devel gcc gcc-c++ libgee-devel

Step 1: Clone and build the latest Gnome-Pie:

[user@workstation ~]$ git clone git://github.com/Simmesimme/Gnome-Pie.git
[user@workstation ~]$ ./Gnome-Pie/make.sh
[user@workstation ~]$ cd Gnome-Pie/build

Step 2: Install Gnome-Pie!

[user@workstation build]$ sudo make install

You’re done! You can launch Gnome-Pie from your application menu (or as I prefer, [super] + pie + [enter]). It launches silently and is displayed with [ctrl] + [alt] + a. Enjoy your pie; Bon Appétit!

Dec 042011

First of all, I do not take credit for any of this. This is basically just a consolidation of the steps found here and here. Anyway, here’s how you root a Motorola Admiral if you are running Linux (tested on Fedora 16).

On your device, toggle the following settings on:

  • Settings » Applications » Unknown sources
  • Settings » Applications » Development » USB Debugging

Continue reading »

Dec 032011

Let’s face it, nobody likes a dirty fork. In this series, I’ll show you some of the tricks I’ve learned over the years to successfully maintain a clean fork on GitHub for projects I actively contribute to.

The examples here will be catered towards people wanting to contribute to the Zend Framework project on GitHub, however the advice given not actually specific to Zend Framework. My advice may also differ slightly from that mentioned in the Zend Framework Git Guide, as it incorporates practices I have acquired over my years of using Git and working on open source projects.

Continue reading »

A simple explanation of git-rebase

Posted by Evan on December 2, 2011 General 2 Responses » Tagged with: ,
Dec 022011

Using git-rebase without actually understanding what it does can cause headaches for you and the developers you’re working with. I don’t like headaches, so let’s take a minute to review what exactly git-rebase does.

Let’s say master is at commit C, and you create a branch feature/my-topic. So you have two branches pointed at the same commit like this:

           feature/my-topic
         / 
A---B---C master

Next, you make two commits D and E in feature/my-topic and push it to your origin (we’ll say GitHub):

           D---E feature/my-topic
         / 
A---B---C master

Meanwhile, let’s say master also gets two commits, D' and E':

           D---E feature/my-topic
         / 
A---B---C---D'---E' master

So now you want to rebase your feature/my-topic branch onto master, so you run git rebase master. The result is this:

                    F---G feature/my-topic
                  / 
A---B---C---D'---E' master

Continue reading »

Fix Fedora 15 Mouse Freezing Intermittently

Posted by Evan on September 16, 2011 General 3 Responses » Tagged with: ,
Sep 162011

So a couple of days ago, my mouse began spontaneously locking up for several seconds at a time on my HP tm2 laptop. It was happening constantly and driving me insane! A couple of attempts to Google around for a simple answer turned up nothing useful, but then it struck me:

Back when I had originally installed Fedora 15, under “Mouse and Touchpad”, I had chosen “Disable touchpad while typing”, noting at the time that the setting seemed to have no effect. Well, apparently one of the recent F15 updates has fixed this issue, so the setting spontaneously started working.

To fix this, simply open up your “Mouse and Touchpad” settings and deselect “Disable touchpad while typing.” I really hate to disable such a useful feature, but there’s no obvious way in the GUI to change the excessively long timeout that’s set by default. I’ll dig around in gconf and see if I can find a way to change the timeout and update here if I have any luck.

Aug 102011

In response to some concerns voiced on the zf-contributors mailing list, I went ahead and built a tool to aid developers in following the progress of Zend Framework 2 across the various developer forks and branches:

You can try the tool out at http://zf2.evan.pro/ or subscribe to the RSS feed at http://zf2.evan.pro/feed. I also hooked it up to a Twitter account that you can follow @zf2dev.

You can follow the progress and fork the tool on GitHub and on the ZF-Contributor mailing list. This is of course, open source; released under the New BSD license.

Fedora 15 on the HP Touchsmart TM2T

Posted by Evan on June 28, 2011 General 1 Response » Tagged with: , ,
Jun 282011

I originally posted this for Fedora 14 on the Fedora Wiki.

This is a guide about how I got Fedora 15 set up and running properly on an HP TouchSmart tm2t-2100 (aka HP tm2) tablet. Instead of simply providing a bunch of steps and commands for you to blindly follow, I am going to provide some extra details and explanations in an attempt to leave readers a bit more educated on the issues they’re trying to solve.

Continue reading »