Errors when Statically Compiling PECL modules into PHP

If you get errors like: configure: WARNING: unrecognized options: --enable-apc when statically compiling PECL modules, such as APC into PHP, then ensure you have the proper version of autoconf installed (version 2.13). On Ubuntu that was fixed with a quick sudo apt-get install autoconf2.13

Then you can get back to removing your configure file and running ./buildconf --force before you re-compile.

Easily create favicon.ico files from PNG graphics

After building a new web site, one of the last things web developers do is polish it off by adding a favicon, which is that little graphic that appears next to bookmarks, in the address bar, and on tabs in all of the major browsers. It helps to reinforce the brand, allows your pages to be distinguished from others in your visitors browser.

There are lots of ways to go about creating them, but my favorite is with a little command line utility called png2ico. This app has no gui, but its singular purpose is to eat PNGs and spit out ICO files, which makes it perfect for making favicons.
Continue reading

Is mds thrashing your OS X?

I use iStatsMenu to keep an eye on my RAM and CPU usage on my Mac Book Pro (which is no slouch with a 2.5 GHz Core 2 Duo Processor and 4 GB of RAM). There are three processes always seem to peg my machine:

  • Firefox
  • TextMate
  • and something called mds

Saving my work and restarting Firefox and Textmate is a no brainer, but I didn’t know what or how to address the problem with mds. Come to find out, mds is responsible for indexing in Spotlight. If its thrashing your CPU and hogging up your RAM, you may need to verify your dives with Disk Utility.app, but for a quick fix run this in Terminal:

sudo mdutil -a -v -i off

This will turn off indexing and you should see an immediate drop in usage and let you get back to work.

4 Easy Steps to Free Up Hard Drive Space on your Mac OS X Hard Drive

My hard drive space was rapidly depleting on my MacBook Pro, and needed to free up some space quickly. I decided to crowd source the answer, and my #lazyweb tweet resulted in some great pointers from my friends @markjaquith, @80085, and @lesmothian.

Here is how I freed over 16gb of space on my OS X Startup Disc.

Continue reading

Installing FUSE + s3fs and sshfs on Ubuntu

Fuse is a program to mount ‘foreign’filesystems to your computer. This is how I got an Amazon S3 (simple storage service) bucket mounted on my Ubuntu server as if it were a local folder:

Install the necessary libraries:
sudo aptitude install build-essential libcurl4-openssl-dev libxml2-dev libfuse-dev comerr-dev libfuse2 libidn11-dev libkadm55 libkrb5-dev libldap2-dev libselinux1-dev libsepol1-dev pkg-config fuse-utils sshfs

We also installed the sshfs (SSH File System) in order to test out FUSE. Go ahead and create a mount folder and mount a remote drive to it:
sudo mkdir -p /mnt/sshfs
sudo chown user:fuse /mnt/sshfs
sudo sshfs user@hostname:/path/on/remote/server /mnt/sshfs

You should now be able to browse files on /path/on/remote/server, locally from /mnt/sshfs. Please note that you will need to set the ownership of the mount before you’ll be able to use it. The fuse group was created automatically and is a good place to start.

To unmount the drive:
fusermount -u /mnt/sshfs

Download the s3fs source (Revision 177 as of this writing) from the Google Code project:
wget http://s3fs.googlecode.com/files/s3fs-r177-source.tar.gz

Untar and install the s3fs binary:
tar xzvf s3fs-r177-source.tar.gz
cd ./s3fs
sudo configure
sudo make
sudo make install

In order to use the allow_other option (see below) you will need to modify the fuse configuration:
sudo vi /etc/fuse.conf

And uncomment the following line in the conf file:
...
#user_allow_other

Now you can mount an S3 bucket like this:
sudo mkdir -p /mnt/s3
s3fs bucketname -o accessKeyId=XXX -o secretAccessKey=YYY -o use_cache=/tmp -o allow_other /mnt/s3

You will need to replace the XXX above with your real Amazon Access Key and YYY with your real Secret Key. I’ve also told it to cache the bucket’s files locally (in /tmp) and to Allow other users to be able to manipulate files in the mount. Check the wiki documentation for more options available to s3fs, including how to save your Access Key and Secret Key in /etc/passwd-s3fs.

Now any files written to /mnt/s3 will be replicated to your Amazon S3 bucket.

Installing ImageMagick and imagick via MacPorts

Installing ImageMagick with MacPorts couldn’t be easier:


sudo port install ImageMagick

But getting it to work with your PHP installation is a bit harder. If you’ve installed PHP via MacPorts with the pear variant you can install the imagick extension via pecl:


sudo pecl install imagick

The trick to getting it to stop complaining about the Wand-config path, is by passing it the proper prefix for ImageMagick. When prompted, hit 1, then enter in:

/opt/local

Now just add this to the end of your php.ini file, and reboot apache:


[imagemagick]
extension=imagick.so

Installing Sphinx on OS X for PHP

I’m starting to use sphinx in my work, and wanted to get a solid development environment set up for it on my local OS X server. Since I built my local server with Mac Ports, it was actually pretty easy to get that installed:

sudo port install sphinx

However, I had trouble setting up the PHP extension for the Sphinx API. I could have used the sphinxapi.php that ships with the sphinx source code, but having a compiled extension is faster, and I don’t have to add more files to my php project. Installing Sphinx via Mac Ports didn’t help either, because it doesn’t install libsphinxclient, which is required to build the PHP Extension. That was until I found some instructions from someone doing something similar for Ruby.

Continue reading

Redirect all traffic to a new site with Apache .htaccess

The easiest way to redirect all traffic from an old site to a new site is to use mod_rewrite with Apache in your .htaccess file. If this file does not already exist in the root of your site’s public folder, then go ahead and create it with a text editor. I suggest using vim.

Then pop this into it:

RewriteEngine On
RewriteRule (.*) http://new.example.com/$1 [L]

The above recipe has the added benefit of also appending the page the user was requesting to the end, so if the new site is a clone of the old site then this will ensure that your users get the page that they requested. There are easier ways to do this if you are just changing URLs out and the site will be on the same server, but this is the easiest way to redirect all traffic if the new site is on a different box all together.

Measuring a Country’s Power by their Talent

Leading indicators are measurements that change over time and suggest future trends for important second-order results like population growth and economic development. Economists in particular are often looking for indicators that have been known historically to lead the overall economy. If unemployment goes down, for example, it is a good bet that shortly thereafter income will rise and the economy will improve. It’s for this very reason, then, that economists and Wall Street fund managers are always looking for newer and better leading indicators. But such indicators needn’t be limited to the economy: they can apply to technology and technical culture, too, which has its own feedback loop to economic development. My friend George Morton, who figured this all out, says that by knowing the right numbers to look at we can have a good idea what countries will be leading in technology — and presumably in economic development and power — in the years ahead. The measure George likes is the number of Cisco Certified Internetwork Experts or CCIEs.

The CCIE is Cisco’s top certification category and VERY hard to earn. Being a CCIE doesn’t mean you have Len Bozack on speed dial, but it might as well. Cisco products dominate the Internet and CCIEs are Cisco gurus, so if you are serious about the Internet as a nation you’ll have CCIEs hanging about, or that’s the theory. Conversely, if you just talk a good game as a country with technological aspirations, maybe you won’t have many CCIEs at all — maybe none. It’s one way to determine who the posers are.

The numbers are enlightening. Check out how the US stacks up…

You don’t have to sell out to have financial security

David Heinemeier Hansson, inventor of Ruby on Rails (something you might of heard of) in response to Paul Graham:

Getting your company to the point where you can pay yourself a decent salary is a great milestone. You created something sustainable that doesn’t rely on spending other people’s money. You deserve to pop a bottle and celebrate!

You certainly shouldn’t curb your ambitions because of that, though. The real economic pay-off for taking the risk of starting a business is what comes after this.

More on: You don’t have to sell your company to have financial security and the freedom to do what you want