Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Gul Banana
Nov 28, 2003

what is desired_val even doing?

Adbot
ADBOT LOVES YOU

qntm
Jun 17, 2009
Good luck if desired_key happens to be an integer or a valid value in data.

Tesseraction
Apr 5, 2009

Gul Banana posted:

what is desired_val even doing?

I think it was intended to be returned if nothing else was, but then the 'programmer' forgot.

Every time I re-read the code something new pops out at me. So many bad things at once I can't see them all in a single viewing...

coaxmetal
Oct 21, 2010

I flamed me own dad

QuarkJets posted:

Python code:
def read_data(data, desired_key):
    if(isinstance(data, dict)):
        indexes = []
        i=0
        desired_val = "none"
        for key in data.iterkeys():
            indexes.append(i)
            indexes.append(key)
            indexes.append(data[key])
            i += 1
        for i in range(len(indexes)):
            if(indexes[i] == desired_key):
                return (indexes[i], indexes[i+1], indexes[i-1])

the real travesty here is that the list was named "indexes" instead of "indices".

shrughes
Oct 11, 2008

(call/cc call/cc)
I stopped reading at the weird overparenthesization.

Tesseraction
Apr 5, 2009

Ronald Raiden posted:

the real travesty here is that the list was named "indexes" instead of "indices".

That's just the icing on the cack.

QuarkJets
Sep 8, 2008

shrughes posted:

I stopped reading at the weird overparenthesization.

I only spot maybe 3 instances where dropping parentheses makes sense; two if statements that don't need them, and one more at the return. Although it's not like this hurts anything. There are a bunch of things wrong with this code, but using parentheses in an if statement isn't one of them

Tesseraction
Apr 5, 2009

In Python it's considered bad practice to use parenthesis for a 'simple' if statement. Just use the 'if' and ':' unless you need to specify ordering.

Personally I still add the brackets so non-Python programmers don't ask me about it when checking over my code.

e: removed typo

Tesseraction fucked around with this message at 23:05 on Jun 29, 2013

shrughes
Oct 11, 2008

(call/cc call/cc)

QuarkJets posted:

I only spot maybe 3 instances where dropping parentheses makes sense; two if statements that don't need them, and one more at the return. Although it's not like this hurts anything. There are a bunch of things wrong with this code, but using parentheses in an if statement isn't one of them

When judging somebody by their code you can just stop when you see the parenthesis style being weird. That the person who wrote this code is too mentally deficient to just let go of his way of doing things and follow the obvious Python standard is enough to categorize this as bad code.

QuarkJets
Sep 8, 2008

shrughes posted:

When judging somebody by their code you can just stop when you see the parenthesis style being weird. That the person who wrote this code is too mentally deficient to just let go of his way of doing things and follow the obvious Python standard is enough to categorize this as bad code.

I wouldn't call it "obvious"; PEP8 suggests wrapping long if statement expressions with parentheses, so it'd be easy for a new Python programmer to see an example of that, get confused and start putting parentheses in all of their if statements.

Again, this is probably the most inconsequential and minor complaint that you could possibly raise regarding that code

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Dirk Pitt posted:

I work with people who take this line of thinking to the extreme and say tests are a waste of time. According to some, the only way to test an app is manually. No mention of why we have had to issue a fix for 1500+ bugs in the first year this app has been in production.

It sounds like they're horrible at it, because the right way to take that line of thinking to an extreme is to write proofs that your code operates as specified. If they're not writing tests and not writing proofs, it sounds like they're lazy and looking for excuses to not write the "boring" code more than anything else.

(It's rather difficult to follow that development style for application code, but if instead you're building a well-specified library it's actually very worthwhile. I wouldn't recommend eschewing tests entirely, but proving your code to be correct is better than trying to catch every possible edge case in a test.)

Chin Strap
Nov 24, 2002

I failed my TFLC Toxx, but I no longer need a double chin strap :buddy:
Pillbug

Tesseraction posted:

I think they want to get the specific index of the key, which is pretty terrible as dict doesn't maintain order when built, so good job to that guy for not checking data structure implementations.

In our testing setup, dict order is intentionally shuffled every time a test is ran, so as to not rely on a fixed order for tests. I think it is a great idea.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Chin Strap posted:

In our testing setup, dict order is intentionally shuffled every time a test is ran, so as to not rely on a fixed order for tests. I think it is a great idea.

This is also the default in Python 3.3 and is optional in 2.7; the hash seed is randomized every time the interpreter is started.

fritz
Jul 26, 2003

Tesseraction posted:

In Python it's considered bad practice to use parenthesis for a 'simple' if statement. Just use the 'if' and ':' unless you need to specify ordering.

Personally I still add the brackets so non-Python programmers don't ask me about it when checking over my code.

e: removed typo

The parentheses in "if (condition): " aren't hurting anybody.

205b
Mar 25, 2007

I mean the parentheses are bad and all but he's searching a dictionary in linear time

Tesseraction
Apr 5, 2009

fritz posted:

The parentheses in "if (condition): " aren't hurting anybody.

Yep, I was just explaining shrughes' comment as not many people know about that particular element of the syntax. Bracketing the statement isn't a syntax error so many people don't necessarily know it's considered 'bad practice.'

ninepints posted:

I mean the parentheses are bad and all but he's searching a dictionary in linear time

This is definitely the issue of it.

It's a wonderful complement of misunderstanding of dictionaries, misuse of iteration and no understanding of the enumeration functions. Each issue is a fold on the errors previous.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Bunny Cuddlin posted:

So this MySQL bug has been open for seven years as of today and someone... well...

https://www.youtube.com/watch?v=oAiVsbXVP6k

im pretty sure that's max headroom

I think https://bugzilla.mozilla.org/show_bug.cgi?id=238041 deserves the same treatment.

PYF bugs that are older than all your friends' kids.

kitten smoothie
Dec 29, 2001

Munkeymon posted:

I think https://bugzilla.mozilla.org/show_bug.cgi?id=238041 deserves the same treatment.

PYF bugs that are older than all your friends' kids.

Things which have happened during the timeframe that this bug has been open

- We have seen two Papal elections, three Presidential elections, and four new members of the Supreme Court
- The Red Sox broke their curse
- Hurricanes Katrina and Sandy
- The Space Shuttle program was reinstated, and then terminated
- The iPhone (hell, six iPhones)
- Steve Jobs came out that he had cancer, had surgery, had more surgery several years later, then died
- Duke Nukem Forever shipped

qntm
Jun 17, 2009

Munkeymon posted:

I think https://bugzilla.mozilla.org/show_bug.cgi?id=238041 deserves the same treatment.

PYF bugs that are older than all your friends' kids.

Does Eclipse have text wrap yet?

1337JiveTurkey
Feb 17, 2005

From sun.misc.FloatingDecimal:

code:
 
          /*
             * Construct, Scale, iterate.
             * Some day, we'll write a stopping test that takes
             * account of the asymmetry of the spacing of floating-point
             * numbers below perfect powers of 2
             * 26 Sept 96 is not that day.
             * So we use a symmetric test.
             */

McGlockenshire
Dec 16, 2005

GOLLOCKS!

1337JiveTurkey posted:

From sun.misc.FloatingDecimal:

code:
 
          /*
             * Construct, Scale, iterate.
             * Some day, we'll write a stopping test that takes
             * account of the asymmetry of the spacing of floating-point
             * numbers below perfect powers of 2
             * 26 Sept 96 is not that day.
             * So we use a symmetric test.
             */

That code will be old enough to vote in next year's mid-term elections.

I think I have a new example to explain technical debt...

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
I give you,

Coding Horrors: The Movie
https://www.youtube.com/watch?v=THERgYM8gBM

:stare:


I lost my poo poo at "...Batman!" :lol:

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
My stack trace :qq:
code:
2013-07-02 19:37:36,482 WARN http-thread-pool-38080(11) javax.enterprise.system.container.web.com.sun.enterprise.web._vs.server - StandardWrapperValve[DownloadMetadataServlet]: PWC1406: Servlet.service() for servlet DownloadMetadataServlet threw exception
java.lang.NullPointerException
	at com.sun.enterprise.v3.services.impl.monitor.MonitorableSelectionKeyHandler$CloseHandler.notifyClosed(MonitorableSelectionKeyHandler.java:94)
	at com.sun.enterprise.v3.services.impl.monitor.MonitorableSelectionKeyHandler$CloseHandler.remotlyClosed(MonitorableSelectionKeyHandler.java:90)
	at com.sun.grizzly.BaseSelectionKeyHandler.notifyRemotlyClose(BaseSelectionKeyHandler.java:233)
	at com.sun.grizzly.util.OutputWriter.notifyRemotelyClosed(OutputWriter.java:353)
	at com.sun.grizzly.util.OutputWriter.flushChannel(OutputWriter.java:148)
	at com.sun.grizzly.util.OutputWriter.flushChannel(OutputWriter.java:76)
	at com.sun.grizzly.http.SocketChannelOutputBuffer.flushChannel(SocketChannelOutputBuffer.java:326)
	at com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:398)
	at com.sun.grizzly.http.SocketChannelOutputBuffer.realWriteBytes(SocketChannelOutputBuffer.java:282)
	at com.sun.grizzly.tcp.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:898)
	at com.sun.grizzly.tcp.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:167)
	at com.sun.grizzly.tcp.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:658)
	at com.sun.grizzly.tcp.Response.doWrite(Response.java:685)
	at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:422)
	at com.sun.grizzly.util.buf.ByteChunk.append(ByteChunk.java:380)
	at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:452)
	at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:439)
	at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:160)
	at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:155)
	at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:112)
	at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:72)
	at java.io.DataOutputStream.write(DataOutputStream.java:90)
	at com.google.protobuf.CodedOutputStream.writeRawBytes(CodedOutputStream.java:954)
	at com.google.protobuf.CodedOutputStream.writeRawBytes(CodedOutputStream.java:875)
	at com.google.protobuf.CodedOutputStream.writeBytesNoTag(CodedOutputStream.java:386)
	at com.google.protobuf.CodedOutputStream.writeBytes(CodedOutputStream.java:229)
	at my.company.sync.DownloadMetadata$TaggedBinary.writeTo(DownloadMetadata.java:1216)
	at com.google.protobuf.CodedOutputStream.writeMessageNoTag(CodedOutputStream.java:380)
	at com.google.protobuf.CodedOutputStream.writeMessage(CodedOutputStream.java:222)
	at my.company.sync.DownloadMetadata$News.writeTo(DownloadMetadata.java:3728)
	at com.google.protobuf.CodedOutputStream.writeMessageNoTag(CodedOutputStream.java:380)
	at com.google.protobuf.CodedOutputStream.writeMessage(CodedOutputStream.java:222)
	at my.company.sync.DownloadMetadata$PublishedItemResponse.writeTo(DownloadMetadata.java:6457)
	at com.google.protobuf.AbstractMessageLite.writeDelimitedTo(AbstractMessageLite.java:90)
	at my.company.sync.Serializer.writeMessages(Serializer.java:43)
	at my.company.servlets.DownloadMetadataServlet.processRequest(DownloadMetadataServlet.java:70)
	at my.company.servlets.DownloadMetadataServlet.doPost(DownloadMetadataServlet.java:116)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
	at java.lang.Thread.run(Thread.java:662)

Less Fat Luke
May 23, 2003

Exciting Lemon

Zaphod42 posted:

I give you,

Coding Horrors: The Movie
https://www.youtube.com/watch?v=THERgYM8gBM

:stare:


I lost my poo poo at "...Batman!" :lol:
What the gently caress JavaScript.

shrughes
Oct 11, 2008

(call/cc call/cc)
http://codex.wordpress.org/Updating_WordPress

shrughes
Oct 11, 2008

(call/cc call/cc)

Zaphod42 posted:

I give you,

Coding Horrors: The Movie
https://www.youtube.com/watch?v=THERgYM8gBM

:stare:


I lost my poo poo at "...Batman!" :lol:

Why am I not surprised the man talking about Ruby is a smug condescending little poo poo?

No Safe Word
Feb 26, 2005

shrughes posted:

Why am I not surprised the man talking about Ruby is a smug condescending little poo poo?

:ironicat: x 1000

And none of it is really condescending anyway it's just pointing out goofy unexpected behaviors without any context because it's a goofy five minute lightning talk

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

shrughes posted:

Why am I not surprised the man talking about Ruby is a smug condescending little poo poo?

Nice!

nuvan
Mar 29, 2008

And the gentle call of the feral 3am "Everything is going so well you can't help but panic."

Zaphod42 posted:

I give you,

Coding Horrors: The Movie
https://www.youtube.com/watch?v=THERgYM8gBM

:stare:


I lost my poo poo at "...Batman!" :lol:

For anyone who is curious why the javascript stuff happens the way it does, there's an explanation here

RICHUNCLEPENNYBAGS
Dec 21, 2010

I always get a giggle out of this one: http://codex.wordpress.org/Editing_wp-config.php

"Please, do not edit this Codex Page with the settings for your own server as you are giving the world access to your website's MySQL password, and will not make your install work. Thanks."

e: So I actually looked at that and gee, that's a really bad idea. There are a number of plugins, if I recall, that do stuff requiring access to the filesystem by using ssh, why not use that?

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

RICHUNCLEPENNYBAGS posted:

I always get a giggle out of this one: http://codex.wordpress.org/Editing_wp-config.php

"Please, do not edit this Codex Page with the settings for your own server as you are giving the world access to your website's MySQL password, and will not make your install work. Thanks."
http://codex.wordpress.org/index.php?title=Editing_wp-config.php&limit=500&action=history :allears:
(search for 'Reverted' and hit Prev to see what they're reverting, which seems to usually be credentials)
http://codex.wordpress.org/index.php?title=Editing_wp-config.php&diff=102567&oldid=102561

geonetix
Mar 6, 2011


Munkeymon posted:

PYF bugs that are older than all your friends' kids.

This one is absolutely amazing: Firefox can't position scrollbars properly in textareas. I've ran into it so often, and there's simply no solution other than having no padding in textareas for firefox users.

qntm
Jun 17, 2009

geonetix posted:

This one is absolutely amazing: Firefox can't position scrollbars properly in textareas. I've ran into it so often, and there's simply no solution other than having no padding in textareas for firefox users.

The best part is people appear to have been actively working on this bug for about a year now, with no resolution.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

RICHUNCLEPENNYBAGS posted:

So I actually looked at that and gee, that's a really bad idea. There are a number of plugins, if I recall, that do stuff requiring access to the filesystem by using ssh, why not use that?
A large number of people run wordpress on bad shared hosts that don't give ssh access.

seiken
Feb 7, 2005

hah ha ha
LoseThos is now TempleOS and has an incredible video on the front page.

Dietrich
Sep 11, 2001

seiken posted:

LoseThos is now TempleOS and has an incredible video on the front page.

That website confuses and scares me.

Jewel
May 2, 2009

I can't find a single thing that isn't wrong with that site and that video and that OS.

And oh my god that bird. That bird. :gonk:

Edit: "And he walks the wrong way. I'unno why I did that.... H-hheh hehh I'm not a pedophile hheh!" :stare:

Jewel fucked around with this message at 16:07 on Jul 3, 2013

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

seiken posted:

LoseThos is now TempleOS and has an incredible video on the front page.

This is part of the Half-Life 3 ARG, I'm sure of it.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
When I show people projects like my VM I often wonder if I come across like the LoseThos guy. :smith:

Adbot
ADBOT LOVES YOU

seiken
Feb 7, 2005

hah ha ha
God likes six-forty by four-eighty because it's good for children doing art.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply