My thoughts on Oink

Oink is a web and iPhone app which let you to rate and share objects.  Kevin Rose and Daniel Burka  both from Digg and now Milk Inc managing this product. Oink is trying to focus on things inside places but not places itself, so this is how they differ themselves from services like Yelp and Foursquare.

Oink iPhone app

I see two problems currently with Oink. First, the search is only available on iPhone app and not website. Search in app is also not working the way I like. 1- there aren’t much items available around my location. 2- most of the items now is about foods which sometimes I think there are other things around the world to rate and share. The second problem, I can see is duplicates. It is impossible to remove duplicates of similar objects. So assume we are in the restaurant and each of us take picture of our dish and upload it to Oink. There is no way that Oink can find similar items and then aggregate all the rates. Other than these problems, Oink did a good job in the UI usability and marketing.

 

 

My habits as a entrepreneur

1- “Giving money away is a prerequisite to making more money. When you get older,” he told me “you have to keep thinking of new ways to create value. That’s important.” John Pappajohn

2- To guarantee being among the best in the world at something you pretty much need 10,000 hours of practice.

3- It is not a tragedy to not achieve your dream, but it is a tragedy not to have a dream.

4-  knowledge of the industry, hard work, reading everything I can get my hands on, optimism, risks, a network of family and business colleagues, and lots of motivation. Most importantly, I remember where I came from.

5-  Have a customer before you start your business.  Execution is useless.  The only thing that’s important is money. You get money by having a customer. You get a customer by satisfying a need that’s so important to them they would be willing to pay for it.  If you have a customer that’s willing to pay you money, then execution becomes a lot easier.  James Altucher

 

 

Start-Ups, Entrepreneurship, Venture Capital

I like to start series of blogs about what I learn about entrepreneurship. Ok lets start from business plan.

When you have an idea that you think is worth to make a business out of it you need to answer these questions.

1- What is your product?
2- Who is the customer?
3- How many people will buy it?
4- How much will it cost to design and build?
5- What is the sales price?
6- What is your exit strategy?

That is a very usual that you need some investor to give you some money to start your business. It is also common that you give some of your company equity in return for the capital you need to start. For raising funds you usually need to pitch your business plan for venture capitals (VC). Some of well known VCs are located in Silicon Valley, California. In Silicon Valley, most VCs firms are focusing in technology specially in software industry. Here is list of some VCs.

Its also common to be part of a accelerators to help you begin your business. Accelerators are usually help you to form your Inc, or LLC, give you office space, help you to prepare for pitch, connect you with VCs and other resources, and also give you a seed money to start your business. Some of well known accelerators in Silicon Valley are listed here.

Add facebook’s like button to your WP

This is very easy to integrate facebook’s like button to your posts. Ok here is step-by-step procedere.

1-Login to your WordPress admin

2-Go to the appearance –> editor section

3-From right panel click on Main index Template

4-On the line before

<p class="postmetadata"></p>

5-Paste the below code

<div class="postmetadata" id="facebooklikebtn">
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php the_permalink() ?>&amp;layout=standard&amp;show-faces=false&amp;width=450&amp;action=like&amp;font=verdana&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:20px"></iframe>
</div>

6-Do the above for the Page Template and Single Post
7-You Done!

If you have any question find me @digvan

Introduction to Redis

Introduction to Redis

Redis is a key-value database that has very nice features which every computer scientist love it.

Why I love Redis?

  • Redis give the data structure like all computer scientist learn in the school such as Set, sorted set, List, and Hash. So you don’t need to think in SQL anymore.
  • Redis is very fast it can gives you the performance about 50,000 to 100,000 operation per second in basic basic computers (2GHz CPU with 2GB RAM).
  • you can install Redis in 2 minutes. (Linux and Windows)
  • It’s written in ANSI-C so you can easily pick the source code (Yes, it’s open source!) and modify the code if you want.
  • There are native clients for almost every language (include PythonRuby and PHP) and Yes, you don’t need Thrift.
  • You can setup master-slave replication of Redis in 2 minutes.
  • Redis has great community lead by Salvatore Sanfilippo. (also check Redis Google group)
  • Redis is great for large scale web programming without need of MySQL. (Check Retwis )
  • Redis is very easy to learn.

Where should I start the basic?

  • First download the source code from Github or Google code.
  • Second compile the source code (basically just type ./make)
  • Download and install your language client if you prefer to work with Redis from your language here is list all language.
  • Run Redis server — $ ./redis-server — (Redis use port # 6379 by default)
  • Run Redis client  – $ ./redis-cli – and enter follow commands to see “Hello World!”

1- > set foo bar
2- > get foo
3- > lpush myList world!
4- > lpush myList Hello
5- > lpop myList
6- > lpop myList

In line 1, we set the key name “foo” to the value “bar”

In line 2, we get the value for the key name “foo” so the return value is “bar”

In line 3, we (left) push the value “world!” to the list “myList”

In line 4, we (left) push the value “Hello” to the list “myList”

In line 5, we (left) pop the value from “myList” and the return value is “Hello”

In line 6, we (left) pop the value from “myList” and the return value is “world!”

Now, you get the idea how Redis works, so lets do one real project in Python and Redis.

Can I see Redis in real project?

Yes, In this project I want to design a program that get the RSS from source, then parse the RSS and send the title of each news to Twitter.

What you need to do before start to code?

0- Python 2.5 or higher

1- Redis and py-redis

2- Twitter python library (included in package)

3- Yahoo social python

Next:    Enter the following code in your favorite text editor and save the file.

import redis,twitter
import yahoo.yql

def getandset():
	''' Get the weather condition for WOID=12778445 and save in the database'''

	q = yahoo.yql.YQLQuery().execute('select * from rss where url="http://weather.yahooapis.com/forecastrss?w=12778445"')
	temp = q["query"]["results"]["item"]["condition"]["temp"]
	text = q["query"]["results"]["item"]["condition"]["text"]
	date = q["query"]["results"]["item"]["condition"]["date"]
	#forecast
	high = q["query"]["results"]["item"]["forecast"][0]['high']
	low  = q["query"]["results"]["item"]["forecast"][0]['low']

	r = redis.Redis('localhost')
	r.set('weather:current:temp', temp)
	r.set('weather:current:cond', text.lower())
	r.set('weather:tomorrow:high', high)
	r.set('weather:tomorrow:low', low)

def post():
	API = twitter.Api(username = "YOUR TWITTER USERNAME", password = 'YOUR TWITTER PASSWORD')
	r = redis.Redis('localhost')
	temp = r.get('weather:current:temp')
	cond = r.get('weather:current:cond')
	tom_high = r.get('weather:tomorrow:high')
	tom_low = r.get('weather:tomorrow:low')
	if (temp or cond or tom_high or tom_low):
	tweet = 'Currently %s F and %s at %s. Tomorrow: high %s F, low: %s F'
	name = 'West Lafayette'
	tweet = tweet % (temp, cond, name, tom_high, tom_low)
	print tweet
	print "Posting...."
	API.PostUpdate(tweet)
	print "Done!"

if __name__ == '__main__':
getandset()
post()

Summery of code:
In this code we first use YQL (the service form Yahoo!) to get the RSS (in this example we get the weather condition for West Lafayette, IN)
Then we parse the RSS to get our desired field which is basically temperatures and forecast. After that we save these values to our database using ‘SET’ function. Please make attention to the key name style I use “‘weather:current:temp’” which is basically tell you in this key we want to have the today’s temperature. In the post function, I basically retrieve the value we inserted to database and post it to your Twitter account.
You can download the source code for this tutorial from here.
Now that you should learnt the SET data structure, next time I will explain LIST which is one of the most important structure in Redis.
Further Reading:

Extract Abstracts from PubMed

I’m in the research group that we want to extract protein-protein interaction by using partial matching. After a while we found we need some article’s abstracts from  National Center for Biotechnology Information by using PUBMED ID. Here is my program to get articles from NCBI, extract abstract section and save abstract part into new file name by PUBMED ID.

import urllib2
import re
import os
from BeautifulSoup import BeautifulSoup

DIRECTORY = "abstractFiles"
try:
        os.mkdir(DIRECTORY)

except OSError:
        print "the directory %s is already exist" %DIRECTORY

f=open('output-1.txt', 'r')

tickers = []
for line in f:
        tickers.append(line[13:21])

os.chdir(DIRECTORY)
for t in tickers:
        try:

                rows=urllib2.urlopen( \
                'http://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed&cmd=search&term=%s' \
                %t).read()

                soup = BeautifulSoup(rows)
                abs = soup.findAll('p',attrs={'class' : re.compile("abstract")})

                ab = str(abs[0])
                ab = ab[20:]

                ab = ab.replace('</p>','')
                t = open(t+'.txt','w')

                t.write(ab)
                t.close()

        except IOError:

                errors = [t]
                errf = open('bad_trickers.txt','w+')

                errf.write(str(errors))
                errf.close()

                print errors
f.close()

Note: This program is written in Python. To run this program you will need an external library named BeautifulSoup.

Click here to download the source code.

Artificial Intelligence

Finally this semester I got AI. I always like to be involve much and much in AI world, and now I feel AI and ML are my final goal. I would spend all my spare time to study more and more AI. I found some useful links for everyone interested too.

Digvan.Com!

Finally, after several month I updated my personal homepage. In this version I use jQuery as my AJAX framework. About jQuery, I should say it’s amazing easy to learn and work with. In my homepage I will keep my resume and portfolio up to date. Also I will add my pictures in photo section. Another intersting feature I added last night is “Latest Status” in footer. Now, I can update my latest status from my iPhone anytime, anywhere. It would be cool to review my status after 20 years!