Imagine you have a website and a subdirectory (say, http://example.com/gallery/) and you now want to make use of a subdomain instead (say, http://gallery.example.com)
Doesn't sound too hard, does it?
Mon, 17/05/2010 - 23:24 — horuskol
I've just installed the PHP YAML library which is currently being developed. This will hopefully allow me to write more complex configuration documents than the tradition ini format allows.
The installation process was a bit hit and miss though, with minimal documentation, and a couple of errors on the way.
Ubuntu Packages
First off, you will need the following Ubuntu packages:
$ sudo apt-get install php5 $ sudo apt-get install php5-dev $ sudo apt-get install php-pear
Sat, 01/05/2010 - 17:14 — horuskol
For most applications, there really isn't all that much to Apache configuration beyond setting up the virtual host and document root.
But Apache has a lot more to offer, and this set of articles will show how to set up some security on your site.
Mon, 01/03/2010 - 19:50 — horuskol
As I go further down the rabbit hole that is web-development, and break away from the path of pre-built libraries and frameworks, I just keep learning more.
A few weeks ago I finally got around to creating my own collection class - for the uninitiated, a collection is a way of creating something that behaves like an array, but with the added advantage of having inheritable and extensible methods, like an object.
Mon, 14/12/2009 - 19:28 — horuskol
Okay, so automically generating a friendly URL for a blog post or forum post from their titles doesn't really take a lot - but this snippet might make it easier for you:
function make_slug($orig, $length = 0) { $slug = preg_replace('/[^a-zA-Z0-9]/', '-', $orig); $slug = preg_replace('/\-\-+/', '-', $slug); $slug = strtolower($slug); if ($length > 0) { // limits the length of the slug $slug = substr($slug, 0, $length); } if (strrpos($slug, '-') == strlen($slug) - 1) { // removes any ending - $slug = substr($slug, -1); }
Tue, 06/10/2009 - 19:53 — horuskol
I recently helped a poster at HTML Forums who wanted to be able to reformat floating point numbers in PHP.
The problem is that some of these numbers were in exponential format. There was also a requirement not to round a number like 0.004 to 0, although the 'precision' was to be constant for all uses of this function in the script.
8.8458e-119 = 8.84e-119 1.06542e-52 = 1.07e-52 2.68e-36 = 2.68e-36 2.91405e-35 = 2.92e-35 0.0190644 = 0.01 0.0205511 = 0.02 0.004 = 0.004
Sun, 13/09/2009 - 19:44 — horuskol
At almost 1,000 pages, the HTML5 specification from the W3C can seem a bit daunting.
However, the reason for this extremely wordy specification is to clear up a lot of ambiguity that existed in previous specifications targeted at browser vendors and producers of related software. This is actually a good thing, since it locks down the behaviour and rules that browsers have to obey, meaning that web developers can be more sure of conformity across browsers.
But that does mean that the specification is full of sections that are just not relevant to the creators of websites.
Sun, 06/09/2009 - 14:13 — horuskol
A fun little function that will produce the Roman Numeral representation for any number from 1-3999.
The reason for the limitation is because the Romans used barred letters for the number 5000 and larger, and the representation of 4000 would be MV, which is hard to represent in a simple ASCII string (maybe as an exercise to the reader, the function can be extended?).
function intToRoman($number) { if (!is_numeric($number)) { echo "Input is not a number\r\n\r\n"; return; }
A few weeks ago I asked my friend Sofee at Heart Shaped Designs if she would mind designing a site theme for RandomtTweak.
After a couple of weeks of swapping thoughts (from me) and designs (from her), I was handed a pretty smart looking final design and the component images and font specifications for me to use in creating the final HTML/CSS design. I just hope that Sofee will forgive what I've done with her design...
Theming Drupal
Sat, 01/08/2009 - 09:27 — horuskol
RandomTweak is now on Twitter - http://twitter.com/randomtweak