r/shittyprogramming • • Jul 10 '15

I did it! I just wrote a program that passed the Turing test!

240 Upvotes

Here's the output of our latest chat session:

Me: Hi
Carl: Hello
Me: Are you a bot?
Carl: No
Carl: :)
Me: Ok

r/shittyprogramming • • Apr 29 '24

May I present one of my classmates ways to ensure he never has unmatched brackets?

Post image
239 Upvotes

r/shittyprogramming • • Aug 21 '14

super approved Using a for-loop to do something once is good practice, right?

Post image
239 Upvotes

r/shittyprogramming • • Aug 30 '16

PSA: Cut down on Imports If You Live in the UK to Reduce Performance Cost

238 Upvotes

Acknowledging the UK's upcoming departure from the EU, import costs are undoubtedly going to increase. To reduce the effect, I recommend the following steps.

  • If you're only importing one or two items, write them yourself instead.

  • Make sure you never import all items in a package if you won't use them all.

  • Shorten import names to increase efficiency.

  • Low-level interfaces will let you optimise to reduce cost.

Examples

Before

import time

time.sleep(1)

After

from time import sleep as s

s(1)

Before

import urllib2

result = urllib2.urlopen("http://www.reddit.com/").read()

After

from socket import socket as a
from socket import AF_INET as b
from socket import SOCK_STREAM as c

s = a(b,c)

s.connect(("reddit.com",80))
s.send(b"GET / HTTP/1.1\nHost: www.reddit.com\n\n")

result = s.recv(10000)

r/shittyprogramming • • Jul 07 '16

Do my Java programs need to run as root to use random numbers?

238 Upvotes

My friend was telling me that Random is sudo random.


r/shittyprogramming • • Mar 29 '16

Watch Paint Dry: How I got a game on the Steam Store without anyone from Valve ever looking at it.

Thumbnail
medium.com
238 Upvotes

r/shittyprogramming • • Jan 19 '16

Obfuscate your table names: it will prevent SQL infection!

238 Upvotes

Don't use obvious names for your database tables like 'users' or 'products'. This makes it easy for malicious users to enter things like ";DROP TABLE users" and drop your tabels. Instead make table names hard to guess by using the same strategies you should use for picking passwords:

  • Replace letters with numbers: 'us3rs', 'pr0ducts'

You can also prefix them with a salt: 'salt_us3rs', 'salt_pr0ducts'. This should secure any rainbow tables as well. This is really basic stuff and called security through obfuscatery. Take care!


r/shittyprogramming • • Aug 25 '15

Stop using MySQL!

238 Upvotes

It is mine, not yours!


r/shittyprogramming • • Oct 06 '18

Why you should never use getElementById() on YouTube.

Post image
237 Upvotes

r/shittyprogramming • • Dec 10 '17

I need to call the print() function in Python, what's the phone number?

237 Upvotes

r/shittyprogramming • • Apr 21 '15

<%=quality comments; --!> 9gag on programming languages...

Post image
237 Upvotes

r/shittyprogramming • • Apr 17 '15

Clever...

Post image
237 Upvotes

r/shittyprogramming • • Jun 15 '14

PSA: this is not /r/softwaregore/!

236 Upvotes

This sub is mainly for bad practices and downright stupidity in writing program source code. A bug is not a sign of shitty programming!

Thanks, and enjoy your stay


Hmm. As /u/ekolis rightly says, it's not /r/badcode/ either. Mods! Define the sub better! ;)


r/shittyprogramming • • Feb 16 '14

Always keep a counter for your infinite loop (House of Cards Season 2)

Post image
236 Upvotes

r/shittyprogramming • • Apr 01 '21

regex has better performance than math

Post image
235 Upvotes

r/shittyprogramming • • Nov 23 '16

PROOF that Python 3 is NOT Turing complete!!!

235 Upvotes

In computer science a fundamental law is that if I have one Turing Machine I can build any other Turing Machine. If I have COBOL then I can bootstrap a compiler for FORTRAN.... if I cannot create another Turing Machine in your language, then your language cannot be Turing Complete.

Currently you cannot run Python 2 inside the Python 3 virtual machine. Since I cannot, that means Python 3 is not Turing Complete and should not be used by anyone.

Source


r/shittyprogramming • • Jan 10 '16

I keep hearing "don't write your own crypto." Can someone here write it for me?

234 Upvotes

I'll then write yours for you. PM me, thx!


r/shittyprogramming • • Oct 06 '15

How to write more easily readable boolean functions

Post image
234 Upvotes

r/shittyprogramming • • Oct 01 '14

Password for online banking must be 6 characters

Thumbnail
imgur.com
234 Upvotes

r/shittyprogramming • • Feb 25 '15

How to get more code coverage

233 Upvotes

So this just happened at a Fortune 100 company that I contracted for...

When pushing to production a new requirement came down that unit tests needed to have 80% code coverage. This was a big issue, because unit tests weren't even part of the requirement let alone this much code coverage for such as large application.

So I throw up the red flag and say we have to delay the launch because apparently the 80% coverage is a "unchangeable automated check". To which the senior developer responds with the following:

"Oh don't worry about it - just add a 5000 line private function that just writes to the debug log, and call it with the unit test."

Now that is thinking outside the box. A shitty box.


r/shittyprogramming • • Sep 16 '14

super approved Hacker here. I found a way to crash any web server.

233 Upvotes
  1. Go into Internet Explorer or any of the lesser browsers

  2. Press F12

  3. Type the following into the console:

    document.title=document.title+' (Not Responding)';var el=document.createElement('div');el.setAttribute('style','cursor:wait;position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(255,255,255,.8);z-index:2147483647');document.body.appendChild(el);

Voila! Instant crash!


r/shittyprogramming • • Apr 20 '13

I simulated a vector field on an Intel CPU

Post image
233 Upvotes

r/shittyprogramming • • Dec 07 '20

Traveling salesmen problem solved in 0(1) time!

232 Upvotes

Right now, given a list of n destinations, the current solution for a traveling salesmen to visit each destination once without repeating roads is for the salesmen to not actually do that. There's covid out there, it's just irresponsible to go door to door. The solution is to just stay home.


r/shittyprogramming • • May 08 '18

why is the println function not working?

232 Upvotes

println(2.718) just prints 2.718 instead of 1. any ideas?