DEV Community

Glen Connolly
Glen Connolly

Posted on

Cat Login Detection

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.

Alt Text

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!

Alt Text

Top comments (9)

Collapse
 
cyril_ogoh profile image
ogoh cyril

๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚
' why do we not tell the user that their cat is trying to login to the application

Cat's after seeing this : ๐Ÿ™€๐Ÿ™€๐Ÿ™€

Collapse
 
cyril_ogoh profile image
ogoh cyril • Edited

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

Collapse
 
elmuerte profile image
Michiel Hendriks

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.

Collapse
 
connollyglen93 profile image
Glen Connolly

Wow that's a little more intelligent than mine ๐Ÿ˜บ there is a real market for cat prevention, but mine only covers detection

Collapse
 
michaeltharrington profile image
Michael Tharrington

Haha! This is too purfect. Really nice touch with the 9 lives threshold. ๐Ÿ˜น

Collapse
 
urielbitton profile image
Uriel Bitton

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

Collapse
 
lbonanomi profile image
lbonanomi

This is delightful and practical in equal measure.

Collapse
 
connollyglen93 profile image
Glen Connolly

Thank you ๐Ÿ˜

Collapse
 
zomglings profile image
Neeraj Kashyap

Haha, my cat always tries to crack my passwords by brute force. Nice. :)