DEV Community

Glen Connolly
Glen Connolly

Posted on

16 7

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

Image of Bright Data

Global Data Access Unlocked – Reach data across borders without restrictions.

Unlock the power of global data collection with our advanced proxy solutions. Ideal for market research and more.

Unlock Data Now

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. :)

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay