Archive for January, 2010

Effectively repair MySQL Tables

on Wednesday 27th January, 2010 Gabe speculated thusly…

$ cd /var/lib/mysql

find -type f -name '*.MYI' -exec myisamchk --silent --force --fast --update-state --key_buffer_size=64M --sort_buffer_size=64M --read_buffer_size=1M --write_buffer_size=1M {} \;

Posted in Development, HowTo, Information, Linux, MySQL, Operating System, Programming

No Comments »

Access denied for user ‘debian-sys-maint’@'localhost’ (using password: YES)

on Tuesday 26th January, 2010 Gabe speculated thusly…

Find your debian-sys-maint password in /etc/mysql/debian.cnf.

GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY ' ' WITH GRANT OPTION;

Replace with your debian-sys-maint password.

Posted in Debian, Development, MySQL, Operating System, Ubuntu

No Comments »

Creating a PHP array of ISO 3166-1 Country Codes

on Thursday 7th January, 2010 Gabe speculated thusly…

I recently came across http://opencountrycodes.appspot.com/ which has an ISO 3166-1 list of country codes for various programming languages. I wanted to generate an HTML drop down list for customer to choose from based on these codes. However, there is no PHP version provoided. So taking the XML version found at http://opencountrycodes.appspot.com/xml/ I made a trivial script that would take the codes found in the XML document and organise them in to a PHP array called $XML2PHPCountryCodes and save that array in a file called country_names.php. The output file can then be included in any PHP script making the contained array available.

< ?php
$str = file_get_contents('http://opencountrycodes.appspot.com/xml/');
$xml = new SimpleXMLElement($str);
$out = '$countries'." = array(\n";
foreach ($xml->country as $country)
{
	$out .= "'{$country['code']}' => \"{$country['name']}\",\n";
}
$out .= ");";

file_put_contents('country_names.php', $out);

Posted in Development, PHP, Programming

3 Comments »