Libertà vo cercando, ch'è sì cara, come sa chi per lei vita rifiuta

Autore: affinitoalessandro Page 1 of 6

CKS Challenge #1

Here we’re going to see together how to solve a bugged Kubernetes architecture, thanks to a nice KodeKloud challenge, where:

  1. The persistent volume claim can’t be bound to the persistent volume
  2. Load the ‘AppArmor` profile called ‘custom-nginx’ and ensure it is enforced.
  3. The deployment alpha-xyz use an insecure image and needs to mount the ‘data volume’.
  4. ‘alpha-svc’ should be exposed on ‘port: 80’ and ‘targetPort: 80’ as ClusterIP
  5. Create a NetworkPolicy called ‘restrict-inbound’ in the ‘alpha’ namespace. Policy Type = ‘Ingress’. Inbound access only allowed from the pod called ‘middleware’ with label ‘app=middleware’. Inbound access only allowed to TCP port 80 on pods matching the policy
  6. ‘external’ pod should NOT be able to connect to ‘alpha-svc’ on port 80


1 Persistent Volume Claim

So first of all we notice the PVC is there but is pending, so let’s look into it

One of the first differences we notice is the kind of access which is ReadWriteOnce on the PVC while ReadWriteMany on the PV.

Also we want to check if that storage is present on the cluster.

Let’s fix that creating a local-storage resource:

Get the PVC YAML, delete the extra lines and modify access mode:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  finalizers:
  - kubernetes.io/pvc-protection
  name: alpha-pvc
  namespace: alpha
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
  storageClassName: local-storage
  volumeMode: Filesystem

Now the PVC is “waiting for first consumer”.. so let’s move to deployment fixing 🙂

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims

https://kubernetes.io/docs/concepts/storage/storage-classes/#local


2 App Armor

Before fixing the deployment we need to load the App Armor profile, otherwise the pod won’t start.

To do this we move our profile inside /etc/app-arrmor.d and enable it enforced


3 DEPLOYMENT

For this exercise the permitted images are: ‘nginx:alpine’, ‘bitnami/nginx’, ‘nginx:1.13’, ‘nginx:1.17’, ‘nginx:1.16’and ‘nginx:1.14’.
We use ‘trivy‘ to find the image with the least number of ‘CRITICAL’ vulnerabilities.

Let’s give it a look at what we have now

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: alpha-xyz
  name: alpha-xyz
  namespace: alpha
spec:
  replicas: 1
  selector:
    matchLabels:
      app: alpha-xyz
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: alpha-xyz
    spec:
      containers:
      - image: ?
        name: nginx

We can start scanning all our images to see that the most secure is the alpine version

So we can now fix the deployment in two ways

  • put nginx:alpine image
  • add alpha-pvc as a volume named ‘data-volume’
  • insert the annotation for the app-armor profile created before
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: alpha-xyz
  name: alpha-xyz
  namespace: alpha
spec:
  replicas: 1
  selector:
    matchLabels:
      app: alpha-xyz
  strategy: {}
  template:
    metadata:
      labels:
        app: alpha-xyz
      annotations:
        container.apparmor.security.beta.kubernetes.io/nginx: localhost/custom-nginx
    spec:
      containers:
      - image: nginx:alpine
        name: nginx
        volumeMounts:
        - name: data-volume
          mountPath: /usr/share/nginx/html
      volumes:
      - name: data-volume
        persistentVolumeClaim:
          claimName: alpha-pvc
---

4 SERVICE

We can be fast on this with one line

kubectl expose deployment alpha-xyz --type=ClusterIP --name=alpha-svc --namespace=alpha --port=80 --target-port=80

5 NETWORK POLICY

Here we want to apply

  • over pods matching ‘alpha-xyz’ label
  • only for incoming (ingress) traffic
  • restrict it from pods labelled as ‘middleware’
  • over port 80
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: restrict-inbound
  namespace: alpha
spec:
  podSelector:
    matchLabels:
      app: alpha-xyz
  policyTypes:
    - Ingress
  ingress:
    - from:
        - podSelector:
            matchLabels:
              app: middleware
      ports:
        - protocol: TCP
          port: 80
        

We can test now the route is closed between the external pod and the alpha-xyz

Done!


REFERENCES:

Connect to an external service on a different AKS cluster through private network

My goal is to call a service on an AKS cluster (aks1/US) from a pod on a second AKS cluster (aks2/EU).
These clusters will be on different regions and should communicate over a private network.

For the cluster networking I’m using the Azure CNI plugin.

Above you can see a schema of the two possible ending architectures. ExternalName  or ExternalIP  service on the US AKS pointing to a private EU ingress controller IP.

So, after some reading and some video listening, it seemed for me that the best option was to use an externalName service on AKS2 calling a service defined in a custom private DNS zone (ecommerce.private.eu.dev), being these two VNets peered before.

Address space for aks services:
dev-vnet  10.0.0.0/14
=======================================
dev-test1-aks   v1.22.4 - 1 node
dev-test1-vnet  11.0.0.0/16
=======================================
dev-test2-aks   v1.22.4 - 1 node
dev-test2-vnet  11.1.0.0/16 

After some trials I can get connectivity between pods networks but I was never able to reach the service network from the other cluster.

  • I don’t have any active firewall
  • I’ve peered all three networks: dev-test1-vnet, dev-test2-vnet, dev-vnet (services CIDR)
  • I’ve create a Private DNS zones private.eu.dev where I’ve put the “ecommerce” A record (10.0.129.155) that should be resolved by the externalName service

dev-test1-aks (EU cluster):

kubectl create deployment eu-ecommerce --image=k8s.gcr.io/echoserver:1.4 --port=8080 --replicas=1

kubectl expose deployment eu-ecommerce --type=ClusterIP --port=8080 --name=eu-ecommerce

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.1/deploy/static/provider/cloud/deploy.yaml

kubectl create ingress eu-ecommerce --class=nginx --rule=eu.ecommerce/*=eu-ecommerce:8080

This is the ingress rule:

❯ kubectl --context=dev-test1-aks get ingress eu-ecommerce-2 -o yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: eu-ecommerce-2
  namespace: default
spec:
  ingressClassName: nginx
  rules:
  - host: lb.private.eu.dev
    http:
      paths:
      - backend:
          service:
            name: eu-ecommerce
            port:
              number: 8080
        path: /ecommerce
        pathType: Prefix
status:
  loadBalancer:
    ingress:
    - ip: 20.xxxxx

This is one of the externalName I’ve tried on dev-test2-aks:

apiVersion: v1
kind: Service
metadata:
  name: eu-services
  namespace: default
spec:
  type: ExternalName
  externalName: ecommerce.private.eu.dev
  ports:
    - port: 8080
      protocol: TCP

These are some of my tests:

# --- Test externalName 
kubectl --context=dev-test2-aks run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- wget -qO- http://eu-services:8080
: '
    wget: cant connect to remote host (10.0.129.155): Connection timed out
'

# --- Test connectivity AKS1 -> eu-ecommerce service
kubectl --context=dev-test1-aks run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- wget -qO- http://eu-ecommerce:8080
kubectl --context=dev-test1-aks run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- wget -qO- http://10.0.129.155:8080
kubectl --context=dev-test1-aks run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- wget -qO- http://eu-ecommerce.default.svc.cluster.local:8080
kubectl --context=dev-test1-aks run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- wget -qO- http://ecommerce.private.eu.dev:8080
# OK client_address=11.0.0.11

# --- Test connectivity AKS2 -> eu-ecommerce POD
kubectl --context=dev-test2-aks run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- wget -qO- http://11.0.0.103:8080
#> OK


# --- Test connectivity - LB private IP
kubectl --context=dev-test1-aks run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- wget --no-cache -qO- http://lb.private.eu.dev/ecommerce
#> OK
kubectl --context=dev-test2-aks run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- wget --no-cache -qO- http://lb.private.eu.dev/ecommerce
#> KO  wget: can't connect to remote host (10.0.11.164): Connection timed out
#>> This is the ClusterIP! -> Think twice!


# --- Traceroute gives no informations
kubectl --context=dev-test2-aks  run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- traceroute -n -m4 ecommerce.private.eu.dev
: '
    *  *  *
    3  *  *  *
    4  *  *  *
'

# --- test2-aks can see the private dns zone and resolve the hostname
kubectl --context=dev-test2-aks run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- nslookup ecommerce.private.eu.dev
: ' Server:    10.0.0.10
    Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local
    Name:      ecommerce.private.eu.dev
    Address 1: 10.0.129.155
'

I’ve also created inbound and outbound network policies for the AKS networks:

  • on dev-aks (10.0/16) allow all incoming from 11.1/16 and 11.0/16
  • on dev-test2-aks allow any outbound

SOLUTION: Set the LB as an internal LB exposing the external IP to the private subnet

kubectl --context=dev-test1-aks patch service -n ingress-nginx ingress-nginx-controller --patch '{"metadata": {"annotations": {"service.beta.kubernetes.io/azure-load-balancer-internal": "tr
ue"}}}'

This article is also in Medium 🙂


Seen docs:

Differences from Scrum, Lean and Disciplined Agile Delivery

So, your manager just finished a SCRUM course, because your enterprise company thinks it is the cutting-edge management process and now everything should be SCRUM or something very close…

Are you doing SCRUM?

How much time do you dedicate to sprint planning?

Do you have a fixed, cross-functional and autonomous team assigned to fixed length sprints full time?

Do you have a dedicated person for managing business requirements inside a backlog?

Are you taking short (5 min per person) daily stand-up meetings where everyone shares just the blocking points to the rest of the team and the Scrum master?

Are you sure you need Scrum?

Applying a complex methodology when you are in a deep technical depth situation will just make the things worse.
It is what Martin Fowler calls Flaccid Scrum.

In this case what you really need to do first is to increment your delivery fluency starting from practices like Continuous Delivery or applying pragmatic methodologies like Extreme Programming.

For many people, this situation is exacerbated by Scrum because Scrum is a process that’s centered on project management techniques and deliberately omits any technical practices, in contrast to (for example) Extreme Programming.

Martin Fowler

Fluent Delivering teams not only focus on business value, they realize that value by shipping as often as their market will accept it. This is called “shipping on the market’s cadence.”

Delivering teams are distinguished from Focusing teams not only by their ability to ship, but their ability to ship at will.

Extreme Programming (XP) pioneered many of the techniques used by delivering teams and it remains a major influence today. Nearly all fluent teams use its major innovations, such as continuous integration, test-driven
development, and “merciless” refactoring.

In recent years, the DevOps movement has extended XP’s ideas to modern cloud-based environments.

Triple constraint triangle

Comparing Scrum with Lean

So, let’s say your company’s managers already read this article and its related sources, so you’re really going fast on your CI/C processes and almost everything is versioned and monitored…

How to manage that in a big company with a lot of distributed teams?

Let’s give a fast look to Lean and then to Disciplined Agile Delivery.

SCHEDULE / TIME

Agile: fixed timeboxes and release plans are used to schedule your next activities. You need to sort your activities in order to plan your tasks by priority in a managed backlog.

Lean: the schedule can vary based on priority of the tasks exposed in a Kanban board that should be always visible by every one. No need for all the team to be full time on one task, the experts can use a divide-and-conquer approach, focusing on the most critical parts first and releasing when it is possible, following the customer Service Agreements.

SCOPE

Agile: the sprint backlog will contain the minimum scope necessary to develop the next product release

Lean: the tasks are generated by customer tickets where they specify also the urgency level.

BUDGET

Agile: ROI and Burndown charts are used to monitor budget during the project

Lean: KPI and Service Level Agreement are used to continuously check product quality and the production chain efficiency

Disciplined Agile Delivery

The Disciplined Agile Delivery (DAD) process framework is a peoplefirst,
learning-oriented hybrid agile approach to IT solution delivery. It
has a risk-value lifecycle, is goal-driven, is scalable, and is enterprise
aware.

Here the differences from Scrum, Lean and Disciplined Agile Delivery.

PEOPLE

Keep the docs at the really minimum.
The traditional approach of having formal handoffs of work products (primarily documents) between different disciplines such as requirements, analysis, design, test, and development is a very poor way to transfer knowledge that creates bottlenecks and proves in practice to be a huge source of waste of both time and money.

Teams should be cross-functional with no internal hierarchy. In Scrum for instance, there are only three Scrum team roles: Scrum Master, product owner, and team member. The primary roles described by DAD are stakeholder, team lead, team member, product owner, and architecture owner.

LEARNING

The first aspect is domain learning: how are you exploring and identifying what your stakeholders need, and
perhaps more importantly, how are you helping the team to do so?

The second aspect is process learning, which focuses on learning to improve your process at the individual, team, and enterprise levels.

The third aspect is technical learning, which focuses on understanding how to effectively work with the tools and technologies being used to craft the solution for your stakeholders.

What may not be so obvious is the move away from promoting specialization among your staff and instead fostering a move toward people with more robust skills, something called being a generalizing specialist.
Progressive organizations aggressively promote learning opportunities for their people outside their specific areas of
specialty
as well as opportunities to actually apply these new skills.

HYBRID PROCESS

DAD will take elements from the other methodologies to tailor a process that best suites an enterprise agile team:

  • prioritized backlog from Scrum
  • Kanban dashboard and limit work in progress approach from Kanban (Toyota production system)
  • Agile way to manage data a and documents
  • CI/CD, TDD, collective ownership practices from Extreme Programming and DevOps

IT SOLUTIONS OVER SOFTWARE

As IT professionals we do far more than just develop software. Yes, software is clearly important, but in addressing the needs of our stakeholders we often provide new or upgraded hardware, change the business/operational processes that stakeholders follow, and even help change the organizational structure in which our stakeholders work.

Agile was created mostly by developers and consultants, we need to focus more on business needs and company processes optimizations.

Goal-Driven Delivery Lifecycle

  • It is a delivery process extending the Scrum one, starting from the initial vision to the release in production;
  • explicit phases: Inception, Construction and Transition;
    • Inception: initiate team, schedule stakeholders meetings, requirements collection, architecture design, align with company policies, release planning, set up environment
    • Construction: CI, CD, burndown charts, TDD, refactoring, retrospective, etc..
    • Transition: delivering in production. This stage contains steps like UAT, data migration, support environment preparation, stakeholders alignment, finalize documentation and solution deployment.
  • put the phases in the right context: evaluate system preparation activities before development start and management of the system by other groups after the final release
  • explicit milestones

Conclusions

Here we have seen, shortly, the main differences from Scrum, Lean and Disciplined Agile Delivery.

DAD is a very complex process and to find out the details there is just THE book to read in the final references.

A complete enterprise delivery process is something that requires months of work by an architecture board, but the point here is how to take the right direction as soon as possible, avoiding being hypnotized by buzz-words like Scrum or thinking that we are really agile just because we do a hour stand-up meeting every morning.

Start from removing your technical depth following firmly EP and DevOps practices. Then start formalizing your process methodology and make sure every one is walking on the same path.

REFERENCES:

Supervised learning regression analysis on Google stocks

Supervised learning on Google stock analysis and predictions

Abstract

We study some tech stock price through data visualization and some financial technique, focusing on those which are intended to give a sort of reliable prevision to permit brokers have a basis on which they could decide when it is the best moment to sell or buy stocks. We first analyze a year of data about the biggest companies as Amazon, Google, Apple and Microsoft but right after that we focus on Google stocks.

Next we leave the financial tools for supervised learning analysis. These machine learning processes learn a function from an input type to an output type using data comprising examples. Furthermore we’ll talk specifically of regression supervised learning, meaning that we’re interested in inferring a real valued function whose values corresponds to the mean of a dependant variable (stock prices).

We first applied linear regression on the last 6 years of Google Trends about the word ‘google’ specifically searched in the financial news domain, versus the last 6 years Google stock prices. From now on we change our feature domain with a multivariate input, i.e. we use other stock prices (AAPL, MSFT, TWTR, AMZN) to study the accuracy of others algorithms such as a multivariate linear regression, a SVR and a Random Forest.

keywords : Finance, Stock Price Analysis, MACD, Machine Learning, Linear Regression, SVR, Random Forest, Data Visualization, Python, R

What to do next ?

  • Do you see any error? Please tell me what to correct and why;
  • Implement these algorithms on other stocks and compare results
  • Add the r sqared to the RMSE comparison
  • Try to predict future stocks prices instead of contemporary ones

Amazon, Apple, Microsoft and Google pairplot

Amazon, Apple, Microsoft and Google pairplot

Controllo automatico della connessione rimanente, per rete 3 (tre.it)

Script per il controllo automatico (dalle 8:00 alle 23:00 ogni 30 min) della connessione  rimanente con l’abbonamento 3. In caso il valore sia inferiore ad uno preimpostato (500MB) invia un email d’allerta. E’ necessario essere connessi con la 3.

L’unica versione funzionante è la selenium, che necessita Firefox.

Ma con qualche piccola modifica sono sicuro che riusciate ad utilizzare Chrome se preferite, o a reindirizzarlo sul sito del vostro provider.

Se è effettivamente utile fatemelo sapere che si può migliorare facilmente. 🙂

Data mining – 2014 homeworks solutions

Homeworks solutions (pdf + code).

  1. Homework 1 – Sol
  2. Homework 2 – Sol
  3. Homework 3 – Sol
  4. Homework 4 – Sol
  5. Homework 5 – Sol
  6. Homework 6 – Sol

Algorithm Design / Theoretical Computer Science – 2015 – Homeworks solutions

Hi

Since often in the homeworks the questions are similar to those of the previous years, here there are my solutions.
It costed us weeks of work, too much for dying forgotten in my hard disk.

Site course

  • Homework 2 :  Solution
    Themes : Set Cover, partial set cover, max cover, linear programmming (LP), integer linear programming (ILP), maximum weight matching, game theory, approximation, steiner tree, minimum spanning tree.

For the Latex version of the solutions please donate and I will send it to you with joy. 🙂


Stop forgetting seen episodes

I don’t have good memory.. so often I click ( and start watching ) on tv-series episodes already seen.. and it can take a while before I realize it..

That’s how I resolved :

On Chrome ( on Firefox it’s very similar)

  • open the page with the links
  • open the Developer Tools (Ctrl+Maiusc+I on Chrome) or right-click on the body of the page and select Inspect Element
  • click on the + on the right ( new style rule) and add these 2 blocks:adding a new rule in chrome developer tools

a{
background-color: white;
}

a:visited {
background-color: black;
}

If the background isn’t white change the colors as you wish. But remember that it isn’t a permanent solution, it works as long as you keep the window open!

That’s all 😉

[RDF/OWL] semantic analysis with Jena

Hi, this is a little Eclipse project I did for a course on Semantic Web.

It works with Jena API and uses some dataset for querying through SPARQL. You’ll see how to deal with the various functionalities such as loading a RDF into a model, querying it through runtime code or the Fuseki interface, how to store the model through TDB and some OWL reasoning

Download :   

Download of tweets with Python

Our goal is to download a stream of tweets in Rome as they are created and create a web page that displays their location on Google maps.
We will need the help pf two modules : twython and pygmaps. The first to connect to the Twitter servers and to read the tweets, the second one to represent these tweets on the Google map.

So you will need to

  1. Install twython
  2. download the edited pygmaps module (or you can do it by yourself adding the Title functionality to the addpoint() function)
  3. download and test my script
  4. tweetMap

Swi-Prolog : ricorsione

Learn Prolog now : Recursion
Lista dei predicati in Prolog

% -- hungry bear
isDigering(X,Y):- justAte(X,Y).
isDigering(X,Y):- justAte(X,Z),
		  isDigering(Z,Y).
					
justAte(bear, john).
justAte(bear, honey).
justAte(john, chicken).
justAte(john, potatoes).
justAte(chicken, worm).

/*
	?- isDigering(bear, Gnam).
		Gnam = john ;
		Gnam = honey ;
		Gnam = chicken ;
		Gnam = potatoes ;
		Gnam = worm ;
*/

% -- The history of music 

descend(X,Y):- child(X,Y).
descend(X,Y):- child(X,Z),
	       descend(Z,Y).
				
child(worksong,blues).
child(blues,jazz).
child(jazz, prog).
child(blues,rockabilly).
child(rockabilly, hardRock).
child(hardRock, metal).

% -- Counting one by one

numeral(0).
numeral( succ(X) ):- numeral(X).

% -----------------------

% -- King Fibonacci 

fib(1, 1).
fib(X, Y):- X>0, Z is X-1 ,
	    fib(Z, Y2),
	    Y is X*Y2 .

% somma da una lista			
sumList([], 0).
sumList(List, Sum):- [Head| Tail] = List,
		     sumList( Tail, TempSum),
		     Sum is  TempSum + Head.


% riconosce liste con lo stesso numero di caratteri
a2b([],[]).
a2b([_|A], [_|B]) :- a2b(A, B).


% calcolo lunghezza delle stringhe 
len([],0).
len([_|T], N):- len(T,X), 
		N is X+1.

% mischia due stringhe un carattere alla volta 
combine([],[],[]).
combine(L1, L2, Result):- 	L1 = [A|T1], L2 = [B|T2],
				combine(T1, T2, R),
				append([A,B],R,Result).
				%Result = [A,B,R]. crea una lista di liste	
	/* 
		 combine([c,n],[a,e],X).
		 X = [c, a, n, e] ;
	*/

[2] SWI-Prolog + Eclipse : Parole crociate

Prima di svolgere il prossimo esercizio consiglio di installare il plugin PDT su Eclipse per avere una postazione di lavoro più comoda e potente :

Eclipse : versione successiva alla 4
SWI-Prolog : versione successiva alla 6
PDT

Attenzione a non installare la versione nel repository di ubuntu che è più vecchia

$ apt-cache showpkg swi-prolog
Package: swi-prolog
Versions:
6.4.1-1-g09194b7-raringppa2 ... <- da installare
5.10.4-5ubuntu1 (/var/lib/apt/lists/i

$ sudo apt-get install swi-prolog=6.4.1-1-g09194b7-raringppa2

Exercise 2.4 Here are six Italian words:
astante , astoria , baratto , cobalto , pistola , statale .
They are to be arranged, crossword puzzle fashion, in the following grid:
The following knowledge base represents a lexicon containing these words:

word(astante, a,s,t,a,n,t,e).
word(astoria, a,s,t,o,r,i,a).
word(baratto, b,a,r,a,t,t,o).
word(cobalto, c,o,b,a,l,t,o).
word(pistola, p,i,s,t,o,l,a).
word(statale, s,t,a,t,a,l,e).
Write a predicate crossword/6 that tells us how to fill in the grid. The first three arguments should be the vertical words from left to right, and the last three arguments the horizontal words from top to bottom.

% 3 verticali V1,V2,V3 e 3 orizzonatali H1,H2,H3
word(astante, a,s,t,a,n,t,e).
word(astoria, a,s,t,o,r,i,a).
word(baratto, b,a,r,a,t,t,o).
word(cobalto, c,o,b,a,l,t,o).
word(pistola, p,i,s,t,o,l,a).
word(statale, s,t,a,t,a,l,e).

crossword(V1,V2,V3, H1,H2,H3) :- 
		word(V1, _,V1H1,_,V1H2,_,V1H3,_),
		word(V2, _,V2H1,_,V2H2,_,V2H3,_),
		word(V3, _,V3H1,_,V3H2,_,V3H3,_),
		word(H1, _,V1H1,_,V2H1,_,V3H1,_),
		word(H2, _,V1H2,_,V2H2,_,V3H2,_),
		word(H3, _,V1H3,_,V2H3,_,V3H3,_),
             % non incrociare le parole con sé stesse
		H1\=V1, H2\=V2, H3\=V3.	

% chi più ne ha più ne metta :)
/*
word(scatole, s,c,a,t,o,l,e).
word(estonia, e,s,t,o,n,i,a).
word(baretto, b,a,r,e,t,t,o).
word(cavallo, c,a,v,a,l,l,o).
word(ceretta, c,e,r,e,t,t,a).
word(cintola, c,i,n,t,o,l,a).
word(pittalo, p,i,t,t,a,l,o).
word(lisbona, l,i,s,b,o,n,a).
word(funesto, f,u,n,e,s,t,o).
word(colante, c,o,l,a,n,t,e).
*/

/*
one solution :
     a   c   p
   a s t o r i a  
     t   b   s 
   b a r a t t o  
     n   l   o   
   s t a t a l e  	
     e   o   a
*/

Numero SMS virtuale online

Free online sms

Un paio di siti utili quando non si voglia dare il proprio numero per la registrazione a siti di poco conto

Mentre da qui possiamo inviarli gratuitamente

Primo script in Prolog

SWI-Prolog è la versione qui utilizzata.
Sistema: Ubuntu 13.04.
Strumenti: Gedit, Terminale.
Per installarlo : sudo apt-get install swi-prolog

Prolog is a declarative programming language. This means that in prolog, you do not write out what the computer should do line by line, as in procedural languages such as C and Java . The general idea behind declarative languages is that you describe a situation. Based on this code, the interpreter or compiler will tell you a solution. In the case of prolog, it will tell you whether a prolog sentence is true or not and, if it contains variables, what the values of the variables need to be.

Piccolo script per iniziare a conoscere il Prolog

largeFamily.pl

% database familiare
% iniziamo da lontano definendo un insieme di esseri umani..

human(john).
human(david).
human(gino).
human(bobbysolo).
human(karen).
human(gloria).
% ora separiamoli in base al sesso :
sex(john, man). % maschietti
sex(david, man).
sex(gino, man).
sex(bobbysolo, man).
sex(karen, woman). % femminucce
sex(sasha, woman).
sex(gloria, woman).
% iniziamo a definire le coppie
partner(john, gloria).
partner(david, britney).
partner(gino, topino).
partner(john, karen).
haveChild(john, sasha). % genitori
%haveChild(john, david).
% john,karen -> sasha,bobbysolo -> rocco,brigitte -> moana
haveChild(karen, sasha).
haveChild(gloria, david).
haveChild(sasha, rocco).
haveChild(bobbysolo, rocco).
haveChild(rocco, moana).
haveChild(brigitte, moana).
% definiamo ora delle funzioni che controllino se
% - A sia il padre di B
isFather(A, B) :- sex( A, man), haveChild(A,B).
% - A sia la madre di B
isMother(A, B) :- sex( A, woman), haveChild(A,B).
% - F e M siano padre a madre di A
parents(A, F, M) :- isFather(F, A), isMother(M,A).
% - A sia un avo di B
ancestor(A,B) :- haveChild(A,B).
ancestor(A,B) :- haveChild(A,X), ancestor(X,B). % non senti puzza di ricorsione ?
% - uno dei due è il padre/madre, il figliastro, il fratello/astro o un progenitore
areRelatives(A,B) :- isFather(A,B) | isFather(B,A) | isMother(A,B) | isMother(B,A);
partner(A,C), haveChild(C,B);
partner(C,A), haveChild(C,B);
haveChild(C,A), haveChild(D,B), ( partner(C,D); partner(D,C) );
ancestor(A,B); ancestor(B,A).

Mentre queste sono delle possibili interrogazioni da terminale

?- isFather(john,_).
true.
?- isFather(john,B).
B = david.
?- parents(david,Father,Mother).
Father = john,
Mother = gloria ;
false.

?- ancestor(john, Discendente).
Discendente = sasha ;
Discendente = rocco ;
Discendente = moana ;
false.

?- areRelatives(gloria, sasha).
true .
?- areRelatives(john,david).
true .
?- areRelatives(karen, moana).
true ;

CyanogenMod 10.1 su Samsung SL i9003

Cyanogenmod 10.1 Alpha 8

A partire da una Gingerbread 2.3.6 XXKPQ rootata.

Il sistema è molto gradevole e altamente configurabile, anche reattivo una volta che si è creata la partizione di swap.
Rimangono dei problemi con la fotocamera che spero si risolvano presto (è un’alpha..)

NB : sul mio modello le performance tweaks non hanno funzionato, non facendolo partire. Quindi se ci volete provare non dimenticate il backup..

Screenshot cyanogenmod Screenshot_2013-08-12-14-12-44 Screenshot_2013-08-12-14-17-45

Page 1 of 6

Powered by WordPress & Theme by Anders Norén