Where Art meets Science and falls in love.
17 Aug
As we know Brightkite is a location based social network where users can checkin into a location and make posts. I always had a thought on how we can acheive this functionality using django framework. Last week I started off this project with an eye on contributing it to Pinax project. I talked to Jtauber and I was lucky enough to get a chance before the feature freeze of pinax.
To start this project we need to recollect the basic requirements.
1. Registration for users. This can be acheived by django registration
2. Search for a location and get its proper place name, latitude and longitude data
3. Ability to checkin to that location. In simple words store the userid, place name, latitude, longitude and datetime of the checkin.
I am not going to start a brand new django project and build it upon it. Instead I recommend you to check out pinax project source code. Or you start a new project and add django-registration app to INSTALLED_APPS and set the urls. There are a bunch of tutorials on web on how to do that. Now we can create a new application called “locations”.
#!/bin/sh $ python manage.py startapp locations
You now have the basic skeleton of the location application. Lets start creating the model “Location”. As discussed in the basic requirements above.
from django.db import models from django.contrib.auth.models import User class Location(models.Model): user = models.ForeignKey(User) time_checkin = models.DateTimeField() place = models.CharField(max_length=100) latitude = models.FloatField() longitude = models.FloatField() class Meta: ordering = (‘-time_checkin’,) get_latest_by = ‘time_checkin’
The model is pretty self explanatory. It has a foriegn key to User, so that each user can have his own checkins. After the model is created our objective is to search for a location and get the geo data for that location. For this we will take help of GeoPy a geocoding toolbox for python. We can query web services like Yahoo, Google, Geocoders to get geo data for a location.
We create an entry in urls.py for this lcoations search.
urlpatterns = patterns(”, (r’new/$’, ‘locations.views.new’), )
To create a form, just create a file forms.py in locations and
class LocationForm(forms.Form): place = forms.CharField()
This means when somebody tries to access the url ‘/new/’ the request is routed to the view ‘new’. Lets create a definition for the ‘new’. Open view.py
@login_required def new(request): if request.method == ‘POST’: location_form = LocationForm(request.POST) if location_form.is_valid(): y = geocoders.Yahoo(‘yahoo_map_api’) p = location_form.cleaned_data[‘place’] place, (lat, lng) = y.geocode(p) location = {‘place’: place, ‘latitude’: lat, ‘longitude’: lng} checkin_form = CheckinForm() return render_to_response(“locations/checkin.html”, {“location”: location, “checkin_form”: checkin_form}) else: location_form = LocationForm() return render_to_response(“locations/new.html”, {“location_form”: location_form})
First of all I am protecting this view, so that only logged in users(@login_required) will be able to search locations. Next if the request of the type POST only the loop gets executed. If some tries to access with a GET/anything the else part will be executed there by rendering an empty form again. I’m extracting the data from request.POST and putting in location_form variable.
Next we import geocoders from geopy and then instantiate its Yahoo class. We can use Google or Geocoders as well, but I chose Yahoo. Pass your YAHOO_API_KEY as argument to Yahoo class. I am extracting the form data into a variable ‘p’ and then performing a geocode using the yahoo object. A request is made to Yahoo Geocoding service and geo data is returned. I created 3 variables place, lat & lng which contains place name, latitude & longitude. I pass all these variables into a dictionary and pass them to a template(checkin.html). In this process I am also creating a blank checkin_form which is also passed to the tempalte. I will discuss those details in the next part. You can check out the checkin.html which is pretty simple. It contains just a form.
More is part-2…
I am disabling comments for this posts as I already wrote this post in my personal blog. Head over to my blog to share some feedback with me.
15 Aug
Its happening at Beijing 2008 Olympic Games. World Records, Controversies, Revenge, and more.
At the same time players getting frustrated for the medals.
“I don’t care about this medal. I wanted gold,” he said.
Who had a high hopes from the last Olympic 2004.
“This will be my last match. I wanted to take gold, so I consider this Olympics a failure,” he said.
Swedish coach Leo Myllari said: “It’s all politics.”
Check More here
The bronze medal belonging to Ara Abrahamian of Sweden lies on the floor during the medal ceremony for the men’s 84kg Greco-Roman wrestling competition at the Beijing 2008 Olympic Games August 14, 2008. REUTERS/Hans Deryk (CHINA) - yahoo
Bronze medallist Ara Abrahamian (R) of Sweden throws his medal on the floor during the medal ceremony for the men’s 84kg Greco-Roman wrestling competition at the Beijing 2008 Olympic Games August 14, 2008. Gold medallist Andrea Minguzzi of Italy watches from the left. REUTERS/Oleg Popov (CHINA) - Yahoo
The bronze medal belonging to Ara Abrahamian lies on the floor during the medal ceremony for the men’s 84kg Greco-Roman wrestling competition at the Beijing 2008 Olympic Games August 14, 2008. REUTERS/Oleg Popov (CHINA) - Yahoo
15 Aug
Good News for Batman Fans !! Like me
Dark Knight Returns is the hot topic so far. Lot of discussion is going around about Gotham, who will be next villain and more.
And i came across some fake image release about the Batman - Dark Knight Returns.
I wish this should be true.
29 Jul
So this will be my first post on simori. I had been observing this site for quite sometime and found very useful information. In case you have n’t got me yet, I am yashh. So here I am to add a few tidbits of mine.
For about an year I was wondering if google provided any API’s for the 3rd party players to utilize google search. In fact google has supported the Soap API for few years. The Soap API provided a lot of freedom for the developers to utilize the Google search remotely. The main advantage was that we could hide the backend queries from the presentation. In simple terms the results do not have the brand name google. Although google limited the queries to 1000 per day it was worth while. As of December 5, 2006, google is no longer issuing any new API keys to the developers and instead started promoting the AJAX search APIwhich does not give the developers the freedom to manipulate the presentation of search results.
Now it is Yahoo which has come the BOSS api which is used to launch search products. The first obvious question is how is it different from the previous Yahoo API.
So let’s get started with a small exercise to know how Y! BOSS API works. Sign up for an BOSS Application ID. For this excercise I am using Y! BOSS mashup python library. You can download the library here. Unzip the library. Open config.json file in code editor and edit the application id with yours. Fire up your terminal (if on mac or command prompt on windows).
#!/bin/sh
$ cd Desktop/boss_mashup_framework_0.1
$ export PYTHONPATH=$PYTHONPATH:$PWD
$ python
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
>>> from yos.boss import ysearch
>>> data = ysearch.search(‘python’, count=10)
>>> data
# You find all the top search results for the keyword ‘python’
in a dictionary format. Voila you are able to search the web from your terminal.
Will Larson developed a python wrapper for the Yahoo BOSS boss_array.py. This eases our development by a large amount. Here is a good tutorial using the wrapper.
Conclusion: Yahoo BOSS api is certainly a boon for third party apps and developers. All it needs to improve is the speed and accuracy. It will take some time for the developers to accustom to it and develop new API’s over BOSS.
I am disabling comments for this posts as I already wrote this post in my personal blog. Head over to my blog to share some feedback with me.
20 Jul
“Heath Ledger born April 4, 1979 was an Academy Award-, BAFTA-, Golden Globe-, and SAG Award-nominated Australian film and television actor. After appearing in television roles during the 1990s, Ledger developed a movie career, appearing in nearly 20 films. He starred in both critical and box-office successes, including 10 Things I Hate About You, The Patriot, Monster’s Ball, A Knight’s Tale, and Brokeback Mountain. For his portrayal of Ennis Del Mar in Brokeback Mountain, Ledger was nominated for a 2005 Oscar for “Best Actor in a Leading Role” and also was nominated and won “Best Actor” awards for that role from BAFTA and the Australian Film Institute and the New York Film Critics Circle, respectively, as well as won an MTV Movie Award with Jake Gyllenhaal for their “best kiss” in the film.
He played the Joker in the movie The Dark Knight, shortly before dying, on January 22, 2008, from an accidental prescription drug overdose at age 28. His final film performance, uncompleted at the time of his death, is the role of Tony in Terry Gilliam’s forthcoming film The Imaginarium of Doctor Parnassus. Posthumously, on February 23, 2008, he shared the Independent Spirit Robert Altman Award with the cast and crew of the film I’m Not There, in which he portrayed a character named “Robbie Clark”, based on a stage in the life of Bob Dylan. “
From Wiki
20 Jul
Dark Knight Sets Weekend Record with “155.34 M”
“The Dark Knight” took in a record $155.34 million in its first weekend, topping the previous best of $151.1 million for “Spider-Man 3″ in May 2007 and pacing Hollywood to its biggest weekend ever, according to studio estimates Sunday”. Yahoo.
” Estimated ticket sales for Friday through Sunday at U.S. and Canadian theaters, according to Media By Numbers LLC. Final figures will be released Monday.
1. “The Dark Knight,” $155.34 million.
2. “Mamma Mia!”, $27.6 million.
3. “Hancock,” $14 million.
4. “Journey to the Center of the Earth,” $11.9 million.
5. “Hellboy II: The Golden Army,” $10 million.
6. “WALL-E,” $9.8 million.
7. “Space Chimps,” $7.4 million.
8. “Wanted,” $5.1 million.
9. “Get Smart,” $4.1 million.
10. “Kung Fu Panda,” $1.8 million. ”
From Yahoo.
12 Jul
11 Jul





Today at exactly 8:00 in the morning, Apple opens the door to accept their orders of the new iPhone 3G. Similar to the commotion of the last iPhone, crows have lined up heavily last night to claim their spot in front of Apple and AT&T stores. People who were skeptical to purchase about the first iPhone a year ago, are now lined up, waiting for the new and improved iPhone 3G. The “launch” of the new iPhone doesn’t end there, in various places like YouTube & Flickr, owners of the new iPhone post up pictures, videos, reviews and most importantly their “love”.
For those you missed the commotion, here’s the experience all recorded.
7 Jul
Found this really awesome picture of Hokusai’s Great Wave made from blue jeans. At first I couldn’t make up what the blue things were, it looked like shreaded blue papers with Hokusai’s painting. But when I looked closely at the length of the medium, and the texture on them, I soon recognize that they were all blue jeans!
6 Jul
On June 17th, 2008 Firefox 3 set Guinness World record for most downloads in 24 hours. Million number of ursers downloaded firefox 3 in just one day. The excpectations in more than 5 million in one day, but i am not sure about the count. But i bet it will be more than 2 million. But its really amazing to see such an amount of users using Firefox.
The mail Expected Feautres.