CookieViz on Mac OS X in more than 128 words

CookieViz is a visualization tool that measures the impact of cookies on your own browsing.

https://linc.cnil.fr/fr/cookieviz-une-dataviz-en-temps-reel-du-tracking-de-votre-navigation

The page is git is https://github.com/LINCnil/CookieViz

I install MAMP: https://www.mamp.info/en/downloads/

MAMP is a compilation of free open source software to manage dynamic websites on computers running macOS or Windows: Apache, the web server; MySQL, the database management system; phP, Perl or Python, programming languages used for web development.

Install Homebrew: Homebrew is a free open source software management system that simplifies the installation of software on Apple's macOS and Linux operating system.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The script asks to switch to superuser mode via the sudo command and asks to type the password several times.

At the end of the installation you get a successful installation!

I install mitmdump which is in the mitmproxy package

brew install mitmproxy

Validate the installation by tapping mitmdump –version

mitmdump --version
 Mitmproxy: 4.0.4
 Python: 3.7.5
 OpenSSL: OpenSSL 1.1.1d 10 Sep 2019
 Platform: Darwin-17.7.0-x86_64-i386-64bit

I start MAMP and not MAMP PRO which is paid

I get the home page of my Apache web server that is booted on port 8888 by default I can reach by typing localhost:8888 as url in my browser.

If I go into the MAMP -Preferences menu I can change the ports used.

I downloaded from the github source of cookieViz https://github.com/LINCnil/CookieViz via the Clone and download link. It is also possible to start a terminal and place yourself at the root of the WEB Apache server.

By default the root is in /Applications/MAMP/htdocs/ but you can change it via the MAMP graphical interface

cd /Applications/MAMP/htdocs/
git clone https://github.com/LINCnil/CookieViz.git

By default the default user of the database is "root" and password "root" To change t
he password by default: https://docume
ntation.mamp.info/en/MAMP-Mac/How-Tos/Change-the-password-of-the-MySQL-root-user/ /App
lications/MAMP/Library/bin/mysqladmin -u root -p password

Adding a user phpmyadmin – mysql – user 'add a user' tab User Accounts

I added a user 'cookvi' with password 'cookvi'

I edited the settings.inc file via a text editor or nano control

/**
 The database server used by CookieViz.
 Default is 'localhost' and should be fine for most cases.
 If 'localhost' doesn't work and the database runs locally, try '127.0.0.1'.
 */
define ('DB_SERVER', '127.0.0.1:8889');

...

define ('DB_USER', 'cookvi');

/**
 The password of the CookieViz database user.
 */
define ('DB_PASSWD', 'cookvi');

I then edited the nano monitor_mitmdump.php file of the directory /soft

cd /Applications/MAMP/htdocs/CookieViz/soft/
nano monitor_mitmdump.php 

I went to http://localhost:8888/phpmyadmin/ and I created a new CookieViz base

I clicked on the created database and i used the "import" function and loaded the file /Applications/MAMP/htdocs/CookieViz/cookieviz/sql/url_referer-1.sql which contains the table structure

Edit the four values below
$PROXY-HOST – "localhost"; Proxy server addre
ss $PROXY-PORT – "8082"; Proxy server p
ort $PROXY-USER -""; Userna
me $PROXY-PASS -""; Password

CookieViz is php5 compatible and not phpt7 you should expect changes in the code:

Replacing:

$link - mysql_connect ('localhost', '', '') by $link - mysqli_connect ('127.0.0.1:8889', 'cookvi', 'cookvi','CookieViz') 
mysql_select_db ('CookieViz') by mysqli_select_db ($link, 'CookieViz')
mysql_error() by mysqli_connect_error()
mysql_query ($query) by mysqli_query ($link, $query)
mysql_fetch_assoc ($result) by mysqli_fetch_assoc ($result) 
mysql_close ($link) by mysqli_close ($link)  

Start a server mitmdump on port 8082: mit
mdump -p 8082 -w mitmdump.log

I am now launching the php script /Applications/MAMP/htdocs/CookieViz/soft/monitor_mitmdump.php

At the firefox level I went into network preference sets in the general settings and I configured the proxy

We find that we have connections that pass through the proxy Prox
y server listening at http://:8081 127.0.0.1:
49915: clientconnect 127.0.0.1:4991
5: CONNECT www.youtube.com:443< cannot="" establis
h="" tls="" with="" client="" (sni:="" www.youtube.com):="" tlsexception("ssl="" handshake="" error:="" error()")="[(‘SSL routines’, ‘ssl3_read_bytes’, ‘sslv3 alert bad certificate’)]" 1
27.0.0.1:49917:="" clientconnect=""
127.0.0.1:49915:="" clientdisconnect=
"" 127.0.0.1:49917:="" get="" http://detectportal.firefox.com/success.tx
t="">< 200="" ok="" 8b="" 127.0
.0.1:49919:="" clientconnect="" 12
7.0.0.1:49920:="" clientconnect=""
127.0.0.1:49919:="" get="" http://detectportal.firefox.com/success.txt?ipv4=""
>< 200="" ok="" 8b="" 127.0.0.
1:49920:="" get="" http://detectportal.firefox.com/success.txt?ipv6="">< 200 O
K 8b 200="" ok=""></ 200 OK 8b>

The results can then be viewed on the web server http://localhost:8888/CookieViz/cookieviz/

The Python heap sorting algorithm in less than 128 words

The principle of the heap sorting algorithm is as follows:

  • We search for the father of the last knot of the tree and we sift it: the father of a knot in a binary tree corresponds to the lower round of (i-1)/2 with i the position of the knot in the table that stores the tree.
  • Sieving a knot involves visiting his right and left son and swapping the root with the larger of the two.
  • The tree is sifted until it reaches the root, the largest number of the tree is then in the root position at the beginning of the painting.
  • The root that is the largest number is swapped with the last leaf (i.e. the n position of the table that stores the n-size tree). This number is considered to be well ordered (i.e. it is in last position and it is the largest)
  • The sieving and swapping operation is repeated by considering the subtree that goes from root to n-1 (so as not to move the number that has been correctly ordered) until we reach the left wire of the root (index 1)

See wikipedia link: https://fr.wikipedia.org/wiki/Tri_par_tas

from math import
#128mots.com
def indice_fils_gauche (noeud_pere:int):
	return (noeud_pere - 2) - 1

def indice_fils_droit (noeud_pere:int):
	return (noeud_pere - 2) - 2
#Retourne the pere node index if it exists (node must be 0)
def indice_noeud_pere(knot):
	#Si it is the lower rounding of (knot-1)/2
	return floor (knot - 1)/2)

#permute 2 elements of a table and incrementally the overall variable compteur_permutation to be initialized in the hand
def permute (table, index1: int, index2:int):
	print ("Permutation of the element" - str (index1) - "with element" - str (index2))
	print(" Before permutation: " - str (table))
	globalcompteur_permutation
	if (index1!2):
	#on back up the value of Index 1 in a temporary variable
		tmp - table[indice1]
		table[indice1] - table[indice2]
		table[indice2] - tmp
		compteur_permutation 1
	print(" After permutation: " - str (table))

#Tamise a binary tree from a parametre knot
#1. the knot is compared with the right and left wire (if they exist)
#2. we swap with the highest value
#128mots.com
def thames (tree, knot, length):
	#On visits right and left son
	print ("Tamisage of" - str (knot) - " tree: " - str (tree)	
	indexSonRight - indice_fils_droit (knot)
	IndexLeft - indice_fils_gauche (knot)
	print ("IndexSonRight" - str (indexSon))
	print ("Left-hand index"" - str (left-hand index)


	if (indexSonRight< longueur): # si le fils droit existe longueur):="" #="" si="" le="" fils="" droit=""></ longueur): # si le fils droit existe>
		if (tre[indiceFilsDroit]e- tree[indiceFilsGauche]): #Si the right son is larger than the left wire
			if (tre[indiceFilsDroit]e- tree[noeud]): #Si the right wire is larger than the sifted knot
				permute (tree, indexSonright,knot)
		elif (tre[indiceFilsGauche]e - tre[noeud]e): #Si the left wire is higher than the sifted knot, so you swap
			permute (tree, left-hand index, knot)
	elif (Left-hand index< longueur): #Si le fils gauche existe longueur):="" #si="" le="" fils="" gauche=""></ longueur): #Si le fils gauche existe>
		if (tre[indiceFilsGauche]e - tre[noeud]e): #Si the left wire is higher than the sifted knot so we swap
			permute (tree, left-hand index, knot)
	print(" After sieving: " - str (tree))			
#128mots.com

compteur_permutation 0
tree - #[11, 222, 3, 24, 5, 46, 67, 899]On writes a tree in the form of a painting
print ("starting tree: " - str (tree)

#128mots.com
#Tamisage initial
#on takes the last element of the arbe which is a leaf and one looks for his father
IndexDuNoeudPere - indice_noeud_pere (tree)-1) 
#on sifting is compared to the father knot with the right and left son
#puis you swap with the highest value
for i in range (DuNoeudPere index,-1,-1): #On siftto to the root
	thames (tree,i,len (tree)

permute (tree, len (tree)-1.0) #on swaps the first element and the last 
#suite sieving is the greatest value so it is placed at the end of the table

#on repeats the sieving
for i in range(len(tree)-1,1,-1): 
	indexDuNoeudPereDeI - indice_noeud_pere (i-1) #on takes the element i of the arbe which is a sheet and one looks for his father
	for j in range (duKnotPereDeI index,-1,-1): #On siftto to the root
		thames (tree, j,i)
	permute (tree, i-1.0)

print ("final result of sorting: " - str (tree))
print ("number of permutations: " - str(compteur_permutation))