Home » Archive by category "Mac"

Cyberduck

CyberduckNot too long ago I talked about an alternative for my Rackspace Cloud Files Sync application.

Recently I moved my pictures and videos over to Microsoft OneDrive. I also use Dropbox but for my disk usage I found it to be a bit too expensive. With OneDrive I get 100GB for € 1.99 a month or 200GB for € 3.99. Which is already cheaper as what I was paying with Rackspace Cloud Files. An added benefit of using OneDrive is that you can choose not to download certain (big) files or folders.

After moving my stuff over to OneDrive I was in need of deleting the stored files in Rackspace Cloud Files. My application is supposed to be able to sync an empty folder to a filled container effectively cleaning it up. But as I never tested it with thousands of files it did not seem to work and the application simply crashed a few times as well.

Meet Cyberduck! It describes itself as Libre FTP, SFTP, WebDAV, S3 & OpenStack Swift browser for Mac and Windows. It also supports Rackspace Cloud Files (which is now based on OpenStack as well if I’m not mistaken). With it you can browse your stored files, add or delete them and even synchronize folders just like you could do with my app. I highly recommend using Cyberduck if you were using Rackspace Cloud Files Sync before.

Monkey X Pro – 30% Discount

Monkey X ProA couple of days ago I received an e-mail by Blitz Research Ltd offering me a nice discount on Monkey X Pro, which I took advantage of. To show some love towards BRL and Monkey X Pro I thought I would share the offer here.

Monkey X Pro is a programming language for creating games which can be deployed to several targets including, but not limited to, Android, iOS, HTML5, Desktop, XNA, Ouya and more.

When you buy Monkey X Pro simply enter the coupon code MONKEYX30 for a 30% discount.

Now go buy it and support BRL!

Note: this offer is only available for a limited time and is available until 2nd June.

Keeping VirtualBox Guest Additions in sync with Vagrant

Whenever you’re upgrading the software packages on your VirtualBox machine, managed by Vagrant, you risk VirtualBox Guest Additions render unusable and thus your shared folders don’t work anymore. This usually happens whenever a kernel upgrade is being done which requires the VirtualBox drivers to be recompiled.

Thanks to a Vagrant plugin called vbguest you can now safely upgrade your software packages. If you’ve got this plugin installed every time you run vagrant up it’ll check the installed version of VirtualBox Guest Additions and updates it accordingly.

To install the plugin run the following command from your shell:

$ vagrant plugin install vagrant-vbguest

Convert HTML to PDF with HTML2PDF Web Service

HTML2PDF Web ServiceRecently I launched my new product HTML2PDF Web Service — a web service for converting HTML to PDF.

In this post I’d like to talk about HTML2PDF Web Service. Why to choose it, how to use it and what technologies were used to create it.

Why Choose HTML2PDF Web Service?

Programmatically generating PDF documents is a painful and time consuming problem that neither makes your developers nor designers happy. With HTML2PDF Web Service you can design your invoices or reports in HTML, style them with CSS and convert the resulting page into a PDF document. Using HTML2PDF Web Service saves your developers and designers time which is better spent making your product better.

Say your web application or mobile app (or any application for that matter) needs to generate invoices or reports in PDF format. Unless you can install special HTML to PDF conversion software you’re probably stuck with some of the libraries available for your language that can programmatically generate PDF documents. To do this you would probably design your document in something like MS Word, LibreOffice Writer or perhaps HTML. After this design has been approved you can start programming your PDF module; setting up coordinates, font sizes etc. And then all of the sudden you notice your library has limited support for doing actual document layouts and presenting tabular data that can span multiple lines. Now you need to write your own routines for splitting text over multiple lines, keep track of coordinates and make sure nothing overlaps. If like me you’ve already been there, it’s quite the nightmare.

So being able to design in HTML, style with CSS (heck, even use a bit of JavaScript) and convert the resulting page to PDF would speed up this process a lot. Am I starting to tickle your interest?

How to use HTML2PDF Web Service

Simply create your soon to be PDF documents in HTML, style them with CSS and if wanted you can use JavaScript as well. The final document is best previewed in a WebKit based browser such as Google Chrome, since that’s the technology HTML2PDF Web Service uses in the background to render the HTML and convert it to PDF.

Here are some examples on how to call the web service. Converting HTML to PDF is easy with the HTML2PDF Web Service. You can pass an URL to the page you want to convert or either send the HTML code with the request.

cURL

$ curl -H "X-API-Key: F8802062-4D31-11E3-8F59-BFD4058B6BFF"
       -H "X-API-Username: MyUsername"
       -d '{"content":"<html><head><title>My page</title></head><body><h1>Hello World!</h1><p>I am an HTML page converted to PDF!</p></body></html>"}'
       https://html2pdfwebservice.com/api/convert > page.pdf

Perl

#!/usr/bin/env perl
use strict;
use warnings;
use Mojo::UserAgent;

my $ua = Mojo::UserAgent->new;
my $tx = $ua->post(
    'https://html2pdfwebservice.com/api/convert' => {
        'X-API-Username' => 'MyUsername',
        'X-API-Key'      => 'F8802062-4D31-11E3-8F59-BFD4058B6BFF'
    } => json => {url => 'http://domain.com/invoice.html'}
);
if (my $res = $tx->success) {
    my $pdf_data = $res->body;
}

Ruby

require 'net/https'
require 'uri'

uri           = URI.parse('https://html2pdfwebservice.com/api/convert')
https         = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
# In case the SSL certificate isn't accepted
https.verify_mode = OpenSSL::SSL::VERIFY_NONE

req = Net::HTTP::Post.new(uri.path)
req['X-API-Username'] = 'MyUsername'
req['X-API-Key']      = 'F8802062-4D31-11E3-8F59-BFD4058B6BFF'
req.body              = '{"url": "http://domain.com/invoice.html"}'

res = https.request(req)
if res.code == '200'
    pdf_data = res.body
    # - or write to file -
    # File.open('invoice.pdf', 'w') { |file| file.write(res.body) }
end

PHP

$settings = array(
    'url' => 'http://domain.com/invoice.html',
);

$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($settings));
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'X-API-Username: MyUsername',
    'X-API-Key: F8802062-4D31-11E3-8F59-BFD4058B6BFF'
));

curl_setopt($curl, CURLOPT_URL, 'https://html2pdfwebservice.com/api/convert');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Helps to debug in case of issues
// curl_setopt($curl, CURLOPT_VERBOSE, 1);

// In case the SSL certificate isn't accepted because of outdated certificates
// on your server
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$res = curl_exec($curl);
// Save PDF to disk
file_put_contents('document.pdf', $res);
curl_close($curl);

Technologies used to develop HTML2PDF Web Service

The most interesting part in developing HTML2PDF Web Service was choosing which technology to use for converting HTML to PDF. After doing research on the subject and testing several solutions I eventually went with a WebKit based solution. By using WebKit it’s easier for the end user to preview their document using a WebKit based browser.

The HTML to PDF conversion server was developed using Go. Go is a fun language to program with, does concurrency in a really nice way and can produce a native executable for Linux, OS X, Windows and some other platforms. Thanks to Go the conversion server is fast, snappy and low on memory and CPU usage. Being able to create a binary executable allows me to sell the conversion server as a standalone product as well.

To get access to the web service there’s also a web application which is written in Perl. My favorite web framework of choice has become Mojolicious for quite some time now and thus HTML2PDF Web Service has been written with it. DBIx::Class has been used for database interaction and Validation::Class is used to validate all user inputted data.

Used databases are PostgreSQL and Redis. The former is used to store user accounts, subscriptions and more. The latter is used to keep track of token usage per user.

Sign up now for a free trial

If after reading all this and you’re still reading, please do sign up for a free trial. The trial gives full access to all the features of the web service so if you like it, please consider buying a subscription.

In case of any questions, please do contact me either through the comments on this page or send an e-mail to support at support@html2pdfwebservice.com.

Monkey re-branded to Monkey X and comes with Desktop target

Monkey by Blitz Research Ltd has been re-branded to Monkey X. Monkey X focuses on multi-platform and multi-device game development. Monkey code translates to the language used by the platform. Javascript for HTML5 games for example and C#/XNA when targeting Xbox 360. Supported platforms are Windows, Mac OSX, Linux, Flash, HTML5, iOS, Android, WP7/8, Xbox 360 and more. Ouya as well!

With the re-branding also comes a new free version. Before, the free version only supported the HTML5 target but now also includes the desktop target. Other targets can be acquired by purchasing a Monkey X Pro license.

Now that the desktop target is freely available as well I think I’ll go give Monkey a try soon. I haven’t used BlitzMax in ages (and I consider it a dead end as well) and since Monkey is very similar to BlitzMax I don’t expect too much trouble to get adapted to it.