Simori.com

Where Art meets Science and falls in love.

Archive for the ‘How-To’ Category

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.

Implementation:

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.

Yahoo’s new API BOSS

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.

  1. Unlimited queries per day.
  2. No restriction on presentation.
  3. Search Web, Images & News.
  4. Get Spelling sugestions.
  5. Reorder the search results & many other.

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.

Mactracker provides detailed information on every Apple Macintosh computer ever made, including items such as processor speed, memory, optical drives, graphic cards, supported Mac OS versions, and expansion options. Also included is information on Apple mice, keyboards, displays, printers, scanners, digital cameras, iPod, Apple TV, iPhone, Wi-Fi Cards/Base Stations, Newton, and Mac OS versions.

The software is packed with not only Apple desktop and laptop computers but also devices and peripherals such as iPhone, Servers, LaserWriter and Apple TV that Apple introduced between 1983 to 2008! It automatically detect your Mac and provide its in-depth profile.

I found a post on how to set PATH environment variables via the terminal, but for those who like to be escorted with GUI, here’s a little tip for you.

If you haven’t already do so, download TextWrangler. It’s a free text editor for Mac

Here’s the interface for TextWrangler.

With TextWrangler, you can edit hidden files on the Mac WITHOUT the ’sudo’ command. Here’s how:

(more…)

This is a beginner’s guide for installing MySQL (mysql-5.0.51b-osx10.5-x86.dmg) to a OS X 10.5.3

I’ve run into so many problems, frustration and problem trying to install MySQL to my Leopard because the documentations for installing MySQL have changed so much throughout different versions of MySQL and Mac OSX. I basically had to prowl through all sort of sources on downloading, installing and configuring MySQL on my OS X 10.5.3. After going through the nightmares, I thought I should document all my steps so people after me are better off than I am.

Note: If someone is expert in this matter, please help out this post by providing some of your experience and tutorials on improving this post, thanks!

(more…)

The next generation of iPhone will be released in just 4 days. Many who have refrained from buying the first iPhone are greatly anticipating this new, improved and de-bugged second generation iPhone. However, that’s not the only group demanding the next generation of iPhone, the current iPhone owners are also really reluctant on keeping their iPhones. And for those people who want to sell their iPhone in order to “upgrade” it, here’s something for you.

Questions you may have before selling your iPhone:

  • When to sell the iPhone?
  • How to reset everything?
  • How to market your iPhone?
  • Where to sell your iPhone online auction(Ebay & Craigslist) or international?
  • What to do if you have a locked or unlocked iPhone?
  • more..

(more…)

OldSchool Icon Set: Making Of. I

Here’s a full-length video tutorial on how the OldSchool Icon Set: Gameboy was created. This is a great video for you to pick up some nice bevel effects.



OldSchool Icon Set: Making Of. I from Pawel Kadysz on Vimeo.

Over the years, 3D-technology in modeling helped to create the realism of characters in games and movies. Due to 3D, we’re no longer constraint by the limitation of 2D, and Physics in gaming and characters look way better for the game play than before. However, today’s 3D is no longer the same as yesterday. Before we see the new breakthrough in 3D, let’s reminiscence the “old”.

Here are a couple of my favorite 3D breakthroughs.

1). Toy Story

2). Parasite Eve - Aya Brea & Lara Croft

2). Final Fantasy - The Dream Within

But all these breakthroughs are now yesterday when I came across this image of Song Hye Gyo.

This picture is all computer generated.
Yes, this is not Song Hye Gyo, but only a 3D model of her.

Here are the proofs,

Here’s the tutorials to create your own Song Hye Kyo.

How to Make Your Own Multitouch

Here’s a really short video on how to make your own Multitouch feature that’s seen on the iPhone and MacBook Air. The projects cost under $50!

  • 0 Comments
  • Filed under: Apple News, How-To
  • Generate Your Own QR Code

    Everywhere you look, even in supermarket, you see QR Code.

    For those who’re not familiar with QR Code, it’s a little demonstration of QR Code.

    If you’re really interested in having your own code. This website, Kaywa, encrypts URL, Text, Phone Number & SMS information into QR Code for you. Check it out.



    Your Ad Here

    Here’s a QR Code of Simori.com!

  • 0 Comments
  • Filed under: How-To, Web Goodies