Two good videos regarding startups

Just for my own sanity/memory here are two videos I think are worth watching as an entrepreneur/person involved in startups.

Fred Wilson on how to be your own boss (goes from lifestyle businesses up to venture-backed businesses)

Fred Wilson: 10 Ways to Be Your Own Boss from 99% on Vimeo.

 

Mark Suster on funding in the frothy market ("When the H'ordeurve tray comes around, take two")

7th Founder Showcase - Mark Suster Keynote from Founder Institute on Vimeo.

 

 

The Suster video is pretty long, but if you have the time watch it. If you don't... wait until you do have time, then watch it.

Tutorial Quickie: Get client IP Addresses using Nginx and Django

So this is going to be pretty quick - I just wanted to note this down since it was really frustrating to figure out. I also want to caution that the way I did this, is not necessarily the only/best way but it worked for me.

That being said I have Django set up, with Nginx, using FastCGI. If you don't have this set up, then these things might not work for you.

So there are typically two HTTP headers that will tell you what your client IP is: REMOTE_ADDR and X_FORWARDED_FOR. To be honest, I'm not exactly sure what the difference is, but I think they are really the same and the difference is that some servers provide one in the header and others provide the other...but either way, I'll show you how to get both.

So you'll have to get into your virtual server configuration file and for me the filepath is this: /etc/nginx/sites-available/mysite.com. You'll have to go ahead and add the following lines to your FastCGI configuration like so:

And so now you'll get both the REMOTE_ADDR and X_FORWARDED_FOR headers to read in.

Then to capture that, you'll have to do the following in your Django view:

And done.

For reference on some other header variables nginx lets you pass look here: http://wiki.nginx.org/HttpProxyModule
And here is where I found out how to do this: http://stackoverflow.com/questions/1627901/remote-addr-not-getting-sent-to-django-using-nginx-tornado 

More Nginx configuration solutions

I'm mostly putting these up here so that I can remember them...

But for those of you who are getting your (free) SSL certificates from Comodo, I found this link that tells you how/what to concatenate your .crt files into for Nginx: http://forum.nginx.org/read.php?11,125477

And here is a server configuration file for Nginx that I was able to use to figure out how to properly serve my static files: https://code.djangoproject.com/wiki/ServerArrangements

Just got our site working with Nginx (was using Apache)!

Thanks a lot to the tutorial here:

http://www.dmclaughlin.com/2008/11/03/complete-guide-to-deploying-django-on-ubuntu-with-nginx-fastcgi-and-mysql/

We were currently running Apache (which btw took years to configure...) and I just spun up an EC2 instance and got our site deployed on it using Nginx super quickly! Will maybe write more details on this later but that tutorial really guided me step-by-step and worked perfectly...

Now I have to go through my old SSL tutorial and set that up. Overall though...feelin like a baus.

Tutorial: A Slick Way to SSH into your AWS EC2 Instance [Ubuntu/Cygwin]

So I found out there are some tricks to both getting SSH into your ec2 instance to work, as well as getting it to work in a slick manner. My goal is for you to be able to simply type:

aws_ssh

into your terminal, and for that to magically work! Only the first two steps are really relevant in getting it all working, but the next few make it slick and AWSome...

Here's what I'm going to show you:

  1. Set up proper permissions on your .pem file
  2. Test SSH in Terminal
  3. Make an executable file to SSH
  4. Create a shortcut to that SSH

SET UP PROPER PERMISSIONS ON YOUR .PEM FILE

So the way AWS sets it up is that if you try to SSH into your instance with a badly permissioned key (.pem) file then it will send some message like "ZOMG we need your key to be more secure, permission denied, public key" (btw that was totally paraphrased). But anyways, what you need to do is simply change permissions on the file to something a little more secure (like owner read-only) and AWS will be a little less temperamental.

sudo chmod 600 /path/to/key.pem

BOOM. Now that should be it for that.

 

TEST SSH IN TERMINAL

This is just a basic test to make sure that your .pem file is up-to-par now and everything is working. So go ahead and try this out:

ssh -i /path/to/key.pem ubuntu@your.aws.public.dns

This should work! If it does sir/ma'am then proceed. If not, it may be one of a few things.

  • Double-check your ec2 public dns is right, for some reason Amazon has changed mine up once or twice...
  • Make sure you typed ubuntu@ in front of your DNS if you're using an ubuntu instance. I believe that a CentOS instance uses root@, and I have no idea for the others...

 

MAKE AN EXECUTABLE FILE TO SSH

So now that you've made sure SSH'ing into your ec2 instance actually works, let's start doing some magic. The first thing you'll have to do is create the executable file and then make it an executable file.

Create the executable file

Create that file somewhere (I'm calling mine aws_ssh.sh. Name yours w/e but just make sure it ends with .sh) and make sure you add the hash-bang so it knows to use bash and also include the ssh -i line that worked in the last step.

Make it an executable file

 To make this executable it's pretty easy... just do the following inside the directory that holds aws_ssh.sh.

chmod u+x aws_ssh.sh

Now you should be ready to go with the executable file! To double check that the file works just type this in Terminal:

/full/path/to/aws_ssh.sh

 

MAGICALLY CREATE THE SHORTCUT TO SSH

This next part is magical (for noobs like myself)! We are going to create a magical short-cut for you to easily ssh into your instance. Now that you know how to ssh from Terminal, and can do it all through an executable file (so you never have to memorize the DNS), we're going to create a simple one-worded shortcut to launch that executable from your Terminal!!

Essentially we're just going to create an alias from a keyword to that executable file (woops, did I just ruin the magic part?).

Here's how we do it:

Open ~/.bashrc and add the following line to the bottom of the file somewhere:

Just replace aws_ssh with whatever keyword you'd like to assign and you should be good! Just make sure you don't add any extra spaces or it won't work. To test this out EXIT TERMINAL, re-open it and test out your keyword. Type aws_ssh (or w/e you chose) and hit enter and you should have success!

 

As always if you guys run into any issues feel free to http://wesleyzhao.com/pages/contact me!

Tutorial: How to Set Up Dedicated MySQL Database Server Using Amazon EC2

DISCLAIMER: This is my current setup. Users with other distros beware.

So in the spirit of learning about scalability (and also after running into some issues dealing with several databases running on different local development environments we are using) I decided it would be a good idea to set up an EC2 instance solely as a database server. This tutorial will use MySQL as the database of choice not necessarily because I think it's the best, but because it is what I'm used to (I know... I'm lazy). So here's what we need to do.

  1. Assume you have an EC2 instance running for this
  2. Install mysql, apache2, php5, and phpmyadmin
  3. Configure your MySQL
  4. Configure your EC2 instance

ASSUME YOU HAVE AN EC2 INSTANCE RUNNING FOR THIS

Done. 

(JK, kinda. Here's a tutorial for this. Also I currently use the AMI mentioned above in the disclaimer. BTW You will need to SSH into your EC2 instance. Amazon has a pretty good tutorial if you just right click your instance in the management console, and click Connect).

INSTALL MYSQL, APACHE2, PHP5, PHPMYADMIN

Alright, now assuming we are running a clean ec2 instance, here are some of the dependencies you'll need. But before you do anything, just make sure your packages are up to date with the following code in your terminal.

sudo apt-get update

Install Apache (ignore this if you don't plan on using phpmyadmin or another front-facing MySQL app)

sudo apt-get install apache2

That was easy.

Install MySQL

 

sudo apt-get install mysql-server

During the install it might ask you if you want to preconfigure this for Apache. I almost got confused here, but click the Space Button to select, then Tab to hit "OK."

Oh, also, make sure you fill in a password for root (the more secure the better...but write it down).

Install PHP (ignore if you don't need phpmyadmin)

sudo apt-get install php5 sudo apt-get install php5-mysql sudo apt-get install libapache2-mod-php5

To double check everything is working by going into /var/www and adding a php file and try loading it. You may need to restart the apache2 server to check this by doing:

sudo service apache2 restart

Install PhpMyAdmin (not required if you don't think you'll need this)

sudo apt-get install phpmyadmin

Boom! So far so good....

Now try going to the webpage by typing: http://your.ec2.public.dns/phpmyadmin

Cool if it worked. If not bummer :(. Sorry, try again? 

 

CONFIGURE YOUR MYSQL

These next parts are not for the weak....also on a more serious note, these instructions may be specific to my Meerkat Ubuntu server.

But ah yes, what you'll need to do to configure your MySQL is two-fold.

Allow access from an outside IP

You'll need to navigate to your my.cnf file by typing:

sudo emacs /etc/mysql/my.cnf

Then change bind-address from 127.0.0.1 to 0.0.0.0. For me this was on line 52 and should look like this.

bind-address                 = 0.0.0.0

Grant MySQL user permission access from outside IP

Note: replace root with the user you chose (default is root). Replace securepassword with your password. You can change % if you want, as it is, it will allow access from any ip address.

Now you're at the final step my friend...

 

CONFIGURE YOUR EC2 INSTANCE

All you'll really need to do here is edit the security group of your instance to allow for the MySQL default pport (3306), and the HTTP port (80, if you plan to use phpmyadmin or something like that). 

To do this:

>go to the AWS Management Console

>Navigate to your EC2 Instance, and locate the name under the "Security Group" column

>Click Security Groups on the left bar, and then click the name of the security group assigned to your instance

>Click Inbound on the bottom

>Under Create a rule use the dropdown menu to find MYSQL and HTTP and add those both one at a time

>Make sure to click Apply Rule Changes or it won't save.

 

YEEE. Now you shall be ready to go. This will allow you to have a dedicated EC2 instance for all your MySQL database requests. 

Here are some of the tutorials I used to get this info: installing it all and configuring MySQL.

Tutorial: Setting Up Apache/SSL to Serve HTTPS

DISCLAIMER: This is my current setup. Users with other distros beware.

I've just successfully figured out how to build trust in my website for FREE (during my 30 day trial)! I wanted to record it down for myself and hopefully relieve some of the frustration from others who may be trying to figure it out, but have no consolidated tutorial. Again - note the DISCLAIMER above. Along with that fact, this tutorial is basic and will only set it up so all pages are served via HTTPS - will figure out how to do the mix later...

Here are the basic steps we'll walk through to get this to work:

  1. Get an SSL certificate
  2. Install your SSL certificate
  3. Configure Apache to serve as HTTPS
  4. Hope for a miracle

Now... let's do this.

GET AN SSL CERTIFICATE

The first thing you'll have to do is choose where you want to get it from. I was directed to PositiveSSL from a trusted ex-Googler/friend and so that's what I went with. More specifically, because I was just playing around I decided to go with their free trial before I shelled out some ca$h-money. Here's where you'd go for that

PositiveSSL - Free SSL Certificate for 30 days

So now that we are at the page, you need to click through, then discover you'll need to copy/paste a Certificate Signing Request (CSR).

Get a CSR

I would personally make a folder to termporarily store this stuff:

mkdir ssl_stuff
cd ssl_stuff

Then type the following to generate both your private key (the .key file) and public CSR (the .csr file):

openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out server.csr

It will then prompt you for some fields and most of them are optional...but why not:

Enter in your domain name in replacement of mydomain.com under 'Common Name.' It is also suggested that you make a backup of your myserver.key (or private key) just in case (I made mine myserver_backup.key).

Meow, copy paste the contents of your server.csr file back into the webpage and continue on to get your free certificate!

NOTE: You'll have to fill out a couple more annoying forms and hit complete!

Finally, you'll have to wait to get about 3 emails, the first will just be some rando confirmation, then a authentication email, then finally you'll get the email with the zip file of your SSL certificate!!!!!! Onward.

*Where I got my info : Comodo Support CSR Generation

 

INSTALL YOUR SSL CERTIFICATE

Boom! be proud you made it this far. First thing you'll have to do is unzip your SSL certificate, and use Filezilla (or your favorite FTP client) or FTP straight up from Terminal like a boss to move those files (preferably) into the same folder you kept that other ish in. So hopefully the following command will work inside the ssl_stuff folder:

ls   mydomain_com.crt mydomain_com.ca-bundle myserver.key  myserver_backup.key server.csr

Now you'll have to move the private key and certificates to the correct Apache folder. Depending on your distro it will still probably be in /etc/ssl/ somewhere under private and certs folders but here is what I had to do:

KK COOL. Now you're going to have to configure Apache to find and use the SSL Certificate.

You'll need to find where you have your VirtualHost stuff set up but mine was in /etc/apache2/sites-enabled/000-default. Here's what you'll have to add to the file somewhere inside the VirtualHost tags:

*Where I got my info: Comodo Support Ceritificate Installation

Now run the following to just confirm that it works.

sudo a2enmod ssl #enable SSLEngine etc. to work
sudo service apache2 restart

If everything works fine and dandy you're good! If no, it's probably a spelling error...shame on you. 

 

CONFIGURE APACHE TO SERVER AS HTTPS

Alrighty troll, we're almost there. We've got most of this set up. Now we just have a few last Apache configuration steps so stay with me.

Tell Apache to redirect all HTTP requests to HTTPS

Add the following to your Apache httpd.conf file:

And type the following in terminal to enable RewriteEngine (etc) to work and then to check for spelling errors:

sudo a2enmod rewrite
sudo service apache2 restart

Tell Apache to serve through the HTTPS port

The default port being used for your pages is probably 80, which you need to switch to 443. It's as simple as just replacing 80 with 443 in your 000-default file. So it should look something like this:

Open up the HTTPS (443) port on your instance

So navigate over to your AWS Management Console and click:

  • EC2 (on top toolbar)
  • Instances (left toolbar) >> then read what security group it is
  • Security Groups (left toolbar)
  • Name of Security Group your instance was assigned
  • Inbound (new loaded panel on bottom)

And now under 'Create new rule' selected 'HTTPS' and click Add Rule. Finally click Apply Rule Changes (DON'T forget this).

 

HOPE FOR A MIRACLE

Ah young padawan, your final task:

sudo service apache2 restart

YAY! Now if you try to navigate to any page, it should automagically load as an HTTPS url rather than HTTP and everything should work! If not then... well... let me know! I will definitely be much more helpful if your setup is the same as mine, but if not I will do my best!

 

FINAL_NOTE_1: If Chrome/whatever-browser is saying you have unsecure content but loads your SSL certificate, it is probably because some of the scripts (like JQuery or Webfont) you are loading are via HTTP request. Simply change those to HTTPS, re-open your browser, and it should all work!

FINAL_NOTE_2: Here are some other sites I used while making this:

My Amazon EC2 Instance

I've used a lot of tutorials on the web regarding installing/configuring/herp-derping my ec2 instance for my projects and have one thing to be consistent: there is no consistency...

So I've put it upon myself to try to be as consistent (or at least fully transparent) on the configuration/system I am running so that someone who happens to be using my exact setup can follow it step by step, and someone who is not can know right away that the reason my tutorials don't work might just be because of a difference in setups.

So let's get the details out right now:

aws image id - ami-cc405a5 [probably the most important thing to know]

os - Ubuntu Maverick Meerkat [tried upgrading to Natty, f'd everything up]

python - 2.6.6

HTTP server - Apache2

There is probably several more things I need to specify, but for now this is good. Please let me know if you want me to specify anything else, and I will add as I think of important things.

Using 'Big Brother' To Motivate You

I'm not sure if it's the right way, but I know that it works. I often use 'Big Brother' characters to motivate myself to work harder. My notion of 'Big Brother' is someone that is ever-present and constantly keeping an eye out on you. So an example of how I use it:

One Spring Day in Philly it was raining and my coach was not going to be at Track Practice. I had to run a couple 100m's at a given speed and I knew it was going to be tough. This was towards the middle/end of April as we were heading into our Y Combinator interview. I was on my last few reps of my last set and one thing that crossed my mind was: "I can slow down now and nobody will notice." I knew it was possible, I would not ever get found out, and it would make definitely make my muscles a lot happier. 

But then I immediately realized that it's cheating, wrong, and would defeat the purpose of doing the workout (which is to get better/faster/stronger).

So obviously, people can rationalize this out and say here is the good that can come out of not finishing through, and here is the bad side. It's easy to tell yourself something is wrong, but it's hard to actually get yourself not to do it. Something that is not a steadfast rule but is pretty applicable to most things is the right thing to do, is usually the hard thing to do.

So at that moment when I had to make the choice of doing the easy (wrong) thing or the hard (right thing) to do, I played a little Jedi-mind trick on myself. I imagined what if Paul Graham was watching you? What if he could see the choice you're making.

The answers to that is obviously, he would not accept me into Y Combinator if he knew I was a slacker and not a persistent, hard worker. Unfortunately, I still never got into YC (yet) but at least I know it's not because I didn't finish those last reps...

I use this strategy on a lot of things like finishing up dumb homework assignments, forcing myself to study for tests, getting myself to read thing I know I won't be tested on, being able to pull all nighters coding (however those are usually fun), and also (the reason I thought of writing this post in the first place tonight) getting yourself to finish running 2 miles at 12AM when noone's making you.

I also often mix and match 'Big Brothers' too - sometimes it's PG, sometimes it's Maddie, sometimes it's My Dad, etc etc. Depending on the situation and who I believe could affect my performance the most, I decide who to use as my 'Big Brother.'

 

Sometimes though, I wonder if using a 'Big Brother' is cheating to avoid cheating. If you think about it, using a 'Big Brother' is somewhat a sign of being able to motivate yourself, but on the other hand it's also a sign that you need someone else to motivate you. It's good that it works, and you're able to drum this up from imagination, but to some extent it's also not 'real.' As in it's quite possible that some people may consider using a 'Big Brother' not a genuine sign that a person is driven and driven for all the right reasons. I question myself sometimes as to whether or not I am essentially choosing the easier route, where the hard route is doing something just because it's right. Rather than doing it because you know someone else would think it's right. Do people need to be more genuine? Does it matter?

IDK. Up to you.

Heading Home to Seattle!

Yup it's true. We explained all about it in our video update today if anyone is interested! And also if anyone has any questions on why, feel free to contact me as well.

Besides that I'm just trying to head to sleep rgiht now and get a quick post in. Big thing that happened today - fixed my sound on Ubuntu! Did that just by following this simple tutorial, and it worked after step one....