Home » Archive by category "Programming" (Page 4)

I’m now a freelance developer

To my surprise I hadn’t even announced here that I have recently started freelancing! As of August the 1st I now operate under the name Kras IT and am available as a freelance developer. Since it’s now the 1st of September this means I’m already in business for a month now which has been exciting. I’ve been with my previous employer for almost 7 years and after a lot of thinking and planning I decided to take the leap!

As a freelance developer you can hire me for all your PHP and Perl work. I mainly do webdevelopment but I do a lot of backend as well. Aside from that I also enjoy configuring Linux servers. I personally think being able to configure and optimize both your app and the server(s) the app is running on can be a great asset, as it gives a lot more insight in the overall workings of your software.

Aside from doing freelance work I also plan on doing product development. I’ve got a few ideas in the pipeline of which one I expect to launch within 5 months. I’m likely to blog about this in the near future as well as about freelancing and running your own business.

For a full list of skills you can take a look at my website at Kras IT. Currently the website is still Dutch only but my LinkedIn and résumé are in English. Do you’ve got any questions or are in need of a freelance developer? Feel free to contact me!

How to catch and test sent e-mails in your app

A nice gem (literally, it’s a Ruby program) I stumbled upon yesterday is called MailCatcher. Using MailCatcher you can catch all the mail that’s being sent by the app you’re developing and (re)view their contents.

MailCatcher makes this possible by running (or rather being) a simple SMTP server. All you’ve got to do is direct your app to use the SMTP server provided by MailCatcher. Mail sent with this SMTP server stays inbound so you don’t have to worry a test mail is receiving by a customer.

It also provides a neat web interface in which you can review the mails that have been sent. Aside from viewing the contents of the mail you can also do further inspection on it by taking a deeper look into the source of the mail to view headers and such.

Screen shot 2011-06-23 at 11.39.03 PM(source: mailcatcher.me)

By using WebSockets the webinterface immediately updates when a mail has been sent. You can also download the e-mail to load it up in your e-mail client. This can be useful to review HTML based e-mails to see how they render.

If you’re using Vagrant I suggest you add the port the webinterface runs on to the forwarded ports list. Also run mailcatcher with --http-ip 0.0.0.0 so you can reach the webinterface from the host OS.

Create a PDF document out of an HTML page

Perl has several modules on CPAN for creating and manipulating PDF files. Just a single search on PDF results in over 500 modules that have something to do with PDF files.

The most useful (or rather essential for PDF processing) are PDF::API2 and CAM::PDF. The former lends itself best for creating PDF’s and the latter for manipulating existing PDF’s and extracting data (such as plain text) from it.

Though these modules make handling PDF’s easier, handling PDF’s still isn’t much fun. As I was in need of a way to generate PDF’s out of work orders (or job tickets) and not feeling much for creating the layout manually and properly formatting paragraphs (manually) with PDF::API2 I started to look further.

I ended up trying out PDF::FromHTML. With PDF::FromHTML you can create a simple HTML layout and let the module create a PDF out of it. You can do some basic configuration such as changing fonts and font-size (check out its documentation for more). It also provides a nifty command line tool called html2pdf.pl for converting an HTML page to a PDF.

The resulting PDF’s from PDF::FromHTML weren’t as pretty as I had wanted, but good enough for the problem I needed solving. But after I started using these work order PDF’s in practice I found I needed more formatting freedom when writing the problem description. So I decided to add Markdown support through Text::Markdown.

Using Markdown I had added a list of tasks to a work order with the items being in bold text and the descriptions underneath it in normal text. Sadly the PDF’s created by PDF::FromHTML didn’t cope very well with nested HTML-elements. A bold paragraph would somehow cause the next paragraph become bold as well. I think that’s a bug in PDF::FromHTML and I’m sure it can be fixed and shame on me for not looking into it.

So instead of seeing if I could fix the bug I did a quick search on the internet and stumbled upon xhtml2pdf, which is provided by python-pisa/xhtml2pdf. Pisa is a Python library for converting HTML pages to PDF’s. It’s far more sophisticated than PDF::FromHTML as it supports more (all?) HTML tags and even CSS2 (plus some CSS3 stuff) for styling.

Currently my webapp will be using xhtml2pdf if it’s available or either fall back to PDF::FromHTML.

Some other interesting Perl PDF modules worth looking into some day are PDF::Boxer and PDF::TextBlock. And while writing this post I also found out that PhantomJS, a headless WebKit, also has a way of saving a page to PDF. So even though handling PDF’s still isn’t a lot of fun, with all these modules and software available it has become a lot easier.

Want to use a web service to convert HTML to PDF? Then take a look at HTML2PDF Web Service.

HTML2PDF Web Service - Convert HTML to PDFUsing HTML2PDF Web Service you can design in HTML and CSS, and convert the resulting page to PDF. Free trial available!

Server provisioning: my experience with Puppet and Chef

Server provisioning tools such as Chef and Puppet make it easy to automate installation and configuration of your servers. I’ve used both now in two projects where they provisioned my virtual servers built with Vagrant.

I’ve first heard of Chef and Puppet when I started using Vagrant. With Vagrant you can quickly get a virtual server up and running for your project. In its most basic form Vagrant can execute a shell script in which you setup your server. Because this is a bit limiting it’s interesting to look into a more automated provisioning process.

Just over a year ago I started using Vagrant for Maximus and after giving both Chef and Puppet a quick review I decided to go with Puppet. At the time I thought it looked easier to use and it had lots of modules available for installing software.

Earlier this week I decided to add Vagrant to a new project of mine: a small and simple CRM system which is adapted to my workflow, and decided to give Chef (Solo) a try. At first Chef looked like a lot more hassle than Puppet, but that’s mainly because you start off with a big chef directory just to get started and cookbooks have a folder hierarchy of their own as well. In contrast, with Puppet modules basically have a files, manifests and templates directory.

If I compare my experience between Puppet and Chef I had more trouble setting up my Puppet manifests than I did setting up my Chef cookbooks and recipes. I’ve found Chef cookbooks easier to use than Puppet modules. Mainly because configuring software with Chef seemed a lot easier. Maybe that’s because the available Chef cookbooks actually provide this functionality as it seemed totally absent in most Puppet modules I’ve come across. Maybe it was there but I couldn’t find it. That’s another thing, the Chef cookbooks seem to be better documented than the Puppet modules I’ve seen. One thing I do like about Puppet is that you can define dependencies between every step or command you want to run. I’m not sure if Chef supports this as well.

Just to make clear, my experience with Puppet and Chef is limited and I currently don’t use it to provision servers used in production (at least not yet, but I’m sure that’ll change in the future). This is just based on my experience. If you’re interested in these tools I suggest you try them both to see what it’s all about. They both have a solo/standalone version which doesn’t require a main server where your cookbooks or modules are stored.

One great resource of getting started with Chef can be found at Christopher H. Laco’s website.

Pulling the plug on Maximus, the BlitzMax Module Manager

A couple of weeks ago I talked about the future of Maximus and said that I would inform you about my decision once it was made. I’ve come to a decision about Maximus and have decided that I will pull the plug on it. I just don’t know when yet.

For the time being the website will stay online but I’m no longer making an effort in keeping it up and running. As soon as I need the server resources that Maximus is currently taking I’ll be shutting it down.

There’s a slight chance I’ll move Maximus to my local homeserver which isn’t always available. The only reason I would do this is so I’ll still have a hosted module repository in case I want to use BlitzMax again. But considering I haven’t touched the language in a while I’m not sure yet.