Convert HTML to PDF

As a background task for our web application BeeBole, I was looking for an easy and efficient way to produce PDF documents without being stuck with postscript like syntax or being feature limited in a design point of view.

Last week I discovered the tool I was looking for : WKHTMLTOPDF

By leveraging the power of the webkit engine through QtWebKit module, this thing is converting HTML with full CSS support to PDF the same way you “Save as PDF” from your browser ;)

In this article, I’ll show you the very first prototype I did of a possible WKHTMLTOPDF integration with our application.
Continue reading

37Signals Dives Into Erlang

37Signals is a great company with amazing achievements. Behind Basecamp (an incredibly simple project management tool) and Ruby on Rails (Yeah, just that), they are now announcing they just dived into the Erlang world.

They use it for their Campfire application which is a web-based messaging/chatroom solution and the performances prove one more time that Erlang is a killer language when it comes to build stable and scalable back end systems.

You can read their full article here.

37Signals, Facebook,…

What are you waiting for? Start developing your own web application with Erlang now!

Test the Performance and Scalability of Your Web Applications With Tsung

What is Tsung ?

The purpose of Tsung is to simulate users in order to test the scalability and performance of IP based client/server applications. You can use it to do load and stress testing of your servers.

(Definition coming from the Tsung website)

In this post, I will introduce the use of Tsung in order for you to stress test your web applications.

Why Tsung ?

Because it’s an Open-Source project and, to tell the truth, mainly because this application has been coded in Erlang which gives Tsung a little advantage on the other tools: it has the potential to simulate A LOT of concurrent requests … without crashing. That’s what we expect from a stress testing app, isn’t it?

Continue reading

Erlang Resources For Web Applications

We have been very happy to see more and more interest for the Erlang material we were providing (our video has just reached 1000 plays).

And with the growing number of posts and tutorials, we decided it was time to give them a real dedicated Erlang page

In the future, more content and more links will be added to this page. All your feedback is also very welcome to help us create a comprehensive and complete guide.

It is really nice to see so much enthusiasm and a vibrant community starting around Erlang for web apps. Two new Erlang blogs we came across and that are definitively worth a look:

Good luck to Chad and Lloyd.

How To Send Emails From An Erlang Web Application

Do you want to quickly be able to send an email from your Erlang web application to one or more email addresses?

In this post I will show you an easy two steps method to achieve that goal:

  1. We are going to make our Ubuntu box (See how to install Erlang on Ubutntu) capable of sending emails to the outside world … and only that, nothing more (no mailbox configuration, spam assassin, etc …).
  2. Write an Erlang function responsible for building the message and sending it.

Continue reading

Video Tutorial To Start Developing Web Applications on Erlang

Please find hereunder a video tutorial highlighting the key points of developing a JSON based web application with Erlang and Mochiweb.

Note that, for best performances (HD Definition), you have to directly go to the Vimeo website where the video is stored and watch it in full screen mode.

You may want to download the video. In that case, you will have to follow the instructions at the bottom of the video page on the Vimeo website.

Click on the image below to go the the video page.

Go to the video page

The purpose of all this, aside from arousing your curiosity, is to provide you with a getting started pack and allow you to go a step further in the Erlang web application sphere.

I invite you to download the example application (as illustrated in the video stickyNotes.zip) in order for you to understand all the pieces of the puzzle and to venture behind the scene.

Just keep in mind that stickyNotes is a one shot application that I’ve developed from scratch with the unique aim of illustrating the video example.

Having said that, any comment or suggestion is always welcome, especially about ‘struct.erl’, a module that I’ve created when I was learning the language in order to play with the tree structure resulting from the mochijson2 decode function.

We are using it in our mainstream development and I’m still wondering if I might have missed something important with regard to the Erlang distro or Mochiweb itself.

In order to install this stuff on your system and assuming that Erlang is properly setup on your box, just follow these steps:

1) Download stickyNotes and extract the archive in your home directory:

stickyNotes.zip

2) cd to stickyNotes dir and compile the code :

make clean && make

3) Start the application and initialize the db from the Erlang console (only once)

./start-dev.sh
stickydb:reset().

4) Browse the following address 127.0.0.1:8000

Super easy isn’t ?

Enjoy

Web Application on Erlang: Configure Nginx with Mochiweb

My previous post, the first of our series dedicated to the Erlang world, was definitively getting too long, so here is the second chapter of this marvelous article.

I’ll assume that you have successfully installed Erlang and Mochiweb and deployed your first small tiny app.

When it comes to deliver static content at lightning speed and do reverse proxy job, there is one name : Nginx, the Igor Sysoev high-performance HTTP server.

It plays well with ssl and in the last dev version you can even find an interesting module for uploading files, nothing less … we will probably tell you more about that in the series.

Nginx is really turning itself into a real handy swiss knife.

Continue reading

How To Quickly Set Up Ubuntu 8.04 loaded with Erlang, Mochiweb and Nginx

Let’s say you want to give a try to Erlang (Discover our post about Why Erlang?) for your next web development project and you want to be up and running as quickly as possible… you just landed smoothly in the right place.

This post is the starting point of a series of posts in which I’m going to provide you with all the commands you’ll need to set up an Ubuntu 8.04 server loaded with Erlang, Mochiweb proxied by Nginx.

In the same series, I’ll also cover:

  • The basic configuration of Postfix (mail)
  • The use of Imagemagick to create dynamically a captcha for your application
  • The configuration of Bind9 in order to play with the url CNAME

The goal here is not to set up an hardened production server with all the optimizations and security niceties in head (I definitively want to avoid a ‘Why not Gentoo, or Slackware, or Debian, or FreeBSD, …?’, I love them all).

Continue reading

Web Application on Erlang: So Far, So Good, …

As a quick recap, I’m building a lightweight server side custom framework which focuses mainly on handling JSON service requests.  This, combined with Mnesia, is our MC stack (Model – Controller).  The client browser will be fully in charge of the ‘V’iew layer of the app.

(See our post Why Erlang ? for more information).

A stable version of the core has been finished a week ago.  In brief, a request hits the server, Nginx proxies it to Mochiweb which starts a new process. 

At this point the framework converts the posted data (JSON) to a native Erlang structure. We check if the request contains one or more services and, based on their name (=:= module), we spawn processes accordingly.

As you may have noticed, in order to save some http requests and to use the full power of our server, the client can ask for an array of services.

i.e. : Let’s imagine you are building a screen which is divided into multiple small independent functional parts : your preferences, your status, your personal info, whatever …, you have the choice to wrap all those service calls into one JSON and the framework will happily process those in parallel … fine isn’t?

At this stage of development, and provided that the DB is not fully populated, if I make a comparison with other developments I’ve done using other languages/architectures, my global feeling is : SPEED.

Whenever I find myself in the situation of using a ‘map’ function and depending on the computation weight on each element, I’m parallelizing the operation (pmap).

Coupled with PURE for the rendering at the client side, we aim to end up with a highly responsive application.

The job now is to continue on that track and make the whole thing even more flexible.

One of my concern when choosing Erlang was the lack of libraries compared to other languages such as Ruby. However, I found relatively easy to develop, from scratch, a mail module responsible to dynamically build messages to be send to one or more addresses (via Postfix) and a ‘captcha’ system.

Soon, I will say a little bit more about those two points and will also describe how to quickly set up an Ubuntu server running Erlang and friends.

Stay tuned