Jordan Has a Blog

I’m Calling Myself Out

Last night while I was in the car with my roommate, I was discussing how if I had just kept up with a few projects that I had started in the past, I’d probably have some mild success and traction with at least one of them by now. I just finished up Rework by 37signals and I think I got the most out of the very last page of the book from the essay about Inspiration. Inspiration is perishable, when you have it you work your ass off nonstop until you literally can’t work anymore. It’s an amazing feeling and such a high to be working on something that you truly believe can change the world. As my roommate says, it’s 20 hours of work for 10 minutes of fun and that’s what all my past projects have seemed to end as, only 10 minutes of fun.

So I realized the problem is that once the inspiration goes away, and it always seems to run out at some point, I end with this ‘meh’ feeling and things just aren’t as fun as they used to be. It sucks to admit this happens, and I’m writing this blog post to help myself from making lies in believing that I’m still pumped about things I’ve started earlier and convincing myself that I’m just too busy at the moment to put time into it. Instead, I need to just suck it up and get back to work on things that I’ve started until they’re finished. If I was excited enough at one point to put so much work into it, I might as well complete it and stick to it so that it at least has a shot. My goal with any project of mine is to just have people use it and appreciate it, not to make millions and cash out quick. So quitting is obviously the worst thing I can do, but also the easiest thing to do because I can always make excuses as to why it would never have worked anyway.

Some of the past projects I’ve quit include a web app directory in 2007 that I didn’t see a market for after it was all built and complete. It was also designed terribly, code wise, so changes took far too long, never try to roll your own framework if you really don’t know what you’re doing. Now I see about 5 or 6 clones that all have a decent user base and I think how that could have been me.

I also had a podcast with two friends that was running for about a month back in 2008. We had about 10 listeners by episode 5 but since we were expecting overnight success, and didn’t get it, we decided that we just didn’t have the time to continue working on it.

Finally, I created a Craigslist alert app which, after spamming twitter quite a bit, ended up with about 100 happy users. I saw some opportunity to make it even better so I started from scratch and started developing what I would describe now as Notifo + Twilio + other cool features. Neither of these services existed at the time, and I had a family friend who is an amazing web designer on board for equity to help out. I had some personal issues that set me back about 6 months and by the time I came around I saw too many competitors in the space and decided to stop development and not even give it a shot.

After thinking last night about all these things, I ended up being a little disappointed with myself, so here I am writing a blog post to make sure I never make these mistakes again. The point of me telling you? I’m hoping you keep me in check. If I say I have a project to share with you, hound me until I actually release it.

Django - Allow Users to Log in Using Email Rather Than Username

One of the annoying things about Django is that it doesn’t allow logins via email out of the box if you’re using their built-in user authentication . You must create your own authentication backend in order to accomplish this. However, one of the things I love about Django is the ability to create authentication backends without too much of a headache. This comes in handy when dealing with things like allowing users to log in via Twitter, Facebook Connect, any OpenID providers, or allowing them to login via email and password.

Django authentication backends are quite simple, essentially whenever you call the django.contrib.auth.authenticate() function, Django uses the authenticate method in any of the classes specified by the AUTHENTICATION_BACKENDS tuple set in your settings.py. If one of the classes fails to authenticate the user, Django moves on to the next one until either one successfully returns a user object or there are no other backends to attempt, in which case it results in a failed login. A very simple authentication backend which allows users to login via email rather than username is the following code in backends.py:

backends.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from django.conf import settings
from django.contrib.auth.models import User

class EmailModelBackend(object):
    def authenticate(self, username=None, password=None):
        try:
            user = User.objects.get(email=username)
            if user.check_password(password):
                return user
        except User.DoesNotExist:
            return None

    def get_user(self, user_id):
        try:
            return User.objects.get(pk=user_id)
        except User.DoesNotExist:
            return None

And you simply need to add to your settings.py:

settings.py
1
2
3
4
AUTHENTICATION_BACKENDS = (
    'path.to.this.backends.EmailModelBackend',
    'django.contrib.auth.backends.ModelBackend',
)

I generally place my backends in whatever app I create to store extra user info, but you can put it anywhere, just make sure it’s in your PYTHONPATH.

Django 1.2 - CSRF Verification Failed. Request Aborted.

I was getting this 403 error today while attempting to make a POST request to a view:

403 Forbidden

CSRF verification failed. Request aborted.

Help Reason given for failure:

CSRF cookie not set.

Edit 10/29/2010 I’ve modified this post to only contain the proper way of resolving the issue. You can read about Cross Site Request Forgeries here and Django’s protection mechanisms here

To resolve the 403 issue, you want to add the csrf_token template tag within your form somewhere. This adds a hidden div with the value of the input as the csrf token:

anything.html
1
2
3
4
<form action="..." method="POST">
    {% csrf_token %}
    ...
</form>

If you’d like to not protect against CSRF with Django’s built in mechanisms, use the csrf_exempt decorator:

views.py
1
2
3
4
5
from django.views.decorators.csrf import csrf_exempt
...
@csrf_exempt
def my_func(request):
    ...

Illegal Streaming

I was faced with a problem last Sunday, like many football fans usually are, of not being able to watch the game that I really care about. Rather, I have to watch what the CBS and Fox stations in my area decide are the games that appeal to the general mass of viewers. The thing I find crazy is the fact that the NFL fails to please their entire viewership by not leveraging the Internet when it comes to sports. But when it comes to television shows, the broadcasting companies are finally understanding how to please people. Look at the success there has been with streaming shows directly from the broadcaster’s websites, streaming the shows right from Hulu, and all the other means of show streaming that are legal now. Why haven’t more content providers done this for sports? I know ESPN has ESPN360, but this doesn’t provide every game that ESPN plays on television, and it is also only available for people using an ISP that has signed up for it. So ESPN is ALMOST there, but not quite. As I sit here watching one football game that is being streamed illegally on Justin.tv, and watching another one simultaneously on television, I realized I’m exposed to twice as many advertisements. The illegal stream is doing more good for the broadcasting company than bad. I find it crazy that the NFL wouldn’t cut a deal with Fox and CBS to allow the games to be streamed legally. I’m not the most business savvy person by any means, but I feel like less than 1% of NFL fans will buy an NFL package from their cable provider that allows them to watch any game they want, while over 30% (literarlly making percentages up) would watch a game streaming legally on cbs.com. Since it’s all about money (although it should be about caring for the fans that really make the NFL the sport it is) you tell me which deal would be more profitable for the NFL? I know there are many aspects of the business I’m completely ignorant to, and there are probably plenty of reasons why this isn’t possible, but considering it’s 2009 and they are losing money from illegal streaming, they might as well make everyone happy and make some money at the same time. I’m going to get back to watching my illegal stream, where everyone is benefiting BUT the NFL.

OLPC Project Could Help More Than Just the Children

According to stats posted by the Miniwatts Marketing Group and the annual Failed State Index, it appears that the OLPC project could help more than just the unprivileged children who receive laptops.

The Failed State Index gives each country a score off 1-10 based on 12 indicators. The higher the index score, the more unstable the country is. Comparing the index score to the penetration rate of internet usage based on population yields interesting results:

One potential argument could be that the states(countries) with low index scores are most likely states with poor economies, which would obviously effect the number of people who could even afford internet in the first place.

To test if the trend of increasing stability exists when countries with similar economies are compared, a similar chart is created using countries with I-5 indicator scores below 6. This indicator of the Failed State Index gives a score based on uneven economic development along group lines.

By comparing countries only with economies promising enough to sustain the costs of the infrastructures needed for internet, we get a better picture of how the internet truly effects ones stability.

As we can see, the upward trend still exists with countries with similar economies. Efforts by groups like the OLPC Association could end up affecting more than just the children the project aspired to help in the first place. Maybe some foreign aid should go towards building the infrastructures needed to get these failing states wired so they can stop relying on their corrupt or incapable governments and help solve critical issues themselves.

Besides, our foreign aid policy has proven not to work well in the first place, so we might as well try something new. I’m aware by simply wiring a country and allowing the citizens to have access to computers and the Internet isn’t going to magically increase their stability, but it would definitely help them in so many ways. Just think how much these technologies help us everyday and where we’d be without them. To say that this couldn’t help a failing state pick itself off the ground would be absurd.

All data used for this can be seen here

We Forgot to Pay the Power Bill…

My friend’s power got turned off because he lost the game of “Let’s see how long I can wait to pay bills,” so he came to my room because he really needed wanted to play some GTA IV. This was the only place we could squeeze him in.