Category Archives: Development

Angular links

 Recommended sites:

Best practices:



Global data sharing:


  1. Guide to Router
  2. Angular router fundamentals
  3. Bootstrap navigation menu 🏅
  4. Nested routes and nested auxiliary routes

Observers and observables:


Various articles:

Pro angular:


Anti angular:


Submit form data to call a web service (Javascript)

If you want to create a small web project, a approach would be to use a combination of bootstrap (frontend), lumen (backend) and jquery (interaction between the two). It is a very strong combination with a very low owning and maintenance cost that can easily scale (by upgrading to laravel) if needed. You can also use angular with does not add a lot of overhead.

While you are trying to implement the above, the following pattern is encountered a lot of times: you need to call a web service via js while the data are filled by the user via a form on the html page. While the web service is being called, you need to show a spinner on the page so that the user understands that he needs to wait until the call has been completed.

Continue reading Submit form data to call a web service (Javascript)

How to install Lumen (for development)

1. Install composer

Either by apt or by using installation wizards. It’s easy.

2. Install Lumen

composer global require "laravel/lumen-installer"

3. Create the project.

Navigate to the directory which you want to be the parent of the directory containing the project and run:

composer create-project --prefer-dist laravel/lumen <your directory>

The directory does not have to be in htdocs (or other equivalent directory of your server)

4. Create a symbolic link in htdocs of Apache

Either with ln -s or mklink.


ln -s /projects/php/<your directory> /xampp/htdocs/<your directory>







Laravel – Deploy on shared hosting

For each method below, we assume that:

Note also that the simplest and safest way to deploy Laravel on Apache web server would be to set the website document root to the Laravel’s [app]/public directory. But usually this is not allowed on shared hostings.

Method 1: set the right document root folder

If you are deploying your application on a subdomain, let’s say a subdomain named [app] (i.e. http://[app], most hosting services let’s you to specify the root folder for your subdomain.

So you can simply set the root folder for the subdomain to:


and put the Laravel application inside the folder named [app] on your hosting.

When your website is accessed at http://[app] will be served your Laravel application from [app]/public.

Pros: this is the easiest and safest method.
Cons: the hosting service should allow you to choose the document root folder and it’s hard they give you this option for the main domain.

Method 2: create a symbolic link*** (recommended)

Most shared hosting services doesn’t allow you to set the document root folder, but if you have an SSH access you should be able to replace the document root with a symbolic link.

Let be public_html the website document root.

Via SSH, create the ~/[app] folder in your home:

$ cd ~
$ mkdir [app]

Then you can deploy the Laravel application inside the [app] folder.

Create the symbolic link to [app]/public (be sure that public_html is empty):

$ rm -r public_html
$ ln -s [app]/public public_html

Now it’s like the document root folder is [app]/public.

Pros: safe and quite easy.
Cons: the hosting service should allow you to create symbolic links, this usually means you need an SSH access.

Method 3: add an .htaccess in the application root (unsafe)

You can add an .htaccess file in the root of your Laravel application, with this content:

  # Turn Off mod_dir Redirect For Existing Directories
  DirectorySlash Off
  # Rewrite For Public Folder
  RewriteEngine on
  RewriteRule ^(.*)$ public/$1 [L]

In your hosting service just put the Laravel application, with the above .htaccess, inside the website document root folder (e.g. the public_html folder). All incoming requests will be rewritten to point inside the public folder.

This is an unsafe method since the Laravel application root folder become the website document root. This could publicly expose some private data (e.g. the .env file) if something go wrong, for example if you accidentally remove the .htaccess file from the application’s root.

Also this method breaks the url /public (e.g. that will show the content of the public directory instead of be available inside the Laravel application.

Pros: easy.
Cons: unsafe and breaks the url /public.

Method 4: move the public folder

You can find around the web some nice tutorial that will show you how to move the Laravel’s public folder under the website document root, leaving outside the rest of the application (in a private and safe place). You will need to change some paths inside the index.php file in order to get it working.

A really good tutorial is this one:

Personally, I would prefer to add the .htaccess file (method 3) over this method, since it is less invasive, it preserves the default Laravel application structure, and both the development and the deployment process will be easier.

But, if you need the most safe method for your application then you should take in account this last method.

Pros: safe and applicable on most hosting services.
Cons: a bit complex to implement; needs some tricks to properly works and to manage the deployment process.


Round float numbers in Javascript

Why it’s complicated

JavaScript’s Math object provides a method for rounding to whole numbers. If we want to round to a set number of decimal places, then we have to handle that ourselves. This post doesn’t get into the details of floating-point arithmetic, but the short of it is most programming languages use a binary floating-point representation which can only approximate many decimal fractions. This results in rounding errors for the most common approaches to rounding in JavaScript.

Continue reading Round float numbers in Javascript

Evaluate search engine with trec-eval

$ ./trec_eval [-q] [-m measure] qrel.txt results.txt


query-id 0 document-id relevance

  • query-id: is the query id
  • 0: is reserved and is not used
  • document-id: is the document id
  • relevance: should be 1 for relevant documents and 0 for non relevant documents


query-id Q0 document-id rank score STANDARD
  • query-id: is the query id
  • Q0: is the run id (unique for the document)
  • document-id: is the document id of a relevant document
  • rank: is the rank of the id (unique, ascending)
  • score: is the similarity score (descending)
  • STANDARD: is a custom tag (ignored)


Evaluation measures:

runid Name of the run (is the name given on the last field of the results file)
num_q Total number of evaluated queries
num_ret Total number of retrieved documents
num_rel Total number of relevant documents (according to the qrels file)
num_rel_ret Total number of relevant documents retrieved (in the results file)
map Mean average precision (map)
gm_map Average precision. Geometric mean
Rprec Precision of the first R documents, where R are the number os relevants
bpref Binary preference
recip_rank Reciprical Rank
iprec_at_recall_0.00 Interpolated Recall – Precision Averages at 0.00 recall
iprec_at_recall_0.10 Interpolated Recall – Precision Averages at 0.10 recall
iprec_at_recall_0.20 Interpolated Recall – Precision Averages at 0.20 recall
iprec_at_recall_0.30 Interpolated Recall – Precision Averages at 0.30 recall
iprec_at_recall_0.40 Interpolated Recall – Precision Averages at 0.40 recall
iprec_at_recall_0.50 Interpolated Recall – Precision Averages at 0.50 recall
iprec_at_recall_0.60 Interpolated Recall – Precision Averages at 0.60 recall
iprec_at_recall_0.70 Interpolated Recall – Precision Averages at 0.70 recall
iprec_at_recall_0.80 Interpolated Recall – Precision Averages at 0.80 recall
iprec_at_recall_0.90 Interpolated Recall – Precision Averages at 0.90 recall
iprec_at_recall_1.00 Interpolated Recall – Precision Averages at 1.00 recall
P_5 Precision of the 5 first documents
P_10 Precision of the 10 first documents
P_15 Precision of the 15 first documents
P_20 Precision of the 20 first documents
P_30 Precision of the 30 first documents
P_100 Precision of the 100 first documents
P_200 Precision of the 200 first documents
P_500 Precision of the 500 first documents
P_1000 Precision of the 1000 first documents

Solr useful commands

Useful links:

start/stop server:

bin/solr start
bin/solr start -f
bin/solr start -cloud
bin/solr restart
bin/solr -e techproducts
bin/solr stop
bin/solr status


manage cores:

bin/solr create -c <core>
bin/solr delete -c <core>

delete all:


post document:

java -Dc=<core> -jar post.jar blabla.xml
bin/post -c <core> example/exampledocs/*.xml

query documents:

see also:

http://localhost:8983/solr/<core>/select?q=videoquery documents with field selection:

query a specific field


query a range


format query response output

  • json:
  • xml:
  • csv: