Real-time plots using websockets, python, javascript and Google Charts

There are many examples of use of websockets out there, however most of them are cumbersome or too complex for newbies.

Here is an extremely simple example of websockets I made, which consists of a server (implemented both in PERL and Python, up to you the choice) that pushes a message (i.e. randomly generated values) to the client upon a fixed time interval:

https://github.com/albertobeta/UberSimpleWebsockets

Two clients are available in this example:

  • client-JustLog.html displays on screen the log with the messages received;
  • client-Chart.html shows a bar chart (based on Google Charts) which updates in real time with the data received.

Configuration

If you are running this code in a local host (i.e. your local machine) no configuration is needed. Otherwise, you can change ports and host from the config sections in the code.

Usage

  1. SERVER: choose either send.pl (PERL) or send.py (Python) and run ONE of them from the terminal: type eitherperl send.pl or python send.py
  2. CLIENT: Open one of the two clients (but they also work at the same time in two separate tabs) using a modern browser (e.g. tested and working with Chrome v.42+). Notice that the client must be opened after the server is running (otherwise, you will have to push the “reconnect” button).
  3. See the data pushed automatically from the server to the client via websockets :bowtie: (Optionally, you might want to use Firebug with client-Chart.html to see the console logs)

Requirements

  • PERL or Python
  • A modern browser that supports websockets (e.g. Chrome v.42+)

Notice:

  • The PERL implementation of the server requires Net::WebSocket::Server. In Mac OSX it can be installed using the command: sudo perl -MCPAN -e 'install Net::WebSocket::Server'
  • The Python implementation of the server requires Tornado that can be installed using pip (pip install tornado) or manually:
tar xvzf tornado-4.1.tar.gz
cd tornado-4.1
python setup.py build
sudo python setup.py install

Why user reviews visualization needs emotion: a proof of concept.

In the last decade many popular web and mobile services have collected huge (and precious) amounts of data about users’ opinions, which are generally expressed in form of ratings and reviews. However, the way most of these services present the data collected to their end-users is often old-fashioned and mainly consists of simple numbers and plain charts.

For instance, let’s take TripAdvisor as a test case. TripAdvisor is one of the main references worldwide for hotels and restaurants reviews, which can drive the choices of millions of travelers when visiting a new location, hence leading to a significant real-world economic impact for local businesses and associated services.

Nonetheless, the way content is presented by TripAdvisor can sometimes be confusing to the general audience. Despite having collected a considerably rich amount of data, in fact, these information are displayed using tens of numeric values associated to basic plots such as horizontal bar charts:

tripAdvisor

These visualization choices are not as immediate as they could be, and require further interpretation by the user (e.g. having 54 terrible reviews on a total of 1200 is different than having 54 terrible reviews on a total of 100, and this is not immediately reflected in the information displayed).

In the era of new data visualization techniques and infographics, something better can be done. This is precisely the motivation behind the creation of MoodAdvisor, a free web & mobile app that allows travellers to quickly visualize in a very graphical and straightforward fashion the excellency of a hotel and the the happiness of previous travelers who left a review. The former measure is based on the number of excellent and very good reviews normalized according to the total number of reviews and converted into a percentage, while the latter measure is based on state-of-the-art algorithms of sentiment analysis to interpret the affect in the reviews left on TripAdvisor for a certain location.

MoodAdvisor allows the user to search for any hotel worldwide through a simple form, then retrieves the data from TripAdvisor, computes in real-time the aforementioned values of excellency and happiness, and visualizes the results using gauges followed by colored boxes representing the latest reviews associated to simple emotions (happy, neutral, sad):

moods

For the front end, MoodAdvisor makes use of jQuery UI + Javascript to asynchronously retrieve data and of HTML5 + Google charts to visualize the results. The back-end (data scraping and sentiment analysis) is developed using PHP.

Unfortunately, when requesting to access the official API, TripAdvisor did not approve the use MoodAdvisor did of their data since it was in violation of their Terms of Use and I was explicitly requested not to go live with my service. For this reason, MoodAdvisor was never officially launched :( However, the technology behind MoodAdvisor is fully functional and can be applied to many other web services and datasets (e.g. reviews of products on Amazon etc…). Moreover it constitutes a proof of concept on how the visualization of user ratings and reviews not only could be graphically more informative, but also should introduce novel measures, such as emotion, which are intrinsic to human communication capabilities and therefore convey information in a more efficient and straightforward way.

MoodAvisor can still be tried at moodadvisor.com, even though the results presented now are based on dummy data. I also released part of the code (data scraping from a webpage using regular expressions) on GitHub.

This post originally appeared on LinkedIN.

The top 8 free retro games for the Holiday Season (iOS and Android)

Christmas is coming! And what’s better during the holiday season than playing some festive videogames!? A popular tradition back in the ’80s and ’90s was to produce Xmas-themed games featuring festive music and our favourite pixelated heroes (if you are from that generation you might remember titles such as Holiday Lemmings or Jazz Jackrabbit). Well, this tradition is back! Here is our top list of Xmas-themed and old-style mobile games available today in the App and Play stores…

1. Droppin’ Santa (iOS Universal & Android)

Dropping Santa for iOS and AndroidDroppin’ Santa is an infinite scroller where a pixelated Santa Claus has to drop presents down the chimneys while avoiding green fireballs. The gameplay is as simple as that, yet the game is not as simple as it may sound. Fun and addictive! The game soundtrack is a mix of “We wish you a merry Christmas” and “Jingle Bells” with an original chiptune style! My personal highscore is 43 presents. What’s yours?

iTuneshttps://itunes.apple.com/app/droppin-santa-8bit-retro-xmas/id938661029?ls=1&mt=8

Play Storehttps://play.google.com/store/apps/details?id=net.Betella.DroppinSanta

dropping Santa highscore iOS and Android

2. Christmas Invaders (iOS Universal & Android)

icon175x175screen568x568-1Inspired by the arcade classic Space Invaders. Tilt your device to control your Christmas Tree shooter and hit the oncoming enemies that are getting closer and closer.

iTuneshttps://itunes.apple.com/us/app/christmas-invaders/id770300201?mt=8

Play Storehttps://play.google.com/store/apps/details?id=com.hovelgames.invadersgame

3. Super Mega Worm Vs Santa (iOS Universal & Android)

icon175x175Guess who has been a naughty boy this Christmas? Santa and his little helpers have crossed the line and now they must pay. Join Wojira, The Great Mega Worm, as it returns in this all new adventure set in the North Pole. Crawl and eat your way through waves of elves and their evil machines as you grow and evolve into the ultimate weapon of mass destruction to become the Super Mega Worm!

iTuneshttps://itunes.apple.com/us/app/super-mega-worm-vs-santa/id406920248?mt=8

Play Storehttps://play.google.com/store/apps/details?id=com.deceasedpixel.smwxmas2

screen480x480

4. Flap Tap Santa (iOS Universal & Android)

icon175x175-1 screen322x572-1Yet another clone of Flappy Birds, with the addtion of a nice, Xmasy 8bit soundtrack. You (Santa) have to avoid Xmas decorations and chimneys. Each time you avoid an obstacle, a present will drop in the chimney below. Flappy Birds fans will love it!

iTuneshttps://itunes.apple.com/us/app/flap-tap-santa-christmas-gift/id948249694?mt=8

Play Storehttps://play.google.com/store/apps/details?id=com.nerdgames.flaptapsanta

5. Santa’s Coming (iOS Universal)

icon175x175 screen568x568Nice and fun vertical scroller where Santa Claus has to collect presents and candies while avoiding fireplaces! The game features 27 Levels (of which 12 easy & 15 hard) to ensure hours of fun!

iTuneshttps://itunes.apple.com/us/app/santas-coming-retro-game-2014/id486934862?mt=8

6. Green Christmas (iOS Universal)

IMG_3934 icon175x175-1Collect the Christmas items to earn points while avoiding the coal. Little green-colored game that reminds the old ZX spectrum or Olivetti PC screens! Ideal for the nostalgics.

iTuneshttps://itunes.apple.com/us/app/green-christmas/id578661633?mt=8

7. Saving Xmas (iOS Universal)

icon175x175 Help Santa to eat all the cookies. Protect children from inappropriate presents. Give Grinch ultimate K.O. in the epic battle for Christmas! Feed Rudolf to make him prepared for the Christmas night and much more! Many little games in one!

iTuneshttps://itunes.apple.com/us/app/saving-xmas/id769923892?mt=8

screen520x924

8. EightBit Santa (iOS Universal)

screen568x568 icon175x175Help Santa to collect presents and avoid obstacles while going down the chimney. A nice vertical scroller with a lovely soundtrack (that includes a real “ho ho ho”).

iTuneshttps://itunes.apple.com/us/app/eightbit-santa/id730879286?mt=8

 

That’s it for now. Do you know other free and Xmas-themed retro games worth mentioning?