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 - http://download.eclipse.org/technology/dltk/updates-dev/latest/


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:


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.
Jordi

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 ASP.net 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 ASP.net 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!.

Jordi.

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:



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.
Jordi

Thursday, 25 September 2014

"Cannot load SSL Library" using Delphi XE7

Delphi XE7 is using Indy version 10.6.0.5169 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:

Screenshots: