Author Archive

I Hate the French (lyrics)

Extracts from “I Hate the French”, a satirical comedy song written by Richard Curtis and performed by Howard Goodall, live during Rowan Atkinson’s 1980 UK tour.

They all wear berets and they’re all called “Jacques”,
They even steal from us the words they lack:
“le Weekend”, “le Camping” and “Cul-de-sac”,
That’s why I hate the French…

They bake their bread in such a naughty shape,
They brag about their wine, and worship the grape,
They criticise our food but then they eat “Crêpe”!
That’s why I hate the French…

And now they’ve started coming here in droves,
“French cigarettes”, “French letters”, and “French clothes”.

I’m sick and tired of eating all this “Brie”,
And I’ll be buggered if I go to “Gay Paris”!

They’re pretty cocky ’bout their “games in the dark”,
They think with girls they light a “special spark”,
But look what the bastards did to Joan of Arc!
That’s why I hate the French…


Really useful RegEx bits

If like me, you often need to use regular expressions, but still after over 10 years of using them can waste an entire morning just trying to write a simple search and replace, here are some really useful snippets I have used along the way.

To match an HTML link within a string, and to isolate the inner HTML, (whatever occurs between the opening and closing anchor tags), use:

<?php
preg_match('#<a\s+.*?href=[\'"]([^\'"]+)[\'"]\s*
    (?:title=[\'"]([^\'"]+)[\'"])?.*?>((?:(?!</a>).)*)</a>#i', $input, $match);

// $input - A STRING CONTAINING AN ANCHOR LINK WITH INNER HTML
$input = 'This is some text containing a linked image <a
    href="http://www.google.com"><img src="google.jpg" alt="Google"
    width="200" height="50" /></a>. Goodbye.';

// $match[0] RETURNS THE ENTIRE LINK INCLUDING THE INNER HTML AND ANCHOR TAGS
$match[0] == '<a href="http://www.google.com"><img src="google.jpg"
    alt="Google" width="200" height="50" /></a>';

// $match[1] RETURNS JUST THE ANCHOR LINK
$match[1] == 'http://www.google.com';

// $match[2] RETURNS THE INNER HTML, IN THIS CASE, JUST THE IMAGE TAG
$match[2] == '<img src="google.jpg" alt="Google" width="200" height="50" />';
?>

To match an email address, and to isolate either the username or domain name part of the address, use:

<?php
preg_match('#([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i',
    $input, $match);

// $input - A STRING CONTAINING AN EMAIL ADDRESS
$input = 'My email address is spam-a-lot@mydomain.com. Write me!';

// $match[0] RETURNS ONLY THE VALID EMAIL ADDRESS
$match[0] == 'spam-a-lot@mydomain.com';

// $match[1] RETURNS ONLY THE USERNAME PART
$match[1] == 'spam-a-lot';

// $match[2] RETURNS ONLY THE DOMAIN NAME PART
$match[2] == 'mydomain.com';
?>

To match an email address, and replace it with a clickable link to the email address, use:

<?php
$ret = preg_replace("#([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i",
    "\\1<a href="mailto:\\2@\\3">\\2@\\3</a>", $input);

// $input - A STRING CONTAINING AN EMAIL ADDRESS
$input = 'My email address is spam-a-lot@mydomain.com. Write me!';

// $ret - RETURNED STRING CONTAINING A CLICKABLE EMAIL LINK
$ret == 'My email address is <a
    href="mailto:spam-a-lot@mydomain.com">spam-a-lot@mydomain.com</a>.
    Write me!';
?>



Working with MySQL databases from PHP

If like me, you often forget what your database tables are called, or need to check if a MySQL table has been created successfully, but don’t have access to a handy control panel or interface, you may need to write a small PHP script to fetch the results you need. Here are a few that I find myself using time and time again:

Connect to your MySQL database

<?php
$db_user = 'joe_bloggs';
$db_pass = 'test123';
$db_host = 'localhost';
$db_name = 'my_database';

$db = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name , $db);
?>

Get a list of all tables in a database

<?php
$query = mysql_query("SHOW TABLES");
while ($result = mysql_fetch_array($query)) {
  echo $result[0] . "<br>";
}
?>

Get a list of all data in a table

<?php
$db_table = "my_table";
$query = mysql_query("SELECT * FROM '$db_table'");
while ($row = mysql_fetch_assoc($query)) {
  print_r($row) . "<br>";
}
?>


Flight Of The Conchords… Mutha Ucker!

“Flight Of The Conchords” are New Zealand comedy duo Bret McKenzie and Jemaine Clement, and sell themselves as “formerly New Zealand’s fourth most popular guitar-based digi-bongo acapella-rap-funk-comedy folk duo”. Their combination of witty observation, characterisation and acoustic guitar music has gained them a worldwide cult following. If you haven’t heard of them already, check them out.

Here are some of their funnier YouTube clips:


New iPhone 4G prototype left in bar!

New iPhone 4G prototype

On the evening of Thursday, 18th of March, Apple Software Engineer Gray Powell was celebrating his 27th birthday at Gourmet Haus Staudt, a German beer garden just 20 miles from the company’s Infinite Loop headquarters in Redwood City, California.

He also happened to be field-testing the next-generation iPhone at the time. He posted a Facebook update from the secret prototype, (disguised as a regular 3G), “I underestimated how good German beer is“.

Obviously, he underestimated too much, as he promptly set the new iPhone down on the stool next to him and left the bar! Gizmodo got the phone and full story here:
http://gizmodo.com/5520164/this-is-apples-next-iphone

Rumour is, Bill Gates also left a new Microsoft prototype phone in the bar, but three weeks later it was still there…


The Apple iPad – unveiled!

The Apple iPad

Apple is, at this very moment, unveiling the new iPad!

An A4 size version of the iPhone, 0.5 inches thick, 1.5 pounds, 9.7″ touch screen and a 1GHz chip. It comes in 16GB, 32GB and 64GB. WiFi and Bluetooth, an accelerometer, compass, speaker, microphone and the standard iPod connector, 10 hours battery life and a month of standby time.

Oh, and I want one!


Demotivational: Geek Humour

“Motivational Posters” are the kind commonly found in schools and corporate offices, designed to inspire people to achieve more or think differently. Over the years, they have been repeatedly parodied, and “Demotivational Posters” have become an Internet meme, juxtaposing banal optimism with comical pessimism. Here are some of my favourites demotivational posters.

Geek Humour – Because no one else gets your jokes anyway.


Demotivational: Call The Cops

“Motivational Posters” are the kind commonly found in schools and corporate offices, designed to inspire people to achieve more or think differently. Over the years, they have been repeatedly parodied, and “Demotivational Posters” have become an Internet meme, juxtaposing banal optimism with comical pessimism. Here are some of my favourites demotivational posters.

The Cops – Somebody should call them…


Demotivational: Ninja Cat

“Motivational Posters” are the kind commonly found in schools and corporate offices, designed to inspire people to achieve more or think differently. Over the years, they have been repeatedly parodied, and “Demotivational Posters” have become an Internet meme, juxtaposing banal optimism with comical pessimism. Here are some of my favourites demotivational posters.

Ninja Cat – By the time you see it, you’re already dead.


Demotivational: May Contain Nuts

“Motivational Posters” are the kind commonly found in schools and corporate offices, designed to inspire people to achieve more or think differently. Over the years, they have been repeatedly parodied, and “Demotivational Posters” have become an Internet meme, juxtaposing banal optimism with comical pessimism. Here are some of my favourites demotivational posters.

96 Units of Cum – Manufactured on a line that uses nuts!


Demotivational: Cookies

“Motivational Posters” are the kind commonly found in schools and corporate offices, designed to inspire people to achieve more or think differently. Over the years, they have been repeatedly parodied, and “Demotivational Posters” have become an Internet meme, juxtaposing banal optimism with comical pessimism. Here are some of my favourites demotivational posters.

Cookies – Damn right they’re THAT good!


Demotivational: Cock Flavoured

“Motivational Posters” are the kind commonly found in schools and corporate offices, designed to inspire people to achieve more or think differently. Over the years, they have been repeatedly parodied, and “Demotivational Posters” have become an Internet meme, juxtaposing banal optimism with comical pessimism. Here are some of my favourites demotivational posters.

Cock Flavoured – Suddenly, you’re not so hungry after all.


Demotivational: Jedi Squirrels

“Motivational Posters” are the kind commonly found in schools and corporate offices, designed to inspire people to achieve more or think differently. Over the years, they have been repeatedly parodied, and “Demotivational Posters” have become an Internet meme, juxtaposing banal optimism with comical pessimism. Here are some of my favourites demotivational posters.

Jedi Squirrels – Now we’re all screwed!


Demotivational: Post-It Notes

“Motivational Posters” are the kind commonly found in schools and corporate offices, designed to inspire people to achieve more or think differently. Over the years, they have been repeatedly parodied, and “Demotivational Posters” have become an Internet meme, juxtaposing banal optimism with comical pessimism. Here are some of my favourites demotivational posters.

Post-It Notes – Finally, a good use for them!


Copyright © 1996-2010 Neil Hillman. All rights reserved.
iDream theme by Templates Next | Powered by WordPress