/dev/null

Elite is stupid. Back to the roots.

September 3, 2010

Ape: Ajax Push Engine

Tags: , — 22:20

Let me say a few words about Ape, an Ajax push server I came across this week:

http://www.ape-project.org/

Even though the authors say it’s a stable 1.0 release and “insanely great”, there are some issues you should be aware of. I write this in the hope that it helps others to evaluate the server and to give feedback to the developers. The general idea of combining fast C code with JavaScript is very good. It’s still a young Open Source project and has a lot of potential.

Incomplete documentation

It turned out to be a little bit challenging to develop code for Ape because of the quality of the documentation. There is an API documentation (which is not good for new users) and there is a Wiki with some links leading to missing pages. Most of the examples deal with how to implement a chat server. In fact Ape was previously named ACE (Ajax Chat Engine). It’s sometimes hard to understand how to use it for a general purpose application and what the limits are.

Maximum length of channel names

One of these limitations is the maximum length of 40 characters for channel names. In my library I use channel names like ‘foo.bar.baz’ that can be easily published with OpenAjax on the JavaScript side. Some of these events never arrived nor did the subscribe function throw an exception.

Nickname required to connect to server

At first it seemed like the server requires a nickname to connect, which makes sense for chat applications only. Not every Web site out there should ask the user to enter his nickname, right? After investigating the issue (I didn’t find a hint in the documentation), I found out that an example server-side script in /var/ape/examples was causing this behavior. You can comment out this line in main.ape.js to “fix” it:

include(“examples/nickname.js”);

Error when sending messages to empty channels

If you happen to send a message to a channel that is currently not subscribed (Ape calls it “joined”, like in a chat software), you’ll get an error. This behavior is strange, if you are used to other message servers that just accept the message, even if nobody will ever get it. If you know this can happen, it’s not so much of an issue anymore.

Complicated domain name setup

Ape uses sub domains in the form of [Number].ape. to communicate with the JavaScript client. Each connect increases the number (which is stored in a cookie) by one. They call the numbers “frequencies”. According to the documentation, this concept should provide sessions within a session, if you open multiple tabs in the same browser. I’ve never seen something like that before. I disabled the feature by modifying their code and tracking the different tabs on the server side. My code will be published later, so you can copy this, if you like. Another problem with the changing domain names is that you have a hard time to set this up locally in /etc/hosts – there is no support for wildcards.

Config directly inside the JavaScript library

I found it really strange to configure the Ape server URL directly in Build/uncompressed/apeClientJS.js. If you ever update this file, your config will be overwritten. Why not provide the config as a parameter to the load() or constructor function? Again, I modified the code.

Based on MooTools

There are two versions of the client library, one for MooTools and one for other JavaScript frameworks, which includes MooTools. I did not find out yet, why you need MooTools to write an Ajax push library for general usage. I also did not investigate how many files are loaded additionally when the Ape library is included. My feeling tells me, that this whole thing can be improved and that the library should be compressed and put in one single file.

No standard protocols

Even though it probably is possible to connect Ape to a general usage message server (like ActiveMQ or RabbitMQ) with some additional work, it does not offer a standard STOMP or AMQP interface by default. The Web site states that the Ape protocol is faster than everything else. So far, I was not able to confirm or reject that claim ;)

JavaScript on the server side

It is convenient to be able to use JavaScript on the server side. Just let me note that this can lead to previously unexpected errors. JavaScript is a loosely typed language and if you happen to return a number instead of a string as nickname to the server, you will see this exception:

/var/ape/examples/nickname.js:6:TypeError: params.name.toLowerCase is not a function

August 24, 2010

FrOSCon not relevant?

Tags: , — 22:49

The hobby experts on Wikipedia say that FrOSCon is not relevant:

Keine Relevanz [...] ersichtlich. Die Fotos lassen auf eine eher familiäre Veranstaltung schliessen.

Well, I havent looked at it this way so far. FrOSCon is not exactly a small “family event”… the discussion was a good laugh before going to bed :D

Money lost during wire transfer

Tags: — 10:35

Isn’t it funny? I couple of hours ago I write about what could happen IF a bank uses a NoSQL database like Cassandra.

I just got an email from my customer, saying that my money got lost during the wire transfer process at the clearing house. What a coincidence! Did that ever happen to you? I never heard about this before. At least the bank will refund the amount, which is really generous xD

Cassandra

Tags: , — 03:36

Just one short note, before I go to bed.

At FrOSCon I saw the talk about the NoSQL database Cassandra. The guy was pretty convincing. He also said, SQL joins are slow and cumbersome for some use cases (his example was Twitter). Then his slides showed how nicely Cassandra can provide the same data as some kind of materialized view that is constantly updated after data changes. And how secure the storage is with multiple backups and smart fail-safe mechanisms.

I was impressed.

On the other hand, I am skeptical towards the promisses of the NoSQL advocates. And I normally don’t like any software that runs on Java (see Eclipse), but that’s another story. That kind of stuff sounds nice on the paper, but fails randomly in the real world. Probably because it is too smart and advanced.

Directly after I came back home from FrOSCon, I noticed that certain feeds (like replies to me) show very recent tweets only. Nothing older than about 4 days. The search results page says: “Older tweets are temporarily unavailable.” Oh, really?

Imagine you would use this kind of technology to run a bank: “Sorry, we lost your account transactions. We are sure you had at least 10 dollars on your account, so that is all you can get today. Maybe we find the rest later.”

Hopefully they can restore their fail-safe materialized views. Somebody should convince police and government to use NoSQL databases: “Sorry, we lost your criminal record of the last 20 years. You are free to go.”

I know, most NoSQL databases are not made for banking or even business applications. Friends – for example – are not that important/critical and that’s probably why Facebook, the other big Cassandra showcase project, does not really know how many I have. The number changes frequently by ± 1.

August 20, 2010

Notification Free PHP Coding

Tags: — 16:23

This is a reply to http://100days.de/serendipity/archives/50-Notification-Free-PHP-Coding.html. Gaylord Aulke’s opinions are normally quite valuable. There are a couple of arguments (just read the comments) in both directions and to be fair, Gaylord also said, that his opinion is different for frameworks and libraries.

Even though I tend look into PHP notifications (some code produces so much of them, that you can only ignore them), I wasn’t really sure what my final position on Notification Free PHP Coding is and I was not too strict about it.

That changed today.

While demonstrating my reporting frontent for PHPUnit to the customer this month, I had to find out that it’s JUnit/XML logger sometimes produces broken XML files: You can get a “PCDATA invalid Char” exception when loading it with DOMDocument::load(). Sebastian Bergmann encouraged me to send a pull request on github, which is nice. Except that I never contributed to PHPUnit before. Nor did I actively use github. Like Lars Jankowfsky I tend to stay with SVN, when possible (that’s probably worth another blog post).

Anyways: It was easy to fix the bug (actually, it turned out to be more complex) and after reading a couple of git manuals, I found out how to commit, push and send a pull request. The only thing I didn’t notice is that I used the constant ENT_QUOT (undefined) instead of ENT_QUOTES (defined) as an argument to htmlspecialchars() for some reason – this is why I recommend to focus on each line of code to other people…

htmlspecialchars(self::convertToUtf8($string), ENT_QUOT, ‘UTF-8′)

Not a big thing, if I would have seen the PHP notice!

Notice: Use of undefined constant ENT_QUOT – assumed ‘ENT_QUOT’

It was not possible to see it, not because I did not look at the error messages or the test results, but because the default config for PHP on Ubuntu is error_reporting = E_ALL & ~E_NOTICE. To use an undefined constant is just plain wrong and leads to an undefined state of the software – it must be noticed. Also, whenever there are too much notices, you won’t be able to spot it. Therefore the only way to avoid it is to produce notification free code. I don’t want something embarrassing like this ever happen to me again.

Lesson learned.

The Perfect Development Environment

Tags: — 08:49

This is a reply to http://thinkvitamin.com/dev/the-perfect-development-environment/

Work Setting

I prefer to be alone, with no one walking around, having conversations on the phone or asking questions. And yes, barking dogs are bad while you try to focus on source code^^

If people can not keep their mouth shut, loud music helps a lot. Use the headphones, whenever other people are around.

If you do an on-site consulting job, better not keep the client from asking questions though: This is what he (or she) pays for! Same is true, if you happen to be in the role of a lead developer. There is no way to hide behind your screen(s). Not matter how many you have.

Desk & Chair

I prefer a simple chair. All the fancy furniture didn’t work for me:

And a desk made of real wood, not that crappy and cheap IKEA stuff made of plastic and particle board. No dinning room table, those are usually too high (76cm). Remember that the keyboard/notebook has a certain height too. The perfect desk is 73cm high. I agree it should be simple, without “cubby holes, drawers and cord hiders”.

Monitor Setup

As a freelance developer, I need a lot of space on my desk to draw diagrams and sign my invoices. Or just to put the Amazon Kindle. It’s a good replacement for the obligatory PDF readers or word processors that are open in the background and hold the customer requirements.

There are some scientific results that suggest that any screen larger than 17 inch will decrease productivity. Not sure about that. But certainly I don’t want to move my head all the time to collect information from different screens. I was able to work on a JavaScript project with more than 50k lines of code on a 10 inch netbook without problems.

Mouse & Keyboard

I normally have to use the keyboard built into my ThinkPad, which does it’s job quite well. The best keyboard I ever had was a Cherry G80-3000 with MX gold crosspoint technology and without Windows keys. Those times are gone forever. Everything has to be flat in this century and you can get used to it.

As a PHP/JS/C/Perl developer, you will be happy with a US layout. As a consultant not living in the States, you might want to use a local layout, so that you can easily access non-ascii chars while writing your important business documents.

The best mouse I found so far is the Logitech Basic mouse and it is very cheap at the same time. It is available in gray and black. Perfect.

Minimizing Distractions

I usually outperform other developers, even those with 3 screens, not because I am cool, but because I don’t use Windows when not working on some Office document. This reduces the times when I have to explain my customer or co-worker that “it does not work and I don’t know why”. Also it’s easy to get rid of 3D effects, playful window borders and desktop widgets that distract you. Skype looks less like a computer game too, but works equally well. The UMTS modem works every time, not not just every second time (if it fails, you will see a meaningful error message). There is no need to think a lot about which applications to use and there is a standard way for pretty much everything. Last but not least most servers run Unix too, so you don’t experience those strange “file not found” problems after the code was deployed to the production environment. Windows isn’t case sensitive.

System Shortcuts & Project Management

You normally have 3 or 4 windows open that matter:

  1. the console (to run the unit tests and do svn/git commits)
  2. the text editor (gedit)
  3. the Web browser (2 tabs, one with the app and one with google open to search for documentation)
  4. and maybe GIMP (if you work on graphics too) or Skype for talking with other people about the project

Remember that we outsourced requirements documents to the Kindle or real paper where you can scratch around.

Those windows fit into any task bar, even on small screens. You don’t want to see your desktop wallpaper, while you’re working. Maximize your windows and use the full space available (Mac users will complain now, as far as I remember).

Tortoise SVN is crap, but the best you can get on Windows, I guess. Better use the command line applications on Unix. If you do Open Source or want to be cool, you use git and tell all your friends that svn is bad.

IDE & Other Programs

Most editors fail when working on large projects. Eclipse (also known as Aptana, Zend Studio, PDT) used to have a CSS editor that was so slow, that it took several minutes to open large CSS files. The memory management did not work really well – eventually I found a garbage collection plugin, which added small trash button in the bottom right corner that I had to press every time, the memory usage went to high (WTF!?). Just today I enabled the option “insert spaces for tabs”, pressed the tab key and it inserted a… tab. Crap.

Besides those annoyances, the Eclipse file/folder tree does not update automatically and the SVN plugin (there are many with different bugs to chose from, right?) seems as waste of time compared to the straight forward usage of the default command line tools.

Therefore my recommendation is to use gedit, the default editor that comes with Gnome. It’s only downside is that it can not save files on SMB shares (VirtualBox shared folders) because of a bug, and that really is the only reason for me to use Aptana from time to time.

gedit’s major features:

  • It is stable
  • You see the character on the screen, directly after you pressed a key (no delay)
  • You write nice looking code that is readable, even without additional tools, filters and beautifiers
  • The file/folder tree updates automatically
  • Syntax highlighting for JavaScript, PHP and other languages
  • Automatic indentation
  • UTF-8 is default – you never accidentally break the encoding again and get hurt by your co-workers for this
  • Low memory usage
  • The save button works every time (not true for Eclipse, as I had to find out painfully)
  • It doesn’t occupy a lot of the valuable space on the screen

And yes, it can use plug-ins and you can write your own, if you feel something is missing. I am happy with how it is.

Conclusion

I don’t know.

August 15, 2010

AWF-CMS.org online again

Tags: , — 21:03

Ha, after almost 3 years, the home page of my (so far) biggest Open Source project AWF-CMS is online again. When I started working for Zend in 2006/2007, I felt the need to write a version that is based on Zend Framework. Of course I was busy with my customer projects, so that never happened. Even worse, due to a server upgrade, the configuration for the AWF Web site was broken and I didn’t even find the time to fix that until today. This is bad, as I still love the software. It was really useful and probably still is, even though not properly maintained anymore. As you can see, I decided to use WordPress as a replacement. But there is no cool image management/gallery, there is no Wiki, there is just a HTML/WYSIWYG editor for content etc. This is way behind what AWF-CMS could deliver. At least it is possible to manage multiple sites since WordPress 3.0 – a feature that was available in AWF for a very long time.

Anyways, you can not dance on every party, as we say in Germany :)

August 1, 2010

My favourite music

Tags: , — 17:40

After waiting for 29 years, I finally feel like I know what my all-time favourite music is – I been thinking about this a lot lately. Isn’t this one of the most frequently asked questions when you meet new people? Ok, maybe not on a computer conference or in the office. Anyways, I can be a nerd next time and give them a link to this page…

#1 video

The Smashing Pumpkins – Today

#1 artist (I love all their albums)

Placebo

#1 song (guess this doesn’t come as a surprise)

Nirvana – Smells like teen spirit

and finally the #1 album

The Jealous Sound – Kill Them With Kindness

July 15, 2010

It’s really hard to talk about JavaScript best practices and JMVC

I was totally enthusiastic, when I first learned about JavaScriptMVC – because it brings all the best practices you are accustomed to into the JavaScript world. That means the MVC architecture, Object-oriented development with simulated inheritance, EJS templates, easy testing, OpenAjax support, powerful event delegation and so on.

However, I often have a hard time to convince other developers about those advantages. I guess testing is the easiest one, because no developer would dare to argue against testing, even though many developers don’t do it or don’t do it right. Questions and discussions about testing seem to be very rare. Developers just discuss it with their non-technical managers, if they want to get around that “effort”.

But it already starts with OpenAjax. I rarely find a developer that knows what it is and what it is good for and why you might need an event hub in JS at all. Zend, W3C, IBM and Google are some of the more well-known members of the OpenAjax Alliance. If you hear about it the first time now, take the time to have a look.

Just yesterday I was talking to an obviously experienced JS dev (who was working for a well known mobile phone company), that was browsing through the JavaScriptMVC documentation and stopped in the chapter about EJS templates: “Yeah, I saw something similar in our own project and removed it. It is confusing, if the JS code and the HTML are in separate files, because you don’t see the code together in one file. HTML should only be edited by developers who know the JS code very well”. Not sure what to say about that. Why not give up separation of concerns at all and put everything in one big file? Then you see the big picture on your hopefully big screen. Also you always need to check the full version control system diff after each change because the file name alone doesn’t tell you what was changed and you probably have more of those exciting conflicts to resolve. And: You REALLY need to be an expert to understand what is going on. The company can never fire you, because no one else would ever understand that kind of code. Sorry for being sarcastic, but that kind of attitude can seriously damage the health of innocent other people who need to clean up the mess in 20h work days afterwards, to meet the deadline of the project. Or the project is so small that it doesn’t matter. Or the company you work for can afford to pay a lot of developers who have the time to maintain a JS app without templates.

Convincing people about the usefulness of controllers is not easy too. Either you start showing an OpenAjax subscribe action – then the developer most likely won’t understand what that is good for (see above). Or you talk about event delegation, then the developer will point to jQuery’s live() method, which does event delegation too. In fact, JavaScriptMVC’s event delegation used to be one of the strong points and I admit that I am not totally up to date with the whole discussion right now, because I was busy with a PHP project during the last 6 months. I know Justin Meyer is/was working on the controller code so that it makes more use of jQuery, he contributes code to jQuery and he is in contact with John Resig. Anyways, the whole point about controllers again is separation of concerns and not so much the technical details behind the scenes. The JavaScript world is moving very fast and implementation details change a lot, but separation of concerns is not really something that you can look at as something you probably don’t need. The JS world sometimes feels like the PHP world about 10 years ago.

Ok, after getting rid of those thoughts, I will return to work now. The next 2 weeks will be quite relaxed with very little work. So maybe, I can read through the new JavaScriptMVC code and update my knowledge. It really feels uncomfortable not the be able to answer questions in detail. Also I start confusing PHP and JS syntax *lol*

See also: http://jupiterjs.com/news/talkin-javascriptmvc-is-hard

June 21, 2010

Howto: Connect to a Cisco VPN using Ubuntu Linux 10.04

Tags: , , , — 21:03

Argh, I spent the whole day figuring out how to connect to the VPN of my current customer. The Windows client on my other computer works just fine, at least after selecting the UDP option. But it is quite some overhead to install Windows on my Linux box just to connect to a VPN. The proprietary Cisco VPN client for Linux works until kernel version 2.6.25 AFAIK. Therefore, This is no option for all users of Ubuntu 10.04.

There is an Open Source client for the cisco vpn concentrator that replaces the Cisco client: vpnc

It can be installed on the command line using

sudo apt-get update && sudo apt-get install vpnc resolvconf

Once you’ve done this, you will want to create a config file for your VPN:

/usr/share/vpnc/pcf2vpnc ciscovpnconfigfile.pcf > default.conf

Now move that file to /etc/vpnc:

sudo mv default.conf /etc/vpnc

Theoretically you should be able to use the VPN now like this:

sudo vpnc

And terminate it like that:

sudo vpn-disconnect

Of course it would be too easy this way. There were a couple of changes I had to apply to the config file:

First of all and most importantly, the line

Application version Cisco Systems VPN Client 5.0.07.0240:WinNT

simulates a Windows client, which the Cisco concentrator at my customer’s network checked for. If that is the case and it refuses the connection, you won’t see any error that tells you about it, vpnc just won’t connect properly and say “no response from target” after several seconds! It took a long time until I figured that out, but just because I had a similar problem with an older Windows client previously. Also it’s hard to find out, how the version string is supposed to look like.

The other line I added was “NAT Traversal Mode cisco-udp” and if you like “Xauth password XXX” to store your password in the config file, so that you don’t need to enter it each time you connect.

Hope that works for you!

Older Posts »

Powered by PHP, Memcached, Suhosin, MySQL and WordPress