DEV Community

loading...

Cat Login Detection

Glen Connolly
PHP developer formally Java student formally C# beginner wannabe Go developer dreaming of writing an application in Rust.
・2 min read

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

Discussion (9)

Collapse
michaeltharrington profile image
Michael Tharrington (he/him)

Haha! This is too purfect. Really nice touch with the 9 lives threshold. 😹

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 Author

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

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
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 Author

Thank you 😁

Collapse
zomglings profile image
Neeraj Kashyap

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