Installing protractor and selenium server on MAC

Protractor is actually substituting Karma as E2E tool for AngularJS applications!
To install protractor on a MAC checkout the following instructions:
1. Install Node.js if not already installed (see How To Install Node.js on MAC)
2. Install protractor node module
$ sudo npm install -g protractor
This will install /usr/local/lib/node_modules/protractor/
3. Install a standalone selenium server:
$ sudo webdriver-manager update

Now to start the selenium server type:
$ webdriver-manager start
this will start the selenium server on port 4444, if you need a different port i.e. 5555 then type:
$ webdriver-manager start –seleniumPort 5555

Now to launch the first protractor E2E test using the running selenium server go to:
$ cd /usr/local/lib/node_modules/protractor
and type:
$ protractor example/conf.js
It’s also possible to execute the test using directly i.e. chrome driver:
$ protractor example/chromeOnlyConf.js

Take a look at the provided example files under:
/usr/local/lib/node_modules/protractor/example

P.S. the selenium port (if changed from the default 4444) must be set into:
/usr/local/lib/node_modules/protractor/example/conf.js

 

 

How to convert mysql database from character set latin1 to utf8

This is just a note that I would like to point out for the future, having lost almost an entire day goggling and trying all the possible steps to convert a mysql database from latin1 to utf8, without any dump. Summarizing, you need the following steps:

1. ALTER DATABASE myDb CHARACTER SET utf8;
(set the Database DEFAULT CHARACTER SET to utf8 and the COLLATE to utf8_general_ci)

2. ALTER TABLE myTable CHARACTER SET utf8;
(change the CHARACTER SET to utf8 for the single table)

3. ALTER TABLE myTable CHANGE myCol myCol varchar(255) character set utf8;
(change the CHARACTER SET of the single column in this case the column named myCol of the table myTable)

4. Now for the single column we need a double round trick to correctly convert the old textual content written into tables in latin1:
4.1 ALTER TABLE myTable CHANGE myCol myCol VARBINARY(255);
(this modify the textual filed in a binary field keeping into account the utf8, the length is required for the VARBINARY that is the counterpart for VARCHAR, other binary doesn’t require the length i.e. BINARY for CHAR, BLOB for TEXT, TINYBLOB for TINYTEXT, MEDIUMBLOB for MEDIUMTEXT, LONGBLOB for LONGTEXT)
4.2 ALTER TABLE myTable CHANGE myCol myCol varchar(255) character set latin1;
(this will put back the value as textual but using the latin1 in order to have all the bytes in the columns)
4.3 ALTER TABLE myTable CHANGE myCol myCol varchar(255) CHARACTER SET utf8;
(set again the CHARACTER SET of the column as utf8)

Tips 1: Think to enlarge the size of the textual field where applicable because converting text from latin1 to utf8 can require more bytes. I.E. the ‘à’ in latin1 is using 1 byte in utf8 will use 2 byte

Tips 2: If the alter table to change the column to a binary type fails with “Column ‘myCol’ cannot be FULLTEXT index” then this means you have a key in your column like
FULLTEXT KEY `full_key` (`myCol`)
If this is the case just drop the key out
ALTER TABLE myTable DROP index full_key;

Installing Node.js and Karma on MAC

Starting to study AngularJS, following the “Android devices catalog” tutorial from http://docs.angularjs.org/tutorial, I needed to install Node.js and Karma in order to run the unit tests.

Node.js is a Server-side software for writing scalable Internet applications, especially web servers. Programs are server side in JavaScript, using event-driven, asynchronous I/O to minimize overhead and maximize scalability. Node.js is built on the Google’s open source JavaScript engine (Chrome’s JavaScript runtime).
1. Downloaded pkg from http://nodejs.org/
2. Executed node-v0.10.12.pkg:
3. Info: This package will install node and npm into /usr/local/bin
4. This will take 42.4 MB on your computer
5. node was installed at /usr/local/bin/node
….npm was installed at /usr/local/bin/npm
….Make sure that /usr/local/bin is in your $PATH.
6. To check the version installed execute:
….> node –version  (actually I’ve installed v0.10.12)

Karma is a “Spectacular Test Runner for JavaScript“. As root user executed from Terminal
> npm install -g karma  (this install karma on the machine)
> karma –version (Karma version: 0.8.6)
karma has been installed at /usr/local/bin/karma

 

Benvenuti!

Benvenuti! Spero di trovar del tempo libero per poter pubblicare articoli e pagine sui miei interessi/hobbies.

Max

Pubblicato in blog