Saturday, 19 March 2016

Testing new Windows 10 components of Delphi 10 Seattle

It's been a while since I got my Delphi 10 Seattle and I really love its new Windows 10 components and styles. I have already played with it and I can say that these new components are really slick and will make your apps really stand out. I've tried the TSplitView and the ActivityIndicator which are great for a full Windows 10 integration. 

Here you can see some screenshots of one of the applications I have created with it and the source code is available on Github:

Initial Screen:

Notice the home button that will control the split view.

Showing the controls:

Controls are hidden/displayed when the home button is pressed. Each of those actions will call each page on the TPageControl component. I'm still looking for a solution where I don't have to show the tabs on the TPagecontrol but I'll get to it later on. I think that as of now, I have a pretty interesting solution that runs fine in my Surface under Windows 10 and it totally looks awesome.

Animation Controls:

I've just added one of the animation controls with a simple processing. There is nothing fancy here, just updating the process regularly would do. If I wanted to make anything better I should put it in a thread for better refresh.

I also tried the TToggleSwitch but it was flickering in runtime so I will report the problem to Embarcadero later on. The new style works really well but I found that the ShBrowseForFolder is not rendering it correctly:

The source code of this little utility can be found here:

Executables can be downloaded here:

This small application will allow you to:
  • Perform a search on a particular folder and file extension.
  • Replace the content of each file for some other content. (really handy when you need to replace a variable in source code files for example).
  • Delete the files.
  • Also to search empty folders and delete them (really handy when your svn complains about checking in empty folders).

Let me know if you have any questions.


Sunday, 20 December 2015

Sending REST API messages with Delphi to is one of the most interesting cloud base solutions I have found so far, and most importantly; basic accounts are for free (up to 30 requests/second, after that is when you have to pay). Using I can keep track of my applications, using the Analytics feature. This is an easy way of knowing how many installs you have running and also it provides cloud storage to add some more details etc. I'm using this module for my project "Flickr Photo Analytics" as I currently have over thousand downloads but I don't have a clue whether the app is being used or not. Here is where the Analytics feature of gets really handy.

Embarcadero has its own AppAnalytics but I just wanted something that I could handle on my own with an easy setup. I have been using Parse for a while for few mobile applications and now I've decided to extend it to my windows desktop applications.

The idea is very simple. Every time the application is used, it will send a notification to via REST API. provides several communication protocols for different languages e.g. Java, Javascript, .NET, etc. but unfortunately not for Delphi. Here is why I decided to write about it as I haven't seen anything on the Internet and it could be interesting for many users out there.

To use it in Delphi, we can use the REST API via IdHTTP component. On their website they provide the syntax using curl and here is the correct translation to use it with Delphi and that works:



With just this little piece of code, the Analytics feature of Parse will start tracking down your installs. It's not a real time tracking so it takes time to appear on the dashboard. Once you have your applications there, you can review the stats:

As I'm not expecting any traffic at all in my app it is really a good solution and it serves my needs. I also have a small android app that pulls from there so I can read some of the stats published by my app anywhere I go. In the end it all lies to connectivity and what's the best and easy way to achieve it. Using this approach didn't take me long at all. 

I hope it can be useful to the community.

PS: If you know any better solution out there, please do let me know!.


Sunday, 6 September 2015

How to use Eclipse for Ruby on Rails

I have been trying to use different alternatives to run Ruby on Rails locally with available tools in the market. I have used nice editors like Sublime Text 2, notepad++ and others but I really wanted a programming IDE that I could interact with (navigate through the classes, files, etc. with easy clicks). I tested also Rubymine which is the Ruby on Rails IDE but still I wondered if there was another solution available. Then I discovered that I could use one of my favourite editors...eclipse with the DLTK (Dynamic Language toolkit) to achieve my purposes.

In this post I will cover the necessary steps you need to do to get your eclipse IDE up and running to become your Ruby on Rails IDE.

First you need to get a version of eclipse. (The Eclipse Java EE IDE for Web Developers in my case)

For this article I will use the Eclipse Luna SR2 version so everyone has a reference. You can use the version you currently have installed as the DLTK packages can be installed separately.

Once eclipse is up and running, go to Help menu and Install new software. A new window will open and in there use the following URL:

   dltk -

Select the packages DLTK and DLTK test and click Next.

Now you can create Ruby Projects:

Once we want to create a new project, the system will ask for an interpreter. We will have to configure where ruby.exe is located:

Click on Configure interpreters and add a new ruby interpreter pointing to the location where your ruby files are.

Now you can add your files into the project and start working with it. Here is a simple example that I have coded for this article that you can test:

class Calculator
  def sum(i,j)
    return i+j

require 'test/unit'
require_relative 'calculator.actions'

class TestCalculator < Test::Unit::TestCase
    def SumIntegers
      test =
      expected = test.sum 3,2
      puts expected
      assert_equal expected, 5

If you try to run this in eclipse, an error is thrown in the console:

C:/luna/eclipse/configuration/org.eclipse.osgi/898/0/.cp/testing/dltk-testunit-runner.rb:252:in `block in <top (required)>': uninitialized constant Test::Unit::UI::SILENT (NameError)

To fix this, you need to open:

C:/luna/eclipse/configuration/org.eclipse.osgi/898/0/.cp/testing/dltk-testunit-runner.rb and solve this by commenting out:

#autoRunner.output_level = Test::Unit::UI::SILENT
and adding the following:

autoRunner.runner_options[:output_level] = Test::Unit::UI::Console::OutputLevel::SILENT

as shown in the image:

and run the test again.

Now your IDE is ready for action.

jqplot integration with ASP.NET MVC

I haven't been writing for a while and it's not always easy to find time to write about interesting stuff. I must say that I wish I had enough time to post all what I have been learning for the last past years, but I will try to keep it up. Today I'm bringing you an interesting post about jqplot integration with MVC. I have been using ASP.NET for quite a while now (more than 5 years) and I hope this post could help you with the integration of jqplot as I faced some challenges that I'm resolving here.

jqplot is a plotting and charting plugin for the jQuery Javascript framework. It's very pluggable and really easy to use.

jqplot can be easily installed using Nuget package from VS:

Here is a simple example from the website:

As you could see, integration is quite simple and to plot the data, this one needs to be formatted in the format of a set [Date, value] to be displayed correctly. So here is the first challenge as we need to find a way to populate this list from our controller and then pass the correct formatted list to our jqplot function.

I'm working on an application called Flickr Photo Analytics. This application is able to connect to your Flickr stream and retrieve some useful stats that you can keep track overtime. The base application is written in Delphi and now I'm developing the web interface that goes with it using MVC. For this article I will use the examples from my source repository.

The best way to approach this problem is by creating a new ActionResult in the controller that will build the relevant data (data that we want to display and in the correct format -> [Date and Value]). Then via javascript, I will use an AJAX (Asynchronous JavaScript and XML) call to call the action method from the controller and retrieve the data in JSON format. One the data is back, I will generate the list in the correct format so jqplot can plot the data.

Here is the code from my controller:

This code loads an xml file containing some relevant data from my application and according to an id that can be passed as an argument in the url, it will return a different JSON list.

The view only needs a div with an id, in this case, chart1 that will be automatically populated with a graph by jqplot once the following javascript is loaded:

The javascript will receive the results from the JSON call in a stats variable. Once we get the whole content of the variable, we need to build the correct array that will go into jqplot. This will be done using: arr.push([new Date(date), value]):

The html is as follows (view):

Loaded units required for jqplot and the div required to display the chart.

And the final result can be seen here:

Check out the properties that I have enabled for jqplot as I've use it for quite a while and I like the way I can configure it.

Any questions, please ask!.


Wednesday, 26 August 2015

Gource history visualisation.

Few days ago, one of my colleagues showed me one amazing tool to display the history from your repository. I thought this tool was only available for TFS as the tool was called (TFS Source control History Visualization) and it can be added to your Visual Studio easily through NuGet packages.
It's quite cool as it lets you see the files you are working on in a really nice graph using some force-directed based diagram. This reminds me of a similar diagram I was working on few years ago. You can read more about it here.
The tool that I've been using here is called Gource. It's really easy to use and it supports multiple types of repositories like SVN, GIT, TFS, etc. I've tried with all three and the results are excellent.

Here is a little demonstration of the tool running against one of my personal repositories: 

The command to get this running is as follows:

gource -1080x808 --elasticity 0.4 --stop-at-end --transparent --hide filenames --time-scale 4 --seconds-per-day 1 --auto-skip-seconds 1 --bloom-intensity 1 --bloom-multiplier 1 "C:\Source code\FlickrPhotoStats"

There are several ways for generating the video and some examples can be found here:
Latest version of the application can be downloaded here:

Saturday, 14 March 2015

Projects moved to Github

As you might be aware, Google Code Project Hosting is about to shut down so I have decided to move all my projects to GitHub as it was one of the options Google was offering. So here you have all my Delphi Open source projects for your entertainment. Most of them are already finished and not much is going on, but they are good for reference. Some of my active projects are already on GitHub and I do really like the platform:

Open Source Projects:
Projects that were already in Github:

I need to add the documentation, but I will be doing it over these weeks.

Thursday, 25 September 2014

"Cannot load SSL Library" using Delphi XE7

Delphi XE7 is using Indy version and if you want to use SSL components you now need to install OpenSSL. I'm using IdSSLIOHandlerSocketOpenSSL1 component for my FlickrPhotoStats application (you can read more about it here : Delphi REST client to retrieve flickr statistics ) that uses REST technology to retrieve flickr stats using the available API.

My tool used to work under Delphi XE6 without problems and after my upgrade to Delphi XE7 I can see that when it tries to use the IdHTTP component the following exception is thrown: "Cannot load SSL library". Basically the error is raised because now you need to install (*see comments below) you need to update OpenSSL as Delphi XE7 has a dependency with the latest library. Update it locally in your machine in order to use IndySSL components. At runtime, Indy loads two libraries: libeay32.dll and ssleay32.dll (these libraries are not distributed with Indy due to some restrictions exporting SSL technology). 

The easiest solution to fix this issue, is to download the following library:

This library among others can be found here: Win32OpenSSL.

NOTE: this solution is only applicable on Windows. I have only tested it under Windows 7 64 bits and it works fine.

Once the setup has been launched, select the following option:

After the libraries have been installed, the application will work without problems. DLLs can be found in the OpenSSL-Win32 directory also. With the selected option (Windows system directory) the libraries will be installed at C:\windows\SysWOW64 folder.

Update: KM mentioned that it's better to distribute the libraries with the app instead of installing the libraries under windows directory.

Update: Nicholas Ring has provided a very useful link for OpenDec (Home of OpenSSL DLLs & the Delphi Encryption Compendium), DLLs can be found here also:

If you are interested in my application, this can be found here:

Source code and binaries can be found here:


Sunday, 6 July 2014

Delphi REST client to retrieve flickr statistics

It's been a while since I last posted an article here, and today I'm coming with an exciting application I have been working on lately called "flickr photo stats". I'm a keen photographer and I like posting all my pictures in Flickr as it's a great platform for sharing and publishing your work. You can find my profile here:
What's most important is that Flickr provides an API which allows you to request information about your pictures. The Flickr API is available for non-commercial use by outside developers and we can request an API key for our particular use. To use the Flickr API, you need to have an application key that can be requested here: The App garden. As mentioned before this application key is for personal use and I had to request mine and explain the intentions for its use as I only wanted to get some values from my photos and keep track of them.

What I'm trying to achieve?

If I open one of the pictures, I can see that every picture contains 3 main values regarding statistics:
  - Views: Number of views that the picture receives.
  - Favourites: Number of likes that the picture receives.
  - Comments: Number of comments that the picture receives.
In previous versions of Flickr, they offered a professional profile in where users could see the global stats for the entire portfolio. Now with the new version, they only show the values for individual pictures. Many other platforms like ViewBug or 500px show the total number of views and other interesting information that could be useful when building your portfolio and study the data to see what people are more interested in seeing in your profile. I spent a while going through some forums in Flickr, trying to see if someone had created an additional service or application to display the information of the profile, but after weeks of research, nothing original came up.

Then I started doing my own research as to see how difficult or easy it would be to request the information from the API and when going through the definition of it I saw that they provide a REST request/response. A smile was drawn to my face :) when I immediately thought that I could build a REST client with Delphi and get the information I needed easily.

I'm on the phase of testing Delphi XE6 so I developed the application with it. :)

My solution

The requirement is to get as much information regarding the number of views, comments and likes from your portfolio. As the profile could have many pictures, this application only focuses in the photos you want to track e.g. the number of views overtime of one of your photos or counting the total views, likes and comments for the photos you add into the app list.

My current solution is really simple and effective after the results of my testing. Here you can see a screenshot of the application:
On the left, a list of photos containing the ID, title, number of views, likes, comments and the last time the application update the counters.
On the right a view of one of the pictures with the number of views (depending on the selection) over time. The application allows a batch update where it will request an update all the counters. Every day the system creates a new entry under a particular photo, so we can keep track of the overtime. Current example is just showing the data from the last 3 days.
The application stores all the details in an internal repository in XML format (see figure below) and it can be loaded/saved any time. The app is still under development so there could be bugs but it works fine.
The REST client uses a IdHTTP component with a IdSSLIOHandlerSocketOpenSSL handler as Flickr uses https
The main API methods used by the app are:
  • (Returns the list of people who have favorited a given photo)
    • Arguments:
      • api_key (Required) Your API application key.
      • photo_id (Required). The ID of the photo to fetch the favoriters list for
  • (Get information about a photo. The calling user must have permission to view the photo)
    • Arguments:
      • api_key (Required) Your API application key.
      • photo_id (Required). The ID of the photo to fetch the favoriters list for
Example response:
<photo id="1253576" secret="81b96be690" server="1" farm="1" page="1" pages="3" perpage="10" total="1">
  <person nsid="33939862@N00" username="Dementation" favedate="1166689690" />

Once we get the values from the REST response, we can use a XMLDocument component to read the values we need:
procedure TfrmFlickr.RequestInformation_REST_Flickr(id: string);
  Item, itemExisting: TListItem;
  response: string;
  iXMLRootNode, iXMLRootNode2, iXMLRootNode3, iXMLRootNode4: IXMLNode;
  views, title, likes, comments: string;
  stat: IStat;
  photo, existing: IPhoto;
  response := IdHTTP1.Get(, id));
  iXMLRootNode := XMLDocument1.ChildNodes.first; 
  iXMLRootNode2 := iXMLRootNode.NextSibling; 
  iXMLRootNode3 := iXMLRootNode2.ChildNodes.first; 
  views := iXMLRootNode3.attributes['views'];
  iXMLRootNode4 := iXMLRootNode3.ChildNodes.first; 
  while iXMLRootNode4 <> nil do
    if iXMLRootNode4.NodeName = 'title' then
      title := iXMLRootNode4.NodeValue;
    if iXMLRootNode4.NodeName = 'comments' then
      comments := iXMLRootNode4.NodeValue;
    iXMLRootNode4 := iXMLRootNode4.NextSibling;

  response := IdHTTP1.Get(, id));
  iXMLRootNode := XMLDocument1.ChildNodes.first; 
  iXMLRootNode2 := iXMLRootNode.NextSibling;
  iXMLRootNode3 := iXMLRootNode2.ChildNodes.first;
  likes := iXMLRootNode3.attributes['total'];

How to start 

Once you have your application key sorted out, you can check that your API key works by running the test echo that Flickr service API provides:

An example response is as follows:

<rsp stat="ok">

From here we will use the api_key value and place it into the apy key textbox in the app:

To know what's your photo_id, you just need to open your picture on Flickr and you will get the ID on the URL:

Once we have the photo_id we can add it into the list and the application will add a new entry. If we click on the checkbox associated to the entry, the graph on the right will be displayed with the values (current and stored). The graph is dynamically build so you can add/remove as many as you want. A selection of views/likes/comments is possible under the graph so every time a selection is made, the graph is generated displaying one of those selected values.
At the end of the main list there is a label that tallies up all the values from the list which gives you a great indication about how your pictures are doing.

Source code and binaries can be found here:
Enjoy the reading and do not hesitate to add your comments and thoughts about it. There are still many things to fix and enhance but at least I can get some meaningful values and track items easily without having to explore each single picture on Flickr.
A better example is shown in the figure below after adding 275 photos into the app:
I can easily see that those pictures have reached more than 200k views in total which gives me a good indication of the amount of visits the profile gets. As I run the app every day (to keep track of everything), I can see that the number of views are going up.

Update 20/07/2014.
A second version of the up is ready and it just enhances the way information is displayed:

New version here:


Sunday, 3 November 2013

My first Android App with Delphi XE5

A lot has been going on since Embarcadero released Delphi XE4. I must say I was astonished with what they achieved in such a short time with that version. Just being able to develop your own mobile applications using Delphi was something amazing. Even though I found that version quite cumbersome as it was not trivial the way to deploy your app into an iOS system I gave it a try with no much success (I needed a virtual machine for the Mac device and had to borrow someone's iPad to publish the app, but I'm not a Mac person). So, what I was really waiting for was their latest release Delphi XE5 with Android compatibility. The most interesting part: how simple it is to create a project and deploy it into your android device. In less than a minute you can have your "hello world!" app in your phone with just few clicks. 
Delphi XE5 comes with the Android SDK 22.0.1 32 bit (at least the one that I got when installing Delphi) and you can see all the configuration paths for that particular SDK under Tools -> SDK Manager:

The first step is to enable your device to accept USB Debugging. To achieve this, you can follow the steps from the following link which related the way you have to enable developer mode for Samsung Galaxy Note 3. I have got a Samsung Galaxy Mega, so the same rule applies:

Once done, you will see new options in your phone:

Enable "Still awake" and "USB debugging". Once those are enabled, plug your phone into the computer using the USB cable. Then, the phone will ask you if you want to allow USB debugging: Accept it and let's go to Delphi UI.

Now in Delphi XE5, I will create a very simple project. So, go to File -> New -> FireMonkey Mobile Application.

As my new device is not in the list of available devices, I just choose something that more or less has the same dimensions. In this case as my phablet is a 6.3 inches, I choose the WSVGA 7" option:

Once this is done, I just want to create a simple "hello world" app which consists of displaying a label and when a button is pressed displaying a message. A very simple application but without changing the way I think (I'm building a Delphi application).
unit Unit1;


  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls;

  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    { Private declarations }
    { Public declarations }

  Form1: TForm1;


{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
  showMessage('Delphi XE5 Rocks');

As you can see, I'm coding in Delphi. Once this is done, If I have followed the previous steps correctly, my phone should appear under targets for that particular SDK:
Now I just need to Save my project and Run it so it can be automatically deployed in my phone. Once done, I'll be able to see the app in my phone and perform the operations it was designed to do:
Here it is. As you can see really simple steps and with a great outcome: A Delphi App in your most loved android device. Now it's time to explore and do some more research about what you can do here.

Related links:

Sunday, 24 February 2013

Using Delphi code coverage

I couldn't find a good self-explanatory example for the usage of Delphi-code-coverage tool so here you will find a simple example from top to bottom. The idea is really simple; I have a set of units which I want to know whether they are covered by my unit tests or not. Even though there is a lot of information about the project, I couldn't find a really good example explaining all the details about How to properly set up the project, folders, flags, etc. I have used the Delphi-code-coverage-wizard which is great to generate the initial structure (batch file + list of paths + units) but I went manual from there as I couldn't get any output.
I must say that both projects are really good and that's why I'm giving them an opportunity as I want to test the coverage of my projects under Delphi XE.
First step is to correctly identify where your source code is and your unit tests are. This step is really important as to correctly set-up the code coverage project. All my testing code is under my repository and available here: Delphi-repositoty. For this example I'm using a very simple example where I have a unique unit test which tries to cover two units (thundax.AbstractFactory.pas and thundax.Prototype.pas).

My unit test project is called thundax.DesignPatternsTest.exe which has 2 tests:
Now I want to know if those two unit tests cover my previously defined units (thundax.AbstractFactory.pas and thundax.Prototype.pas).

Download Delphi-Code-Coverage and leave it under your bin\ folder or where your test.exe application is (in my case thundax.DesignPatternsTest.exe).
Create two text files called dcov_paths.lst and dcov_units.lst. You can use Delphi-code-coverage-wizard to set up the initial structure, but I would rather go manual as I have more control of the execution.

- The first file (dcov_paths.lst) will contain the path to your source code:
C:\ThundaxDelphiRepository\thundax-delphi-personal-repository\src\Design Patterns\

- The second file (dcov_units.lst) will contain the list of unit tests you want to check whether they cover your code or not.

Your projects needs to have debug information generating a detailed Map file:

Now we can create a small batch file (dcov_execute.bat) or run the following command from the command line tool:
CodeCoverage.exe -e "thundax.DesignPatternsTest.exe" -m "" -ife -uf dcov_units.lst -spf dcov_paths.lst -od ".\" -lt -html -xml -emma -meta

This is the configuration that works for me, where:
  • -e identifies the executable to run (in this case the Unit test framework).
  • -m identifies the map file (the map file contains all the debugging symbols).
  • -ife include file extension (if you are using generics.collections use this option).
  • -uf list of your units (source code, not your unit tests code).
  • -spf list of source directories.
  • -od Output directory (".\" gets  the current).
  • -lt generates log file. (Delphi-Code-Coverage-Debug.txt).
  • -html Html output
  • -xml Xml output
  • -emma EMMA output
  • -meta Generate separate meta and coverage files when generating emma output - 'coverage.em' and '' will be generated for meta data and coverage data. (Needs -emma as well). These are the important files to run EMMA.
Once the line has been run, you should get the correct output files:
  • CodeCoverage_summary.html (Html output)
  • CodeCoverage_summary.xml (xml output)
  • (EMMA output)
  • coverage.em (EMMA output)
  • (EMMA output)
  • Delphi-Code-Coverage-Debug.txt 
  • thundax.AbstractFactory(thundax.AbstractFactory.pas).html (Your report)
  • thundax.Prototype(thundax.Prototype.pas).html (Your report)

If you open the summary you will see the total of lines and %age covered by your test:

And you can inspect the files by doing click on the links:
As you can see, one of the units is only 69% covered. Once we inspect the file we can see that there are lines (highlighted in blue) which are not covered by my unit tests and the green ones which are.

If you want to use EMMA, is as easy as this (once the code coverage tool has outputted the .ec and .em files):

java -cp emma.jar emma report -r html -in coverage.em,

Emma component will generate a coverage folder with the following html file:

The entire example can be found in my Delphi repository.

I hope you find this useful and start using it.

Sunday, 3 February 2013

Macro actions (mouse and keyboard) with Delphi

I know this could be an old topic, but I find really useful to know how to send the key strokes or how to simulate the mouse click using our favourite language: Delphi. It's for this, that I have create a small open source project where you can find one of my latest tools "thundax macro actions". In here you will be able to add a sequence of actions e.g move the mouse to a particular position, perform right click or left click and type any kind of message or just press a special key like CONTROL or F1, etc. to automate repetitive tasks or actions that you usually perform and that you need to do as quick as possible. As I always automate everything, it was a really nice idea to come up with this solution and it is quite pleasant to see it working for you. All the source code is available and it is free for anybody to inspect, comment and give suggestions to improve this little tool. I have used the tool to perform a series of operations without me interacting and it saved me loads of time.

Imagine that you need to go through a text where you need to add an extra character or something which would be really tedious to perform manually. With this stand-alone tool, you will be able to perform the same operation with just defining the list of actions to execute and off you go.

The code is really easy to understand and the way to send the key strokes or to perform the left/right click of the mouse are really easy to do. You'll find hundreds of examples on the net:

Here is the tool:

Download it from the following link:
There are still loads of things to do to complete the tool, but at least there is a working solution which can now be used.

Related links: