Wednesday, April 10, 2013

MySQL vs PostgreSQL

The "M" in LAMP stands for MySQL, but there are other database management systems that can be used too. Another big open-source one is PostgreSQL. Like MySQL, it is available on a wide range of platforms, including Linux, FreeBSD, Solaris, Windows, and Mac OS X. I'm going to try and give a very high level overview of some of the basic advantages and disadvantages of each.


I have more experience with MySQL, but I have used both before. MySQL labels itself as "The most popular open source database," while PostgreSQL calls itself "The world's most advanced open source database." Those labels themselves give a little bit of insight into how the two differ on a very high level. Historically, MySQL's top priorities have been ease of use and performance, while PostgreSQL has maintained data integrity and security as its top priorities. As a result, the common opinion seems to be that MySQL is easier to use and is fast for applications like a website. On the other hand, the public opinion seems to be that PostgreSQL is more challenging, but offers more advanced features and can be more reliable, although it can be slower for simple queries. Both have good support in PHP.

If you want to know about the more in depth differences between the two, here are some comparisons of them I found:

Based on what I know, I think both database management systems are very capable of handling anything the average website will throw at them. It seems like it all comes down to what you're more comfortable working with.

Tuesday, April 9, 2013

Great PHP Tutorial

When I first learned PHP, I used this tutorial. I like it because it's easy to follow, and it provides great examples. Even a beginner would be ok reading it because it starts at the very beginning, explaining what PHP is and how to install it, and it gets into some decently advanced aspects later on. I still use it as a reference when I forget the exact syntax for something or need to figure something out I don't remember how to do. I'd recommend it to anyone that could use a good PHP reference.

Sunday, April 7, 2013

Setting up WordPress on a Ubuntu 12.10 Server

Ever wanted to host your own blog? Here's one way to do it. WordPress is one of the more user friendly content management systems available, and although others may be better suited to enterprise applications(I'm looking at you, Drupal), WordPress does just fine as a blog CMS. To begin with, I set up a 64 bit installation of Ubuntu Server 12.10 in VirtualBox. Then I followed the tutorial I posted previously to set it up as a LAMP server.

The next step is to set up a database that your blog will use. I chose to use MySQL. You can name the database whatever you want, and create a user that has access to it. Here are the MySQL commands you will need(replace username and password ):
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO "username"@"localhost" IDENTIFIED BY "password";
FLUSH PRIVILEGES;
EXIT;
Now your database is set up and ready to go! Next, download the latest release of WordPress to your www directory and extract it. You will need to be root to do this:
sudo su
cd /var/www/
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
Now you have a directory containing the wordpress installation at /var/www/wordpress/. However, we still need to connect the MySQL database to the WordPress installation. Enter the wordpress directory and you will find a file called "wp-config-sample.php". Rename it to "wp-config.php" and open it with a text editor. Here's a screenshot of wp-config.php open in VI (You can see part of a GUI because I'm logged in through SSH). I've underlined the parts you need to update in yellow.
mv wp-config-sample.php wp-config.php
vi wp-config.php 



Next step: Make your blog more secure against hackers! If you scroll down a little in the wp-config.php file, you will find a list of keys. Make a new key for each one. You won't have to remember them, so make them as complicated and nasty as possible. You're looking for this section:



Now then, cross your fingers and open your web browser to http://hostname/wordpress/wp-admin/install.php. If all went well, you should see this:


Follow the instructions on the screen to create an admin account for your blog. Note: this is not the username and password for your database. It's a new one that will be used to log into the administrator account of the blog. Fill in the information and hit the button to install WordPress.

Now you can log in to your new WordPress blog! That wasn't so bad, was it? Your blog will be at http://hostname/wordpress/.

Happy Blogging!

Wednesday, April 3, 2013

Pure CSS Tutorials

When it comes to incorporating animations into a website, JavaScript is probably what comes immediately to mind.  If you're feeling adventurous, though, CSS can be used to create some similar effects.  Over the past few years, I've had to explore some of them while working on web design projects at the office I work at.  Here are a couple that I've found that I think are particularly good.  None of them contain JavaScript.

Pure CSS Slider:
The great thing about this slide show is that it's 100% CSS driven and it incorporates some neat effects. Captions show up in a transparent box on top of the image, there's an animated progress bar at the bottom of each slide, the slide show pauses when you hover over it, and there is a smooth animation when the slide changes.  While I don't think this means that JQuery is dead, it is impressive to see CSS used so effectively. Click here to see the site.

CSS Sprite Menu:
This tutorial shows how CSS sprites can be used to create a dynamic menu. The menu links change color when you hover over them, and the active one stays colored.  It's a very creative use of some of the newer features of CSS, and it looks fantastic.  You can see the tutorial here, and a demo of it here.

Blurry Background:
This one is a pretty simple trick, but it produces some pretty neat results.  It uses two images to create a frosted glass-like background for a boxed region on the page.  There's not much else to say about it, so you can find the tutorial here.

Color Fade on Hover:
This is actually one I figured out on my own last summer.  It makes the color of a link fade when you mouse over it.  It only takes a little bit of CSS to get the job done:

a {
  color: #FFFFFF;
  -o-transition: .5s;
  -ms-transition: .5s;
  -moz-transition: .5s;
  -webkit-transition: .5s;
  transition: .5s;
}
a:hover { color: #FF0000; }

Then any links (<a href=""></a>) will have a fading color.  I've tried to use inline CSS to demonstrate it here since I can't upload my own CSS to this blog, but the colors may be hard to see.
   These links fade on hover.

And that's it!  CSS has become very capable of all sorts of graphical effects.  I've only brushed the surface, but I hope some of you might find something useful in these tutorials or might be inspired to dig a little deeper into CSS3.