The beauty of open source ...

Submitted by Jochus on Mon, 11/10/2010 - 00:09 | Posted in: Drupal
Posted in

For the last 4 years, I have been working with a lot of open source software. I once had a project with a commercial software package, and I have to say ... I really missed the open source world. But why? ... Well, there are 2 reasons:

The first reason: if something goes wrong, or you don't understand why it's going that way, you just check the source code. In most of the cases, it was the developer who implemented the link to the core incorrect. But by understanding the core, you can learn a lot. How to make a call to a core function? Etc, etc, ...

The second reason: you have the communities. People who are really willing to help you, without wanting anything for it. I've been in a lot of communities, but the community of Drupal is really crazy. There are soooo many developers in the world, sharing their thoughts on the internet. Or who are just trying to help you for free.

Now, I have this nice example of an open source world. I once had a strange problem with Drush (which is a CLI tool for Drupal). By checking the code, I could understand what was going wrong. So I logged this ticket: http://drupal.org/node/933110. Now, if you check the ticket, you see I'm actually applying a patch for the problem. But what's a patch?

A patch is a piece of software designed to fix problems[1] with, or update a computer program or its supporting data. This includes fixing security vulnerabilities[1] and other bugs, and improving the usability or performance. Though meant to fix problems, poorly designed patches can sometimes introduce new problems (see software regressions). Patch management is the process of using a strategy and plan of what patches should be applied to which systems at a specified time.
Source: http://en.wikipedia.org/wiki/Patch_%28computing%29

So the developer looked at my code, and he actually applied to patch to the source tree :-). You can see it here: http://drupal.org/cvs?commit=432252. I strongly believe that this way of working is so efficient. The product gets so easily corrected and improved ... and this is a big reason why Drupal is amazingly growing these days ...

TracTicketChangesetsPlugin vs TracTicketChangelogPlugin

Submitted by Jochus on Fri, 08/10/2010 - 00:21 | Posted in:

For the last few weeks, I have been testing 2 plugins for Trac: TracTicketChangesetsPlugin and TracTicketChangelogPlugin. The first seemed to me more mature (more development, documentation, etc ...). But it was really a pain-in-the-ass to get it working. There are way too many steps to let it work ... and in the end ... I didn't have any success.

So then I started working with the Changelog. I had some issues with Python 2.6 (plugin was build for Python 2.5). More details can be found here: http://trac-hacks.org/ticket/7746. The plugin was requiring simplejson, which is a package for Python 2.5. That package doesn't exist for Python 2.6 as the last version has "json" built-in. So I manually had to change the source.

After changing the Python code, I was able to install the plugin, but I still wasn't able to see any changelogs. It noticed that I was using


#{ticket_number}: {my_custom_message}

Notice the ':' character. The standard regex (log_pattern = \s*#%s+\s+.*) does NOT support this. So after altering the regex: log_pattern = \s*#%s+(:)\s+.*, I was able to see my changelogs.

Now, the importance of this plugin: we are able to get an overview of which changes are made for which ticket. The only thing you have to do, is to include the ticket number in your SCM commit message :-)

How to disable the 'ckeditor' on Drupal's contact form?

Submitted by Jochus on Thu, 07/10/2010 - 00:57 | Posted in: Drupal
Posted in


Well one of the nice Drupal modules we are using is ckeditor.

This module will allow Drupal to replace textarea fields with the CKEditor - a visual HTML editor, sometimes called WYSIWYG editor. This HTML text editor brings many of the powerful WYSIWYG editing functions of known desktop editors like Word to the web. It's very fast and doesn't require any kind of installation on the client computer.

So what is ckeditor?
CKEditor is the next version of FCKeditor. The editor has been rebranded and completely rewritten. It is now much faster (the code has been optimized), loads faster (the number of files has been reduced, so the browser will perform less HTTP requests) and developers friendly.

This editor is really working fine. Installation is very simpel: you just install the module in your sites/all/modules folder and you install the ckeditor implementation of http://ckeditor.com/download.

Ok, the first thing I noticed when enabling the module: EVERY single textarea in the Drupal site was rendered with ckeditor :-/ ... For example: the contact form was changed into a ckeditor. I just want to have ckeditor for changing pages. How do you fix that?

The solution contains 2 important steps:

  • disable the ckeditor for all textarea's: go to Site configuration > CKEditor. Edit: CKEditor Global Profile. Choose: Visibility settings and change Use inclusion or exclusion mode: to Include. Now what does this mean? ckeditor will only appear in the pages you describe
  • when you go to a textarea, ckeditor will add some help text at the bottom of the textarea. For example: CKEditor: the ID for excluding or including this element is page@node/6/edit.edit-body.. Now, I don't want to add this line to the Include pages list for every single node, so I provided a kind of regex for this (it's not really a regex...). The trick is to change the node number into a wildcard, like this: page@node/*/edit.edit-body

It's a clean solution to decide on which pages a ckeditor should be used :-)!

Eclipse: performance issues with PDT

Submitted by Jochus on Mon, 04/10/2010 - 00:06 | Posted in: Drupal
Posted in

I've been using Eclipse PDT for a while now. It's very easy to connect my IDE to my Drupal site. And it's very easy because I can easily access my Java projects too :-).

But I was running into some performance issues: Eclipse seems to be veryyyyy slow, and very unstable. I had to restart it every 2 hours. At DrupalCON, I also noticed some people were having troubles with Eclipse and performance. So I hope this blogpost will help a lot of people.

First of all, this blogpost is created based on a Ubuntu Lucid 10.04 operating system. I'm not using open-jdk, but I'm using the real implementation of Sun (well, Oracle :p)

<a href="mailto:jochen@DESKTOP">jochen@DESKTOP</a>-JOCHEN ~ $ dpkg -l | grep sun
ii  splix                                2.0.0-2ubuntu3                                  Driver for Samsung's SPL2 (bw) and SPLc (col
ii  sun-java6-bin                        6.20dlj-1ubuntu3                                Sun Java(TM) Runtime Environment (JRE) 6 (ar
ii  sun-java6-jdk                        6.20dlj-1ubuntu3                                Sun Java(TM) Development Kit (JDK) 6
ii  sun-java6-jre                        6.20dlj-1ubuntu3                                Sun Java(TM) Runtime Environment (JRE) 6 (ar

To be sure you are using the Sun implementation (or you want to see a list of JDK's on your machine), you can run the following command:

<a href="mailto:jochen@DESKTOP">jochen@DESKTOP</a>-JOCHEN ~ $ sudo update-java-alternatives -l 
java-6-sun 63 /usr/lib/jvm/java-6-sun

Anywayz, the important things is to create the following file: /usr/lib/eclipse/eclipse.ini
This is the contents for that file:

-vmargs
-Xms128M
-Xmx512M
-XX:PermSize=128M
-XX:MaxPermSize=512M

  • vmargs: param indicating I want to specify "virtual machine" arguments
  • Xms: initial Java heap size
  • Xmx: maximum Java heap size
  • XX:PermSize: the section of the heap reserved for the permanent generation holds all of the reflective data for the JVM. This size should be increased to optimize the performance of applications that dynamically load and unload a lot of classe
  • XX:MaxPermSize: maximum size of the Permanent Generation

Now, it's very important to create each argument on a new line. Don't do this:

-vmargs -Xms128M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=512M

... don't ask me why this doesn't work, I think this is a bug in Eclipse ? ...

Now, to end this blogpost, we need to be sure this configuration is ok!? Right?
Fire up Eclipse and go to Window > Preferences. Pick General and check Show heap status

Now, to check if your settings were picked up by Eclipse, check the bottom right of your screen. You should something like this:

This will show you the heap size, as also a possibility to run the garbage collector (force it) by clicking the trash icon

Eclipse: PHP debugger failed to pick up breakpoints

Submitted by Jochus on Thu, 30/09/2010 - 00:11 | Posted in: Drupal
Posted in

Well, I was extremely happy to create this blogpost. But a time ago, the debugger stopped working. I had no idea why, and I couldn't figure out what the problem was.

Randy Fay helped me out on this one. Check this screenshot:



The Server debugger was configured for XDebug, but I was using Zend. Switch that setting, and debugging was working again! I don't know why the setting was switched. I'm sure I didn't change it ... So I hope it stays this way :-)

PUSH: real time information through your existing web browser, no reloading and no plug-ins – a web developers dream

Submitted by Jochus on Wed, 22/09/2010 - 00:15 | Posted in: Drupal
Posted in


Most of us (yes, except for Sander ;-)) are using Facebook. There's a small Facebook chat client in the browser, which makes it possible to chat with your friends.
Did you ever notice how fast this chat is going? I mean, you press enter and 1 second later, the message appears on the other PC.
I think this seems rather normal for a person who doesn't know much about programming, but for a developer, this is rather amazing. Everybody knows "polling": a technique were you refetch some blocks from the server after a period of X seconds. But working with polling means: introducing a certain delay (maximum X seconds).

I'm currently working on a project were we also need real time information. No, it's not a chat, something different. I cannot give much details now (it's all top secret you know ;-)), but I have been playing around with http://www.ape-project.org/.

What is APE?

APE is a full-featured OpenSource solution designed for Ajax Push. It includes a webserver (Comet implementation) and a Javascript Framework. APE allows to implement any kind of real-time data streaming to a web browser, without having to install anything on the client-side.

 

Why APE is insanely great?

APE, previously named ACE (Ajax Chat Engine), is an awesome piece of software whose development started in early 2006 with the democratization of the AJAX technology. Our product is based on principles and philosophies we care about (Open Source, Accessibility, Future of the Internet). As for that, we think we have created something insanely great.

Only web standards!

APE only uses web standards (with the use of Asynchronous JavaScript and XML (AJAX)). You do not need any plugins to be installed on your web browser, just enjoy!

Push, don't pull!

APE is a Server for pushing real-time data to Rich Internet Applications, no pull! Data is sent, live, to thousands of clients, in a JavaScript socket fashion. It allows you to write real-time web applications without using any client plugins (Java, Flash...).

Usability!

APE works with all of the Internet browsers, it is cross-platform and cross-subdomain. It works on mobile devices, smartphones, video game platforms, as long as they include a web browser.

100% FREE & OpenSource!

The APE Project is 100 % Open Source and FREE for commercial and non-commercial use, released under the GNU Public Licence version 2. We want to contribute to a better web by sharing our technologies.

 

The Ajax Push Engine Project is divided into two distinct parts. The most central part is our epoll-driven HTTP streaming server, the APE Server. Through the APE Protocol, the APE JavaScript Framework sends and receives the actions on the client side.

 


The APE server

APE Server is an Comet server implementing the POST and GET methods of the HTTP protocol. It does not replace a regular Web Server (such as Apache, Lighttpd or Nginx), however, the APE Server is only used for AJAX Push.

  • Fully written in C
  • Publisher/Subscriber based
  • Scalable
  • Linux, BSD & Mac OS X Support
  • Epoll-Driven (KQueue for BSD)
  • Fully Asynchronous
  • Server-Side JavaScript (SSJS)
    • Extend APE protocol
    • Mootools powered
    • Built-in Message Queue system
    • Extendable

 


The APE Javascript framework

Written with the use of the MooTools Library, the APE JavaScript Framework receives information sent by the server (RAWs), handles the data, and sends back the users commands (CMDs). With a very small footprint (~10KB), the APE Framework loads really fast on your web browser, thus it's fully adapted for slow connections such as EDGE or 3G.

  • Based on Mootools
  • Bring Socket API to the client (TCP Sockets)
  • Cross-Browser
  • Several Transport Methods (Long-polling, XHRStreaming, JSONP, Server Sent Events)
  • Support any other Framework for plugins (JQuery...)
  • Sessions & Multi tabbing/windowing management

 


The APE protocol

To enable the communication between the Server and the APE JavaScript Framework (or whatever client you want), APE has it's own Protocol. It has a really small footprint, and it's really fast to interpret.

  • Fully JSON powered
  • Easily extendable
  • APE Specific
  • Send & receive multiple info into one packet
  • Specificaly designed for Comet Push
  • Bandwith saver

 

Installation (Ubuntu)

Download file(s)

libmysqlclient15off

$ sudo dpkg -i libmysqlclient15off_5.1.30really5.0.83-0ubuntu3_i386.deb

Install

$ sudo dpkg -i APE_Server-1.0.i386.deb

 

Configuration

Running the server on port 80

To make the APE Server work on a dedicated IP through port 80, you just need to edit the ape.conf file (./bin) as the following:

# ./bin/ape.conf
Server {
	port = 80
	daemon = yes
	ip_listen = <ip to bind APE>  
	domain = auto
	rlimit_nofile = 10000
}

Transfer methods between server/client

APE supports different transport methods:

  • Long Polling: default transport method

    • With long polling, the client requests information from the server in a similar way to a normal poll. However, if the server does not have any information available for the client, instead of sending an empty response, the server holds the request and waits for some information to be available. Once the information becomes available (or after a suitable timeout), a complete response is sent to the client. The client then immediately re-request information from the server.
  • JSONP: for cross domain push

    • This transport method allows APE to work cross domain. For example your APE Server runs on http://ape.yourdomain.com but you also want it to be accessible on any other domain. This can be done using JSONP.
  • XHRStreaming: for better performance and low latency

    • This transport method is similar to long polling, but instead of closing connection when new data arrives, the server keeps the connection open. This only works in browsers based on Gecko or Webkit (e.g. Safari, Chrome, Firefox).
  • WebSockets : Best performances. (FF4, Chrome, Safari 5)

    • If you are using a recent APE version (git version for APE Server and APE JSF) you can use WebSocket. It's the transport method 6. If you want to use websocket your APE Server must run on port 443 or 80. APE supports the WebSockets protocol as it's defined on this page: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76. But also provides a support for prior version (< 76)

Changing the timeout interval (25s) of the "Long polling" transfer method

[10:42] <Jochus> hi
[10:42] <Jochus> a little question
[10:43] <Jochus> is it correct "Long polling" kills the connection after 25s?
[10:51] <Psoden> it seems that way. If by killing you mean closes current polling and starts another
[10:53] <Jochus> yes, by killing: I mean closing the current polling :-)
[10:53] <Jochus> is it possible to change the timeout?
[11:05] <+Getty> no
[11:05] <+Getty> also you dont want to
[11:05] <+Getty> its like the time the stargate can stand open
[11:08] <Jochus> Getty: ok, thanks!

 

What is the "x" number in front of the XHR request?

Maybe you already noticed the number before each request sent to the APE server:

http://2.ape.ape-project.org/?
-------^

This number is called frequency. Each time the APE JSF is loaded, the frequency is incremented. This allows the APE Server to detect that the user loaded a new page.

  • If APE JSF is loaded without sessions, the frequency is only used to bypass some browser limitations.
  • If APE JSF is loaded with sessions, instead of sending a connect command when start(); is called, it asks the APE server for the user's session.

The server then sends the Multi and Uni pipes the user was connected to, so the APE JSF will fire multiPipeCreate and uniPipeCreate events.

Balsamiq: designing user interfaces

Submitted by Jochus on Thu, 16/09/2010 - 00:25 | Posted in: Java
Posted in



As a web developer, it can be quite time consuming to meticulously code complex pages with HTML and CSS. What’s worse is to invest a lot of time doing that and then realizing that your precious layout just doesn’t work from a UX stand point. Sometimes you have multiple ideas for a layout and are torn between which one to go with.


There are many software tools out there which allow you to create wireframe mockups/sketches of user interfaces. Some of these tools can be quite expensive and for a startup that is bootstrapping, totally out of reach. Luckely, there's an inexpensive tool called Balsamiq Mockups For Desktop which really increased the productivity as a designer

Mockups For Desktop is based on the Adobe AIR platform. Once you install the AIR runtime on your PC, installing AIR-based applications is a breeze.

The elements are very simple to position with intelligent snap-to-grid alignment. Double-clicking an element allows you to edit its text content. You can also modify and fine tune the properties of each element by using the hovering property editor that shows up when an element has focus.

I use this tool a lot for creating functional analyses. And I must say: I love it! :-) ! Demo online is totally free, and you can export your mockups into XML format. So it's very easy to continu working on them. You can also save the mockups as PNG and PDF.