A4Tech Glaser X6-6AK mouse

My old mini mouse that I used with my laptop is in the coma.  The left mouse button is not working any more.  So, I passed by a computer shop today to get myself a new companion.  The simplest mouse (out of the mini range) that was available was A4Tech Glaser X6-6AK.

It is a fine peripheral.

  • Small size (mini)
  • Short cable, which wraps around and a USB plug that folds into the bottom side.
  • Matte surface, which decreases slippage

It’s not the cheapest mouse in the shop (price tag just under 20 EUR), but it is a pleasure to use.

And there is one thing about this mouse and pretty much every other mouse that I’ve seen today that totally blows my mind an suggests to me that the end of human race is much closer than I thought.  Did you notice that orange button on the image above?  Do you have any idea what that button does?  I’ll give you a hint – it’s marked with “2X”.  I had to pause and pull myself together when I learned.  Here is the truth.

It’s a double-click button!  Say what?  Firstly, is double-clicking really such an exhausting activity that people need a separate mouse button for it?  And secondly, even if someone does need a button like that, do we really have to have it on ALL mice?  I mean, there wasn’t a single mouse in the shop that didn’t have this button.

I am officially puzzled and confused.

Blueprint CSS framework : does it work? Or not?

Chris has an interesting example of Blueprint CSS framework not working. The code looks like it should work, but it doesn’t. And since it was me who recommended Blueprint CSS to him, I felt like I had to understand what’s going on. Or at least find a working solution. First, I tried his code snippet, and indeed it wasn’t working.

<div class="container">
    <div class="span-24 last">
        <div class="span-4 first">4</div>
        <div class="span-10">10</div>
        <div class="span-10 last">10</div>
    </div>
</div>

It was breaking the last DIV into a line of its own, which is not what you or I would expect. After a few minutes of going back and forward, I started with an empty HTML file and started copying Blueprint CSS examples one by one, trying to figure out how to make it work. And here is the code that did it for me.

<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Blueprint Test</title>
        <!-- Framework CSS -->
        <link rel="stylesheet" href="blueprint/screen.css" type="text/css" media="screen, projection">
    </head>
    <body>
        <div class="container">
            <div class="span-4">4</div>
            <div class="span-10">10</div>
            <div class="span-10 last">10</div>
        </div>
    </body>
</html>

The biggest two differences between the version that works and the version which doesn’t seem to be an additional DIV with “span-24 last” classes, and the “first” class added to the first content DIV.

With this I have to agree with Chris, that it should have worked.

Day in brief

  • I've heard about Standard PHP Library (SPL) a billion times. Always wanted to use it for something. Today I finally did. Awesome! #
  • I favorited a YouTube video — F**king Matt Damon & Ben Affleck! TOO FUNNY!! http://youtu.be/5l9BcreGd-M?a #
  • I favorited a YouTube video — Letterman – George Clooney's Boyfriend http://youtu.be/ometb79hMh0?a #
  • The plan for the weekend was to catch some sleep. It's 4:37am, Saturday morning and I am not in bed yet. Plan #FAIL #
  • I favorited a YouTube video — Настоящая показуха.wmv http://youtu.be/gbG75akOvBo?a #

CakePHP + GraphViz = making sense of a numerous models

NOTE: THIS IS VERY MUCH OUTDATED! Read about the update or go directly to GitHub repository for the new version.

 

I have a task at hand.  I have to re-introduce myself to a rather large codebase.  It’s a project that migrated to CakePHP a couple of years ago and haven’t seen since.  There was a whole team of people working on it sense then, and now I need to make sense of all those changes that were done and help reorganize and refactor them a bit.  When I looked into CakePHP’s models/ folder, I was surprised to find 50+ models there.  Each and every one of them links to other models.  And documentation is practically non-existing.  How do I go about it?  I hack up a little script to help me out.

There is a really elegant and beautiful tool for graphing things – GraphViz.  If you haven’t heard of it, you need to drop whatever is that you are doing and familiarize yourself with GraphViz.  Right now.  Right.  This. Second.  You are missing out a whole universe until you do so.  I’ll wait.

Now that you are back, I just want to mention a very slick tool, which is a part of GraphViz package – dot.  It is a simple language in which you can describe graphs.  Sort of like “A goes to B, which goes to C”.   You specify your graph in a very human readable format in a text file, and then dot will transform that text file into an image format of your choice (PNG, JPEG, GIF, etc).  The primary beauty of this is that those text files can be generated automatically by using pretty much any programming language.

So here is what I did.  I assumed the following:

  1. Project documentation should be in app/docs/ folder.  That’s where I’ll put the script and that’s where it will generate the dot configuration, dot later will generate the graph of all my models and their relationships.
  2. Main project application folder is app/.  Models are stored in app/models/ folder.
  3. Project can have a number of plugins, which can have their own models, which I still want to know about.  Plugins are in app/plugins/ and if plugin xyz has models, they are stored in app/plugins/xyz/models.
  4. My project is under version control.  Specifically I use Subversion, but it’s easy to adjust the script to support other systems.
  5. I can get current project revision by running a command in shell.  For Subversion that is /usr/bin/svnversion.

I probably assumed a whole bunch of other things, but you can get an idea of how simple the setup is from the above ones.

Here is how I generate a graph of all models and their dependencies:

cd app/docs/
php -f graph.php > graph.dot
dot -Tpng graph.dot > graph.png

Obviously, I can’t show you the full graph from that system (it’s not open source, it’s not mine, and it will drive you insane in a matter of seconds), but here is how a small part of that image looks like.

There is a different colour for each type of model relationship ($belongsTo, $hasMany, and $hasAndBelongsToMany). Each model folder is in a separate sub-graph cluster. There is a legend graph on the image. The current time stamp and version control revision are also imposed on the image for easier referencing.

And here is the source for the graph.php script. Feel free to modify any way you like. If you spot any major bugs or better ways of doing things, please let me know in the comments.

Continue reading CakePHP + GraphViz = making sense of a numerous models