Archive for the ‘Web’ Category

PHP may harm your computer.

October 24th, 2013 1 comment

At time of writing, all results from the PHP website are blacklisted for containing 4 trojans apparently.

Categories: PHP
Tags: ,

CSS Framework Breadcrumb Support

February 29th, 2012 No comments

I’ve noticed that the search term “blueprint css breadcrumb” has brought visitors to my blog. From what I vaguely remember about blueprint css, it doesn’t have support for breadcrumb navigation. If there is, either the documentation for it isn’t up to par or I’m expected to read the whole source which, particularly when it comes to CSS, renders the framework pointless anyway.

Whoever you are, you might want to check out Bootstrap, from Twitter. Bootstrap does have breadcrumb support, with example Markup right next to it in the documentation to get you going.

Categories: All, CSS, Web

When you need jQuery (or Bootstrap), but fast!

February 24th, 2012 No comments

I sometimes need to test some jQuery locally and I’m never organised enough to have a template ready. The latest version from a CDN is all I need and googling for the URL or searching my bookmarks will take longer than the solution I came up with today.


<script src=””


<script src=”” type=”text/javascript”></script>

I’m hoping that if I use it enough times, I’ll remember it! If you use this tip, make sure you don’t copy paste this onto your production systems. You could do without the one extra request to

Edit: I’ve added a URL for Bootstrap, from Twitter. It is:

<link href=""
rel="stylesheet" />


<link href="" rel="stylesheet" />

CSS Frameworks: In with the New, Out with the Old

November 18th, 2011 2 comments

I’ve noticed that my old post 960 Grid System vs Blueprint CSS is still getting quite a few hits so I thought I’d post an update about it.

Of the two, I now use… neither!

Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites. It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.

Just the other day I built a nice page in a matter of a few minutes using Bootstrap, from Twitter and it has me totally sold. If you need to throw something together quickly, then this is the way to go. Things I like about Bootstrap:

  • Single css file to include which includes reset CSS (no need for multiple css files).
  • Remotely hosted for quickstart. Bootstrap itself suggests to use <link rel=”stylesheet” href=””>
  • Simple markup
  • Customizable fixed or fluid layouts
  • Typography that just works (check out the inline labels).
  • Media markup (although I haven’t actually understood the purpose of it yet).
  • Very nice Tables with support for tablesorter.
  • Beautiful Forms with sexy buttons.
  • Navigation/Tab/Breadcrumb/Pagination
  • Sexy Alerts & Navigation 
  • … and a whole bunch of things you can do by adding small javascript snippets, such as modal dialogs, popovers, etc…

Definitely worth checking out if you are researching CSS frameworks and haven’t tried it yet!

Larnaka bus company “Zinon” website navigation decoded.

November 15th, 2011 6 comments

Cyprus, as anybody who lives or has lived here knows too well, has a very poor public transport system. One of my biggest problems with it is the lack of information about the various services (timetables, routes, ticket prices, connections with other modes of transport etc…).

Recently various websites have been popping up from the various companies to try and help address these issues, but I’d rather they didn’t and would much prefer the internet to be rid of these unfriendly and practically unusable sites. They are a waste of cyber space and it angers me that somebody, somewhere, has been paid for them… not to mention they’re probably being sold some extremely expensive hosting too.

Zinon Buses

Larnaka has one such company, Zinon buses. Its website is built by a company called SK Webline Ltd who’s own website, to no surprise, is “not available online at the moment due to updates on it” in a design that a 2 year old could cough up in a few minutes. Why do people pay such companies to build them a website? Would you pay this company to build you a website?

Anyway, let’s take a look at this site…

Read more…

Categories: All, Cyprus, Web

Simple PHP one-liner to generate random Lorem Ipsum (Lipsum) text.

August 16th, 2011 5 comments

Copying and pasting lipsum text from a site such as can be boring and tedious at times, especially when you would like to test multiple blocks and how well they will look with text of varying length.

Getting random lipsum of varying length is pretty easy in PHP, in fact you can do it on just one line of code:

$lipsum = simplexml_load_file(‘’)->lipsum;

Need more than one random string? Turn it into a method:

function random_lipsum($amount = 1, $what = ‘paras’, $start = 0) {

return simplexml_load_file(“$amount&what=$what&start=$start”)->lipsum;



  • $amount is… how much of $what you want.
  • $what is either paras, words, bytes or lists.
  • $start is whether or not to start the result with ‘Lorem ipsum dolor sit amet…
Categories: All, PHP, Web

12th Annual System Administrator Appreciation Day

July 29th, 2011 No comments

Today, and annually on the last Friday of July is sysadmin day.

A sysadmin unpacked the server for this website from its box, installed an operating system, patched it for security, made sure the power and air conditioning was working in the server room, monitored it for stability, set up the software, and kept backups in case anything went wrong. All to serve this webpage.

Head over to for more.

Categories: All, Technology, Web

Themes in CakePHP 2.0.0

May 23rd, 2011 5 comments

I’ve spent the best part of half a day trying to figure out why themes were not working for me in CakePHP 2.0.0

The closest I got to a solution can be found over on

Difference is that you need to set $this->viewClass to ‘Theme’ instead of $this->view, but there are 2 more unmentioned issues with the sample code provided as a solution:

public function beforeRender() {
	if ($this->RequestHandler->isMobile()) {
		$this->viewClass = 'Theme';
		$this->theme = 'mobile';

The first is that RequestHandler has been replaced by request.

So you may use:

if ($this->request->isMobile()) {


if ($this->request->is('mobile')) {

The other is that despite you’ve named your theme ‘mobile’, CakePHP’s new CamelCasing behaviours will turn this into ‘Mobile’. Because of this, you need your theme’s files to be located in ‘app/View/Themed/Mobile‘, and not in ‘app/View/Themed/mobile‘.

Categories: All, PHP, Web

Masking fixed length strings in PHP.

May 17th, 2011 2 comments

A particular problem came up in the office today, masking of credit card numbers. As my friend Leonid has pointed out, one would think that this is a very simple task for any programmer. Or not.

Having read Leonid’s solution, and finding a comment on which would also mask everything but the first and last four digits of a credit card number, I still felt that I needed to throw something of my own together. So here it is:

 * Mask part of a string
 * <code>
 * echo maskString('4012888888881881', 6, 4, '*');
 * </code>
 * @param	string	$s		String to process
 * @param	integer	$start	Number of characters to leave at start of string
 * @param	integer	$end	Number of characters to leave at end of string
 * @param	string	$char	Character to mask string with
 * @return	string
function maskString($s, $start, $end, $char = 'X') {
	$middle = '';
	for ($i = 0; $i < strlen($s) - $start - $end; $i++) {
		$middle .= $char;
	return preg_replace('/^(d{' . $start . '})(d+.)(d{' . $end . '})$/', '${1}' . $middle . '${3}', $s);

iPhone and/or iPod user agent detection with JavaScript

September 8th, 2010 1 comment

A colleague of mine sent me a piece of code which he had implemented to detect the iPhone by javascript. His code looked like this:

if((!navigator.userAgent.match(/iPhone/i))) { //step here if not iphone }

Although the code works, there is some room for improvement. And so here is what he is now using:

var agent = navigator.userAgent;
var is_iphone = (agent.match(/iPhone/i) ? true : (agent.match(/iPod/i) ? true : false));

/* the is_iphone variable is now true or false
   we can use it as many times as we like: */

if (is_iphone) {
  /* it's an iphone, do something */

if (!is_iphone) {
  /* this is not an iphone, do something else */

Much more readable too, I think.

Categories: All, Web