I was taking a quick break from work last week when my cat predictably took up napping position on my keyboard. When I looked at the monitor I noticed she had tried to login, and a question dawned on me:
In an age where we use machine learning to detect changes in the inflection in a voice and process hundreds of thousandths of images in seconds, why do we not tell the user that their cat is trying to login to the application they're using and impersonate them?
OK maybe that's not what the cat is doing, but either way it seemed like a great opportunity for an easter egg.
Maybe not the smartest detection setup, but assuming the user is not using software to allow for non-blocking key input detection, I decided counting the characters provided and searching for a character which was entered more than 'X' amount of times would suffice. The aim here was to detect whether a cat is sitting on the keyboard, so sophistication was never a priority here.
private function catInputDetected($s)
{
return max(array_count_values(str_split($s))) > self::CAT_THRESHOLD;
}
And can you guess what self::CAT_THRESHOLD is?
const CAT_THRESHOLD = 9; //9 Lives
All that was left was to run this check against the username and password, and inform the user that their cat has no boundaries.
if($this->catInputDetected($username) || $this->catInputDetected($password))
{
throw new \LengthException(
"
It would appear your cat has attempted to log in.
Please remove your cat from the workspace and try again.
"
);
}
Thanks for reading!
Top comments (9)
๐๐๐
' why do we not tell the user that their cat is trying to login to the application
Cat's after seeing this : ๐๐๐
But on a serious note
It's a nice idea
But if I were to work on this
The main features would be getting the cat off the keyboard
By irritating๐ฉ it
In a way it's wouldn't make its re-act ๐พviolence causing harm to the machine ๐
And
It's would be user friendly not enough to frustrate ๐ ๐ ๐ the users
This is a really old problem, and I can't believe it doesn't come standard with the OS :)
In 2000 PawSense won the IgNobel in Computer Science for solving that issue.
Wow that's a little more intelligent than mine ๐บ there is a real market for cat prevention, but mine only covers detection
Haha! This is too purfect. Really nice touch with the 9 lives threshold. ๐น
I have a cat and he does this all the time, so this is amazing lol
Although most of the time he walks across my keyboard as if it was a bridge, find a way to detect that too
This is delightful and practical in equal measure.
Thank you ๐
Haha, my cat always tries to crack my passwords by brute force. Nice. :)