IDEA fucked up indices

Since v7 (I think), IDEA has had some internal indexing strategy of the files in projects. These indices somehow got messed up in my current Diana install. I started getting exceptions like:

java.lang.NullPointerException
        at com.intellij.psi.stubs.StubTree.(StubTree.java:9)
        at com.intellij.lang.javascript.index.JSPackageIndex$2.map(JSPackageIndex.java:60)
        at com.intellij.lang.javascript.index.JSPackageIndex$2.map(JSPackageIndex.java:91)
        at com.intellij.util.indexing.MapReduceIndex.mapNew(MapReduceIndex.java:82)
        ...

and

java.lang.AssertionError
        at com.intellij.util.io.storage.Storage.deleteRecord(Storage.java:315)
        at com.intellij.openapi.vfs.newvfs.persistent.FSRecords.b(FSRecords.java:213)
        at com.intellij.openapi.vfs.newvfs.persistent.FSRecords.a(FSRecords.java:296)
        ...

In addition, one file showed in IDEA to have strange content, looking like it came from another sourcefile. Though, when i looked into the file from the console, it wasn’t changed at all.

I ended up solving this by closing down IDEA and deleting its cache files (on my Mac stored in ~Library/Caches/IntelliJIDEA8x/caches).

Starting IDEA again and opening my project, it rebuilt indices and everything seems to work again :-)

April 3, 2009  Tags:   Posted in: Tools  5 Comments

Problem Adding Flex SDK in IDEA

…on a Mac or Linux.

I downloaded the latest Flex SDK from Adobe and simply unzipped the files in a directory on disk. I then entered module settings in IntelliJ IDEA and tried adding a new Flex SDK, simply by pointing IDEA at the unzipped directory. But, IDEA complained that “the selected directory is not a valid home for Flex SDK”. It took me a little while to discover what was wrong. The file permissions were wrong!

When unzipping the flex sdk zipfile download, the unix file permissions for group and other are cleared to 0, which means no permissions. This is a problem when unzipping with “sudo” (or as root) into /usr/local, and then running IDEA as another user, because that user cannot read the files and directories.

These two commands solve the problem, when executed in the unzipped Flex SDK directory:

sudo find . -type f -exec chmod go+r {} \;
sudo find . -type d -exec chmod go+r+x {} \;

they add read bit on all files for group and others and read and execute bit on all directories, again for group and others.
One last thing: I had to restart IDEA to make it see these changes (you might be able to simply click refresh in the file dialog).

January 30, 2009  Tags: ,   Posted in: Tools, Uncategorized  No Comments

Changing Port Number of svn+ssh Subversion Protocol

Most times, when we access subversion through the svn+ssh:// protocol, we are satisfied with the default behaviour, which is simply spawning ssh behind the scenes, and have it connect using the default port 22 of the ssh protocol.

But, sometimes this is not enough. In my previous post I just described how ssh is great for tunneling and port forwarding. To access a remote subversion server, which was hidden behind a firewall and two hops into the system behind it, I had to port forward a local port all the way to the ssh port 22 of the behind the firewall host. My local ssh port that was tunneled into the remote system ended up on a local port, say 12345.

So, how to tell subversion to spawn ssh with a config of port 12345, when accessing a svn+ssh://-like URL? Well, turned out to be quite easy.

Subversion has a local configuration file .subversion/config, which can be used for various, … hmm, configuration stuff :-) A cool thing is, that one can provide new protocols. So, with this configuration in .subversion/config:

[tunnels]
sshtunnel = ssh -p 12345

I can use a subversion URL like this: svn+sshtunnel:// and subversion will spawn the given command with the port option.

Great tool – subversion.

January 11, 2009  Tags:   Posted in: Tools  6 Comments

SSH Tunneling Tricks – Executing a specific command at pubkey authentication

OpenSSH must be – by far – the most neat, handy and cool tool in the tool chain. At least when accessing remote unix boxes, that is.

Currently, I have been preparing a laptop for some remote work, and have been using OpenSSH to dig some tunnels through the company firewall, through a couple of hops and forwarding some ports along the way. One neat trick I picked up in setting this up, is how to execute a specific command when logging in through public key authentication.

Most of us know, how creating a public/private key pair with ssh-keygen and the putting the pubkey in the .ssh/authorized_keys2 file on the remote host, allows us to login to that very host without giving username and password all the time.

But what I did not know, was that the public key line in the .ssh/authorized_keys2 file can have a command-prefix. Here is an example:

command="ssh nexthop" ssh-dss AACBAJzPxSaB8B3GYgX5zUUXtYyLd...  comment-here

Yep. You simply prefix the key line in .ssh/authorized_keys2 with a command="" prefix, and then put the command inside the quotes. Each time a login is made with the private key of this public key, the command will be executed instead of a shell being spawned.

And why is this interesting for digging tunnels and forwarding ports along the way? Because the command executed can be another SSH command, which then connects to the next hop along the path to the hosts I need to reach. And the SSH command can even have -L local forwarding options on each hop, setting up a stream of forwarding into the system. I simply created a specific public/private key pair for this tunnelling setup, and added a Host section in my .ssh/config file to force login with that identity. I then login using this Host configuration, when I need the tunnelling setup.

Neat hugh!

January 11, 2009  Tags: ,   Posted in: Operating Systems, Tools  2 Comments

Flex-Mojos keepAs3Metadatas Option to Apply keep-as3-metadata Compiler Option

If you use the flex-mojos plugin to compile flex code in a maven project, you might have the need to apply the -compiler.keep-as3-metadata option to the compiler, like I did.

The documentation for compile-swf mojo says to put something like the following, into the configuration element:

<keepAs3Metadatas>
   <metadata>Bindable</metadata>
   <metadata>Events</metadata>
</keepAs3Metadatas>

but that failed horribly. It seems like maven tries to instantiate a Metadata class (which I think the mojo use for applying author metadata to the flash), for each metadata element, which is wrong (and fails the build). Well, the solution was simple, name it something else, like here, where I name it name:

  <build>
    <plugins>
      <plugin>
        <groupId>info.flex-mojos</groupId>
        <artifactId>flex-compiler-mojo</artifactId>
        <extensions>true</extensions>
        <configuration>
          <keepAs3Metadatas>
            <name>ConditionalShow</name>
          </keepAs3Metadatas>
        </configuration>
      </plugin>
    </plugins>
  </build>

December 29, 2008  Tags: ,   Posted in: Rich Internet Applications  No Comments

Docked ApplicationControlBar Is Not In Children List

Here is a funny thing about how ApplicationControlBar acts differently as a child when docked and not docked.

I had to write some code that traverse the complete tree of components in a flex application, and that was when I first discovered about rawChildren lists. It turns out, that not all components are added as children to containers. Some are added as rawChildren instead. I first thought this to be for stuff like borders, title bars, dividers, … that does not have real meaning for the application, as for instance input fields and buttons has.

Well, it turns out I was wrong. The mx.core.Application container has special handling for mx.containers.ApplicationControlBar. Here is the source code for Application.dockControlBar:

    mx_internal function dockControlBar(controlBar:IUIComponent,
            dock:Boolean):void
    {
        if (dock)
        {
            try
            {
                removeChild(DisplayObject(controlBar));
            }
            catch(e:Error)
            {
                return;
            }

            rawChildren.addChildAt(DisplayObject(controlBar), firstChildIndex);
            setControlBar(controlBar);
        }
        else // undock
        {
            try
            {
                rawChildren.removeChild(DisplayObject(controlBar));
            }
            catch(e:Error)
            {
                return;
            }

            setControlBar(null);
            addChildAt(DisplayObject(controlBar), 0);
        }
    }

as you can see, if the control bar is in docked state, it will be added only to the rawChildren list and not to the children list. And vice versa.

What this meant to me was, that when I traversed children lists of containers down in the component hierarchy, I did not see the ApplicationControlBar instance.

Well, lesson learned.

December 29, 2008  Tags:   Posted in: Programming, Rich Internet Applications  No Comments

Resizing Flex Dialog to Flash Dimensions

Not long ago, we had created a flex dialog with fixed width and height, which gave users with less screen resolution a real problem. The dialog was opening with the titlebar and close buttons outside the screen. Hence, the dialog couldn’t be closed and it couldn’t be moved.

Here is how to make the dialog resize itself according to the screen estate that the flash has been given:

<?xml version="1.0" ?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()">
    <mx:Script><![CDATA[
        import mx.core.Application;
        private function onCreationComplete() : void {
            height = Application.application.stage.height - 20;
            width = Application.application.stage.width - 20;
        }
]]></mx:Script>
</mx:Panel>

It is really simple. You go through the Application singleton to reach the Stage. And the stage know about the width and height of the flash.

December 1, 2008  Tags: ,   Posted in: Programming, Rich Internet Applications  2 Comments

Is DDD Worth It? It Surely Aint Gonna Save Us!

In this post, I will play the devils advocate a bit.

I attended several of the sessions in the Domain Driven Design (DDD) track on Øredev 2008 today, and to the end of the panel debate, I kind of got to thinking: “Why actually bother ourselves with DDD?”

Now, don’t get me wrong here. I actually like the idea of extra emphasis on domain modelling in our profession. Indeed, I wrote “DDD Wanna-Be” as the tagline on my conference pass. I really wanna do DDD. By I also got to thinking: “Why, actually?”

Being the Devils Advocate

It is old knowledge in the computer science industry, that no new tool or language are going to make us orders of magnitude more productive than yesterday. When going from imperative procedural to object-oriented programming, we get to express models in another way, said to be more like the real world. But it really does not make us any more productive than we were in the imperative thinking.

Likewise with DDD. I cannot see it making us orders of magnitude more productive, than when not doing DDD. I really do not. Sure, distilling the core domain seems a good idea, and protecting it with an anti-corruption layer might also be a good idea. And so on. But overall, the development of an application will not go way faster as a consequence of applying DDD. Actually, I think applying DDD to your application development can have the effect of slowing you down. At least while you learn. This is okay, if there is a bonus in the end. But is there?

And do the computing industry actually need saving? It is repeated again and again, how too little focus on domain modelling will create messy, unmaintainable systems. Maybe so. Maybe not. In close co-operation with colleagues and clients I have helped build lots of systems, that both meet the users needs by supporting the business domain while at the same time being maintainable. And we were not practising DDD.

Back to Being Myself Again

So why do I still like the idea of striving for more domain modelling?

Maybe because I find it an interesting academic exercise. Maybe because I see emerging DDD-supporting, interesting technology in stuff like spring load-time-weaving to inject into all of the domain, that I will get to play with then. Maybe because it is something new. Maybe to not be bored by always doing what I did yesterday, even though it worked for me just fine yesterday. Maybe to bring the fun back.

Do you do DDD? And if so, why? Honestly :-)

November 19, 2008  Tags: ,   Posted in: Design, Programming  7 Comments

The D Programming Language Is Not For Me

Today at Øredev 2008, I learned about the programming language D, but also that D is not for me.

I had not had the chance yet, to sit down and take a look at D, so I thought it would be a nice idea for me to attend the session named “What Makes a Programming Language Productive?” by Walter Bright, one of the people behind D. So I had completely no knowledge of D before I entered the session.

Now, the conference material did not mention anything about D being a systems programming language, something I kind of found out half-way through the session. And now I also understand why the language designers thought they had done some great things with stuff like automatic memory management and garbage collection, no pre-processor, automatic documentation generation from comments in the source, type inference, etc…

But, being an application developer myself, working with languages like Java and C# in addition to easy access to dynamic languages on the VM, not many of the constructs seem new or that special to me. But I guess they will be for C and C++ programmers doing systems programming.

But this is not the only thing that I find not to be for me.

The D language is said to support multi-paradigm programming. What this means is, that you can write imperative code in the old C-style, object-oriented code, inline assembler, template meta-programming and soon also functional programming in the same language – namely D.

Walter said this to be an advange. If for example, you wanted to express a part of your program in another paradigm, you would not have to learn a new language and interface with that from your D program. True, I guess, to some extent, at least about the integration part. But these are completely different paradigms. Learning to program in a functional language aint that much about syntax, but very much about understanding problem solving in the functional paradigm. Likewise in an imperative or object-oriented paradigm.

But D tries to express multiple paradigms in D alone. That way you won’t have to switch programming language, to express something in another paradigm. I would really think that another design goal of D: “Have a short learning curve for programmers comfortable with programming in C or C++” would go against its goal of being multi-paradigm.

How can one syntax support all those paradigms in a nice and concise manner?

How can the semantics of interoperating code between several paradigms be done simple enough, for it to be understandable and usable?

November 19, 2008  Tags:   Posted in: Programming  10 Comments

RubyMine – A New Ruby IDE

Here is something interesting.

JetBrains is releasing their ruby and rails support in IDEA as a specially targetted product called RubyMine. I just took a download of the preview and tried it out. To a long term IDEA user, it looks an awful lot like, … IDEA :-) I guess it is “just” a slimmed down version of IntelliJ IDEA, with “only” the ruby and rails support, together with various VCS plugins.

This is actually what Sun have been doing with Netbeans for some time now. Providing a slimmed down download of Netbeans, that only includes their support for ruby and rails.

November 4, 2008  Tags: , ,   Posted in: Tools  No Comments