Category Archives: Development

Great presentation on Nginx: Cranking Nginx to 11 – DPC 2012

New job uses Nginx a lot so been reading up on this topic and came across this presentation on Nginx which I thought was worthy or reposting.

Link to original presentation:

Tagged ,

Powerful Validation from Respect

All developers have had to, and one time or another, write a validation class. Over the years, I’ve personally tweaked my own validation class and it has become a pretty standard part of all my coding project; However that may all change now.

Respect is not the first PHP validation class to hit the tubes of the Net but it does appear to be one of the better implemented and flexible ones out there.

More powerful Validation from Respect –

Tagged ,

Getting Git to work in Textmate, Resolving "sh: git: command not found" error

I’ve been doing a lot of work with Git lately and its great. I downloaded and installed the Git Bundle for Textmate but it didn’t  seem to work, always returning the error message “sh: git: command not found”. Since I did most of my Git work from the command line I just ignored it but for some reason tonight I decided I needed to fix.

Since I knew Git worked on my system, it must have been something with the way Textmate was configured. I couldn’t figure out how to confiugre Textmate to point to my Git install so I guess I cheated and I created a symbolic link on my system to point to my Git install. It seems to have corrected my issue with Textmate.

The command I ran was pretty simple
sudo ln -s /usr/local/git/bin/git /usr/bin/git
That’s it, Textmate is now happy with my Git install.

Tagged ,

'report_activate_error': RubyGem version error

So from time to time I will post small things to my blog that I just want to keep track of or remember how I did something. This is one of those post. I should prefix this post to anyone who happens to come across it and read it, I am by no means a “Rails Developer” and as a matter of fact, I ran into this problem working through a “How to” books.

The issue

I am running OSX 10.6.2 and although I had Ruby on Rails working on it at one time, some how, some where it broke. Now there is nothing more frustrating to a n00b who is trying to work through a tutorial on how to learn a new programming language and not being able to get past the first chapter because something about the base install of the programming language that you don’t know anything about and you’re trying to learn, wont work.

The Actual Error

When I try to create my first controller this is what happens
ruby script/generate controller main welcome
And this is what the system kicked out to me
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:271:in `require_frameworks’: RubyGem version error: rack(1.0.0 not ~> 1.0.1) (RuntimeError)

from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:134:in `process’
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send’
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run’
from /Users/eric/Dropbox/Code/Rails/r4music1/config/environment.rb:9
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/commands/generate.rb:1
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’
from script/generate:3
Naturally, the first thing I do is start hitting Google and start clicking on links. A lot of similar issues with a wide variety of solutions. From just doing a simple ‘sudo gem update’, to making sure rake is installed, to making sure you have the correct rake version installed. None of which worked for me. Finally, I stumbled onto Wojno’ Site and following the steps in his post I manage to resolve my problem.

The Fix
If you didn’t want to click on Wonjno’s link here are the steps that fixed my problem. Had to change a couple of things because my install paths were a little different since I was running a different OS.
We begin by uninstalling the problem package
sudo gem uninstall rack
When prompted, make sure you remove all versions of the rack packages. Now this is one place where my experience differed a little. I ended up getting prompted to uninstall rails itself. I’m a brave soul, that didn’t scare me, so yeah I uninstalled it.
Here is what that looked like
sudo gem uninstall rack
Remove executables: rackup in addition to the gem? [Yn]  Y
Removing rackup
You have requested to uninstall the gem: rack-1.0.0
actionpack-2.3.3 depends on [rack (~> 1.0.0)]
actionpack-2.3.5 depends on [rack (~> 1.0.0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
OK, that was a little scary but we will fix it.
I did manually remove the directory for the older version of rack
sudo rm -rf /Library/Ruby/Gems/1.8/gems/rack-1.0.1/
Now we reinstall things. Don’t forget we need to reinstall the rails itself
sudo gem install -v=2.3.5 rails
sudo gem install rack
After that, life was good, at least for me. If you found this article and actually read it in hopes that it helped fix your issue, well then I hope you had some success as well.

Tagged , , ,

Microsoft and Zend

More for my geek friends. This is old news but if you haven’t heard.

Microsoft and Zend Technologies Announce Technical Collaboration to Improve Interoperability of PHP on the Windows Server Platform / 10 / 2006 / Announcements / Zend News / Company /

REDMOND, Wash., and CUPERTINO, Calif. — Oct. 31, 2006 — Microsoft Corp. and Zend Technologies Inc. today announced a technical collaboration to enhance the experience of running the PHP scripting language on Windows Server® 2003. The parties expect to extend the collaboration to the next version of Windows Server, code-named “Longhorn.” The resulting technology enhancements and ongoing interaction with the PHP community is expected to enable customers to take advantage of the Windows Server platform. The cooperative effort seeks to provide customers with richer functionality and better integration, resulting in improved performance and increased reliability.

Continue reading

Tagged ,

Vi for programmers

This is a great article that shows you how to really harness some of the power of VIM. I snagged it from

It was a multiple part article so this is going to be kind of long but really filled with a lot of great information.

If you’re a developer working on a UNIX/Linux platform, you’ve already encountered vi. Vi users fall into one of two categories: those who hate it and continually curse its finger-twisting key combinations and hard-to-remember commands, and those who love the flexibility and power it offers. For a long time, I was in the former category. However, continuous usage has led to a gradual appreciation for the speed and power under the cryptic interface, and I’ve since learnt a bunch of shortcuts and key combinations that ease the task of writing code in the editor. This article discusses my personal top ten features. Before proceeding, ensure that you have a copy of ViM (that’s Vi iMproved) installed and working on your system. You can download both binaries and sources from

Continue reading


Backing Up and Restoring Your MySQL Database

Do you need to change your web host or switch your database server? This is probably the only time when you really think of backing up your MySQL data. If you’ve got a website with a database or your custom database running for your applications, it is imperative that you make regular backups of the database. In this article, I will outline two easy ways of backing up and restoring databases in MySQL.
The easiest way to backup your database would be to telnet to the your database server machine and use the mysqldump command to dump your whole database to a backup file. If you do not have telnet or shell access to your server, don’t worry about it; I shall outline a method of doing so using the PHPMyAdmin web interface, which you can setup on any web server which executes PHP scripts.

Playing with mysqldump

If you have either a shell or telnet access to your database server, you can backup the database using mysqldump. By default, the output of the command will dump the contents of the database in SQL statements to your console. This output can then be piped or redirected to any location you want. If you plan to backup your database, you can pipe the output to a sql file, which will contain the SQL statements to recreate and populate the database tables when you wish to restore your database. There are more adventurous ways to use the output of mysqldump.

A Simple Database Backup:

You can use mysqldump to create a simple backup of your database using the following syntax.

mysqldump -u [username] -p [password] [databasename]> [backupfile.sql]

[username] – this is your database username
[password] – this is the password for your database
[databasename] – the name of your database
[backupfile.sql] – the file to which the backup should be written.

The resultant dump file will contain all the SQL statements needed to create the table and populate the table in a new database server. To backup your database ‘Customers’ with the username ‘sadmin’ and password ‘pass21’ to a file custback.sql, you would issue the command:

mysqldump -u sadmin -p pass21 Customers> custback.sql

Continue reading

Tagged , , ,

Configuring Apache to use a .htaccess file

Just a good step by step on how to configure Apache to use a .htaccess file. I rarely ever use this method except in testing so I always forget.

First, get your web administrator to enable your use of .htaccess files. This requires a stanza in ServerRoot/conf/access.conf like this:

AllowOverride AuthConfig

where /home/webber is replaced by your home directory. Without this, the usual default is AllowOverride None, which means that .htaccess files are ignored. The above stanza allows .htaccess control in all subdirectories of the specified Directory.

Set up a reasonably secure directory for the password (and optionally the group) files. This directory should not be in the web document tree! If it is, someone who can learn or guess the URL of the password file can fetch it and try to crack the passwords. (This refers to visitors from elsewhere on the Internet. There is no simple way to prevent users with accounts on the web server host itself from snooping in the password file, so we will have to settle for security by obscurity and trust them not to try too hard.)
Let us name this directory http-etc by analogy to the Unix /etc directory where the system passwd and group files reside. Place it in your home directory (not in public_html) so that it is outside URL space. Give it permission 701 = rwx—–x meaning you the owner can do anything, and the web server, running as the ordinary user apache, can access the directory but cannot list it (so it must know the file names in advance).1

Continue reading

Tagged , ,

Backup files with tar

I don’t remember where I got this article from but it is full of some good information

TAR is the Unix Tape ARchive utility. It can be used to either store data on a streaming tape device like a DAT drive, or store files in what is commonly called a tarball file- somewhat like a pkzip file, only compression is optional.

[The basics]

In these examples, I will use the following file structure: a top level directory called DIR1 containing the files picture.jpg, document.doc and database.db.


[Creating a tarball]

If we were in the directory DIR1 and wanted to backup all the files to a tarball called backup.tar, we could issue this command:

$ tar cvf backup.tar .
tar: backup.tar is the archive; not dumped

c=create (an archive)
v=verbose (just because)
f=filename (the name of our tarball)
.=current directory (what’s going to be backed up)

Also worth mentioning is that by default tar is recursive- meaning it will back up all files and subdirectories recursively unless you otherwise specify with the n flag (non-recursive)

[Displaying the Contents of a Tarball]

The current directory will now contain a file called backup.tar. To display the contents of the tarball file, we could issue this command:

$ tar tvf backup.tar
drwxr-xr-x root/gci 0 Jun 29 10:10 ./
-rw-r–r– root/gci 1 Jun 29 10:10 picture.jpg
-rw-r–r– root/gci 1 Jun 29 10:10 document.doc
-rw-r–r– root/gci 1 Jun 29 10:10 databse.db
Continue reading

Tagged , , ,
%d bloggers like this: