Archive for the ‘Tech’ Category

PHP complains date.timezone is not set

Wednesday, November 28th, 2012 | Programming, Tech

Sometimes, PHP will kick up a fuss complaining about date.timezone not being set. We found this on the Symfony framework and were able to replicate it on standalone scripts.

[Exception]
DateTime::__construct(): It is not safe to rely on the system's timezone settings.
You are required to use the date.timezone setting or the date_default_timezone_set()
function. In case you used any of those methods and you are still getting this
warning, you most likely misspelled the timezone identifier.
We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead

Normally, you would fix this by editing your php.ini file and adding a declaration there.

date.timezone = "Europe/Berlin"

But we had already done this and it still wasn’t working! After some further investigation, it seemed that PHP simply couldn’t access the value.

echo(ini_get("date.timezone"));

This doesn’t make any sense, and we never got to the bottom of what was going on, but there are two ways around the problem. Firstly, you could modify your PHP script so that it makes a call to set the system timezone.

date_default_timezone_set("Europe/Berlin");

However, this involves having to modify your code, which is bad as you don’t want to have to set the timezone manually, especially in a piece of code which could be deployed to servers in different timezones.

A better approach is to set it in the vhosts directive in Apache.

php_value "date.timezone" "Europe/Berlin"

This isn’t the cleanest solution but allowed us to solve an otherwise unexplainable error.

Running CruiseControl on Gentoo

Thursday, November 22nd, 2012 | Life, Tech

If you are trying to run CruiseControl on Gentoo Linux, you may find that you get an error similar to the following.

line 109: /bin/java: No such file or directory

There is due to the Java path. You can find it using the following command.

whereis java

You can then create a symlink to it.

ln -s /usr/bin/java /bin/java

Try running the command again and it should work.

Missing psych (for YAML output)

Friday, November 16th, 2012 | Programming, Tech

If you’re using YAML in Ruby and have it installed via RVM, you might get a notice similar to the following.

It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.

You can solve this using the following commands.

rvm pkg install libyaml
rvm reinstall 1.9.3

You may (or even need) to replace 1.9.3 with your exact version number.

PHPUnit on OSX Lion CLI

Saturday, November 10th, 2012 | Programming, Tech

If you’re trying to run PHPUnit from the terminal in Mac OSX Lion, you may get an error similar to the following.

File/Iterator/Autoload.php failed to open stream

You can resolve this by running the following commands.

curl http://pear.php.net/go-pear.phar > go-pear.php
sudo php -q go-pear.php

PHPUnit should now run without errors (or at least, without errors in their code 😉 ).

Embedding other templates in Sinatra ERB templates

Sunday, November 4th, 2012 | Programming, Tech

If you are using the Sinatra framework in Ruby, and you want to embed one ERB template in another, you can do this simply by using the ERB template tag like you can in your regular Ruby code.

<%= erb :welcome %>

Replace “welcome” with your template name as you usually do.

Apple Maps

Tuesday, October 30th, 2012 | Tech, Thoughts

Everyone knows that the new Apple Maps are rubbish, and we all want Google Maps back. This is still the case, but there is one area where Apple Maps is actually really good – “turn by turn directions”, aka the sat nav feature. George informs me that this is actually just TomTom, which probably explains it.

I don’t know if I would replace my sat nav with it – it presumably downloads maps on the fly, so what happens if you lose signal on the motorway, and how much cellular data is it using? But for getting around big cities, it looks very useful as I found it a lot better than my actual sat nav, for directions and clarity.

Cassandra RubyGem on Mac OSX Lion

Monday, October 29th, 2012 | Programming, Tech

If you’re trying to run Apache Cassandra with the RubyGem, you may encounter an error similar to the following.

thrift_client(0.8.1 not ~> 0.7.0)

You can fix this by editing the RubyGem.

cd /Library/Ruby/Gems/1.8/gems/cassandra-0.12.1/lib/
vim cassandra.rb

Find the line which sets the dependency.

gem 'thrift_client', '~> 0.7.0'

Change it to the following.

gem 'thrift_client', '~> 0.8.0'

Your script should now run without an error.

Fine tuning Facebook Events

Thursday, October 25th, 2012 | Tech

If you’re tired of Facebook inviting you to lots of events you weren’t actually invited to, using a 12 hour time format and starting your week on a Saturday, never fear, it’s easy to fix.

If you go to Events, then select the cog on the right hand side, then select settings, you are able to fine tune your options.

Command not found on updatedb on Mac OSX Lion

Tuesday, October 23rd, 2012 | Life, Tech

If you’re running Mac OSX Lion and trying to update your locate db, you may get the following error message.

-bash: updatedb: command not found

You can call updatedb by using its full path instead.

/usr/libexec/locate.updatedb

You could also create a symlink in your bin directory which would then allow you to just call updatedb as normal.

AppleCare

Sunday, October 21st, 2012 | Tech

One of the problems with the new AirPort Utility, 6.0+, is that it doesn’t have a DHCP clients table. This is obviously ridiculous, as anything claiming to be a router that can act as a DHCP server needs to have one, so I phoned AppleCare to sort it out.

They first asked me for the product’s serial number. But the problem is, this is genuinely invisible.

It’s below all those big symbols. Can you read that? I certainly can’t. No matter how close I move my face (human optics lacking a zoom function after all) and my eyesight is pretty good. Luckily, I managed to find it via AirPort Utility.

After some digging with first line, and some more with the senior I was passed through to, they eventually sorted it out for me – fair play to them as they basically spent twenty minutes talking me through how to bypass all of Apple’s security lockdowns to get the old software installed that does have the functionality.

Unfortunately by this point I had been on the call almost an hour, at a cost of £10 to myself, but they did at least solve the problem.