Monday, May 18, 2009
Friday, May 15, 2009
Catching Up
The move into the house it taking a toll on my time. Unfortunately I haven't had much time to work on the site. I'm hoping I can make some real progress this weekend, at least creating mockups of the dashboard (or search and search results page) if nothing else.
Tuesday, May 12, 2009
The building blocks of a registration page
I've built out and pretty much completed the registration workflow at this point. It's nothing fancy, you fill out a bunch of forms and upon successful completion it drops a row into the database, but it works. There were quite a few individual components that contributed to my success.
First off, I used a HTML + CSS form template that I found over at woork. I wanted to avoid tables and this helped me to do it. Ultimately I'm not quite sure if its the final model I'll follow for building out forms, but it's working for now, so I'll quit messing with it.
Next I used jQuery + jQuery UI to style my buttons and error notifications. Google is hosting these libraries thanks to their AJAX Libraries API. Oh, and did you know that Google also hosts the CSS for jQuery UI as of jQuery UI 1.7.0? They don't mention it on their API page anywhere, but they do. Here's how to load up the CSS for the jQuery UI Redmond theme via Google:
<link rel="stylesheet" type="text/css" media="all" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/redmond/jquery-ui.css" />
Also rediculously helpful is a page over at the filament group that explains how to style buttons for jQuery UI, as well as how to do things like getting a hand icon to show up when you hover over a button. (Why doesn't jQuery UI have a page like this?!)
As for the actual logic behind the form, most of that is handled by the awesomeness that is CodeIgniter. They have a fantastic form validation class that handles almost everything for you. Not only can you validate data, but in the same stroke you can clean data too (e.g. trim, convert to a md5 hash, etc.), like this:
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|matches[passconf]|md5');
Thanks to their ability to chain all of the rules together, you can literally validate and prep a field in one line. Done. Finito!
First off, I used a HTML + CSS form template that I found over at woork. I wanted to avoid tables and this helped me to do it. Ultimately I'm not quite sure if its the final model I'll follow for building out forms, but it's working for now, so I'll quit messing with it.
Next I used jQuery + jQuery UI to style my buttons and error notifications. Google is hosting these libraries thanks to their AJAX Libraries API. Oh, and did you know that Google also hosts the CSS for jQuery UI as of jQuery UI 1.7.0? They don't mention it on their API page anywhere, but they do. Here's how to load up the CSS for the jQuery UI Redmond theme via Google:
<link rel="stylesheet" type="text/css" media="all" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/redmond/jquery-ui.css" />
Also rediculously helpful is a page over at the filament group that explains how to style buttons for jQuery UI, as well as how to do things like getting a hand icon to show up when you hover over a button. (Why doesn't jQuery UI have a page like this?!)
As for the actual logic behind the form, most of that is handled by the awesomeness that is CodeIgniter. They have a fantastic form validation class that handles almost everything for you. Not only can you validate data, but in the same stroke you can clean data too (e.g. trim, convert to a md5 hash, etc.), like this:
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|matches[passconf]|md5');
Thanks to their ability to chain all of the rules together, you can literally validate and prep a field in one line. Done. Finito!
Saturday, May 9, 2009
How I stay motivated
I tend to read a lot of posts on entrepreneurship. Not necessarily because I think of myself as an entrepreneur, but more because I'm fascinated with the topic and learning about what to do (and not to do). Amongst all of the advice I'd read there's been a lot of common themes. One of them is that you'll spend a lot of time on your business, far more time than you'd spend in any regular job. The second is that you really need to love what you're doing if you want to stay motivated.
As much as I love working on my website there are days when I would really rather be doing something else. Such as, for instance, when some new downloadable content comes out for a game and I'd rather be playing that than programming. It happens. So how do I keep motivated?
I've started many projects previously and I have a very bad habit of starting a project only to get halfway through it and start on a new, different project. But I've been doing something different this time, and it's working to my advantage: blogging. As simple as it sounds, keeping a blogging schedule has led me to make constant, steady progress on my site. By requiring myself to post something new every few days I have to make progress on the site, otherwise I have nothing to blog about. And there's always something worth blogging about, whether it's discussing how I solved a problem, or implemented a new technology, or mockups I created for a page I'm going to build, etc. There's always something new, but only if I've been working on my site. Blogging about what I'm working on is definitely a practice I'll take with me on other projects I work on (but not before I'm done with this one!).
As much as I love working on my website there are days when I would really rather be doing something else. Such as, for instance, when some new downloadable content comes out for a game and I'd rather be playing that than programming. It happens. So how do I keep motivated?
I've started many projects previously and I have a very bad habit of starting a project only to get halfway through it and start on a new, different project. But I've been doing something different this time, and it's working to my advantage: blogging. As simple as it sounds, keeping a blogging schedule has led me to make constant, steady progress on my site. By requiring myself to post something new every few days I have to make progress on the site, otherwise I have nothing to blog about. And there's always something worth blogging about, whether it's discussing how I solved a problem, or implemented a new technology, or mockups I created for a page I'm going to build, etc. There's always something new, but only if I've been working on my site. Blogging about what I'm working on is definitely a practice I'll take with me on other projects I work on (but not before I'm done with this one!).
Wednesday, May 6, 2009
A framework for speed
When I first started posting to this blog I had the (unstated) goal of posting every 2 to 3 days. I've not posted for two weeks. 2 days != 2 weeks. Sorry. To be fair, I just moved into a new house, so between the packing, moving, and unpacking I've not had time for much of anything. However, if I were smart I would've planned for that by either saying I was going to take a break or making sure I'd have content ready during that time period. I did neither. Lesson learned; it won't happen again.
Anyway, while I was building out the registration forms for the site I realized that I was not moving fast enough (yet again). I was diving into all sorts of intricacies of form validation when I knew there had to be a much easier way to do it. I needed a framework that could do the heavy lifting leaving me to simply build out the pages on the site without having to write so much code. I stumbled upon a couple solutions, one being CakePHP and the other CodeIgniter. After studying them both I decided upon using CodeIgniter, mainly because it seemed faster, smaller, and easier to use.* It many ways it feels like an extension to PHP, providing a vast array of tools without requiring you to use any of them. And their documentation supports that. You can easily grab a class or a helper, quickly reference it, complete the task you're on and move right on to the next thing.
After completing the registration form I'll need to take a quick detour and work on the style for a bit. I've toyed around with a couple styling possibilities, but I need to solidify something soon or else I'm going to have to come back later and update the classes on every tag on every page. That doesn't sound like fun.
*Note that this is entirely based on my perception, not reality, as I've not had the time to play with them both fully. Your mileage may vary.
Anyway, while I was building out the registration forms for the site I realized that I was not moving fast enough (yet again). I was diving into all sorts of intricacies of form validation when I knew there had to be a much easier way to do it. I needed a framework that could do the heavy lifting leaving me to simply build out the pages on the site without having to write so much code. I stumbled upon a couple solutions, one being CakePHP and the other CodeIgniter. After studying them both I decided upon using CodeIgniter, mainly because it seemed faster, smaller, and easier to use.* It many ways it feels like an extension to PHP, providing a vast array of tools without requiring you to use any of them. And their documentation supports that. You can easily grab a class or a helper, quickly reference it, complete the task you're on and move right on to the next thing.
After completing the registration form I'll need to take a quick detour and work on the style for a bit. I've toyed around with a couple styling possibilities, but I need to solidify something soon or else I'm going to have to come back later and update the classes on every tag on every page. That doesn't sound like fun.
*Note that this is entirely based on my perception, not reality, as I've not had the time to play with them both fully. Your mileage may vary.
Wednesday, April 22, 2009
Scotchel has a home
A few days ago I registered scotchel.com. I figured it was about time. There's nothing there yet (other than Google advertisements), but come June, there will be.
On Logos
Over the weekend I set out to make a logo for my site. Perhaps not the final one, but at least something that I won't be completely ashamed of. I've made logos a few times before, and in the cases I have I typically approach it by taking the name of the site and seeing how I can make a logo out of it. So in the case of Scotchel, I just dumped the word into Photoshop and stared at it for a while. I thought about the things I wanted to convey about the site, how I want people to find love, go on dates, how it's easy to use, and friendly. I looked for parts of Scotchel that would lend themselves well to additional images. Ways I could restructure the word to get additional meanings out of it. Anything I could think of to add onto it.
After a while I realized that the upper curve of the S in Scotchel looks a lot like half of a heart. And that's what started my iterations on the logo:
For anyone that's even halfway familiar with Photoshop these weren't hard to come up with. The basic style is just taking the S, flipping it horizontally, changing the color, and erasing the part of the S I didn't want. And shazam! We have a heart.
As I worked through different iterations I realized that the serif fonts didn't convey a sense of friendliness. They conveyed a sense of formalness. Not what I wanted. So I gradually started moving to more sans-serif fonts. When I got to about the fifth font I realized that I really liked the handwritten fonts a lot. I didn't have many on my system though, so I hit up Urban Fonts and started browsing through their directory of fonts. It was actually quite hard to find a handwritten font that had an S with a curve that could be used for a symmetrical heart. But, after a bunch of tries, I landed on one I liked.
I finally tried a few different things with the heart on the S, though I only kept the filled in heart and the half-black/half-red heart. When I was satisfied that I had found a logo I liked I ran them past Rachel for her review. She really liked the first one and the second to last one. Personally I really liked the very last one because it was still easy to read the word but you could see the heart pretty clearly. Rachel agreed with my premise and we ended up going with the very last one, for now :-)
After a while I realized that the upper curve of the S in Scotchel looks a lot like half of a heart. And that's what started my iterations on the logo:
For anyone that's even halfway familiar with Photoshop these weren't hard to come up with. The basic style is just taking the S, flipping it horizontally, changing the color, and erasing the part of the S I didn't want. And shazam! We have a heart.
As I worked through different iterations I realized that the serif fonts didn't convey a sense of friendliness. They conveyed a sense of formalness. Not what I wanted. So I gradually started moving to more sans-serif fonts. When I got to about the fifth font I realized that I really liked the handwritten fonts a lot. I didn't have many on my system though, so I hit up Urban Fonts and started browsing through their directory of fonts. It was actually quite hard to find a handwritten font that had an S with a curve that could be used for a symmetrical heart. But, after a bunch of tries, I landed on one I liked.
I finally tried a few different things with the heart on the S, though I only kept the filled in heart and the half-black/half-red heart. When I was satisfied that I had found a logo I liked I ran them past Rachel for her review. She really liked the first one and the second to last one. Personally I really liked the very last one because it was still easy to read the word but you could see the heart pretty clearly. Rachel agreed with my premise and we ended up going with the very last one, for now :-)
Sunday, April 19, 2009
Goal: Launch in June
Goals keep you honest. It's harder to let a date slip when you set a goal to be done by a certain date. And at least for me personally, posting my goals publicly makes me feel more accountable.
Goals also help you to focus your efforts. They give you something to aim for and give you the means to adjust your plans if you're not on track. One of my goals is to launch my website in June. I've been a little loose about that, it may be June 1st or June 30th, but it's about two months from now give or take a bit.
I realized that with all of my work with CouchDB that I wasn't making much real progress. Nearly three weeks of effort with nothing to show for it. Sure, I learned a lot, but I hadn't built a single page yet. That's when it occurred to me that I should just start building even if it's not in the most optimal fashion. I know how to work with MySQL databases. I can use MySQL for now and migrate the data later if/when it becomes necessary. After all, no one will know the difference except for me!
Goals also help you to focus your efforts. They give you something to aim for and give you the means to adjust your plans if you're not on track. One of my goals is to launch my website in June. I've been a little loose about that, it may be June 1st or June 30th, but it's about two months from now give or take a bit.
I realized that with all of my work with CouchDB that I wasn't making much real progress. Nearly three weeks of effort with nothing to show for it. Sure, I learned a lot, but I hadn't built a single page yet. That's when it occurred to me that I should just start building even if it's not in the most optimal fashion. I know how to work with MySQL databases. I can use MySQL for now and migrate the data later if/when it becomes necessary. After all, no one will know the difference except for me!
Thursday, April 16, 2009
Installing PHP5.3 RC2 on Ubuntu 8.10
Over the last couple of days I've been attempting to install the second release candidate for PHP 5.3 on Ubuntu 8.10. It shouldn't have taken me more than perhaps an hour. But it took me a couple days because I was being stubborn and wanted to be more efficient (that sure backfired).
Anyway, I have to give my thanks to Jake over at The Netocracy for putting together the steps that I initially followed to install PHP 5.3. I had a few variations, but it ended up being a similar process.
I'm assuming that Apache2 isn't installed yet, in which case you'll need to run the following three commands to get some of the basics out of the way:
sudo apt-get install apache2 sudo apt-get install apache2-threaded-dev sudo apt-get install libxml2-dev
In case you're wondering why you need those, apache2 gets you your server, apache2-thread-dev gets you the apxs2 file that you'll need when you go to configure PHP, and libxml2-dev is required for configure as well.
Next you'll need the latest PHP snapshot. Download and extract the contents. Good, you're ready to begin. First off you'll need to run this:
sudo ./configure --with-apxs2=/usr/bin/apxs2
That shouldn't give you any issues, in which case you can run this:
sudo make
Now, before you begin installing PHP, you're going to need to edit your httpd.conf file to account for the fact that the Ubuntu installation of Apache2 doesn't use the file (it exists, but it's empty). It's pretty simple, first you need to launch an editor for the file:
sudo gedit /etc/apache2/httpd.conf
And then add the following couple of lines into the file:
#stuff
LoadModule stuff
Great, now you're ready to install:
sudo make install
Everything should've installed successfully at this point, in which case we need to undo what we just did to the httpd.conf file. Run the following command and delete the contents of the file (including the LoadModule line that the PHP installer just added):
sudo gedit /etc/apache2/httpd.conf
Excellent. Now we need to set up the Ubuntu way of handling modules in Apache2. We're going to create a couple files, php5.conf and php5.load, starting with the former:
sudo gedit /etc/apache2/mods-available/php5.conf
This is what you'll want to place in the php5.conf file:
<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
</IfModule>
Next up is php5.load:
sudo gedit /etc/apache2/mods-available/php5.load
Add this to php5.load:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
Now that you've set up the files for the module, you should be able to enable the module by using this command:
sudo a2enmod php5
Finally you'll want to edit the apache2.conf file to add a line so that Apache2 doesn't complain about not having a server name every time you start or stop it. Run this command to start editing:
sudo gedit /etc/apache2/apache2.conf
And add this line at the end of the file:
ServerName localhost
You're ready to start using Apache2 with PHP 5.3. Let's get Apache2 up and running:
sudo apache2ctl start
Success!
Anyway, I have to give my thanks to Jake over at The Netocracy for putting together the steps that I initially followed to install PHP 5.3. I had a few variations, but it ended up being a similar process.
I'm assuming that Apache2 isn't installed yet, in which case you'll need to run the following three commands to get some of the basics out of the way:
sudo apt-get install apache2 sudo apt-get install apache2-threaded-dev sudo apt-get install libxml2-dev
In case you're wondering why you need those, apache2 gets you your server, apache2-thread-dev gets you the apxs2 file that you'll need when you go to configure PHP, and libxml2-dev is required for configure as well.
Next you'll need the latest PHP snapshot. Download and extract the contents. Good, you're ready to begin. First off you'll need to run this:
sudo ./configure --with-apxs2=/usr/bin/apxs2
That shouldn't give you any issues, in which case you can run this:
sudo make
Now, before you begin installing PHP, you're going to need to edit your httpd.conf file to account for the fact that the Ubuntu installation of Apache2 doesn't use the file (it exists, but it's empty). It's pretty simple, first you need to launch an editor for the file:
sudo gedit /etc/apache2/httpd.conf
And then add the following couple of lines into the file:
#stuff
LoadModule stuff
Great, now you're ready to install:
sudo make install
Everything should've installed successfully at this point, in which case we need to undo what we just did to the httpd.conf file. Run the following command and delete the contents of the file (including the LoadModule line that the PHP installer just added):
sudo gedit /etc/apache2/httpd.conf
Excellent. Now we need to set up the Ubuntu way of handling modules in Apache2. We're going to create a couple files, php5.conf and php5.load, starting with the former:
sudo gedit /etc/apache2/mods-available/php5.conf
This is what you'll want to place in the php5.conf file:
<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
</IfModule>
Next up is php5.load:
sudo gedit /etc/apache2/mods-available/php5.load
Add this to php5.load:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
Now that you've set up the files for the module, you should be able to enable the module by using this command:
sudo a2enmod php5
Finally you'll want to edit the apache2.conf file to add a line so that Apache2 doesn't complain about not having a server name every time you start or stop it. Run this command to start editing:
sudo gedit /etc/apache2/apache2.conf
And add this line at the end of the file:
ServerName localhost
You're ready to start using Apache2 with PHP 5.3. Let's get Apache2 up and running:
sudo apache2ctl start
Success!
Tuesday, April 14, 2009
PHPillow requires PHP 5.3
I started playing with PHPillow, a PHP wrapper for CouchDB. My intent was to use this to interact with CouchDB as it would handle all of the heavy lifting and allow me to focus exclusively on my application. I downloaded the source code, got it set up, and ran the speed_test.php script that they created. The first half executed successfully, creating 1000 documents and doing 5000 GETs on those documents. However, the script failed when trying to do a view, stating:
Fatal error: Call to undefined method phpillowUserView::user() in [...]/speed_test.php on line 56
After reading through the code for a bit I found that it was failing because the code utilizes some functionality that's only available in PHP 5.3 (a development version) and I'm using PHP 5.2 (the latest stable version). There are several ways I could fix this:
I should mention another option, which would be the open source way of doing this. I could add/modify code in PHPillow to make it work with PHP 5.2. Some of their code already works with it, so it's clearly possible. Someone just needs to invest the time to make it happen. Unfortunately that person is not me. I don't have the programming skill to pull off that kind of thing yet.
Fatal error: Call to undefined method phpillowUserView::user() in [...]/speed_test.php on line 56
After reading through the code for a bit I found that it was failing because the code utilizes some functionality that's only available in PHP 5.3 (a development version) and I'm using PHP 5.2 (the latest stable version). There are several ways I could fix this:
- Modify the code in speed_test.php (and anywhere else where I'd use similar code) to use PHP 5.2-style code. On the upside, it should be the most immediate way to fix it. However, I'll need to do some learning because I have absolutely no idea what code I'd need to fix it now. And at some point PHP 5.3 will get released and I'll want to go back and fix my code. Not a big issue, just more of a small annoyance.
- Install PHP 5.3. Considering I'm already using two things that are in alpha (CouchDB and PHPillow), adding in a third is hardly a major concern at this point. This may actually end up being faster than modifying the code (sadly) because I just need to do some file/command-line wrangling instead of learning how to access PHPillow with PHP 5.2-style code.
- Drop PHPillow and write my own classes/functions. I'm probably better off having someone else write the library for me though. Writing my own code might work as a short term solution to get me going now, but it's likely a bad long-term solution.
- Drop PHP and use another language to program my site. Considering the only other language I have some familiarity with is Python, this may not be the best idea. I'm better off expanding my knowledge of PHP rather than learning something brand new.
I should mention another option, which would be the open source way of doing this. I could add/modify code in PHPillow to make it work with PHP 5.2. Some of their code already works with it, so it's clearly possible. Someone just needs to invest the time to make it happen. Unfortunately that person is not me. I don't have the programming skill to pull off that kind of thing yet.
Subscribe to:
Posts (Atom)
