Archive for the ‘Tech’ Category

Installing Mongo PHP driver on CentOS 6 cPanel

Monday, September 17th, 2012 | Life, Tech

Once again, the PECL installer. In order to get the Mongo driver for PHP working, you need to install it manually.

mkdir mongo
cd mongo
wget https://github.com/mongodb/mongo-php-driver/zipball/master
unzip master
cd mongodb-mongo-php-driver-df8b217
phpize
./configure
make install

Add the extension to your php.ini file.

extension=mongo.so

Restart Apache, and Mongo should appear inf your phpinfo() output.

Install Memcache on CentOS 6 cPanel

Tuesday, September 11th, 2012 | Programming, Tech

Here is how to install Memcache for PHP on a CentOS 6 cPanel / WHM box. Some of the guides suggest that you need libevent (well, you do need libevent), though when I tried it, I already had it installed. But if you need it, yum will sort you out.

yum install libevent

Next, install memcache itself. Note that the package is called memcached.

yum install memcached

Of course, just installing it doesn’t mean that the daemon is running. So don’t forget to start it too!

/etc/init.d/memcached start

Finally, we need to add the PHP extension. Beware that the PECL installer on WHM won’t work! So you need to compile it manually from source. That isn’t too difficult though.

wget http://pecl.php.net/get/memcache
tar zxvf memcache
cd memcache-3.0.6
phpize
./configure
make
make install

And add the extension to your php.ini.

extension=memcache.so

Now restart Apache and a memcache section should appear in your PHP info.

Add Scala to your system path on Mac

Wednesday, September 5th, 2012 | Programming, Tech

Lets say you are running Mac OS X Lion and you have installed Scala to /usr/local/scala. To access scala from the terminal you need to do the following.

cd /etc/paths.d/
sudo vim scala

Add one line with the following in.

/usr/local/scala/bin

Save the file and restart terminal. You’ll now be able to use scala from the terminal.

Converting CVS to Git, with branches

Thursday, August 30th, 2012 | Life, Tech

There are quite a number of tools to convert a CVS repository to a Git repository out there. However, most of them don’t seem to be able to copy over the branches properly. A work around is to convert it to Mercurial first, then convert it to Git.

In this example I’m using a repository called RedDog.

First, we need to get Mercurial on the system.

yum install mercurial

Next we need to add the convert extension to the .hrc file. This might be a global file, or might be in your home directory, can’t quite remember.

[extensions]
hgext.convert=

Check out from CVS and convert to Mercurial.

cvs checkout RedDog
hg convert RedDog

This will create a Mercurial repository called RedDog-hg. Now we need to get hold of Fast Export.

git clone git://repo.or.cz/fast-export.git

Once we have the software we can initialise a new Git repository that we’re going to use and then CD into the folder.

git init RedDog-git
cd RedDog-git

Run the Fast Export tool, specifying the location of the Mercurial repository.

../fast-export/hg-fast-export.sh -r ../RedDog-hg

This will migrate everything into your new Git repository. If you run an ls -a you should see the .git folder, which you may want to rename to RedDog.git (something.git locations are actually just .git directories).

You may optionally also want to do a check out into that folder.

git checkout HEAD

However, you don’t have to – you can begin using it remotely without doing a local checkout.

ActiveRecord::ConnectionNotEstablished in Rails

Friday, August 24th, 2012 | Programming, Tech

I ran into this error while trying to get Ruby on Rails 3.1.1 which I installed from the Rails Installer to talk to MySQL. My stack is built from WAMP, so it might not have been as easily as it would be on a standlone MySQL installation.

Here is are the steps I took to fix it.

Edit Gemfile in project and add the following line.

gem 'mysql2', '< 0.3'

Rebuild the MySQL adapter with your version of MySQL.

gem uninstall mysql2
gem install mysql2 -- --with-mysql-config="C:/wamp/bin/mysql/mysql5.5.16/bin/mysql_config.pl"

Download the MySQL connector from the MySQL website.

http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

Once you have the zip file, uncompress it and copy lib/libmysql.dll to the Ruby bin directory. Finally, go back to your Rails project and run the following command.

bundle install

I was finally then able to run a command such as the following.

rails generate model Something name:string

Without it throwing any errors up.

Install DKMS on CentOS 5.7

Saturday, August 18th, 2012 | Life, Tech

DKMS is in RPMForge, so we need to add that before we can install it via Yum.

cd /root/
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm
rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm
yum install dkms

Installing APC for PHP on Fedora 15

Sunday, August 12th, 2012 | Life, Tech

This is how to install APC for PHP on Fedora 15.

yum install php-devel
yum install pcre-devel
yum install php-pear
pecl install apc

Create a file in /etc/php.d named apc.ini, containing the following.

extension=apc.so

Install VirtualBox guest additions on Fedora 15

Monday, August 6th, 2012 | Life, Tech

To install VirtualBox guest additions on Fedora 15, you want to mount the ISO into the CD room of your host computer (either using Daemon Tools, or an actual CD drive) and give that to your virtual machine. Then run the following commands.

yum update
yum install dkms
yum install gcc
reboot
mkdir /mnt2
mount /dev/cdrom /mnt2
cd /mnt2
sh ./VBoxLinuxAdditions.run

PHPUnit and PEAR packages break on Mountain Lion

Monday, August 6th, 2012 | Programming, Tech

If you have recently upgraded to Mac OS X Mountain Lion (10.8) you may find that PHPUnit and other PEAR packages no longer work. You may get errors similar to the following.

PHP Copy & Paste Detector

Warning: require(PHPCPD/Autoload.php): failed to open stream: No such file or directory in /Users/chris/pear/bin/phpcpd on line 49

Fatal error: require(): Failed opening required 'PHPCPD/Autoload.php' (include_path='.:') in /Users/chris/pear/bin/phpcpd on line 49

PHP Mess Detector

Warning: require_once(PHP/PMD/TextUI/Command.php): failed to open stream: No such file or directory in /Users/chris/pear/bin/phpmd on line 38

Fatal error: require_once(): Failed opening required 'PHP/PMD/TextUI/Command.php' (include_path='.:') in /Users/chris/pear/bin/phpmd on line 38

Unfortunately, there doesn’t seem to be an easy way to fix them, other then by reinstalling each package.

sudo pear install --force --alldeps phpunit/phpunit
sudo pear install --force --alldeps phpmd/PHP_PMD

The tools should then run as expected.

View all CVS commits in past week

Tuesday, July 31st, 2012 | Life, Tech

This will give you a list of all the commits made between a specific date period. Just alter the dates accordingly.

cvs diff -N -c -D 2011-03-21 -D 2011-02-28 > /tmp/diff.txt