CherryPy is sweet !

Some quick questions:

Are you looking for fast, fun, stable HTTP, WSGI web server?

Faster development using Python?

Object oriented ?

Do you want to run multiple HTTP servers at once (on multiple ports).

Command line options ?

Easy configuration ?

Built in caching, encoding, sessions, authorizations. static contents ?

YES“, CherryPy is sweet. It allows developers to build web applications in much the same way they would build any other object-oriented Python program. This results in smaller source code developed in less time.
You can download the latest version from here.
Example:

import cherrypy
import json

class Application(object):
    @cherrypy.expose
    def hi(self, *args):
        if not args:
            raise cherrypy.HTTPError(400, "no args.")
        elif len(args) == 1:
            m={}
            m['message'] = "Hey " + args[0]
            return json.dumps(m)
        else:
            raise cherrypy.HTTPError(400, "Something is fishy")
root = Application()

cherrypy.server.socket_host = '0.0.0.0'
cherrypy.server.socket_port = 8080
cherrypy.quickstart(root, '/')

Save and Run the script: python cherry.py

ENGINE Started monitor thread '_TimeoutMonitor'.
ENGINE Started monitor thread 'Autoreloader'.
ENGINE Serving on 0.0.0.0:8080
ENGINE Bus STARTED

Click here to see the output.(http://localhost:8080/hi/govil)

{"message": "Hey govil"}

Sources: http://cherrypy.org/

Bootstrap!

Last month I was asked to change the whole UI of my company’s product, as design was not great and didn’t match the current UI wars. Now being a developer it was completely a different task for me. After doing a little research, we used Twitter Bootstrap toolkit. So, current stage is that whole product is using Bootstrap css and js in a week. Some answers:

Do design and the interface look good?
The grid speaks itself, playing around with rows and spans are much easier and less time consuming. I just dropped my content in the html with the bootstrap appropriate class and its done! The whole design looks Consistent throughout the product. Navigations, NavTabs, Forms, Paginations, Alerts, BreadCrumbs etc all are easy to integrate with so much of less code to write.

Does javascript components are good?
With bootstrap, I could easily manipulate modal windows alerts, tooltips, popover, button etc. Integration was simple and fast to accomplish the results.

Is it responsive?
Bootstrap is responsive. All just works fine, when I shifted the product from a laptop to iPad or phone. Bootstrap adapts to the change in platforms with super speed and efficiency.

Documentation?
The Bootstrap docs speak themselves, they are neat, clean and to the point.

What is the Boss’s reaction?
From my perspective, I didn’t spend a lot of time in learning but definitely working knowledge of web development concepts like HTML and CSS were required. It was a immediate quality and efficient work.

A Pinch

It is remarkable that how much a pinch of reading can enhance your penetrating powers in an idea and opinions. Here are some good reads which I want to share.

A Pinch of Life
25 Things about life
Some lessons that can be learned to help along the journey of life.

A Pinch of motivation
Lost, stand again !!
When you win, you matter, When you lose, you matter, When you feel lost, you matter, When you find your way, you matter !!

A Pinch of dedication
Famous The Pirate Bay guys
The galaxy’s most resilient BitTorrent site and superb guys.

A Pinch of food
Eat alot !
Eat smarter and work smarter.

A Pinch of adventure/travel
Discover the world
Quite simply, traveling the world will be one of the best decisions you’ll ever make.

Access webcam without any plugins : WebRTC

WebRTC is free, open project that enables web browsers with Real-Time Communications (RTC) capabilities via simple Javascript APIs. This project is supported by Google, Mozilla and Opera. In here we are going to access webcam using Web APIs.

First step is to download the browers which supports latest media and RTC APIs.

  • Download Chrome
    Then, you need to enable the feature by visiting about:flags and Enable “Media Source API” the flag.
  • Download Firefox
    Then, you need to go to about:config and enable the feature “media.navigator.enabled”

Next step is to create video.html file. See below:

<html>
<body bgcolor="black">
<center>
	<video id="basic-stream" width="100%" height="80%" class="videostream" autoplay></video>
	<p><button id="capture-button">Capture video</button> <button id="stop-button">Stop</button></p>
</center>
<script type="text/javascript" pagespeed_no_defer="">
	pagespeed.lazyLoadImages.overrideAttributeFunctions();
</script>

<script>
function onFailSoHard(e){
	if(e.code==1)
		{
			alert('User denied access to their camera');
		}
		else
		{
			alert('getUserMedia() not supported in your browser.');
		}
}
(function(){
	var video=document.querySelector('#basic-stream');
	var button=document.querySelector('#capture-button');
	var localMediaStream=null;
	button.addEventListener('click',function(e)
	{
		if(navigator.getUserMedia)
		{
			navigator.getUserMedia('video',function(stream){
				video.src=stream;video.controls=true;
				localMediaStream=stream;},onFailSoHard);
		}
		else if(navigator.webkitGetUserMedia)
		{
			navigator.webkitGetUserMedia({video:true},function(stream){
				video.src=window.webkitURL.createObjectURL(stream);
				video.controls=true;localMediaStream=stream;},onFailSoHard);
		}
		else if(navigator.mozGetUserMedia)
		{
			// alert('moz');
			navigator.mozGetUserMedia({video:true},function(stream){
				// video.src=URL.createObjectURL(stream);
				video.mozSrcObject = stream;
				video.controls=true;localMediaStream=stream;},onFailSoHard);
		}
		else
		{
			onFailSoHard({target:video});
		}
	},false);
	 document.querySelector('#stop-button').addEventListener('click',function(e){video.pause();localMediaStream.stop();},false);
		})();
</script>
</body>
</html>

 

There is API Difference between Firefox and chrome:
Firefox and Chrome both prefix their interfaces and are likely to continue to do so until the standard is more finalized. The following table shows the relevant names:

W3C Standard           Chrome                   Firefox
--------------------------------------------------------------
getUserMedia           webkitGetUserMedia       mozGetUserMedia
RTCPeerConnection      webkitRTCPeerConnection  mozRTCPeerConnection
RTCSessionDescription  RTCSessionDescription    mozRTCSessionDescription
RTCIceCandidate        RTCIceCandidate          mozRTCIceCandidate

Copy and paste the video.html in the /var/www and run(http://localhost/video.html)

Thats it !

Sources: http://www.webrtc.org, http://dev.w3.org

Its your personal cloud, its your data and nobody cares !

The Cloud is nothing but The Internet. The Cloud Computing is nothing but The Service over Network. It comes in three forms: public clouds, private clouds, and hybrids clouds.
Public clouds are the ones in which service and infrastructure are provided by some 3rd party over the internet, but the problems with public clouds are security, control, privacy etc. Private clouds are the ones in which service and infrastructure are maintained over a private network, but the problem is, it is over a private network. Some companies started offering private version of their public clouds, but not worth it.

So what we need is public accessibility, control of the data, security, privacy and something which is personal, and to this kind of cloud, people call as Personal Cloud. As by the names it suggests its personal localized cloud accessible from anywhere all the time. It can be maintained by Individual, Family, Business etc.
Honestly, it doesn’t sound that steamy. Lets think, Did a common guy ever thought of accessing the data anywhere before existence of any public cloud service providers?. I guess ‘NO’.
Same way only few people feel the need of securing and having full control of their data rite now, eventually others will too.

As we talk about personal cloud, some expectations comes up in the mind, which could be:
- Easy installation of the cloud.
- Easy to maintain.
- Easy to use.
- Good support.
- Can handle lot of data.
- Can run on low config machines.
- Supports all the devices.
- Can be accessed from anywhere.
If any personal cloud provider meets these expectations, its a hit !!

Lets take an example: Here we have a family of four people. Mr. and Mrs. Smith and their children Alice and Bob.
They have installed a personal cloud on their home machine and lets call their cloud as MrAndMrsSmith’s cloud. The data resides on personal cloud and can be synced across multiple devices. Everybody have their devices to access the data from anywhere they want, it may be mobile, laptop, Desktop etc. They start using their cloud by uploading and downloading files to/from their own cloud.

Here Mrs. Smith keep uploading her pics from her mobile on the cloud and Mr. Smith gets to see her pics instantly without doing anything on his laptop through automatic Synchronization. Mrs. Smith also uploads some delicious recipes which she only wants to share with her friends, means you get to decide to whom you want to give control of the data.
Mr. Smith put some important documents on the cloud and which he only wants Mrs. Smith to see but not Alice & Bob.
Alice & Bob keeps their video games, ebooks and funny stuff on the cloud which they wanna share with their friends.
Smiths by themselves maintain their home cloud, which is a easy management of digital data and also they get their privacy and they get to own their data. They felt the need of personal cloud and they are using it. This actually changed the way they use to store, manage or share the data earlier.

Trillions of gigs of digital data is being generated every year and surely good proportion of that data comes under the category of personal data. Lets secure it !!