Websockets Server - Cookbook. As explained in this webpage, the Websocket protocol allows full-duplex, bi-directional communications between a server and clients. For this WebSocket tutorial, we will need to implement a server. We chose the Tornado Websocket server for our Internet of Things project. In this tutorial, we will present an example of how to get the Tornado Server running using websockets. This tutorial is divided into two parts: A Hello World which uses Tornado A websocket streaming example which uses Websocket4j. 1 - Hello World! 1.1 - Server side: Tornado¶ Warning Tornado only runs on Unix-like platforms.
Installation¶ First, download the sources, unpack and follow the readme. For more information concerning the installation, you can go here Code¶ You can find all the documentation you need here, but I will explain the main parts of the following basic Tornado Websocket server program. The main idea is to define a class inherited from the WebSocketHandler class. Open on_message on_close In our case: Code¶ Building a bookmarking service with python and phantomjs. March 29, 2012 19:16/1 comments/ phantomjs python Using python and phantomjs, a headless webkit browser, it is a snap to build a self-hosted bookmarking service that can capture images of entire pages. Combine this with a simple javascript bookmarklet and you end up with a really convenient way of storing bookmarks. The purpose of this post will be to walk through the steps to getting a simple bookmarking service up and running.
Installing phantomjs First step is installing phantomjs and making sure it is working correctly. Depending on your system you may need to follow slightly different instructions to get things running, so refer to phantomjs's documentation if you run into issues. Select the appropriate binary depending on your system architecture: Grab the tarball and extract it somewhere: mkdir ~/bin/ cd ~/bin/ wget tar xzf phantomjs-1.5.0-linux-x86-dynamic.tar.gz Symlink the binary somewhere onto your path. Dive Into HTML5. Create a stylish HTML5 template from scratch. HTML5 is certainly one of the latest buzzwords in the web community. It isn't something new anymore and we've already seen how cool it is. Features like simplified doctype, more semantic markup, input types and placeholders are just some of the reasons you'd like to use a HTML5 template. So, today we're going to build a HTML5 template using the full power of CSS3.
View demo The HTML5 template design Here's a screenshot with the HTML5 template layout we're going to code: As you may notice, the above HTML5 template is simple, minimal and stylish - thanks to the CSS3 awesome features. The not-so-secret ingredients: Simple logo using Google Font APINice drop shadow effects.Pattern background using data URI scheme.Vertical drop down menu animated with jQuery.Arrow shapes made with pseudo-elements.CSS3 gradients. A word on data URIs I wanted to create this HTML5 template demo without using any images and I made it. So the result is something like that: The encoded image is basically a pattern. The CSS. Getting Started with Web Audio API. Before the HTML5 <audio> element, Flash or another plugin was required to break the silence of the web. While audio on the web no longer requires a plugin, the audio tag brings significant limitations for implementing sophisticated games and interactive applications.
The Web Audio API is a high-level JavaScript API for processing and synthesizing audio in web applications. The goal of this API is to include capabilities found in modern game audio engines and some of the mixing, processing, and filtering tasks that are found in modern desktop audio production applications. What follows is a gentle introduction to using this powerful API. Getting started with the AudioContext An AudioContext is for managing and playing all sounds. A single instance of AudioContext can support multiple sound inputs and complex audio graphs, so we will only need one of these for each audio application we create. The following snippet creates an AudioContext: Loading sounds Playing sounds full source code Volume: