Recent Posts
Switching from Wordpress to a static website
I migrated my Blog site from Wordpress to a faster static web site using markdown files and Hugo.
read more
Doctor Planning resolved with #Prolog
Below my #prolog solution for “Doctor Planning” proposed by dmcommunity.org challenge April 2020
There should be more constraints like a limit of shifts a week for each doctor… In any case after few seconds I get the first result [[2,3,4],[2,3,4],[2,3,4],[2,3,4],[1,2,3],[1,2,4],[1,2,4]]
It means: Monday sheets: doctor 2 (early), doctor 3 (late) and doctor 4 (night)…
:- use_module(library(clpfd)). /* using swi-prolog */ :- use_module(library(clpz)). /* using scryer-prolog */ /* solver for issue https://dmcommunity.
read more
Imperative (not functional) languages are so boring. Long life to logical and declarative programming like Prolog
Below a simple example of using a a declarative language (Prolog) for finding all solutions for a trick game…
?- use_module(library(clpfd)). ?- X in 1..9, Y #= (X * 3 + 3) * 3, Z #= (Y rem 10) + (Y div 10), setof(Z, X^Y^label([X,Y,Z]), Sol). Sol = [9],
read more
My Networking Survival Kit
In this small tutorial I’ll speak about tunneling, ssh port forwarding, socks, pac files, Sshuttle
I’ve been using Linux since 1995 but I have never been interested a lot in networking. In these many days of smart working (due to Covid-19) I have found some useful tricks to connect to remote systems that are not directly reachable from my lan/vpn
Case 1 (port forwarding): I wanted to connect to targethost.redaelli.org at tcp port 10000 but I was not able to reach it directly but only through an other host (tunnelhost.
read more
How to backup and restore Glue data catalog
How to recover a wrongly deleted glue table? You should have scheduled a periodic backup of Glue data catalog with
aws glue get-tables --database-name mydb > glue-mydb.json And recreate your table with the command
aws glue create-table --cli-input-json '{...}' But the json format of aws glue get-tables is quite different from the json format of aws create-table. For the conversion you can use a simple python script like the following one
read more
N queens in Prolog
Below the N Queens problem solved in Prolog and Constraint Logic Programming over Finite Domains library
:- use_module(library(clpfd)). n_queens(N, Queens) :- length(Queens, N), Queens ins 1..N, all_different(Queens), %% the queens must be in different columns different_diagonals(Queens). different_diagonals([]). different_diagonals([Q|Queens]) :- different_diagonals(Queens, Q, 1), different_diagonals(Queens). different_diagonals([], _, _). different_diagonals([Q|Queens], Q0, Distance) :- abs(Q0 - Q) #\= Distance, NewDistance #= Distance + 1, different_diagonals(Queens, Q0, NewDistance). /* Queens is the list of columns of the queens: the corresponding rows are the position of the elements/columns in the list Queens Examples: ?
read more
Prolog and Constraint Logic Programming over Finite Domains
I like Prolog and in these days I have studied the library CLP(FD).
For instance it is easy to write a simple code for solving “How many men and horses have 8 heads and 20 feet?”. You write the rules and contraints and Prolog will find the solution for you
men\_and\_horses(Men, Horses):- Men in 0..10, Horses in 0..10, Men + Horses #= 8, %% heads must be 8 Men \* 2 + Horses \* 4 #= 20.
read more
Running Talend Remote Engine in a docker container
I was not able to find a Dockerfile for running Talend Remote Engine in a container. So I tried to build a new one. It is a working in progress: do you have any suggestions?
TODO / Next steps:
registering the engine using Talend API running the engine with a unix user “talend” FROM centos:7 # centos is the recommended linux distribution MAINTAINER Matteo Redaelli <matteo.redaelli@gmail.com> # Build and run this image with: # - docker build -t talend/remote_engine:2.
read more
Emacs package sql-sqlline and python package sqlu
Few days ago I published the following two opensource packages:
sql-sqlline: an emacs package that extends sql package for quering less known databases (aws redshift, aws athena, ..) sqlu: a python package for extracting tables from sql select statements Comments: buy Andriol - Mar 2, 2020I don’t know if it’s just me or if perhaps everybody else experiencing issues with yor site. It appears as though some of the written text on your posts are running off the screen.
read more
Using Apache Camel from Groovy
Apache Camel is an open source integration framework that empowers you to quickly and easily integrate various systems consuming or producing data.
Apache Groovy is a Java-syntax-compatible object-orientedprogramming language for the Java platform. It is both a static and dynamic language with features similar to those of Python, Ruby, and Smalltalk. It can be used as both a programming language and a scripting language for the Java Platform, is compiled to Java virtual machine (JVM) bytecode, and interoperates seamlessly with other Java code and libraries.
read more