Showing posts with label Projects. Show all posts
Showing posts with label Projects. Show all posts

Wednesday, 12 January 2011

Multiuser Chatroom with App Engine Channel API - Part 2


The Part-1 of designing multiuser chat room with app engine deals with providing a basic information of how to create a simple chatroom/gameroom with App Engine Channel API. That article was more based on the tic-tac-toe example provided by the Google App Engine team.

In this post, I will talk about the ways in which this can be optimized using memcache.

But before that, let's look at the complications with the previous one
  1. The Channel ID is a function of only userid. This means that one user can not login from multiple clients and can expect consistency. There will always be an inconsistency and improper outgoing messages on the channels.
  2. Too much datastore operations. For every action, there is too much datastore operations going on. As the number of players keep on increasing, this problem becomes more intense. A developer reported that he had to wait several seconds for things to happen while doing it with ~30 players. This is an optimized version and will have much better serving time
  3. Coding style. Well frankly, I was not satisfied with the coding style in prev version, so in the hope of creating better and beautiful code, I decided to rewrite it and I came up with this new file tournament.py, which is pretty neat.

First of all, in order to get an insight of effective memcaching in datastore entities, go through this post on Nick's blog. This has been completely used.

EfficientModel

In order to do good optimizations, I have a base class EfficientModel from which my datastore classes will be derived. Entities of kind EfficientModel are designed to be in memcache most of the time they are required. All the operations on these entities take place in memcache only. After the memcached entity has been updated "certain" number of times, the change is replicated in the datastore. The EfficientModel has an attribute mc_version, which stores the version number of this entity in memcache. The concept is that every entity has a revision number associated. Whenever there is any change in one of the attributes/property of the entity it's version number increases by one. mc_version stored the version number of entity in memcache. db_version stores the version number of entity in the datastore. The difference between memcache version and datastore version is called as FAULT NUMBER. When fault_number goes beyond a certain number known as fault_tolerance, then the memcache entity and the datastore entity are sync'd.


Properties, Classmethods and Functions
  • keyname, property. : Returns the key name of the entity. Equivalent to
    .key().name()
    
  • memcache_key, property : The derived class is expected to define this property. This is supposed to return the key which will be used in memcache while storing and retrieving this entity. It is assumed at some places the memcache_key shall be same as keyname.
  • from_id(id), classmethod : This classmethod returns the entity based on the id passed. It first tries to fetch the entity from memcache. If not found, it attempts to fetch the entity from datastore. If that is not found, then it creates an entity with the key_name as the id passed and returns that.
  • _from_memcache, private function : Returns the memcached snapshot of the entity
  • _get, private function : Attempts to get self from memcache. If not found, goes through a get_or_insert call.
  • fetch_from_id(id), classmethod : The difference between fetch_from_id and from_is is that, fetch_from_id always creates an entity in the datastore if it does not already exists. While in case of from_id a dummy object (one which is not in the datastore, yet) is returned.
  • sync_from_db, function : Sync the entities from datastore to memcache. Essentially, the entity is copied to memcache from datastore and the versions are updated
  • sync_to_db, function : Sync the entities from memcache to data store. Essentially, the entity is copied from memcahe to datastore and the versions are updated
  • _store, private function : Stores the entity in memcache and updates the mc_version. If the fault becomes more than fault tolerance, it syncs the entity across datastore and memcache.
  • find_parent(id), classmethod : This is not implemented and the derived class is expected to work on this. This is supposed to return the key name of the parent entity of this entity.

Channels

The channel ids created are a function of userid as well as the time.time(). Whenever a channel id is created, it is stored as a property in the Player model as well as the Game model. Duplicacy of data, helps do better reads.


Player Class


The Player Class has more or less the same functions, but their writing style became little different due to change in coding style.



Game Class


The important parts of the class are shown here. For a more detailed version, have a look at the source code.

This is a better optimized version. I am still working on it on a bigger and wider scale and will keep updating about the scaling issues of this approach and how to fix them.

Resources

  1. Multiuser Chatroom with App Engine Channel API - Part 1: http://blog.myblive.com/2010/12/multiuser-chatroom-with-app-engine.html
  2. Source Code: http://code.google.com/p/pranav/source/browse/chat-channel
  3. Channel API: http://code.google.com/appengine/docs/python/channel
  4. Discuss: Google Groups Discussion
  5. Tic Tac Toe App: http://code.google.com/p/channel-tac-toe

Saturday, 6 November 2010

Getting rid of facebook group emails, beautifully


Like many others, after being irritated by facebook's constant emails for every post on a group I am a member of, I made Group Email Digest (facebook page) application which sends me the daily summary of posts on a group. The applications sends out one email per day per group. The first version of the app launched was pretty simple and had some basic bugs which restricted the use of the application. The latest release of the app (the app is still in beta) has fixed those bugs and paved way for more interesting features in the applications.

Here is a brief summary of bugs fixed, bugs not fixed and things on my mind (to show up in later releases). For a complete and updated detail of issues, visit the bug tracker page.

UPDATE
The bug related to closed/secret group's emails not being trigged has been fixed.

Resolved Bugs/ Issues
  1. Blank Email/Text: A blonde had three swimming pools. One had cold water, the other had warm water and there was no water in the third pool. When asked about the third pool, she said.. well, sometimes I don't feel like swimming. :-) The Group Email Digest app used to send out blank emails, when there had been no recorded activity. This has been fixed, and now, no emails are send if there is no activity.
    Likewise, if there were only links shared, videos posted, images uploaded onto the group, there was a similar blank text coming up. This has been alternated by message, description and caption in that order.
  2. Digest Emails not generating: For few old group's, the emails were not being triggered. I found this out to be a version change issue on facebok front, and maintaining the compatibility, this has been fixed. The emails for all groups shall be triggering starting Nov 06
  3. URLs for old groups not coming properly: The URLs for old facebook groups were not formatted appropriately. This resulted in the clicks taking user to facebook home page instead of taking to the group page. This issue has been fixed.

Unresolved Bugs/Issues
The following issues remain unresolved as of now.
  1. Time Zone: All the emails are triggered just after 00:15 hrs UTC. This should ideally be 00:15 hrs User Time Zone. I am looking for a resource efficient method for this, and hopefully should get this fixed soon.
  2. Closed/Private Group Emails not trigerring: I am experimenting with delivering digest emails from closed/private group to its members in a resource efficient manner, and hopefully should arrive at some conclusion soon.

Things in my mind
The following features you should hope to see in near future.
  1. Localization: You should see the mail in the language of your choice, right? So, very soon, you will receive emails and all the text will be localized based on the information we obtain about you from your facebook account.
  2. Activity Graphs: Wanna know how active is a group? Very soon, you will be able to see a graphical visual of the activity taking place in the groups you are a member of.
  3. Group Suggestions: Want to do more exiting talks to people of your interests? Group suggestions will be telling you about new active groups based on your taste.

Did I miss a feature? Suggest features for Group Digest App here.

Saw a bug/issue/concern? Report it here.

Follow @groupdigestapp on twitter.

Friday, 8 October 2010

Easy tagCloud jQuery Plugin


This is the 101th post on Bellicose Beliefs (former CodeControl), and today we have with us, an easy tagcloud plugin for jQuery. It is called easy tagcloud because it is really very easy to use and provides options to make life easier.

The source code can be obtained from GoogleCode Repository of CodeControl-Samples http://code.google.com/p/codecontrol-samples/source/browse/#hg/myBtagcloud

Friday, 1 October 2010

BeamtoUs - Discover Vote Share



Welcome Beamto.us (twitter @beamtous), a completely new and beautiful music sharing portal. We love to call each single element that you share as a beam. This is also my current project, where I am involved in close coordination with caffeine powered code monkeys - Ritesh Nadhani (idea bubble generator), Taras, Freechin and others. Beamto.us.

Beamto.us is a music sharing portal targeting specific to genres like psy trance, chillout trance, dark trance, progressive trance and other sub genres in them. You can easily upload your music, or if you have already done that on youtube, soundcloud or other portals, can link from Beamto.us. I'd like to talk more on what are the interesting things that you can do with Beamto.us. The official About Us page says
"Beamto.us Aggregates. The only website in the World that aggregates all electronic music. We use the best back-end technology to bring an excellent interface to all the users. The main page of the site aggregates and lists only the most popular songs voted by the users. Our algorithm has been simulated and tested to be absolutely fair to rankings."






Features

  1. Beamto.us allows you to login through your existing Google Account, so you don't need to go through all the registration hassle and pain.
  2. You can upload your music onto our servers or can hotlink your existing website/link for your music at Beamto.us.
  3. Vote Up/ Down a particular beam. And yeah, the votes and rankings do decay so if your beam is hot and new, you are going to be at the top.
  4. Easily share your beams on Facebook, MySpace, Twitter and many other favorite sites, where your friends can see them
  5. Concerned about copyright issues or something else, just let us know. We deal with abuse reports very seriously.
  6. We have lots of space and our servers are on the cloud, so don't worry about a downtime :-) Whenever someone wants to go through your beam, we make sure that it is always up and serving hot.
  7. Its FREE to use. Yes, you don't need to pay in order to use or share your beams. Just come over and we will be doing the things for you.

The portal is still in its early phases and we have some very exiting plans to make it fun. Yes, that's our concern. Make beaming fun, simple and share !!

And yes, we are always listening to our users who tell us about our faults and where we need to improve. And we do work on them. So, whenever you feel something is missing, just let us know.

Sunday, 23 May 2010

AtoZ-Help : version 0.2 released


The version 0.2 of AtoZ-help Framework is available for download and testing purposes. AtoZ-help is a framework written in Pure Python and runs on Google AppEngine for creating feature rich help pages online. The help pages can be integrated with your existing website or can be released as an independent site.

Check out the source code at : http://code.google.com/p/atoz-help/
Got a buF? Report it at : http://code.google.com/p/atoz-help/issues/list
The latest version is available for download. Download it here


Sunday, 27 December 2009

AtoZ Help - An Engine for creating online help section on AppEngine

So, this Christmas, i had nothing better to do than sit and do this project named AtoZ-help.

The project aims at creating an engine that can create and manage the help sections of a website in a very efficient and hassles-less manner.

Website : http://atoz-help.appspot.com
Repository: http://atoz-help.googlecode.com

The project is under rapid development and this release has been completed in 2 days (starting from scratch), and although serious issues are not quite expected, there needs a lot of tuning, refining and features to be added.

If you have a bug report/ feature request. kindly so in the issues list here. Please search the issue list to avoid duplicacy.

As of now, it is not recommended to use this project for business purposes just because the project is evolving very fast, and so some features might get changed or discontinued. It is however, good if you are a developer and want to try things out.

I will be releasing a complete tutorial and a much convenient template for AtoZ, but they are not in my priority list. The roadmap for this project is listed at the RoadMap Wiki Page.

Sunday, 31 May 2009

A better feed reader

Most of the feed readers - web based, desktop based are more or less similar in their approach. You subscribe to a feed, and they will display all new (or non read) items. It is good. Now this is what a feed reader should do. Some feed readers (like Google reader) go beyond this and allow you to share your favorite feeds with your friends.What more does anyone needs?

Well, there are many more ways in which a feed reader can be enhanced. I wil be talking about the one that i find most useful.

Everything is not important

I am a feed junkie. I go to any website, and if i find anything interesting, i immediately subscribe to its feed. Months later, i realise that not all posts from that website is what i actually am interested in. Let's take a scenario.Most people are subscribed to Slashdot or LifeHacker or Reddit. I am particularly interested in Programming and Technology. And specifically in Python, C++, WebApps. But what i am getting in my feeds is everything from FORTRAN to JAVA and from Microprocessors to launch of new space craft. This is useless information for me, and what i will be doing probably is - select all, mark as read. If i dont get a chance to read my feeds for a day or two, i will easilt have 1000+ posts and when bulk mark as read, i am probably going to miss out things that might be important for me.

Overcoming the situation

In my opinion, there is only one way to overcome the situation. Get the specific posts from the feeds, in which the reader is interested. So, if i am interested in Python and C++, i will be able to see and read only those feeds that have relevent information about Python and C++.
Again, there are two approaches to make this possible.

Approach 1) Let the reader speak for himself.

When a user is subscribing a new feed say "Programming", suggest him - This is a very broad category. Would you like something in particular, say C++ or Python? If he says yes, go ahead and keep this thing in memory.

Aproach 2) Find out yourself.

In this approach, the user is initially presented with all the posts corresponding to a feed. A track record is kept for the feeds that the user has actually read and for those feeds for which he has just "marked as read". Based on these data over a span of time, the system will be generating a set of keywords, which describe a range of interests for one particular user.

One or both of the above approaches can be used. What matters is that the set of keywords for the range of user's interests in posts should be accurate. This is never guaranteed to be comprehensive, but should be somewhat near to it.

Now things are quite simple. We have the feed, we have the list of posts, and we have the user's interest. For every post in the feed, scan it. See if it contains things that might interest user. Show him only those posts, that he is interested in. If the system is uncertain about a post, that can be under the "posts you might be interested in" section of the feed reader.

If implemented in this manner, i believe that feed readers can be more popular and good than the present ones.

If any engineer who is working on some feed reader is reading this post, and might consider it for their next release, i would be happy if they could contact me and say "Thanks" :-)

Make this world a better place.

Tuesday, 31 March 2009

Codechef - India's biggest Online Programming Battle

CodeChef is India's biggest and aggressive online programming battlefield. I came to know about CodeChef, a couple of days back only, and no doubt, i am impressed.
Designed in a very elegant manner, using jQuery to the max and with cool color blends, the site offers a nice look and feel. Definitely better than other sites in similar area.

My first Impression with CodeChef.

As i created my account, and logged into the site. There were a couple of things that attracted my attention. The thing that i really liked was live stats. The site gives you live stats of the coders trying to get into problem solving and their result. This creates an adrenaline rush, and you are tempted to do something.

Most of the top coders on this site are from premier Indian Institutes like IIT, IISc and others. You can see the real names of people instead of their hax0r names. This is somewhat non-traditional. Traditionally, programmers all over the world have been known by their IRC nicks only. So, if you see someone over coding arena with the nick 'pranny', you can very well assume that his IRC nick is 'pranny'.

The site offers a wide range of programming languages, from LISP to Java. However, if you watch closely the maximum number of entries come from C++, then comes Java. As per my observation, i have not seen a single entry in Python (my favorite). So, if you are a python enthusiastic, there is lot scope for you.

The April challenge

The April challenge is about to come. For more details log onto CodeChef and see for yourself.


Practise for TopCoder and Google Code Jam


In my opinion, the best place to practise for TopCoder and Google Code Jam is to start off with CodeChef. The easy level practise problems, should be completed accurately and well within time. The medium difficulty ones are good and the difficult ones do require brain.

If you are needing any help with Codechef, you can contact their help section at http://www.codechef.com/help/

Thursday, 11 December 2008

YaWa - AppEngine Library to automate models behaviour

When it comes to my qualification, i am a software engineer. When it comes to my work, i deal with only webapps. And when it comes to web app, it comes to data exchange - between the system and the user. Hell lot of data exchange. Most of it is in the form of "forms". There is a form wherein user inputs some value to the system. The system the processes the request and gives the response. A major share of these requests and response are based on some tables, or the DataStore entity as AppEngine calls it.
I had been working on a way to abstract these interactions. So that the forms could be generated magically. These forms are not just plain DjanoForms, rather highly interactive forms, which has the ability to perform all the basic actions - create new record, edit an existing record, delete an existing record and search a record. And now i have with me - YaWa.
YaWa stands for Yet Another Widget fro Appengine. It is a library that can be imported in your appengine applications and helps you abstract the process of human-system interaction.

What does YaWa consists of.

In plain terms, yawa consists of a couple of python modules and a couple of templates. That's it. There won't be much need to modify the core files, until you want some feature that is not provided. The templates are the eye-candy. They are responsible for the look and feel of the forms. You may modify these templates in order to suit your needs.

How to use YaWa

In order to use YaWa, all you have to do is to prepare a list of Models that you want to work with, a list of those properties you want to exclude. Now the core module of YaWa, called bond, will feed on these lists and based on the templates, will generate UI elements.

Project code and live demo

The project is hosted at http://yaw-appengine.googlecode.com. A live demo can be taken at http://pran.appspot.com.

Suggestions and issue reporting

Report any suggestions, feature requests or issues here.

Monday, 24 November 2008

OnlineCompiler.org

OnlineCompiler.org is a completed online development environment for C/C++ in Linuc/Unix Style and built over the opensource WebDevStudio project.

You can access onlineCompiler.org here. This is a joint project by CodeControl and Ajay Jain. OnlineCompiler.org has a lot of features that will make online development quite comfortable and fun. You can save your prohects over there, take a backup and retrieve it later, or may be download it. It is specially useful in cases when you need to do something and they don't have a compiler. 

Currently onlinecompiler.org supports only Unix/Linux GCC based C/C++. We are planning to introduce Python support very soon. But no official dates. :-)

Hope you will like it. For any queries, comments, appreciation or crtisim, just comment out here. We will be glad to hear from you.

Sunday, 9 September 2007

MIT Project Oxygen

MIT Project Oxygen - Human Centered, Pervasive Computing

For over forty years, computation has centered about machines, not people. We have catered to expensive computers, pampering them in air-conditioned rooms or carrying them around with us. Purporting to serve us, they have actually forced us to serve them. They have been difficult to use. They have required us to interact with them on their terms, speaking their languages and manipulating their keyboards or mice. They have not been aware of our needs or even of whether we were in the room with them. Virtual reality only makes matters worse: with it, we do not simply serve computers, but also live in a reality they create.

In the future, computation will be human-centered. It will be freely available everywhere, like batteries and power sockets, or oxygen in the air we breathe. It will enter the human world, handling our goals and needs and helping us to do more while doing less. We will not need to carry our own devices around with us. Instead, configurable generic devices, either hand held or embedded in the environment, will bring computation to us, whenever we need it and wherever we might be. As we interact with these "anonymous" devices, they will adopt our information personalities. They will respect our desires for privacy and security. We won't have to type, click, or learn new computer jargon. Instead, we'll communicate naturally, using speech and gestures that describe our intent , and leave it to the computer to carry out our will.

New systems will boost our productivity. They will help us automate repetitive human tasks, control a wealth of physical devices in the environment, find the information we need (when we need it, without forcing our eyes to examine thousands of search-engine hits), and enable us to work together with other people through space and time.

As partial fulfillment to the Computer Engineering structure, we were supposed to given a seminar . I choose this topic. You can download the full seminar report from here. The PDF of the presentation is also available at this location.

permalink

Wednesday, 8 August 2007

Online C/ C++ Compiler

There are many times, when you have thought of compiling some code while surfing a website. Now to compile the code, start off with your favorite C/C++ Compiler is a bit difficult task. So an alternative is to use an Online C/C++ Compiler, designed by Siddharth Upmanyu. It is a full feature rich C/C++ compiler. You can even have command line parameters and upload an input file.

The Compiler is now available as Facebook Application - http://apps.facebook.com/onlinecompiler

Here is the link to FB app - http://apps.facebook.com/onlinecompiler


If you find the app not working, there could be minor glitches. Please reload the app. If it persists, kindly drop me a mail.