Categories
Other

My History of Failure

“I’ve failed over and over and over again in my life, and that is why I succeed.”

This is my third attempt.  I’ve tried twice before and failed, but this time could be different.  It could end up in failure just like the others, but I don’t think it will.  I’m smarter this time around.  I’ve learned from my mistakes, am better at what I do, and I have more to lose.

Encode4Free

The first time around was in 2007.  I had just learned PHP and thought I had what it took to make a video encoding startup.  This was before the term “cloud” was popular, and my idea was that users would upload videos to my service, encode them into whatever format they liked, and then re-download them.  For revenue, I thought that a free service could be done by adding advertising to the beginning of the encoded video.  Or, a user could pay small fee to get moved to the front of the queue and have no advertisements.

The idea seemed good, but I wasn’t dedicated to it.  I got a design going and had the back-end encoding stuff working, but I just couldn’t act on it.  Some other things went wrong too.

  • No motivation – I was still in college, didn’t need the money, and enjoyed my life just where it was.  There wasn’t really a huge motivation for me to do this.
  • No passion – I honestly didn’t care about video encoding.  Sure it’s cool, but only cool from a technical standpoint.  It wasn’t something I could really get behind.
  • Knowledge – I really had no idea how deep the programming rabbit hole went at this point.  Not knowing what good design was really put a cramp in how fast I could develop too.  In short, I was inexperienced and it showed.
  • Flawed business model – In retrospect, this should have been a freemium model.  10 minute video for free, anything over is charged.  That way people don’t get annoying advertisements added to their videos.

Should I Get The Book?

In 2008 and early 2009 I worked on “Should I Get The Book?”(SIGTB).  As a grad student reflecting on my undergraduate years, I realized that I spent a ridiculous amount of money on books that I never needed.  After talking to friends and classmates, it seemed this was a universal problem, and my startup idea was born.  This time, I did things right (sort of).  I took a few hours every week over the the summer and started hacking away at it.  By the end of the summer, I had a functioning product.  I did a launch, and the waited.  But nobody came.

So what happened?  Was it competition?  Was it a poor idea?  Well, it was a lot of things.

  • Design – This is huge.  My site design sucked.  I basically ripped off a WordPress template that somebody made because it looked cool.  It had nothing to do with my idea, and it showed.  People coming to the page would say “So what is this about?”.
  • UI – The interface and experience was awful.  None of it made sense, and the changes that people did suggest I back-burnered until I “had more time”.
  • Seed Data – The idea that users leave reviews about whether they needed the book or not was great, except that nobody would do it.  Without having some reviews already in there, I found that people weren’t motivated to leave a review because they thought the site wasn’t being used.  I needed to have data seeded, but I couldn’t think of a good way to do this without paying any money (I had none at the time).
  • Focus – I tried to focus on too many schools at once with the first launch.  I should have started with one to see if the concept would stick.
  • Advertising – On a college campus, flyers and word of mouth is key.  I had zero flyers and nobody talking about me.
  • Karma – Users like getting a reward for doing something.  It doesn’t have to be money, karma works just as well.  Users get to scratch their competitive urge by posting reviews, getting karma, and checking to see if they have more then their friends. I should have done this, but didn’t.
  • Evergreen data – One of the big problems with this data is that the instructor can change books, change styles, or even stop teaching.  The data can become useless quickly.

Once I realized most of these things I vowed to start a re-design with all of these issues addressed.  I was about 25% of the way through the mock-up when I was informed that RateMyProfessor.com had a similar feature.  It was easy to use, and they already had a huge user base.  My idea was basically sunk.

While SIGTB flopped, it was important step for me.  I had pushed a project through to completion, learned a lot about marketing, and learned that I really need a co-founder to talk me out of bad ideas.  Most importantly though, I proved to myself that I could accomplish something.  I might have given up too quickly, but I think that the idea wouldn’t have worked well anyways.

CampaignAlytics (Working Name)

I started this idea out in late October of this year.  The idea is that email campaign analytics can be done better.  Currently analytics is rolled in as a feature for big mailers (Mail Chimp, etc), but it doesn’t provide the in-depth analytics that a lot of marketing folks are looking for.  We’re looking to change that.  I’ve been working for an hour a day since November 1st, and have a lot to show for it.  I pitched the idea to a local pitch night, and the reception was great.  We have a lot of great features, and do it all in a non-obtrusive way that is compatible with mailing services, or can be rolled into your custom solution using our API.

I’m taking a different path with this startup, based on the things I’ve learned on the last two.

  • Pay for a design – The first thing I did for this web app was pay for a design.  I got a great deal, and now have a design that I can be proud of and shows off the product like nothing I could have ever come up with.
  • Co-Founder – Having someone to talk you out of bad ideas, and give you a sense of perspective is amazing.  Having someone to discuss ideas with and share the burden is pretty great too.
  • Funding – I’ve come to the conclusion that without a little bit of funding, this startup will take forever to complete.  We’re applying to the seed incubator Momentum and hopefully we’ll get funded.
  • Iterate – I’ve already gone through two different layouts and menu structures for the account/analytics page.  The second version is far better than the first because I asked for feedback from a few trusted people and implemented the changes right away.

The thing I hope you can take away from this is that you are going to fail many times before you succeed.  Being persistent (and maybe a bit stubborn) will take you 70% of the way there, and the rest is on how good your idea is.

Categories
PHP Programming Wordpress Development

PHP Alternative Syntax

Did you know that PHP has an alternative syntax structure?  Up until about two years ago, I didn’t either.  It wasn’t until I started poking around in the WordPress core that I saw it.  Intrigued, I popped over to PHP.net and read an entry on it.  In a nutshell, the alternative syntax can go far in making your PHP code much easier to read.  The control structures if, while, for, foreach, and switch can all be expressed in the alternative syntax form.  In general, I prefer to use the alternative syntax when mixing PHP in with HTML, and the standard syntax when writing pure PHP.

If Example

// This....
if($myString == "foo"):
    echo "bar";
else:
    echo "no-foo-bar";
endif;
 
//...is equal to this.
if($myString == "food") {
    echo "bar";
} else {
    echo "no-foo-bar";
}

ForEach Example

$names = array("bob", "tom", "john");
 
//This....
foreach($names as $name):
    echo "Your name is: {$name}";
endforeach;
 
//...is equal to this.
foreach($names as $name) {
    echo "Your name is: {$name}";
}

Resources

If you’re looking for more resources on PHP’s alternative syntax, check out the documentation here, or the WordPress source code for examples.

Categories
Other Other Programming PHP Programming

SVN Merge Example (Trunk to Branch)

I’m often in the situation where I need to merge changes from the trunk development into a branch.  I can never, EVER, remember the command, so I’m putting in here in hopes that I can reference it again and that other people might find it useful.

svn merge -r x:y svn://repositoryURL/repo/trunk/ .

So, how does it work? X is the revision that you branched at. This can also be the revision that you last merged changes from. Y is the version that you want to merge up to.  In most instances, HEAD is probably what you’re looking for.

Note:  Using –dry-run if you want to see the changes that will be made before actually doing it.  It takes some of the “this is scary” out of merging.

Categories
Other PHP Programming

Creating a Flexible Caching Module

I work for a great company, I really do.  Sure we have our problems (like just coming out of the developer stone age), but overall I work with smart, friendly people who are passionate about what they do.  One of the things that always bugged me though was the lack of any sort of caching in our CMS.  Most times it’s not needed, but when an operation takes about 100 queries or so to finish, then it’s time to start caching.

Since I’m a bit of an efficiency freak, I thought I would take a crack at writing a flexible caching module that is easy for our developers to use.  So what do “easy” and “flexible” mean?  To be “easy”, the caching module must be usable by even a novice developer and have a limited number of options.  For instance, I ended up deciding that we really only need two public methods, and one public property.

  • $cache->exists – If “$cache” is a cache object, calling exists checks to see if the cached object already exists in the database.  It also checks to see if it’s expired or not.  If it’s expired or non-existent, it returns false.   It returns true if the cached object exists and is up to date.
  • $cache->put($val) – This is how you store something in cache.  It can be any type of serializable PHP object.  So basically, resource types are off limits but objects, arrays, variables, entire web pages, etc. can be used.
  • $cache->get() – This fetches the object stored  in the cache.  It handles the re-serialization of it as well, so it really makes things pretty idiot proof.

What about flexible?  Well, by that I mean we need to be able to transparently implement several different types of caching.  Since we’re just crawling out of the dark ages, I opted to implement a fallback caching mechanism.  Here’s how it works.

  • The programmer defines a variable in our settings area to be which caching option he/she wants to use.  Options are memcached, file, mysql.
  • If the setting isn’t defined, we try memcached by default.  This is by far the best caching system to use, so it makes sense to try it first.
  • If memcached fails, we go to a database caching schema.  While not nearly as good as using memcached, it’s possible it could save you tons of queries on your database.
  • If the user chooses file caching, we do that.  It’s a pretty bad idea to use in most cases, but may still have it’s uses.

So why did it come this?  It’s not that we host terribly high-volume sites, but that our CMS is super slow.  A full-on page will take about 4 seconds to load to your screen completely, and that’s running local on the network.  One of the main problems is that we use output bufferring extensively.  The ENTIRE FRIGGIN PAGE is buffered.  This has 3 side effects:

  1. Slight performance loss due to bufferring.
  2. Apparent page load time sucks because the browser has to wait for the entire page to be generated before getting output.
  3. Development is super easy because you don’t ever have to worry about output being sent before doing a call like “header()”.

We can’t remove output buffering unfortunately.  It’s at the very core of our CMS and development practices, so it just won’t work.  To get the load time to generate the page as low as possible, I decided that caching was needed.

So what sort of problems do we run in to with this caching module?  Glad you asked!  Many of the problems aren’t specific to this caching module, but to caching in general.  The quick list:

  • If the original query wasn’t complicated, it’s not worth storing the results.  The number of queries the caching module does in MySQL mode is 3.  If your initial query was less than that, or not a super-complex-mega-join, it’s not worth using.  This caveat goes away in memcached mode.
  • Smart naming and design.  You have to be very careful out what you cache, and when.  Remember, page content and queries probably change when a user is logged in or on a different device.  Just things to keep in mind.
  • Getting developers to use it.  Not everyone likes to learn, let alone change their habits.  The biggest barrier to this is getting people to use it.  Some people don’t care about efficiency either (sad, I know), but at least our system administrator thanks me.

The caching module seems to work pretty well too.  On one particularly SQL heavy page, I reduced page load time from 14 seconds (ridiculous) to just under 6 seconds (still bad, but getting better).

That’s it for now.  Any questions or comments are welcome.

Categories
Python

Learning Django

If you’ve ever wanted to learn how to write web apps in Python + Django, I suggest checking out: http://www.djangobook.com/en/2.0/

One might automatically think to go to the main Django site, but this book is far superior.  The examples are clearer, the layout is smarter, and the writing is more concise.  Whoever writes this, good job.

Categories
Python

Choosing a Python Web Framework

If you follow this blog at all, you know that I’m a PHP programmer.  Specifically, I like to work the LAMP stack.  Lately though I’ve been getting the itch to grow my Python skills and learn a new web framework.  After some searching about on the internet, I came up with two Python web frameworks that look promising: Django and Pylons.

Django and Pylons are both Python web frameworks that encourage rapid development of web sites using the Model-View-Controller design pattern.  They both are similar, but also have enough differences to warrant some discussion before choosing one over the other.

From my research and experience, Django is good because it’s easy.  It’s easy to set up a site and the administrative interface is built up for you.  The only issues people have is that it doesn’t allow a great deal of customization, and sometimes Django hides what is going on from you.  To some people this is desirable, to others it isn’t.

People seem to like Pylons because it’s extremely flexible.  For your models you can use SQL Alchemy or some other ORM, while for your template engine you can use Mako or any other kind that you’d like.

Mainly because I like to have flexibility, I think I’ll start out with Pylons.  If you’re interested in learning more about the differences between the two frameworks check out this and this.

Categories
Other

Are we really worth 3.5 million?

A news (I use this term loosely) article recently came across TechCrunch about a Google engineer being offered $3.5 million in restricted stock to not leave for Facebook.  Now, I was alway taught to not undervalue myself, and I completely agree with that line of thought.  However, 3.5 million is ridiculous.  How many startups could you fund with that kind of money?  How many lives could be saved through research, aid, or vaccines?   How much good could be done with $3.5 million?

I understand that this may just be a rumor (it is TechCrunch after all), but it brings up a good point.  As programmers we’ve been taught that our skills are irreplaceable, but I don’t believe that.  Yes we have a hard job, and being good at what we do is even harder, but we’re not worth $3.5 million.  $100,000 for a good programmer, sure.  $500,000 for a “rock star”, maybe. But never $3.5 million.

Google is afraid of losing talent, but this seems like a knee-jerk reaction.  There will always be brilliant engineers who want to work for Google, so I say let him/her go.  Put that $3.5 million to use somewhere it can make a difference, not in the pocket of someone who likely already has a ton of cash.  Besides, if this person is leaving for Facebook, they are probably burnt out or looking for a new challenge anyways.  It happens, and no amount of money will change the fact that they are probably going to leave after their contract is up anyways.

Categories
Python

Getting Started with Google App Engine [Part 1]

For longest time I’ve done web development exclusively in PHP.  Lately however I’ve been looking for something a bit different to play with.  I already know Python (not well of course, but that’s changing), so I thought I’d look into web app development using that.  The most obvious way to develop web apps with Python is with a framework like Django or Pylons, but I was interested in scalability too.  Actually, I was interested in EASY scalability.  This is where Google App Engine and their WebApp framework steps in.

What is Google App Engine?

Google App Engine (GAE) is a platform for building highly scalable web applications on Google’s infrastructure.  So what does that mean for you?  It means you can use Python or Java to create web sites hosted on Google’s servers.  The main benefit of using GAE is scalability.  Google’s infrastructure is ridiculously huge, and having access to that means basically unlimited scalability.  You also get to access this all for free, and after you reach the free quota limits, you pay only for what you use.  For more information on quotas for the free service, click here.

Getting Started

Now that you’re interested, you probably want to try it out.  Before you can do that though, you need to create a GAE account and download the development environment.  Development environments are available for Windows, Mac, and Linux.  Setting up the environment is fairly straight forward, and all directions from this point forward should work for you regardless of your platform.  More information about setting up the development environment is available here.

A Simple “Hello World”

Keeping with the spirit of programmers everywhere, I’m going to start off with a simple “Hello World” program.  The first thing you need to do is create a directory called helloworld in the GAE directory.  After that, create 2 files in the new directory called helloworld.py and app.yaml.  Add the following to those files.

helloworld.py

print 'Content-Type: text/html'
print ''
print 'Hello world!'

app.yaml

application: helloworld
version: 1
runtime: python
api_version: 1
 
handlers:
-	url: /.*
	script: helloworld.py

So let’s explain things a bit.  The first file helloworld.py, is straight forward.  The first line sets the content type to HTML, prints a new line, and then prints “Hello world!”.  The second file app.yaml, is a little more complicated.  Here’s the breakdown:

  • application – The name of the folder containing the application.
  • version – The version of the app you plan to upload to GAE.  Increment this every time you are going to upload to GAE and it will keep track of your different versions.
  • runtime – This is the language you are writing the app in.  Python is what we’re using, but Java (lowercase) is also an option.
  • api_version – The GAE api version that we are using.  1 is usually a good choice here.
  • handlers – This essentially maps the url path to a python file.  Once you start the web server, by going to any URL you will be routed through the helloworld.py script.  If you wanted http://localhost/hello to go through helloworld.py, the you would change “url” to “/hello”.

Once those files are in place, running the app is easy.  Let’s assume that the helloworld script is in a directory called helloworld within my Google App Engine directory.  With that assumption, you run:

google_appengine/dev_appserver.py helloworld/

Next Time…

In the next part of this series, I’ll talk about getting started with submitting forms, storing information in the data store, and using templates.