Google Starts Showing Real Time Search Results
Posted by Chris in Arb Stuff, Search Engine Optimisation on December 9th, 2009
You may notice Google has launched its latest enhancement to their search results… look carefully for a pause link and a scrollbar. These real time searches are live feeds from other large sites like Twitter. I have only seen Twitter so far in my result, but I believe that Google will show their news feeds and FriendsFeed too, plus a few more I am sure like Facebook and MySpace.
I did a search for “weight loss” and grabbed a screen shot for you…

Let us know what feeds you notice in the real time search results.
PHP: If Number Negative Then Make Zero
Posted by Chris in Tips & Tutorials on December 4th, 2009
In PHP, checking if a integer is negative and if it is then setting it to zero is easy, but I was looking for something shorter (and potentially faster) than:
if ($x < 0) $x = 0;
Well, this is a very quick check and reset, but there is a function max that does this too and it works with arrays too.
$x = max(0, $x); // $x will be set to 0 if it was less than 0
The max() function returns the number with the highest value of two specified numbers.
<?php
echo max(1, 3, 5, 6, 7); // 7
echo max(array(2, 4, 5)); // 5
echo max(0, 'hello'); // 0
echo max('hello', 0); // hello
echo max(-1, 'hello'); // hello
// With multiple arrays, max compares from left to right
// so in our example: 2 == 2, but 4 < 5
$val = max(array(2, 4, 8), array(2, 5, 7)); // array(2, 5, 7)
// If both an array and non-array are given, the array
// is always returned as it's seen as the largest?>
$val = max('string', array(2, 5, 7), 42); // array(2, 5, 7)South African Words
I was sent this email with SA words and thought it rude not to share it:
In preparation for next year’s World Cup, tourists need to brush up on
their Sarf Efrican
Braai
What is a braai? It is the first thing you will be invited to when you visit South Africa. A braai is a backyard barbecue and it will take place whatever the weather. So you will have to go even if it’s raining like mad. At a braai you will beintroduced to a substance known as mieliepap.
Ag
This one of the most useful South African words. Pronounced like the “ach” in the German “achtung”, it can be used
to start a reply when you are asked a tricky question, as in: “Ag, I don’t
know.” Or a sense of resignation: “Ag OK, I’ll have some more mieliepap
then.” It can stand alone too as a signal of irritation.
Donner
A rude word, it comes from the Afrikaans “donder” (thunder). Pronounced “dorner”, it means
“beat up.” A team member in your rugby team can get donnered in a game, or your
wife can donner you if you come back from a braai at three in the morning.
Eina
Widely used by all language groups, this word, derived from the Afrikaans, means “ouch.”
Pronounced “aynah”. You can say it in sympathy when you see your friend the day
after he got donnered by his wife.
Hey
Often used at the end of a sentence to emphasize the
importance of what has just been said, as in “You’re only going to get donnered if
you come in late again, hey?” It can also stand alone as a question. Instead of
saying “excuse me?” or “pardon me?” when you have not heard something
directed at you, you can always say: “Hey?” Izit? This is another great word to use
in conversations. Derived from the two words “is” and “it”, it can be
used when you have nothing to contribute if someone tells you something at a braai. For
instance, if someone would say: “The Russians will succeed in their bid for capitalism
once they adopt a work ethic and respect for private ownership.” It is quite appropriate
to respond by saying: “Izit?”
Ja well no fine
This is another conversation fallback. Derived from the four words: “yes”,”well”, “no” and
fine”, it roughly means “OK”. If your bank manager tells you your account is
overdrawn, you can, with confidence, say: “Jawelnofine.”
Klap
Pronounced “klup” – an Afrikaans word meaning smack, whack or spank. If you spend too much
time in front of the TV during exam time, you could end up getting a “klap” from
your mother. In America , that is called child abuse. In South Africa , it is called
promoting education. But to get “lekker geklap” is to get motherlessly drunk.
Lekker
An Afrikaans word meaning nice, this word is used by all language groups to express
approval. If you enjoyed a braai thoroughly, you can say: “Now that was
lekk-errrrrrr!” while drawing out the last syllable.
Tackies
These are sneakers or running shoes. The word is also used to describe automobile or truck tyres. “Fat
tackies” are really wide tyres, as in:” You’ve got lekker fat tackies on your Volla, hey?”
Dop
This word has two basic meanings, one good and one bad. First the
good: A dop is a drink, a cocktail, a sundowner, a noggin. When invited for a dop, be careful!
It could be one sedate drink or a blast, depending on the company. Now the bad: To dop is to
fail. If you “dopped” standard two (Grade 4) more than once, you probably won’t
be reading this.
Saamie
This is a sandwich. For generations, school- children have
traded “saamies” during lunch breaks. In South Africa you don’t send your kid
to school with liver-polony saamies. They are impossible to trade.
Bakkie
This word is pronounced “bucky” and can refer to a small truck or pick-up. If a young man takes
his “girl” (date) in a bakkie it could be considered as a not so “lekker”
form of transport because the seats can’t recline.
Howzit
This is a universal South African greeting, and you will hear this word throughout the country. It is often accompanied
with the word “Yes!” as in:” Yes, howzit?”. In which case you answer
“No, fine.”
Now now
In much of the outside world, this is a comforting phrase:
“Now now, it’s really not so bad.” But in South Africa , this phrase is used in
the following manner: “Just wait, I’ll be there now now.” It means “a
little after now”.
Tune grief
To be tuned grief is to be aggravated, harassed. For
example, if you argue with somebody about a rugby game at a braai and the person had too much
dop (is a little “geklap”), he might easily get aggravated and say.:
“You’re tuning me grief, hey!”. To continue the argument after this could be
unwise and result in major tuning of grief…
Boet
This is an Afrikaans word meaning
“brother” which is shared by all language groups. Pronounced “boot” but
shorter, as in “foot”, it can be applied to a brother or any person of the male
sex. For instance a father can call his son “boet” and friends can apply the term
to each other too. Sometimes the diminutive “boetie” is used. But don’t use it
on someone you hardly know – it will be thought patronizing and could lead to you getting a
“lekker klap”.
Pasop
From the Afrikaans phrase meaning “Watch Out!”,
this warning is used and heeded by all language groups. As in: “The boss hasn’t had
his coffee yet – so you better pasop boet” Sometimes just the word “pasop!” is
enough without further explanation. Everyone knows it sets out a line in the sand not to be
crossed.
Skop, Skiet en donner
Literally “kick, shoot and thunder”, this phrase is
used by many South African speakers to describe action movies. A Clint Eastwood movie
is always a good choice if you’re in the mood for of a lekker skop, skiet en donner flick.
Vrot
Pronounced – “frot”. A expressive word which means “rotten” or
“putrid” in Afrikaans, it is used by all language groups to describe anything
they really dislike. Most commonly intended to describe fruit or vegetables whose shelf lives
have long expired, but a pair of old tackies (sneakers) worn a few years too long can be
termed “vrot” by some unfortunate folk which find themselves in the same vicinity
as the wearer. Also a rugby player who misses important kicks or tackles can be said to have
played a vrot game – opposite to a “lekker” game (but not to his face). A movie
was once reviewed with this headline: “Slick Flick, Vrot Plot.” Could also be used
as an expression” I got vrot last night” (drunk)
Rock up
To rock up is to just, sort of arrive (called “gate crash” in other parts of the world). You don’t
make an appointment or tell anyone you are coming – you just rock up. Friends can do that but
you have to be selective about it. For example, you can’t just rock up for a job
interview.
Scale
To scale something is to steal it. A person who is “scaly” has a
doubtful character, is possibly a scumbag, and should rather be left off the invitation list
to your next braai.
Ja-nee
“Yes No” in English. Politics in South Africa has
always been associated with family arguments and in some cases even with physical fights. It
is believed that this expression originated with a family member who didn’t want to get a
klap or get donnerred, so he just every now and then muttered “ja-nee”. Use it when
you are required to respond, but would rather not choose to agree or disagree
Enjoy!
PHP Shorthand IF – ELSE Statement
Posted by Chris in Tips & Tutorials on September 14th, 2009
The IF – ELSE statement in PHP has a shorthand version if you are comparing two values. A conditional operator “?:” (or ternary) operator is used to shorten this statement down to one line. The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE. In variable example:
$variable = (statement) ? "return if true" : "return if false";
Example below:
<?php
// Example usage for: Ternary Operator
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];
// The above is identical to this if/else statement
if (empty($_POST['action'])) {
$action = 'default';
} else {
$action = $_POST['action'];
}
?>
Seeing as this statement is one of the most used statement while programming, it is a handy one to remember!
Counting Distinct Domains in Email List
Posted by Chris in Tips & Tutorials on September 4th, 2009
I found this MySQL query that counts the number of emails that have the same domain name in a table. This is handy when you want to check which domain, in your list of emails in a table in the database, is the most popular or even the top group of domains. My first guess for the list I wanted to check was that aol.com, yahoo.com, hotmail.com and gmail.com would be the top four, and guess what… they were.
I editted the query a little to work on the latest version of MySQL:
SELECT DISTINCT (RIGHT(LCASE(email), LENGTH(email) – INSTR(email, ‘@’))) AS domain, COUNT(email) AS number FROM member
GROUP BY (RIGHT(LCASE(email), LENGTH(email) – INSTR(email, ‘@’))) HAVING (((COUNT(email)) > 1)) ORDER BY number DESC;


