r/shittyprogramming • • May 21 '20
Best way to present profanity in code
I have written code for a discord js bot that I am really proud of and have been working on for a long time now, I currently have it as a private repo on my github. My problem is that in the code I have a profanity filter that contains a list of non employer friendly words, what would be the best way of presenting this as an example of my programming ability without removing the profanity filter/list of swear words but that will also not put off employers?
171
Upvotes
125
u/ElkTF2 May 21 '20
substitute them for counterparts and explajn they would normally be replaced (e.g, frick, shoot, fiddlesticks, etc) would be my favorite solution
133
u/Ristovski May 21 '20
Store a hash of each profanity, then when checking each message on Discord, run the same hash function on each word - if the hashes are the same, you got a hit.
147
u/[deleted] May 21 '20
My team at a Hackathon once made a program that listens for profanity in a broadcast and censors it when it hears it. If we used profanity in our presentation we’d be immediately disqualified, so for the demo “apple” was our curse word. You could try adding in a bunch of non-profane words (like fruit names) and running your program on a bunch of text that uses them
25
u/calsosta May 21 '20
ROT13
Store naughty words in ROT13. When you use them ROT13.
34
u/TheSoundDude May 21 '20
Leave it there, and if they don't have a sense if humour find someone else who does.
12
u/djdanlib May 21 '20
/looks at subreddit name
Have a pre-press outfit make it into a really nicely formatted book. Apply chapter numbers at regular intervals instead of basing them on function. Write a compelling title that involves you getting a job at that employer because you gave them a book. Get a professional photographer to take a headshot and use that for the cover. Use Amazon print-on-demand to generate a novel-sized paperback hard copy of your source, and apply gold leaf to the outside of the pages. Then sign and shrink wrap the resulting special edition book, and present it to the interviewer.
11
u/JeffSergeant May 21 '20 edited May 21 '20
Ps. Does it correctly handle Scunthorpe, Marseille, and Cockfosters?
6
u/JeffSergeant May 21 '20 edited May 21 '20
Put the list in another web service and just put a call to your naughty words api in the code.. or leave them a sample naughtywords.include without all the bad words
Or just leave them in, assume your prospective employers are grown ups!
9
u/blackasthesky May 21 '20 edited May 21 '20
As an employer this would not put me off, honestly. This list serves a purpose in this case.
Edit: but I understand why you want to prevent it anyways
3
u/Dogeek May 21 '20
Who gives a fuck. I've worked for a porn game for two years and put that on my resume. The company I now work for didn't give a fuck, even hired me thanks to it.
It's a profanity filter, people are supposed to see curse words there.
2
u/Beefster09 May 21 '20
The profanity list should probably be stored as a separate configuration file anyway. Have the install script generate a swear list.
2
u/chargers949 May 21 '20 edited May 21 '20
Comment it out and replace with a db hit. If db not found or request times out then skip profanity filter.
Or you could just add comments right above the profanity definitions and call the class ProfanityList.
Any stupid reviewer who can’t see that’s ok then it’s a test for you to disqualify them.
On a side note always good to leave a note in your profanity test cases. Had a director hit me up first thing in the morning once when he saw my profanity filter test case I had staged, sitting on server still waiting for me to run tests. It was a 4 part test and i still needed to do last two parts.
2
u/KernowRoger May 21 '20
I think the easiest is just don't include it in source control and put a note saying place naughty.txt here or similar.
2
u/MorallyDeplorable May 22 '20 edited May 22 '20
Put them all in as word=chr(xx)+chr(xx)..., or encode them in json with \xXX
Base64 encode them
Store them in a separate file that's labeled so they know what they're clicking on
Put them in a PNG with this random thing
Use a different encoding from before ASCII
Repitch them to be supersonic WAV files, play them out of their speakers, and retrieve the list with speech recognition ymmv
Use Pig Latin
Put them behind a paywall
chmod the file to 000, chmod it to 666 when you need to read it.
2
u/m_0g May 22 '20
This should be in normal r/programming, this is cool, not shitty!
That aside though, another option you could use is to add a layer of indirection to the profanity. Eg. Put this list in its own header like "bad_words.h", or in its own repository even and use it as a dependency.
The hash option that's already been mentioned is also a super good idea!
2
u/xhable May 22 '20 edited May 27 '20
Anybody that is put off by profane words being in a profanity filter isn't somebody I would want to work for.
Keep the swear words as a filter for shit employers.
1
u/TheWittyScreenName May 21 '20
Save them as a list of hashes. Most languages have an easy hash function for strings anyway, since thats how they check for equality quickly.
As a bonus, It shows that you understand how to keep sensitive data private
1
u/irlingStarcher May 21 '20
Depends where you’re applying. If it’s a place that has user generated content, they probably already have their own profanity filter code that lists lots of bad words/phrases and won’t be phased by you having developed your own similar solution
1
u/Horyv May 21 '20
Separate profanity word list into a separate file, and don’t include it in your repo. In your repo, include a basic list of words as an illustration (fudge, sugar, heck), and document the format.
Set expectations that anyone deploying your software should include their own list of profane words.
1
u/ciaran036 May 21 '20
Why would it put them off? It'll get their attention :)
1
u/null000 May 22 '20
I'd question whether it matters in the first place. If there's a computer reviewing your code and not a person, you're too early in the process to be giving them your github (it's too information dense to be a helpful signal at this stage) and if the people reviewing your code aren't intelligent enough to understand why there would be profanity in a "profanity list", I'd question whether I'd want to work there to begin with.
That said, I'd make sure your unit tests use innocent words in any case (e.g. someone else's suggestion of using "apple") and I'd consider making the profanity list user-provided if you're still concerned about it being a deal breaker. In either case, definitely make sure to include the list as a separate txt/json file instead of something that's built into the code.
1
u/republitard_2 May 29 '20
/r/Poopyprogramming
1
u/OneHitPlunder Jun 16 '20
If your main concern is keeping the list of profane words secret, I would suggest hashing the profane words and testing the hash of each word against the stored hashes of profane words to determine if it's profane or not.
1
u/[deleted] May 21 '20 edited May 21 '20
Well, for me if the employer does not understand this subculture of the programmers, fuck the employer.
0
u/[deleted] May 21 '20
[deleted] — view deleted comment
0
u/[deleted] May 21 '20
[deleted] — view deleted comment