Sublime CodeIntel Configuration for virtualenv

If you are using Sublime Text 2, Sublime CodeIntel is a must have plugin. It provides code intelligence for languages ranging from Python to Javascript with features like code autocomplete and jump to symbol definition.

Working with virtualenv

It supports Python default installation out of the box but if you are working with virtualenv, then you will need to manually configure CodeIntel to pick up your virtual environment.

Configuration files are located at ~/.codeintel/config or project_root/.codeintel/config (you might need to create this yourself). Change the config file like so:

{
    "Python": {
        "python": '~/.virtualenvs/your_env/bin/python',
        "pythonExtraPaths": ['~/.virtualenvs/your_env/lib/python2.6/site-packages',
        ]
    },
}
view raw config This Gist brought to you by GitHub.

The example above is based on my virtualenv setup, yours might be different. So, please change accordingly.

Managing Django Static Files on Heroku

Deploying and running Django apps on Heroku is really a no-brainer, except for one thing — serving static files via collectstatic.

I run collectstatic as usual, using heroku run command just like how I did it for syncdb. It worked but I’m getting 404 error when serving static files.

It turns out that running collectstatic via heroku run spins up a new dyno and collectstatic is running in an isolated environment. So, all the collected static files are deployed to that location and only for this new dyno and the dyno attached to our Django app can’t access that. — Heroku support staff

Solution

The dead simple solution would be to run collectstatic as part of the Procfile before starting the app. We need to “chain” together our Procfile commands for the web process, like so:

web: python my_django_app/manage.py collectstatic --noinput; bin/gunicorn_django --workers=4 --bind=0.0.0.0:$PORT my_django_app/settings.py
view raw Procfile This Gist brought to you by GitHub.

OK there you go, no more 404 error when serving static files from your Django app on Heroku. Plus, every time you deploy your app, newly added static files will be collected automatically.

Update

There are a lot of questions about the configurations. Cross check with my settings.py here http://pastebin.com/H43gRKsJ

Important thing here is your STATICFILES_DIRS. Make sure to include your project_name/app_name/static here. In my case, I have project_name/staticfiles for the STATIC_ROOT. Change STATIC_URL = ‘/static/’ if you want to serve from Heroku, same goes to ADMIN_MEDIA_PREFIX = ‘/static/admin/’

Finally add this to your urls.py in order to serve from Heroku.

urlpatterns += patterns(”,
(r’^static/(?P.*)$’, ‘django.views.static.serve’, {‘document_root’: settings.STATIC_ROOT}),
)

Files could be access as such:

/app/project_name/staticfiles/style.css > http://flaming-fire-999.herokuapp.com/static/style.css

/app/lib/python2.7/site-packages/django/contrib/admin/media/css/login.css > http://flaming-fire-999.herokuapp.com/static/admin/css/login.css
Please note that this is not the best way to serve static files but it works. One last thing, you still need to go through all these things if you are using django storages and django compressor to serve static files via Amazon S3 because django compressor needs a temp file system cache on Heroku.

Start-Up Chile: Want to Make The Cut? Here Are Some Advice

The 3rd and final round of Start-Up Chile 2011 application is now open. If your startup is still in “alpha/beta” mode, you are highly encouraged to apply (even your startup is not, do apply). My startup, Flvrd (still in beta mode) was one of 154 startups around that get selected in the previous round.

If you are applying or think to apply, one of the questions that usually goes through your mind is: “Is it hard to get into Start-Up Chile?

Well, honestly I don’t think it is hard based on Flvrd’s application but it is getting tougher from round to round because more and more startups are applying. FYI, Round 1 (329 applications, 110 startups selected) and Round 2 (650+ applications, 154 startups selected).

But there are a few important areas that I think you need to really focus on. So lets go through those (together with my personal advice) by looking into the judging criteria.

  1. Human Capital (weight: 33%): quality of the talent and commitment of the founding team members.
  2. Project (weight: 34% – composite): Strategy, differentiation, and innovation factors of the product/service purported:
    • Product/Service (weight: 17%)
    • Market (weight: 17%)
  3. Environment (weight: 33%): Value of the founding team’s networks for the Chilean entrepreneurship ecosystem.

Human Capital

They are looking for an awesome team. All startup incubators are looking for the best team and not the best idea. So make sure you have an awesome team — good chemistry, work well together, complementary skill sets and some impressive stats about the team members.

In brief, the Flvrd Team: Flvrd has two co-founders (Koekoe and I) with complementary skill sets. We have known each other for more than 3 years and we work together on projects and group assignments during our time in university. We have also participated and won in a number of international tech and entrepreneurship competitions while in university. Bonus: we are a couple.

How about a single founder? Well, to my knowledge there are a number of single founder startups that got accepted. So if you are alone, your Start-Up Chile dream is not dead, never. There are other factors which are more important than this. So don’t worry.

Project

This is all about your idea/product and they are looking for globally scalable ideas/products. If your idea is super local and could not be replicated in other countries, you might want to rethink your idea.

I don’t know how well Flvrd scores under this section but if you don’t have a world changing idea/product — I don’t think this will put you in a disadvantaged position. FYI, Flvrd is neither a world changing idea nor follows the blue ocean strategy. We just do things differently.

But It is important to have a working prototype. It shows your commitment and also your execution. Remember the popular saying? “An idea is nothing without execution”. So having a real product where you and your team have been working on for some time is a huge plus.

A pitch video is also important in the case where the judges didn’t get the picture of what you are doing, a KISS video will help you explain your idea/product. FYI, we spent more than a week working on the pitch video but well worth it.

You are also required to answer questions related to your startup’s execution and business plan. So, make sure you know what you are doing, what is your plan, the market, competitors, etc. You have to do some basic research to answer these questions well — don’t assume!

Side note: The best way to keep up with your market and competitors is to follow tech and startup blogs like TechCrunch, Mashable, ReadWriteWeb, The Next Web, VentureBeat, etc.

Environment

This is where they want to know how you can contribute to the Chilean entrepreneurship ecosystem by leveraging on your skills, experiences and your networks. So, it is good to have an established network back home so that you can link them to Start-Up Chile and Chilean entrepreneurship culture/ecosystem as a whole.

Bonus: Make your application stands out and the best way to do it is through video.

So, there you go some tips and advice for startups applying for Start-Up Chile. Feel free to ping me if you have any questions.

Reminder: You have until October 27th 2011 to make the cut. Act now!

Hello WordPress, Bye Posterous

I’ve been switching back and forth between various blogging platforms  — WordPress, Tumblr and Posterous. If my memory serves me right, I started off with WordPress, then Tumblr, and back to WordPress before ended up with Posterous. Now, I’m back on WordPress.

Past few months, I’m contemplating a move from Posterous for two reasons — speed and flexibility.

  • Speed — Posterous is slow, and getting slower after they roll out Posterous Spaces. Back in the early days when I started using Posterous, loading my blog and the blog management pages is pretty fast but now, speed bump everywhere. Try search for posterous is slow on Google.
  • Flexibility — Posterous’ simplicity is great, but because of that it’s not very flexible. You can’t embed Javascript snippets and do much modification besides the look and feel. Those like me who want more control, a self-hosted WordPress is a better choice.

So, it’s time to switch back to a self-hosted WordPress blog and here I am. Now I’ve total control over every aspect of my blog from the speed to the look and feel. If you are wondering how I migrate from Posterous to a self-hosted WordPress, check out this post by Antonio Cangiano.

Flvrd Joining Start-Up Chile

Woot! Flvrd (my first real startup project) will be joining Start-Up Chile with 153 other startups from around the world. You can read the official announcement here and Flvrd’s own blog post.

I’m ecstatic. I started Flvrd as a personal project while learning Python/Django. Then, it became a startup project when I decided to make it public. Now with the help of Start-Up Chile, I can make it my real startup sooner than later.

This is a once-in-a-lifetime opportunity and the stepping stone to my life-long entrepreneurship journey. I finally get to experience what entrepreneurs call “the startup culture”. I’m looking forward to meet the other participants from all around the world and those dedicated people behind Start-Up Chile.

See you!

Django “Global” Template Variable

Depending on the project you are working on, you might want to access one or more template variables across all your templates like the User object. If you are making news or blog project, one example would be navigation bar item, say a category list.

You might be tempted to pass the category list from your views or create a template tag for that; but that just violate the Django’s DRY principle. So the best way would be through custom context processor. Writing your own is actually very easy.

1. Writing the context processor function.

You can put this function anywhere in your project. My preference is to place this code inside a context_processors.py file under the related app.

# The context processor function
def categories(request):
    all_categories = Category.objects.all()

    return {
        'categories': all_categories,
    }

Note: Each context processor must return a dictionary and takes only one arguement, HttpRequest object.

2. Point it to your TEMPLATE_CONTEXT_PROCESSORS in your settings.py file.

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.request",
    # ...
    "yourapp.context_processors.categories"
)
view raw settings.py This Gist brought to you by GitHub.

Now categories is available for use in all your templates.

Done!

Flvrd and What I’ve Learned

Flvrd, a project I’ve been working with @koekoecrunch for the last four months has finally launched on May 18, 2011, about a week ago. You can read the launch announcement here. Have been fixing bugs and pushing updates for the past week, so a little delay here. Anyway…

Some History

Before Flvrd, I’ve been poking around with two projects — a casual Facebook game (codename Traveloot) and a location-based looting/scavenging mobile game (codename Lootpop). I abandoned Traveloot because at that time, the Facebook apps platform is very buggy. So I pivoted the concept (of looting “virtual” items) to Lootpop. While working on Lootpop I learned a decent amount of Objective-C and iOS programming but what makes me abandon this project is because it’s a little too much to take for a person who is learning new stuff. My takeaway here is, if you are learning new stuff (programming languages), work on something that is simple and interest you, period.

Back to Flvrd

So, I had this idea… jump straight in and start coding (Why? See my bottom line). The idea of Flvrd has been “refreshed” and simplified several times during the development period. The original concept was about expressing comments without the need of words. You use “flavors” to express your thoughts (what I try to solve is to reduce comments that are rubbish and spam). So, long story short, Flvrd is now what it is — flavoring pictures or videos with flavors using flavicons. Simple yet fun.

What I’ve Learned

After four months of hacking and hustling…

  • Learned Django (and Python) and some Javascript + JQuery.
  • Level up my CSS.
  • Learned and relearn sysadmin stuff (setting up servers, config, etc)
  • Launched a real project/product to the World.
  • Starting a web startup is NOT easy BUT cheap (and I’ve nothing to lose, just my time)

Bottom Line…

So entrepreneur wannabe, if you have an idea, just do it and start hacking! Stop worrying whether your is good or bad, whether there is a market for it or whether the world will use it or not. You can spend time all you want finding the perfect market, writing a 100+ pages of business plan or validating your idea so it could be the next Google or Facebook. BUT, the only thing that matter is your product or prototype. Why? Because you are nobody and just a wannabe. People don’t give a damn about your idea or your sugar coated, well crafted business plan unless you are somebody. Really… seriously. So, don’t waste time worrying, spend time working on it. Need more motivation? Read this.

BTW, you… get flvrd now.

Announcing: Fryday App

Today, I’m happy and proud to announce the launch of Fryday an experimental project by @koekoecrunch and me, @matthewphiong.

Fryday What?

Fryday Logo

Fryday is a web app that let you express your anger, frustration, hatred, outrage or whatever negative on Friday. Yes, just on Friday. It allows you to post your messages, pictures, videos or voice screams securely (secured with bank-level data encryption). You’ll be able to share with your friends, your selected friends and have a good laugh about it.

One common use of Fryday is to take a picture of your boss, doodle on it (uhmm… like “Stop throwing me work you bitch! It’s Friday, Friday, gotta get lost on Friday”) to release your anger and then upload it to Fryday. You can select which friends to share with and have a LMFAO!

Why Fryday?

As we all know, Friday is the most tense and frustrating day of the week. This very day that is all about work, work and work and deadline, deadline and deadline. When we are all excited and planning our weekend, Friday will come and spoil it. So, we really can’t stand Friday and because of that we really want to FRY it! Hence Fryday was born.

Oh BTW, Fryday (the name) is highly inspired by Rebecca Black’s Friday. Thanks Rebecca! We ♥ your Friday.

Fryday FYI

We have been working on this on and off for more than 6 months now. Here are some unbelievable and shocking stats (even we are shocked!)

  • 1000 litres of sweat drained.
  • 100 kilograms of caffeine consumed.
  • 500 SMS sent.
  • 250 papers wasted.
  • 25 Fridays wasted.
  • 500 kilograms of chocolate strawberry cakes consumed.
  • And most recently… 100 hours of Rebecca Black’s Friday!

Excuse us if Fryday is not as good as it sounds or hyped. FYI I’m learning Django and Koekoe is learning Illustrator while building this app, we are still very noob. We hope this app will make you feel as good as having a delicious chocolate strawberry cake on Friday. Anyway, we hope you don’t hate it :)

P.S. Happy 1st of April :)

KTHXBAI,
matt & koekoe
ireallyhatefriday@gmail.com

Price War: Linode vs Slicehost vs Amazon EC2 vs Rackspace Cloud Servers

Updated: New AWS pricing (Effective 1 July 2011)

It’s time for a war again, price war that is. So what is the real price per month between the four most popular cloud/VPS hosting providers?

Again, the contenders are:

I’m currently hosting a few blogs and websites on a Linode 512 plan (512MB RAM). The incoming and outgoing bandwidth are approx. 100GB and 50GB respectively/month. So I’ll use these data in the calculation for EC2 and Cloud Servers and assumes 730 hours of service/month.

So, The Winner Is…

For Linode and Slicehost, the price is fixed with preallocated storage and transfer.

Linode 512 Plan

  • RAM: 512MB
  • Storage: 20GB
  • Transfer: 200GB (Both In & Out)

Price/month: $19.95

Slicehost 512 Slice

  • RAM: 512MB
  • Storage: 20GB
  • Transfer: 300GB (Both In & Out)

Price/month: $38

Amazon EC2 Micro Instance

Price varies between regions, we’ll use the cheapest one.

  • Instance/hour: $0.02
  • RAM: 613MB
  • Storage: EBS storage only ($0.10/GB), say we use 20GB
  • Transfer: In ($0.10/GB), Out ($0.15/GB)
  • Transfer: In ($0.00/GB), Out ($0.12/GB)*

Instance/month: $14.60
Storage/month: $2.00
Transfer (In)/month: $5 $0*
Transfer (Out)/month: $15 $12*

Price/month: $36.60 $28.60*

*New Pricing as of 1 July 2011

Rackspace Cloud Servers

  • Instance/hour: $0.03
  • RAM: 512MB
  • Storage: 20GB
  • Transfer: In ($0.08/GB), Out ($0.18/GB)

Instance/month: $21.90
Storage/month: -
Transfer (In)/month: $4
Transfer (Out)/month: $18

Price/month: $43.90

So, we have an obvious winner here: Linode*. For roughly the same amount of resources (RAM, storage and transfer), Linode is almost 50% cheaper than Slicehost and EC2 (See update below). Rackspace Cloud Servers top the list with $43.90, that is 2x more (the cost of the instance alone is already $21.90) than what I currently pay for Linode.

Update: Even with the new EC2 pricing (old: $36.60, new: $28.60), Linode* is still $9 cheaper than EC2.

Conclusion

As noted here, go for cloud if you want to run your stuff for a short period of time (few hours or days), CPU intensive stuff or web apps that have unpredictable load and need to scale up and down easily and quickly. If you want to host a blog or website (long term) go for VPS. I would recommend Linode* over the rest. It’s really hard to argue when comes to price/resources. It’s simply the best bang for the buck.

*Note: My referral link. Signup using my link if you think this post is useful, I would appreciate the referral. Otherwise, just hit linode.com in your address bar.

Looking Back at 2010

2 days past 2011 and I think it’s time for me to reflect back on 2010 and looking forward for another 363 days in 2011.

2010

2010 has been a wonderful year but with very less result to show. I started off 2010 with a “money can’t buy” internship at Microsoft Research India. Exactly today (3rd Jan) but in 2010. I came back on 29 March and spend the rest of 2010 pretty much on hacking (not this hacking but this) and learning. More on learning and less on hacking… so, a lot of input but a little output.

In between, I’ve got the chance to meet and pitch to Steve Ballmer and I’ve competed (last competition for me as a student) in PolyU Global Student Challange 2010 in Hong Kong.

Personally… I’ve been learning Python (Django) and Objective-C (iOS) and hacking around a location based game project. Initially, I was working on a Facebook game, but I’ve put it on hold indefinitely and switched to iOS (iPhone). You can still check out the landing page: playtraveloot.com. For this who have subscribed as beta tester… sorry :(

2011

No fancy resolution but it will be a “lot of hacking and less of learning” year for me. I’m looking forward to release my first app called Lootpop!