Prime Factoring with PHP

A surprisingly large number of math based computer problems appear to require factorization, finding prime number, or prime factoring. Presented below is a reasonably fast algorithm for prime factoring a number – it is limited to the integer size on PHP (231-1). It should be a fairly trivial exercise to modify the function below to… Continue reading Prime Factoring with PHP

Fractions

For many people the mere mention of fractions elicits a wince, and while these lovely math constructs played a notable role in our early years of math, they are reasonably simple entities. While most humans revisit fractions over many years and often still fail to grasp the concept, for a computer, the elementary operations with… Continue reading Fractions

Setting the timezone on PHP

Versions of PHP after 5.10 include the date.timezone directive in php.ini. Many applications which reference time need this directive to be set. A list of accepted values can be found at: http://www.php.net/manual/en/timezones.php The timezone is set as a quoted string, with no delimiter at the end, for example: date.timezone = “Continent/City” The location of the… Continue reading Setting the timezone on PHP

Installing mcrypt (PHP) on AWS Linux AMI

Update: with the update of PHP to v5.3.3, the amzn repository now includes php-mcrypt, rendering the steps below unnecessary. At the moment, the amzn repository has v5.3.2 of PHP (while the latest version is v5.3.3) – it also does not offer php-mcrypt. While in previous servers I have included a wider selection of repositories, I… Continue reading Installing mcrypt (PHP) on AWS Linux AMI

Installing APC on AWS Linux AMI

Update: Current versions of Amazon’s Linux AMI include the package php-pecl-apc (v3.1.9 – the same as the latest from PECL) in the repository. Using a package manager is usually preferable to using PECL- it will help you keep up to date, is centrally managed, and minimizes unnecessary dependencies (especially build tools). APC can be installed… Continue reading Installing APC on AWS Linux AMI